Lightweight Bartering Grid

lbg.resource.service
Class LiveResourceService

java.lang.Object
  extended by lbg.resource.service.LiveResourceService
All Implemented Interfaces:
AbstractResourceHandle, ResourceService

public class LiveResourceService
extends java.lang.Object
implements ResourceService

Live implementation of the Resource service, handling requests to a given Resource.

Author:
Xavier Dalem, Cyril Briquet

Constructor Summary
protected LiveResourceService(LiveResource owner_resource)
          Create a service for a resource.
 
Method Summary
 int cacheCapacity()
           
 void cancelTask()
          Cancel the currently running task
 ResourceHandle createHandle()
          Get a handle to the owner resource
 void delete_me_runTask(Task t)
          Deprecated.  
 long expectedTaskRuntime()
          How much time should running this task take ?
 java.lang.String id()
           
 boolean idle()
          Get the state of the resource
 boolean isAlive()
          Gets the Resource status
 Task runningTask()
          Deprecated.  
 boolean runTask(Task t, GridData[][] working_set)
           
 boolean setWorkingSet(GridData[][] working_set)
           
 long taskStartTime()
          Returns the Task start time in seconds
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiveResourceService

protected LiveResourceService(LiveResource owner_resource)
                       throws GridException
Create a service for a resource.

Parameters:
owner_resource - The resource concerned by this service
Throws:
GridException
Method Detail

toString

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

createHandle

public ResourceHandle createHandle()
                            throws GridException
Get a handle to the owner resource

Specified by:
createHandle in interface ResourceService
Throws:
GridException

id

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

cacheCapacity

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

setWorkingSet

public boolean setWorkingSet(GridData[][] working_set)
                      throws GridException
Specified by:
setWorkingSet in interface AbstractResourceHandle
Returns:
true if the data described by the working set can be stored in the Resource data cache, or false if the working set size is larger than the cache limit, or if the data couldn't be scheduled for download
Throws:
GridException

runTask

public boolean runTask(Task t,
                       GridData[][] working_set)
                throws GridException
Specified by:
runTask in interface AbstractResourceHandle
Returns:
true if the data described by the working set can be stored in the Resource data cache, or false if the working set size is larger than the cache limit, or if the data couldn't be scheduled for download
Throws:
GridException

idle

public boolean idle()
Get the state of the resource

Specified by:
idle in interface AbstractResourceHandle
Returns:
true if the resource is idle

isAlive

public boolean isAlive()
Gets the Resource status

Specified by:
isAlive in interface AbstractResourceHandle
Returns:
true (this method is only there for networking needs)

runningTask

@Deprecated
public Task runningTask()
Deprecated. 

Get the task currently run by the resource

Specified by:
runningTask in interface AbstractResourceHandle

delete_me_runTask

@Deprecated
public void delete_me_runTask(Task t)
                       throws GridException
Deprecated. 

Ask the resource to run a task

Parameters:
t - The task to run
Throws:
GridException
To do:

cancelTask

public void cancelTask()
                throws GridException
Cancel the currently running task

Specified by:
cancelTask in interface AbstractResourceHandle
Throws:
GridException

expectedTaskRuntime

public long expectedTaskRuntime()
                         throws GridException
How much time should running this task take ?

Throws:
GridException

taskStartTime

public long taskStartTime()
Returns the Task start time in seconds

Specified by:
taskStartTime in interface AbstractResourceHandle

Lightweight Bartering Grid

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