jgroup.relacs.config
Class AppConfig

java.lang.Object
  extended by jgroup.relacs.config.AppConfig
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, ConfigurationObject

public class AppConfig
extends java.lang.Object
implements java.io.Externalizable, ConfigurationObject

Class for holding application information, including replication style and recovery strategy for the dependable applications.

Since:
Jgroup 1.2
Author:
Hein Meling
See Also:
Serialized Form

Constructor Summary
AppConfig()
          Default constructor for externalization and configuration parser construction.
AppConfig(java.lang.String regName, java.lang.String className, java.lang.String args, int groupId, boolean inExecJVM)
          Creates a new AppConfig instance, from the given class name, arguments and group identifier.
 
Method Summary
static AppConfig addApplication(java.lang.String regname, java.lang.String classname, java.lang.String args, int group, boolean inExecJVM)
          Augment the system with an additional application.
static void addApplications(AppConfig[] apps)
          Add the given set of applications to the static maps.
 void addParam(java.lang.String name, java.lang.String value)
          Add the given name-value pair to the internal parameter map.
 void addService(java.lang.String serviceName)
          Add the given service to the protocol stack for this application.
 boolean equals(java.lang.Object obj)
          Returns true if the provided object is equal to this object.
static AppConfig getApplication(java.lang.Class cl)
          Returns an AppConfig object associated with the specified class.
static AppConfig getApplication(int gid)
          Returns an AppConfig object associated with the specified group identifier.
static AppConfig getApplication(java.lang.Object appObj)
          Returns an AppConfig object associated with the specified object instance.
static AppConfig getApplication(java.lang.String name)
          Returns an AppConfig object associated with the specified name.
static AppConfig[] getApplications()
          Returns an array of all applications registered.
 boolean getBooleanParam(java.lang.String name)
          Returns the boolean value associated with the parameter name provided to this method.
 java.lang.String[] getClassArgs()
          Returns the class arguments as a string array.
 ClassData getClassData()
          Returns a class data object for the application.
 java.lang.String getClassName()
          Returns the class name as a string.
 int getCurrentGroupSize()
           
 int getGroupId()
           
 int getInitialRedundancy()
           
 int getIntParam(java.lang.String name)
          Returns the integer value associated with the parameter name provided to this method.
 int getIntParam(java.lang.String name, int defaultValue)
          Returns the integer value associated with the parameter name provided to this method.
 int getMinimalRedundancy()
           
 java.lang.String getParam(java.lang.String name)
          Returns the value associated with the parameter name provided to this method.
 java.lang.String getParam(java.lang.String name, java.lang.String defaultVal)
          Returns the value associated with the parameter name provided to this method; if this application has no such parameter defined the provided default value will be returned.
 RecoveryStrategy getRecoveryStrategy()
           
 java.lang.String getRegistryName()
          Returns the name associated with this application in the (dependable) registry.
 java.lang.String[] getServiceSet()
          Retrieve the set of services used by this application.
 View getView()
          Returns the current view of this application, which may be an empty view in case the application has not installed any views yet.
 HostSet getViewHosts()
          Returns the set of hosts on which replicas of this application is known to be located.
 int hashCode()
          Returns a hash code value for this application info object.
 boolean hasService(java.lang.String service)
          Returns true if this application contains the specified service, otherwise false is returned.
 boolean needsRecovery()
          Returns true if this application needs recovery, otherwise false is returned.
 void parse(org.w3c.dom.Element elm)
          Parses the specified element.
 void readExternal(java.io.ObjectInput in)
           
static void setDistributionScheme(DistributionScheme distScheme)
          Method to store the distribution scheme of the local replication manager.
 void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
          Set the properties that should apply for this application.
 void setRecoveryStrategy(java.lang.String strategy)
          Sets the recovery strategy for this application.
 void setRedundancy(int minimal, int initial)
          Set the minimal and initial redundancy for this application.
 void setServiceSet(java.lang.String stackOrder)
          Set the service set or stack order for this application.
 boolean startInExecJVM()
          Returns true if this application should be started within the same JVM as the execution daemon.
 java.lang.String toString()
          Returns a string representation of this object
 java.lang.String toString(boolean full)
          Returns a string representation of this object.
 void viewChange(View view)
          Update this application group's view and set of view hosts.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AppConfig

public AppConfig(java.lang.String regName,
                 java.lang.String className,
                 java.lang.String args,
                 int groupId,
                 boolean inExecJVM)
