tassl.workflow.resources
Class Resource

java.lang.Object
  extended by tassl.workflow.resources.Resource
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ResourceCloud, ResourceCluster

public abstract class Resource
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  java.lang.String identifier
           
protected  java.lang.String keyfile
           
protected  java.util.HashMap<java.lang.String,Node> nodeList
           
protected  java.lang.String softwareDirWorker
           
protected  java.util.HashMap<java.lang.String,java.lang.String> supportedApps
           
protected  java.lang.String userWorker
           
protected  java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.List<java.lang.String>>> wflNode
           
protected  java.lang.String workerBasePropertyFile
           
protected  java.lang.String workingDir
           
protected  java.lang.String zone
           
 
Constructor Summary
Resource()
           
 
Method Summary
abstract  java.util.List allocateStage(java.lang.String wflId, java.lang.String stageId, java.util.List<java.lang.String> MachineWorkers, java.lang.String properties)
          Allocate N workers to a specific stage.
abstract  boolean checkAllocatePossibleStage(int numWorkers, java.lang.String properties)
          Check if the stage can be allocated in this resource
 java.util.HashMap checkAllWorkerStatus()
          Check the status of all the workers
protected  boolean checkIfExistsNodeAcct(java.util.List<NodeAcct> currentNodeAcct, java.lang.String ip)
          Check if an machine, identified by IP, is registered in the accounting already.
 java.lang.String checkWorkerStatus(java.lang.String address, int port)
           
 boolean createWorkerProperties(java.lang.String filename, java.lang.String wflId, java.lang.String stageId, java.lang.String appname, java.lang.String workerclass, java.lang.String properties, double perf, java.lang.String tasks)
           
abstract  void disableSite()
          Disable a site by setting all resources to 0 and terminate currently running workers/VMs.
abstract  java.util.List<NodeAcct> generateAccountingInfo(java.lang.String wflId, java.lang.String stageId, long timestamp, java.util.List<NodeAcct> currentNodeAcct)
          Generate the accounting information of a stage.
 java.util.HashMap<java.lang.String,java.util.List> getActiveResourcesWorkflow()
          Get the list of active resources organized by workflowid.stageid
abstract  java.util.List getAvailableSlotsScheduling(java.lang.String siteAddress, java.lang.String[] allocatedWorkers)
          It creates the list of available slots for scheduling considering the workers per machine and the number of available machines.
protected  int getCandidateTunnelPort(java.util.List avoidPorts)
          Return a port to use for the tunnel from Agent to Worker
 double getCostDataIn()
           
 double getCostDataOut()
           
 java.lang.String getIdentifier()
           
 java.lang.String getKeyfile()
           
 java.util.HashMap<java.lang.String,Node> getNodeList()
          Return the list of nodes of this site in the format "name or ip": Node
 double getOverhead()
           
 java.lang.Integer getPortMapWorker(java.lang.String address, int port)
           
 java.util.HashMap<java.lang.String,java.lang.String> getSupportedApps()
           
 java.lang.String getUserWorker()
           
 java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.List<java.lang.String>>> getWflNode()
          Return nodes assigned to each workflow
 java.lang.String getWflStageWorker(java.lang.String worker)
          Return the workflowId.stageId where the worker is allocated worker ip:port
 java.lang.String getWorkerBasePropertyFile()
           
 java.util.List<java.lang.String> getWorkersWorkflowStage(java.lang.String workflowId, java.lang.String stageId)
          Return the workers allocated to a specific stage workflow
 java.lang.String getZone()
           
abstract  boolean isActive(java.lang.String ip)
          Check if the node corresponding to this IP is active.
abstract  boolean isStatusActive(java.lang.String ip)
          Check if the machine is in active status in the records.
 boolean loadConfig(java.lang.String file, java.lang.String type)
           
 void releasePortMapWorker(java.lang.String addressWorker, int portWorker)
          Release ports from SSH tunnel from Agent to Worker.
