public abstract class InfrastructureManager extends Object implements NodeSourcePlugin
internalRegisterAcquiredNode(Node)
configure(Object...)
- define a way to acquire
a single node from underlying infrastructure in
acquireNode()
- define a way to acquire all
available nodes from the infrastructure in the method
acquireAllNodes()
- register available nodes in
the resource manager using
internalRegisterAcquiredNode(Node)
, so they
till be taken into account. - add the name of new class to the resource
manager configuration file (config/rm/nodesource/infrastructures).Modifier and Type | Class and Description |
---|---|
protected static interface |
InfrastructureManager.PersistedInfraVariablesHandler<T>
Interface that allows handling the runtime variables through a functional point of view.
|
static class |
InfrastructureManager.RMDeployingNodeAccessor
Helper nested class.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
ELASTIC |
protected static org.apache.log4j.Logger |
logger
class' logger
|
protected NodeSource |
nodeSource
manager's node source
|
protected Map<String,Serializable> |
persistedInfraVariables
Store information about the running infrastructure.
|
protected Lock |
readLock
Use this lock to wrap a read access to runtime variables
|
protected static String |
RM_URL_KEY |
protected Lock |
writeLock
Use this lock to wrap a write access to runtime variables
|
Constructor and Description |
---|
InfrastructureManager() |
Modifier and Type | Method and Description |
---|---|
abstract void |
acquireAllNodes()
Asynchronous request of all nodes acquisition.
|
void |
acquireAllNodes(Map<String,?> nodeConfiguration) |
abstract void |
acquireNode()
Asynchronous node acquisition request.
|
void |
acquireNodes(int n,
long timeout,
Map<String,?> nodeConfiguration)
Asynchronous node acquisition request.
|
void |
acquireNodes(int n,
Map<String,?> nodeConfiguration)
Asynchronous node acquisition request.
|
protected String |
addDeployingNode(String name,
String command,
String description,
long timeout)
Creates a new RMDeployingNode's, stores it in a local ArrayList and
notify the owning NodeSource of the RMDeployingNode creation
|
protected RMDeployingNode |
addDeployingNodeWithLockAndPersist(String nodeUrl,
RMDeployingNode deployingNode) |
protected RMDeployingNode |
addLostNodeWithLockAndPersist(String nodeUrl,
RMDeployingNode lostNode) |
protected List<String> |
addMultipleDeployingNodes(List<String> nodeNames,
String obfuscatedCmd,
String message,
long nodeTimeout)
Add multiple deploying nodes
|
protected String |
buildDeployingNodeURL(String pnName)
Builds the name of the deploying node given its name
|
protected boolean |
checkAllNodesAreAcquiredAndDo(List<String> nodeNames,
Runnable toRunWhenOK,
Runnable toRunWhenKO) |
protected boolean |
checkNodeIsAcquiredAndDo(String nodeName,
Runnable toRunWhenOK,
Runnable toRunWhenKO)
Check if the Node with the given name is already acquired ( usefull when
the launcher of the process which is supposed to launch a RMNode waits
for its registration ).
|
protected abstract void |
configure(Object... parameters)
Adds information required to deploy nodes in the future.
|
protected boolean |
declareDeployingNodeLost(String toUpdateURL,
String description)
Declares a deploying node lost.
|
protected org.ow2.proactive.resourcemanager.utils.CommandLineBuilder |
getDefaultCommandLineBuilder(org.ow2.proactive.resourcemanager.utils.OperatingSystem targetOS)
This method returns a
CommandLineBuilder filled
in with "default" settings. |
List<RMDeployingNode> |
getDeployingAndLostNodes()
To retrieve nodes whose registration status is deploying or lost.
|
protected Collection<RMDeployingNode> |
getDeployingNodesWithLock() |
RMDeployingNode |
getDeployingOrLostNode(String nodeUrl) |
abstract String |
getDescription() |
protected org.ow2.proactive.resourcemanager.utils.CommandLineBuilder |
getEmptyCommandLineBuilder()
Returns an empty
CommandLineBuilder |
protected Collection<RMDeployingNode> |
getLostNodesWithLock() |
Map<String,String> |
getMeta() |
protected Set<String> |
getPersistedDeployingNodesUrl() |
protected <T> T |
getPersistedInfraVariable(InfrastructureManager.PersistedInfraVariablesHandler<T> t)
Acquire the read lock and call the handle method of the handler given in parameter.
|
protected Set<String> |
getPersistedLostNodesUrl() |
protected String |
getRmUrl() |
Map<Integer,String> |
getSectionDescriptions() |
protected abstract void |
initializePersistedInfraVariables()
This method should initialize a value in the runtime variables map for all the runtime variables that will be
used in the class.
|
void |
internalConfigure(Object... parameters)
called by the node source at configuration time.
|
void |
internalNotifyDownNode(String nodeName,
String nodeUrl,
org.objectweb.proactive.core.node.Node node)
This method is called by the system when a Node is detected as DOWN.
|
RMDeployingNode |
internalRegisterAcquiredNode(org.objectweb.proactive.core.node.Node node)
This method is called by the RMCore to notify the InfrastructureManager
that a new node was added to the core.
|
boolean |
internalRemoveDeployingNode(String pnUrl)
To remove a deploying node given its url
|
void |
internalRemoveNode(org.objectweb.proactive.core.node.Node node)
Performs some cleanup ( essentially removal of the cached node ) and call
removeNodeImpl
|
void |
internalShutDown()
Called by the node source at shutdown time.
|
protected boolean |
isShutDown() |
boolean |
isUsingDeployingNode() |
protected void |
multipleDeclareDeployingNodeLost(List<String> deployingNodes,
String message)
Declare multiple nodes lost
|
protected abstract void |
notifyAcquiredNode(org.objectweb.proactive.core.node.Node node)
Notifies the implementation of the infrastructure manager that a new node
has been registered.
|
protected void |
notifyDeployingNodeLost(String pnURL)
Notifies the user that the deploying node was lost or removed (because of
a timeout, user interaction...) Default empty implementation is provided
because implementors don't necessary use this feature.
|
abstract void |
notifyDownNode(String nodeName,
String nodeUrl,
org.objectweb.proactive.core.node.Node node)
Define what needs to be done in an infrastructure implementation when a node is detected as down.
|
void |
onDownNodeReconnection(org.objectweb.proactive.core.node.Node node)
Called by the system every time a node that is DOWN reconnects
and changes its status to FREE or BUSY.
|
void |
persistInfrastructureVariables()
If nodes recovery is enabled, persist the current state of the node
source.
|
void |
reconfigure(Object... updatedInfrastructureParameters)
Reconfigure the infrastructure of a potentially already deployed node
source with the given parameters.
|
void |
recoverPersistedInfraVariables(Map<String,Serializable> persistedInfrastructureVariables)
Copy all the runtime variables map given in parameter to the runtime
variables map of this infrastructure.
|
protected void |
removeDownNodePriorToNotify(String nodeName)
This method can be overriden by subclasses, especially if they do not
want the node to be removed from the InfrastructureManager map when
detected as down.
|
abstract void |
removeNode(org.objectweb.proactive.core.node.Node node)
Removes the node from the resource manager.
|
RMNode |
searchForNotAcquiredRmNode(String nodeUrl)
Look for a
RMNode in data structures holding lost and deploying
nodes. |
void |
setNodeSource(NodeSource nodeSource)
Sets an infrastructure node source.
|
protected <T> T |
setPersistedInfraVariable(InfrastructureManager.PersistedInfraVariablesHandler<T> t)
Acquire the write lock, and then:
1) call the handle method of the handler given in parameter
2) call the method that persist in database the runtime variables.
|
void |
setPersistedNodeSourceData(NodeSourceData nodeSourceData) |
protected void |
setRmDbManager(RMDBManager dbManager) |
protected void |
setRmUrl(String rmUrl) |
protected void |
shutDown()
Notify this infrastructure it is going to be shut down along with its
nodesource.
|
RMDeployingNode |
update(RMDeployingNode rmNode)
Updates a deploying node.
|
protected boolean |
updateDeployingNodeDescription(String toUpdateURL,
String newDescription)
To update the description of a deploying node.
|
protected static final org.apache.log4j.Logger logger
protected NodeSource nodeSource
protected static final String ELASTIC
protected static final String RM_URL_KEY
protected Map<String,Serializable> persistedInfraVariables
protected transient Lock readLock
protected transient Lock writeLock
public Map<String,String> getMeta()
getMeta
in interface NodeSourcePlugin
protected <T> T getPersistedInfraVariable(InfrastructureManager.PersistedInfraVariablesHandler<T> t)
protected <T> T setPersistedInfraVariable(InfrastructureManager.PersistedInfraVariablesHandler<T> t)
public void setNodeSource(NodeSource nodeSource)
nodeSource
- policy node sourcepublic void recoverPersistedInfraVariables(Map<String,Serializable> persistedInfrastructureVariables)
persistedInfrastructureVariables
- the runtime variables to recover.public List<RMDeployingNode> getDeployingAndLostNodes()
public RMDeployingNode getDeployingOrLostNode(String nodeUrl)
public final boolean internalRemoveDeployingNode(String pnUrl)
pnUrl
- the url of the deploying node to remove.public final void internalRemoveNode(org.objectweb.proactive.core.node.Node node) throws RMException
node
- the node to be removedRMException
public void internalNotifyDownNode(String nodeName, String nodeUrl, org.objectweb.proactive.core.node.Node node) throws RMException
node
- the ProActive Programming Node that is down. This parameter
can be null if no information about the node can be
retrieved apart from its url.nodeUrl
- the URL of the node that is down.RMException
- if any problems occurred.protected void removeDownNodePriorToNotify(String nodeName)
nodeName
- the node to removepublic abstract void notifyDownNode(String nodeName, String nodeUrl, org.objectweb.proactive.core.node.Node node) throws RMException
node
- the ProActive Programming Node that is down.RMException
- if any problems occurred.public final RMDeployingNode internalRegisterAcquiredNode(org.objectweb.proactive.core.node.Node node) throws RMException
checkNodeIsAcquiredAndDo(String, Runnable, Runnable)
At this
point, if a previous call to
addDeployingNode(String, String, String, long)
was made (means that implementor uses deploying nodes features), this
method ensures that the implementation method (see
notifyAcquiredNode(Node)
is only called if
no timeout has occurred for the associated deploying node.node
- the newly added nodeRMException
protected List<String> addMultipleDeployingNodes(List<String> nodeNames, String obfuscatedCmd, String message, long nodeTimeout)
nodeNames
- node names which will be createdobfuscatedCmd
- obfuscated command used to start the nodemessage
- user messagenodeTimeout
- node timeout usedprotected void multipleDeclareDeployingNodeLost(List<String> deployingNodes, String message)
deployingNodes
- list of urls of deploying nodesmessage
- user messagepublic final void internalConfigure(Object... parameters)
parameters
- the parameters of the infrastructure managerIllegalArgumentException
- if the parameters are invalidprotected boolean isShutDown()
public final void internalShutDown()
shutDown()
public abstract String getDescription()
protected abstract void configure(Object... parameters)
parameters
- of the infrastructure managerIllegalArgumentException
- if the parameters are invalidpublic void reconfigure(Object... updatedInfrastructureParameters)
updatedInfrastructureParameters
- parameters potentially containing
updated dynamic parametersIllegalArgumentException
- if parameters are incorrectConfigurable.dynamic()
public abstract void acquireNode()
internalRegisterAcquiredNode(Node)
public void acquireNodes(int n, Map<String,?> nodeConfiguration)
n
- the number of nodes to acquirenodeConfiguration
- the configuration for nodes to be acquiredpublic void acquireNodes(int n, long timeout, Map<String,?> nodeConfiguration)
n
- the number of nodes to acquiretimeout
- The maxime waiting time (in milliseconds) before starting to acquire nodes
This timeout is used to acquire locks for concurrent deployment if needed.
The request will be skipped if it can't be started within the specified timeout.nodeConfiguration
- the configuration for nodes to be acquiredpublic abstract void acquireAllNodes()
internalRegisterAcquiredNode(Node)
public abstract void removeNode(org.objectweb.proactive.core.node.Node node) throws RMException
node
- the node to release.RMException
- if any problems occurred.protected void notifyDeployingNodeLost(String pnURL)
pnURL
- the deploying node's URL for which one the timeout occurred.protected abstract void notifyAcquiredNode(org.objectweb.proactive.core.node.Node node) throws RMException
addDeployingNode(String, String, String, long)
was made), and is called only for deploying nodes for which one no
timeout occurred.node
- the newly registered nodeRMException
- if the implementation does not approve the node acquisition
requestprotected void shutDown()
public void persistInfrastructureVariables()
RMConstants.DEFAULT_LOCAL_NODES_NODE_SOURCE_NAME
.protected void setRmDbManager(RMDBManager dbManager)
protected final org.ow2.proactive.resourcemanager.utils.CommandLineBuilder getDefaultCommandLineBuilder(org.ow2.proactive.resourcemanager.utils.OperatingSystem targetOS)
CommandLineBuilder
filled
in with "default" settings. That means that the returned
CommandLineBuilder is useable as such.
OperatingSystem.UNIX
targetOS
- the operating system on which one the node will be deployedprotected final org.ow2.proactive.resourcemanager.utils.CommandLineBuilder getEmptyCommandLineBuilder()
CommandLineBuilder
CommandLineBuilder
protected final String addDeployingNode(String name, String command, String description, long timeout)
name
- The RMDeployingNode's name.description
- The RMDeployingNode's descriptiontimeout
- after which one the deploying node will be declared lost. (
node acquisition after this timeout is discarded )UnsupportedOperationException
- if the infrastructure manager is shuting downprotected final boolean updateDeployingNodeDescription(String toUpdateURL, String newDescription)
toUpdateURL
- The RMDeployingNode's URL whose description will be updated.newDescription
- The new descriptionprotected final boolean declareDeployingNodeLost(String toUpdateURL, String description)
toUpdateURL
- The RMDeployingNode's URL which is to be declared as lostdescription
- the new rmdeployingnode's description, can be null.protected final boolean checkNodeIsAcquiredAndDo(String nodeName, Runnable toRunWhenOK, Runnable toRunWhenKO)
internalRegisterAcquiredNode(Node)
to avoid
races.nodeName
- the node's nametoRunWhenOK
- the Runnable that will be launched if the node is already
acquired (can be null)toRunWhenKO
- the Runnable that will be launched if the node has not been
found among nodesource.getAliveNodes(). (can be null)protected final boolean checkAllNodesAreAcquiredAndDo(List<String> nodeNames, Runnable toRunWhenOK, Runnable toRunWhenKO)
protected String buildDeployingNodeURL(String pnName)
pnName
- The name of the deploying nodepublic RMNode searchForNotAcquiredRmNode(String nodeUrl)
RMNode
in data structures holding lost and deploying
nodes. It does not look into the acquired nodes because this data
structure holds instances of Node
and thus has no information
about the acquired RMNode
.nodeUrl
- RMNode
that could be found using the given URL, or nullpublic void onDownNodeReconnection(org.objectweb.proactive.core.node.Node node)
node
- the node that has reconnected.public RMDeployingNode update(RMDeployingNode rmNode)
The update is performed on deploying nodes first. If no node if found, lost nodes are considered.
rmNode
- the new deploying node instance to use.null
.protected abstract void initializePersistedInfraVariables()
configure(Object...)
method.
This method runs with the write lock acquired.public void setPersistedNodeSourceData(NodeSourceData nodeSourceData)
protected RMDeployingNode addDeployingNodeWithLockAndPersist(String nodeUrl, RMDeployingNode deployingNode)
protected Collection<RMDeployingNode> getDeployingNodesWithLock()
protected RMDeployingNode addLostNodeWithLockAndPersist(String nodeUrl, RMDeployingNode lostNode)
protected Collection<RMDeployingNode> getLostNodesWithLock()
public boolean isUsingDeployingNode()
protected void setRmUrl(String rmUrl)
protected String getRmUrl()
public Map<Integer,String> getSectionDescriptions()
getSectionDescriptions
in interface NodeSourcePlugin