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