abstract  java.util.List releaseSomeWorkers(java.lang.String workflowId, java.lang.String stageId, java.util.List workers)
          Release SOME workers allocated to the specific workflow stage
abstract  java.util.List releaseSomeWorkersbyMachineIp(java.lang.String workflowId, java.lang.String stageId, java.util.List machineIps)
          Release all workers of the selected machines
 void releaseTunnelsWorker(java.lang.String addressWorker)
          Release reverse SSH tunnel from Agent to Worker.
abstract  java.util.List releaseWorkers(java.lang.String workflowId, java.lang.String stageId)
          Release ALL workers allocated to the specific workflow stage
abstract  void restoreSite()
          Restore a previously disabled site.
 void setAgentSSHTunnelPortRange(int[] portRange)
           
 void setIdentifier(java.lang.String identifier)
           
 void setKeyfile(java.lang.String keyfile)
           
 void setNodeList(java.util.HashMap<java.lang.String,Node> nodeList)
           
 void setOverhead(double overhead)
           
 void setPorts(int taskServicePort, int mgmtServicePort, int fileServerPort)
           
 void setStartSSHtunnelAgent(boolean value)
           
 void setStartSSHtunnels(boolean startSSHtunnels)
           
 void setSupportedApps(java.util.HashMap<java.lang.String,java.lang.String> supportedApps)
           
 void setWorkerBasePropertyFile(java.lang.String workerBasePropertyFile)
           
 void startAgentToWorkerTunnel(java.lang.String remoteport, java.lang.String remoteaddress)
           
 void startTunnelsWorker(java.lang.String addkey, java.lang.String address)
           
 java.util.List startWorkers(java.util.List<java.lang.String> nodeinfo, java.lang.String wflId, java.lang.String stageId, java.lang.String appname, java.lang.String properties, java.util.List<java.lang.Double> performance, java.lang.String tasks)
           
 java.util.HashMap<java.lang.String,java.lang.Double> string2HashMapDouble(java.lang.String values)
          Convert a string to HashMap
 java.util.HashMap<java.lang.String,java.lang.Integer> string2HashMapInt(java.lang.String values)
          Convert a string to HashMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifier

protected java.lang.String identifier

zone

protected java.lang.String zone

nodeList

protected java.util.HashMap<java.lang.String,Node> nodeList

wflNode

protected java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.List<java.lang.String>>> wflNode

supportedApps

protected java.util.HashMap<java.lang.String,java.lang.String> supportedApps

softwareDirWorker

protected java.lang.String softwareDirWorker

userWorker

protected java.lang.String userWorker

workerBasePropertyFile

protected java.lang.String workerBasePropertyFile

workingDir

protected java.lang.String workingDir

keyfile

protected java.lang.String keyfile
Constructor Detail

Resource

public Resource()
Method Detail

loadConfig

public boolean loadConfig(java.lang.String file,
                          java.lang.String type)

string2HashMapInt

public java.util.HashMap<java.lang.String,java.lang.Integer> string2HashMapInt(java.lang.String values)
Convert a string to HashMap

Parameters:
values - The format is m1.small:10;Logger.getLogger(ResourceCloud.class.getName()).log(Level.SEVERE, null, e);m1.medium:5;m1.large:3 or ip:2;ip:2 or etc
Returns:
HashMap

string2HashMapDouble

public java.util.HashMap<java.lang.String,java.lang.Double> string2HashMapDouble(java.lang.String values)
Convert a string to HashMap

Parameters:
values - The format is m1.small:10;m1.medium:5;m1.large:3 or ip:2;ip:2 or etc
Returns:
HashMap

getSupportedApps

public java.util.HashMap<java.lang.String,java.lang.String> getSupportedApps()

getIdentifier

public java.lang.String getIdentifier()

getZone

public java.lang.String getZone()

getKeyfile

public java.lang.String getKeyfile()

getOverhead

public double getOverhead()

getUserWorker

public java.lang.String getUserWorker()

getCostDataIn

public double getCostDataIn()

getCostDataOut

public double getCostDataOut()

