00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
00021 #define GLITE_WMS_COMMON_REQUESTAD_EXPDAGAD_H
00022
00023
00024
00025
00026
00027 #include "boost/scoped_ptr.hpp"
00028 #include "NodeAd.h"
00029 #include "DAGAd.h"
00030 #include "JdlAttributeList.h"
00031 #include "glite/jobid/JobId.h"
00032 #include <classad_distribution.h>
00033 #include "extractfiles.h"
00034 namespace glite {
00035 namespace jdl {
00036
00041 struct JobIdStruct{
00042
00044 JobIdStruct();
00045
00047 JobIdStruct(const JobIdStruct& jobStruct);
00048
00050 ~JobIdStruct();
00051
00053 JobIdStruct& operator=(const JobIdStruct& jobStruct);
00054
00056 glite::jobid::JobId jobid ;
00057
00059 std::string* nodeName ;
00060
00062 std::vector< JobIdStruct* > children ;
00063
00064 private:
00065
00069 void flushMemory(void);
00070 };
00071
00084 class ExpDagAd{
00085 typedef std::vector<classad::ExprTree*> isb_value;
00086 public:
00088 enum attribute {
00090 EDG_JOBID,
00092 VIRTUAL_ORGANISATION,
00094 MYPROXY_SERVER,
00096 SEQUENCE_CODE,
00098 ISB_DEST_URI,
00100 SUBMIT_TO
00101 };
00103 enum multiAttribute {
00105 INPUTSB,
00107 ZIPPED_ISB
00108 };
00109 enum level {
00111 CURRENT ,
00113 SUBMISSION,
00115 NO_NODES,
00117 MULTI_LINES,
00119 RESTORED
00120 };
00124 ExpDagAd( const std::string& jdl ) ;
00126 ExpDagAd( std::ifstream& jdl_in ) ;
00128 ExpDagAd( const ExpDagAd& dag );
00130 ExpDagAd( Ad *ad );
00132 ExpDagAd( const classad::ClassAd &classAd);
00134 void operator=(const ExpDagAd& dag);
00136 ExpDagAd( DAGAd* ad);
00138 virtual ~ExpDagAd() throw();
00143 ExpDagAd* check ();
00145
00148 std::string toString (const level &lev = CURRENT ) ;
00149
00154 std::vector<std::string> getSubmissionStrings (std::vector<std::string> *jobids=NULL) ;
00157 std::string jobid2node(const std::string &jobid);
00159
00164 bool hasAttribute (const std::string& attr_name ) ;
00169 bool hasNodeAttribute ( const glite::jobid::JobId &node,
00170 const std::string &attr_name);
00175 bool hasNodeAttribute (const std::string &node,
00176 const std::string &attr_name);
00178
00184 void replaceNode (const glite::jobid::JobId &nodeId, NodeAd &nodeAd);
00189 void replaceNode (const std::string &nodeName, NodeAd &nodeAd);
00191
00198 void setNodeAttribute ( const glite::jobid::JobId &node,
00199 const std::string &attr_name,const std::string &attr_value);
00205 void setNodeAttribute (const std::string &node,
00206 const std::string &attr_name , const std::string &attr_value);
00212 void setNodeAttribute ( const glite::jobid::JobId &node,
00213 const std::string &attr_name,int &attr_value);
00219 void setNodeAttribute (const std::string &node,
00220 const std::string &attr_name , int &attr_value);
00226 void setNodeAttribute ( const glite::jobid::JobId &node,
00227 const std::string &attr_name,bool &attr_value);
00233 void setNodeAttribute (const std::string &node,
00234 const std::string &attr_name , bool &attr_value);
00241 void setNodeAttribute (const glite::jobid::JobId &node,
00242 const std::string &attr_name , const std::vector<std::string> &attr_value);
00249 void setNodeAttribute (const std::string &node,
00250 const std::string &attr_name , const std::vector<std::string> &attr_value);
00252
00257 NodeAd getNode (const glite::jobid::JobId &nodeId);
00261 NodeAd getNode (const std::string &nodeName);
00267 std::vector< std::string > getNodeStringValue (const glite::jobid::JobId &node,
00268 const std::string &attr_name);
00274 std::vector< std::string > getNodeStringValue (const std::string &node,
00275 const std::string &attr_name);
00281 int getNodeInt (const glite::jobid::JobId &node,
00282 const std::string &attr_name);
00288 int getNodeInt (const std::string &node,
00289 const std::string &attr_name);
00295 bool getNodeBool (const glite::jobid::JobId &node,
00296 const std::string &attr_name);
00302 bool getNodeBool (const std::string &node,
00303 const std::string &attr_name);
00309 std::string getNodeAttribute (const std::string &node,
00310 const std::string &attr_name );
00314 std::vector< std::pair< std::string , classad::ExprTree* > >
00315 getSubAttributes (const std::string &attr_name);
00318 std::vector<std::string> getNodes();
00320
00327 void delNodeAttribute (const glite::jobid::JobId &node,
00328 const std::string &attr_name );
00333 void delNodeAttribute (const std::string &node,
00334 const std::string &attr_name );
00338 bool removeAttribute(attribute attr_name);
00342 bool removeAttribute(const std::string& attr_name);
00344
00346
00351 void getJobIdStruct (JobIdStruct& jobIdStruct);
00352
00356 std::map<std::string,std::string> getJobIdMap();
00361 bool gettoBretrieved(){return toBretrieved;}
00367 ExtractedAd* getExtractedAd();
00371 void inherit(const std::string& attr_name);
00378 void setLocalAccess(bool lookInto);
00381 void expand () ;
00384 std::string showDependencies () ;
00386
00391 std::string getAttribute (attribute attr_name );
00395 std::string getString(const std::string &attr_name);
00399 bool getBool(const std::string &attr_name);
00403 Ad getAttributeAd (const std::string& attr_name);
00406 std::vector<std::string> getInputSandbox ();
00407
00408
00409
00410
00411 classad::Value getTypeValue(const std::string& attr_name);
00412 std::vector<std::string> getStringValue(const std::string& attr_name);
00418 std::vector<std::string> getAttribute (multiAttribute attr_name);
00420
00426 void setAttribute (attribute attr_name, const std::string& attr_value);
00431 void setAttribute (multiAttribute attr_name, const std::vector<std::string>& attr_values);
00432
00435 std::size_t size();
00437
00441 const std::string getDefaultRank ();
00444 const std::string getDefaultReq ();
00450 void setDefaultRank (const std::string& attr_value ) ;
00456 void setDefaultReq (const std::string& attr_value ) ;
00462 void setDefaultRank (classad::ExprTree *attr_value ) ;
00468 void setDefaultReq (classad::ExprTree *attr_value ) ;
00474 void setDefaultValues (bool val) { uiManipulation = val; };
00476
00485 bool hasWarnings();
00492 std::vector<std::string> getWarnings();
00499 void addWarning(const std::string &msg);
00507 void addWarnings(const std::string &nodeName, Ad *ad);
00509 protected:
00511 boost::shared_ptr<glite::jdl::DAGAd> dagad;
00512 private:
00513
00514 void reset() ;
00515 void inherit(glite::jdl::NodeAd* jobad, const std::string& attr_name,
00516 classad::ExprTree* expression, bool force=false);
00517 void inherit(glite::jdl::NodeAd* jobad,classad::ClassAd &dagClassAd);
00518 void evaluateAttribute(const std::string& attr_name, bool flatten=false) ;
00524 std::vector<DAGAd::node_iterator> orderNodes();
00525 void createMap();
00526 classad::ExprTree* EvaluateValue(classad::Value val, classad::ExprList* list );
00527 void checkSandBox( std::vector < std::pair<std::string , isb_value > >& isb , Ad& osb_nodes );
00528 void fromString (const std::string& jdl, std::string jdl_file ="") ;
00529 void fromFile ( std::ifstream& jdl_int ) ;
00530 void extract();
00531 bool checked ;
00532 std::map<std::string,std::string> map_nodes;
00533 checkType lookInto_b;
00534 classad::ExprTree *defaultRank ;
00535 classad::ExprTree *defaultReq ;
00536 bool uiManipulation,toBretrieved ;
00537
00538 ExtractedAd *extractedAd ;
00539 std::vector<std::string> warning_messages_v ;
00540 };
00541
00542 }
00543 }
00544
00545 #endif
00546