Class ConnectionAdapterImpl
- java.lang.Object
-
- org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl
-
- All Implemented Interfaces:
ConnectionAdapter,ConnectionFacade,MessageConsumer,OpenflowProtocolService,org.opendaylight.yangtools.yang.binding.RpcService
public class ConnectionAdapterImpl extends Object implements ConnectionFacade
Handles messages (notifications + rpcs) and connections.- Author:
- mirehak, michal.polkorab
-
-
Field Summary
Fields Modifier and Type Field Description protected InetSocketAddressaddressprotected io.netty.channel.Channelchannelprotected booleandisconnectOccuredprotected org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueueoutputprotected static com.google.common.cache.RemovalListener<RpcResponseKey,org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>>REMOVAL_LISTENERprotected com.google.common.cache.Cache<RpcResponseKey,org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>>responseCacheexpiring cache for future rpcResponses.
-
Constructor Summary
Constructors Constructor Description ConnectionAdapterImpl(io.netty.channel.Channel channel, InetSocketAddress address, boolean useBarrier, int channelOutboundQueueSize)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<BarrierOutput>>barrier(BarrierInput input)voidcheckListeners()Throws exception if any of required listeners is missing.voidconsume(org.opendaylight.yangtools.yang.binding.DataObject message)Invoked to consume a message.voidconsumeDeviceMessage(org.opendaylight.yangtools.yang.binding.DataObject message)Method is equivalent toMessageConsumer.consume(DataObject)to prevent missing method in every children ofAbstractConnectionAdapterStatisticsclass, because we overriding original method forStatisticsCounters.Future<Boolean>disconnect()Disconnect corresponding switch.com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoOutput>>echo(EchoInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoReplyOutput>>echoReply(EchoReplyInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<ExperimenterOutput>>experimenter(ExperimenterInput input)Send experimenter message to device, reply is not solicitated.protected org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener<?>findRpcResponse(RpcResponseKey key)Return cached RpcListener ornullif not cached.voidfireConnectionReadyNotification()Notify listener about connection ready-to-use event.com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<FlowModOutput>>flowMod(FlowModInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetAsyncOutput>>getAsync(GetAsyncInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetConfigOutput>>getConfig(GetConfigInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetFeaturesOutput>>getFeatures(GetFeaturesInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetQueueConfigOutput>>getQueueConfig(GetQueueConfigInput input)InetSocketAddressgetRemoteAddress()Returns the address of the connected switch.com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GroupModOutput>>groupMod(GroupModInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<HelloOutput>>hello(HelloInput input)booleanisAlive()Determines if the connection to the switch is alive.booleanisAutoRead()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)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<MultipartRequestOutput>>multipartRequest(MultipartRequestInput input)voidonSwitchCertificateIdentified(X509Certificate switchcertificate)Notify listener about switch certificate information.com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PacketOutOutput>>packetOut(PacketOutInput input)com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PortModOutput>>portMod(PortModInput input)<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)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.yang.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.voidsetAlienMessageListener(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)voidsetAutoRead(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)voidsetConnectionReadyListener(ConnectionReadyListener connectionReadyListener)Set listener for connection became ready-to-use event.voidsetDatapathId(BigInteger datapathId)Set datapathId for the dpn.voidsetExecutorService(ExecutorService executorService)Sets executorService.voidsetMessageListener(OpenflowProtocolListener messageListener)Sets the protocol message listener.voidsetPacketInFiltering(boolean enabled)Set filtering of PacketIn messages.voidsetSystemListener(SystemNotificationsListener systemListener)Sets the system message listener.com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<TableModOutput>>tableMod(TableModInput input)-
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
disconnect, getRemoteAddress, isAlive, isAutoRead, setAutoRead
-
Methods inherited from interface org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer
consume
-
Methods inherited from interface org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OpenflowProtocolService
barrier, echo, echoReply, experimenter, flowMod, getAsync, getConfig, getFeatures, getQueueConfig, groupMod, hello, meterMod, multipartRequest, packetOut, portMod, roleRequest, setAsync, setConfig, tableMod
-
-
-
-
Field Detail
-
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
protected final InetSocketAddress 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<?>> responseCache
expiring cache for future rpcResponses.
-
-
Constructor Detail
-
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 Detail
-
setMessageListener
public void setMessageListener(OpenflowProtocolListener messageListener)
Description copied from interface:ConnectionAdapterSets the protocol message listener.- Specified by:
setMessageListenerin interfaceConnectionAdapter- Parameters:
messageListener- here will be pushed all messages from switch
-
setConnectionReadyListener
public void setConnectionReadyListener(ConnectionReadyListener connectionReadyListener)
Description copied from interface:ConnectionAdapterSet listener for connection became ready-to-use event.- Specified by:
setConnectionReadyListenerin interfaceConnectionAdapter- Parameters:
connectionReadyListener- listens to connection ready event
-
setSystemListener
public void setSystemListener(SystemNotificationsListener systemListener)
Description copied from interface:ConnectionAdapterSets the system message listener.- Specified by:
setSystemListenerin interfaceConnectionAdapter- Parameters:
systemListener- here will be pushed all system messages from library
-
setAlienMessageListener
public void setAlienMessageListener(AlienMessageListener alienMessageListener)
Description copied from interface:ConnectionAdapterSet handler for alien messages received from device.- Specified by:
setAlienMessageListenerin interfaceConnectionAdapter- Parameters:
alienMessageListener- here will be pushed all alien messages from switch
-
consumeDeviceMessage
public void consumeDeviceMessage(org.opendaylight.yangtools.yang.binding.DataObject message)
Method is equivalent toMessageConsumer.consume(DataObject)to prevent missing method in every children ofAbstractConnectionAdapterStatisticsclass, because we overriding original method forStatisticsCounters.- Parameters:
message- from device to processing
-
checkListeners
public void checkListeners()
Description copied from interface:ConnectionAdapterThrows exception if any of required listeners is missing.- Specified by:
checkListenersin interfaceConnectionAdapter
-
fireConnectionReadyNotification
public void fireConnectionReadyNotification()
Description copied from interface:ConnectionAdapterNotify listener about connection ready-to-use event.- Specified by:
fireConnectionReadyNotificationin interfaceConnectionAdapter
-
onSwitchCertificateIdentified
public void onSwitchCertificateIdentified(X509Certificate switchcertificate)
Description copied from interface:ConnectionAdapterNotify listener about switch certificate information.- Specified by:
onSwitchCertificateIdentifiedin interfaceConnectionAdapter- Parameters:
switchcertificate- X509Certificate of switch
-
registerOutboundQueueHandler
public <T extends OutboundQueueHandler> OutboundQueueHandlerRegistration<T> registerOutboundQueueHandler(T handler, int maxQueueDepth, long maxBarrierNanos)
Description copied from interface:ConnectionAdapterRegisters a new bypass outbound queue.- Specified by:
registerOutboundQueueHandlerin 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:ConnectionAdapterSet filtering of PacketIn messages. By default these messages are not filtered.- Specified by:
setPacketInFilteringin interfaceConnectionAdapter- Parameters:
enabled- True if PacketIn messages should be filtered, false if they should be reported.
-
setDatapathId
public void setDatapathId(BigInteger datapathId)
Description copied from interface:ConnectionAdapterSet datapathId for the dpn.- Specified by:
setDatapathIdin interfaceConnectionAdapter- Parameters:
datapathId- of the dpn
-
setExecutorService
public void setExecutorService(ExecutorService executorService)
Description copied from interface:ConnectionAdapterSets executorService.- Specified by:
setExecutorServicein interfaceConnectionAdapter- Parameters:
executorService- for all dpns
-
flowMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<FlowModOutput>> flowMod(FlowModInput input)
- Specified by:
flowModin interfaceOpenflowProtocolService
-
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,
RpcResultwill contain errors and failed status - else
RpcResultwill 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.yang.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,
RpcResultwithout errors and successful status will be returned, - else
RpcResultwill contain errors and failed status
- if send successful,
-
consume
public void consume(org.opendaylight.yangtools.yang.binding.DataObject message)
Description copied from interface:MessageConsumerInvoked to consume a message.- Specified by:
consumein interfaceMessageConsumer- Parameters:
message- to process
-
disconnect
public Future<Boolean> disconnect()
Description copied from interface:ConnectionAdapterDisconnect corresponding switch.- Specified by:
disconnectin 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)
- Specified by:
barrierin interfaceOpenflowProtocolService
-
echo
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoOutput>> echo(EchoInput input)
- Specified by:
echoin interfaceOpenflowProtocolService
-
echoReply
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<EchoReplyOutput>> echoReply(EchoReplyInput input)
- Specified by:
echoReplyin interfaceOpenflowProtocolService
-
experimenter
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<ExperimenterOutput>> experimenter(ExperimenterInput input)
Description copied from interface:OpenflowProtocolServiceSend experimenter message to device, reply is not solicitated.- Specified by:
experimenterin interfaceOpenflowProtocolService
-
getConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetConfigOutput>> getConfig(GetConfigInput input)
- Specified by:
getConfigin interfaceOpenflowProtocolService
-
getFeatures
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetFeaturesOutput>> getFeatures(GetFeaturesInput input)
- Specified by:
getFeaturesin interfaceOpenflowProtocolService
-
getQueueConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetQueueConfigOutput>> getQueueConfig(GetQueueConfigInput input)
- Specified by:
getQueueConfigin interfaceOpenflowProtocolService
-
groupMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GroupModOutput>> groupMod(GroupModInput input)
- Specified by:
groupModin interfaceOpenflowProtocolService
-
hello
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<HelloOutput>> hello(HelloInput input)
- Specified by:
helloin interfaceOpenflowProtocolService
-
meterMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<MeterModOutput>> meterMod(MeterModInput input)
- Specified by:
meterModin interfaceOpenflowProtocolService
-
packetOut
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PacketOutOutput>> packetOut(PacketOutInput input)
- Specified by:
packetOutin interfaceOpenflowProtocolService
-
multipartRequest
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<MultipartRequestOutput>> multipartRequest(MultipartRequestInput input)
- Specified by:
multipartRequestin interfaceOpenflowProtocolService
-
portMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<PortModOutput>> portMod(PortModInput input)
- Specified by:
portModin interfaceOpenflowProtocolService
-
roleRequest
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<RoleRequestOutput>> roleRequest(RoleRequestInput input)
- Specified by:
roleRequestin interfaceOpenflowProtocolService
-
setConfig
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<SetConfigOutput>> setConfig(SetConfigInput input)
- Specified by:
setConfigin interfaceOpenflowProtocolService
-
tableMod
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<TableModOutput>> tableMod(TableModInput input)
- Specified by:
tableModin interfaceOpenflowProtocolService
-
getAsync
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<GetAsyncOutput>> getAsync(GetAsyncInput input)
- Specified by:
getAsyncin interfaceOpenflowProtocolService
-
setAsync
public com.google.common.util.concurrent.ListenableFuture<org.opendaylight.yangtools.yang.common.RpcResult<SetAsyncOutput>> setAsync(SetAsyncInput input)
- Specified by:
setAsyncin interfaceOpenflowProtocolService
-
isAlive
public boolean isAlive()
Description copied from interface:ConnectionAdapterDetermines if the connection to the switch is alive.- Specified by:
isAlivein interfaceConnectionAdapter- Returns:
- true, if connection to switch is alive
-
isAutoRead
public boolean isAutoRead()
Description copied from interface:ConnectionAdapterDetermines if the channel is configured to auto-read.- Specified by:
isAutoReadin interfaceConnectionAdapter- Returns:
- true, if channel is configured to auto-read
-
setAutoRead
public void setAutoRead(boolean autoRead)
Description copied from interface:ConnectionAdapterSets option for automatic channel reading - if set to false, incoming messages won't be read.- Specified by:
setAutoReadin interfaceConnectionAdapter- Parameters:
autoRead- target value to be switched to
-
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:ConnectionAdapterReturns the address of the connected switch.- Specified by:
getRemoteAddressin 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 ornullif not cached.
-
-