blob: d8143bdbeb9e2a59de66dacbd477bda25d9dfab9 [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'Connorb876bf12014-10-02 14:59:37 -070017
Brian O'Connorb876bf12014-10-02 14:59:37 -070018
Brian O'Connor9476fa12015-06-25 15:17:17 -040019import com.google.common.annotations.Beta;
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070020import org.onosproject.event.ListenerService;
Brian O'Connor9476fa12015-06-25 15:17:17 -040021
Thomas Vachuska10d4abc2014-10-21 12:47:26 -070022import java.util.List;
23
Brian O'Connorb876bf12014-10-02 14:59:37 -070024/**
25 * Service for application submitting or withdrawing their intents.
26 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040027@Beta
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070028public interface IntentService
29 extends ListenerService<IntentEvent, IntentListener> {
30
Brian O'Connorb876bf12014-10-02 14:59:37 -070031 /**
32 * Submits an intent into the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070033 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070034 * This is an asynchronous request meaning that any compiling or
35 * installation activities may be done at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070036 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070037 * @param intent intent to be submitted
38 */
39 void submit(Intent intent);
40
41 /**
42 * Withdraws an intent from the system.
Thomas Vachuska4b420772014-10-30 16:46:17 -070043 * <p>
Brian O'Connor66630c82014-10-02 21:08:19 -070044 * This is an asynchronous request meaning that the environment may be
45 * affected at later time.
Thomas Vachuska4b420772014-10-30 16:46:17 -070046 * </p>
Brian O'Connorb876bf12014-10-02 14:59:37 -070047 * @param intent intent to be withdrawn
48 */
49 void withdraw(Intent intent);
50
Thomas Vachuska83e090e2014-10-22 14:25:35 -070051 /**
Ray Milkey8c6d00e2015-03-13 14:14:34 -070052 * Purges a specific intent from the system if it is <b>FAILED</b> or
53 * <b>WITHDRAWN</b>. Otherwise, the intent remains in its current state.
54 *
55 * @param intent intent to purge
56 */
57 void purge(Intent intent);
58
59 /**
Ray Milkeyf9af43c2015-02-09 16:45:48 -080060 * Fetches an intent based on its key.
61 *
62 * @param key key of the intent
63 * @return intent object if the key is found, null otherwise
64 */
Brian O'Connorf2114992015-03-17 16:03:14 -070065 Intent getIntent(Key key);
Ray Milkeyf9af43c2015-02-09 16:45:48 -080066
67 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070068 * Returns an iterable of intents currently in the system.
Brian O'Connorb876bf12014-10-02 14:59:37 -070069 *
70 * @return set of intents
71 */
Brian O'Connor66630c82014-10-02 21:08:19 -070072 Iterable<Intent> getIntents();
73
74 /**
Brian O'Connor38224302016-08-02 22:03:01 -070075 * Adds an intent data object to the pending map for processing.
76 * <p>
77 * This method is intended to only be called by core components, not
78 * applications.
79 * </p>
80 *
81 * @param intentData intent data to be added to pending map
82 */
83 void addPending(IntentData intentData);
84
85 /**
Thomas Vachuskac46af202015-06-03 16:43:27 -070086 * Returns an iterable of intent data objects currently in the system.
87 *
88 * @return set of intent data objects
89 */
90 Iterable<IntentData> getIntentData();
91
92 /**
Brian O'Connor66630c82014-10-02 21:08:19 -070093 * Returns the number of intents currently in the system.
94 *
95 * @return number of intents
96 */
97 long getIntentCount();
Brian O'Connorb876bf12014-10-02 14:59:37 -070098
99 /**
Brian O'Connorb876bf12014-10-02 14:59:37 -0700100 * Retrieves the state of an intent by its identifier.
101 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800102 * @param intentKey intent identifier
Brian O'Connor66630c82014-10-02 21:08:19 -0700103 * @return the intent state or null if one with the given identifier is not
toma1d16b62014-10-02 23:45:11 -0700104 * found
Brian O'Connorb876bf12014-10-02 14:59:37 -0700105 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800106 IntentState getIntentState(Key intentKey);
Brian O'Connorb876bf12014-10-02 14:59:37 -0700107
108 /**
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700109 * Returns the list of the installable events associated with the specified
110 * top-level intent.
111 *
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800112 * @param intentKey top-level intent identifier
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700113 * @return compiled installable intents
114 */
Ray Milkeyf9af43c2015-02-09 16:45:48 -0800115 List<Intent> getInstallableIntents(Key intentKey);
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700116
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800117 /**
118 * Signifies whether the local node is responsible for processing the given
119 * intent key.
120 *
121 * @param intentKey intent key to check
122 * @return true if the local node is responsible for the intent key,
123 * otherwise false
124 */
125 boolean isLocal(Key intentKey);
Brian O'Connorbe28a872015-02-19 21:44:37 -0800126
Thomas Vachuska10d4abc2014-10-21 12:47:26 -0700127 /**
Jonathan Hart34f1e382015-02-24 16:52:23 -0800128 * Returns the list of intent requests pending processing.
129 *
130 * @return intents pending processing
131 */
Jonathan Hart13d3dd92015-02-25 16:09:42 -0800132 Iterable<Intent> getPending();
Jonathan Hart34f1e382015-02-24 16:52:23 -0800133
Brian O'Connorb876bf12014-10-02 14:59:37 -0700134}