Bamboo.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 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 __BAMBOO_H_
00025 #define __BAMBOO_H_
00026 
00027 #include <vector>
00028 #include <map>
00029 #include <queue>
00030 #include <algorithm>
00031 
00032 #include <omnetpp.h>
00033 #include <IPvXAddress.h>
00034 
00035 #include <OverlayKey.h>
00036 #include <NodeHandle.h>
00037 #include <BaseOverlay.h>
00038 #include <BasePastry.h>
00039 
00040 #include "PastryTypes.h"
00041 #include "PastryMessage_m.h"
00042 #include "PastryRoutingTable.h"
00043 #include "PastryLeafSet.h"
00044 #include "PastryNeighborhoodSet.h"
00045 
00046 
00053 class Bamboo : public BasePastry, public LookupListener
00054 {
00055     friend class BambooLookupListener;
00056 
00057   public:
00058 
00059     virtual ~Bamboo();
00060 
00061     // see BaseOverlay.h
00062     virtual void initializeOverlay(int stage);
00063 
00064     // see BaseOverlay.h
00065     virtual void handleTimerEvent(cMessage* msg);
00066 
00067     // see BaseOverlay.h
00068     virtual void handleUDPMessage(BaseOverlayMessage* msg);
00069 
00070     void handleStateMessage(PastryStateMessage* msg);
00071 
00072   protected:
00073 
00074     void lookupFinished(AbstractLookup *lookup);
00080     virtual void changeState(int toState);
00081 
00082   private:
00083 
00084     // local state tables
00085     simtime_t leafsetMaintenanceInterval;
00086     simtime_t localTuningInterval;
00087     simtime_t globalTuningInterval;
00088 
00089     cMessage* leafsetMaintenanceTimer;
00090     cMessage* globalTuningTimer;
00091     cMessage* localTuningTimer;
00092 
00097     void doLeafsetMaintenance(void);
00098 
00099     int getNextRowToMaintain();
00100 
00101     void doLocalTuning();
00102 
00106     void doGlobalTuning(void);
00107 
00116     bool handleFailedNode(const TransportAddress& failed);
00117 
00122     void checkProxCache(void);
00123 
00124     // see BaseOverlay.h
00125     virtual void joinOverlay();
00126 
00127 };
00128 
00129 class BambooLookupListener : public LookupListener
00130 {
00131   private:
00132     Bamboo* overlay;
00133 
00134   public:
00135     BambooLookupListener(Bamboo* overlay)
00136     {
00137         this->overlay = overlay;
00138     }
00139 
00140     virtual void lookupFinished(AbstractLookup *lookup)
00141     {
00142         overlay->lookupFinished(lookup);
00143         delete this;
00144     }
00145 };
00146 
00147 
00148 #endif
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3