Package ckbot :: Module multiprotocol :: Class NidMapper
[hide private]
[frames] | no frames]

Class NidMapper

source code


class NidMapper implements a mapping between "external" and "internal"
node ID values. The internal node ID values are associated with owners,
which are typically Protocol instances.

IMPLEMENTATION:
  
  The current implementation is silly -- it gives each owner an address
  space of a given number of bits (default 8). External node ID values
  consist of owner ID bits followed by node ID bits

Instance Methods [hide private]
 
__init__(self, bits=8)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
iterowners(self)
Iterate over all the node owners
source code
 
addOwner(self, owner, oid=None)
Add a new node owner
source code
 
mapX2I(self, nid)
Map external node ID into an owner and internal node ID
source code
 
mapI2X(self, owner, nid)
Map owner and node ID into external node ID
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, bits=8)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

addOwner(self, owner, oid=None)

source code 

Add a new node owner

INPUT:
    owner -- hashable -- "owner" of a node range; must be hashable
    oid -- int -- owner ID to use, or None to have one generated
      If an owner ID is re-used, an exception will be raised