Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.net
Class DefaultCacheServer

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.DefaultCacheServer

Direct Known Subclasses:
DefaultCacheServer.GarServer

public class DefaultCacheServer
extends Base

DefaultCacheServer is a simple command line facility and convenience API that starts all services that are declared as requiring an "autostart" in the configurable factory XML descriptor.

DefaultCacheServer can also monitor services it started to ensure they exist. Monitoring services is enabled by default.

Since:
Coherence 2.2
Author:
gg/yc/hr

Nested Class Summary
static class DefaultCacheServer.GarServer
          GarServer provides the functionality of DefaultCacheServer under the context of a GAR file.
protected  class DefaultCacheServer.ShutdownProcess
          ShutdownHook implementation.

 

Field Summary
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  java.lang.Thread m_threadShutdown
          Shutdown hook thread.

 

Constructor Summary
DefaultCacheServer(ConfigurableCacheFactory factory)
          Construct a DefaultCacheServer using the provided factory.

 

Method Summary
protected static DefaultCacheServer ensureInstance(ConfigurableCacheFactory factory)
          Returns the DefaultCacheServer singleton, creating it if necessary.
protected static DefaultCacheServer.GarServer ensureInstance(java.io.File fileGar, java.lang.String sAppName)
          Returns the DefaultCacheServer singleton, creating it if necessary.
protected static ConfigurableCacheFactory getConfigurableCacheFactory()
          Gets a ConfigurableCacheFactory based on the default configuration.
protected static DefaultCacheServer getInstance()
          Returns the DefaultCacheServer created by a previous invocation of ensureInstance(ConfigurableCacheFactory).
protected  java.lang.String getServiceBanner(Cluster cluster)
          Create a list of running services in the given Cluster.
protected  java.lang.String getServiceName(XmlElement xmlScheme)
          Based on the provided XmlElement, which represents the caching scheme, determine the service name that will be used for the service.
protected  void handleEnsureServiceException(java.lang.RuntimeException e)
          Invoked if starting a service raises an exception.
protected  void initialStartServices(boolean fMonitor)
          Start the services.
static void main(java.lang.String[] asArg)
          Entry point: start the cache server under two possible contexts: With a "coherence-cache-config.xsd" compliant configuration file.
protected  void monitorServices(long cWaitMillis)
          Check the ServiceMonitor status ensuring it is monitoring services and DefaultCacheServer has not been shutdown.
protected  void setUp(long cWaitMillis)
          Setup any necessary resources.
static void shutdown()
          Shutdown the cache server.
 void shutdownServer()
          Shutdown the DefaultCacheServer.
static java.util.List start()
          Start all services that are declared as requiring an "autostart" in the default configurable factory XML descriptor.
static java.util.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.
static void startDaemon(java.io.File fileGar)
          Deprecated. use startServerDaemon(File) instead
static void startDaemon(java.io.File fileGar, java.lang.String sAppName)
          Deprecated. use startServerDaemon(File, String) instead
 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.
static DefaultCacheServer.GarServer startServerDaemon(java.io.File fileGar)
          Start the cache server on a dedicated daemon thread using the given File reference to a GAR.
static DefaultCacheServer.GarServer startServerDaemon(java.io.File fileGar, java.lang.String sAppName)
          Start the cache server on a dedicated daemon thread using the given File reference to a GAR.
 java.util.List startServices()
          Start all services that are declared as requiring an "autostart" in the configurable factory XML descriptor.
protected  java.util.Map startServicesInternal()
          Starts the services marked with autostart returning a map of service name to the created service.
protected  java.util.Map startServicesInternal(boolean fMonitor)
          Starts the services marked with autostart returning a map of service name to the created service.
protected  void stopMonitoring()
          Ensures the DCS instance has shutdown and the associated ServiceMonitor is no longer monitoring services.
 void waitForServiceStart()
          Block the calling thread until DefaultCacheServer has called start on all associated services.

 

Field Detail

DEFAULT_WAIT_MILLIS

public static final long DEFAULT_WAIT_MILLIS
The default number of milliseconds between checks for service restart.
See Also:
Constant Field Values

m_serviceMon

protected volatile ServiceMonitor m_serviceMon
The ServiceMonitor used to monitor services.

m_fShutdown

protected volatile boolean m_fShutdown
Flag that indicates whether of not the shutdown was initiated.

