OverSim
SendToKeyListener Class Reference
Inheritance diagram for SendToKeyListener:
LookupListener

Public Member Functions

 SendToKeyListener (BaseOverlay *overlay, BaseOverlayMessage *msg)
 ~SendToKeyListener ()
virtual void lookupFinished (AbstractLookup *lookup)
- Public Member Functions inherited from LookupListener
virtual ~LookupListener ()
 virtual destructor

Private Attributes

BaseOverlayoverlay
BaseOverlayMessagemsg
GlobalStatisticsglobalStatistics

Detailed Description

Definition at line 1257 of file BaseOverlay.cc.

Constructor & Destructor Documentation

SendToKeyListener::SendToKeyListener ( BaseOverlay overlay,
BaseOverlayMessage msg 
)
inline

Definition at line 1264 of file BaseOverlay.cc.

{
this->overlay = overlay;
this->msg = msg;
}
SendToKeyListener::~SendToKeyListener ( )
inline

Definition at line 1271 of file BaseOverlay.cc.

{
overlay = NULL;
if (msg != NULL) {
delete msg;
msg = NULL;
}
}

Member Function Documentation

virtual void SendToKeyListener::lookupFinished ( AbstractLookup lookup)
inlinevirtual

Implements LookupListener.

Definition at line 1280 of file BaseOverlay.cc.

{
if (dynamic_cast<BaseRouteMessage*>(msg)) {
BaseRouteMessage* routeMsg = static_cast<BaseRouteMessage*>(msg);
if (lookup->isValid()) {
if (lookup->getResult().size()==0) {
EV << "[SendToKeyListener::lookupFinished()]\n"
" [ERROR] SendToKeyListener: Valid result, "
"but empty array." << endl;
} else {
routeMsg->setHopCount(routeMsg->getHopCount()
+ lookup->getAccumulatedHops());
for (uint32_t i=0; i<lookup->getResult().size(); i++) {
static_cast<BaseRouteMessage*>
(routeMsg->dup()),
}
}
} else {
EV << "[SendToKeyListener::lookupFinished()]\n"
<< " Lookup failed - dropping message"
<< endl;
/*
std::cout << simTime() << " "
<< routeMsg->getEncapsulatedPacket()->getName() << " "
<< routeMsg->getSrcNode()
<< " [SendToKeyListener::lookupFinished()]\n"
<< " Lookup failed - dropping message"
<< std::endl;
*/
overlay->bytesDropped += routeMsg->getByteLength());
}
} else if (dynamic_cast<LookupCall*>(msg)) {
LookupCall* call = static_cast<LookupCall*>(msg);
LookupResponse* response = new LookupResponse();
response->setKey(call->getKey());
response->setHopCount(lookup->getAccumulatedHops());
if (lookup->isValid()) {
response->setIsValid(true);
response->setSiblingsArraySize(lookup->getResult().size());
for (uint32_t i=0; i<lookup->getResult().size(); i++) {
response->setSiblings(i, lookup->getResult()[i]);
}
if (lookup->getResult().size() == 0) {
EV << "[SendToKeyListener::lookupFinished() @ "
<< " (" << overlay->thisNode.getKey().toString(16) << ")]\n"
<< " LookupCall "
<< call->getNonce()
<< " failed! (size=0)" << endl;
}
} else {
response->setIsValid(false);
EV << "[SendToKeyListener::lookupFinished() @ "
<< " (" << overlay->thisNode.getKey().toString(16) << ")]\n"
<< " LookupCall "
<< call->getNonce()
<< " failed!" << endl;
}
overlay->sendRpcResponse(call, response);
msg = NULL;
} else {
throw cRuntimeError("SendToKeyListener::lookupFinished(): "
"Unknown message type!");
}
delete this;
}

Member Data Documentation

GlobalStatistics* SendToKeyListener::globalStatistics
private

Definition at line 1262 of file BaseOverlay.cc.

BaseOverlayMessage* SendToKeyListener::msg
private

Definition at line 1261 of file BaseOverlay.cc.

BaseOverlay* SendToKeyListener::overlay
private

Definition at line 1260 of file BaseOverlay.cc.


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