org.objectweb.proactive.core.descriptor.data
Class VirtualNodeImpl

java.lang.Object
  extended byorg.objectweb.proactive.core.event.AbstractEventProducer
      extended byorg.objectweb.proactive.core.event.NodeCreationEventProducerImpl
          extended byorg.objectweb.proactive.core.descriptor.data.VirtualNodeImpl
All Implemented Interfaces:
java.util.EventListener, Job, NodeCreationEventListener, NodeCreationEventProducer, ProActiveListener, RuntimeRegistrationEventListener, java.io.Serializable, ServiceUser, VirtualNode

public class VirtualNodeImpl
extends NodeCreationEventProducerImpl
implements VirtualNode, java.io.Serializable, RuntimeRegistrationEventListener, NodeCreationEventListener, ServiceUser

A VirtualNode is a conceptual entity that represents one or several nodes. After activation a VirtualNode represents one or several nodes.

Since:
ProActive 0.9.3
Version:
1.0, 2002/09/20
Author:
ProActive Team
See Also:
ProActiveDescriptor, VirtualMachine, Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
AbstractEventProducer.ListenerList
 
Field Summary
static int counter
           
protected  long globalTimeOut
          represents the sum of the timeout + current time in ms
protected  java.lang.String jobID
           
protected  ProActiveRuntimeImpl proActiveRuntimeImpl
          Reference on the local runtime
protected  long timeout
          represents the timeout in ms
 
Fields inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
eventListeners, logger, shouldSerializeListeners
 
Fields inherited from interface org.objectweb.proactive.core.descriptor.data.VirtualNode
vnLogger
 
Method Summary
 void activate()
          Activates all the Nodes mapped to this VirtualNode in the XML Descriptor
 void addFileTransferDeploy(FileTransfer ft)
           
 void addFileTransferRetrieve(FileTransfer ft)
           
 void addP2PNodesLookup(P2PNodeLookup nodesLookup)
           
 void addVirtualMachine(VirtualMachine virtualMachine)
          Adds a VirtualMachine entity to this VirtualNode
 int createdNodeCount()
          Deprecated. use getNumberOfCurrentlyCreatedNodes() or getNumberOfCreatedNodesAfterDeployment() instead
 void createNodeOnCurrentJvm(java.lang.String protocol)
          Creates a node with the given protocol(or null) on the current jvm, ie the jvm that originates the creation of this VirtualNode.
 java.lang.String getJobID()
           
 int getMinNumberOfNodes()
          Returns the minimum number of nodes needed for this VirtualNode.
 java.lang.String getName()
          Returns the name of this VirtualNode
 Node getNode()
          Returns the first Node created among Nodes mapped to this VirtualNode in the XML Descriptor Another call to this method will return the following created node if any.
 Node getNode(int index)
          Returns the Node mapped to this VirtualNode with the specified index.
 Node getNode(java.lang.String url)
          Returns the node of the given url among nodes mapped to this VirtualNode in the xml descriptor or null if such node does not exist.
 int getNodeCount()
          Returns the number of Nodes mapped to this VirtualNode in the XML Descriptor
 Node[] getNodes()
          Returns all nodes mapped to this VirtualNode
 java.lang.String[] getNodesURL()
          Returns all nodes url mapped to this VirualNode
 int getNumberOfCreatedNodesAfterDeployment()
          Returns the number of Nodes that could successfully be created at the end of the deployment
 int getNumberOfCurrentlyCreatedNodes()
          Returns the number of Nodes already created (at the time of the reception of method call) among the Nodes mapped to this VirtualNode in the XML Descriptor
 java.lang.String getPadURL()
          return the url of the proactive descriptor which created this VN
 java.lang.String getProperty()
          Returns the value of property attribute.
 java.lang.String getRegistrationProtocol()
           
 long getTimeout()
          Returns the timeout of this VirtualNode
 java.lang.Object getUniqueAO()
          Returns the unique active object created on the unique node mapped to this VirtualNode.
 java.lang.String getUserClass()
          Returns the real class of the service user
 VirtualMachine getVirtualMachine()
          Returns the virtualMachine entity linked to this VirtualNode or if cyclic, returns one of the VirtualMachines linked to this VirtualNode with a cyclic manner(internal count incremented each time this method is called).
 boolean isActivated()
          Returns true is this VirtualNode is already activated, false otherwise
 boolean isLookup()
           
 boolean isMainVirtualNode()
          return true if the virtual node represents a node with a main method
 boolean isMultiple()
          checks the cardinality of the virtual node (i.e. whether the node is mapped to several nodes or not)
 void killAll(boolean softly)
          Kills all nodes mapped to this VirtualNode.
 void nodeCreated(NodeCreationEvent event)
          Use for p2p infrastructure to get nodes.
 void runtimeRegistered(RuntimeRegistrationEvent event)
          Signals that a registration occured on the runtime encapsulated in the event
 void setIsMainVirtualNode(boolean isMainVirtualNode)
          set tha main property of this VN
 void setMinNumberOfNodes(int min)
          Sets the minimal number of nodes this VirtualNode needs to be suitable for the application.
 void setName(java.lang.String s)
          Sets the name of this VirtualNode
 void setPadURL(java.lang.String XMLpadURL)
          set the url of the pad
 void setProperty(java.lang.String value)
          Sets the property attribute to the given value
 void setRegistrationProtocol(java.lang.String protocol)
           
 void setRuntimeInformations(java.lang.String information, java.lang.String value)
          Allows to set runtime informations for this VirtualNode activation.
 void setService(UniversalService service)
          Sets the given service
 void setTimeout(long timeout, boolean waitForTimeout)
          Sets the timeout variable to the given value.
 void waitForAllNodesCreation()
          Waits until all Nodes mapped to this VirtualNode in the XML Descriptor are created
 
