blob: a7c751564749221ce329ace358b25d345480dfb3 [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
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 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080047 default IntentState getIntentState(Key intentKey) {
48 return null;
Brian O'Connor03406a42015-02-03 17:28:57 -080049 }
Brian O'Connor66630c82014-10-02 21:08:19 -070050
51 /**
toma1d16b62014-10-02 23:45:11 -070052 * Returns the list of the installable events associated with the specified
53 * original intent.
54 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080055 * @param intentKey original intent identifier
toma1d16b62014-10-02 23:45:11 -070056 * @return compiled installable intents
57 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080058 default List<Intent> getInstallableIntents(Key intentKey) {
59 throw new UnsupportedOperationException("getInstallableIntents()");
Brian O'Connor03406a42015-02-03 17:28:57 -080060 }
Brian O'Connor66630c82014-10-02 21:08:19 -070061
toma1d16b62014-10-02 23:45:11 -070062 /**
Jonathan Hart2085e072015-02-12 11:44:03 -080063 * Writes an IntentData object to the store.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080064 *
Jonathan Hart2085e072015-02-12 11:44:03 -080065 * @param newData new intent data to write
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080066 */
Brian O'Connor03406a42015-02-03 17:28:57 -080067 default void write(IntentData newData) {}
Jonathan Hart2085e072015-02-12 11:44:03 -080068
69 /**
70 * Writes a batch of IntentData objects to the store. A batch has no
71 * semantics, this is simply a convenience API.
72 *
73 * @param updates collection of intent data objects to write
74 */
Brian O'Connor03406a42015-02-03 17:28:57 -080075 default void batchWrite(Iterable<IntentData> updates) {}
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080076
Brian O'Connorea4d7d12015-01-28 16:37:46 -080077 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080078 * Returns the intent with the specified identifier.
79 *
80 * @param key key
81 * @return intent or null if not found
82 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080083 default Intent getIntent(Key key) {
84 // FIXME remove this default implementation when all stores have implemented it
Brian O'Connorb499b352015-02-03 16:46:15 -080085 return null;
86 }
87
88 /**
89 * Returns the intent data object associated with the specified key.
90 *
91 * @param key key to look up
92 * @return intent data object
93 */
Ray Milkey5b3717e2015-02-05 11:44:08 -080094 default IntentData getIntentData(Key key) { //FIXME remove when impl.
Brian O'Connorb499b352015-02-03 16:46:15 -080095 return null;
96 }
97
98 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -080099 * Adds a new operation, which should be persisted and delegated.
100 *
Brian O'Connorcff03322015-02-03 15:28:59 -0800101 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800102 */
Brian O'Connorcff03322015-02-03 15:28:59 -0800103 default void addPending(IntentData intent) {} //FIXME remove when impl.
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800104
105 /**
106 * Checks to see whether the calling instance is the master for processing
107 * this intent, or more specifically, the key contained in this intent.
108 *
Brian O'Connorbe28a872015-02-19 21:44:37 -0800109 * @param intentKey intentKey to check
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800110 * @return true if master; false, otherwise
111 */
112 //TODO better name
Brian O'Connorbe28a872015-02-19 21:44:37 -0800113 default boolean isMaster(Key intentKey) { //FIXME remove default when impl.
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800114 return true;
115 }
Brian O'Connor66630c82014-10-02 21:08:19 -0700116}