OverSim
RecursiveLookup Class Reference

#include <RecursiveLookup.h>

Inheritance diagram for RecursiveLookup:
RpcListener AbstractLookup

Public Member Functions

 RecursiveLookup (BaseOverlay *overlay, RoutingType routingType, const RecursiveLookupConfiguration &config, bool appLookup)
virtual ~RecursiveLookup ()
 Virtual destructor.
virtual void lookup (const OverlayKey &key, int numSiblings=1, int hopCountMax=0, int retries=0, LookupListener *listener=NULL)
 Lookup siblings for a key.
virtual const NodeVectorgetResult () const
 Returns the result of the lookup.
virtual bool isValid () const
 Returns true, if the lookup was successful.
virtual void abortLookup ()
 Aborts a running lookup.
virtual uint32_t getAccumulatedHops () const
 Returns the total number of hops for all lookup paths.
void handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 This method is called if an RPC timeout has been reached.
void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from AbstractLookup
virtual ~AbstractLookup ()
 Virtual destructor.

Private Attributes

BaseOverlayoverlay
LookupListenerlistener
uint32_t nonce
bool valid
NodeVector siblings
RoutingType routingType
int redundantNodes
int numRetries
bool appLookup

Additional Inherited Members

- Protected Member Functions inherited from RpcListener
virtual void handleRpcResponse (BaseResponseMessage *msg, const RpcState &rpcState, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcTimeout (const RpcState &rpcState)
 This method is called if an RPC timeout has been reached.

Detailed Description

Definition at line 48 of file RecursiveLookup.h.

Constructor & Destructor Documentation

RecursiveLookup::RecursiveLookup ( BaseOverlay overlay,
RoutingType  routingType,
const RecursiveLookupConfiguration config,
bool  appLookup 
)

Definition at line 31 of file RecursiveLookup.cc.

RecursiveLookup::~RecursiveLookup ( )
virtual

Virtual destructor.

Definition at line 44 of file RecursiveLookup.cc.

{
if (listener != NULL) {
delete listener;
listener = NULL;
}
}

Member Function Documentation

void RecursiveLookup::abortLookup ( )
virtual

Aborts a running lookup.

This method aborts a running lookup without calling the listener and delete the lookup object.

Implements AbstractLookup.

Definition at line 82 of file RecursiveLookup.cc.

{
delete this;
}
uint32_t RecursiveLookup::getAccumulatedHops ( ) const
virtual

Returns the total number of hops for all lookup paths.

Returns
The accumulated number of hops.

Implements AbstractLookup.

Definition at line 89 of file RecursiveLookup.cc.

{
//throw new cRuntimeError("RecursiveLookup is asked for # accumulated hops!");
return 0; //TODO hopCount in findNodeCall/Response ?
}
const NodeVector & RecursiveLookup::getResult ( ) const
virtual

Returns the result of the lookup.

Returns
The result node vector.

Implements AbstractLookup.

Definition at line 72 of file RecursiveLookup.cc.

{
return siblings;
}
void RecursiveLookup::handleRpcResponse ( BaseResponseMessage msg,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
virtual

This method is called if an RPC response has been received.

Parameters
msgThe response message.
contextPointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcIdThe RPC id.
rttThe Round-Trip-Time of this RPC

Reimplemented from RpcListener.

Definition at line 112 of file RecursiveLookup.cc.

{
FindNodeResponse* findNodeResponse = check_and_cast<FindNodeResponse*>(msg);
if (findNodeResponse->getSiblings() &&
findNodeResponse->getClosestNodesArraySize() > 0) {
valid = true;
for (uint32_t i = 0; i < findNodeResponse->getClosestNodesArraySize();
i++) {
siblings.push_back(findNodeResponse->getClosestNodes(i));
}
}
// std::cout << "RecursiveLookup::handleRpcResponse() "
// << findNodeResponse->getClosestNodesArraySize() << std::endl;
// inform listener
if (listener != NULL) {
listener = NULL;
}
delete this;
}
void RecursiveLookup::handleRpcTimeout ( BaseCallMessage msg,
const TransportAddress dest,
cPolymorphic *  context,
int  rpcId,
const OverlayKey destKey 
)
virtual

This method is called if an RPC timeout has been reached.

Parameters
msgThe original RPC message.
destThe destination node
contextPointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcIdThe RPC id.
destKeythe destination OverlayKey

Reimplemented from RpcListener.

Definition at line 95 of file RecursiveLookup.cc.

{
//TODO retry
valid = false;
// inform listener
if (listener != NULL) {
listener = NULL;
}
delete this;
}
bool RecursiveLookup::isValid ( ) const
virtual

Returns true, if the lookup was successful.

Returns
true, if the lookup was successful.

Implements AbstractLookup.

Definition at line 77 of file RecursiveLookup.cc.

{
return valid;
}
void RecursiveLookup::lookup ( const OverlayKey key,
int  numSiblings = 1,
int  hopCountMax = 0,
int  retries = 0,
LookupListener listener = NULL 
)
virtual

Lookup siblings for a key.

Parameters
keyThe key to lookup
numSiblingsNumber of siblings to lookup
hopCountMaxMaximum hop count
retriesNumber of retries if lookup fails
listenerListener to inform, when the lookup is done

Implements AbstractLookup.

Definition at line 54 of file RecursiveLookup.cc.

{
this->listener = listener;
FindNodeCall* call = new FindNodeCall("FindNodeCall");
call->setLookupKey(key);
call->setNumSiblings(numSiblings);
call->setBitLength(FINDNODECALL_L(call));
routingType, -1, retries, -1, this);
}

Member Data Documentation

bool RecursiveLookup::appLookup
private

Definition at line 110 of file RecursiveLookup.h.

Referenced by lookup().

LookupListener* RecursiveLookup::listener
private

Definition at line 103 of file RecursiveLookup.h.

Referenced by handleRpcResponse(), handleRpcTimeout(), lookup(), and ~RecursiveLookup().

uint32_t RecursiveLookup::nonce
private

Definition at line 104 of file RecursiveLookup.h.

Referenced by abortLookup(), and lookup().

int RecursiveLookup::numRetries
private

Definition at line 109 of file RecursiveLookup.h.

BaseOverlay* RecursiveLookup::overlay
private

Definition at line 102 of file RecursiveLookup.h.

Referenced by abortLookup(), lookup(), and ~RecursiveLookup().

int RecursiveLookup::redundantNodes
private

Definition at line 108 of file RecursiveLookup.h.

Referenced by lookup().

RoutingType RecursiveLookup::routingType
private

Definition at line 107 of file RecursiveLookup.h.

Referenced by lookup().

NodeVector RecursiveLookup::siblings
private

Definition at line 106 of file RecursiveLookup.h.

Referenced by getResult(), and handleRpcResponse().

bool RecursiveLookup::valid
private

Definition at line 105 of file RecursiveLookup.h.

Referenced by handleRpcResponse(), handleRpcTimeout(), isValid(), and RecursiveLookup().


The documentation for this class was generated from the following files: