Merge "BUG-4117: preparation for FlowCapableNode notification impl."
[openflowplugin.git] / openflowplugin-api / src / main / java / org / opendaylight / openflowplugin / api / openflow / lifecycle / LifecycleConductor.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 io.netty.util.Timeout;
12 import io.netty.util.TimerTask;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.device.DeviceManager;
15 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsManager;
16 import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageIntelligenceAgency;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
18
19 import javax.annotation.Nonnull;
20 import java.util.concurrent.TimeUnit;
21
22 /**
23  * This class is a binder between all managers
24  * Should be defined in OpenFlowPluginProviderImpl
25  */
26 public interface LifecycleConductor {
27
28     /**
29      * Returns device context from device manager device contexts maps
30      * @param nodeId node identification
31      * @return null if context doesn't exists
32      */
33     DeviceContext getDeviceContext(final NodeId nodeId);
34
35     /**
36      * Registers ont time listener for notify when services rpc, statistics are done stop or start
37      * @param manager service change listener
38      * @param nodeId node identification
39      */
40     void addOneTimeListenerWhenServicesChangesDone(final ServiceChangeListener manager, final NodeId nodeId);
41
42     /**
43      * Returns device of version
44      * @param nodeId node identification
45      * @return null if device context doesn't exists
46      */
47     Short gainVersionSafely(final NodeId nodeId);
48
49     /**
50      * Set new timeout for {@link io.netty.util.HashedWheelTimer}
51      * @param task timer task
52      * @param delay delay
53      * @param unit time unit
54      * @return new timeout
55      */
56     Timeout newTimeout(@Nonnull TimerTask task, long delay, @Nonnull TimeUnit unit);
57
58     /**
59      * Returns message intelligence agency
60      * @return MessageIntelligenceAgency set by constructor
61      */
62     MessageIntelligenceAgency getMessageIntelligenceAgency();
63
64     /**
65      * Interrupt connection for the node
66      * @param nodeId node identification
67      */
68     void closeConnection(final NodeId nodeId);
69
70     /**
71      * Setter for device manager once set it cant be unset or overwritten
72      * @param deviceManager should be set in OpenFlowPluginProviderImpl
73      */
74     void setSafelyDeviceManager(final DeviceManager deviceManager);
75
76     /**
77      * Setter for statistics manager once set it cant be unset or overwritten
78      * @param statisticsManager should be set in OpenFlowPluginProviderImpl
79      */
80     void setSafelyStatisticsManager(final StatisticsManager statisticsManager);
81
82     /**
83      * Xid from outboundqueue
84      * @param nodeId
85      * @return
86      */
87     Long reserveXidForDeviceMessage(final NodeId nodeId);
88 }