Methods inherited from class org.objectweb.proactive.core.event.NodeCreationEventProducerImpl
addNodeCreationEventListener, notifyListeners, notifyOneListener, removeNodeCreationEventListener
 
Methods inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
addListener, hasListeners, notifyAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counter

public static int counter

proActiveRuntimeImpl

protected transient ProActiveRuntimeImpl proActiveRuntimeImpl
Reference on the local runtime


timeout

protected long timeout
represents the timeout in ms


globalTimeOut

protected long globalTimeOut
represents the sum of the timeout + current time in ms


jobID

protected java.lang.String jobID
Method Detail

setProperty

public void setProperty(java.lang.String value)
Sets the property attribute to the given value

Parameters:
value - property the value of property attribute, this value can be "unique", "unique_singleAO", "multiple", "multiple_cyclic" or nothing

getProperty

public java.lang.String getProperty()
Description copied from interface: VirtualNode
Returns the value of property attribute.

Specified by:
getProperty in interface VirtualNode
Returns:
String

getTimeout

public long getTimeout()
Description copied from interface: VirtualNode
Returns the timeout of this VirtualNode

Specified by:
getTimeout in interface VirtualNode
Returns:
the timeout of this VirtualNode

setTimeout

public void setTimeout(long timeout,
                       boolean waitForTimeout)
Sets the timeout variable to the given value. Using waitForTimeout = true will force this VirtualNode to wait until the timeout expires before giving access to its nodes, waitForTimeout = false allows this VirtualNode to give access to its node when number of nodes expected are really created or the timeout has expired

Parameters:
timeout - the timeout to set in ms
waitForTimeout - to force or not this VirtualNode to wait untile timeout's expiration

setName

public void setName(java.lang.String s)
Sets the name of this VirtualNode

Parameters:
s - the name of this Virtual Node

getName

public java.lang.String getName()
Description copied from interface: VirtualNode
Returns the name of this VirtualNode

Specified by:
getName in interface VirtualNode
Returns:
String

addVirtualMachine

public void addVirtualMachine(VirtualMachine virtualMachine)
Description copied from interface: VirtualNode
Adds a VirtualMachine entity to this VirtualNode

Specified by:
addVirtualMachine in interface VirtualNode
Parameters:
virtualMachine -

addFileTransferDeploy

public void addFileTransferDeploy(FileTransfer ft)

addFileTransferRetrieve

public void addFileTransferRetrieve(FileTransfer ft)

getVirtualMachine

public VirtualMachine getVirtualMachine()
Description copied from interface: VirtualNode
Returns the virtualMachine entity linked to this VirtualNode or if cyclic, returns one of the VirtualMachines linked to this VirtualNode with a cyclic manner(internal count incremented each time this method is called).

Specified by:
getVirtualMachine in interface VirtualNode
Returns:
VirtualMachine

activate

public void activate()
Activates all the Nodes mapped to this VirtualNode in the XML Descriptor

Specified by:
activate in interface VirtualNode

isMainVirtualNode

public boolean isMainVirtualNode()
return true if the virtual node represents a node with a main method

Returns:
boolean

getPadURL

public java.lang.String getPadURL()
return the url of the proactive descriptor which created this VN

Returns:
String

setIsMainVirtualNode

public void setIsMainVirtualNode(boolean isMainVirtualNode)
set tha main property of this VN

Parameters:
isMainVirtualNode -

setPadURL

public void setPadURL(java.lang.String XMLpadURL)
set the url of the pad

