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