C# 클래스 Brunet.Services.Dht.Dht

This class provides a client interface to the dht, the servers only work together on a neighboring basis but not on a whole system basis. It is up to the client to provide fault tolerance. This class does it by naive replication.
This class implements the fault tolerant portion of the Dht by using naive replication as well as fixing holes in the dht. A hole occurs when enough data results are received during a get to confirm existence, but not all the results returned a value. In the case of a hole, a put will be used to place the data back to seal the hole.
상속: IDht
파일 보기 프로젝트 열기: pstjuste/brunet 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
DEGREE int
DELAY int
DhtLog System.Diagnostics.BooleanSwitch
MAJORITY int
Node Brunet.Node

보호된 프로퍼티들

프로퍼티 타입 설명
_adgs_table System.Collections.Hashtable
_adps_table System.Collections.Hashtable
_online bool
_rpc RpcManager
_sync object

공개 메소드들

메소드 설명
AsyncCreate ( MemBlock key, MemBlock value, int ttl, Channel returns ) : void
AsyncGet ( MemBlock key, Channel returns ) : void This starts the get process by sending dht.Get to all the remote end points that contain the key we're looking up. The next step is is when the results are placed in the channel and GetEnqueueHandler is called or GetCloseHandler is called. This means the get needs to be stateful, that information is stored in the _adgs_table.
AsyncPut ( MemBlock key, MemBlock value, int ttl, Channel returns ) : void
AsyncPut ( MemBlock key, MemBlock value, int ttl, Channel returns, bool unique ) : void

This is the generic Put that is used by both the regular Put and Create methods. The use of the unique variable differentiates the two. This is asynchronous. Results are stored in the Channel returns. Creates and Puts return true if successful or exception if there are network errors in adding the entry, creates also fail if a previous entry exists. The work of determining success is handled in PutEnqueueHandler and PutCloseHandler.

Create ( MemBlock key, MemBlock value, int ttl ) : bool
Dht ( Node node ) : System

A default Dht client provides a DEGREE of 1 and a sychronous wait time of up to 60 seconds.

Dht ( Node node, int degree ) : System

Allows the user to specify the power of two of degrees to use. That is if degree=n, DEGREE for the dht is 2^n.

Dht ( Node node, int degree, int delay ) : System

Allows the user to specify the power of two of degrees to use. That is if degree=n, DEGREE for the dht is 2^n.

Get ( MemBlock key ) : System.Collections.Hashtable[]
GetEnqueueHandler ( Object o, EventArgs args ) : void

This is called as a result of a successful retrieval of data from a remote end point and performs follow up gets for remaining values

This adds the results to the entry in the _adgs_table. Once a value has been received by a majority of nodes, it is enqueued into the requestors returns channel. If not all results were retrieved follow up gets are performed, this is determined by looking at the state of the token, a non-null token implies there are remaining results.

MapToRing ( byte key ) : MemBlock[]

Get the hash of the first key and add 1/DEGREE * Address space to each successive key. The results are the positions in the ring where the data should be stored.

Put ( MemBlock key, MemBlock value, int ttl ) : bool
Put ( MemBlock key, MemBlock value, int ttl, bool unique ) : bool

This is the sychronous version of the generic Put used by both the Put and Create methods. The use of the unique variable differentiates the two. Returns true if successful or an exception if there are network errors in adding the entry, creates also fail if a previous entry exists.

PutCloseHandler ( Object o, EventArgs args ) : void

보호된 메소드들

메소드 설명
GetCloseHandler ( object o, EventArgs args ) : void

This is called by the Get callbacks when all the results for a get have come in. This looks at the results, finds holes, and does a follow up put to place the data back into the dht via GetFollowUp.

GetFollowUp ( AsDhtGetState adgs ) : void

Restores any of the Dht results that don't return all their values. We only get here at the end of a Dht return operation.

This analyzes the holes and fills them in individually. This only fills holes where there was a positive result (MAJORITY of results received).

GetLeaveEarly ( AsDhtGetState adgs ) : void

This helps us leave the Get early if we either have no results or our remaining results will not reach a majority due to too many nodes missing data. This closes the clients returns queue.

StateChangeHandler ( Node n, Node state ) : void

We're online once we are seeking connections, we're offline once Disconnect has been called.

메소드 상세

AsyncCreate() 공개 메소드

public AsyncCreate ( MemBlock key, MemBlock value, int ttl, Channel returns ) : void
key MemBlock
value MemBlock
ttl int
returns Channel
리턴 void

AsyncGet() 공개 메소드

This starts the get process by sending dht.Get to all the remote end points that contain the key we're looking up. The next step is is when the results are placed in the channel and GetEnqueueHandler is called or GetCloseHandler is called. This means the get needs to be stateful, that information is stored in the _adgs_table.
public AsyncGet ( MemBlock key, Channel returns ) : void
key MemBlock
returns Channel
리턴 void

AsyncPut() 공개 메소드

public AsyncPut ( MemBlock key, MemBlock value, int ttl, Channel returns ) : void
key MemBlock
value MemBlock
ttl int
returns Channel
리턴 void

AsyncPut() 공개 메소드

This is the generic Put that is used by both the regular Put and Create methods. The use of the unique variable differentiates the two. This is asynchronous. Results are stored in the Channel returns. Creates and Puts return true if successful or exception if there are network errors in adding the entry, creates also fail if a previous entry exists. The work of determining success is handled in PutEnqueueHandler and PutCloseHandler.
public AsyncPut ( MemBlock key, MemBlock value, int ttl, Channel returns, bool unique ) : void
key MemBlock The index to store the value at.
value MemBlock The value to store.
ttl int The dht lease time for the key:value pair.
returns Channel The Channel where the result will be placed.
unique bool True to do a create, false otherwise.
리턴 void

