RecursiveLookup.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __RECURSIVE_LOOKUP_H
00025 #define __RECURSIVE_LOOKUP_H
00026
00027 #include <NodeVector.h>
00028 #include <AbstractLookup.h>
00029 #include <RpcListener.h>
00030 #include <CommonMessages_m.h>
00031
00032 class LookupListener;
00033 class BaseOverlay;
00034
00040 class RecursiveLookupConfiguration
00041 {
00042 public:
00043 int redundantNodes;
00044 int numRetries;
00045 bool failedNodeRpcs;
00046 };
00047
00048 class RecursiveLookup : public RpcListener,
00049 public AbstractLookup
00050 {
00051 public:
00052 RecursiveLookup(BaseOverlay* overlay, RoutingType routingType,
00053 const RecursiveLookupConfiguration& config,
00054 bool appLookup);
00058 virtual ~RecursiveLookup();
00059
00060
00061 virtual void lookup(const OverlayKey& key, int numSiblings = 1,
00062 int hopCountMax = 0, int retries = 0,
00063 LookupListener* listener = NULL);
00064
00070 virtual const NodeVector& getResult() const;
00071
00077 virtual bool isValid() const;
00078
00085 virtual void abortLookup();
00086
00092 virtual uint32_t getAccumulatedHops() const;
00093
00094 void handleRpcTimeout(BaseCallMessage* msg,
00095 const TransportAddress& dest,
00096 cPolymorphic* context, int rpcId,
00097 const OverlayKey& destKey);
00098
00099 void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic* context,
00100 int rpcId, simtime_t rtt);
00101 private:
00102 BaseOverlay* overlay;
00103 LookupListener* listener;
00104 uint32_t nonce;
00105 bool valid;
00106 NodeVector siblings;
00107 RoutingType routingType;
00108 int redundantNodes;
00109 int numRetries;
00110 bool appLookup;
00111 };
00112
00113 #endif //__RECURSIVE_LOOKUP_H