Main Page | Modules | Class Hierarchy | Class List | File List | Class Members | File Members

ServerConnection.h

Go to the documentation of this file.
00001 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__
00002 #define __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__
00003 
00004 #ident "$Header: /cvs/jra1mw/org.glite.lb.client-interface/interface/ServerConnection.h,v 1.6 2005/08/03 09:30:10 akrenek Exp $"
00005 
00011 #include <string.h>
00012 #include <list>
00013 
00014 #include "glite/wmsutils/jobid/JobId.h"
00015 
00016 #include "glite/lb/Event.h"
00017 #include "glite/lb/JobStatus.h"
00018 #include "glite/lb/consumer.h"
00019 
00020 EWL_BEGIN_NAMESPACE
00021 
00029 class QueryRecord {
00030 public:
00031         friend class ServerConnection;
00032         friend edg_wll_QueryRec *convertQueryVector(const std::vector<QueryRecord> &in);
00033 
00034         /* IMPORTANT: must match lbapi.h */
00042         enum Attr {
00043                 UNDEF=0,        
00044                 JOBID,          
00045                 OWNER,          
00046                 STATUS,         
00047                 LOCATION,       
00048                 DESTINATION,    
00049                 DONECODE,       
00050                 USERTAG,        
00051                 TIME,           
00052                 LEVEL,          
00053                 HOST,           
00054                 SOURCE,         
00055                 INSTANCE,       
00056                 EVENT_TYPE,     
00057                 CHKPT_TAG,      
00058                 RESUBMITTED,    
00059                 PARENT,         
00060                 EXITCODE,       
00061         };
00062 
00068         enum Op {
00069                 EQUAL=EDG_WLL_QUERY_OP_EQUAL, 
00070                 LESS=EDG_WLL_QUERY_OP_LESS, 
00071                 GREATER=EDG_WLL_QUERY_OP_GREATER, 
00072                 WITHIN=EDG_WLL_QUERY_OP_WITHIN, 
00074                 UNEQUAL=EDG_WLL_QUERY_OP_UNEQUAL 
00075         };
00076   
00077 
00082         QueryRecord();
00083 
00089         QueryRecord(const QueryRecord &src);
00090 
00097         QueryRecord& operator=(const QueryRecord &src);
00098 
00108         QueryRecord(const Attr name, const Op op, const std::string &value);
00109 
00119         QueryRecord(const Attr name, const Op op, const int value);
00120 
00130         QueryRecord(const Attr name, const Op op, const struct timeval &value);
00131 
00141         QueryRecord(const Attr name, const Op op, const glite::wmsutils::jobid::JobId &value);
00142 
00143         /* this one is for attr==TIME and particular state */
00154         QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value);
00155         
00156         /* constructors for WITHIN operator */
00167         QueryRecord(const Attr name, const Op op, const std::string &value_min, const std::string &value_max);
00168 
00179         QueryRecord(const Attr name, const Op op, const int value_min, const int value_max);
00180 
00191         QueryRecord(const Attr name, const Op op, const struct timeval &value_min, const struct timeval &value_max);
00192 
00205         QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value_min, const struct timeval &value_max);
00206 
00207         /* convenience for user tags */
00216         QueryRecord(const std::string &tag, const Op op, const std::string &value);
00217 
00228         QueryRecord(const std::string &tag, const Op op, const std::string &value_min, const std::string &value_max);
00229         
00234         ~QueryRecord();
00235   
00241         static const std::string AttrName(const Attr attr) ;
00242   
00243 protected:
00244 
00245         /* conversion to C API type */
00246         operator edg_wll_QueryRec() const;
00247 
00248 private:
00249         Attr    attr;
00250         Op      oper;
00251         std::string tag_name;
00252         int state;
00253         std::string string_value;
00254         glite::wmsutils::jobid::JobId jobid_value;
00255         int     int_value;
00256         struct timeval timeval_value;
00257         std::string string_value2;
00258         int     int_value2;
00259         struct timeval timeval_value2;
00260 };
00261 
00262 
00264 enum AggOp { AGG_MIN=1, AGG_MAX, AGG_COUNT };
00265 
00266 
00282 class ServerConnection {
00283 public:
00311         friend class Job;
00312 
00318         ServerConnection(void);
00319 
00324         ServerConnection(const std::string &);
00325 
00330         void open(const std::string &);
00331 
00336         void close(void);
00337 
00338         /* END DEPRECATED */
00339 
00340         /* set & get parameter methods */
00341 
00350         void setQueryServer(const std::string& host, int port);
00351 
00359         void setQueryTimeout(int time);
00360 
00369         void setX509Proxy(const std::string& proxy);
00370 
00381         void setX509Cert(const std::string& cert, const std::string& key);
00382 
00391         std::pair<std::string, int> getQueryServer() const;
00392 
00401         int getQueryTimeout() const;
00402 
00411         std::string getX509Proxy() const;
00412 
00421         std::pair<std::string, std::string> getX509Cert() const;
00422 
00423         /* end of set & get */
00424 
00429         virtual ~ServerConnection();
00430 
00431 
00432         /* consumer API */
00433 
00450         std::vector<std::vector<std::pair<QueryRecord::Attr,std::string> > >
00451                 getIndexedAttrs(void);
00452 
00453         /* Retrieve hard and soft result set size limit.
00454          * \ingroup property
00455          *
00456          * Returns both the hard and soft limit on the number of
00457          * results returned by the bookkeeping server.
00458          * \returns Pair (hard, soft) of limits.
00459          * \throws 
00460          */
00461         // std::pair<int,int> getLimits(void) const;
00462 
00471         void setQueryJobsLimit(int max);
00472 
00481         void setQueryEventsLimit(int max);
00482   
00494         void queryEvents(const std::vector<QueryRecord>& job_cond,
00495                          const std::vector<QueryRecord>& event_cond,
00496                          std::vector<Event>& events) const;
00497   
00501         const std::vector<Event> queryEvents(const std::vector<QueryRecord>& job_cond,
00502                                              const std::vector<QueryRecord>& event_cond) const;
00503 
00509         const std::list<Event> queryEventsList(const std::vector<QueryRecord>& job_cond,
00510                                                const std::vector<QueryRecord>& event_cond) const;
00511 
00512 
00520         std::string queryEventsAggregate(const std::vector<QueryRecord>& job_cond,
00521                                          const std::vector<QueryRecord>& event_cond,
00522                                          enum AggOp const op,
00523                                          std::string const attr) const;
00524   
00525 
00538         void queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00539                          const std::vector<std::vector<QueryRecord> >& event_cond,
00540                          std::vector<Event>& eventList) const;
00541   
00547         const std::vector<Event> 
00548         queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00549                     const std::vector<std::vector<QueryRecord> >& event_cond) const;
00550 
00551         
00560         void queryJobs(const std::vector<QueryRecord>& query,
00561                        std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00562 
00568         const std::vector<glite::wmsutils::jobid::JobId>
00569         queryJobs(const std::vector<QueryRecord>& query) const;
00570   
00571         
00580         void queryJobs(const std::vector<std::vector<QueryRecord> >& query,
00581                        std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00582   
00587         const std::vector<glite::wmsutils::jobid::JobId>
00588         queryJobs(const std::vector<std::vector<QueryRecord> >& query) const;
00589 
00599         void queryJobStates(const std::vector<QueryRecord>& query, 
00600                             int flags,
00601                             std::vector<JobStatus> & states) const;
00602 
00607         const std::vector<JobStatus>  queryJobStates(const std::vector<QueryRecord>& query, 
00608                                                      int flags) const;
00609 
00615         const std::list<JobStatus>  queryJobStatesList(const std::vector<QueryRecord>& query,
00616                                                      int flags) const;
00617   
00628         void queryJobStates(const std::vector<std::vector<QueryRecord> >& query, 
00629                             int flags,
00630                             std::vector<JobStatus> & states) const;
00631 
00636         const std::vector<JobStatus>  
00637         queryJobStates(const std::vector<std::vector<QueryRecord> >& query, 
00638                        int flags) const;
00639   
00648         void userJobStates(std::vector<JobStatus>& stateList) const;
00649         const std::vector<JobStatus> userJobStates() const;
00650   
00651   
00660         void userJobs(std::vector<glite::wmsutils::jobid::JobId> &jobs) const;
00661 
00666         const std::vector<glite::wmsutils::jobid::JobId> userJobs() const;
00667 
00676         void setParam(edg_wll_ContextParam name, int value); 
00677 
00686         void setParam(edg_wll_ContextParam name, const std::string &value); 
00687 
00696         void setParam(edg_wll_ContextParam name, const struct timeval &value); 
00697 
00705         int getParamInt(edg_wll_ContextParam name) const;
00706 
00714         std::string getParamString(edg_wll_ContextParam name) const;
00715 
00723         struct timeval getParamTime(edg_wll_ContextParam name) const;
00724   
00725 protected:
00726 
00727         edg_wll_Context getContext(void) const;
00728 
00729 private:
00730         edg_wll_Context context;
00731 };
00732 
00733 EWL_END_NAMESPACE
00734 
00735 #endif

Generated on Thu May 11 20:44:16 2006 for Glite LB Client: CPP - Interface by doxygen 1.3.5