Lightweight Bartering Grid

lbg.peer.register.negotiation
Class ConsumptionGrantsContainer

java.lang.Object
  extended by lbg.peer.register.negotiation.ConsumptionGrantsContainer

public class ConsumptionGrantsContainer
extends java.lang.Object

A ConsumptionGrantsContainer contains received Consumption grants that have been received since the received Consumption grants were last processed.

Author:
Cyril Briquet

Constructor Summary
ConsumptionGrantsContainer(java.util.Collection<PeerProfile> cgs, int s)
           
 
Method Summary
 ExternalPeerHandle grantor(int i)
           
 PeerProfile grantorProfile(int i)
           
 PeerProfile[] grantors()
           
 int initialConsumptionGrants(int i)
           
 int pendingConsumptionGrants()
           
 int pendingConsumptionGrants(int i)
           
 java.lang.Integer pendingGrantorIndex(PeerProfile peer_profile)
          Returns the index of target pending grantor.
 java.lang.Integer pendingGrantorIndex(java.lang.String peer_id)
          Returns the index of target pending grantor.
 java.util.Collection<java.lang.String> pendingGrantors()
          Returns the id set of pending grantors.
 int pendingGrantorsCount()
          Returns the number of pending grantors.
 java.util.Collection<java.lang.Integer> pendingGrantorsIndex()
          Returns the index of pending grantors.
 java.util.Iterator<java.lang.Integer> pendingGrantorsIndexIterator()
          Returns an Iterator of the index of pending grantors.
 int randomPendingGrantorIndex()
           
 int size()
           
 void spillAllConsumptionGrants(int i)
          Spills, i.e.
 void spillConsumptionGrants(int i, int count)
          Spills, i.e.
 java.lang.String toString()
           
 int totalConsumptionGrants()
           
 void useAllConsumptionGrants(int i)
          Uses all Consumption Grants from target grantor.
 void useConsumptionGrants(int i, int count)
          Uses some Consumption Grants from target grantor.
 int usedConsumptionGrants()
           
 int usedConsumptionGrants(int i)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsumptionGrantsContainer

public ConsumptionGrantsContainer(java.util.Collection<PeerProfile> cgs,
                                  int s)
                           throws GridException
Throws:
GridException
Method Detail

toString

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

size

public int size()

grantors

public PeerProfile[] grantors()

grantorProfile

public PeerProfile grantorProfile(int i)
                           throws GridException
Throws:
GridException

grantor

public ExternalPeerHandle grantor(int i)
                           throws GridException
Throws:
GridException

pendingGrantors

public java.util.Collection<java.lang.String> pendingGrantors()
Returns the id set of pending grantors.

Returns:
pending grantors id set

pendingGrantorsCount

public int pendingGrantorsCount()
Returns the number of pending grantors.

Returns:
pending grantors count

pendingGrantorsIndexIterator

public java.util.Iterator<java.lang.Integer> pendingGrantorsIndexIterator()
Returns an Iterator of the index of pending grantors.

Returns:
pending grantors index Iterator

pendingGrantorsIndex

public java.util.Collection<java.lang.Integer> pendingGrantorsIndex()
Returns the index of pending grantors.

Returns:
pending grantors index

pendingGrantorIndex

public java.lang.Integer pendingGrantorIndex(PeerProfile peer_profile)
                                      throws GridException
Returns the index of target pending grantor.

Parameters:
peer_profile - target pending grantor profile
Returns:
pending grantor index
Throws:
GridException - if a parameter is illegal

pendingGrantorIndex

public java.lang.Integer pendingGrantorIndex(java.lang.String peer_id)
                                      throws GridException
Returns the index of target pending grantor.

Parameters:
peer_id - target pending grantor id
Returns:
pending grantor index
Throws:
GridException - if a parameter is illegal

randomPendingGrantorIndex

public int randomPendingGrantorIndex()
                              throws GridException
Returns:
random pending grantor index
Throws:
GridException

initialConsumptionGrants

public int initialConsumptionGrants(int i)
                             throws GridException
Throws:
GridException

pendingConsumptionGrants

public int pendingConsumptionGrants(int i)
                             throws GridException
Throws:
GridException

usedConsumptionGrants

public int usedConsumptionGrants(int i)
                          throws GridException
Throws:
GridException

useAllConsumptionGrants

public void useAllConsumptionGrants(int i)
                             throws GridException
Uses all Consumption Grants from target grantor.

Target grantor is removed from the index of remaining grantors.

Parameters:
i - index of target grantor
Throws:
GridException - if a parameter is illegal

spillAllConsumptionGrants

public void spillAllConsumptionGrants(int i)
                               throws GridException
Spills, i.e. fakes to use, all Consumption Grants from target grantor.

Target grantor is removed from the index of remaining grantors.

Parameters:
i - index of target grantor
Throws:
GridException - if a parameter is illegal

useConsumptionGrants

public void useConsumptionGrants(int i,
                                 int count)
                          throws GridException
Uses some Consumption Grants from target grantor.

If target grantor has no more remaining Consumption Grants, it is removed from the index of remaining grantors.

Parameters:
i - index of target grantor
count - number of used Consumption Grants
Throws:
GridException - if a parameter is illegal

spillConsumptionGrants

public void spillConsumptionGrants(int i,
                                   int count)
                            throws GridException
Spills, i.e. fakes to use, some Consumption Grants from target grantor.

If target grantor has no more remaining Consumption Grants, it is removed from the index of remaining grantors.

Parameters:
i - index of target grantor
count - number of used Consumption Grants
Throws:
GridException - if a parameter is illegal

totalConsumptionGrants

public int totalConsumptionGrants()

pendingConsumptionGrants

public int pendingConsumptionGrants()

usedConsumptionGrants

public int usedConsumptionGrants()

Lightweight Bartering Grid

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