Lightweight Bartering Grid

lbg.peer.core.rms
Class WorkingSet

java.lang.Object
  extended by lbg.peer.core.rms.WorkingSet

public class WorkingSet
extends java.lang.Object

Resource Working Set.

It is guarantueed that the Working Set always contains and locks the input data of running Tasks.

It is guarantueed that the Working Set size is never larger than the cache size of the Resource that is managed.

When a data id is added to, or cleared from, the WorkingSet, the ResourceManager ResourceDataTracker is updated.

Author:
Cyril Briquet

Constructor Summary
WorkingSet(Peer managed_peer, ResourceHandle rh, ResourceDataTracker data_tracker)
          Constructs a new WorkingSet.
 
Method Summary
 boolean addLocalData(MetaGridData data)
          Note: the Resource-level DataTracker is updated by this operation
 boolean addLocalData(MetaGridData[] ds)
          Note: the Resource-level DataTracker is updated by this operation
 boolean addSupplyingData(MetaGridData data)
          Note: the Resource-level DataTracker is updated by this operation
 boolean addSupplyingData(MetaGridData[] ds)
          Note: the Resource-level DataTracker is updated by this operation
 int availableCapacity()
          Returns the nominal data storage available capacity (i.e.
 void clearAddAndLockLocalInputData(Task t)
          Clears WorkingSet, then add-and-lock target Local data.
 void clearAddAndLockSupplyingInputData(Task t)
          Clears WorkingSet, then add-and-lock target Supplying data.
 void clearAllUnlockedData()
          Note: the Resource-level DataTracker is updated by this operation
 void clearLocalUnlockedData()
          Note: the Resource-level DataTracker is updated by this operation
 void clearSupplyingUnlockedData()
          Note: the Resource-level DataTracker is updated by this operation
 boolean containsData(MetaGridData data)
           
 boolean containsLocalData(MetaGridData data)
           
 boolean containsSupplyingData(MetaGridData data)
           
 GridData[][] getData()
          Returns the GridData stored in the WorkingSet, so as to communicate them to the managed Resource.
 java.lang.String[] getDataId()
           
 GridData[][] getLocalData()
           
 java.lang.String[] getLocalDataId()
           
 MetaGridData[] getLocalGridMetaData()
           
 MetaGridData[] getMetaGridData()
           
 GridData[][] getSupplyingData()
           
 java.lang.String[] getSupplyingDataId()
           
 MetaGridData[] getSupplyingMetaGridData()
           
 int localSize()
          Returns the number of stored Local data.
 int lockedSize()
          Returns the number of locked data (whether Local or Supplying).
 ResourceHandle managedResource()
          Managed Resource Handle.
 int nominalCapacity()
          Returns the nominal data storage nominal capacity.
 int size()
          Returns the number of all stored data.
 int supplyingSize()
          Returns the number of stored Supplying data.
 java.lang.String toString()
           
 void unlockLocalInputData(Task t)
           
 void unlockSupplyingInputData(Task t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WorkingSet

public WorkingSet(Peer managed_peer,
                  ResourceHandle rh,
                  ResourceDataTracker data_tracker)
           throws GridException
Constructs a new WorkingSet.

Parameters:
managed_peer - managed Peer
rh - managed Resource Handle
data_tracker - managed Peer Data Tracker
Throws:
GridException - if a parameter is illegal
Method Detail

toString

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

managedResource

public ResourceHandle managedResource()
Managed Resource Handle.


nominalCapacity

public int nominalCapacity()
Returns the nominal data storage nominal capacity.


size

public int size()
Returns the number of all stored data.


localSize

public int localSize()
Returns the number of stored Local data.


supplyingSize

public int supplyingSize()
Returns the number of stored Supplying data.


lockedSize

public int lockedSize()
Returns the number of locked data (whether Local or Supplying).


availableCapacity

public int availableCapacity()
Returns the nominal data storage available capacity (i.e. ws.capacity() - ws.lockedSize()).


containsData

public boolean containsData(MetaGridData data)
                     throws GridException
Throws:
GridException

containsLocalData

public boolean containsLocalData(MetaGridData data)
                          throws GridException
Throws:
GridException

containsSupplyingData

public boolean containsSupplyingData(MetaGridData data)
                              throws GridException
Throws:
GridException

getDataId

public java.lang.String[] getDataId()
                             throws GridException
Throws:
GridException

getLocalDataId

public java.lang.String[] getLocalDataId()
                                  throws GridException
Throws:
GridException

getSupplyingDataId

public java.lang.String[] getSupplyingDataId()
                                      throws GridException
Throws:
GridException

getData

public GridData[][] getData()
                     throws GridException
Returns the GridData stored in the WorkingSet, so as to communicate them to the managed Resource.

Throws:
GridException

getLocalData

public GridData[][] getLocalData()
                          throws GridException
Throws:
GridException

getSupplyingData

public GridData[][] getSupplyingData()
                              throws GridException
Throws:
GridException

getMetaGridData

public MetaGridData[] getMetaGridData()
                               throws GridException
Throws:
GridException

getLocalGridMetaData

public MetaGridData[] getLocalGridMetaData()
                                    throws GridException
Throws:
GridException

getSupplyingMetaGridData

public MetaGridData[] getSupplyingMetaGridData()
                                        throws GridException
Throws:
GridException

clearAllUnlockedData

public void clearAllUnlockedData()
                          throws GridException

Note: the Resource-level DataTracker is updated by this operation

Throws:
GridException

clearLocalUnlockedData

public void clearLocalUnlockedData()
                            throws GridException

Note: the Resource-level DataTracker is updated by this operation

Throws:
GridException

clearSupplyingUnlockedData

public void clearSupplyingUnlockedData()
                                throws GridException

Note: the Resource-level DataTracker is updated by this operation

Throws:
GridException

clearAddAndLockLocalInputData

public void clearAddAndLockLocalInputData(Task t)
                                   throws GridException
Clears WorkingSet, then add-and-lock target Local data.

Throws:
GridException

clearAddAndLockSupplyingInputData

public void clearAddAndLockSupplyingInputData(Task t)
                                       throws GridException
Clears WorkingSet, then add-and-lock target Supplying data.

Throws:
GridException

unlockLocalInputData

public void unlockLocalInputData(Task t)
                          throws GridException
Throws:
GridException

unlockSupplyingInputData

public void unlockSupplyingInputData(Task t)
                              throws GridException
Throws:
GridException

addLocalData

public boolean addLocalData(MetaGridData data)
                     throws GridException

Note: the Resource-level DataTracker is updated by this operation

Returns:
true if target data_id was not already in the working set
Throws:
GridException

addSupplyingData

public boolean addSupplyingData(MetaGridData data)
                         throws GridException

Note: the Resource-level DataTracker is updated by this operation

Returns:
true if target data_id was not already in the working set
Throws:
GridException

addLocalData

public boolean addLocalData(MetaGridData[] ds)
                     throws GridException

Note: the Resource-level DataTracker is updated by this operation

Returns:
true if no target data_id was already in the working set
Throws:
GridException

addSupplyingData

public boolean addSupplyingData(MetaGridData[] ds)
                         throws GridException

Note: the Resource-level DataTracker is updated by this operation

Returns:
true if no target data_id was already in the working set
Throws:
GridException

Lightweight Bartering Grid

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