org.pentaho.di.cluster
Class SlaveServer

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

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


Field Summary
static RepositoryObjectType REPOSITORY_ELEMENT_TYPE
           
static String STRING_SLAVESERVER
           
static String XML_TAG
           
 
Constructor Summary
SlaveServer()
           
SlaveServer(Node slaveNode)
           
SlaveServer(String name, String hostname, String port, String username, String password)
           
SlaveServer(String name, String hostname, String port, String username, String password, String proxyHostname, String proxyPort, String nonProxyHosts, boolean master)
           
 
Method Summary
 void addCredentials(org.apache.commons.httpclient.HttpClient client)
           
 void addProxy(org.apache.commons.httpclient.HttpClient client)
           
 int allocateServerSocket(String runId, int portRangeStart, String hostname, String transformationName, String sourceSlaveName, String sourceStepName, String sourceStepCopy, String targetSlaveName, String targetStepName, String targetStepCopy)
           
 WebResult cleanupTransformation(String transName, String carteObjectId)
           
 Object clone()
           
 String constructUrl(String serviceAndArguments)
           
 void copyVariablesFrom(VariableSpace space)
          Copy the variables from another space, without initializing with the defaults.
 WebResult deAllocateServerSockets(String transName, String clusteredRunId)
           
 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)
           
 String execService(String service)
           
static SlaveServer findSlaveServer(List<SlaveServer> slaveServers, ObjectId id)
           
static SlaveServer findSlaveServer(List<SlaveServer> slaveServers, String name)
           
 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 getHostname()
           
 SlaveServerJobStatus getJobStatus(String jobName, String carteObjectId, int startLogLineNr)
           
 LogChannelInterface getLogChannel()
           
 String getName()
          Gets the name of the repository object.
 long getNextSlaveSequenceValue(String slaveSequenceName, long incrementValue)
           
 String getNonProxyHosts()
           
 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.
 String getPassword()
           
 String getPort()
           
 String getPortSpecification()
           
 String getProxyHostname()
           
 String getProxyPort()
           
 RepositoryDirectoryInterface getRepositoryDirectory()
          Not used in this case, simply return root /
 RepositoryObjectType getRepositoryElementType()
          Gets the repository element type.
 org.apache.commons.httpclient.methods.PostMethod getSendByteArrayMethod(byte[] content, String service)
           
 String getServerAndPort()
           
 List<SlaveServerDetection> getSlaveServerDetections()
           
static String[] getSlaveServerNames(List<SlaveServer> slaveServers)
           
 SlaveServerStatus getStatus()
           
 SlaveServerTransStatus getTransStatus(String transName, String carteObjectId, int startLogLineNr)
           
 String getUsername()
           
 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 getWebAppName()
           
 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 isMaster()
           
 boolean isShared()
           
 String[] listVariables()
          List the variables (not the values) that are currently in the variable space.
 WebResult pauseResumeTransformation(String transName, String carteObjectId)
           
 WebResult removeJob(String jobName, String carteObjectId)
           
 WebResult removeTransformation(String transName, String carteObjectId)
           
 void replaceMeta(SlaveServer slaveServer)
           
 String sendExport(String filename, String type, String load)
          Send an exported archive over to this slave server
 String sendXML(String xml, String service)
           
 void setChangedDate(Date changedDate)
           
 void setDescription(String description)
          Sets the description of the repository object.
 void setHostname(String urlString)
           
 void setMaster(boolean master)
           
 void setName(String name)
          Sets the name of the repository object.
 void setNonProxyHosts(String nonProxyHosts)
           
 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 setPassword(String password)
           
 void setPort(String port)
           
 void setProxyHostname(String proxyHostname)
           
 void setProxyPort(String proxyPort)
           
 void setRepositoryDirectory(RepositoryDirectoryInterface repositoryDirectory)
           
 void setShared(boolean shared)
           
 void setUsername(String username)
           
 void setVariable(String variableName, String variableValue)
          Sets a variable in the Kettle Variables list.
 void setWebAppName(String webAppName)
           
 void shareVariablesWith(VariableSpace space)
          Share a variable space from another variable space.
 String sniffStep(String transName, String stepName, String copyNr, int lines, String type)
          Sniff rows on a the slave server, return xml containing the row metadata and data.
 WebResult startJob(String jobName, String carteObjectId)
           
 WebResult startTransformation(String transName, String carteObjectId)
           
 WebResult stopJob(String transName, String carteObjectId)
           
 WebResult stopTransformation(String transName, String carteObjectId)
           
 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

STRING_SLAVESERVER

public static final String STRING_SLAVESERVER
See Also:
Constant Field Values

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

SlaveServer

public SlaveServer()

SlaveServer

public SlaveServer(String name,
                   String hostname,
                   String port,
                   String username,
                   String password)

SlaveServer

public SlaveServer(String name,
                   String hostname,
                   String port,
                   String username,
                   String password,
                   String proxyHostname,
                   String proxyPort,
                   String nonProxyHosts,
                   boolean master)

SlaveServer

public SlaveServer(Node slaveNode)
Method Detail

getLogChannel

public LogChannelInterface getLogChannel()

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

clone

public Object clone()
Overrides:
clone in class Object

replaceMeta

public void replaceMeta(SlaveServer slaveServer)

toString

public String toString()
Overrides:
toString in class Object

getServerAndPort

public String getServerAndPort()

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getHostname

public String getHostname()

setHostname

public void setHostname(String urlString)

getPassword

public String getPassword()
Returns:
the password

setPassword

public void setPassword(String password)
Parameters:
password - the password to set

getUsername

public String getUsername()
Returns:
the username

setUsername