m_fServicesStarted

protected boolean m_fServicesStarted
Flag that indicates whether this instance of DefaultCacheServer has called start on the associated services.
See Also:
initialStartServices(boolean)

m_threadShutdown

protected java.lang.Thread m_threadShutdown
Shutdown hook thread.

Constructor Detail

DefaultCacheServer

public DefaultCacheServer(ConfigurableCacheFactory factory)
Construct a DefaultCacheServer using the provided factory.
Parameters:
factory - the ConfigurableCacheFactory

Method Detail

startAndMonitor

public void startAndMonitor(long cWaitMillis)
Start the cache server and check the service status periodically, restarting any stopped services.

This method will block the calling thread.

Parameters:
cWaitMillis - the number of milliseconds between checks

startDaemon

public void startDaemon(long cWaitMillis)
Start the cache server and asynchronously check the service status periodically, restarting any services that have stopped.
Parameters:
cWaitMillis - the number of milliseconds between checks
Since:
Coherence 12.1.2

startServices

public java.util.List startServices()
Start all services that are declared as requiring an "autostart" in the configurable factory XML descriptor.
Returns:
list of services that have been successfully started

shutdownServer

public void shutdownServer()
Shutdown the DefaultCacheServer.

waitForServiceStart

public void waitForServiceStart()
Block the calling thread until DefaultCacheServer has called start on all associated services. Upon control being returned services may not be running due to possible error on start or concurrent shutdown.
Throws:
java.lang.IllegalStateException - iff the services were not attempted to be started, which could be due to concurrent shutdown

shutdown

public static void shutdown()
Shutdown the cache server.
Since:
Coherence 3.2

startDaemon

public static void startDaemon()
Deprecated. use startServerDaemon() instead
Start the cache server on a dedicated daemon thread. This method is intended to be used within managed containers.
Since:
Coherence 3.2

startDaemon

public static void startDaemon(java.io.File fileGar)
Deprecated. use startServerDaemon(File) instead
Start the cache server on a dedicated daemon thread using the given File reference to a GAR. The file reference may be to a GAR file complying to the GAR file structure or a directory containing contents complying to the same structure. This method is intended to be used within managed containers.
Parameters:
fileGar - file reference to either a GAR file or a directory containing the contents of the GAR
Since:
Coherence 12.1.2

startDaemon

public static void startDaemon(java.io.File fileGar,
                               java.lang.String sAppName)
Deprecated. use startServerDaemon(File, String) instead
Start the cache server on a dedicated daemon thread using the given File reference to a GAR. The file reference may be to a GAR file complying to the GAR file structure or a directory containing contents complying to the same structure. This method is intended to be used within managed containers.
Parameters:
fileGar - file reference to either a GAR file or a directory containing the contents of the GAR
sAppName - name to be used for the application
Since:
Coherence 12.1.2

startServerDaemon

public static DefaultCacheServer startServerDaemon()
Start the cache server on a dedicated daemon thread. This method is intended to be used within managed containers.
Returns:
the instance of the DefaultCacheServer started
Since:
Coherence 12.1.2

startServerDaemon

public static DefaultCacheServer.GarServer startServerDaemon(java.io.File fileGar)
Start the cache server on a dedicated daemon thread using the given File reference to a GAR. The file reference may be to a GAR file complying to the GAR file structure or a directory containing contents complying to the same structure. This method is intended to be used within managed containers.
Parameters:
fileGar - file reference to either a GAR file or a directory containing the contents of the GAR
Returns:
an instance of the DefaultCacheServer.GarServer started
Since:
Coherence 12.1.2

startServerDaemon

public static DefaultCacheServer.GarServer startServerDaemon(java.io.File fileGar,
                                                             java.lang.String sAppName)
Start the cache server on a dedicated daemon thread using the given File reference to a GAR. The file reference may be to a GAR file complying to the GAR file structure or a directory containing contents complying to the same structure. This method is intended to be used within managed containers.
Parameters:
fileGar - file reference to either a GAR file or a directory containing the contents of the GAR
sAppName - name to be used for the application
Returns:
an instance of the DefaultCacheServer.GarServer started
Since:
Coherence 12.1.2

main

public static void main(java.lang.String[] asArg)
Entry point: start the cache server under two possible contexts:
  1. With a "coherence-cache-config.xsd" compliant configuration file.
  2. With a GAR file or a directory containing the contents of a GAR file and optionally an application name.
