Lightweight Bartering Grid

lbg.peer.service
Class TestPeerHandle

java.lang.Object
  extended by lbg.peer.service.TestPeerHandle
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<PeerHandle>, AbstractExternalPeerHandle, AbstractInternalPeerHandle, AbstractUserPeerHandle, ExternalPeerHandle, InternalPeerHandle, PeerHandle, UserPeerHandle

public class TestPeerHandle
extends java.lang.Object
implements ExternalPeerHandle, InternalPeerHandle, UserPeerHandle

Implementation of PeerHandles for testing purposes only.

Author:
Cyril Briquet
See Also:
Serialized Form

Constructor Summary
TestPeerHandle(java.lang.String id)
           
 
Method Summary
 void addResource(ResourceHandle rh, int power)
           
 void cancelJob(int job_id)
           
 void cancelLocalTaskOnSupplyingResource(java.lang.String supplier_id, Task t)
           
 void cancelSupplyingTaskOnLocalResource(java.lang.String consumer_id, Task t)
           
 int compareTo(PeerHandle other)
           
 ConsumptionTaskID computeSupplyingTask(java.lang.String consumer_id, Task t)
           
 boolean equals(java.lang.Object obj)
           
 void grantConsumption(java.lang.String supplier_id, int granted_count)
           
 int hashCode()
           
 java.lang.String hostname()
           
 java.lang.String id()
           
 boolean isAlive()
           
 int peerPort()
           
 void preemptLocalTaskOnLocalResource(Task t, byte[] logs)
           
 void preemptSupplyingTaskOnLocalResource(java.lang.String consumer_id, Task t, byte[] logs)
           
 int queryJobStatus(int job_id)
           
 void removeResource(ResourceHandle rh)
           
 void requestSupplying(java.lang.String consumer_id, int tasks_count)
           
 int resourcePort()
           
 int submitJob(UserHandle uh, JobDescriptor jd)
           
 java.lang.String toString()
           
 void uploadBySupplyingCompletedTask(java.lang.String supplier_id, Task t)
           
 void uploadLocallyCompletedTask(Task t)
           
 int userPort()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TestPeerHandle

public TestPeerHandle(java.lang.String id)
               throws GridException
Parameters:
id - Peer id
Throws:
GridException
Method Detail

toString

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

compareTo

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

equals

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

hashCode

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

id

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

hostname

public java.lang.String hostname()
Specified by:
hostname in interface PeerHandle

peerPort

public int peerPort()
Specified by:
peerPort in interface AbstractExternalPeerHandle

requestSupplying

public void requestSupplying(java.lang.String consumer_id,
                             int tasks_count)
                      throws GridException
Specified by:
requestSupplying in interface AbstractExternalPeerHandle
Throws:
GridException

grantConsumption

public void grantConsumption(java.lang.String supplier_id,
                             int granted_count)
                      throws GridException
Specified by:
grantConsumption in interface AbstractExternalPeerHandle
Throws:
GridException

computeSupplyingTask

public ConsumptionTaskID computeSupplyingTask(java.lang.String consumer_id,
                                              Task t)
                                       throws GridException
Specified by:
computeSupplyingTask in interface AbstractExternalPeerHandle
Throws:
GridException

cancelSupplyingTaskOnLocalResource

public void cancelSupplyingTaskOnLocalResource(java.lang.String consumer_id,
                                               Task t)
                                        throws GridException
Specified by:
cancelSupplyingTaskOnLocalResource in interface AbstractExternalPeerHandle
Throws:
GridException

cancelLocalTaskOnSupplyingResource

public void cancelLocalTaskOnSupplyingResource(java.lang.String supplier_id,
                                               Task t)
                                        throws GridException
Specified by:
cancelLocalTaskOnSupplyingResource in interface AbstractExternalPeerHandle
Throws:
GridException

uploadBySupplyingCompletedTask

public void uploadBySupplyingCompletedTask(java.lang.String supplier_id,
                                           Task t)
                                    throws GridException
Specified by:
uploadBySupplyingCompletedTask in interface AbstractExternalPeerHandle
Throws:
GridException

isAlive

public boolean isAlive()
Specified by:
isAlive in interface AbstractExternalPeerHandle

resourcePort

public int resourcePort()
Specified by:
resourcePort in interface AbstractInternalPeerHandle

addResource

public void addResource(ResourceHandle rh,
                        int power)
                 throws GridException
Specified by:
addResource in interface AbstractInternalPeerHandle
Throws:
GridException

removeResource

public void removeResource(ResourceHandle rh)
                    throws GridException
Specified by:
removeResource in interface AbstractInternalPeerHandle
Throws:
GridException

preemptLocalTaskOnLocalResource

public void preemptLocalTaskOnLocalResource(Task t,
                                            byte[] logs)
                                     throws GridException
Specified by:
preemptLocalTaskOnLocalResource in interface AbstractInternalPeerHandle
Throws:
GridException

preemptSupplyingTaskOnLocalResource

public void preemptSupplyingTaskOnLocalResource(java.lang.String consumer_id,
                                                Task t,
                                                byte[] logs)
                                         throws GridException
Specified by:
preemptSupplyingTaskOnLocalResource in interface AbstractInternalPeerHandle
Throws:
GridException

uploadLocallyCompletedTask

public void uploadLocallyCompletedTask(Task t)
                                throws GridException
Specified by:
uploadLocallyCompletedTask in interface AbstractInternalPeerHandle
Throws:
GridException

userPort

public int userPort()
Specified by:
userPort in interface AbstractUserPeerHandle

submitJob

public int submitJob(UserHandle uh,
                     JobDescriptor jd)
              throws GridException
Specified by:
submitJob in interface AbstractUserPeerHandle
Throws:
GridException

cancelJob

public void cancelJob(int job_id)
               throws GridException
Specified by:
cancelJob in interface AbstractUserPeerHandle
Throws:
GridException

queryJobStatus

public int queryJobStatus(int job_id)
                   throws GridException
Specified by:
queryJobStatus in interface AbstractUserPeerHandle
Throws:
GridException

Lightweight Bartering Grid

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