blob: bf3f32f1a1da718f3f1bd540707662666ba0a8e2 [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 /**
35 * Returns a collection of all intents in the store.
36 *
37 * @return iterable collection of all intents
38 */
39 Iterable<Intent> getIntents();
40
41 /**
toma1d16b62014-10-02 23:45:11 -070042 * Returns the state of the specified intent.
43 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080044 * @param intentKey intent identification
toma1d16b62014-10-02 23:45:11 -070045 * @return current intent state
46 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080047 IntentState getIntentState(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070048
49 /**
toma1d16b62014-10-02 23:45:11 -070050 * Returns the list of the installable events associated with the specified
51 * original intent.
52 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080053 * @param intentKey original intent identifier
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080054 * @return compiled installable intents, or null if no installables exist
toma1d16b62014-10-02 23:45:11 -070055 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080056 List<Intent> getInstallableIntents(Key intentKey);
Brian O'Connor66630c82014-10-02 21:08:19 -070057
toma1d16b62014-10-02 23:45:11 -070058 /**
Jonathan Hart2085e072015-02-12 11:44:03 -080059 * Writes an IntentData object to the store.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080060 *
Jonathan Hart2085e072015-02-12 11:44:03 -080061 * @param newData new intent data to write
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080062 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080063 void write(IntentData newData);
Jonathan Hart2085e072015-02-12 11:44:03 -080064
65 /**
66 * Writes a batch of IntentData objects to the store. A batch has no
67 * semantics, this is simply a convenience API.
68 *
69 * @param updates collection of intent data objects to write
70 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080071 void batchWrite(Iterable<IntentData> updates);
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080072
Brian O'Connorea4d7d12015-01-28 16:37:46 -080073 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080074 * Returns the intent with the specified identifier.
75 *
76 * @param key key
77 * @return intent or null if not found
78 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080079 Intent getIntent(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -080080
81 /**
82 * Returns the intent data object associated with the specified key.
83 *
84 * @param key key to look up
85 * @return intent data object
86 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080087 IntentData getIntentData(Key key);
Brian O'Connorb499b352015-02-03 16:46:15 -080088
89 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -080090 * Adds a new operation, which should be persisted and delegated.
91 *
Brian O'Connorcff03322015-02-03 15:28:59 -080092 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -080093 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -080094 void addPending(IntentData intent);
Brian O'Connorea4d7d12015-01-28 16:37:46 -080095
96 /**
97 * Checks to see whether the calling instance is the master for processing
98 * this intent, or more specifically, the key contained in this intent.
99 *
Brian O'Connorbe28a872015-02-19 21:44:37 -0800100 * @param intentKey intentKey to check
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800101 * @return true if master; false, otherwise
102 */
103 //TODO better name
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800104 boolean isMaster(Key intentKey);
Jonathan Hart34f1e382015-02-24 16:52:23 -0800105
106 /**
107 * Returns the intent requests pending processing.
108 *
109 * @return pending intents
110 */
Jonathan Hart6a8fd1d2015-02-25 15:44:37 -0800111 Iterable<Intent> getPending();
Brian O'Connor66630c82014-10-02 21:08:19 -0700112}