Class JPPFResourceWrapper

java.lang.Object
org.jppf.classloader.JPPFResourceWrapper
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CompositeResourceWrapper

public class JPPFResourceWrapper extends Object implements Serializable
Instances of this class encapsulate the necessary information used by the network classloader, for sending class definition requests as well as receiving the class definitions.
Author:
Laurent Cohen, Martin JANDA
See Also:
  • Field Details

    • EMPTY_RESOURCE_WRAPPER_ARRAY

      public static final JPPFResourceWrapper[] EMPTY_RESOURCE_WRAPPER_ARRAY
      Constant for an empty JPPFResourceWrapper array.
    • resources

      protected transient JPPFResourceWrapper[] resources
      Performance optimization.
  • Constructor Details

    • JPPFResourceWrapper

      public JPPFResourceWrapper()
      Default constructor.
  • Method Details

    • addUuid

      public void addUuid(String uuid)
      Add a uuid to the uuid path of this resource wrapper.
      Parameters:
      uuid - the identifier as a string.
    • getName

      public String getName()
      Get the name of the class whose definition is requested.
      Returns:
      the class name as a string.
    • setName

      public void setName(String name)
      Set the name of the class whose definition is requested.
      Parameters:
      name - the class name as a string.
    • getDefinition

      public byte[] getDefinition()
      Get the actual definition of the requested class.
      Returns:
      the class definition as an array of bytes.
    • setDefinition

      public void setDefinition(byte[] definition)
      Set the actual definition of the requested class.
      Parameters:
      definition - the class definition as an array of bytes.
    • isDynamic

      public boolean isDynamic()
      Determine whether the class should be loaded through the network classloader.
      Returns:
      true if the class should be loaded via the network classloader, false otherwise.
    • setDynamic

      public void setDynamic(boolean dynamic)
      Set whether the class should be loaded through the network classloader.
      Parameters:
      dynamic - true if the class should be loaded via the network classloader, false otherwise.
    • getState

      public JPPFResourceWrapper.State getState()
      Get the state associated with this resource wrapper.
      Returns:
      a State typesafe enumerated value.
    • setState

      public void setState(JPPFResourceWrapper.State state)
      Set the state associated with this resource wrapper.
      Parameters:
      state - a State typesafe enumerated value.
    • getUuidPath

      public TraversalList<String> getUuidPath()
      Get a reference to the traversal list that Keeps and manages the uuid path list and the current position in it.
      Returns:
      a traversal list of string elements.
    • setUuidPath

      public void setUuidPath(TraversalList<String> uuidPath)
      Set the reference to the traversal list that Keeps and manages the uuid path list and the current position in it.
      Parameters:
      uuidPath - a traversal list of string elements.
    • getProviderUuid

      public String getProviderUuid()
      Get the uuid sent by a node when it first contacts a resource provider.
      Returns:
      the uuid as a string.
    • setProviderUuid

      public void setProviderUuid(String providerUuid)
      Set the uuid sent by a node when it first contacts a resource provider.
      Parameters:
      providerUuid - the uuid as a string.
    • getRequestUuid

      public String getRequestUuid()
      Get the uuid for the original task bundle that triggered this resource request.
      Returns:
      the uuid as a string.
    • setRequestUuid

      public void setRequestUuid(String requestUuid)
      Set the uuid for the original task bundle that triggered this resource request.
      Parameters:
      requestUuid - the uuid as a string.
    • getCallable

      public byte[] getCallable()
      Get the serialized callback to execute code on the client side.
      Returns:
      a byte[] instance.
    • setCallable

      public void setCallable(byte[] callable)
      Set the serialized callback to execute code on the client side.
      Parameters:
      callable - a byte[] instance.
    • getCallableID

      public long getCallableID()
      Get the ID of an eventual remote-computed callable.
      Returns:
      the id as a long.
    • getData

      public Object getData(ResourceIdentifier key)
      Get the metadata corresponding to the specified key.
      Parameters:
      key - the string identifying the metadata.
      Returns:
      an object value or null if the metadata could not be found.
    • getData

      public Object getData(ResourceIdentifier key, Object def)
      Get the metadata corresponding to the specified key.
      Parameters:
      key - the string identifying the metadata.
      def - a default value to return if the key is not found.
      Returns:
      an object value or the specified default if the metadata could not be found.
    • setData

      public void setData(ResourceIdentifier key, Object value)
      Get the metadata corresponding to the specified key.
      Parameters:
      key - the string identifying the metadata.
      value - the value of the metadata.
    • getResources

      public JPPFResourceWrapper[] getResources()
      Get the array of requests held by this request. For simple request returns arrays containing this.
      Returns:
      a array of JPPFResourceWrapper instances.
    • getMonitor

      protected Object getMonitor()
      Get the monitor used for synchronized access to data.
      Returns:
      a Object instance.
    • 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
    • hasAny

      public boolean hasAny(ResourceIdentifier... ids)
      Determine whether this resource has any of the specified data.
      Parameters:
      ids - the ids of the data to check.
      Returns:
      true if this resource has any of the specified data, false otherwise.
    • isSingleResource

      public boolean isSingleResource()
      Determine whether this is a request for a single resource definition.
      Returns:
      true if this is a request for a single resource definition, false otherwise.
    • getResourceId

      public long getResourceId(String uuid)
      Parameters:
      uuid - the uuid of the driver for which to get a resource id.
      Returns:
      the unique identifier this resource request in the server.
    • setResourceId

      public void setResourceId(String uuid, long resourceId)
      Set the unique identifier for this resource request in the specified driver.
      Parameters:
      uuid - the uuid of the driver for which to set a resource id.
      resourceId - the identifier as a long.
    • getResourceIds

      public Map<String,Long> getResourceIds()
      Returns:
      the map of driver uuids to resource id.
    • setResourceIds

      public void setResourceIds(Map<String,Long> resourceIds)
      Parameters:
      resourceIds - the map of driver uuids to resource id.
    • getRequestStartTime

      public long getRequestStartTime()
      Returns:
      the time at which the request is received by the server.
    • setRequestStartTime

      public void setRequestStartTime(long requestStartTime)
      Parameters:
      requestStartTime - the time at which the request is received by the server.
    • isHandshaking

      public boolean isHandshaking()
      Returns:
      whether this is a handshake request.
    • setHandshaking

      public void setHandshaking(boolean handshaking)
      Parameters:
      handshaking - whether this is a handshake request.