Merge "Make neutron a simple osgi app"
[controller.git] / opendaylight / md-sal / statistics-manager / src / main / java / org / opendaylight / controller / md / statistics / manager / StatRpcMsgManager.java
1 /**
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.statistics.manager;
10
11 import java.util.List;
12 import java.util.concurrent.Callable;
13 import java.util.concurrent.Future;
14
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
20 import org.opendaylight.yangtools.yang.binding.DataObject;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22
23 import com.google.common.base.Optional;
24 import com.google.common.util.concurrent.SettableFuture;
25
26 /**
27  * statistics-manager
28  * org.opendaylight.controller.md.statistics.manager
29  *
30  * StatRpcMsgManager
31  * It represent access point for Device statistics RPC services which are
32  * filtered for needed methods only and they are wrapped in simply way.
33  * Many statistics responses are Multipart messages, so StatRpcMsgManager
34  * provide a functionality to add all multipart msg and provides back whole
35  * stack to listener when listener catch the last Multipart msg.
36  *
37  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
38  *
39  * Created: Aug 29, 2014
40  */
41 public interface StatRpcMsgManager extends Runnable, AutoCloseable {
42
43     interface RpcJobsQueue extends Callable<Void> {}
44
45     /**
46      * Transaction container is definition for Multipart transaction
47      * join container for all Multipart msg with same TransactionId
48      * Input {@link DataObject} is a possible light-weight DataObject
49      * which is used for identification (e.g. Flow-> Priority,Match,Cookie,FlowId)
50      *
51      * @param <T> extends TransactionAware -
52      */
53     interface TransactionCacheContainer<T extends TransactionAware> {
54
55         void addNotif(T notification);
56
57         TransactionId getId();
58
59         NodeId getNodeId();
60
61         Optional<? extends DataObject> getConfInput();
62
63         List<T> getNotifications();
64     }
65
66     /**
67      * Method is used for check a transaction registration
68      * for multipart cache holder
69      *
70      * @param TransactionId id
71      * @return true if the transaction has been correctly registered
72      */
73     Future<Boolean> isExpectedStatistics(TransactionId id, NodeId nodeId);
74
75     /**
76      * Method converts {@link java.util.concurrent.Future} object to listenenable future which
77      * is registered for Multipart Notification Statistics Collecting processing.
78      *
79      * @param future - result every Device RPC call
80      */
81     <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(
82             Future<RpcResult<T>> future, D inputObj, NodeRef ref, SettableFuture<TransactionId> resultTransId);
83
84     /**
85      * Method adds Notification which is marked as Multipart to the transaction cash
86      * to wait for the last one.
87      *
88      * @param notification
89      */
90     <T extends TransactionAware> void addNotification(T notification, NodeId nodeId);
91
92     /**
93      * The last Multipart should inform code about possibility to take all previous
94      * messages for next processing. The method take all msg and possible input object
95      * and build all to TransactionCacheContainer Object to return. This process clean
96      * all instances in Cache.
97      *
98      * @param TransactionId id
99      * @return TransactionCacheContainer
100      */
101     Future<Optional<TransactionCacheContainer<?>>> getTransactionCacheContainer(TransactionId id, NodeId nodeId);
102
103     /**
104      * Method wraps OpendaylightGroupStatisticsService.getAllGroupStatistics
105      * and registers to Transaction Cache
106      *
107      * @param NodeRef nodeRef
108      */
109     Future<TransactionId> getAllGroupsStat(NodeRef nodeRef);
110
111     /**
112      * Method wraps OpendaylightGroupStatisticsService.getGroupDescription
113      * and registers to Transaction Cache
114      *
115      * @param NodeRef nodeRef
116      */
117     Future<TransactionId> getAllGroupsConfStats(NodeRef nodeRef);
118
119     /**
120      * Method wraps OpendaylightMeterStatisticsService.getGroupFeatures
121      * and registers to Transaction Cache
122      *
123      * @param NodeRef nodeRef
124      */
125     void getGroupFeaturesStat(NodeRef nodeRef);
126
127     /**
128      * Method wraps OpendaylightMeterStatisticsService.getAllMeterStatistics
129      * and registers to Transaction Cache
130      *
131      * @param NodeRef nodeRef
132      */
133     Future<TransactionId> getAllMetersStat(NodeRef nodeRef);
134
135     /**
136      * Method wraps OpendaylightMeterStatisticsService.getAllMeterConfigStatistics
137      * and registers to Transaction Cache
138      *
139      * @param NodeRef nodeRef
140      */
141     Future<TransactionId> getAllMeterConfigStat(NodeRef nodeRef);
142
143     /**
144      * Method wraps OpendaylightMeterStatisticsService.getMeterFeatures
145      * and registers to Transaction Cache
146      *
147      * @param NodeRef nodeRef
148      */
149     void getMeterFeaturesStat(NodeRef nodeRef);
150
151     /**
152      * Method wraps OpendaylightFlowStatisticsService.getAllFlowsStatisticsFromAllFlowTables
153      * and registers to Transaction Cache
154      *
155      * @param NodeRef nodeRef
156      */
157     Future<TransactionId> getAllFlowsStat(NodeRef nodeRef);
158
159     /**
160      * Method wraps OpendaylightFlowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows
161      * and registers to Transaction Cache
162      *
163      * @param NodeRef nodeRef
164      * @param TableId tableId
165      */
166     void getAggregateFlowStat(NodeRef nodeRef, TableId tableId);
167
168     /**
169      * Method wraps OpendaylightPortStatisticsService.getAllNodeConnectorsStatistics
170      * and registers to Transaction Cache
171      *
172      * @param NodeRef nodeRef
173      */
174     Future<TransactionId> getAllPortsStat(NodeRef nodeRef);
175
176     /**
177      * Method wraps OpendaylightFlowTableStatisticsService.getFlowTablesStatistics
178      * and registers to Transaction Cache
179      *
180      * @param NodeRef nodeRef
181      */
182     Future<TransactionId> getAllTablesStat(NodeRef nodeRef);
183
184     /**
185      * Method wraps OpendaylightQueueStatisticsService.getAllQueuesStatisticsFromAllPorts
186      * and registers to Transaction Cache
187      *
188      * @param NodeRef nodeRef
189      */
190     Future<TransactionId> getAllQueueStat(NodeRef nodeRef);
191
192 }
193