getWorkerBasePropertyFile

public java.lang.String getWorkerBasePropertyFile()

getWflNode

public java.util.HashMap<java.lang.String,java.util.HashMap<java.lang.String,java.util.List<java.lang.String>>> getWflNode()
Return nodes assigned to each workflow

Returns:
HashMap //wkfId:{stageid:{"ip:port","ip:port"},stageid:{"ip:port","ip:port"}}

getWorkersWorkflowStage

public java.util.List<java.lang.String> getWorkersWorkflowStage(java.lang.String workflowId,
                                                                java.lang.String stageId)
Return the workers allocated to a specific stage workflow

Parameters:
workflowId -
stageId -
Returns:
List of workers (address:port) or empty list if it does not exist

getNodeList

public java.util.HashMap<java.lang.String,Node> getNodeList()
Return the list of nodes of this site in the format "name or ip": Node

Returns:
HashMap //name:node

setStartSSHtunnels

public void setStartSSHtunnels(boolean startSSHtunnels)

setStartSSHtunnelAgent

public void setStartSSHtunnelAgent(boolean value)

setAgentSSHTunnelPortRange

public void setAgentSSHTunnelPortRange(int[] portRange)

getCandidateTunnelPort

protected int getCandidateTunnelPort(java.util.List avoidPorts)
Return a port to use for the tunnel from Agent to Worker

Returns:

setPorts

public void setPorts(int taskServicePort,
                     int mgmtServicePort,
                     int fileServerPort)

setNodeList

public void setNodeList(java.util.HashMap<java.lang.String,Node> nodeList)

setIdentifier

public void setIdentifier(java.lang.String identifier)

setKeyfile

public void setKeyfile(java.lang.String keyfile)

setSupportedApps

public void setSupportedApps(java.util.HashMap<java.lang.String,java.lang.String> supportedApps)

setOverhead

public void setOverhead(double overhead)

setWorkerBasePropertyFile

public void setWorkerBasePropertyFile(java.lang.String workerBasePropertyFile)

startAgentToWorkerTunnel

public void startAgentToWorkerTunnel(java.lang.String remoteport,
                                     java.lang.String remoteaddress)

startTunnelsWorker

public void startTunnelsWorker(java.lang.String addkey,
                               java.lang.String address)

releasePortMapWorker

public void releasePortMapWorker(java.lang.String addressWorker,
                                 int portWorker)
Release ports from SSH tunnel from Agent to Worker.

Parameters:
addressWorker -
portWorker -

releaseTunnelsWorker

public void releaseTunnelsWorker(java.lang.String addressWorker)
Release reverse SSH tunnel from Agent to Worker.

Parameters:
addressWorker -
portWorker -

startWorkers

public java.util.List startWorkers(java.util.List<java.lang.String> nodeinfo,
                                   java.lang.String wflId,
                                   java.lang.String stageId,
                                   java.lang.String appname,
                                   java.lang.String properties,
                                   java.util.List<java.lang.Double> performance,
                                   java.lang.String tasks)

getWflStageWorker

public java.lang.String getWflStageWorker(java.lang.String worker)
Return the workflowId.stageId where the worker is allocated worker ip:port

Returns:
workflowId.stageId if found or null if not found

checkAllWorkerStatus

public java.util.HashMap checkAllWorkerStatus()
Check the status of all the workers

Returns:
hashmap {"wflId.stageId":{"ip:port",..},"wflId.stageId":{"ip:port",..},...}

getPortMapWorker

public java.lang.Integer getPortMapWorker(java.lang.String address,
                                          int port)

checkWorkerStatus

public java.lang.String checkWorkerStatus(java.lang.String address,
                                          int port)

createWorkerProperties

public boolean createWorkerProperties(java.lang.String filename,
                                      java.lang.String wflId,
                                      java.lang.String stageId,
                                      java.lang.String appname,
                                      java.lang.String workerclass,
                                      java.lang.String properties,
                                      double perf,
                                      java.lang.String tasks)

getActiveResourcesWorkflow

