org.pentaho.di.cluster
Class ClusterSchema

java.lang.Object
  extended by org.pentaho.di.core.changed.ChangedFlag
      extended by org.pentaho.di.cluster.ClusterSchema
All Implemented Interfaces:
Cloneable, ChangedFlagInterface, VariableSpace, XMLInterface, RepositoryElementInterface, RepositoryObjectInterface, SharedObjectInterface

public class ClusterSchema
extends ChangedFlag
implements Cloneable, SharedObjectInterface, VariableSpace, RepositoryElementInterface, XMLInterface

A cluster schema combines a list of slave servers so that they can be set altogether. It (can) also contain a number of performance tuning options regarding this cluster. For example options regarding communications with the master node of the nodes themselves come to mind.

Since:
17-nov-2006
Author:
Matt

Field Summary
static RepositoryObjectType REPOSITORY_ELEMENT_TYPE
           
static String XML_TAG
           
 
Constructor Summary
ClusterSchema()
           
ClusterSchema(Node clusterSchemaNode, List<SlaveServer> referenceSlaveServers)
           
ClusterSchema(String name, List<SlaveServer> slaveServers)
           
 
Method Summary
 ClusterSchema clone()
           
 void copyVariablesFrom(VariableSpace space)
          Copy the variables from another space, without initializing with the defaults.
 String environmentSubstitute(String aString)
          Substitute the string using the current variable space.
 String[] environmentSubstitute(String[] aString)
          Replaces environment variables in an array of strings.
 boolean equals(Object obj)
           
 SlaveServer findMaster()
           
 int findNrSlaves()
           
 SlaveServer findSlaveServer(String slaveServerName)
           
 String getBasePort()
           
 boolean getBooleanValueOfVariable(String variableName, boolean defaultValue)
          This method returns a boolean for the new variable check boxes.
 Date getChangedDate()
           
 String getDescription()
          Gets the description of the repository object.
 String getName()
          Gets the name of the repository object.
 ObjectId getObjectId()
          Get the database ID in the repository for this object.
 ObjectRevision getObjectRevision()
          Gets the object revision.
 VariableSpace getParentVariableSpace()
          Get the parent of the variable space.
 RepositoryDirectoryInterface getRepositoryDirectory()
          Not supported for Partition schema, return the root.
 RepositoryObjectType getRepositoryElementType()
          Gets the repository element type.
 List<SlaveServer> getSlaveServers()
           
 List<SlaveServer> getSlaveServersFromMasterOrLocal()
           
 String[] getSlaveServerStrings()
           
 String getSocketsBufferSize()
           
 String getSocketsFlushInterval()
           
 String getVariable(String variableName)
          Get the value of a variable.
 String getVariable(String variableName, String defaultValue)
          Get the value of a variable with a default in case the variable is not found.
 String getXML()
          Describes the Object implementing this interface as XML
 int hashCode()
           
 void initializeVariablesFrom(VariableSpace parent)
          Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()).
 void injectVariables(Map<String,String> prop)
          Inject variables.
 boolean isDynamic()
           
 boolean isShared()
           
 boolean isSocketsCompressed()
           
 String[] listVariables()
          List the variables (not the values) that are currently in the variable space.
 void replaceMeta(ClusterSchema clusterSchema)
           
 void setBasePort(String basePort)
           
 void setChangedDate(Date changedDate)
           
 void setDescription(String description)
          Sets the description of the repository object.
 void setDynamic(boolean dynamic)
           
 void setName(String name)
          Sets the name of the repository object.
 void setObjectId(ObjectId id)
          Set the database ID for this object in the repository.
 void setObjectRevision(ObjectRevision objectRevision)
          Sets the object revision.
 void setParentVariableSpace(VariableSpace parent)
          Set the parent variable space
 void setRepositoryDirectory(RepositoryDirectoryInterface repositoryDirectory)
           
 void setShared(boolean shared)
           
 void setSlaveServers(List<SlaveServer> slaveServers)
           
 void setSocketsBufferSize(String socketsBufferSize)
           
 void setSocketsCompressed(boolean socketsCompressed)
           
 void setSocketsFlushInterval(String socketFlushInterval)
           
 void setVariable(String variableName, String variableValue)
          Sets a variable in the Kettle Variables list.
 void shareVariablesWith(VariableSpace space)
          Share a variable space from another variable space.
 String toString()
           
 
Methods inherited from class org.pentaho.di.core.changed.ChangedFlag
addObserver, clearChanged, deleteObserver, hasChanged, notifyObservers, setChanged, setChanged
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

XML_TAG

public static final String XML_TAG
See Also:
Constant Field Values

REPOSITORY_ELEMENT_TYPE

public static final RepositoryObjectType REPOSITORY_ELEMENT_TYPE
Constructor Detail

ClusterSchema

public ClusterSchema()

ClusterSchema

public ClusterSchema(String name,
                     List<SlaveServer> slaveServers)
