Merge changes from topic "mdsal-4.0.3"
[openflowplugin.git] / openflowjava / openflow-protocol-api / src / main / java / org / opendaylight / openflowjava / protocol / api / connection / ConnectionAdapter.java
1 /*
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. 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 package org.opendaylight.openflowjava.protocol.api.connection;
9
10 import com.google.common.annotations.Beta;
11 import java.math.BigInteger;
12 import java.net.InetSocketAddress;
13 import java.util.concurrent.Future;
14 import org.opendaylight.openflowjava.protocol.api.extensibility.AlienMessageListener;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolListener;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener;
18
19 /**
20  * Manages a switch connection.
21  *
22  * @author mirehak
23  * @author michal.polkorab
24  */
25 public interface ConnectionAdapter extends OpenflowProtocolService {
26
27     /**
28      * Disconnect corresponding switch.
29      *
30      * @return future set to true, when disconnect completed
31      */
32     Future<Boolean> disconnect();
33
34     /**
35      * Determines if the connection to the switch is alive.
36      *
37      * @return true, if connection to switch is alive
38      */
39     boolean isAlive();
40
41     /**
42      * Returns the address of the connected switch.
43      *
44      * @return address of the remote end - address of a switch if connected
45      */
46     InetSocketAddress getRemoteAddress();
47
48     /**
49      * Sets the protocol message listener.
50      *
51      * @param messageListener here will be pushed all messages from switch
52      */
53     void setMessageListener(OpenflowProtocolListener messageListener);
54
55     /**
56      * Sets the system message listener.
57      *
58      * @param systemListener here will be pushed all system messages from library
59      */
60     void setSystemListener(SystemNotificationsListener systemListener);
61
62     /**
63      * Set handler for alien messages received from device.
64      *
65      * @param alienMessageListener here will be pushed all alien messages from switch
66      */
67     void setAlienMessageListener(AlienMessageListener alienMessageListener);
68
69     /**
70      * Throws exception if any of required listeners is missing.
71      */
72     void checkListeners();
73
74     /**
75      * Notify listener about connection ready-to-use event.
76      */
77     void fireConnectionReadyNotification();
78
79     /**
80      * Set listener for connection became ready-to-use event.
81      *
82      * @param connectionReadyListener listens to connection ready event
83      */
84     void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener);
85
86     /**
87      * Sets option for automatic channel reading - if set to false, incoming messages won't be read.
88      *
89      * @param autoRead target value to be switched to
90      */
91     void setAutoRead(boolean autoRead);
92
93     /**
94      * Determines if the channel is configured to auto-read.
95      *
96      * @return true, if channel is configured to auto-read
97      */
98     boolean isAutoRead();
99
100     /**
101      * Registers a new bypass outbound queue.
102      *
103      * @param <T> handler type
104      * @param handler queue handler
105      * @param maxQueueDepth max amount of not confirmed messaged in queue (i.e. edge for barrier message)
106      * @param maxBarrierNanos regular base for barrier message
107      * @return An {@link OutboundQueueHandlerRegistration}
108      */
109     @Beta
110     <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(T handler,
111         int maxQueueDepth, long maxBarrierNanos);
112
113     /**
114      * Set filtering of PacketIn messages. By default these messages are not filtered.
115      * @param enabled True if PacketIn messages should be filtered, false if they should be reported.
116      */
117     @Beta
118     void setPacketInFiltering(boolean enabled);
119
120     /**
121      * Set datapathId for the dpn.
122      * @param datapathId of the dpn
123      */
124     void setDatapathId(BigInteger datapathId);
125 }