Creates a new AppConfig instance, from the given class name, arguments and group identifier. The AppConfig object must also be initialized with the required redundancy and replication style parameters through the corresponding set methods; otherwise an IllegalStateException will be thrown upon using the AppConfig object.

Parameters:
className - The classname for this application object.
args - The arguments for the application object.
groupId - The group identifier for this application object.
Throws:
java.lang.ClassNotFoundException - Raised if the given class could not be found.

AppConfig

public AppConfig()
Default constructor for externalization and configuration parser construction.

Method Detail

addApplication

public static AppConfig addApplication(java.lang.String regname,
                                       java.lang.String classname,
                                       java.lang.String args,
                                       int group,
                                       boolean inExecJVM)
                                throws ConfigurationException
Augment the system with an additional application.

Parameters:
regname - the registry name for this application
classname - the class name
args - argument string
group - the group identifier for the application
inExecJVM - must be true if the application should be started in the execution daemon JVM. if set to false, the application will be started in a separate process.
Returns:
application info object associated with the pair
Throws:
ConfigurationException - if the specified class name is already registered

addApplications

public static void addApplications(AppConfig[] apps)
                            throws ConfigurationException
Add the given set of applications to the static maps.

Parameters:
apps -
Throws:
ConfigurationException

getApplications

public static AppConfig[] getApplications()
Returns an array of all applications registered.


getApplication

public static AppConfig getApplication(java.lang.String name)
Returns an AppConfig object associated with the specified name. The name may be either the registry name or the class name of the application.

Throws:
java.lang.NullPointerException - Raised if the specified name has no corresponding class in the applications configuration.

getApplication

public static AppConfig getApplication(java.lang.Object appObj)
Returns an AppConfig object associated with the specified object instance.

Throws:
java.lang.NullPointerException - Raised if the specified object instance name has no corresponding class in the applications configuration.

getApplication

public static AppConfig getApplication(java.lang.Class cl)
Returns an AppConfig object associated with the specified class.

Throws:
java.lang.NullPointerException - Raised if the specified class has no corresponding class in the applications configuration.

getApplication

public static AppConfig getApplication(int gid)
Returns an AppConfig object associated with the specified group identifier.

Throws:
java.lang.NullPointerException - Raised if the specified group identifier has no corresponding application in the applications configuration.

setDistributionScheme

public static void setDistributionScheme(DistributionScheme distScheme)
Method to store the distribution scheme of the local replication manager. This is required for recovery strategy construction and initialization.


parse

public void parse(org.w3c.dom.Element elm)
           throws ConfigurationException
Parses the specified element.

Specified by:
parse in interface ConfigurationObject
Throws:
ConfigurationException

getRegistryName

public java.lang.String getRegistryName()
Returns the name associated with this application in the (dependable) registry.


getClassData

public ClassData getClassData()
Returns a class data object for the application.

Returns:
the class data object for the application.

setProperties

public void setProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Set the properties that should apply for this application. If no properties map is provided, the properties is initialized according to this applications properties.


getGroupId

public int getGroupId()

getClassName

public java.lang.String getClassName()
Returns the class name as a string.

Returns:
Returns the class name as a string.

getClassArgs

public java.lang.String[] getClassArgs()
Returns the class arguments as a string array.

Returns:
Returns the class arguments as a string array.

startInExecJVM

public boolean startInExecJVM()
Returns true if this application should be started within the same JVM as the execution daemon. False indicates that the application should be started external the the execution daemon, that is in a separate JVM.


getParam

public java.lang.String getParam(java.lang.String name)
                          throws java.util.NoSuchElementException
Returns the value associated with the parameter name provided to this method.

Parameters:
name - The name of the parameter to retreive from the parameter map.
Returns:
The parameter value associated with the given parameter name.
Throws:
java.util.NoSuchElementException - Raised if the given parameter name was not found in the internal parameter map, or if there is no parameters associated with this application.

getParam

public java.lang.String getParam(java.lang.String name,
                                 java.lang.String defaultVal)
Returns the value associated with the parameter name provided to this method; if this application has no such parameter defined the provided default value will be returned.

Parameters:
name - The name of the parameter to retreive from the parameter map.
defaultVal - The default value to return if the given parameter is not defined in the parameter map.
Returns:
The parameter value associated with the given parameter name.

getIntParam