Parameters:
name -
slaveServers -

ClusterSchema

public ClusterSchema(Node clusterSchemaNode,
                     List<SlaveServer> referenceSlaveServers)
Method Detail

clone

public ClusterSchema clone()
Overrides:
clone in class Object

replaceMeta

public void replaceMeta(ClusterSchema clusterSchema)

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getXML

public String getXML()
Description copied from interface: XMLInterface
Describes the Object implementing this interface as XML

Specified by:
getXML in interface XMLInterface
Specified by:
getXML in interface SharedObjectInterface
Returns:
the XML string for this object

getName

public String getName()
Description copied from interface: RepositoryElementInterface
Gets the name of the repository object.

Specified by:
getName in interface RepositoryElementInterface
Specified by:
getName in interface RepositoryObjectInterface
Specified by:
getName in interface SharedObjectInterface
Returns:
the name

setName

public void setName(String name)
Description copied from interface: RepositoryElementInterface
Sets the name of the repository object.

Specified by:
setName in interface RepositoryElementInterface
Parameters:
name - the name to set

getSlaveServers

public List<SlaveServer> getSlaveServers()
Returns:
the internal (static) list of slave servers

setSlaveServers

public void setSlaveServers(List<SlaveServer> slaveServers)
Parameters:
slaveServers - the slaveServers to set

getSlaveServerStrings

public String[] getSlaveServerStrings()
Returns:
The slave server strings from this cluster schema

isShared

public boolean isShared()
Specified by:
isShared in interface SharedObjectInterface
Returns:
the shared

setShared

public void setShared(boolean shared)
Specified by:
setShared in interface SharedObjectInterface
Parameters:
shared - the shared to set

getBasePort

public String getBasePort()
Returns:
the basePort

setBasePort

public void setBasePort(String basePort)
Parameters:
basePort - the basePort to set

findMaster

public SlaveServer findMaster()
                       throws KettleException
Throws:
KettleException

findNrSlaves

public int findNrSlaves()
Returns:
The number of slave servers, excluding the master server

getSocketsFlushInterval

public String getSocketsFlushInterval()
Returns:
the socketFlushInterval

setSocketsFlushInterval

public void setSocketsFlushInterval(String socketFlushInterval)
Parameters:
socketFlushInterval - the socketFlushInterval to set

getSocketsBufferSize

public String getSocketsBufferSize()
Returns:
the socketsBufferSize

setSocketsBufferSize

public void setSocketsBufferSize(String socketsBufferSize)
Parameters:
socketsBufferSize - the socketsBufferSize to set

isSocketsCompressed

public boolean isSocketsCompressed()
Returns:
the socketsCompressed

setSocketsCompressed

public void setSocketsCompressed(boolean socketsCompressed)
Parameters:
socketsCompressed - the socketsCompressed to set

findSlaveServer

public SlaveServer findSlaveServer(String slaveServerName)

getObjectId

public ObjectId getObjectId()
Description copied from interface: RepositoryElementInterface
Get the database ID in the repository for this object.

Specified by:
getObjectId in interface RepositoryElementInterface
Specified by:
getObjectId in interface RepositoryObjectInterface
Returns:
the database ID in the repository for this object

setObjectId

public void setObjectId(ObjectId id)
Description copied from interface: RepositoryElementInterface
Set the database ID for this object in the repository.

Specified by:
setObjectId in interface RepositoryElementInterface
Parameters:
id - the database ID for this object in the repository

copyVariablesFrom

public void copyVariablesFrom(VariableSpace space)
Description copied from interface: VariableSpace
Copy the variables from another space, without initializing with the defaults. This does not affect any parent relationship.

Specified by:
copyVariablesFrom in interface VariableSpace
Parameters:
space - the space to copy the variables from.

environmentSubstitute

public String environmentSubstitute(String aString)
Description copied from interface: VariableSpace
Substitute the string using the current variable space.

Specified by:
environmentSubstitute in interface VariableSpace
Parameters:
aString - The string to substitute.
Returns:
The substituted string.

environmentSubstitute

public String[] environmentSubstitute(String[] aString)
Description copied from interface: VariableSpace
Replaces environment variables in an array of strings. See also: environmentSubstitute(String string)

Specified by:
environmentSubstitute in interface VariableSpace
Parameters:
aString - The array of strings that wants its variables to be replaced.
Returns:
the array with the environment variables replaced.

getParentVariableSpace

public VariableSpace getParentVariableSpace()
Description copied from interface: VariableSpace
Get the parent of the variable space.

Specified by:
getParentVariableSpace in interface VariableSpace
Returns:
the parent.

setParentVariableSpace

public void setParentVariableSpace(VariableSpace parent)
Description copied from interface: VariableSpace
Set the parent variable space

Specified by:
setParentVariableSpace in interface VariableSpace
Parameters:
parent - The parent variable space to set

getVariable

public String getVariable(String variableName,
                          String defaultValue)
