blob: 87e786c904d59c99747da534013dae39e29d0cc7 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Brian O'Connor66630c82014-10-02 21:08:19 -070017
Sho SHIMIZU64ae11c2014-12-03 15:17:47 -080018import org.onosproject.net.intent.BatchWrite.Operation;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.store.Store;
Brian O'Connor66630c82014-10-02 21:08:19 -070020
toma1d16b62014-10-02 23:45:11 -070021import java.util.List;
22
Brian O'Connor66630c82014-10-02 21:08:19 -070023/**
24 * Manages inventory of end-station intents; not intended for direct use.
25 */
26public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
27
28 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070029 * Returns the number of intents in the store.
Toshio Koided32809b2014-10-09 10:58:54 -070030 *
31 * @return the number of intents in the store
Brian O'Connor66630c82014-10-02 21:08:19 -070032 */
33 long getIntentCount();
34
35 /**
36 * Returns a collection of all intents in the store.
37 *
38 * @return iterable collection of all intents
39 */
40 Iterable<Intent> getIntents();
41
42 /**
Toshio Koided32809b2014-10-09 10:58:54 -070043 * Returns the intent with the specified identifier.
Brian O'Connor66630c82014-10-02 21:08:19 -070044 *
45 * @param intentId intent identification
46 * @return intent or null if not found
47 */
Brian O'Connorb499b352015-02-03 16:46:15 -080048 @Deprecated
Brian O'Connor03406a42015-02-03 17:28:57 -080049 default Intent getIntent(IntentId intentId) {
50 throw new UnsupportedOperationException("deprecated");
Sho SHIMIZU4931ee52015-02-03 21:09:28 -080051 }
Brian O'Connor66630c82014-10-02 21:08:19 -070052
toma1d16b62014-10-02 23:45:11 -070053 /**
54 * Returns the state of the specified intent.
55 *
56 * @param intentId intent identification
57 * @return current intent state
58 */
Brian O'Connorb499b352015-02-03 16:46:15 -080059 @Deprecated
Brian O'Connor03406a42015-02-03 17:28:57 -080060 default IntentState getIntentState(IntentId intentId) {
61 throw new UnsupportedOperationException("deprecated");
62 }
Brian O'Connor66630c82014-10-02 21:08:19 -070063
64 /**
toma1d16b62014-10-02 23:45:11 -070065 * Returns the list of the installable events associated with the specified
66 * original intent.
67 *
68 * @param intentId original intent identifier
69 * @return compiled installable intents
70 */
Brian O'Connorb499b352015-02-03 16:46:15 -080071 @Deprecated
Brian O'Connor03406a42015-02-03 17:28:57 -080072 default List<Intent> getInstallableIntents(IntentId intentId) {
73 throw new UnsupportedOperationException("deprecated");
74 }
Brian O'Connor66630c82014-10-02 21:08:19 -070075
toma1d16b62014-10-02 23:45:11 -070076 /**
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080077 * Execute writes in a batch.
Sho SHIMIZU2bb988b2015-01-20 13:45:35 -080078 * If the specified BatchWrite is empty, write will not be executed.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080079 *
80 * @param batch BatchWrite to execute
81 * @return failed operations
82 */
Brian O'Connor03406a42015-02-03 17:28:57 -080083 @Deprecated
Sho SHIMIZU4c464fb2014-12-03 15:12:21 -080084 List<Operation> batchWrite(BatchWrite batch);
Brian O'Connor03406a42015-02-03 17:28:57 -080085 default void write(IntentData newData) {}
86 default void batchWrite(Iterable<IntentData> updates) {}
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080087
Brian O'Connorea4d7d12015-01-28 16:37:46 -080088 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080089 * Returns the intent with the specified identifier.
90 *
91 * @param key key
92 * @return intent or null if not found
93 */
94 default Intent getIntent(String key) { //FIXME remove when impl.
95 return null;
96 }
97
98 /**
99 * Returns the intent data object associated with the specified key.
100 *
101 * @param key key to look up
102 * @return intent data object
103 */
104 default IntentData getIntentData(String key) { //FIXME remove when impl.
105 return null;
106 }
107
108 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800109 * Adds a new operation, which should be persisted and delegated.
110 *
Brian O'Connorcff03322015-02-03 15:28:59 -0800111 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800112 */
Brian O'Connorcff03322015-02-03 15:28:59 -0800113 default void addPending(IntentData intent) {} //FIXME remove when impl.
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800114
115 /**
116 * Checks to see whether the calling instance is the master for processing
117 * this intent, or more specifically, the key contained in this intent.
118 *
119 * @param intent intent to check
120 * @return true if master; false, otherwise
121 */
122 //TODO better name
123 default boolean isMaster(Intent intent) { //FIXME remove default when impl.
124 return true;
125 }
Brian O'Connor66630c82014-10-02 21:08:19 -0700126}