blob: 6c0dff438986451682731b21a8ff65bcab35ad51 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present 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
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
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 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040026@Beta
Brian O'Connor66630c82014-10-02 21:08:19 -070027public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
28
29 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070030 * Returns the number of intents in the store.
Toshio Koided32809b2014-10-09 10:58:54 -070031 *
32 * @return the number of intents in the store
Brian O'Connor66630c82014-10-02 21:08:19 -070033 */
34 long getIntentCount();
35
36 /**
Brian O'Connor3c58e962015-04-28 23:21:51 -070037 * Returns an iterable of all intents in the store.
Brian O'Connor66630c82014-10-02 21:08:19 -070038 *
Brian O'Connor3c58e962015-04-28 23:21:51 -070039 * @return iterable of all intents
Brian O'Connor66630c82014-10-02 21:08:19 -070040 */
41 Iterable<Intent> getIntents();
42
Brian O'Connor3c58e962015-04-28 23:21:51 -070043
44 /**
45 * Returns an iterable of all intent data objects in the store.
46 *
47 * @param localOnly should only intents for which this instance is master
Brian O'Connora6c9b5c2015-04-29 22:38:29 -070048 * be returned
49 * @param olderThan specified duration in milliseconds (0 for "now")
Brian O'Connor3c58e962015-04-28 23:21:51 -070050 * @return iterable of all intent data objects
51 */
Brian O'Connora6c9b5c2015-04-29 22:38:29 -070052 Iterable<IntentData> getIntentData(boolean localOnly, long olderThan);
Brian O'Connor3c58e962015-04-28 23:21:51 -070053
Brian O'Connor66630c82014-10-02 21:08:19 -070054 /**
toma1d16b62014-10-02 23:45:11 -070055 * Returns the state of the specified intent.
56 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080057 * @param intentKey intent identification
toma1d16b62014-10-02 23:45:11 -070058 * @return current intent state
59 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080060 IntentState getIntentState(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070061
62 /**
toma1d16b62014-10-02 23:45:11 -070063 * Returns the list of the installable events associated with the specified
64 * original intent.
65 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080066 * @param intentKey original intent identifier
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080067 * @return compiled installable intents, or null if no installables exist
toma1d16b62014-10-02 23:45:11 -070068 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080069 List<Intent> getInstallableIntents(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070070
toma1d16b62014-10-02 23:45:11 -070071 /**
Jonathan Hart2085e072015-02-12 11:44:03 -080072 * Writes an IntentData object to the store.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080073 *
Jonathan Hart2085e072015-02-12 11:44:03 -080074 * @param newData new intent data to write
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080075 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080076 void write(IntentData newData);
Jonathan Hart2085e072015-02-12 11:44:03 -080077
78 /**
79 * Writes a batch of IntentData objects to the store. A batch has no
80 * semantics, this is simply a convenience API.
81 *
82 * @param updates collection of intent data objects to write
83 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080084 void batchWrite(Iterable<IntentData> updates);
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080085
Brian O'Connorea4d7d12015-01-28 16:37:46 -080086 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080087 * Returns the intent with the specified identifier.
88 *
89 * @param key key
90 * @return intent or null if not found
91 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080092 Intent getIntent(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -080093
94 /**
95 * Returns the intent data object associated with the specified key.
96 *
97 * @param key key to look up
98 * @return intent data object
99 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800100 IntentData getIntentData(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -0800101
102 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800103 * Adds a new operation, which should be persisted and delegated.
104 *
Brian O'Connorcff03322015-02-03 15:28:59 -0800105 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800106 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800107 void addPending(IntentData intent);
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800108
109 /**
110 * Checks to see whether the calling instance is the master for processing
111 * this intent, or more specifically, the key contained in this intent.
112 *
Brian O'Connorbe28a872015-02-19 21:44:37 -0800113 * @param intentKey intentKey to check
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800114 * @return true if master; false, otherwise
115 */
116 //TODO better name
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800117 boolean isMaster(Key intentKey);
Jonathan Hart34f1e382015-02-24 16:52:23 -0800118
119 /**
120 * Returns the intent requests pending processing.
121 *
122 * @return pending intents
123 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800124 Iterable<Intent> getPending();
Brian O'Connora6c9b5c2015-04-29 22:38:29 -0700125
126 /**
127 * Returns the intent data objects that are pending processing.
128 *
129 * @return pending intent data objects
130 */
131 Iterable<IntentData> getPendingData();
132
133 /**
Brian O'Connorc590ebb2016-12-08 18:16:41 -0800134 * Returns the intent data object that are pending processing for a specfied
135 * key.
136 *
137 * @param intentKey key to look up
138 * @return pending intent data object
139 */
140 IntentData getPendingData(Key intentKey);
141
142 /**
Brian O'Connora6c9b5c2015-04-29 22:38:29 -0700143 * Returns the intent data objects that are pending processing for longer
144 * than the specified duration.
145 *
146 * @param localOnly should only intents for which this instance is master
147 * be returned
148 * @param olderThan specified duration in milliseconds (0 for "now")
149 * @return pending intent data objects
150 */
151 Iterable<IntentData> getPendingData(boolean localOnly, long olderThan);
Brian O'Connor66630c82014-10-02 21:08:19 -0700152}