Query Cycle Simulator HEADER

qcsim.peer.impl
Class PeerDescriptionImpl

java.lang.Object
  |
  +--qcsim.peer.impl.PeerDescriptionImpl
All Implemented Interfaces:
java.io.Externalizable, Notifiee, PeerDescription, java.io.Serializable

public class PeerDescriptionImpl
extends java.lang.Object
implements PeerDescription, java.io.Externalizable, Notifiee

Provides a GUI description of a peer and its downloads.

Version:
1.0
Author:
unascribed
See Also:
Serialized Form

Field Summary
(package private) static int side
           
 
Constructor Summary
PeerDescriptionImpl()
          Constructor
PeerDescriptionImpl(PeerImpl peer)
          Constructor
 
Method Summary
 PeerDescription badResponse(int i)
          Get the ith bad response during the current cycle.
 void badResponse(PeerDescription desc)
          Add the peer description to the list of bad responses.
 int badResponses()
          The total cound of bad responses for the current cycle
 int behavior()
          The peer behavior type.
 void behavior(int behavior)
           
 boolean collectiveNeighbor(int peerID)
          This method adds the peerID to its list of known peers in a malicious collective.
 java.awt.Color color(boolean colorTrust)
          Funtion will return the color that the peer should use to paint itself.
 boolean contains(int x, int y)
          Does this peer's description contain the x and y coordinate.
 void cycle(int cycle)
          Update the current cycle this description should be maintaining.
 void displayDescription(java.awt.Dimension dim, double rand)
          Set the dimension of the display on which to paint the peer.
 java.util.Vector downloadDescriptions()
          Get a list of download descriptions.
 void draw(java.awt.Graphics g, java.awt.Color color)
          This will draw the peer with the specified color.
 void drawLinks(java.awt.Graphics g, java.awt.Color color)
          Will draw the links connecting this peer to its neighbor.
 int failedDownloads()
          Get the total number of failed downloads.
 void failedDownloads(int num)
          Update the total number of failed downloads.
 double globalTrust()
          Yields trust value computed by this peer.
 void globalTrust(double trust)
          Set global trust for a given cycle
 int goodDownloads()
          Get the total number good downloads.
 void goodDownloads(int num)
          Update the total number of good downloads.
 PeerDescription goodResponse()
          Get the good response cooresponding to the current cycle.
 void goodResponse(PeerDescription desc)
          Add the description of the peer that sent a good response.
 int goodUploads()
          Get the total number of good uploads.
 void goodUploads(int num)
          Update the total number of good uploads.
 int inauthenticDownloads()
          Get the total number of inauthentic downloads.
 void inauthenticDownloads(int num)
          Update the total number of inauthentic downloads.
 int inauthenticUploads()
          Get the total number of inauthentic uploads.
 void inauthenticUploads(int num)
          Update the total number of inauthentic uploads.
 void manager(QueryCycleManager manager)
          The Query Cycle Manager, which is used to get the peer descriptions of other peers in the system.
 void notification(Notification notification)
          This just signals the begining of a new cycle
 int peerID()
          Peer id this object describes.
 java.awt.geom.Point2D position()
          The current position on the display.
 int queryResponseAttempts()
          Get the total number of query response attempts.
 void queryResponseAttempts(int num)
          Update the total number of query response attempts.
 void readExternal(java.io.ObjectInput in)
           
 java.lang.String toString()
          String that represents the object this desription describes.
 int voidDownloads()
          Get the total number of void downloads.
 void voidDownloads(int num)
          Update the total number of void downloads.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

side

static final int side
See Also:
Constant Field Values
Constructor Detail

PeerDescriptionImpl

public PeerDescriptionImpl(PeerImpl peer)
Constructor

Parameters:
peer - the peer to describe.

PeerDescriptionImpl

public PeerDescriptionImpl()
Constructor

Method Detail

manager

public void manager(QueryCycleManager manager)
The Query Cycle Manager, which is used to get the peer descriptions of other peers in the system.

Specified by:
manager in interface PeerDescription
Parameters:
manager - The Query Cycle Manager.

toString

public java.lang.String toString()
String that represents the object this desription describes.

Overrides:
toString in class java.lang.Object
Returns:
String containing the peer id.

notification

public void notification(Notification notification)
This just signals the begining of a new cycle

Specified by:
notification in interface Notifiee
Parameters:
notification - The notification.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException

peerID

public int peerID()
Peer id this object describes.

Specified by:
peerID in interface PeerDescription
Returns:
peer id.

behavior

public int behavior()
Description copied from interface: PeerDescription
The peer behavior type.

Specified by:
behavior in interface PeerDescription
Returns:
the type of behavior this peer assumes.

behavior

public void behavior(int behavior)

displayDescription

public void displayDescription(java.awt.Dimension dim,
                               double rand)
Set the dimension of the display on which to paint the peer.

Specified by:
displayDescription in interface PeerDescription
Parameters:
dim - The display dimension.
rand - used to conpute the peer's position on the display

contains