public int getIntParam(java.lang.String name)
                throws java.util.NoSuchElementException
Returns the integer value associated with the parameter name provided to this method.

Parameters:
name - The name of the parameter to retreive from the parameter map.
Returns:
The int parameter value associated with the given parameter name.
Throws:
java.util.NoSuchElementException - Raised if the given parameter name was not found in the internal parameter map.

getIntParam

public int getIntParam(java.lang.String name,
                       int defaultValue)
Returns the integer value associated with the parameter name provided to this method. If this application has no associated value for this parameter, the provided default value is returned.

Parameters:
name - The name of the parameter to retreive from the parameter map.
defaultValue - The default value of the parameter to be return if no value is available in the parameter map.
Returns:
The int parameter value associated with the given parameter name. If the parameter have no specified value for the associated application, we return the provided default value.

getBooleanParam

public boolean getBooleanParam(java.lang.String name)
Returns the boolean value associated with the parameter name provided to this method. If this application has no associated value for this parameter, false is returned.

Parameters:
name - The name of the parameter to retreive from the parameter map.
Returns:
The boolean parameter value associated with the given parameter name. If the parameter have no specified value for the associated application, false is returned.

getServiceSet

public java.lang.String[] getServiceSet()
Retrieve the set of services used by this application.

Returns:
A String[] of services used by this application, ordered from the lowest layer at index position zero.
Throws:
java.lang.IllegalStateException - Raised if the service set has not yet been initialized.

hasService

public boolean hasService(java.lang.String service)
Returns true if this application contains the specified service, otherwise false is returned.

Returns:
True if this application contains the specified service.
Throws:
java.lang.IllegalStateException - Raised if the service set has not yet been initialized.

getRecoveryStrategy

public RecoveryStrategy getRecoveryStrategy()

setRedundancy

public void setRedundancy(int minimal,
                          int initial)
                   throws ConfigurationException
Set the minimal and initial redundancy for this application.

Parameters:
initial - initial redundancy for this application
minimal - minimal redundancy for this application
Throws:
ConfigurationException - if the redundancy specifications are out of bound.

getInitialRedundancy

public int getInitialRedundancy()

getMinimalRedundancy

public int getMinimalRedundancy()

getCurrentGroupSize

public int getCurrentGroupSize()

needsRecovery

public boolean needsRecovery()
Returns true if this application needs recovery, otherwise false is returned.


viewChange

public void viewChange(View view)
Update this application group's view and set of view hosts.


getView

public View getView()
Returns the current view of this application, which may be an empty view in case the application has not installed any views yet.


getViewHosts

public HostSet getViewHosts()
Returns the set of hosts on which replicas of this application is known to be located.


setRecoveryStrategy

public void setRecoveryStrategy(java.lang.String strategy)
                         throws ConfigurationException
Sets the recovery strategy for this application.

Parameters:
strategy - class name denoting the recovery strategy
Throws:
ConfigurationException - if the recovery strategy is not supported.

setServiceSet

public void setServiceSet(java.lang.String stackOrder)
                   throws ConfigurationException
Set the service set or stack order for this application. The layer stack order defines the layers that the application requires to be used, and the group manager will construct the required set of layers in the given order.

Parameters:
stackOrder - The colon separate string of services that this application requires.
Throws:
ConfigurationException - Thrown if the string contains an unspecified service.

addService

public void addService(java.lang.String serviceName)
                throws ConfigurationException
Add the given service to the protocol stack for this application. This method must be invoked in the order in which the layers should be organized in the stack.

Parameters:
serviceName - The service name to add to the application.
Throws:
ConfigurationException

addParam

public void addParam(java.lang.String name,
                     java.lang.String value)
              throws ConfigurationException
Add the given name-value pair to the internal parameter map.

Parameters:
name - The name of the parameter to add to the map.
value - The value to associate with the parameter.
Throws:
ConfigurationException - Raised if the given parameter name already exists within the internal parameter map.

hashCode

public int hashCode()
Returns a hash code value for this application info object.

Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Returns true if the provided object is equal to this object.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this object

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean full)
Returns a string representation of this object. If the full parameter is false, only a short version is returned, otherwise a full version is returned.


readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
Externalizable.readExternal(ObjectInput)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException
See Also:
Externalizable.writeExternal(ObjectOutput)


Copyright © 1998-2006 The Jgroup/ARM development team. All Rights Reserved.