public class VinciContext extends Object
This class can be used to globally affect various behaviors of Vinci clients and servers under its control (for example, which VNS to contact). There is one "global" VinciContext that is used by default, though anyone can create an alternate context should multiple sets of defaults be required in a single program. Each VinciContext also serves to cache resolve results for all clients under its control (for a default of 1 minute).
For the most part, Vinci library users won't have to directly deal with this class, since there is a global context used by default which is almost always adequate.
The most common use of this class is to programmatically specify a VNS hostname other than the default (which is the one specified by the Java property VNS_HOST).
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_VNS_CACHE_SIZE |
Constructor and Description |
---|
VinciContext(String myhost,
int myport) |
Modifier and Type | Method and Description |
---|---|
boolean |
areStaleLookupsAllowed()
Returns whether clients can use stale resolve cache entries for service location in the event
VNS is unreachable.
|
void |
cacheResolveResult(String serviceName,
ResolveResult r)
Provide a resolve result to cache.
|
void |
flushAll() |
void |
flushFromCache(String serviceName)
Flush any cache entries pertaining to the specified service.
|
ResolveResult |
getCachedResolveResult(String serviceName)
Get a cached resolve result (if any).
|
static VinciContext |
getGlobalContext()
Get the global VinciContext used by Vinci classes when no context is explicitly specified.
|
int |
getResolveCacheTTL()
Get the time-to-live of cached service locators (resolve results).
|
ResolveResult |
getStaleCachedResolveResult(String serviceName)
Get a cached resolve result (if any), but allow returning stale cache entries.
|
String |
getVNSHost()
Return the VNS hostname.
|
int |
getVNSPort()
Return the VNS listener port.
|
int |
getVNSResolveTimeout()
Get the timeout setting of VNS resolve queries.
|
int |
getVNSServeonTimeout()
Get the timeout setting of VNS serveon queries.
|
boolean |
isSocketKeepAliveEnabled()
Returns whether socket keepAlive is enabled.
|
VinciFrame |
rpc(Transportable in,
String service_name)
See documentation for VinciClient.rpc().
|
VinciFrame |
rpc(Transportable in,
String service_name,
int timeout)
See documentation for VinciClient.rpc().
|
VinciFrame |
rpc(Transportable in,
String service_name,
int socket_timeout,
int connect_timeout)
See documentation for VinciClient.rpc().
|
Transportable |
sendAndReceive(Transportable in,
String service_name,
TransportableFactory factory)
See documentation for VinciClient.sendAndReceive().
|
Transportable |
sendAndReceive(Transportable in,
String service_name,
TransportableFactory factory,
int socket_timeout)
See documentation for VinciClient.sendAndReceive().
|
Transportable |
sendAndReceive(Transportable in,
String service_name,
TransportableFactory factory,
int socket_timeout,
int connect_timeout)
See documentation for VinciClient.sendAndReceive().
|
void |
setAllowStaleLookups(boolean b)
Set whether clients can use stale resolve cache entries for service location in the event VNS
is unreachable.
|
void |
setResolveCacheTTL(int millis)
Set the time-to-live of cached service locators (resolve results).
|
void |
setSocketKeepAliveEnabled(boolean b)
Set whether socket keepAlive is enabled.
|
void |
setVNSCacheSize(int to)
Set the size of the VNS cache.
|
void |
setVNSHost(String h)
Set the VNS hostname.
|
void |
setVNSPort(int p)
Set the VNS port.
|
void |
setVNSResolveTimeout(int millis)
Set the timeout of VNS resolve queries.
|
void |
setVNSServeonTimeout(int millis)
Set the timeout of VNS serveon queries.
|
public static final int DEFAULT_VNS_CACHE_SIZE
public VinciContext(String myhost, int myport)
myhost
- -myport
- -public void setVNSCacheSize(int to)
to
- The limit on the number of entries that will be maintained in the VNS cache.public String getVNSHost()
IllegalStateException
- if the VNS host has not been specified.public int getVNSPort()
public void setVNSHost(String h)
h
- -public void setVNSPort(int p)
p
- -public boolean areStaleLookupsAllowed()
public void setAllowStaleLookups(boolean b)
b
- -public int getResolveCacheTTL()
public void setResolveCacheTTL(int millis)
millis
- -public int getVNSResolveTimeout()
public void setVNSResolveTimeout(int millis)
millis
- -public int getVNSServeonTimeout()
public void setVNSServeonTimeout(int millis)
millis
- -public boolean isSocketKeepAliveEnabled()
Socket.setKeepAlive(boolean)
public void setSocketKeepAliveEnabled(boolean b)
b
- -Socket.setKeepAlive(boolean)
public static VinciContext getGlobalContext()
public ResolveResult getCachedResolveResult(String serviceName)
serviceName
- -public ResolveResult getStaleCachedResolveResult(String serviceName)
serviceName
- -public void cacheResolveResult(String serviceName, ResolveResult r)
serviceName
- -r
- -public void flushFromCache(String serviceName)
serviceName
- -public void flushAll()
public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory) throws IOException, ServiceException, ServiceDownException, VNSException
in
- -service_name
- -factory
- -IOException
- -ServiceException
- -ServiceDownException
- -VNSException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory, int socket_timeout) throws IOException, ServiceException
in
- -service_name
- -factory
- -socket_timeout
- -IOException
- -ServiceException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory, int socket_timeout, int connect_timeout) throws IOException, ServiceException
in
- -service_name
- -factory
- -socket_timeout
- -connect_timeout
- -IOException
- -ServiceException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
public VinciFrame rpc(Transportable in, String service_name) throws IOException, ServiceException, ServiceDownException, VNSException
in
- -service_name
- -IOException
- -ServiceException
- -ServiceDownException
- -VNSException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
public VinciFrame rpc(Transportable in, String service_name, int timeout) throws IOException, ServiceException, ServiceDownException, VNSException
in
- -service_name
- -timeout
- -IOException
- -ServiceException
- -ServiceDownException
- -VNSException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
public VinciFrame rpc(Transportable in, String service_name, int socket_timeout, int connect_timeout) throws IOException, ServiceException, ServiceDownException, VNSException
in
- -service_name
- -socket_timeout
- -connect_timeout
- -IOException
- -ServiceException
- -ServiceDownException
- -VNSException
- -IllegalStateException
- if the VNS host has not been specified.VinciClient
Copyright © 2016. All rights reserved.