30babc3f7d5a3bc85250b2ae83d85896f2b7d181
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / device / DeviceManager.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.device;
10
11 import com.google.common.util.concurrent.ListenableFuture;
12 import org.opendaylight.openflowplugin.api.openflow.OFPManager;
13 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler;
14 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
15 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
16 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceLifecycleSupervisor;
17 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceTerminationPhaseHandler;
18 import org.opendaylight.openflowplugin.api.openflow.translator.TranslatorLibrarian;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.OfpRole;
20
21 import javax.annotation.CheckForNull;
22
23 /**
24  * This interface is responsible for instantiating DeviceContext and
25  * registering transaction chain for each DeviceContext. Each device
26  * has its own device context managed by this manager.
27  */
28 public interface DeviceManager extends DeviceConnectedHandler, DeviceDisconnectedHandler, DeviceLifecycleSupervisor,
29         DeviceInitializationPhaseHandler, DeviceTerminationPhaseHandler, TranslatorLibrarian, AutoCloseable, OFPManager {
30
31
32     /**
33      * invoked after all services injected
34      */
35     void initialize();
36
37     /**
38      * Method has to activate (MASTER) or deactivate (SLAVE) TransactionChainManager.
39      * TransactionChainManager represents possibility to write or delete Node subtree data
40      * for actual Controller Cluster Node. We are able to have an active TxManager only if
41      * newRole is {@link OfpRole#BECOMESLAVE}.
42      * Parameters are used as marker to be sure it is change to SLAVE from MASTER or from
43      * MASTER to SLAVE and the last parameter "cleanDataStore" is used for validation only.
44      *
45      * @param deviceInfo which device
46      * @param role - NewRole expect to be {@link OfpRole#BECOMESLAVE} or {@link OfpRole#BECOMEMASTER}
47      * @return RoleChangeTxChainManager future for activation/deactivation
48      */
49     ListenableFuture<Void> onClusterRoleChange(final DeviceInfo deviceInfo, final OfpRole role);
50
51     /**
52      * Register device synchronize listeners
53      * @param deviceSynchronizeListener are notified if device is synchronized or not
54      */
55     void registerDeviceSynchronizeListeners(final DeviceSynchronizeListener deviceSynchronizeListener);
56
57     /**
58      * Notify all registered listeners about synchronized status
59      * @param deviceInfo which device
60      * @param deviceSynchronized true if device is synchronized
61      */
62     void notifyDeviceSynchronizeListeners(final DeviceInfo deviceInfo, final boolean deviceSynchronized);
63
64     /**
65      * Register device valid listeners
66      * @param deviceValidListener are notified if device is valid or not
67      */
68     void registerDeviceValidListeners(final DeviceValidListener deviceValidListener);
69
70     /**
71      * Notify all registered listeners about valid status
72      * @param deviceInfo which device
73      * @param deviceValid true if device is valid
74      */
75     void notifyDeviceValidListeners(final DeviceInfo deviceInfo, final boolean deviceValid);
76
77 }
78