core_lib
Class User

java.lang.Object
  extended by core_lib.User

public class User
extends java.lang.Object

The User class encapsulates a single user/peer/node in a Network. In addition to describing behavioral properties, this class also manages bandwidth, and tracks prior interactions with other Users.


Nested Class Summary
static class User.Behavior
          The Behavior enumeration details the initialization models to which a User's behavior may conform.
 
Field Summary
private  BWidthUnit dl_bwidth
          Manager for download bandwidth.
private  User.Behavior model
          The Behavior model to which this User conforms.
private  int num_files
          The number of files owned by this User.
private  double pct_cleanup
          The probability this User will clean up an invalid file.
private  double pct_honest
          The probability this User will provide honest feedback.
private  boolean pre_trusted
          Whether or not the user is pre-trusted
private  BWidthUnit ul_bwidth
          Manager for upload bandwidth.
private  Relation[] vector
          Array storing Relations (reputations) of other User's in Network
 
Constructor Summary
User(User.Behavior model, boolean pre_trusted, Globals GLOBALS)
          Create a User, initializing some fields based on the Behavior argument.
User(User.Behavior model, double cleanup, double honest, boolean pre_trusted, Globals GLOBALS)
          Create a User by providing all relevant fields.
 
Method Summary
static int BehaviorToInt(User.Behavior behavior)
          Retrieve the integer identifier assigned to a Behavior model.
 boolean BWidthAvailableDL(int cycle)
          Check the availability of download bandwidth.
 boolean BWidthAvailableUL(int cycle)
          Check the availability of upload bandwidth.
 void BWidthConsumeDL(int cycle)
          Consume bandwidth from the download BWidthUnit.
 void BWidthConsumeUL(int cycle)
          Consume bandwidth from the upload BWidthUnit.
 double getCleanup()
          Access method to the cleanup field of this User.
 double getHonesty()
          Access method to the honesty field of this User.
 User.Behavior getModel()
          Access method to the Behavior model of this User.
 double getNumFiles()
          Access method to the num_files field of this User.
 Relation getRelation(int user_num)
          Access method to a global Relation between this user and another.
 void incFileCount()
          Increase the file possession counter by one.
static User.Behavior IntToBehavior(int behavior_int)
          Given an integer, return the Behavior associated with that identifier.
 boolean isPreTrusted()
          Access method to the pre_trusted field of this User
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

private User.Behavior model
The Behavior model to which this User conforms.


pre_trusted

private boolean pre_trusted
Whether or not the user is pre-trusted


pct_cleanup

private double pct_cleanup
The probability this User will clean up an invalid file.


pct_honest

private double pct_honest
The probability this User will provide honest feedback.


num_files

private int num_files
The number of files owned by this User.


vector

private Relation[] vector
Array storing Relations (reputations) of other User's in Network


ul_bwidth

private BWidthUnit ul_bwidth
Manager for upload bandwidth.


dl_bwidth

private BWidthUnit dl_bwidth
Manager for download bandwidth.

Constructor Detail

User

public User(User.Behavior model,
            boolean pre_trusted,
            Globals GLOBALS)
Create a User, initializing some fields based on the Behavior argument.

Parameters:
model - Behavior to use for field generation
pre_trusted - Whether or not this user is pre-trusted
GLOBALS - The Network parameterization object

User

public User(User.Behavior model,
            double cleanup,
            double honest,
            boolean pre_trusted,
            Globals GLOBALS)
Create a User by providing all relevant fields.

Parameters:
model - Behavior to which this User conforms
cleanup - Probability of cleaning up an invalid file
honest - Probability of providing an honest feedback
pre_trusted - Whether or not this user is pre-trusted
GLOBALS - The Network parameterization object
Method Detail

BehaviorToInt

public static int BehaviorToInt(User.Behavior behavior)
Retrieve the integer identifier assigned to a Behavior model.

Parameters:
behavior - The behavior model whose identifier is desired
Returns:
The unique integer identifier of that model

IntToBehavior

public static User.Behavior IntToBehavior(int behavior_int)
Given an integer, return the Behavior associated with that identifier.

Parameters:
behavior_int - The integer identifier of the desired Behavior
Returns:
The desired Behavior type

getRelation

public Relation getRelation(int user_num)
Access method to a global Relation between this user and another.

Parameters:
user_num - Numerical identifier of other User
Returns:
Relation describing this User's relationship with 'user_num'

getModel

public User.Behavior getModel()
Access method to the Behavior model of this User.

Returns:
Behavior model of this User

isPreTrusted

public boolean isPreTrusted()
Access method to the pre_trusted field of this User

Returns:
TRUE if this User is pre-trusted, FALSE otherwise.

getCleanup

public double getCleanup()
Access method to the cleanup field of this User.

Returns:
Cleanup rate of this User

getHonesty

public double getHonesty()
Access method to the honesty field of this User.

Returns:
Honesty rate of this User

getNumFiles

public double getNumFiles()
Access method to the num_files field of this User.

Returns:
The number of files this User possesses

incFileCount

public void incFileCount()
Increase the file possession counter by one.


BWidthAvailableUL

public boolean BWidthAvailableUL(int cycle)
Check the availability of upload bandwidth.

Parameters:
cycle - The cycle when this availability query is being made
Returns:
TRUE if upload bandwidth is available. FALSE otherwise.

BWidthConsumeUL

public void BWidthConsumeUL(int cycle)
Consume bandwidth from the upload BWidthUnit.

Parameters:
cycle - The cycle when this consumption is to begin

BWidthAvailableDL

public boolean BWidthAvailableDL(int cycle)
Check the availability of download bandwidth.

Parameters:
cycle - The cycle when this availability query is being made
Returns:
TRUE if download bandwidth is available. FALSE otherwise

BWidthConsumeDL

public void BWidthConsumeDL(int cycle)
Consume bandwidth from the download BWidthUnit.

Parameters:
cycle - The cycle when this consumption is to begin