Parameters:
XMLpadURL - url of the pad

getNodeCount

public int getNodeCount()
Returns the number of Nodes mapped to this VirtualNode in the XML Descriptor

Specified by:
getNodeCount in interface VirtualNode
Returns:
int

createdNodeCount

public int createdNodeCount()
Deprecated. use getNumberOfCurrentlyCreatedNodes() or getNumberOfCreatedNodesAfterDeployment() instead

Specified by:
createdNodeCount in interface VirtualNode

getNumberOfCurrentlyCreatedNodes

public int getNumberOfCurrentlyCreatedNodes()
Description copied from interface: VirtualNode
Returns the number of Nodes already created (at the time of the reception of method call) among the Nodes mapped to this VirtualNode in the XML Descriptor

Specified by:
getNumberOfCurrentlyCreatedNodes in interface VirtualNode
Returns:
int the number of nodes created at the time of the method call

getNumberOfCreatedNodesAfterDeployment

public int getNumberOfCreatedNodesAfterDeployment()
Description copied from interface: VirtualNode
Returns the number of Nodes that could successfully be created at the end of the deployment

Specified by:
getNumberOfCreatedNodesAfterDeployment in interface VirtualNode
Returns:
int the number of nodes effectively created

getNode

public Node getNode()
             throws NodeException
Returns the first Node created among Nodes mapped to this VirtualNode in the XML Descriptor Another call to this method will return the following created node if any.

Specified by:
getNode in interface VirtualNode
Returns:
Node
Throws:
NodeException

getNode

public Node getNode(int index)
             throws NodeException
Description copied from interface: VirtualNode
Returns the Node mapped to this VirtualNode with the specified index. There is no relationship between, the order in the xml descriptor and the order in the array.

Specified by:
getNode in interface VirtualNode
Parameters:
index -
Returns:
Node the node at the specified index in the array of nodes mapped to this VirtualNode
Throws:
NodeException

getNodesURL

public java.lang.String[] getNodesURL()
                               throws NodeException
Description copied from interface: VirtualNode
Returns all nodes url mapped to this VirualNode

Specified by:
getNodesURL in interface VirtualNode
Returns:
String[]. An array of string containing the url of all nodes mapped to this VirtualNode in the XML descriptor.
Throws:
NodeException

getNodes

public Node[] getNodes()
                throws NodeException
Description copied from interface: VirtualNode
Returns all nodes mapped to this VirtualNode

Specified by:
getNodes in interface VirtualNode
Returns:
Node[] An array of Node conataining all the nodes mapped to this VirtualNode in the XML descriptor
Throws:
NodeException

getNode

public Node getNode(java.lang.String url)
             throws NodeException
Description copied from interface: VirtualNode
Returns the node of the given url among nodes mapped to this VirtualNode in the xml descriptor or null if such node does not exist.

Specified by:
getNode in interface VirtualNode
Parameters:
url -
Returns:
Node the node of the given url or null if such node does not exist
Throws:
NodeException

killAll

public void killAll(boolean softly)
Description copied from interface: VirtualNode
Kills all nodes mapped to this VirtualNode. It is in fact the runtime(so the jvm) on which the node is running that is killed. Nodes are previously unregistered from any registry.

Specified by:
killAll in interface VirtualNode
Parameters:
softly - if false, all jvms created when activating this VirtualNode are killed abruptely if true a jvm that originates the creation of a rmi registry waits until registry is empty before dying. To be more precise a thraed is created to ask periodically the registry if objects are still registered.

createNodeOnCurrentJvm

public void createNodeOnCurrentJvm(java.lang.String protocol)
Description copied from interface: VirtualNode
Creates a node with the given protocol(or null) on the current jvm, ie the jvm that originates the creation of this VirtualNode. This newly created node will is mapped on this VirtualNode

Specified by:
createNodeOnCurrentJvm in interface VirtualNode
Parameters:
protocol - the protocol to create the node. If null protocol will be set to the system property: proactive.communication.protocol.

getUniqueAO

public java.lang.Object getUniqueAO()
                             throws ProActiveException
Description copied from interface: VirtualNode
Returns the unique active object created on the unique node mapped to this VirtualNode. This method should be called on a virtualNode, with unique_singleAO property defined in the XML descriptor. If more than one active object are found, a warning is generated, and the first active object found is returned

Specified by:
getUniqueAO in interface VirtualNode
Returns:
Object the unique active object created on the unique node mapped to this VirtualNode. If many active objects are found, the first one is returned
Throws:
ProActiveException - if no active objects are created on this VirtualNode.

isActivated

public boolean isActivated()
Description copied from interface: VirtualNode
Returns true is this VirtualNode is already activated, false otherwise

