Class ProbingAction

  • All Implemented Interfaces:
    java.util.concurrent.Callable<io.netty.channel.ChannelFuture>

    public abstract class ProbingAction
    extends java.lang.Object
    implements java.util.concurrent.Callable<io.netty.channel.ChannelFuture>
    AutoValue class that represents action generated by ProbingStep

    Inherits from Callable, as it has can be called to perform its specified task, and return the ChannelFuture that will be informed when the task has been completed

    Is an immutable class, as it is comprised of the tools necessary for making a specific type of connection. It goes hand in hand with Protocol, which specifies the kind of overall connection to be made. Protocol gives the outline and ProbingAction gives the details of that connection.

    In its build, if there is no channel supplied, it will create a channel from the attributes already supplied. Then, it only sends the OutboundMessageType down the pipeline when informed that the connection is successful. If the channel is supplied, the connection future is automatically set to successful.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ProbingAction.Builder
      AutoValue.Builder that does work of creating connection when not already present.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static io.netty.util.AttributeKey<io.netty.channel.ChannelFuture> CONNECTION_FUTURE_KEY
      AttributeKey in channel that gives ChannelFuture that is set to success when channel is active.
      static io.netty.util.AttributeKey<java.lang.String> REMOTE_ADDRESS_KEY
      AttributeKey in channel that gives the information of the channel's host.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProbingAction()  
    • Field Detail

      • CONNECTION_FUTURE_KEY

        public static final io.netty.util.AttributeKey<io.netty.channel.ChannelFuture> CONNECTION_FUTURE_KEY
        AttributeKey in channel that gives ChannelFuture that is set to success when channel is active.
      • REMOTE_ADDRESS_KEY

        public static final io.netty.util.AttributeKey<java.lang.String> REMOTE_ADDRESS_KEY
        AttributeKey in channel that gives the information of the channel's host.
    • Constructor Detail

      • ProbingAction

        public ProbingAction()
    • Method Detail

      • delay

        public abstract org.joda.time.Duration delay()
        Actual Duration of this delay
      • channel

        public abstract io.netty.channel.Channel channel()
        Channel object that is either created by or passed into this ProbingAction instance
      • protocol

        public abstract Protocol protocol()
        The Protocol instance that specifies type of connection
      • host

        public abstract java.lang.String host()
        The hostname of the remote host we have a connection or will make a connection to
      • call

        public io.netty.channel.ChannelFuture call()
        Performs the work of the actual action.

        First, checks if channel is active by setting a listener to perform the bulk of the work when the connection future is successful.

        Once the connection is successful, we establish which of the handlers in the pipeline is the ActionHandler.From that, we can obtain a future that is marked as a success when we receive an expected response from the server.

        Next, we set a timer set to a specified delay. After the delay has passed, we send the outboundMessage down the channel pipeline, and when we observe a success or failure, we inform the ProbingStep of this.

        Specified by:
        call in interface java.util.concurrent.Callable<io.netty.channel.ChannelFuture>
        Returns:
        ChannelFuture that denotes when the action has been successfully performed.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object