public void setUsername(String username)
Parameters:
username - the username to set

getWebAppName

public String getWebAppName()
Returns:
the username

setWebAppName

public void setWebAppName(String webAppName)
Parameters:
username - the username to set

getNonProxyHosts

public String getNonProxyHosts()
Returns:
the nonProxyHosts

setNonProxyHosts

public void setNonProxyHosts(String nonProxyHosts)
Parameters:
nonProxyHosts - the nonProxyHosts to set

getProxyHostname

public String getProxyHostname()
Returns:
the proxyHostname

setProxyHostname

public void setProxyHostname(String proxyHostname)
Parameters:
proxyHostname - the proxyHostname to set

getProxyPort

public String getProxyPort()
Returns:
the proxyPort

setProxyPort

public void setProxyPort(String proxyPort)
Parameters:
proxyPort - the proxyPort to set

getPortSpecification

public String getPortSpecification()

constructUrl

public String constructUrl(String serviceAndArguments)
                    throws UnsupportedEncodingException
Throws:
UnsupportedEncodingException

getPort

public String getPort()
Returns:
the port

setPort

public void setPort(String port)
Parameters:
port - the port to set

getSendByteArrayMethod

public org.apache.commons.httpclient.methods.PostMethod getSendByteArrayMethod(byte[] content,
                                                                               String service)
                                                                        throws Exception
Throws:
Exception

sendXML

public String sendXML(String xml,
                      String service)
               throws Exception
Throws:
Exception

sendExport

public String sendExport(String filename,
                         String type,
                         String load)
                  throws Exception
Send an exported archive over to this slave server

Parameters:
filename - The archive to send
type - The type of file to add to the slave server (AddExportServlet.TYPE_*)
load - The filename to load in the archive (the .kjb or .ktr)
Returns:
the XML of the web result
Throws:
Exception - in case something goes awry

addProxy

public void addProxy(org.apache.commons.httpclient.HttpClient client)

addCredentials

public void addCredentials(org.apache.commons.httpclient.HttpClient client)

isMaster

public boolean isMaster()
Returns:
the master

setMaster

public void setMaster(boolean master)
Parameters:
master - the master to set

execService

public String execService(String service)
                   throws Exception
Throws:
Exception

getStatus

public SlaveServerStatus getStatus()
                            throws Exception
Throws:
Exception

getSlaveServerDetections

public List<SlaveServerDetection> getSlaveServerDetections()
                                                    throws Exception
Throws:
Exception

getTransStatus

public SlaveServerTransStatus getTransStatus(String transName,
                                             String carteObjectId,
                                             int startLogLineNr)
                                      throws Exception
Throws:
Exception

getJobStatus

public SlaveServerJobStatus getJobStatus(String jobName,
                                         String carteObjectId,
                                         int startLogLineNr)
                                  throws Exception
Throws:
Exception

stopTransformation

public WebResult stopTransformation(String transName,
                                    String carteObjectId)
                             throws Exception
Throws:
Exception

pauseResumeTransformation

public WebResult pauseResumeTransformation(String transName,
                                           String carteObjectId)
                                    throws Exception
Throws:
Exception

removeTransformation

public WebResult removeTransformation(String transName,
                                      String carteObjectId)
                               throws Exception
Throws:
Exception

removeJob

public WebResult removeJob(String jobName,
                           String carteObjectId)
                    throws Exception
Throws:
Exception

stopJob

public WebResult stopJob(String transName,
                         String carteObjectId)
                  throws Exception
Throws:
Exception

startTransformation

public WebResult startTransformation(String transName,
                                     String carteObjectId)
                              throws Exception
Throws:
Exception

startJob

public WebResult startJob(String jobName,
                          String carteObjectId)
                   throws Exception
Throws:
Exception

cleanupTransformation

public WebResult cleanupTransformation(String transName,
                                       String carteObjectId)
                                throws Exception
Throws:
Exception

deAllocateServerSockets

public WebResult deAllocateServerSockets(String transName,
                                         String clusteredRunId)
                                  throws Exception
Throws:
Exception

findSlaveServer

public static SlaveServer findSlaveServer(List<SlaveServer> slaveServers,
                                          String name)

findSlaveServer

public static SlaveServer findSlaveServer(List<SlaveServer> slaveServers,
                                          ObjectId id)

getSlaveServerNames

public static String[] getSlaveServerNames(List<SlaveServer> slaveServers)

allocateServerSocket

public int allocateServerSocket(String runId,
                                int portRangeStart,
                                String hostname,
                                String transformationName,
                                String sourceSlaveName,
                                String sourceStepName,
                                String sourceStepCopy,
                                String targetSlaveName,
                                String targetStepName,
                                String targetStepCopy)
                         throws Exception
Throws:
Exception

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 of the object

setName

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

Specified by:
setName in interface RepositoryElementInterface

isShared

public boolean isShared()
Specified by:
isShared in interface SharedObjectInterface

setShared

public void setShared(boolean shared)
Specified by:
setShared in interface SharedObjectInterface

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.

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

getRepositoryDirectory

public RepositoryDirectoryInterface getRepositoryDirectory()
Not used in this case, simply return 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

sniffStep

public String sniffStep(String transName,
                        String stepName,
                        String copyNr,
                        int lines,
                        String type)
                 throws Exception
Sniff rows on a the slave server, return xml containing the row metadata and data.

Parameters:
transName -
stepName -
copyNr -
lines -
Returns:
Throws:
Exception

getNextSlaveSequenceValue

public long getNextSlaveSequenceValue(String slaveSequenceName,
                                      long incrementValue)
                               throws KettleException
Throws:
KettleException

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