Query Cycle Simulator HEADER

qcsim.peer.impl
Class PeerImpl

java.lang.Object
  |
  +--qcsim.peer.impl.PeerImpl
All Implemented Interfaces:
Peer

public class PeerImpl
extends java.lang.Object
implements Peer

This object contains all information associated with a peer in the network.

Version:
1.0
Author:
unascribed

Constructor Summary
PeerImpl(int debug, PeerManager manager, int peerID, int behavior, NetworkSimulator network)
          Constructor.
PeerImpl(PeerManager manager, int peerID, int behavior, NetworkSimulator network)
          Constructor.
 
Method Summary
 boolean addNeighbor(Peer peer)
          Add neighbor peer.
 PeerBehavior behavior()
          Get peer's behavior for a given scenario
 void collectiveNeighbor(int peerID)
          This method adds the peerID to its list of known peers in a malicious collective.
 PeerContent content()
          get peer content category
 void content(PeerContent content)
          Set peer content category
 int cycle()
          Get the current cycle from the manager.
 PeerDescription description()
          Get a description of the peer.
 java.lang.String dumpIntVector(java.util.Vector v)
           
 java.util.Map localTrust()
          The peer's local trust
 PeerManager manager()
          The peer's manager
 void message(PeerMessage msg)
          Dispatches message to associated message handler.
 Peer neighbor(int i)
          The ith neighbor of this peer
 int neighbors()
          The number of neighbors
 int peerID()
          get peer ID
 void removeFromNetwork()
           
 void removeNeighbor(Peer peer)
          Remove neighbor peer.
 double rpc(PeerRPC cmd)
          Handle a remote procedure call to a peer.
 Notifiee simulatorCallback()
          Get the callback interface used by the simulator to inform the peer with Simulator Notifications.
 double trust()
          A peer's global trust value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeerImpl

public PeerImpl(PeerManager manager,
                int peerID,
                int behavior,
                NetworkSimulator network)
Constructor.

Parameters:
manager - The manager that created this peer.
peerID - peer ID
behavior - The peer's behavior.
network - The network used to send and receive messages.

PeerImpl

public PeerImpl(int debug,
                PeerManager manager,
                int peerID,
                int behavior,
                NetworkSimulator network)
Constructor.

Parameters:
manager - The manager that created this peer.
peerID - peer ID
behavior - The peer's behavior.
network - The network used to send and receive messages.
Method Detail

description

public PeerDescription description()
Description copied from interface: Peer
Get a description of the peer.

Specified by:
description in interface Peer
Returns:
peer description object.

simulatorCallback

public Notifiee simulatorCallback()
Get the callback interface used by the simulator to inform the peer with Simulator Notifications.

Returns:
Notifiee interface for simulation notifications.

peerID

public int peerID()
get peer ID

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

trust

public double trust()
A peer's global trust value.

Returns:
The current global trust value for this peer.

localTrust

public java.util.Map localTrust()
The peer's local trust

Returns:
the local trust Map

message

public void message(PeerMessage msg)
Dispatches message to associated message handler.

Specified by:
message in interface Peer
Parameters:
msg - message received

collectiveNeighbor

public void 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.

neighbors

public int neighbors()
The number of neighbors

Specified by:
neighbors in interface Peer
Returns:
The number of neighbors.

neighbor

public Peer neighbor(int i)
The ith neighbor of this peer

Specified by:
neighbor in interface Peer
Returns:
neighoring peer.

addNeighbor

public boolean addNeighbor(Peer peer)
Add neighbor peer.

Specified by:
addNeighbor in interface Peer
Parameters:
peer - neighbor peer to be added
Returns:
false if peer is not neighbor of this peer

removeNeighbor

public void removeNeighbor(Peer peer)
Remove neighbor peer.

Specified by:
removeNeighbor in interface Peer
Parameters:
peer - neighbor peer to be removed
Returns:
false if peer is not neighbor of this peer otherwise true.

content

public void content(PeerContent content)
Set peer content category

Parameters:
content - the content

content

public PeerContent content()
get peer content category

Specified by:
content in interface Peer
Returns:
the peer's content

behavior

public PeerBehavior behavior()
Get peer's behavior for a given scenario

Specified by:
behavior in interface Peer
Returns:
the peer's behavior object.

manager

public PeerManager manager()
Description copied from interface: Peer
The peer's manager

Specified by:
manager in interface Peer
Returns:
the peer manager.

cycle

public int cycle()
Get the current cycle from the manager.


rpc

public double rpc(PeerRPC cmd)
Handle a remote procedure call to a peer.

Specified by:
rpc in interface Peer
Parameters:
cmd - The rpc command
Returns:
Return value of the rpc.

dumpIntVector

public java.lang.String dumpIntVector(java.util.Vector v)

removeFromNetwork

public void removeFromNetwork()

Query Cycle Simulator HEADER