Back to index

nordugrid-arc-nox  1.1.0~rc6
arex.h
Go to the documentation of this file.
00001 #ifndef __ARC_AREX_H__
00002 #define __ARC_AREX_H__
00003 
00004 #include <arc/infosys/RegisteredService.h>
00005 #include <arc/message/PayloadRaw.h>
00006 #include <arc/delegation/DelegationInterface.h>
00007 #include <arc/infosys/InformationInterface.h>
00008 #include <arc/infosys/InfoRegister.h>
00009 #include <arc/Thread.h>
00010 
00011 #include "grid-manager/grid_manager.h"
00012 
00013 namespace ARex {
00014 
00015 class ARexGMConfig;
00016 class ARexConfigContext;
00017 class CountedResourceLock;
00018 
00019 class CountedResource {
00020  friend class CountedResourceLock;
00021  public:
00022   CountedResource(int maxconsumers = -1);
00023   ~CountedResource(void);
00024   void MaxConsumers(int maxconsumers);
00025  private:
00026   Glib::Cond cond_;
00027   Glib::Mutex lock_;
00028   int limit_;
00029   int count_;
00030   void Acquire(void);
00031   void Release(void);
00032 };
00033 
00034 class OptimizedInformationContainer: public Arc::InformationContainer {
00035  private:
00036   std::string filename_;
00037   int handle_;
00038   Arc::XMLNode doc_;
00039   Glib::Mutex olock_;
00040  public:
00041   OptimizedInformationContainer(void);
00042   ~OptimizedInformationContainer(void);
00043   int OpenDocument(void);
00044   Arc::MessagePayload* Process(Arc::SOAPEnvelope& in);
00045   void AssignFile(const std::string& filename);
00046   void Assign(const std::string& xml);
00047 };
00048 
00049 class ARexService: public Arc::RegisteredService {
00050  protected:
00051   Arc::ThreadRegistry thread_count_;
00052   Arc::NS ns_;
00053   Arc::Logger logger_;
00054   Arc::DelegationContainerSOAP delegations_;
00055   OptimizedInformationContainer infodoc_;
00056   Arc::InfoRegisters inforeg_;
00057   CountedResource infolimit_;
00058   CountedResource beslimit_;
00059   CountedResource datalimit_;
00060   std::string endpoint_;
00061   std::string uname_;
00062   std::string gmconfig_;
00063   bool gmconfig_temporary_;
00064   std::string common_name_;
00065   std::string long_description_;
00066   std::string lrms_name_;
00067   std::string os_name_;
00068   unsigned int infoprovider_wakeup_period_;
00069   std::map<std::string,std::string> glue_states_;
00070   GridManager* gm_;
00071   bool valid_;
00072   ARexConfigContext* get_configuration(Arc::Message& inmsg);
00073   Arc::MCC_Status CreateActivity(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out,const std::string& clientid);
00074   Arc::MCC_Status GetActivityStatuses(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00075   Arc::MCC_Status TerminateActivities(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00076   Arc::MCC_Status GetActivityDocuments(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00077   Arc::MCC_Status GetFactoryAttributesDocument(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00078   Arc::MCC_Status StopAcceptingNewActivities(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00079   Arc::MCC_Status StartAcceptingNewActivities(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00080   Arc::MCC_Status ChangeActivityStatus(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00081   Arc::MCC_Status MigrateActivity(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out,const std::string& clientid);
00082   Arc::MCC_Status CacheCheck(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out);
00083   Arc::MCC_Status UpdateCredentials(ARexGMConfig& config,Arc::XMLNode in,Arc::XMLNode out,const std::string& credentials);
00084   Arc::MCC_Status make_response(Arc::Message& outmsg);
00085   Arc::MCC_Status make_fault(Arc::Message& outmsg);
00086   Arc::MCC_Status make_soap_fault(Arc::Message& outmsg);
00087   Arc::MCC_Status Get(Arc::Message& inmsg,Arc::Message& outmsg,ARexGMConfig& config,const std::string& id,const std::string& subpath);
00088   Arc::MCC_Status Put(Arc::Message& inmsg,Arc::Message& outmsg,ARexGMConfig& config,const std::string& id,const std::string& subpath);
00089   void GenericFault(Arc::SOAPFault& fault);
00090   void NotAuthorizedFault(Arc::XMLNode fault);
00091   void NotAuthorizedFault(Arc::SOAPFault& fault);
00092   void NotAcceptingNewActivitiesFault(Arc::XMLNode fault);
00093   void NotAcceptingNewActivitiesFault(Arc::SOAPFault& fault);
00094   void UnsupportedFeatureFault(Arc::XMLNode fault,const std::string& feature);
00095   void UnsupportedFeatureFault(Arc::SOAPFault& fault,const std::string& feature);
00096   void CantApplyOperationToCurrentStateFault(Arc::XMLNode fault,const std::string& gm_state,bool failed,const std::string& message);
00097   void CantApplyOperationToCurrentStateFault(Arc::SOAPFault& fault,const std::string& gm_state,bool failed,const std::string& message);
00098   void OperationWillBeAppliedEventuallyFault(Arc::XMLNode fault,const std::string& gm_state,bool failed,const std::string& message);
00099   void OperationWillBeAppliedEventuallyFault(Arc::SOAPFault& fault,const std::string& gm_state,bool failed,const std::string& message);
00100   void UnknownActivityIdentifierFault(Arc::XMLNode fault,const std::string& message);
00101   void UnknownActivityIdentifierFault(Arc::SOAPFault& fault,const std::string& message);
00102   void InvalidRequestMessageFault(Arc::XMLNode fault,const std::string& element,const std::string& message);
00103   void InvalidRequestMessageFault(Arc::SOAPFault& fault,const std::string& element,const std::string& message);
00104  public:
00105   ARexService(Arc::Config *cfg);
00106   virtual ~ARexService(void);
00107   virtual Arc::MCC_Status process(Arc::Message& inmsg,Arc::Message& outmsg);
00108   void InformationCollector(void);
00109   virtual bool RegistrationCollector(Arc::XMLNode &doc);
00110   virtual std::string getID();
00111   void StopChildThreads(void);
00112   operator bool(void) { return valid_; };
00113   bool operator!(void) { return !valid_; };
00114 };
00115 
00116 } // namespace ARex
00117 
00118 #endif
00119