com.bigdata.jini.start.config
Class ServiceConfiguration

java.lang.Object
  extended by com.bigdata.jini.start.config.ServiceConfiguration
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JavaServiceConfiguration, JiniCoreServicesConfiguration

public abstract class ServiceConfiguration
extends Object
implements Serializable

A service configuration specifies the target #of services for each type of service, its target replication count, command line arguments, parameters used to configure new instances of the service, etc.

Version:
$Id$ FIXME fields should all be mutable to make it easy to update the data for a configuration znode. [add validation check during (de-)serialization and and also in the public ctor. that will let people set the fields to any values, but only valid data can be written into zookeeper]
Author:
Bryan Thompson
See Also:
Serialized Form

Nested Class Summary
 class ServiceConfiguration.AbstractServiceStarter<V extends ProcessHelper>
          A task that will (re-)start an instance of a service described by its ServiceConfiguration.
static interface ServiceConfiguration.Options
          Options understood by ServiceConfiguration.
 
Field Summary
 String[] args
          Command line arguments for the executable (placed immediately after the command to be executed).
 String className
          The name of the server class to be executed (or a token used for servers that are not started directly by invoking a JVM, such as "jini").
 IServiceConstraint[] constraints
          A set of constraints on where the service may be instantiated.
protected static org.apache.log4j.Logger log
           
 String[] options
          Service options (placed at the end of the command line).
 int replicationCount
          The target replication count for each service instance (the #of services having the same state and providing failover support for one another).
 int serviceCount
          The target service instance count.
 File serviceDir
          The base directory for the persistent state service instances.
 long timeout
          The timeout in milliseconds for a service instance to start.
 
Constructor Summary
ServiceConfiguration(String className, net.jini.config.Configuration config)
           
 
Method Summary
 boolean canStartService(JiniFederation fed)
          Verify that we could start this service.
 boolean canStartService(JiniFederation fed, List<IServiceConstraint> violatedConstraints)
          Verify that we could start this service.
static
<T> T[]
concat(T[] a, T[] b)
          Combines the two arrays, appending the contents of the 2nd array to the contents of the first array.
static String[] getArgs(String className, net.jini.config.Configuration config)
           
static String[] getClassPath()
          Splits the CLASSPATH as reported by System.getProperty(String) into a String[].
protected static IServiceConstraint[] getConstraints(String className, net.jini.config.Configuration config)
           
protected  long getDefaultTimeout()
          The default used for ServiceConfiguration.Options.TIMEOUT (20000 ms).
static String[] getOptions(String className, net.jini.config.Configuration config)
           
static int getReplicationCount(String className, net.jini.config.Configuration config)
           
static int getServiceCount(String className, net.jini.config.Configuration config)
           
static File getServiceDir(String className, net.jini.config.Configuration config)
          Return the directory for the persistent state of the service.
protected static String[] getStringArray(String name, String className, net.jini.config.Configuration config, String[] defaultValue)
           
protected static long getTimeout(String className, net.jini.config.Configuration config, long defaultValue)
           
abstract  ServiceConfiguration.AbstractServiceStarter newServiceStarter(IServiceListener listener)
          Factory method returns an object that may be used to start an new instance of the service.
 String toString()
           
protected  void toString(StringBuilder sb)
          May be extended to add more properties to the toString() representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

className

public final String className
The name of the server class to be executed (or a token used for servers that are not started directly by invoking a JVM, such as "jini").


args

public final String[] args
Command line arguments for the executable (placed immediately after the command to be executed).

See Also:
ServiceConfiguration.Options.ARGS

options

public String[] options
Service options (placed at the end of the command line).

See Also:
ServiceConfiguration.Options.OPTIONS

serviceDir

public final File serviceDir
The base directory for the persistent state service instances. Services are normally started in a subdirectory path reflecting the service type, the logical service instance, and the physical service instance. For example, see ManagedServiceConfiguration.ManagedServiceStarter.getServiceDir().

See Also:
ServiceConfiguration.Options.SERVICE_DIR

serviceCount

public final int serviceCount
The target service instance count.

See Also:
ServiceConfiguration.Options.SERVICE_COUNT

replicationCount

public final int replicationCount
The target replication count for each service instance (the #of services having the same state and providing failover support for one another). This MUST be ONE (1) unless the service implements IReplicatableService. Services such as jini or the ClassServer handle failover either by multiple peers (jini) or by statically replicated state (ClassServer). Their instances are configured directly, with a replication count of ONE (1).

See Also:
ServiceConfiguration.Options.REPLICATION_COUNT

constraints

public final IServiceConstraint[] constraints
A set of constraints on where the service may be instantiated. For example, at most N instances of a service on a host, only on hosts with a given IP address pattern, etc.

See Also:
ServiceConfiguration.Options.CONSTRAINTS

timeout

public final long timeout
The timeout in milliseconds for a service instance to start.

See Also:
ServiceConfiguration.Options.TIMEOUT
Constructor Detail

ServiceConfiguration

public ServiceConfiguration(String className,
                            net.jini.config.Configuration config)
                     throws net.jini.config.ConfigurationException
Parameters:
className - The name of the server class or a token used for servers that are not started by directly invoking a JVM, such as "jini".
config - The Configuration.
Throws:
net.jini.config.ConfigurationException
Method Detail

toString

public String toString()
Overrides:
toString in class Object

toString

protected void toString(StringBuilder sb)
May be extended to add more properties to the toString() representation.

Parameters:
sb -

getDefaultTimeout

protected long getDefaultTimeout()
The default used for ServiceConfiguration.Options.TIMEOUT (20000 ms).

Returns:
The default timeout in milliseconds.

getTimeout

protected static long getTimeout(String className,
                                 net.jini.config.Configuration config,
                                 long defaultValue)
                          throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

canStartService

public boolean canStartService(JiniFederation fed)
Verify that we could start this service. All constraints that would be violated are logged @ INFO.

Note: Constraints which can be evaluated without the federation reference MUST NOT throw an exception if that reference is null. This allows us to evaluate constraints for boostrap services as well as for ManagedServiceConfigurations

Parameters:
fed - The federation.
Returns:
true if all constraints are satisified.

canStartService

public boolean canStartService(JiniFederation fed,
                               List<IServiceConstraint> violatedConstraints)
Verify that we could start this service. All constraints that would be violated are logged @ INFO.

Note: Constraints which can be evaluated without the federation reference MUST NOT throw an exception if that reference is null. This allows us to evaluate constraints for boostrap services as well as for ManagedServiceConfigurations

Parameters:
fed - The federation.
violatedConstraints - When non-null, any constraints which would be violated are added to this list.
Returns:
true if all constraints are satisified.

newServiceStarter

public abstract ServiceConfiguration.AbstractServiceStarter newServiceStarter(IServiceListener listener)
                                                                       throws Exception
Factory method returns an object that may be used to start an new instance of the service.

Parameters:
listener -
Throws:
Exception - if there is a problem creating the service starter.

getServiceDir

public static File getServiceDir(String className,
                                 net.jini.config.Configuration config)
                          throws net.jini.config.ConfigurationException
Return the directory for the persistent state of the service. This is where it will store its configuration, its serviceUUID (for jini services, once assigned by jini), and any persistent state maintained by the service.

Throws:
net.jini.config.ConfigurationException
See Also:
ServiceConfiguration.Options.SERVICE_DIR

getServiceCount

public static int getServiceCount(String className,
                                  net.jini.config.Configuration config)
                           throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

getReplicationCount

public static int getReplicationCount(String className,
                                      net.jini.config.Configuration config)
                               throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

getArgs

public static String[] getArgs(String className,
                               net.jini.config.Configuration config)
                        throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

getOptions

public static String[] getOptions(String className,
                                  net.jini.config.Configuration config)
                           throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

getConstraints

protected static IServiceConstraint[] getConstraints(String className,
                                                     net.jini.config.Configuration config)
                                              throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

getStringArray

protected static String[] getStringArray(String name,
                                         String className,
                                         net.jini.config.Configuration config,
                                         String[] defaultValue)
                                  throws net.jini.config.ConfigurationException
Throws:
net.jini.config.ConfigurationException

concat

public static <T> T[] concat(T[] a,
                             T[] b)
Combines the two arrays, appending the contents of the 2nd array to the contents of the first array.

Parameters:
a -
b -
Returns:

getClassPath

public static String[] getClassPath()
Splits the CLASSPATH as reported by System.getProperty(String) into a String[].



Copyright © 2006-2012 SYSTAP, LLC. All Rights Reserved.