Fix Jdk8 compatibility
[openflowplugin.git] / applications / statistics-manager / src / main / java / org / opendaylight / openflowplugin / applications / statistics / manager / StatisticsManager.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.openflowplugin.applications.statistics.manager;
10
11 import java.util.List;
12
13 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
14 import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
15 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
16 import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
17 import org.opendaylight.openflowplugin.applications.statistics.manager.StatPermCollector.StatCapabTypes;
18 import org.opendaylight.openflowplugin.applications.statistics.manager.impl.StatisticsManagerConfig;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.OpendaylightFlowStatisticsListener;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.OpendaylightFlowTableStatisticsListener;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.queues.Queue;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.OpendaylightGroupStatisticsListener;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.OpendaylightMeterStatisticsListener;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.OpendaylightPortStatisticsListener;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.OpendaylightQueueStatisticsListener;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
33
34 /**
35  * statistics-manager
36  * org.opendaylight.openflowplugin.applications.statistics.manager
37  *
38  * StatisticsManager
39  * It represent a central point for whole module. Implementation
40  * StatisticsManager registers all Operation/DS {@link StatNotifyCommiter} and
41  * Config/DS {@link StatListeningCommiter}, as well as {@link StatPermCollector}
42  * for statistic collecting and {@link StatRpcMsgManager} as Device RPCs provider.
43  * In next, StatisticsManager provides all DS contact Transaction services.
44  *
45  * @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
46  *
47  * Created: Aug 27, 2014
48  */
49 public interface StatisticsManager extends AutoCloseable, TransactionChainListener {
50
51     /**
52      * StatDataStoreOperation
53      * Interface represent functionality to submit changes to DataStore.
54      * Internal {@link TransactionChainListener} joining all DS commits
55      * to Set of chained changes for prevent often DataStore touches.
56      */
57     abstract class StatDataStoreOperation {
58         public enum StatsManagerOperationType {
59             /**
60              * Operation will carry out work related to new node addition /
61              * update
62              */
63             NODE_UPDATE,
64             /**
65              * Operation will carry out work related to node removal
66              */
67             NODE_REMOVAL,
68             /**
69              * Operation will commit data to the operational data store
70              */
71             DATA_COMMIT_OPER_DS
72         }
73
74         private NodeId nodeId;
75         private StatsManagerOperationType operationType = StatsManagerOperationType.DATA_COMMIT_OPER_DS;
76
77         public StatDataStoreOperation(final StatsManagerOperationType operType, final NodeId id){
78             if(operType != null){
79                 operationType = operType;
80             }
81             nodeId = id;
82         }
83
84         public final StatsManagerOperationType getType() {
85             return operationType;
86         }
87
88         public final NodeId getNodeId(){
89             return nodeId;
90         }
91
92         /**
93          * Apply all read / write (put|merge) operation for DataStore
94          *
95          * @param tx {@link ReadWriteTransaction}
96          */
97         public abstract void applyOperation(ReadWriteTransaction tx);
98
99     }
100
101     /**
102      * Method starts whole StatisticManager functionality
103      *
104      * @param notifService
105      * @param rpcRegistry
106      */
107     void start(final NotificationProviderService notifService,
108             final RpcConsumerRegistry rpcRegistry);
109
110     /**
111      * Method provides read/write DataStore functionality cross applyOperation
112      * defined in {@link StatDataStoreOperation}
113      *
114      * @param inventoryOper - operation for DataStore
115      */
116     void enqueue(final StatDataStoreOperation inventoryOper);
117
118     /**
119      * Method wraps {@link StatisticsManager#isProvidedFlowNodeActive(InstanceIdentifier)} method
120      * to provide parallel statCollection process for Set of Nodes. So it has to
121      * identify correct Node Set by NodeIdentifier
122      *
123      * @param nodeIdent
124      */
125      boolean isProvidedFlowNodeActive(InstanceIdentifier<Node> nodeIdent);
126
127      /**
128       * Method wraps {@link StatPermCollector}.collectNextStatistics to provide
129       * parallel statCollection process for Set of Nodes. So it has to
130       * identify correct Node Set by NodeIdentifier.
131       *
132       * @param nodeIdent
133       */
134      void collectNextStatistics(InstanceIdentifier<Node> nodeIdent, TransactionId xid);
135
136      /**
137       * Method wraps {@link StatPermCollector}.connectedNodeRegistration to provide
138       * parallel statCollection process for Set of Nodes. So it has to
139       * connect node to new or not full Node statCollector Set.
140       *
141       * @param nodeIdent
142       * @param statTypes
143       * @param nrOfSwitchTables
144       */
145      void connectedNodeRegistration(InstanceIdentifier<Node> nodeIdent,
146              List<StatCapabTypes> statTypes, Short nrOfSwitchTables);
147
148      /**
149       * Method wraps {@link StatPermCollector}.disconnectedNodeUnregistration to provide
150       * parallel statCollection process for Set of Nodes. So it has to identify
151       * correct collector for disconnect node.
152       *
153       * @param nodeIdent
154       */
155      void disconnectedNodeUnregistration(InstanceIdentifier<Node> nodeIdent);
156
157      /**
158       * Method wraps {@link StatPermCollector}.registerAdditionalNodeFeature to provide
159       * possibility to register additional Node Feature {@link StatCapabTypes} for
160       * statistics collecting.
161       *
162       * @param nodeIdent
163       * @param statCapab
164       */
165      void registerAdditionalNodeFeature(InstanceIdentifier<Node> nodeIdent, StatCapabTypes statCapab);
166
167     /**
168      * Method provides access to Device RPC methods by wrapped
169      * internal method. In next {@link StatRpcMsgManager} is registered all
170      * Multipart device msg response and joining all to be able run all
171      * collected statistics in one time (easy identification Data for delete)
172      *
173      * @return {@link StatRpcMsgManager}
174      */
175     StatRpcMsgManager getRpcMsgManager();
176
177     /**
178      * Define Method : {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode}
179      * Operational/DS data change listener -&gt; impl. target -&gt; register FlowCapableNode to Statistic Collecting process
180      * @return {@link StatNodeRegistration}
181      */
182     StatNodeRegistration getNodeRegistrator();
183
184     /**
185      * Define Method : Flow Config/DS data change listener -&gt; impl. target -&gt;
186      * -&gt; make pair between Config/DS FlowId and Device Flow response Hash
187      * @return
188      */
189     StatListeningCommiter<Flow, OpendaylightFlowStatisticsListener> getFlowListenComit();
190
191     /**
192      * Define Method : Meter Config/DS data change listener and Operation/DS notify commit
193      * functionality
194      * @return
195      */
196     StatListeningCommiter<Meter, OpendaylightMeterStatisticsListener> getMeterListenCommit();
197
198     /**
199      * Define Method : Group Config/DS data change listener and Operation/DS notify commit
200      * functionality
201      * @return
202      */
203     StatListeningCommiter<Group, OpendaylightGroupStatisticsListener> getGroupListenCommit();
204
205     /**
206      * Define Method : Queue Config/DS change listener and Operation/DS notify commit functionality
207      * @return
208      */
209     StatListeningCommiter<Queue, OpendaylightQueueStatisticsListener> getQueueNotifyCommit();
210
211     /**
212      * Define Method : Table Operation/DS notify commit functionality
213      * @return
214      */
215     StatNotifyCommiter<OpendaylightFlowTableStatisticsListener> getTableNotifCommit();
216
217     /**
218      * Define Method : Port Operation/DS notify commit functionality
219      * @return
220      */
221     StatNotifyCommiter<OpendaylightPortStatisticsListener> getPortNotifyCommit();
222
223     StatisticsManagerConfig getConfiguration();
224
225 }
226