Class LocalVNS
java.lang.Object
org.apache.vinci.transport.VinciServableAdapter
org.apache.uima.collection.impl.cpm.container.deployer.vns.LocalVNS
- All Implemented Interfaces:
Runnable
,TransportableFactory
,VinciServable
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptioneval
(Transportable in) Main method called by services advertising their availability.protected void
finalize()
int
getPort()
Returns the next available port.int
Returns the port number on which local VNS is listening for requests.boolean
isAvailable
(int port) Determines if a given port is free.void
run()
Starts VNS thread.void
setConnectionPool
(BoundedWorkQueue pQueue) Associates a port pool with instance of VNS.void
shutdown()
Stop the VNS service.Methods inherited from class org.apache.vinci.transport.VinciServableAdapter
cleanExit, makeTransportable
-
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
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 usedaEndPort
- - 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
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
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
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 interfaceVinciServable
- Specified by:
eval
in classVinciServableAdapter
- Parameters:
in
- the in- Returns:
- the transportable
- Throws:
ServiceException
- the service exception
-
shutdown
public void shutdown()Stop the VNS service. -
finalize
-
run
public void run()Starts VNS thread. This thread runs continuously waiting for service registrations and returning port number back.
-