Create() 공개 메소드

public Create ( MemBlock key, MemBlock value, int ttl ) : bool
key MemBlock
value MemBlock
ttl int
리턴 bool

Dht() 공개 메소드

A default Dht client provides a DEGREE of 1 and a sychronous wait time of up to 60 seconds.
public Dht ( Node node ) : System
node Brunet.Node The node to provide service for.
리턴 System

Dht() 공개 메소드

Allows the user to specify the power of two of degrees to use. That is if degree=n, DEGREE for the dht is 2^n.
public Dht ( Node node, int degree ) : System
node Brunet.Node The node to provide service for.
degree int n where DEGREE=2^n amount of replications to perform. ///
리턴 System

Dht() 공개 메소드

Allows the user to specify the power of two of degrees to use. That is if degree=n, DEGREE for the dht is 2^n.
public Dht ( Node node, int degree, int delay ) : System
node Brunet.Node The node to provide service for.
degree int n where DEGREE=2^n amount of replications to /// perform.
delay int User specified delay for synchronous calls in /// seconds.
리턴 System

Get() 공개 메소드

public Get ( MemBlock key ) : System.Collections.Hashtable[]
key MemBlock
리턴 System.Collections.Hashtable[]

GetCloseHandler() 보호된 메소드

This is called by the Get callbacks when all the results for a get have come in. This looks at the results, finds holes, and does a follow up put to place the data back into the dht via GetFollowUp.
protected GetCloseHandler ( object o, EventArgs args ) : void
o object The channel representing a specific get.
args System.EventArgs Unused.
리턴 void

GetEnqueueHandler() 공개 메소드

This is called as a result of a successful retrieval of data from a remote end point and performs follow up gets for remaining values
This adds the results to the entry in the _adgs_table. Once a value has been received by a majority of nodes, it is enqueued into the requestors returns channel. If not all results were retrieved follow up gets are performed, this is determined by looking at the state of the token, a non-null token implies there are remaining results.
public GetEnqueueHandler ( Object o, EventArgs args ) : void
o Object The channel used to store the results.
args System.EventArgs Unused.
리턴 void

GetFollowUp() 보호된 메소드

Restores any of the Dht results that don't return all their values. We only get here at the end of a Dht return operation.
This analyzes the holes and fills them in individually. This only fills holes where there was a positive result (MAJORITY of results received).
protected GetFollowUp ( AsDhtGetState adgs ) : void
adgs AsDhtGetState The AsDhtGetState to analyze for follow up.
리턴 void

GetLeaveEarly() 보호된 메소드

This helps us leave the Get early if we either have no results or our remaining results will not reach a majority due to too many nodes missing data. This closes the clients returns queue.
protected GetLeaveEarly ( AsDhtGetState adgs ) : void
adgs AsDhtGetState The AsDhtGetState to qualify for leaving early
리턴 void

MapToRing() 공개 메소드

Get the hash of the first key and add 1/DEGREE * Address space to each successive key. The results are the positions in the ring where the data should be stored.
public MapToRing ( byte key ) : MemBlock[]
key byte The key to index.
리턴 MemBlock[]

Put() 공개 메소드

public Put ( MemBlock key, MemBlock value, int ttl ) : bool
key MemBlock
value MemBlock
ttl int
리턴 bool

Put() 공개 메소드

This is the sychronous version of the generic Put used by both the Put and Create methods. The use of the unique variable differentiates the two. Returns true if successful or an exception if there are network errors in adding the entry, creates also fail if a previous entry exists.
public Put ( MemBlock key, MemBlock value, int ttl, bool unique ) : bool
key MemBlock The index to store the value at.
value MemBlock The value to store.
ttl int The dht lease time for the key:value pair.
unique bool True to do a create, false otherwise.
리턴 bool

PutCloseHandler() 공개 메소드

public PutCloseHandler ( Object o, EventArgs args ) : void
o Object The channel used by put.
args System.EventArgs Unused.
리턴 void

StateChangeHandler() 보호된 메소드

We're online once we are seeking connections, we're offline once Disconnect has been called.
protected StateChangeHandler ( Node n, Node state ) : void
n Brunet.Node
state Brunet.Node
리턴 void

프로퍼티 상세

DEGREE 공개적으로 프로퍼티

How many replications are made.
public int DEGREE
리턴 int

DELAY 공개적으로 프로퍼티

How long to wait for synchronous results.
public int DELAY
리턴 int

DhtLog 공개적으로 정적으로 프로퍼티

The log enabler for the dht.
public static BooleanSwitch,System.Diagnostics DhtLog
리턴 System.Diagnostics.BooleanSwitch

MAJORITY 공개적으로 프로퍼티

floor(DEGREE/2) + 1, the amount of positive results for a successful operation
public int MAJORITY
리턴 int

Node 공개적으로 프로퍼티

The node to provide services for.
public Node,Brunet Node
리턴 Brunet.Node

_adgs_table 보호되어 있는 프로퍼티

The state table for asynchronos gets.
protected Hashtable,System.Collections _adgs_table
리턴 System.Collections.Hashtable

_adps_table 보호되어 있는 프로퍼티

The state table for asynchronous puts.
protected Hashtable,System.Collections _adps_table
리턴 System.Collections.Hashtable

_online 보호되어 있는 프로퍼티

True unless node is in offline, leaving, or disconnected
protected bool _online
리턴 bool

_rpc 보호되어 있는 프로퍼티

The RpcManager to perform transactions through.
protected RpcManager _rpc
리턴 RpcManager

_sync 보호되어 있는 프로퍼티

Lock for the dht put/get state tables.
protected object _sync
리턴 object