Bug 6110: Fixed bugs in statistics manager due to race condition.
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / lifecycle / LifecycleService.java
1 /*
2  * Copyright (c) 2016 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.lifecycle;
10
11 import javax.annotation.CheckForNull;
12 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
13 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
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.handlers.DeviceRemovedHandler;
17 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
18 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
19
20 /**
21  * Service for starting or stopping all services in plugin in cluster
22  */
23 public interface LifecycleService extends ClusterSingletonService, OFPContext {
24
25     /**
26      * This method registers lifecycle service to the given provider
27      * @param singletonServiceProvider from md-sal binding
28      */
29     void registerService(final ClusterSingletonServiceProvider singletonServiceProvider);
30
31     /**
32      * This method registers device removed handler what will be executed when device should be removed
33      * from managers,
34      * @param deviceRemovedHandler device removed handler
35      */
36     void registerDeviceRemovedHandler(final @CheckForNull DeviceRemovedHandler deviceRemovedHandler);
37
38     /**
39      * Setter for device context
40      * @param deviceContext actual device context created per device
41      */
42     void setDeviceContext(final DeviceContext deviceContext);
43
44     /**
45      * Setter for rpc context
46      * @param rpcContext actual rpc context created per device
47      */
48     void setRpcContext(final RpcContext rpcContext);
49
50     /**
51      * Setter for statistics context
52      * @param statContext actual statistics context created per device
53      */
54     void setStatContext(final StatisticsContext statContext);
55
56     /**
57      * Some services, contexts etc. still need to have access to device context,
58      * instead to push into them, here is the getter
59      * @return device context for this device
60      */
61     DeviceContext getDeviceContext();
62
63     /**
64      * if some services not started properly need to close connection
65      */
66     void closeConnection();
67 }