PubSubLobby.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 __PUBSUBLOBBY_H_
00025 #define __PUBSUBLOBBY_H_
00026 
00027 #include <deque>
00028 #include <algorithm>
00029 #include <omnetpp.h>
00030 #include <NodeHandle.h>
00031 #include <BaseOverlay.h>
00032 
00033 #include "PubSubMessage_m.h"
00034 #include "PubSubSubspace.h"
00035 
00036 class PubSubLobby : public BaseOverlay
00037 {
00038     public:
00039         // OMNeT++
00040         virtual ~PubSubLobby();
00041         virtual void initializeOverlay(int stage);
00042         virtual void finishOverlay();
00043         virtual void handleUDPMessage(BaseOverlayMessage* msg);
00044         virtual void handleTimerEvent(cMessage* msg);
00045 
00046         virtual bool handleRpcCall(BaseCallMessage* msg);
00047         virtual void handleRpcResponse(BaseResponseMessage *msg,
00048                                        cPolymorphic* context,
00049                                        int rpcId, simtime_t rtt);
00050         virtual void handleRpcTimeout(BaseCallMessage *msg,
00051                                       const TransportAddress &dest,
00052                                       cPolymorphic* context, int rpcId,
00053                                       const OverlayKey &destKey);
00054 
00055     protected:
00056         class ChildEntry {
00057             public:
00058                 NodeHandle handle;
00059                 int ressources;
00060                 std::set<int> dutySet;
00061                 bool operator< (const ChildEntry c) const { return ressources < c.ressources; }
00062                 bool operator== (const ChildEntry c) const { return handle ==  c.handle; }
00063                 bool operator== (const NodeHandle n) const { return handle ==  n; }
00064                 bool operator== (const TransportAddress n) const { return (TransportAddress) handle == n; }
00065         };
00066 
00067         int subspaceSize;
00068         int numSubspaces;
00069         std::vector<std::vector<PubSubSubspaceLobby> > subspaces;
00070         std::list<PubSubHelpCall*> waitingForHelp;
00071 
00072 //        typedef std::map<NodeHandle, ChildEntry> PlayerMap;
00073         typedef std::map<TransportAddress, ChildEntry> PlayerMap;
00074         PlayerMap playerMap;
00075         typedef std::multimap<int, ChildEntry*, std::greater<int> > PlayerRessourceMap;
00076         PlayerRessourceMap playerRessourceMap;
00077 
00078         virtual void handleJoin( PubSubJoinCall* joinMsg );
00079         virtual void handleHelpCall( PubSubHelpCall* helpMsg );
00080         virtual void handleRespCall( PubSubResponsibleNodeCall* respCall );
00081         virtual void handleTakeOverResponse( PubSubTakeOverSubspaceResponse* takeOverResp );
00082         virtual void handleTakeOverTimeout( PubSubTakeOverSubspaceCall* takeOverCall, const TransportAddress& oldNode );
00083         void handleHelpReleaseMessage( PubSubHelpReleaseMessage* helpRMsg );
00084         void replaceResponsibleNode( int subspaceId, NodeHandle respNode );
00085         void replaceResponsibleNode( PubSubSubspaceId subspaceId, NodeHandle respNode );
00086 //        void failedNode(const NodeHandle& node);
00087         void failedNode(const TransportAddress& node);
00088 
00089         // statistics
00090         int numPubSubSignalingMessages;
00091         int pubSubSignalingMessagesSize;
00092 
00093     public:
00094         friend std::ostream& operator<< (std::ostream& o, const ChildEntry& entry);
00095 
00096 };
00097 
00098 #endif
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3