public java.util.HashMap<java.lang.String,java.util.List> getActiveResourcesWorkflow()
Get the list of active resources organized by workflowid.stageid

Returns:

releaseWorkers

public abstract java.util.List releaseWorkers(java.lang.String workflowId,
                                              java.lang.String stageId)
Release ALL workers allocated to the specific workflow stage

Parameters:
workflowId -
stageId -
Returns:
list of workers to be terminated

releaseSomeWorkers

public abstract java.util.List releaseSomeWorkers(java.lang.String workflowId,
                                                  java.lang.String stageId,
                                                  java.util.List workers)
Release SOME workers allocated to the specific workflow stage

Parameters:
workflowId -
stageId -
workers -
Returns:
List of VM types (cloud) or list of machine ips(cluster) corresponding with the workers

releaseSomeWorkersbyMachineIp

public abstract java.util.List releaseSomeWorkersbyMachineIp(java.lang.String workflowId,
                                                             java.lang.String stageId,
                                                             java.util.List machineIps)
Release all workers of the selected machines

Parameters:
workflowId -
stageId -
machineIps -
Returns:
List of workers {address:port,address:port,...}

allocateStage

public abstract java.util.List allocateStage(java.lang.String wflId,
                                             java.lang.String stageId,
                                             java.util.List<java.lang.String> MachineWorkers,
                                             java.lang.String properties)
Allocate N workers to a specific stage. We can select the type of VM we want with properties Call allocateStage from AgentResourceManager and get the list of node:port

Parameters:
wflId -
stageId -
MachineWorkers -
properties - This defines the type of allocation "random" or "exact" as the list of MachineWorkers says
Returns:
list of workers to be started

checkAllocatePossibleStage

public abstract boolean checkAllocatePossibleStage(int numWorkers,
                                                   java.lang.String properties)
Check if the stage can be allocated in this resource

Parameters:
numWorkers -
properties - This can be the type of VM we want, the min performance of a machine, etc..
Returns:

isActive

public abstract boolean isActive(java.lang.String ip)
Check if the node corresponding to this IP is active. It first checks the records and then the real status using ssh.

Parameters:
ip -
Returns:

isStatusActive

public abstract boolean isStatusActive(java.lang.String ip)
Check if the machine is in active status in the records.

Parameters:
ip -
Returns:

getAvailableSlotsScheduling

public abstract java.util.List getAvailableSlotsScheduling(java.lang.String siteAddress,
                                                           java.lang.String[] allocatedWorkers)
It creates the list of available slots for scheduling considering the workers per machine and the number of available machines. It includes the allocated slots if any

Parameters:
siteAddress - address:port of the site to be identified later
allocatedWorkers - machine/vmtype:numWorkers
Returns:
list of WorkerForScheduler objects

generateAccountingInfo

public abstract java.util.List<NodeAcct> generateAccountingInfo(java.lang.String wflId,
                                                                java.lang.String stageId,
                                                                long timestamp,
                                                                java.util.List<NodeAcct> currentNodeAcct)
Generate the accounting information of a stage. It returns only the new information that is not already in the accounting. This info is related to when the machines are provisioned and it will be deleted when they are released.

Parameters:
wflId -
stageId -
timestamp - time when the machine is provisioned
currentNodeAcct - this is the accounting info before the new workers are assigned.
Returns:
List of provisioned machines

disableSite

public abstract void disableSite()
Disable a site by setting all resources to 0 and terminate currently running workers/VMs. After this method, a different method should be called if immediate resource termination is expected


restoreSite

public abstract void restoreSite()
Restore a previously disabled site. After calling this method, the Central Resource Manager/Autonomic Scheduler should be notified


checkIfExistsNodeAcct

protected boolean checkIfExistsNodeAcct(java.util.List<NodeAcct> currentNodeAcct,
                                        java.lang.String ip)
Check if an machine, identified by IP, is registered in the accounting already. For use only in Agent side.

Parameters:
currentNodeAcct -
ip -
Returns: