peersim.core
Class OracleIdleProtocol

java.lang.Object
  extended by peersim.core.OracleIdleProtocol
All Implemented Interfaces:
java.lang.Cloneable, Cleanable, Linkable, Protocol

public final class OracleIdleProtocol
extends java.lang.Object
implements Protocol, Linkable

A protocol that does nothing but knows everything. It provides an interface which models a protocol that knows all nodes in the network, i.e. the neighborhood set of this protocol is always the whole node set. this protocol is also extremely cheap, in fact it has no data fields.


Constructor Summary
OracleIdleProtocol(java.lang.String prefix)
          Does nothing
 
Method Summary
 boolean addNeighbor(Node n)
          Unsupported operation
 java.lang.Object clone()
          Returns this to maximize memory saving.
 boolean contains(Node n)
          This is an expensive operation, should not be used at all.
 int degree()
          Returns the size of the neighbor list.
 Node getNeighbor(int i)
          The neighborhood contains the node itself, ie it contains the loop edge.
 void onKill()
          Performs cleanup when removed from the network.
 void pack()
          A possibility for optimization.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OracleIdleProtocol

public OracleIdleProtocol(java.lang.String prefix)
Does nothing

Method Detail

clone

public java.lang.Object clone()
Returns this to maximize memory saving. It contains no fields.

Specified by:
clone in interface Protocol
Overrides:
clone in class java.lang.Object

contains

public boolean contains(Node n)
This is an expensive operation, should not be used at all. It returns false only if the given node is not in the current network.

Specified by:
contains in interface Linkable

addNeighbor

public boolean addNeighbor(Node n)
Unsupported operation

Specified by:
addNeighbor in interface Linkable
Returns:
true if the neighbor has been inserted; false if the node is already a neighbor of this node

getNeighbor

public Node getNeighbor(int i)
The neighborhood contains the node itself, ie it contains the loop edge.

Specified by:
getNeighbor in interface Linkable

degree

public int degree()
Description copied from interface: Linkable
Returns the size of the neighbor list.

Specified by:
degree in interface Linkable

pack

public void pack()
Description copied from interface: Linkable
A possibility for optimization. An implementation should try to compress its internal representation. Normally this is called by initializers or other components when no increase in the expected size of the neighborhood can be expected.

Specified by:
pack in interface Linkable

onKill

public void onKill()
Description copied from interface: Cleanable
Performs cleanup when removed from the network. This is called by the host node when its fail state is set to Fallible.DEAD. It is very important that after calling this method, NONE of the methods of the implementing object are guaranteed to work any longer. They might throw arbitrary exceptions, etc. The idea is that after calling this, typically no one should access this object. However, as a recommendation, at least toString should be guaranteed to execute normally, to aid debugging.

Specified by:
onKill in interface Cleanable

toString

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