blob: 0c3e64984dcd0a92eb1dc569bf59e6e33b61095e [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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'Connorabafb502014-12-02 22:26:20 -080018import org.onosproject.store.Store;
Brian O'Connor66630c82014-10-02 21:08:19 -070019
toma1d16b62014-10-02 23:45:11 -070020import java.util.List;
21
Brian O'Connor66630c82014-10-02 21:08:19 -070022/**
23 * Manages inventory of end-station intents; not intended for direct use.
24 */
25public interface IntentStore extends Store<IntentEvent, IntentStoreDelegate> {
26
27 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070028 * Returns the number of intents in the store.
Toshio Koided32809b2014-10-09 10:58:54 -070029 *
30 * @return the number of intents in the store
Brian O'Connor66630c82014-10-02 21:08:19 -070031 */
32 long getIntentCount();
33
34 /**
Brian O'Connor3c58e962015-04-28 23:21:51 -070035 * Returns an iterable of all intents in the store.
Brian O'Connor66630c82014-10-02 21:08:19 -070036 *
Brian O'Connor3c58e962015-04-28 23:21:51 -070037 * @return iterable of all intents
Brian O'Connor66630c82014-10-02 21:08:19 -070038 */
39 Iterable<Intent> getIntents();
40
Brian O'Connor3c58e962015-04-28 23:21:51 -070041
42 /**
43 * Returns an iterable of all intent data objects in the store.
44 *
45 * @param localOnly should only intents for which this instance is master
Brian O'Connora6c9b5c2015-04-29 22:38:29 -070046 * be returned
47 * @param olderThan specified duration in milliseconds (0 for "now")
Brian O'Connor3c58e962015-04-28 23:21:51 -070048 * @return iterable of all intent data objects
49 */
Brian O'Connora6c9b5c2015-04-29 22:38:29 -070050 Iterable<IntentData> getIntentData(boolean localOnly, long olderThan);
Brian O'Connor3c58e962015-04-28 23:21:51 -070051
Brian O'Connor66630c82014-10-02 21:08:19 -070052 /**
toma1d16b62014-10-02 23:45:11 -070053 * Returns the state of the specified intent.
54 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080055 * @param intentKey intent identification
toma1d16b62014-10-02 23:45:11 -070056 * @return current intent state
57 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080058 IntentState getIntentState(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070059
60 /**
toma1d16b62014-10-02 23:45:11 -070061 * Returns the list of the installable events associated with the specified
62 * original intent.
63 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080064 * @param intentKey original intent identifier
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080065 * @return compiled installable intents, or null if no installables exist
toma1d16b62014-10-02 23:45:11 -070066 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080067 List<Intent> getInstallableIntents(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070068
toma1d16b62014-10-02 23:45:11 -070069 /**
Jonathan Hart2085e072015-02-12 11:44:03 -080070 * Writes an IntentData object to the store.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080071 *
Jonathan Hart2085e072015-02-12 11:44:03 -080072 * @param newData new intent data to write
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080073 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080074 void write(IntentData newData);
Jonathan Hart2085e072015-02-12 11:44:03 -080075
76 /**
77 * Writes a batch of IntentData objects to the store. A batch has no
78 * semantics, this is simply a convenience API.
79 *
80 * @param updates collection of intent data objects to write
81 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080082 void batchWrite(Iterable<IntentData> updates);
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080083
Brian O'Connorea4d7d12015-01-28 16:37:46 -080084 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080085 * Returns the intent with the specified identifier.
86 *
87 * @param key key
88 * @return intent or null if not found
89 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080090 Intent getIntent(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -080091
92 /**
93 * Returns the intent data object associated with the specified key.
94 *
95 * @param key key to look up
96 * @return intent data object
97 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080098 IntentData getIntentData(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -080099
100 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800101 * Adds a new operation, which should be persisted and delegated.
102 *
Brian O'Connorcff03322015-02-03 15:28:59 -0800103 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800104 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800105 void addPending(IntentData intent);
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800106
107 /**
108 * Checks to see whether the calling instance is the master for processing
109 * this intent, or more specifically, the key contained in this intent.
110 *
Brian O'Connorbe28a872015-02-19 21:44:37 -0800111 * @param intentKey intentKey to check
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800112 * @return true if master; false, otherwise
113 */
114 //TODO better name
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800115 boolean isMaster(Key intentKey);
Jonathan Hart34f1e382015-02-24 16:52:23 -0800116
117 /**
118 * Returns the intent requests pending processing.
119 *
120 * @return pending intents
121 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800122 Iterable<Intent> getPending();
Brian O'Connora6c9b5c2015-04-29 22:38:29 -0700123
124 /**
125 * Returns the intent data objects that are pending processing.
126 *
127 * @return pending intent data objects
128 */
129 Iterable<IntentData> getPendingData();
130
131 /**
132 * Returns the intent data objects that are pending processing for longer
133 * than the specified duration.
134 *
135 * @param localOnly should only intents for which this instance is master
136 * be returned
137 * @param olderThan specified duration in milliseconds (0 for "now")
138 * @return pending intent data objects
139 */
140 Iterable<IntentData> getPendingData(boolean localOnly, long olderThan);
Brian O'Connor66630c82014-10-02 21:08:19 -0700141}