Specified by:
isActivated in interface VirtualNode

isLookup

public boolean isLookup()
Specified by:
isLookup in interface VirtualNode
Returns:
true if this VirtualNode is a VirtualNodeLookup, false if it is a VirtualNodeImpl
See Also:
VirtualNode.isLookup()

getJobID

public java.lang.String getJobID()
Specified by:
getJobID in interface Job
Returns:
the jobID associated with this object
See Also:
Job.getJobID()

runtimeRegistered

public void runtimeRegistered(RuntimeRegistrationEvent event)
Description copied from interface: RuntimeRegistrationEventListener
Signals that a registration occured on the runtime encapsulated in the event

Specified by:
runtimeRegistered in interface RuntimeRegistrationEventListener
Parameters:
event - the creation event that details the registration on the runtime

setRuntimeInformations

public void setRuntimeInformations(java.lang.String information,
                                   java.lang.String value)
                            throws ProActiveException
Description copied from interface: VirtualNode
Allows to set runtime informations for this VirtualNode activation. This method allows to give to this VirtualNode some informations retrieved at runtime and not defined in the XML descriptor. In the current release, this method can be called on a VirtualNode resulting from a lookup. The only one information that can be set is LOOKUP_HOST. This information has a sense if in the XML descriptor this VirtualNode is defined with the line:
 lookup virtualNode="vnName" host="*" protocol="rmi or jini", ie the name of the host where to perform the lookup
 will be known at runtime.
 
We expect to implement several runtime informations. If this method fails, for instance, if the property does not exist or has already been set, or is performed on a VirtualNode not resulting from a lookup, an exception will be thrown but the application will carry on.

Specified by:
setRuntimeInformations in interface VirtualNode
Parameters:
information - the information to be set at runtime
value - the value of the information
Throws:
ProActiveException - if the given information does not exist or has alredy been set
See Also:
At the moment no property can be set at runtime on a VirtualNodeImpl.

setService

public void setService(UniversalService service)
                throws ProActiveException
Description copied from interface: ServiceUser
Sets the given service

Specified by:
setService in interface ServiceUser
Parameters:
service - the service to set
Throws:
ProActiveException - if the given service cannot be set on the user object
See Also:
ServiceUser.setService(org.objectweb.proactive.core.descriptor.services.UniversalService)

getUserClass

public java.lang.String getUserClass()
Description copied from interface: ServiceUser
Returns the real class of the service user

Specified by:
getUserClass in interface ServiceUser
Returns:
the real class of the service user
See Also:
ServiceUser.getUserClass()

setRegistrationProtocol

public void setRegistrationProtocol(java.lang.String protocol)

getRegistrationProtocol

public java.lang.String getRegistrationProtocol()

setMinNumberOfNodes

public void setMinNumberOfNodes(int min)
Sets the minimal number of nodes this VirtualNode needs to be suitable for the application. It means that if in the Deployment file, this VirtualNode is mapped onto n nodes, and the minimum number of nodes is set to m, with of course m < n, calling method getNodes will return when at least m nodes are created

Parameters:
min - the minimum number of nodes

getMinNumberOfNodes

public int getMinNumberOfNodes()
Description copied from interface: VirtualNode
Returns the minimum number of nodes needed for this VirtualNode. This number represents the minimum number of nodes, this VirtualNode needs in order to be suitable for the application. Default value is the total number of nodes requested in the XML file

Specified by:
getMinNumberOfNodes in interface VirtualNode
See Also:
VirtualNode.getMinNumberOfNodes()

isMultiple

public boolean isMultiple()
Description copied from interface: VirtualNode
checks the cardinality of the virtual node (i.e. whether the node is mapped to several nodes or not)

Specified by:
isMultiple in interface VirtualNode
Returns:
true if the virtual node is mapped to several nodes, false otherwise
See Also:
VirtualNode.isMultiple()

waitForAllNodesCreation

public void waitForAllNodesCreation()
                             throws NodeException
Waits until all Nodes mapped to this VirtualNode in the XML Descriptor are created

Throws:
NodeException

nodeCreated

public void nodeCreated(NodeCreationEvent event)
Use for p2p infrastructure to get nodes.

Specified by:
nodeCreated in interface NodeCreationEventListener
Parameters:
event - that details the creation of the node
See Also:
NodeCreationEventListener.nodeCreated(org.objectweb.proactive.core.event.NodeCreationEvent)

addP2PNodesLookup

public void addP2PNodesLookup(P2PNodeLookup nodesLookup)
Parameters:
nodesLookup -


Copyright 2001-2005 INRIA All Rights Reserved.