public boolean contains(int x,
                        int y)
Does this peer's description contain the x and y coordinate.

Specified by:
contains in interface PeerDescription
Parameters:
x - the x position.
y - the y position.
Returns:
true if the description contains the x, y

downloadDescriptions

public java.util.Vector downloadDescriptions()
Get a list of download descriptions.

Specified by:
downloadDescriptions in interface PeerDescription
Returns:
vector of download descriptions.

draw

public void draw(java.awt.Graphics g,
                 java.awt.Color color)
This will draw the peer with the specified color.

Specified by:
draw in interface PeerDescription
Parameters:
g - The graphics to draw on.
color - The color of the peer.

drawLinks

public void drawLinks(java.awt.Graphics g,
                      java.awt.Color color)
Will draw the links connecting this peer to its neighbor.

Specified by:
drawLinks in interface PeerDescription
Parameters:
color - Used to color the link.

color

public java.awt.Color color(boolean colorTrust)
Funtion will return the color that the peer should use to paint itself.

Specified by:
color in interface PeerDescription
Parameters:
colorTrust - If true then base color off of trust value.

position

public java.awt.geom.Point2D position()
The current position on the display. This can be set by calling displayDimension(..)

Specified by:
position in interface PeerDescription
Returns:
The centered point of the description's location

cycle

public void cycle(int cycle)
Update the current cycle this description should be maintaining. param cycle the cycle.

Specified by:
cycle in interface PeerDescription
Parameters:
cycle - the new cycle.

goodDownloads

public int goodDownloads()
Get the total number good downloads.

Specified by:
goodDownloads in interface PeerDescription
Returns:
number of good downloads.

goodDownloads

public void goodDownloads(int num)
Update the total number of good downloads.

Parameters:
num - number of good downloads.

inauthenticDownloads

public int inauthenticDownloads()
Get the total number of inauthentic downloads.

Specified by:
inauthenticDownloads in interface PeerDescription
Returns:
number of inauthentic downloads.

inauthenticDownloads

public void inauthenticDownloads(int num)
Update the total number of inauthentic downloads.

Parameters:
num - number of inauthentic downloads.

voidDownloads

public int voidDownloads()
Get the total number of void downloads.

Specified by:
voidDownloads in interface PeerDescription
Returns:
number of void downloads.

voidDownloads

public void voidDownloads(int num)
Update the total number of void downloads.

Parameters:
num - number of void downloads.

failedDownloads

public int failedDownloads()
Get the total number of failed downloads.

Specified by:
failedDownloads in interface PeerDescription
Returns:
number of failed downloads.

failedDownloads

public void failedDownloads(int num)
Update the total number of failed downloads.

Parameters:
num - number of failed downloads.

goodUploads

public int goodUploads()
Get the total number of good uploads.

Specified by:
goodUploads in interface PeerDescription
Returns:
number of good uploads.

goodUploads

public void goodUploads(int num)
Update the total number of good uploads.

Parameters:
num - number of good uploads.

inauthenticUploads

public int inauthenticUploads()
Get the total number of inauthentic uploads.

Specified by:
inauthenticUploads in interface PeerDescription
Returns:
number of inauthentic uploads.

inauthenticUploads

public void inauthenticUploads(int num)
Update the total number of inauthentic uploads.

Parameters:
num - number of inauthentic uploads.

queryResponseAttempts

public int queryResponseAttempts()
Get the total number of query response attempts.

Specified by:
queryResponseAttempts in interface PeerDescription
Returns:
number query response attempts.

queryResponseAttempts

public void queryResponseAttempts(int num)
Update the total number of query response attempts.

Parameters:
num - The number of query response attempts.

badResponses

public int badResponses()
The total cound of bad responses for the current cycle

Specified by:
badResponses in interface PeerDescription
Returns:
The number of bad responses.

badResponse

public void badResponse(PeerDescription desc)
Add the peer description to the list of bad responses.

Parameters:
desc - The description of the peer.

badResponse

public PeerDescription badResponse(int i)
Get the ith bad response during the current cycle.

Specified by:
badResponse in interface PeerDescription
Parameters:
i - The index (staring from 0) of the desired description.
Returns:
A description of the ith peer that sent a bad response.

goodResponse

public void goodResponse(PeerDescription desc)
Add the description of the peer that sent a good response.

Parameters:
desc - The description of the peer.

goodResponse

public PeerDescription goodResponse()
Get the good response cooresponding to the current cycle.

Specified by:
goodResponse in interface PeerDescription
Returns:
The description of the peer to sent a good response.

collectiveNeighbor

public boolean collectiveNeighbor(int peerID)
This method adds the peerID to its list of known peers in a malicious collective.

Parameters:
peerID - The id of the peer to add.

globalTrust

public double globalTrust()
Yields trust value computed by this peer.

Specified by:
globalTrust in interface PeerDescription
Returns:
trust trust value at peer

globalTrust

public void globalTrust(double trust)
Set global trust for a given cycle

Parameters:
trust - the global trust value

Query Cycle Simulator HEADER