SMILA (incubation) API documentation

org.eclipse.smila.clusterconfig.simple
Class SimpleClusterConfigService

java.lang.Object
  extended by org.eclipse.smila.clusterconfig.simple.SimpleClusterConfigService
All Implemented Interfaces:
ClusterConfigService

public class SimpleClusterConfigService
extends java.lang.Object
implements ClusterConfigService

Simple Cluster Configuration Service implementation.

See Also:
ClusterConfigService

Field Summary
static java.lang.String BUNDLE_ID
          bundle id.
static long DEFAULT_FAILSAFETY_LEVEL
          default number of nodes that may fail until zookeeper stops to work.
static long DEFAULT_MAX_SCALE_UP
          default max scale up is -1 which means: unlimited.
static long DEFAULT_ZK_GC_INTERVAL
          default zookeeper garbage collection interval.
 
Constructor Summary
SimpleClusterConfigService()
          Default Constructor for OSGi DS.
 
Method Summary
protected  void activate(ComponentContext context)
          OSGi Declarative Services service activation method.
protected  void deactivate(ComponentContext context)
          OSGi Declarative Services service deactivation method.
 java.util.List<java.lang.String> getClusterNodes()
          
 long getFailSafetyLevel()
          
 int getHttpPort(java.lang.String serviceName)
          Returns a configured http port for a specified service.
 java.lang.String getLocalHost()
          
protected  long getLongPropertyOrSetDefault(AnyMap properties, java.lang.String key, long defaultValueToSet)
          Looks up the long value with the given key in the givent properties map, if this value is not set, the given defaultvalue will be set.
protected  long getLongPropertyOrSetDefault(java.lang.String key, long defaultValueToSet)
          Looks up the long value with the given key, if this value is not set, the given defaultvalue will be set.
 long getMaxScaleUp()
          
 long getWorkerScaleUp(java.lang.String worker)
          
 java.util.Collection<java.lang.String> getWorkersWithScaleUp()
          
 long getZkGcInterval()
          
 boolean isConfigured()
          
protected  void readConfiguration()
          Read the configuration from the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_ID

public static final java.lang.String BUNDLE_ID
bundle id.

See Also:
Constant Field Values

DEFAULT_ZK_GC_INTERVAL

public static final long DEFAULT_ZK_GC_INTERVAL
default zookeeper garbage collection interval.

See Also:
Constant Field Values

DEFAULT_FAILSAFETY_LEVEL

public static final long DEFAULT_FAILSAFETY_LEVEL
default number of nodes that may fail until zookeeper stops to work.

See Also:
Constant Field Values

DEFAULT_MAX_SCALE_UP

public static final long DEFAULT_MAX_SCALE_UP
default max scale up is -1 which means: unlimited.

See Also:
Constant Field Values
Constructor Detail

SimpleClusterConfigService

public SimpleClusterConfigService()
Default Constructor for OSGi DS.

Method Detail

activate

protected void activate(ComponentContext context)
OSGi Declarative Services service activation method.

Parameters:
context - OSGi service component context.

deactivate

protected void deactivate(ComponentContext context)
OSGi Declarative Services service deactivation method.

Parameters:
context - OSGi service component context.

getClusterNodes

public java.util.List<java.lang.String> getClusterNodes()

If no cluster nodes are specified, the returned cluster consists of the local host only (as returned by getLocalHost().

Specified by:
getClusterNodes in interface ClusterConfigService
Returns:
names of all nodes in cluster

getLocalHost

public java.lang.String getLocalHost()

If no name is specified in the configuration, the host name determined by the local InetAddress is returned.

Specified by:
getLocalHost in interface ClusterConfigService
Returns:
the name of the local host

getZkGcInterval

public long getZkGcInterval()

If no value is specified, the default value of 60 is returned.

Specified by:
getZkGcInterval in interface ClusterConfigService
Returns:
interval for zookeeper clean up of data/log directories.

getFailSafetyLevel

public long getFailSafetyLevel()

Specified by:
getFailSafetyLevel in interface ClusterConfigService
Returns:
number of nodes that may fail without ZooKeeper service stopping to work. '0' if no ClusterConfigService is reachable.

isConfigured

public boolean isConfigured()

Specified by:
isConfigured in interface ClusterConfigService
Returns:
true, if we are running in a configured cluster, false otherwise.

getMaxScaleUp

public long getMaxScaleUp()

If no limit is configured, -1 is returned.

Specified by:
getMaxScaleUp in interface ClusterConfigService
Returns:
total max scale up for all workers of one node (checked by taskmanager).

getWorkerScaleUp

public long getWorkerScaleUp(java.lang.String worker)

Specified by:
getWorkerScaleUp in interface ClusterConfigService
Returns:
scale up limit for given worker, -1 if no scale up limit is set for worker.

getWorkersWithScaleUp

public java.util.Collection<java.lang.String> getWorkersWithScaleUp()

Specified by:
getWorkersWithScaleUp in interface ClusterConfigService
Returns:
all workers that have set a scale up limit.

getHttpPort

public int getHttpPort(java.lang.String serviceName)
Returns a configured http port for a specified service. Returns -1 if no port is configured or the service unknown.

Specified by:
getHttpPort in interface ClusterConfigService

getLongPropertyOrSetDefault

protected long getLongPropertyOrSetDefault(java.lang.String key,
                                           long defaultValueToSet)
Looks up the long value with the given key, if this value is not set, the given defaultvalue will be set.

Parameters:
key - the key of the property
defaultValueToSet - the default value
Returns:
the value from the properties or the default value if not set.

getLongPropertyOrSetDefault

protected long getLongPropertyOrSetDefault(AnyMap properties,
                                           java.lang.String key,
                                           long defaultValueToSet)
Looks up the long value with the given key in the givent properties map, if this value is not set, the given defaultvalue will be set.

Parameters:
key - the key of the property
defaultValueToSet - the default value
Returns:
the value from the properties or the default value if not set.

readConfiguration

protected void readConfiguration()
                          throws java.io.IOException
Read the configuration from the configuration file.

Throws:
java.io.IOException - error during loading of configuration file.

SMILA (incubation) API documentation