Description copied from interface: VariableSpace
Get the value of a variable with a default in case the variable is not found.

Specified by:
getVariable in interface VariableSpace
Parameters:
variableName - The name of the variable
defaultValue - The default value in case the variable could not be found
Returns:
the String value of a variable

getVariable

public String getVariable(String variableName)
Description copied from interface: VariableSpace
Get the value of a variable.

Specified by:
getVariable in interface VariableSpace
Parameters:
variableName - The name of the variable
Returns:
the String value of a variable or null in case the variable could not be found.

getBooleanValueOfVariable

public boolean getBooleanValueOfVariable(String variableName,
                                         boolean defaultValue)
Description copied from interface: VariableSpace
This method returns a boolean for the new variable check boxes. If the variable name is not set or the variable name is not specified, this method simply returns the default value. If not, it convert the variable value to a boolean. "Y", "YES" and "TRUE" all convert to true. (case insensitive)

Specified by:
getBooleanValueOfVariable in interface VariableSpace
Parameters:
variableName - The variable to look up.
defaultValue - The default value to return.
Returns:
See Also:
static method ValueMeta.convertStringToBoolean()

initializeVariablesFrom

public void initializeVariablesFrom(VariableSpace parent)
Description copied from interface: VariableSpace
Initialize variable space using the defaults, copy over the variables from the parent (using copyVariablesFrom()), after this the "injected" variables should be inserted (injectVariables()). The parent is set as parent variable space.

Specified by:
initializeVariablesFrom in interface VariableSpace
Parameters:
parent - the parent to start from, or null if root.

listVariables

public String[] listVariables()
Description copied from interface: VariableSpace
List the variables (not the values) that are currently in the variable space.

Specified by:
listVariables in interface VariableSpace
Returns:
Array of String variable names.

setVariable

public void setVariable(String variableName,
                        String variableValue)
Description copied from interface: VariableSpace
Sets a variable in the Kettle Variables list.

Specified by:
setVariable in interface VariableSpace
Parameters:
variableName - The name of the variable to set
variableValue - The value of the variable to set. If the variableValue is null, the variable is cleared from the list.

shareVariablesWith

public void shareVariablesWith(VariableSpace space)
Description copied from interface: VariableSpace
Share a variable space from another variable space. This means that the object should take over the space used as argument.

Specified by:
shareVariablesWith in interface VariableSpace
Parameters:
space - Variable space to be shared.

injectVariables

public void injectVariables(Map<String,String> prop)
Description copied from interface: VariableSpace
Inject variables. The behaviour should be that the properties object will be stored and at the time the VariableSpace is initialized (or upon calling this method if the space is already initialized). After injecting the link of the properties object should be removed.

Specified by:
injectVariables in interface VariableSpace
Parameters:
prop - Properties object containing key-value pairs.

isDynamic

public boolean isDynamic()
Returns:
the dynamic

setDynamic

public void setDynamic(boolean dynamic)
Parameters:
dynamic - the dynamic to set

getSlaveServersFromMasterOrLocal

public List<SlaveServer> getSlaveServersFromMasterOrLocal()
                                                   throws KettleException
Returns:
A list of dynamic slave servers, retrieved from the first master server that was available.
Throws:
KettleException - when none of the masters can be contacted.

getRepositoryDirectory

public RepositoryDirectoryInterface getRepositoryDirectory()
Not supported for Partition schema, return the root.

Specified by:
getRepositoryDirectory in interface RepositoryElementInterface

setRepositoryDirectory

public void setRepositoryDirectory(RepositoryDirectoryInterface repositoryDirectory)
Specified by:
setRepositoryDirectory in interface RepositoryElementInterface

getRepositoryElementType

public RepositoryObjectType getRepositoryElementType()
Description copied from interface: RepositoryElementInterface
Gets the repository element type.

Specified by:
getRepositoryElementType in interface RepositoryElementInterface
Returns:
the repository element type

getObjectRevision

public ObjectRevision getObjectRevision()
Description copied from interface: RepositoryElementInterface
Gets the object revision.

Specified by:
getObjectRevision in interface RepositoryElementInterface
Returns:
the object revision

setObjectRevision

public void setObjectRevision(ObjectRevision objectRevision)
Description copied from interface: RepositoryElementInterface
Sets the object revision.

Specified by:
setObjectRevision in interface RepositoryElementInterface

getDescription

public String getDescription()
Description copied from interface: RepositoryElementInterface
Gets the description of the repository object.

Specified by:
getDescription in interface RepositoryElementInterface
Returns:

setDescription

public void setDescription(String description)
Description copied from interface: RepositoryElementInterface
Sets the description of the repository object.

Specified by:
setDescription in interface RepositoryElementInterface

getChangedDate

public Date getChangedDate()
Specified by:
getChangedDate in interface SharedObjectInterface
Returns:
the changedDate

setChangedDate

public void setChangedDate(Date changedDate)
Parameters:
changedDate - the changedDate to set