AndroMeta  2.0.0
AndroMeta/include/AndroMeta/MPeer.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2009-2012 AndroMeta LLC. All rights reserved.
00003  *
00004  * AndroMeta LLC retains all intellectual property and proprietary 
00005  * rights to this software and related documentation and any modifications 
00006  * thereto.  Any use, reproduction, disclosure, or distribution of this 
00007  * software and related documentation without an express license agreement 
00008  * from AndroMeta LLC is strictly prohibited.
00009  * 
00010  */
00011 
00018 #ifndef ANDROMETA_M_PEER_H
00019 #define ANDROMETA_M_PEER_H
00020 
00021 #include <AndroMeta/MObject.h>
00022 #include <AndroMeta/MNode.h>
00023 
00024 namespace Meta{
00025   
00026   class MProcTask;
00027   class MPeerBroker;
00028   class MPeerProc;
00029   class MPackage;
00030   class MAuth;
00031   
00042   class MPeer{
00043   public:
00044     
00057     MPeer(MProcTask* task,
00058           MAuth* auth,
00059           const mstr& scratchDir,
00060           size_t maxProcesses=0);
00061     
00065     MPeer(MProcTask* task);
00066     
00070     virtual ~MPeer();
00071     
00075     MProcTask* task();
00076     
00098     bool connect(mstr& hubHost, int hubPort, int localPort,
00099                  const mstr& user, const mstr& password,
00100                  bool requireRouter=false, bool isRouter=false);
00101     
00117     bool submitProcess(const MPackage& package,
00118                        size_t minHosts=1,
00119                        size_t maxHosts=1000,
00120                        double minUptime=100,
00121                        double minCPU=0,
00122                        double minNetwork=0);
00123     
00127     bool submitProcess(MPeerBroker* broker,
00128                        const MPackage& package,
00129                        size_t minHosts=1,
00130                        size_t maxHosts=1000,
00131                        double minUptime=100,
00132                        double minCPU=0,
00133                        double minNetwork=0);
00134     
00138     bool submitProcess(MPeerProc* peerProc,
00139                        const MPackage& package,
00140                        size_t minHosts=1,
00141                        size_t maxHosts=1000,
00142                        double minUptime=100,
00143                        double minCPU=0,
00144                        double minNetwork=0);
00145     
00150     bool attach(int localPort, const mstr& user, const mstr& password);
00151     
00155     size_t maxProcesses() const;
00156     
00160     void setMaxProcesses(size_t maxProcesses);
00161     
00165     const mstr& scratchDir() const;
00166     
00170     void setScratchDir(const mstr& scratchDir);
00171     
00175     int localPort() const;
00176     
00180     virtual void onHubDisconnect();
00181     
00185     virtual void onUpdate();
00186     
00190     mvar peerInfo() const;
00191     
00195     mvar groupInfo() const;
00196     
00197   private:  
00198     MPeer& operator=(const MPeer&);
00199     MPeer(const MPeer&);
00200     
00201     class MPeer_* x_;
00202   };
00203   
00204 } // end namespace Meta
00205 
00206 #endif // ANDROMETA_M_PEER_H