blob: d8e63df27a3856ff724bde2829f03d92d585a9a3 [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
Jonathan Hart34f1e382015-02-24 16:52:23 -080020import java.util.Collections;
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 /**
toma1d16b62014-10-02 23:45:11 -070043 * Returns the state of the specified intent.
44 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080045 * @param intentKey intent identification
toma1d16b62014-10-02 23:45:11 -070046 * @return current intent state
47 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080048 default IntentState getIntentState(Key intentKey) {
49 return null;
Brian O'Connor03406a42015-02-03 17:28:57 -080050 }
Brian O'Connor66630c82014-10-02 21:08:19 -070051
52 /**
toma1d16b62014-10-02 23:45:11 -070053 * Returns the list of the installable events associated with the specified
54 * original intent.
55 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -080056 * @param intentKey original intent identifier
toma1d16b62014-10-02 23:45:11 -070057 * @return compiled installable intents
58 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080059 default List<Intent> getInstallableIntents(Key intentKey) {
60 throw new UnsupportedOperationException("getInstallableIntents()");
Brian O'Connor03406a42015-02-03 17:28:57 -080061 }
Brian O'Connor66630c82014-10-02 21:08:19 -070062
toma1d16b62014-10-02 23:45:11 -070063 /**
Jonathan Hart2085e072015-02-12 11:44:03 -080064 * Writes an IntentData object to the store.
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080065 *
Jonathan Hart2085e072015-02-12 11:44:03 -080066 * @param newData new intent data to write
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080067 */
Brian O'Connor03406a42015-02-03 17:28:57 -080068 default void write(IntentData newData) {}
Jonathan Hart2085e072015-02-12 11:44:03 -080069
70 /**
71 * Writes a batch of IntentData objects to the store. A batch has no
72 * semantics, this is simply a convenience API.
73 *
74 * @param updates collection of intent data objects to write
75 */
Brian O'Connor03406a42015-02-03 17:28:57 -080076 default void batchWrite(Iterable<IntentData> updates) {}
Yuta HIGUCHIa94c6e82014-11-28 18:49:54 -080077
Brian O'Connorea4d7d12015-01-28 16:37:46 -080078 /**
Brian O'Connorb499b352015-02-03 16:46:15 -080079 * Returns the intent with the specified identifier.
80 *
81 * @param key key
82 * @return intent or null if not found
83 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -080084 default Intent getIntent(Key key) {
85 // FIXME remove this default implementation when all stores have implemented it
Brian O'Connorb499b352015-02-03 16:46:15 -080086 return null;
87 }
88
89 /**
90 * Returns the intent data object associated with the specified key.
91 *
92 * @param key key to look up
93 * @return intent data object
94 */
Ray Milkey5b3717e2015-02-05 11:44:08 -080095 default IntentData getIntentData(Key key) { //FIXME remove when impl.
Brian O'Connorb499b352015-02-03 16:46:15 -080096 return null;
97 }
98
99 /**
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800100 * Adds a new operation, which should be persisted and delegated.
101 *
Brian O'Connorcff03322015-02-03 15:28:59 -0800102 * @param intent operation
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800103 */
Brian O'Connorcff03322015-02-03 15:28:59 -0800104 default void addPending(IntentData intent) {} //FIXME remove when impl.
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800105
106 /**
107 * Checks to see whether the calling instance is the master for processing
108 * this intent, or more specifically, the key contained in this intent.
109 *
Brian O'Connorbe28a872015-02-19 21:44:37 -0800110 * @param intentKey intentKey to check
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800111 * @return true if master; false, otherwise
112 */
113 //TODO better name
Brian O'Connorbe28a872015-02-19 21:44:37 -0800114 default boolean isMaster(Key intentKey) { //FIXME remove default when impl.
Brian O'Connorea4d7d12015-01-28 16:37:46 -0800115 return true;
116 }
Jonathan Hart34f1e382015-02-24 16:52:23 -0800117
118 /**
119 * Returns the intent requests pending processing.
120 *
121 * @return pending intents
122 */
123 // FIXME remove default
124 default Iterable<Intent> getPending() {
125 return Collections.emptyList();
126 }
Brian O'Connor66630c82014-10-02 21:08:19 -0700127}