peersim.pastry
Class UniformRandomGenerator

java.lang.Object
  extended by peersim.pastry.UniformRandomGenerator

public final class UniformRandomGenerator
extends java.lang.Object

This initializator assign to the Nodes a nodeId (stored in the protocol MSPastryProtocol) by using this 128-bit (32 byte) random generator. Warning: this implementation is not serialized and is not thread-safe

Title: MSPASTRY

Description: MsPastry implementation for PeerSim

Copyright: Copyright (c) 2007

Company: The Pastry Group


Constructor Summary
UniformRandomGenerator(int aBits, long aSeed)
          instanciate the random generator with the given seed
UniformRandomGenerator(int aBits, java.util.Random r)
          initialized this random generator with the specified random seeder and the number of desider bits to generate
 
Method Summary
 java.math.BigInteger generate()
          Returns a unique 128-bit random number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UniformRandomGenerator

public UniformRandomGenerator(int aBits,
                              java.util.Random r)
initialized this random generator with the specified random seeder and the number of desider bits to generate

Parameters:
aBits - int
r - Random

UniformRandomGenerator

public UniformRandomGenerator(int aBits,
                              long aSeed)
instanciate the random generator with the given seed

Parameters:
aSeed - long
aBits - number of bits of the number-to-be-generateed
Method Detail

generate

public final java.math.BigInteger generate()
Returns a unique 128-bit random number. The number is also put into an internal store to check it will be never returned again

Returns:
BigInteger