public class DefaultCacheServer extends Base
DefaultCacheServer can also monitor services it started to ensure they exist. Monitoring services is enabled by default.
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_WAIT_MILLIS
The default number of milliseconds between checks for service restart.
|
protected boolean |
m_fServicesStarted
Flag that indicates whether this instance of DefaultCacheServer has
called start on the associated services.
|
protected boolean |
m_fShutdown
Flag that indicates whether of not the shutdown was initiated.
|
protected ServiceMonitor |
m_serviceMon
The ServiceMonitor used to monitor services.
|
protected Thread |
m_threadShutdown
Shutdown hook thread.
|
Constructor and Description |
---|
DefaultCacheServer(ConfigurableCacheFactory factory)
Construct a DefaultCacheServer using the provided factory.
|
Modifier and Type | Method and Description |
---|---|
protected static DefaultCacheServer |
ensureInstance(ConfigurableCacheFactory factory)
Returns the DefaultCacheServer singleton, creating it if necessary.
|
protected static ConfigurableCacheFactory |
getConfigurableCacheFactory()
Gets a ConfigurableCacheFactory based on the default configuration.
|
static DefaultCacheServer |
getInstance()
Returns the DefaultCacheServer created by a previous invocation of
ensureInstance(ConfigurableCacheFactory) . |
protected String |
getServiceBanner(Cluster cluster)
Create a list of running services in the given Cluster.
|
protected void |
handleEnsureServiceException(RuntimeException e)
Invoked if starting a service raises an exception.
|
protected void |
initialStartServices(long cWaitMillis)
Setup any necessary resources and start all services.
|
boolean |
isMonitorStopped()
Return the
ServiceMonitor used by the cache server. |
static void |
main(String[] asArg)
Entry point: start the cache server under two possible contexts:
With a "coherence-cache-config.xsd" compliant configuration file.
|
protected void |
markServicesStarted()
Set the "services started" flag.
|
protected void |
monitorServices(long cWaitMillis)
Check the ServiceMonitor status ensuring it is monitoring services.
|
protected boolean |
notifyShutdown()
Ensure the DCS instance has shutdown.
|
protected void |
reportStarted()
Log the start message.
|
static void |
shutdown()
Shutdown the cache server.
|
void |
shutdownServer()
Shutdown the DefaultCacheServer.
|
static List |
start()
Start all services that are declared as requiring an "autostart" in
the default configurable factory XML descriptor.
|
static List |
start(ConfigurableCacheFactory factory)
Start all services that are declared as requiring an "autostart" in
the configurable factory XML descriptor.
|
void |
startAndMonitor(long cWaitMillis)
Start the cache server and check the service status periodically,
restarting any stopped services.
|
static void |
startDaemon()
Deprecated.
use
startServerDaemon() instead |
protected static void |
startDaemon(DefaultCacheServer dcs)
Start the provided cache server on a dedicated daemon thread.
|
void |
startDaemon(long cWaitMillis)
Start the cache server and asynchronously check the service status
periodically, restarting any services that have stopped.
|
static DefaultCacheServer |
startServerDaemon()
Start the cache server on a dedicated daemon thread.
|
List<Service> |
startServices()
Start all services that are declared as requiring an "autostart" in
the configurable factory XML descriptor.
|
protected Map<Service,String> |
startServicesInternal()
Starts the services marked with autostart returning a map of a service
name to the started service.
|
protected boolean |
stopMonitoring()
Ensures the DCS instance has shutdown and the associated
ServiceMonitor is no longer monitoring services.
|
protected void |
stopServiceMonitor()
Stop the ServiceMonitor.
|
void |
waitForServiceStart()
Block the calling thread until DefaultCacheServer has called start on all
associated services.
|
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public static final long DEFAULT_WAIT_MILLIS
protected volatile ServiceMonitor m_serviceMon
protected volatile boolean m_fShutdown
protected boolean m_fServicesStarted
initialStartServices(long)
protected Thread m_threadShutdown
public DefaultCacheServer(ConfigurableCacheFactory factory)
factory
- the ConfigurableCacheFactorypublic void startAndMonitor(long cWaitMillis)
This method will block the calling thread.
cWaitMillis
- the number of milliseconds between checkspublic void startDaemon(long cWaitMillis)
cWaitMillis
- the number of milliseconds between checkspublic List<Service> startServices()
public void shutdownServer()
public void waitForServiceStart()
IllegalStateException
- iff the services were not attempted to be
started, which could be due to concurrent shutdownprotected void markServicesStarted()
public static void shutdown()
public static void startDaemon()
startServerDaemon()
insteadpublic static DefaultCacheServer startServerDaemon()
DefaultCacheServer
startedpublic static void main(String[] asArg)
Default configuration file is "coherence-cache-config.xml"; default keep alive interval is 5 sec.
Example: java -server -Xms512m -Xmx512m com.tangosol.net.DefaultCacheServer cache-config.xml 5 GAR Example: java -server -Xms512m -Xmx512m com.tangosol.net.DefaultCacheServer my-app.gar MyApp 5
asArg
- the command line argumentspublic static List start()
This method will not create a ServiceMonitor for started services.
public static List start(ConfigurableCacheFactory factory)
This method will not create a ServiceMonitor for started services.
factory
- ConfigurableCacheFactory to useprotected boolean stopMonitoring()
protected void stopServiceMonitor()
protected boolean notifyShutdown()
protected void initialStartServices(long cWaitMillis)
cWaitMillis
- the interval, in milliseconds, to monitor servicesprotected void reportStarted()
protected Map<Service,String> startServicesInternal()
protected void monitorServices(long cWaitMillis)
cWaitMillis
- the number of milliseconds between checksprotected void handleEnsureServiceException(RuntimeException e)
e
- the RuntimeExceptionstartServices()
protected String getServiceBanner(Cluster cluster)
cluster
- Cluster for which to create a list of running servicespublic boolean isMonitorStopped()
ServiceMonitor
used by the cache server.protected static void startDaemon(DefaultCacheServer dcs)
dcs
- the cache server to startprotected static ConfigurableCacheFactory getConfigurableCacheFactory()
protected static DefaultCacheServer ensureInstance(ConfigurableCacheFactory factory)
factory
- the CacheFactory to usepublic static DefaultCacheServer getInstance()
ensureInstance(ConfigurableCacheFactory)
.
Will throw an IllegalStateException if there is no instance.