Lightweight Bartering Grid

lbg.user
Class LiveUserAgent

java.lang.Object
  extended by lbg.user.UserAgent
      extended by lbg.user.LiveUserAgent
Direct Known Subclasses:
EmbeddedLiveUserAgent

public class LiveUserAgent
extends UserAgent

UserAgent, Live Implementation.
Related logger: lbg.user

Author:
Xavier Dalem, Cyril Briquet

Constructor Summary
LiveUserAgent(java.lang.String id, java.lang.String host, int port, UserPeerHandle peer, java.lang.String output_dir)
          Creates a Live UserAgent.
LiveUserAgent(java.lang.String id, java.lang.String host, int port, UserPeerHandle peer, java.lang.String output_dir, java.lang.String stats_dir)
          Creates a Live UserAgent.
LiveUserAgent(java.lang.String id, java.lang.String host, int port, UserPeerHandle peer, java.lang.String output_dir, java.lang.String stats_dir, boolean activate_measurement, boolean save_results)
          Creates a Live UserAgent.
 
Method Summary
 long completedJobs()
           
 boolean hasRunningJobs()
           
 java.lang.String host()
          Get user host
 boolean isAlive()
           
 void notifyCompletedJob(Task t)
          Notifies a User that the last Task of a Job has been completed.
 void notifyCompletedTask(Task t)
          Notifies a User that a Task has been completed.
 int port()
          Get user port
 void registerListener(LiveUserAgentListener listen)
          Register this object as a listener.
 UserService service()
           
 void startService()
           
 void startService(boolean set_daemon)
           
 int submitJob(JobDescriptor jd)
          Submits a Job.
 long submittedJobs()
           
 java.lang.String toString()
          String representation of the User.
 void unRegisterListener(LiveUserAgentListener listen)
          Unregister this object as a listener.
 
Methods inherited from class lbg.user.UserAgent
id, usedPeer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiveUserAgent

public LiveUserAgent(java.lang.String id,
                     java.lang.String host,
                     int port,
                     UserPeerHandle peer,
                     java.lang.String output_dir,
                     java.lang.String stats_dir)
              throws GridException
Creates a Live UserAgent.

Measurements are activated by default.

Output data files are saved by default.

Parameters:
id - User ID
host - User host (to contact him from the outside)
port - User port (local)
peer - Parent peer
output_dir - The path of a directory where files will be output. Filenames will be of the form [user_id].[peer_id].job[jobID].bot[botID].task[taskID].dat
stats_dir - The path of a directory where job runtime stats will be saved
Throws:
GridException - if the parameters are erroneous

LiveUserAgent

public LiveUserAgent(java.lang.String id,
                     java.lang.String host,
                     int port,
                     UserPeerHandle peer,
                     java.lang.String output_dir)
              throws GridException
Creates a Live UserAgent.

Measurements are deactivated by default.

Output data files are not saved by default.

Parameters:
id - User ID
host - User host (to contact him from the outside)
port - User port (local)
peer - Parent peer
output_dir - The path of a directory where files will be output. Filenames will be of the form [user_id].[peer_id].job[jobID].bot[botID].task[taskID].dat
Throws:
GridException - if the parameters are erroneous

LiveUserAgent

public LiveUserAgent(java.lang.String id,
                     java.lang.String host,
                     int port,
                     UserPeerHandle peer,
                     java.lang.String output_dir,
                     java.lang.String stats_dir,
                     boolean activate_measurement,
                     boolean save_results)
              throws GridException
Creates a Live UserAgent.

Parameters:
id - User ID
host - User host (to contact him from the outside)
port - User port (local)
peer - Parent peer
output_dir - The path of a directory where files will be output. Filenames will be of the form [user_id].[peer_id].job[jobID].bot[botID].task[taskID].dat
stats_dir - The path of a directory where job runtime stats will be saved
activate_measurement - true if Measurements should be activated
save_results - true to save results to disk
Throws:
GridException - if the parameters are erroneous
Method Detail

toString

public java.lang.String toString()
String representation of the User.

Overrides:
toString in class UserAgent

service

public UserService service()
Specified by:
service in class UserAgent

host

public java.lang.String host()
Get user host


port

public int port()
Get user port


registerListener

public void registerListener(LiveUserAgentListener listen)
Register this object as a listener.

Parameters:
listen - The object that wants to be aware of our actions.

unRegisterListener

public void unRegisterListener(LiveUserAgentListener listen)
Unregister this object as a listener.

Parameters:
listen - The object that doesn't want to be aware of our actions anymore.

notifyCompletedTask

public void notifyCompletedTask(Task t)
                         throws GridException
Notifies a User that a Task has been completed.

Specified by:
notifyCompletedTask in class UserAgent
Parameters:
t - completed Task
Throws:
GridException - if User failed to save output data file

notifyCompletedJob

public void notifyCompletedJob(Task t)
                        throws GridException
Notifies a User that the last Task of a Job has been completed.

Specified by:
notifyCompletedJob in class UserAgent
Parameters:
t - completed Task
Throws:
GridException - if User failed to save output data file

submitJob

public int submitJob(JobDescriptor jd)
              throws GridException
Submits a Job.

Specified by:
submitJob in class UserAgent
Parameters:
jd - descriptor of the Job to submit
Returns:
submitted job id
Throws:
GridException - if a Job with the same id has already been sent

submittedJobs

public long submittedJobs()
Specified by:
submittedJobs in class UserAgent

completedJobs

public long completedJobs()
Specified by:
completedJobs in class UserAgent

hasRunningJobs

public boolean hasRunningJobs()
Specified by:
hasRunningJobs in class UserAgent

isAlive

public boolean isAlive()

startService

public void startService()
                  throws GridException
Throws:
GridException

startService

public void startService(boolean set_daemon)
                  throws GridException
Throws:
GridException

Lightweight Bartering Grid

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