public class CycServerPool extends Object
| Constructor and Description |
|---|
CycServerPool(Collection<String> cycServersSpecs)
Creates a Cyc server pool from provided collection of CycAddress string specifications.
|
CycServerPool(com.cyc.session.CycAddress cycAddress) |
CycServerPool(List<com.cyc.session.CycAddress> cycAddresses) |
CycServerPool(String cycServersSpecs)
Creates a Cyc server pool from provided string specification.
|
| Modifier and Type | Method and Description |
|---|---|
static CycServerPool |
createFromCurrentSession()
Creates a CycServerPool from the CycAddress specified in the current CycSession, with a default
concurrency level of 1 if unspecified in the original address.
|
static CycServerPool |
createFromCurrentSessionWithDefaults(int defaultConcurrencyLevel)
Creates a CycServerPool from the CycAddress specified in the current CycSession, with a default
concurrency level if unspecified in the original address.
|
static CycServerPool |
createFromServersWithDefaults(Iterable<com.cyc.session.CycAddress> addresses,
int defaultConcurrencyLevel)
Creates a CycServerPool for a set of CycAddresses, with a default concurrency level for each if
unspecified in the original addresses.
|
static CycServerPool |
createFromServerWithDefaults(com.cyc.session.CycAddress address,
int defaultConcurrencyLevel)
Creates a CycServerPool for a CycAddress, with a default concurrency level if unspecified in
the original address.
|
static CycServerPool |
createFromSessionWithDefaults(com.cyc.session.CycSession session,
int defaultConcurrencyLevel)
Creates a CycServerPool from the CycAddress specified in a CycSession, with a default
concurrency level if unspecified in the original address.
|
int |
getAvailableWorkerCount()
Get the number of available workers in the pool.
|
int |
getAvailableWorkerCount(com.cyc.session.CycAddress address)
Get the number of available workers for a Cyc server.
|
int |
getCycServerCount() |
com.cyc.session.CycAddress |
getDefaultServer() |
int |
getMaxWorkerCount()
Get the maximum number of workers in the pool.
|
int |
getMaxWorkerCount(com.cyc.session.CycAddress address)
Get the maximum number of workers for a Cyc server.
|
List<com.cyc.session.CycAddress> |
getServerAddresses() |
static boolean |
isValidString(String possiblyCycPoolSpec)
Returns true if
possiblyCycPoolSpec represents a valid Cyc server pool
specification. |
void |
releaseWorker(com.cyc.session.CycAddress cyc)
Returns an unused Cyc worker back to the pool.
|
com.cyc.session.CycAddress |
requestWorker()
Requests a Cyc worker from the pool, will block until one is available.
|
String |
toCycAddressString() |
String |
toString() |
public CycServerPool(List<com.cyc.session.CycAddress> cycAddresses)
public CycServerPool(com.cyc.session.CycAddress cycAddress)
public CycServerPool(Collection<String> cycServersSpecs)
cycServersSpecs - specification of a Cyc pool, listing servers in the following form:
Collectionpublic CycServerPool(String cycServersSpecs)
cycServersSpecs - specification of a Cyc pool, listing servers in the following form:
"host1:port1:c1,host2:port2:c2,host3:port3:c2...", where hostX specifies
the host name, portX specifies the network port, cX specifies the
concurrency level - maximum number of concurrent jobs a Cyc server will
allow. The cX parameter is optional and will default to 1 if absent.public static CycServerPool createFromServersWithDefaults(Iterable<com.cyc.session.CycAddress> addresses, int defaultConcurrencyLevel)
addresses - iterable group of CycAddresses from which to create the pooldefaultConcurrencyLevel - the default concurrency level for each CycAddress, if
unspecifiedpublic static CycServerPool createFromServerWithDefaults(com.cyc.session.CycAddress address, int defaultConcurrencyLevel)
address - CycAddress from which to create the pooldefaultConcurrencyLevel - the default concurrency level for the CycAddress, if unspecifiedpublic static CycServerPool createFromSessionWithDefaults(com.cyc.session.CycSession session, int defaultConcurrencyLevel)
session - CycAddress from which to create the pooldefaultConcurrencyLevel - the default concurrency level for the session's CycAddress, if
unspecifiedpublic static CycServerPool createFromCurrentSessionWithDefaults(int defaultConcurrencyLevel) throws com.cyc.session.exception.SessionConfigurationException, com.cyc.session.exception.SessionCommunicationException, com.cyc.session.exception.SessionInitializationException
defaultConcurrencyLevel - the default concurrency level for the session's CycAddress, if
unspecifiedcom.cyc.session.exception.SessionConfigurationExceptioncom.cyc.session.exception.SessionCommunicationExceptioncom.cyc.session.exception.SessionInitializationExceptionpublic static CycServerPool createFromCurrentSession() throws com.cyc.session.exception.SessionConfigurationException, com.cyc.session.exception.SessionCommunicationException, com.cyc.session.exception.SessionInitializationException
com.cyc.session.exception.SessionConfigurationExceptioncom.cyc.session.exception.SessionCommunicationExceptioncom.cyc.session.exception.SessionInitializationExceptionpublic static boolean isValidString(String possiblyCycPoolSpec)
possiblyCycPoolSpec represents a valid Cyc server pool
specification. A string should have the following form: "host1:port1:c1,host2:port2:c2".possiblyCycPoolSpec - string to check for validitypublic com.cyc.session.CycAddress getDefaultServer()
public int getCycServerCount()
public int getAvailableWorkerCount()
public int getAvailableWorkerCount(com.cyc.session.CycAddress address)
address - address of the Cyc server; only the host & port will be used, concurrency level
will be ignoredpublic int getMaxWorkerCount()
public int getMaxWorkerCount(com.cyc.session.CycAddress address)
address - address of the Cyc server; only the host & port will be used, concurrency level
will be ignoredpublic com.cyc.session.CycAddress requestWorker()
throws InterruptedException
InterruptedExceptionpublic void releaseWorker(com.cyc.session.CycAddress cyc)
cyc - Cyc worker to return to the poolpublic List<com.cyc.session.CycAddress> getServerAddresses()
public String toCycAddressString()
Copyright © 2013–2018 Cycorp, Inc.. All rights reserved.