00001 #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__
00002 #define __EDG_WORKLOAD_LOGGING_CLIENT_SERVERCONNECTION_HPP__
00003
00004 #ident "$Header: /cvs/glite/org.glite.lb.client-interface/interface/Attic/ServerConnection.h,v 1.6.22.4 2010/03/16 09:12:22 zsustr Exp $"
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #include <string.h>
00029 #include <list>
00030
00031 #include "glite/wmsutils/jobid/JobId.h"
00032
00033 #include "glite/lb/Event.h"
00034 #include "glite/lb/JobStatus.h"
00035 #include "glite/lb/consumer.h"
00036
00037 EWL_BEGIN_NAMESPACE
00038
00046 class QueryRecord {
00047 public:
00048 friend class ServerConnection;
00049 friend edg_wll_QueryRec *convertQueryVector(const std::vector<QueryRecord> &in);
00050
00051
00059 enum Attr {
00060 UNDEF=0,
00061 JOBID = EDG_WLL_QUERY_ATTR_JOBID,
00062 OWNER = EDG_WLL_QUERY_ATTR_OWNER,
00063 STATUS = EDG_WLL_QUERY_ATTR_STATUS,
00064 LOCATION = EDG_WLL_QUERY_ATTR_LOCATION,
00065 DESTINATION = EDG_WLL_QUERY_ATTR_DESTINATION,
00066 DONECODE = EDG_WLL_QUERY_ATTR_DONECODE,
00067 USERTAG = EDG_WLL_QUERY_ATTR_USERTAG,
00068 TIME = EDG_WLL_QUERY_ATTR_TIME,
00069 LEVEL = EDG_WLL_QUERY_ATTR_LEVEL,
00070 HOST = EDG_WLL_QUERY_ATTR_HOST,
00071 SOURCE = EDG_WLL_QUERY_ATTR_SOURCE,
00072 INSTANCE = EDG_WLL_QUERY_ATTR_INSTANCE,
00073 EVENT_TYPE = EDG_WLL_QUERY_ATTR_EVENT_TYPE,
00074 CHKPT = EDG_WLL_QUERY_ATTR_CHKPT_TAG,
00075 RESUBMITTED = EDG_WLL_QUERY_ATTR_RESUBMITTED,
00076 PARENT = EDG_WLL_QUERY_ATTR_PARENT,
00077 EXITCODE = EDG_WLL_QUERY_ATTR_EXITCODE,
00078 JDL_ATTR = EDG_WLL_QUERY_ATTR_JDL_ATTR,
00079 };
00080
00086 enum Op {
00087 EQUAL=EDG_WLL_QUERY_OP_EQUAL,
00088 LESS=EDG_WLL_QUERY_OP_LESS,
00089 GREATER=EDG_WLL_QUERY_OP_GREATER,
00090 WITHIN=EDG_WLL_QUERY_OP_WITHIN,
00092 UNEQUAL=EDG_WLL_QUERY_OP_UNEQUAL
00093 };
00094
00095
00100 QueryRecord();
00101
00107 QueryRecord(const QueryRecord &src);
00108
00115 QueryRecord& operator=(const QueryRecord &src);
00116
00126 QueryRecord(const Attr name, const Op op, const std::string &value);
00127
00137 QueryRecord(const Attr name, const Op op, const int value);
00138
00148 QueryRecord(const Attr name, const Op op, const struct timeval &value);
00149
00159 QueryRecord(const Attr name, const Op op, const glite::wmsutils::jobid::JobId &value);
00160
00161
00172 QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value);
00173
00174
00185 QueryRecord(const Attr name, const Op op, const std::string &value_min, const std::string &value_max);
00186
00197 QueryRecord(const Attr name, const Op op, const int value_min, const int value_max);
00198
00209 QueryRecord(const Attr name, const Op op, const struct timeval &value_min, const struct timeval &value_max);
00210
00223 QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value_min, const struct timeval &value_max);
00224
00225
00234 QueryRecord(const std::string &tag, const Op op, const std::string &value);
00235
00246 QueryRecord(const std::string &tag, const Op op, const std::string &value_min, const std::string &value_max);
00247
00252 ~QueryRecord();
00253
00259 static const std::string AttrName(const Attr attr) ;
00260
00261 protected:
00262
00263
00264 operator edg_wll_QueryRec() const;
00265
00266 private:
00267 Attr attr;
00268 Op oper;
00269 std::string tag_name;
00270 int state;
00271 std::string string_value;
00272 glite::wmsutils::jobid::JobId jobid_value;
00273 int int_value;
00274 struct timeval timeval_value;
00275 std::string string_value2;
00276 int int_value2;
00277 struct timeval timeval_value2;
00278 };
00279
00280
00282 enum AggOp { AGG_MIN=1, AGG_MAX, AGG_COUNT };
00283
00284
00300 class ServerConnection {
00301 public:
00329 friend class Job;
00330
00336 ServerConnection(void);
00337
00342 ServerConnection(const std::string &);
00343
00348 void open(const std::string &);
00349
00354 void close(void);
00355
00356
00357
00358
00359
00368 void setQueryServer(const std::string& host, int port);
00369
00377 void setQueryTimeout(int time);
00378
00387 void setX509Proxy(const std::string& proxy);
00388
00399 void setX509Cert(const std::string& cert, const std::string& key);
00400
00409 std::pair<std::string, int> getQueryServer() const;
00410
00419 int getQueryTimeout() const;
00420
00429 std::string getX509Proxy() const;
00430
00439 std::pair<std::string, std::string> getX509Cert() const;
00440
00441
00442
00447 virtual ~ServerConnection();
00448
00449
00450
00451
00468 std::vector<std::vector<std::pair<QueryRecord::Attr,std::string> > >
00469 getIndexedAttrs(void);
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00489 void setQueryJobsLimit(int max);
00490
00499 void setQueryEventsLimit(int max);
00500
00512 void queryEvents(const std::vector<QueryRecord>& job_cond,
00513 const std::vector<QueryRecord>& event_cond,
00514 std::vector<Event>& events) const;
00515
00519 const std::vector<Event> queryEvents(const std::vector<QueryRecord>& job_cond,
00520 const std::vector<QueryRecord>& event_cond) const;
00521
00527 const std::list<Event> queryEventsList(const std::vector<QueryRecord>& job_cond,
00528 const std::vector<QueryRecord>& event_cond) const;
00529
00530
00538 std::string queryEventsAggregate(const std::vector<QueryRecord>& job_cond,
00539 const std::vector<QueryRecord>& event_cond,
00540 enum AggOp const op,
00541 std::string const attr) const;
00542
00543
00556 void queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00557 const std::vector<std::vector<QueryRecord> >& event_cond,
00558 std::vector<Event>& eventList) const;
00559
00565 const std::vector<Event>
00566 queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00567 const std::vector<std::vector<QueryRecord> >& event_cond) const;
00568
00569
00578 void queryJobs(const std::vector<QueryRecord>& query,
00579 std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00580
00586 const std::vector<glite::wmsutils::jobid::JobId>
00587 queryJobs(const std::vector<QueryRecord>& query) const;
00588
00589
00598 void queryJobs(const std::vector<std::vector<QueryRecord> >& query,
00599 std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00600
00605 const std::vector<glite::wmsutils::jobid::JobId>
00606 queryJobs(const std::vector<std::vector<QueryRecord> >& query) const;
00607
00617 void queryJobStates(const std::vector<QueryRecord>& query,
00618 int flags,
00619 std::vector<JobStatus> & states) const;
00620
00625 const std::vector<JobStatus> queryJobStates(const std::vector<QueryRecord>& query,
00626 int flags) const;
00627
00633 const std::list<JobStatus> queryJobStatesList(const std::vector<QueryRecord>& query,
00634 int flags) const;
00635
00646 void queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00647 int flags,
00648 std::vector<JobStatus> & states) const;
00649
00654 const std::vector<JobStatus>
00655 queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00656 int flags) const;
00657
00666 void userJobStates(std::vector<JobStatus>& stateList) const;
00667 const std::vector<JobStatus> userJobStates() const;
00668
00669
00678 void userJobs(std::vector<glite::wmsutils::jobid::JobId> &jobs) const;
00679
00684 const std::vector<glite::wmsutils::jobid::JobId> userJobs() const;
00685
00694 void setParam(edg_wll_ContextParam name, int value);
00695
00704 void setParam(edg_wll_ContextParam name, const std::string &value);
00705
00714 void setParam(edg_wll_ContextParam name, const struct timeval &value);
00715
00723 int getParamInt(edg_wll_ContextParam name) const;
00724
00732 std::string getParamString(edg_wll_ContextParam name) const;
00733
00741 struct timeval getParamTime(edg_wll_ContextParam name) const;
00742
00743 protected:
00744
00745 edg_wll_Context getContext(void) const;
00746
00747 private:
00748 edg_wll_Context context;
00749 };
00750
00751 EWL_END_NAMESPACE
00752
00753 #endif