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