Class ConnectionAdapterImpl
java.lang.Object
org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl
- All Implemented Interfaces:
ConnectionAdapter
,ConnectionFacade
,MessageConsumer
Handles messages (notifications + rpcs) and connections.
- Author:
- mirehak, michal.polkorab
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter
ConnectionAdapter.MessageListener, ConnectionAdapter.SystemListener
-
Field Summary
Modifier and TypeFieldDescriptionprotected final InetSocketAddress
protected final io.netty.channel.Channel
protected boolean
protected final org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue
protected static final com.google.common.cache.RemovalListener
<RpcResponseKey, org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>> protected com.google.common.cache.Cache
<RpcResponseKey, org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>> expiring cache for future rpcResponses. -
Constructor Summary
ConstructorDescriptionConnectionAdapterImpl
(io.netty.channel.Channel channel, InetSocketAddress address, boolean useBarrier, int channelOutboundQueueSize) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<BarrierOutput>> barrier
(BarrierInput input) Invokebarrier
RPC.void
Throws exception if any of required listeners is missing.void
consume
(org.opendaylight.yangtools.binding.DataObject message) Invoked to consume a message.void
consumeDeviceMessage
(org.opendaylight.yangtools.binding.DataObject message) Method is equivalent toMessageConsumer.consume(DataObject)
to prevent missing method in every children ofAbstractConnectionAdapterStatistics
class, because we overriding original method forStatisticsCounters
.Disconnect corresponding switch.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<EchoOutput>> Invokeecho
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<EchoReplyOutput>> echoReply
(EchoReplyInput input) Invokeecho-reply
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<ExperimenterOutput>> experimenter
(ExperimenterInput input) Invokeexperimenter
RPC.protected org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener
<?> Return cached RpcListener ornull
if not cached.void
Notify listener about connection ready-to-use event.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<FlowModOutput>> flowMod
(FlowModInput input) Invokeflow-mod
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<GetAsyncOutput>> getAsync
(GetAsyncInput input) Invokeget-async
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<GetConfigOutput>> getConfig
(GetConfigInput input) Invokeget-config
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<GetFeaturesOutput>> getFeatures
(GetFeaturesInput input) Invokeget-features
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<GetQueueConfigOutput>> Invokeget-queue-config
RPC.Returns the address of the connected switch.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<GroupModOutput>> groupMod
(GroupModInput input) Invokegroup-mod
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<HelloOutput>> hello
(HelloInput input) Invokehello
RPC.boolean
isAlive()
Determines if the connection to the switch is alive.boolean
Determines if the channel is configured to auto-read.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<MeterModOutput>> meterMod
(MeterModInput input) Invokemeter-mod
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<MultipartRequestOutput>> Invokemultipart-request
RPC.void
onSwitchCertificateIdentified
(List<X509Certificate> certificateChain) Notify listener about switch certificate information.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<PacketOutOutput>> packetOut
(PacketOutInput input) Invokepacket-out
RPC.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<PortModOutput>> portMod
(PortModInput input) Invokeport-mod
RPC.<T extends OutboundQueueHandler>
OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler
(T handler, int maxQueueDepth, long maxBarrierNanos) Registers a new bypass outbound queue.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<RoleRequestOutput>> roleRequest
(RoleRequestInput input) Invokerole-request
RPC.protected <I extends OfHeader,
O extends OfHeader>
com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<O>> sendToSwitchExpectRpcResultFuture
(I input, Class<O> responseClazz, String failureInfo) Sends given message to switch, sending result or switch response will be reported via return value.protected <O extends org.opendaylight.yangtools.binding.DataObject>
com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<O>> sendToSwitchFuture
(Object input, String failureInfo) Sends given message to switch, sending result will be reported via return value.void
setAlienMessageListener
(AlienMessageListener alienMessageListener) Set handler for alien messages received from device.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<SetAsyncOutput>> setAsync
(SetAsyncInput input) Invokeset-async
RPC.void
setAutoRead
(boolean autoRead) Sets option for automatic channel reading - if set to false, incoming messages won't be read.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<SetConfigOutput>> setConfig
(SetConfigInput input) Invokeset-config
RPC.void
setConnectionReadyListener
(ConnectionReadyListener connectionReadyListener) Set listener for connection became ready-to-use event.void
setDatapathId
(BigInteger datapathId) Set datapathId for the dpn.void
setExecutorService
(ExecutorService executorService) Sets executorService.void
setMessageListener
(ConnectionAdapter.MessageListener messageListener) Sets the protocol message listener.void
setPacketInFiltering
(boolean enabled) Set filtering of PacketIn messages.void
setSystemListener
(ConnectionAdapter.SystemListener systemListener) Sets the system message listener.com.google.common.util.concurrent.ListenableFuture
<org.opendaylight.yangtools.yang.common.RpcResult<TableModOutput>> tableMod
(TableModInput input) Invoketable-mod
RPC.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter
barrier, disconnect, echo, echoReply, experimenter, flowMod, getAsync, getConfig, getFeatures, getQueueConfig, getRemoteAddress, groupMod, hello, isAlive, isAutoRead, meterMod, multipartRequest, packetOut, portMod, roleRequest, setAsync, setAutoRead, setConfig, tableMod
Methods inherited from interface org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer
consume
-
Field Details
-
REMOVAL_LISTENER
protected static final com.google.common.cache.RemovalListener<RpcResponseKey,org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>> REMOVAL_LISTENER -
channel
protected final io.netty.channel.Channel channel -
address
-
disconnectOccured
protected boolean disconnectOccured -
output
protected final org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue output -
responseCache
protected com.google.common.cache.Cache<RpcResponseKey,org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>> responseCacheexpiring cache for future rpcResponses.
-
-
Constructor Details
-
ConnectionAdapterImpl
public ConnectionAdapterImpl(io.netty.channel.Channel channel, InetSocketAddress address, boolean useBarrier, int channelOutboundQueueSize) Default constructor.- Parameters:
channel
- the channel to be set - used for communicationaddress
- client address (used only in case of UDP communication, as there is no need to store address over tcp (stable channel))useBarrier
- value is configurable by configSubsytem
-
-
Method Details
-
setMessageListener
Description copied from interface:ConnectionAdapter
Sets the protocol message listener.- Specified by:
setMessageListener
in interfaceConnectionAdapter
- Parameters:
messageListener
- here will be pushed all messages from switch
-
setConnectionReadyListener
Description copied from interface:ConnectionAdapter
Set listener for connection became ready-to-use event.- Specified by:
setConnectionReadyListener
in interfaceConnectionAdapter
- Parameters:
connectionReadyListener
- listens to connection ready event
-
setSystemListener
Description copied from interface:ConnectionAdapter
Sets the system message listener.- Specified by:
setSystemListener
in interfaceConnectionAdapter
- Parameters:
systemListener
- here will be pushed all system messages from library
-
setAlienMessageListener
Description copied from interface:ConnectionAdapter
Set handler for alien messages received from device.- Specified by:
setAlienMessageListener
in interfaceConnectionAdapter
- Parameters:
alienMessageListener
- here will be pushed all alien messages from switch
-
consumeDeviceMessage
public void consumeDeviceMessage(org.opendaylight.yangtools.binding.DataObject message) Method is equivalent toMessageConsumer.consume(DataObject)
to prevent missing method in every children ofAbstractConnectionAdapterStatistics
class, because we overriding original method forStatisticsCounters
.- Parameters:
message
- from device to processing
-
checkListeners
public void checkListeners()Description copied from interface:ConnectionAdapter
Throws exception if any of required listeners is missing.- Specified by:
checkListeners
in interfaceConnectionAdapter
-
fireConnectionReadyNotification
public void fireConnectionReadyNotification()Description copied from interface:ConnectionAdapter
Notify listener about connection ready-to-use event.- Specified by:
fireConnectionReadyNotification
in interfaceConnectionAdapter
-
onSwitchCertificateIdentified
Description copied from interface:ConnectionAdapter
Notify listener about switch certificate information.- Specified by:
onSwitchCertificateIdentified
in interfaceConnectionAdapter
- Parameters:
certificateChain
- X509 certificate chain presented by the switch
-
registerOutboundQueueHandler
public <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(T handler, int maxQueueDepth, long maxBarrierNanos) Description copied from interface:ConnectionAdapter
Registers a new bypass outbound queue.- Specified by:
registerOutboundQueueHandler
in interfaceConnectionAdapter
- Type Parameters:
T
- handler type- Parameters:
handler
- queue handlermaxQueueDepth
- max amount of not confirmed messaged in queue (i.e. edge for barrier message)maxBarrierNanos
- regular base for barrier message- Returns:
- An
OutboundQueueHandlerRegistration
-
setPacketInFiltering
public void setPacketInFiltering(boolean enabled) Description copied from interface:ConnectionAdapter
Set filtering of PacketIn messages. By default these messages are not filtered.- Specified by:
setPacketInFiltering
in interfaceConnectionAdapter
- Parameters:
enabled
- True if PacketIn messages should be filtered, false if they should be reported.
-
setDatapathId
Description copied from interface:ConnectionAdapter
Set datapathId for the dpn.- Specified by:
setDatapathId
in interfaceConnectionAdapter
- Parameters:
datapathId
- of the dpn
-
setExecutorService
Description copied from interface:ConnectionAdapter
Sets executorService.- Specified by:
setExecutorService
in interfaceConnectionAdapter
- Parameters:
executorService
- for all dpns
-
flowMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<FlowModOutput>> flowMod(FlowModInput input) Description copied from interface:ConnectionAdapter
Invokeflow-mod
RPC. See alsoFlowMod
.- Specified by:
flowMod
in interfaceConnectionAdapter
- Parameters:
input
- offlow-mod
- Returns:
- output of
flow-mod
-
sendToSwitchExpectRpcResultFuture
protected <I extends OfHeader,O extends OfHeader> com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<O>> sendToSwitchExpectRpcResultFuture(I input, Class<O> responseClazz, String failureInfo) Sends given message to switch, sending result or switch response will be reported via return value.- Parameters:
input
- message to sendresponseClazz
- type of responsefailureInfo
- describes, what type of message caused failure by sending- Returns:
- future object,
- if send fails,
RpcResult
will contain errors and failed status - else
RpcResult
will be stored in responseCache and wait for particular timeout (AbstractConnectionAdapter.RPC_RESPONSE_EXPIRATION
),- either switch will manage to answer and then corresponding response message will be set into returned future
- or response in cache will expire and returned future will be cancelled
- if send fails,
-
sendToSwitchFuture
protected <O extends org.opendaylight.yangtools.binding.DataObject> com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<O>> sendToSwitchFuture(Object input, String failureInfo) Sends given message to switch, sending result will be reported via return value.- Parameters:
input
- message to sendfailureInfo
- describes, what type of message caused failure by sending- Returns:
- future object,
- if send successful,
RpcResult
without errors and successful status will be returned, - else
RpcResult
will contain errors and failed status
- if send successful,
-
consume
public void consume(org.opendaylight.yangtools.binding.DataObject message) Description copied from interface:MessageConsumer
Invoked to consume a message.- Specified by:
consume
in interfaceMessageConsumer
- Parameters:
message
- to process
-
disconnect
Description copied from interface:ConnectionAdapter
Disconnect corresponding switch.- Specified by:
disconnect
in interfaceConnectionAdapter
- Returns:
- future set to true, when disconnect completed
-
barrier
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<BarrierOutput>> barrier(BarrierInput input) Description copied from interface:ConnectionAdapter
Invokebarrier
RPC. See alsoBarrier
.- Specified by:
barrier
in interfaceConnectionAdapter
- Parameters:
input
- ofbarrier
- Returns:
- output of
barrier
-
echo
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoOutput>> echo(EchoInput input) Description copied from interface:ConnectionAdapter
Invokeecho
RPC. See alsoEcho
.- Specified by:
echo
in interfaceConnectionAdapter
- Parameters:
input
- ofecho
- Returns:
- output of
echo
-
echoReply
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoReplyOutput>> echoReply(EchoReplyInput input) Description copied from interface:ConnectionAdapter
Invokeecho-reply
RPC. See alsoEchoReply
.- Specified by:
echoReply
in interfaceConnectionAdapter
- Parameters:
input
- ofecho-reply
- Returns:
- output of
echo-reply
-
experimenter
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<ExperimenterOutput>> experimenter(ExperimenterInput input) Description copied from interface:ConnectionAdapter
Invokeexperimenter
RPC. See alsoExperimenter
.- Specified by:
experimenter
in interfaceConnectionAdapter
- Parameters:
input
- ofexperimenter
- Returns:
- output of
experimenter
-
getConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetConfigOutput>> getConfig(GetConfigInput input) Description copied from interface:ConnectionAdapter
Invokeget-config
RPC. See alsoGetConfig
.- Specified by:
getConfig
in interfaceConnectionAdapter
- Parameters:
input
- ofget-config
- Returns:
- output of
get-config
-
getFeatures
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetFeaturesOutput>> getFeatures(GetFeaturesInput input) Description copied from interface:ConnectionAdapter
Invokeget-features
RPC. See alsoGetFeatures
.- Specified by:
getFeatures
in interfaceConnectionAdapter
- Parameters:
input
- ofget-features
- Returns:
- output of
get-features
-
getQueueConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetQueueConfigOutput>> getQueueConfig(GetQueueConfigInput input) Description copied from interface:ConnectionAdapter
Invokeget-queue-config
RPC. See alsoGetQueueConfig
.- Specified by:
getQueueConfig
in interfaceConnectionAdapter
- Parameters:
input
- ofget-queue-config
- Returns:
- output of
get-queue-config
-
groupMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GroupModOutput>> groupMod(GroupModInput input) Description copied from interface:ConnectionAdapter
Invokegroup-mod
RPC. See alsoGroupMod
.- Specified by:
groupMod
in interfaceConnectionAdapter
- Parameters:
input
- ofgroup-mod
- Returns:
- output of
group-mod
-
hello
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<HelloOutput>> hello(HelloInput input) Description copied from interface:ConnectionAdapter
Invokehello
RPC. See alsoHello
.- Specified by:
hello
in interfaceConnectionAdapter
- Parameters:
input
- ofhello
- Returns:
- output of
hello
-
meterMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<MeterModOutput>> meterMod(MeterModInput input) Description copied from interface:ConnectionAdapter
Invokemeter-mod
RPC. See alsoMeterMod
.- Specified by:
meterMod
in interfaceConnectionAdapter
- Parameters:
input
- ofmeter-mod
- Returns:
- output of
meter-mod
-
packetOut
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PacketOutOutput>> packetOut(PacketOutInput input) Description copied from interface:ConnectionAdapter
Invokepacket-out
RPC. See alsoPacketOut
.- Specified by:
packetOut
in interfaceConnectionAdapter
- Parameters:
input
- ofpacket-out
- Returns:
- output of
packet-out
-
multipartRequest
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<MultipartRequestOutput>> multipartRequest(MultipartRequestInput input) Description copied from interface:ConnectionAdapter
Invokemultipart-request
RPC. See alsoMultipartRequest
.- Specified by:
multipartRequest
in interfaceConnectionAdapter
- Parameters:
input
- ofmultipart-request
- Returns:
- output of
multipart-request
-
portMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PortModOutput>> portMod(PortModInput input) Description copied from interface:ConnectionAdapter
Invokeport-mod
RPC. See alsoPortMod
.- Specified by:
portMod
in interfaceConnectionAdapter
- Parameters:
input
- ofport-mod
- Returns:
- output of
port-mod
-
roleRequest
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<RoleRequestOutput>> roleRequest(RoleRequestInput input) Description copied from interface:ConnectionAdapter
Invokerole-request
RPC. See alsoRoleRequest
.- Specified by:
roleRequest
in interfaceConnectionAdapter
- Parameters:
input
- ofrole-request
- Returns:
- output of
role-request
-
setConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<SetConfigOutput>> setConfig(SetConfigInput input) Description copied from interface:ConnectionAdapter
Invokeset-config
RPC. See alsoSetConfig
.- Specified by:
setConfig
in interfaceConnectionAdapter
- Parameters:
input
- ofset-config
- Returns:
- output of
set-config
-
tableMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<TableModOutput>> tableMod(TableModInput input) Description copied from interface:ConnectionAdapter
Invoketable-mod
RPC. See alsoTableMod
.- Specified by:
tableMod
in interfaceConnectionAdapter
- Parameters:
input
- oftable-mod
- Returns:
- output of
table-mod
-
getAsync
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetAsyncOutput>> getAsync(GetAsyncInput input) Description copied from interface:ConnectionAdapter
Invokeget-async
RPC. See alsoGetAsync
.- Specified by:
getAsync
in interfaceConnectionAdapter
- Parameters:
input
- ofget-async
- Returns:
- output of
get-async
-
setAsync
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<SetAsyncOutput>> setAsync(SetAsyncInput input) Description copied from interface:ConnectionAdapter
Invokeset-async
RPC. See alsoSetAsync
.- Specified by:
setAsync
in interfaceConnectionAdapter
- Parameters:
input
- ofset-async
- Returns:
- output of
set-async
-
isAlive
public boolean isAlive()Description copied from interface:ConnectionAdapter
Determines if the connection to the switch is alive.- Specified by:
isAlive
in interfaceConnectionAdapter
- Returns:
- true, if connection to switch is alive
-
isAutoRead
public boolean isAutoRead()Description copied from interface:ConnectionAdapter
Determines if the channel is configured to auto-read.- Specified by:
isAutoRead
in interfaceConnectionAdapter
- Returns:
- true, if channel is configured to auto-read
-
setAutoRead
public void setAutoRead(boolean autoRead) Description copied from interface:ConnectionAdapter
Sets option for automatic channel reading - if set to false, incoming messages won't be read.- Specified by:
setAutoRead
in interfaceConnectionAdapter
- Parameters:
autoRead
- target value to be switched to
-
getRemoteAddress
Description copied from interface:ConnectionAdapter
Returns the address of the connected switch.- Specified by:
getRemoteAddress
in interfaceConnectionAdapter
- Returns:
- address of the remote end - address of a switch if connected
-
findRpcResponse
protected org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?> findRpcResponse(RpcResponseKey key) Return cached RpcListener ornull
if not cached.
-