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