Rice Pastry API

rice.p2p.multiring
Class MultiringIdFactory

java.lang.Object
  extended by rice.p2p.multiring.MultiringIdFactory
All Implemented Interfaces:
IdFactory

public class MultiringIdFactory
extends java.lang.Object
implements IdFactory

Version:
$Id: MultiringIdFactory.java 3524 2007-01-09 14:09:27Z jeffh $
Author:
Alan Mislove, Peter Druschel

Nested Class Summary
protected  class MultiringIdFactory.MultiringEntrySet
           
protected  class MultiringIdFactory.MultiringKeySet
           
protected  class MultiringIdFactory.MultiringMapEntry
           
protected  class MultiringIdFactory.MultiringSortedMap
           
 
Field Summary
protected  IdFactory factory
          The underlying IdFactory
protected  Id ringId
          The multiring node supporting this endpoint
 
Constructor Summary
MultiringIdFactory(Id ringId, IdFactory factory)
          Constructor
 
Method Summary
 Id buildId(byte[] material)
          Builds a protocol-specific Id given the source data.
 Id buildId(int[] material)
          Builds a protocol-specific Id given the source data.
 Id buildId(java.lang.String string)
          Builds a protocol-specific Id by using the hash of the given string as source data.
 Id.Distance buildIdDistance(byte[] material)
          Builds a protocol-specific Id.Distance given the source data.
 Id buildIdFromToString(char[] chars, int offset, int length)
          Builds an Id by converting the given toString() output back to an Id.
 Id buildIdFromToString(java.lang.String string)
          Builds an Id by converting the given toString() output back to an Id.
 IdRange buildIdRange(Id cw, Id ccw)
          Creates an IdRange given the CW and CCW ids.
 IdRange buildIdRangeFromPrefix(java.lang.String string)
          Builds an IdRange based on a prefix.
 IdSet buildIdSet()
          Creates an empty IdSet.
 IdSet buildIdSet(java.util.SortedMap map)
          Creates an empty IdSet.
 NodeHandleSet buildNodeHandleSet()
          Creates an empty NodeHandleSet.
 Id buildNormalId(byte[] material)
          Builds a protocol-specific Id given the source data.
 Id buildNormalId(java.lang.String material)
          Builds a protocol-specific Id given the source data.
 Id buildRandomId(java.util.Random rng)
          Builds a random protocol-specific Id.
 Id buildRandomId(RandomSource rng)
           
 RingId buildRingId(Id ringId, byte[] material)
          Builds a ringId by using the provided Id and ringIds.
 RingId buildRingId(Id ringId, Id id)
          Builds a ringId by using the provided Id and ringIds.
protected static int find(char[] chars, char value)
           
 int getIdToStringLength()
          Returns the length a Id.toString should be.
 Id getRingId()
          Method which returns the underlying Id which represents the local node's ring
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ringId

protected Id ringId
The multiring node supporting this endpoint


factory

protected IdFactory factory
The underlying IdFactory

Constructor Detail

MultiringIdFactory

public MultiringIdFactory(Id ringId,
                          IdFactory factory)
Constructor

Parameters:
factory - the underlying factory to use
Method Detail

getRingId

public Id getRingId()
Method which returns the underlying Id which represents the local node's ring

Returns:
The Id represetning the local ring

buildRingId

public RingId buildRingId(Id ringId,
                          byte[] material)
Builds a ringId by using the provided Id and ringIds.

Parameters:
ringId - The id to use as the ringid
material - The id material to use
Returns:
The built Id.

buildRingId

public RingId buildRingId(Id ringId,
                          Id id)
Builds a ringId by using the provided Id and ringIds.

Parameters:
ringId - The id to use as the ringid
id - The id to use as the id
Returns:
The built Id.

buildNormalId

public Id buildNormalId(byte[] material)
Builds a protocol-specific Id given the source data.

Parameters:
material - The material to use
Returns:
The built Id.

buildNormalId

public Id buildNormalId(java.lang.String material)
Builds a protocol-specific Id given the source data.

Parameters:
material - The material to use
Returns:
The built Id.

buildId

public Id buildId(byte[] material)
Builds a protocol-specific Id given the source data.

Specified by:
buildId in interface IdFactory
Parameters:
material - The material to use
Returns:
The built Id.

buildId

public Id buildId(int[] material)
Builds a protocol-specific Id given the source data.

Specified by:
buildId in interface IdFactory
Parameters:
material - The material to use
Returns:
The built Id.

buildId

public Id buildId(java.lang.String string)
Builds a protocol-specific Id by using the hash of the given string as source data.

Specified by:
buildId in interface IdFactory
Parameters:
string - The string to use as source data
Returns:
The built Id.

buildRandomId

public Id buildRandomId(java.util.Random rng)
Builds a random protocol-specific Id.

Specified by:
buildRandomId in interface IdFactory
Parameters:
rng - A random number generator
Returns:
The built Id.

buildRandomId

public Id buildRandomId(RandomSource rng)
Specified by:
buildRandomId in interface IdFactory

buildIdFromToString

public Id buildIdFromToString(java.lang.String string)
Builds an Id by converting the given toString() output back to an Id. Should not normall be used.

Specified by:
buildIdFromToString in interface IdFactory
Parameters:
string - The toString() representation of an Id
Returns:
The built Id.

buildIdFromToString

public Id buildIdFromToString(char[] chars,
                              int offset,
                              int length)
Builds an Id by converting the given toString() output back to an Id. Should not normally be used.

Specified by:
buildIdFromToString in interface IdFactory
Parameters:
chars - The character array
offset - The offset to start reading at
length - The length to read
Returns:
The built Id.

find

protected static int find(char[] chars,
                          char value)

buildIdRangeFromPrefix

public IdRange buildIdRangeFromPrefix(java.lang.String string)
Builds an IdRange based on a prefix. Any id which has this prefix should be inside this IdRange, and any id which does not share this prefix should be outside it.

Specified by:
buildIdRangeFromPrefix in interface IdFactory
Parameters:
string - The toString() representation of an Id
Returns:
The built Id.

getIdToStringLength

public int getIdToStringLength()
Returns the length a Id.toString should be.

Specified by:
getIdToStringLength in interface IdFactory
Returns:
The correct length;

buildIdDistance

public Id.Distance buildIdDistance(byte[] material)
Builds a protocol-specific Id.Distance given the source data.

Specified by:
buildIdDistance in interface IdFactory
Parameters:
material - The material to use
Returns:
The built Id.Distance.

buildIdRange

public IdRange buildIdRange(Id cw,
                            Id ccw)
Creates an IdRange given the CW and CCW ids.

Specified by:
buildIdRange in interface IdFactory
Parameters:
cw - The clockwise Id
ccw - The counterclockwise Id
Returns:
An IdRange with the appropriate delimiters.

buildIdSet

public IdSet buildIdSet()
Creates an empty IdSet.

Specified by:
buildIdSet in interface IdFactory
Returns:
an empty IdSet

buildIdSet

public IdSet buildIdSet(java.util.SortedMap map)
Creates an empty IdSet.

Specified by:
buildIdSet in interface IdFactory
Returns:
an empty IdSet

buildNodeHandleSet

public NodeHandleSet buildNodeHandleSet()
Creates an empty NodeHandleSet.

Specified by:
buildNodeHandleSet in interface IdFactory
Returns:
an empty NodeHandleSet

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection