RecursiveLookup.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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     // see IterativeLookup.h
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
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3