Lightweight Bartering Grid

lbg.resource.service
Class LiveResourceHandle

java.lang.Object
  extended by lbg.resource.service.LiveResourceHandle
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<ResourceHandle>, AbstractResourceHandle, ResourceHandle

public class LiveResourceHandle
extends java.lang.Object
implements ResourceHandle

A handle to a resource.

Author:
Xavier Dalem
See Also:
Serialized Form

Constructor Summary
LiveResourceHandle(java.lang.String id, int cache_capacity, java.lang.String res_host, int res_port)
          Create a handle to contact a LiveResource
 
Method Summary
 int cacheCapacity()
           
 void cancelTask()
          Ask a Resource to cancel running Task
 int compareTo(ResourceHandle other)
           
 void delete_me_runTask(Task t)
          Deprecated. Specify new Working Set when running a task.
 boolean equals(java.lang.Object obj)
           
 long expectedTaskRuntime()
          Ask a Resource to give expected Task runtime
 int hashCode()
           
 java.lang.String id()
           
 boolean idle()
          Checks if a resource if idle.
 boolean isAlive()
          Gets a resource's network state.
 Task runningTask()
          Deprecated.  
 boolean runTask(Task t, GridData[][] working_set)
          Sets a resource's working set then runs a task.
 boolean setWorkingSet(GridData[][] working_set)
          Sets a resource's working set This call is non-blocking (only verification of the validity of the WS is done before returning: data is not yet downloaded).
 long taskStartTime()
          Ask a Resource when the running Task has started
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiveResourceHandle

public LiveResourceHandle(java.lang.String id,
                          int cache_capacity,
                          java.lang.String res_host,
                          int res_port)
                   throws GridException
Create a handle to contact a LiveResource

Parameters:
id - The resource ID
cache_capacity -
res_host - A way to contact the resource
res_port - The port on which the resource listens
Throws:
GridException
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(ResourceHandle other)
Specified by:
compareTo in interface java.lang.Comparable<ResourceHandle>

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

id

public java.lang.String id()
Specified by:
id in interface AbstractResourceHandle

cacheCapacity

public int cacheCapacity()
Specified by:
cacheCapacity in interface AbstractResourceHandle

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

setWorkingSet

public boolean setWorkingSet(GridData[][] working_set)
                      throws GridException
Sets a resource's working set This call is non-blocking (only verification of the validity of the WS is done before returning: data is not yet downloaded).

Specified by:
setWorkingSet in interface AbstractResourceHandle
Returns:
true if setting the Working Set succeeded.
Throws:
GridException
See Also:
Concept of a Working Set

idle

public boolean idle()
Checks if a resource if idle.
If the Resource cannot be contacted, it is considered to be idle, so that removing it can be done without any further step

Specified by:
idle in interface AbstractResourceHandle
Returns:
the state of the Resource

isAlive

public boolean isAlive()
Gets a resource's network state.

Specified by:
isAlive in interface AbstractResourceHandle
Returns:
true if the resource could be reached and answered correctly

runningTask

@Deprecated
public Task runningTask()
Deprecated. 

Get the running Task of a Resource.

Specified by:
runningTask in interface AbstractResourceHandle
Returns:
the Task, or null if the Resource cannot be contacted

delete_me_runTask

@Deprecated
public void delete_me_runTask(Task t)
                       throws GridException
Deprecated. Specify new Working Set when running a task.

Ask a Resource to run a Task

Throws:
GridException
See Also:
runTask(Task, GridData[][])
To do:

runTask

public boolean runTask(Task t,
                       GridData[][] working_set)
                throws GridException
Sets a resource's working set then runs a task. This call is non-blocking (only verification of the validity of the WS is done before returning: data is not yet downloaded).

Specified by:
runTask in interface AbstractResourceHandle
Returns:
true if setting the Working Set succeeded.
Throws:
GridException
See Also:
Concept of a Working Set

cancelTask

public void cancelTask()
                throws GridException
Ask a Resource to cancel running Task

Specified by:
cancelTask in interface AbstractResourceHandle
Throws:
GridException

expectedTaskRuntime

public long expectedTaskRuntime()
                         throws GridException
Ask a Resource to give expected Task runtime

Throws:
GridException - in case of communication error

taskStartTime

public long taskStartTime()
Ask a Resource when the running Task has started

Specified by:
taskStartTime in interface AbstractResourceHandle
Returns:
the time, or -1 if the Resource cannot be contacted

Lightweight Bartering Grid

Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.