edu.jhu.cnds.Frugal
Class FrugalResourceImpl

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--edu.jhu.cnds.Frugal.FrugalResourceImpl

public class FrugalResourceImpl
extends java.rmi.server.UnicastRemoteObject
implements FrugalResourceRemote, java.lang.Runnable

Concrete implementation of a Frugal Resource, capable of performing work for the caller.

Version:
2.0
Author:
R. Sean Borgstrom
See Also:
Serialized Form

Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
FrugalResourceImpl()
          This constructor performs no actions at this time.
FrugalResourceImpl(FrugalResourceServer backend)
          Constructs a new implementation of the Frugal Resource interface.
 
Method Summary
 long currentFreeMemory()
          Provides information used to calculate the cost to use this resource.
 long currentSpeed()
          Provides information used to calculate the cost to use this resource.
 long currentUsedMemory()
          Provides information used to calculate the cost to use this resource.
 void exit()
          Exits the VM.
 java.lang.Object getAdmin()
          Returns an administrative interface for this Frugal Resource.
 double globalMaxLoad()
          Provides information to the CostBean.
 long globalMaxSpeed()
          Provides information to the CostBean.
 void inform(long machines, double globalMax, long globalMaxSpeed)
          Receives information on global state.
 long machineCount()
          Provides information to the CostBean.
 double maxLoad()
          Provides information used to calculate the cost to use this resource.
 long maxSpeed()
          Provides information used to calculate the cost to use this resource.
 long minSpeed()
          Provides information used to calculate the cost to use this resource.
 void run()
          Creates a load tester implementation, which will test the speed of the system where this Frugal Resource is executing, performing calculations for 1 second in every 30.
 java.lang.Object[] run(Projectable submittedClass, java.lang.Object[] argv)
          Performs work for a remote class.
 void startTesting()
          Spawns a thread that tests the speed of the system where this Frugal Resource is executing, performing calculations for 1 second in every 30.
 long totalMemory()
          Provides information used to calculate the cost to use this resource.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrugalResourceImpl

public FrugalResourceImpl()
                   throws java.rmi.RemoteException
This constructor performs no actions at this time.

FrugalResourceImpl

public FrugalResourceImpl(FrugalResourceServer backend)
                   throws java.rmi.RemoteException
Constructs a new implementation of the Frugal Resource interface.
Parameters:
backend - The server that advertises this implementation on the various lookup groups.
Method Detail

run

public java.lang.Object[] run(Projectable submittedClass,
                              java.lang.Object[] argv)
                       throws java.rmi.RemoteException
Performs work for a remote class.
Parameters:
submittedClass - A class containing the code for the work it should do. The Frugal Resource will invoke its 'main' method with the given arguments.
argv - Arguments to that class.
Returns:
The array of Objects returned by that class' 'main' method.

exit

public void exit()
          throws java.rmi.RemoteException
Exits the VM.

inform

public void inform(long machines,
                   double globalMax,
                   long globalMaxSpeed)
Receives information on global state.
Parameters:
machines - The number of Frugal Resources in the system.
globalMax - The highest load seen, globally, rounded to the next highest integral power of 2.
globalMaxSpeed - The highest speed seen, globally.

machineCount

public long machineCount()
                  throws java.rmi.RemoteException
Provides information to the CostBean.
Returns:
The number of Frugal Resources this Frugal Resource believes are currently available on the computing cluster.

globalMaxLoad

public double globalMaxLoad()
                     throws java.rmi.RemoteException
Provides information to the CostBean.
Returns:
A number this Frugal Resource thinks is the highest load seen on the system, rounded to the next highest integral power of 2.

globalMaxSpeed

public long globalMaxSpeed()
                    throws java.rmi.RemoteException
Provides information to the CostBean.
Returns:
The highest computational speed achieved by a Frugal Resource this Frugal Resource believes is currently available on the computing cluster.

totalMemory

public long totalMemory()
                 throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
Total memory assigned to the virtual machine where this Frugal Resource runs.

currentFreeMemory

public long currentFreeMemory()
                       throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
Currently free memory on the virtual machine where this Frugal Resource runs.

currentUsedMemory

public long currentUsedMemory()
                       throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
Currently used memory on the virtual machine where this Frugal Resource runs.

currentSpeed

public long currentSpeed()
                  throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
The speed of the machine where this Frugal Resource runs, under the load conditions where its speed was last tested, using an abstract measure based on the number of calculations of a specific type performed per second.

maxSpeed

public long maxSpeed()
              throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
The highest machine speed ever seen by this Frugal Resource, using the abstract measure described above.

minSpeed

public long minSpeed()
              throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
The lowest machine speed ever seen by this Frugal Resource, using the abstract measure described above.

maxLoad

public double maxLoad()
               throws java.rmi.RemoteException
Provides information used to calculate the cost to use this resource.
Returns:
The highest load ever seen by this Frugal Resource, defined as the highest speed ever seen divided by the lowest speed ever seen.

startTesting

public void startTesting()
                  throws java.rmi.RemoteException
Spawns a thread that tests the speed of the system where this Frugal Resource is executing, performing calculations for 1 second in every 30. (See 'run()')

run

public void run()
Creates a load tester implementation, which will test the speed of the system where this Frugal Resource is executing, performing calculations for 1 second in every 30.
Specified by:
run in interface java.lang.Runnable

getAdmin

public java.lang.Object getAdmin()
                          throws java.rmi.RemoteException
Returns an administrative interface for this Frugal Resource.
Returns:
An object implementing DestroyAdmin, Entry, JoinAdmin, and StorageLocationAdmin