4a954c00fb26d4825ef6bd657e72c9ce73ad3374
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / statistics / StatisticsContext.java
1 /*
2  * Copyright (c) 2015 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.api.openflow.statistics;
10
11 import com.google.common.util.concurrent.ListenableFuture;
12 import io.netty.util.Timeout;
13 import java.util.Optional;
14 import org.opendaylight.openflowplugin.api.openflow.OFPContext;
15 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
16 import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
17 import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
18 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
19 import org.opendaylight.openflowplugin.api.openflow.rpc.listener.ItemLifecycleListener;
20
21 /**
22  * Context for statistics
23  */
24 public interface StatisticsContext extends RequestContextStack, AutoCloseable, OFPContext {
25
26     /**
27      * Gather data from device
28      * @return true if gathering was successful
29      */
30     ListenableFuture<Boolean> gatherDynamicData();
31
32     /**
33      * Initial data gathering
34      * @return true if gathering was successful
35      */
36     ListenableFuture<Boolean> initialGatherDynamicData();
37
38     /**
39      * Method has to be called from DeviceInitialization Method, otherwise
40      * we are not able to poll anything. Statistics Context normally initialize
41      * this part by initialization process but we don't have this information
42      * in initialization phase and we have to populate whole list after every
43      * device future collecting. Because device future collecting set DeviceState
44      * and we creating marks for the correct kind of stats from DeviceState.
45      */
46     void statListForCollectingInitialization();
47
48     /**
49      * @param pollTimeout handle to nearest scheduled statistics poll
50      */
51     void setPollTimeout(Timeout pollTimeout);
52
53     /**
54      * @return handle to currently scheduled statistics polling
55      */
56     Optional<Timeout> getPollTimeout();
57
58     /**
59      * @return dedicated item life cycle change listener (per device)
60      */
61     ItemLifecycleListener getItemLifeCycleListener();
62
63     @Override
64     void close();
65
66     /**
67      * On / Off scheduling
68      * @param schedulingEnabled true if scheduling should be enabled
69      */
70     void setSchedulingEnabled(final boolean schedulingEnabled);
71
72     /**
73      * Check status
74      * @return true if scheduling is enabled
75      */
76     boolean isSchedulingEnabled();
77
78     /**
79      * Gain device state
80      * @return device state from device context from lifecycle service
81      */
82     DeviceState gainDeviceState();
83
84     /**
85      * Gain device context
86      * @return device context from lifecycle service
87      */
88     DeviceContext gainDeviceContext();
89
90     /**
91      * In case to change mastership to slave or connection interrupted stop the future and release thread
92      */
93     void stopGatheringData();
94 }