Class Connector

java.lang.Object
com.fishlib.io.sched.Job
com.illumon.iris.db.v2.locations.remote.Connector
All Implemented Interfaces:
com.fishlib.base.log.LogOutputAppendable

public class Connector extends com.fishlib.io.sched.Job implements com.fishlib.base.log.LogOutputAppendable
This class is a clone of Connector, with the following changes:
  • maybeRetry(IOException) quits trying when the job has been canceled.
  • IOJobImplLenient is used instead of IOJobImpl
Fishlib: "This class creates a new IOJob by connecting to a specific SocketAddress."
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    these are the states the connector can be in
  • Constructor Summary

    Constructors
    Constructor
    Description
    Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,SocketChannel,IOException> rawObserver)
    Initiate a new connection, delivering only a raw socket
    Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, boolean useLenientIOJob, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer)
    Initiate a new connection.
    Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer)
    Initiate a new connection.
    Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer)
    Initiate a new connection.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.fishlib.base.log.LogOutput
    append(com.fishlib.base.log.LogOutput logOutput)
     
    void
     
    int
     
    int
     
     
     
    int
    invoke(SelectableChannel channel, int readyOps, com.fishlib.base.Procedure.Nullary handoff)
     
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Connector

      public Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer) throws IOException
      Initiate a new connection.
      Parameters:
      addr - the address to which we will connect
      connectParameters - the timing and retry parameters
      ioParameters - the IO parameters for the connected socket
      handler - the IO handler for the connected socket
      observer - called when the connection is established or fails
      Throws:
      IOException
    • Connector

      public Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer) throws IOException
      Initiate a new connection.
      Parameters:
      addr - the address for the initial connection, may be null
      addrFun - a function which provides the address to which we will connect
      connectParameters - the timing and retry parameters
      ioParameters - the IO parameters for the connected socket
      handler - the IO handler for the connected socket
      observer - called when the connection is established or fails
      Throws:
      IOException
    • Connector

      public Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.sched.IOParameters ioParameters, com.fishlib.io.sched.IOStats stats, com.fishlib.io.sched.IOHandler handler, com.fishlib.io.logger.Logger log, boolean useLenientIOJob, com.fishlib.base.Procedure.Ternary<Connector,com.fishlib.io.sched.IOJob,IOException> observer) throws IOException
      Initiate a new connection.
      Parameters:
      addr - the address for the initial connection, may be null
      addrFun - a function which provides the address to which we will connect
      connectParameters - the timing and retry parameters
      ioParameters - the IO parameters for the connected socket
      handler - the IO handler for the connected socket
      useLenientIOJob - if true, use the IOJobImplLenient implementation, else IOJobImpl
      observer - called when the connection is established or fails
      Throws:
      IOException
    • Connector

      public Connector(com.fishlib.io.sched.Scheduler sched, com.fishlib.io.sched.SocketFactory socketFactory, SocketAddress addr, com.fishlib.base.Function.Nullary<SocketAddress> addrFun, com.fishlib.io.sched.ConnectParameters connectParameters, com.fishlib.io.logger.Logger log, com.fishlib.base.Procedure.Ternary<Connector,SocketChannel,IOException> rawObserver) throws IOException
      Initiate a new connection, delivering only a raw socket
      Parameters:
      addr - the address for the initial connection, may be null
      addrFun - a function which provides the address to which we will connect
      connectParameters - the timing and retry parameters
      rawObserver - called when the connection is established or fails
      Throws:
      IOException
  • Method Details

    • append

      public com.fishlib.base.log.LogOutput append(com.fishlib.base.log.LogOutput logOutput)
      Specified by:
      append in interface com.fishlib.base.log.LogOutputAppendable
      Overrides:
      append in class com.fishlib.io.sched.Job
    • getSocket

      public SocketChannel getSocket()
    • getState

      public Connector.State getState()
    • getConnectFailures

      public int getConnectFailures()
    • getDroppedConnections

      public int getDroppedConnections()
    • invoke

      public int invoke(SelectableChannel channel, int readyOps, com.fishlib.base.Procedure.Nullary handoff) throws IOException
      Specified by:
      invoke in class com.fishlib.io.sched.Job
      Throws:
      IOException
    • cancelled

      public void cancelled()
      Specified by:
      cancelled in class com.fishlib.io.sched.Job
    • timedOut

      public void timedOut()
      Specified by:
      timedOut in class com.fishlib.io.sched.Job