Bug 1484 - StatisticManager performance improvement refactoring
[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
25 /**
26  * statistics-manager
27  * org.opendaylight.controller.md.statistics.manager
28  *
29  * StatRpcMsgManager
30  * It represent access point for Device statistics RPC services which are
31  * filtered for needed methods only and they are wrapped in simply way.
32  * Many statistics responses are Multipart messages, so StatRpcMsgManager
33  * provide a functionality to add all multipart msg and provides back whole
34  * stack to listener when listener catch the last Multipart msg.
35  *
36  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
37  *
38  * Created: Aug 29, 2014
39  */
40 public interface StatRpcMsgManager extends Runnable, AutoCloseable {
41
42     interface RpcJobsQueue extends Callable<Void> {}
43
44     /**
45      * Transaction container is definition for Multipart transaction
46      * join container for all Multipart msg with same TransactionId
47      * Input {@link DataObject} is a possible light-weight DataObject
48      * which is used for identification (e.g. Flow-> Priority,Match,Cookie,FlowId)
49      *
50      * @param <T> extends TransactionAware -
51      */
52     interface TransactionCacheContainer<T extends TransactionAware> {
53
54         void addNotif(T notification);
55
56         TransactionId getId();
57
58         NodeId getNodeId();
59
60         Optional<? extends DataObject> getConfInput();
61
62         List<T> getNotifications();
63     }
64
65     /**
66      * Method is used for check a transaction registration
67      * for multipart cache holder
68      *
69      * @param TransactionId id
70      * @return true if the transaction has been correctly registered
71      */
72     Future<Boolean> isExpectedStatistics(TransactionId id, NodeId nodeId);
73
74     /**
75      * Method converts {@link java.util.concurrent.Future} object to listenenable future which
76      * is registered for Multipart Notification Statistics Collecting processing.
77      *
78      * @param future - result every Device RPC call
79      */
80     <T extends TransactionAware, D extends DataObject> void registrationRpcFutureCallBack(Future<RpcResult<T>> future, D inputObj, NodeRef ref);
81
82     /**
83      * Method adds Notification which is marked as Multipart to the transaction cash
84      * to wait for the last one.
85      *
86      * @param notification
87      */
88     <T extends TransactionAware> void addNotification(T notification, NodeId nodeId);
89
90     /**
91      * The last Multipart should inform code about possibility to take all previous
92      * messages for next processing. The method take all msg and possible input object
93      * and build all to TransactionCacheContainer Object to return. This process clean
94      * all instances in Cache.
95      *
96      * @param TransactionId id
97      * @return TransactionCacheContainer
98      */
99     Future<Optional<TransactionCacheContainer<?>>> getTransactionCacheContainer(TransactionId id, NodeId nodeId);
100
101     /**
102      * Method wraps OpendaylightGroupStatisticsService.getAllGroupStatistics
103      * and registers to Transaction Cache
104      *
105      * @param NodeRef nodeRef
106      */
107     void getAllGroupsStat(NodeRef nodeRef);
108
109     /**
110      * Method wraps OpendaylightGroupStatisticsService.getGroupDescription
111      * and registers to Transaction Cache
112      *
113      * @param NodeRef nodeRef
114      */
115     void getAllGroupsConfStats(NodeRef nodeRef);
116
117     /**
118      * Method wraps OpendaylightMeterStatisticsService.getGroupFeatures
119      * and registers to Transaction Cache
120      *
121      * @param NodeRef nodeRef
122      */
123     void getGroupFeaturesStat(NodeRef nodeRef);
124
125     /**
126      * Method wraps OpendaylightMeterStatisticsService.getAllMeterStatistics
127      * and registers to Transaction Cache
128      *
129      * @param NodeRef nodeRef
130      */
131     void getAllMetersStat(NodeRef nodeRef);
132
133     /**
134      * Method wraps OpendaylightMeterStatisticsService.getAllMeterConfigStatistics
135      * and registers to Transaction Cache
136      *
137      * @param NodeRef nodeRef
138      */
139     void getAllMeterConfigStat(NodeRef nodeRef);
140
141     /**
142      * Method wraps OpendaylightMeterStatisticsService.getMeterFeatures
143      * and registers to Transaction Cache
144      *
145      * @param NodeRef nodeRef
146      */
147     void getMeterFeaturesStat(NodeRef nodeRef);
148
149     /**
150      * Method wraps OpendaylightFlowStatisticsService.getAllFlowsStatisticsFromAllFlowTables
151      * and registers to Transaction Cache
152      *
153      * @param NodeRef nodeRef
154      */
155     void getAllFlowsStat(NodeRef nodeRef);
156
157     /**
158      * Method wraps OpendaylightFlowStatisticsService.getAggregateFlowStatisticsFromFlowTableForAllFlows
159      * and registers to Transaction Cache
160      *
161      * @param NodeRef nodeRef
162      * @param TableId tableId
163      */
164     void getAggregateFlowStat(NodeRef nodeRef, TableId tableId);
165
166     /**
167      * Method wraps OpendaylightPortStatisticsService.getAllNodeConnectorsStatistics
168      * and registers to Transaction Cache
169      *
170      * @param NodeRef nodeRef
171      */
172     void getAllPortsStat(NodeRef nodeRef);
173
174     /**
175      * Method wraps OpendaylightFlowTableStatisticsService.getFlowTablesStatistics
176      * and registers to Transaction Cache
177      *
178      * @param NodeRef nodeRef
179      */
180     void getAllTablesStat(NodeRef nodeRef);
181
182     /**
183      * Method wraps OpendaylightQueueStatisticsService.getAllQueuesStatisticsFromAllPorts
184      * and registers to Transaction Cache
185      *
186      * @param NodeRef nodeRef
187      */
188     void getAllQueueStat(NodeRef nodeRef);
189
190 }
191