java.lang.Object
org.apache.vinci.transport.VinciServableAdapter
org.apache.uima.collection.impl.cpm.container.deployer.vns.LocalVNS
All Implemented Interfaces:
Runnable, TransportableFactory, VinciServable

public class LocalVNS extends VinciServableAdapter implements Runnable
LOCAL Vinci Naming Service. Used by locally deployed TAEs. Locally, meaning TAEs running on the same machine but in different JVM. This VNS is primarily used by TAEs to advertise their availability after succesfull startup.
  • Constructor Details

    • LocalVNS

      public LocalVNS()
      Instantiates a new local VNS.
    • LocalVNS

      public LocalVNS(String aStartPort, String aEndPort, String aVNSPort) throws PortUnreachableException
      Instantiates Local Vinci Naming Service.
      Parameters:
      aStartPort - - a starting port # for clients (services)
      aEndPort - - an ending port # for clients( services)
      aVNSPort - - port on which this VNS will listen on
      Throws:
      PortUnreachableException - the port unreachable exception
    • LocalVNS

      public LocalVNS(int aStartPort, int aEndPort, int aVNSPort) throws PortUnreachableException
      Initialize local VNS instance with a range of ports, and the port for the VNS itself. A given port is tested first for availability. If it is not available the next port is tested, until one is found to be available.
      Parameters:
      aStartPort - - starting port number used
      aEndPort - - end port number. Together with StartPort defines the range of ports (port pool)
      aVNSPort - - port on which this VNS will listen for requests
      Throws:
      PortUnreachableException - unreachable port after retries
  • Method Details

    • setConnectionPool

      public void setConnectionPool(BoundedWorkQueue pQueue)
      Associates a port pool with instance of VNS.
      Parameters:
      pQueue - - queue where allocated ports will be added
    • isAvailable

      public boolean isAvailable(int port)
      Determines if a given port is free. It establishes a short lived connection to the port and if successful returns false.
      Parameters:
      port - number to check
      Returns:
      true, if is available
    • getVNSPort

      public int getVNSPort()
      Returns the port number on which local VNS is listening for requests.
      Returns:
      - VNS port number
    • getPort

      public int getPort() throws PortUnreachableException
      Returns the next available port. The port is allocated from a cache of ports given to the VNS service on startup.
      Returns:
      - free port
      Throws:
      PortUnreachableException - can't get port in configured range
    • eval

      public Transportable eval(Transportable in) throws ServiceException
      Main method called by services advertising their availability. Each service, on startup sends "serveon" request to VNS and waits for assigned port. The VNS looks up its cahce of ports and returns to the service one that has not yest allocated.
      Specified by:
      eval in interface VinciServable
      Specified by:
      eval in class VinciServableAdapter
      Parameters:
      in - the in
      Returns:
      the transportable
      Throws:
      ServiceException - the service exception
    • shutdown

      public void shutdown()
      Stop the VNS service.
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • run

      public void run()
      Starts VNS thread. This thread runs continuously waiting for service registrations and returning port number back.
      Specified by:
      run in interface Runnable