Lightweight Bartering Grid

lbg.peer.core.rms
Class ResourceDataTracker

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

public class ResourceDataTracker
extends java.lang.Object

A ResourceDataTracker tracks the (Local and Supplying) data stored on all Resources of the Peer.

The tracked data are those sent in a WorkingSet to a Resource. To each data id is associated the set of Resources where the data has been sent.

The tracked data can be searched to locate Resources following various criteria using the Storage Affinity metric. Of particular interest is the locateIdleResourceWithBestStorageAffinity() method.

Author:
Cyril Briquet

Nested Class Summary
static class ResourceDataTracker.TransferCostData
          Helper class of Data Tracker.
 
Constructor Summary
ResourceDataTracker(Peer managed_peer)
          Constructs a new ResourceDataTracker.
 
Method Summary
 java.util.Set<ResourceDataTracker.TransferCostData> locateIdleResourcesWithStorageAffinity(Task t)
          Deprecated.  
 ResourceHandle locateIdleResourceWithBestStorageAffinity(Task t)
          Locate best (Storage Affinity-wise) Resource which has a mximum of data required by target Task in her WorkingSet.
 java.lang.String locateLessLocallyReplicatedData(java.lang.String[] data_ids)
          Locate data in target data set that is the less replicated on this Peer Resources.
 java.lang.String locateMostLocallyReplicatedData(java.lang.String[] data_ids)
          Locate data in target data set that is the most replicated on this Peer Resources.
 java.util.Set<ResourceHandle> locateResourcesWithReplicatedData(java.lang.String data_id)
          Locate Resources which have target data in their WorkingSet.
 java.util.Set<ResourceHandle> locateResourcesWithReplicatedData(java.lang.String[] data_ids)
          Locate Resources which have all target datas in their WorkingSet.
 java.lang.String toString()
           
 boolean trackData(java.lang.String data_id, ResourceHandle rh)
           
 void untrackAllData(java.lang.String[] data_ids, ResourceHandle rh)
          Untrack all data for target Resource.
 void untrackData(java.lang.String[] data_ids, ResourceHandle rh)
           
 void untrackData(java.lang.String data_id, ResourceHandle rh)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourceDataTracker

public ResourceDataTracker(Peer managed_peer)
                    throws GridException
Constructs a new ResourceDataTracker.

Throws:
GridException
Method Detail

toString

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

trackData

public boolean trackData(java.lang.String data_id,
                         ResourceHandle rh)
                  throws GridException
Returns:
true if target data was not already tracked on target Resource
Throws:
GridException

untrackData

public void untrackData(java.lang.String data_id,
                        ResourceHandle rh)
                 throws GridException
Throws:
GridException

untrackData

public void untrackData(java.lang.String[] data_ids,
                        ResourceHandle rh)
                 throws GridException
Throws:
GridException

untrackAllData

public void untrackAllData(java.lang.String[] data_ids,
                           ResourceHandle rh)
                    throws GridException
Untrack all data for target Resource. Checks if target data includes all data tracked for target Resource.

Throws:
GridException

locateResourcesWithReplicatedData

public java.util.Set<ResourceHandle> locateResourcesWithReplicatedData(java.lang.String data_id)
                                                                throws GridException
Locate Resources which have target data in their WorkingSet.

Returns:
null if no Resource has target data in her WorkingSet
Throws:
GridException

locateResourcesWithReplicatedData

public java.util.Set<ResourceHandle> locateResourcesWithReplicatedData(java.lang.String[] data_ids)
                                                                throws GridException
Locate Resources which have all target datas in their WorkingSet.

Returns:
null if no Resource has all target datas in her WorkingSet
Throws:
GridException

locateIdleResourcesWithStorageAffinity

@Deprecated
public java.util.Set<ResourceDataTracker.TransferCostData> locateIdleResourcesWithStorageAffinity(Task t)
                                                                                           throws GridException
Deprecated. 

Locate Resources which have some data of target Task in their WorkingSet.

Returns:
null if no idle Resource has any target data in her WorkingSet
Throws:
GridException

locateIdleResourceWithBestStorageAffinity

public ResourceHandle locateIdleResourceWithBestStorageAffinity(Task t)
                                                         throws GridException
Locate best (Storage Affinity-wise) Resource which has a mximum of data required by target Task in her WorkingSet.

If there are several such Resources, the one with the largest number of unused cache slots (i.e. free space) is selected.

Returns:
null if no idle Resource has any target data in her WorkingSet
Throws:
GridException

locateMostLocallyReplicatedData

public java.lang.String locateMostLocallyReplicatedData(java.lang.String[] data_ids)
                                                 throws GridException
Locate data in target data set that is the most replicated on this Peer Resources.

Throws:
GridException

locateLessLocallyReplicatedData

public java.lang.String locateLessLocallyReplicatedData(java.lang.String[] data_ids)
                                                 throws GridException
Locate data in target data set that is the less replicated on this Peer Resources.

Throws:
GridException

Lightweight Bartering Grid

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