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