If both are provided the latter takes precedence. Additionally DefaultCacheServer accepts a numeric value to monitor the service status (keep alive interval).

Default configuration file is "coherence-cache-config.xml"; default keep alive interval is 5 sec.

 Example:
   java -server -Xms512m -Xmx512m com.tangosol.net.DefaultCacheServer coherence-cache-config.xml 5
 GAR Example:
   java -server -Xms512m -Xmx512m com.tangosol.net.DefaupltCacheServer my-application.gar MyGarApp 5
 
Parameters:
asArg - the command line arguments

start

public static java.util.List start()
Start all services that are declared as requiring an "autostart" in the default configurable factory XML descriptor.
Returns:
list of services that have been successfully started

start

public static java.util.List start(ConfigurableCacheFactory factory)
Start all services that are declared as requiring an "autostart" in the configurable factory XML descriptor.
Parameters:
factory - ConfigurableCacheFactory to use
Returns:
list of services that have been successfully started

stopMonitoring

protected void stopMonitoring()
Ensures the DCS instance has shutdown and the associated ServiceMonitor is no longer monitoring services.

startServicesInternal

protected java.util.Map startServicesInternal()
Starts the services marked with autostart returning a map of service name to the created service.
Returns:
a map of service name to the created service for all started services

startServicesInternal

protected java.util.Map startServicesInternal(boolean fMonitor)
Starts the services marked with autostart returning a map of service name to the created service.
Parameters:
fMonitor - whether to monitor the started services to ensure their existence
Returns:
a map of service name to the created service for all started services

getServiceName

protected java.lang.String getServiceName(XmlElement xmlScheme)
Based on the provided XmlElement, which represents the caching scheme, determine the service name that will be used for the service.
Parameters:
xmlScheme - the caching scheme to derive a service name from
Returns:
the service name that will be used based on the provided scheme

setUp

protected void setUp(long cWaitMillis)
Setup any necessary resources.
Parameters:
cWaitMillis - the interval, in milliseconds, to monitor services

initialStartServices

protected void initialStartServices(boolean fMonitor)
Start the services. This will be done exactly once during startAndMonitor.
Parameters:
fMonitor - whether the started services should be monitored

monitorServices

protected void monitorServices(long cWaitMillis)
Check the ServiceMonitor status ensuring it is monitoring services and DefaultCacheServer has not been shutdown. Iff either proposition is true return to the caller.
Parameters:
cWaitMillis - the number of milliseconds between checks

handleEnsureServiceException

protected void handleEnsureServiceException(java.lang.RuntimeException e)
Invoked if starting a service raises an exception. Re-throws the exception. Override, for example, to log the exception and continue starting services.
Parameters:
e - the RuntimeException
See Also:
startServices()

getServiceBanner

protected java.lang.String getServiceBanner(Cluster cluster)
Create a list of running services in the given Cluster.
Parameters:
cluster - Cluster for which to create a list of running services
Returns:
string containing listing of running services

startDaemon

protected static void startDaemon(DefaultCacheServer dcs)
Start the provided cache server on a dedicated daemon thread. This method is intended to be used within managed containers.
Parameters:
dcs - the cache server to start

getConfigurableCacheFactory

protected static ConfigurableCacheFactory getConfigurableCacheFactory()
Gets a ConfigurableCacheFactory based on the default configuration.
Returns:
a ConfigurableCacheFactory

ensureInstance

protected static DefaultCacheServer ensureInstance(ConfigurableCacheFactory factory)
Returns the DefaultCacheServer singleton, creating it if necessary.
Parameters:
factory - the CacheFactory to use
Returns:
the DefaultCacheServer singleton

ensureInstance

protected static DefaultCacheServer.GarServer ensureInstance(java.io.File fileGar,
                                                             java.lang.String sAppName)
Returns the DefaultCacheServer singleton, creating it if necessary.
Parameters:
fileGar - file reference to either a GAR file or a directory containing the contents of the GAR
sAppName - application name
Returns:
the DefaultCacheServer singleton

getInstance

protected static DefaultCacheServer getInstance()
Returns the DefaultCacheServer created by a previous invocation of ensureInstance(ConfigurableCacheFactory). Will throw an IllegalStateException if there is no instance. This is intended for use only by the static methods;
Returns:
the DefaultCacheServer

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.