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.3 2007/08/01 17:17:14 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
00042 enum Attr {
00043 UNDEF=0,
00044 JOBID = EDG_WLL_QUERY_ATTR_JOBID,
00045 OWNER = EDG_WLL_QUERY_ATTR_OWNER,
00046 STATUS = EDG_WLL_QUERY_ATTR_STATUS,
00047 LOCATION = EDG_WLL_QUERY_ATTR_LOCATION,
00048 DESTINATION = EDG_WLL_QUERY_ATTR_DESTINATION,
00049 DONECODE = EDG_WLL_QUERY_ATTR_DONECODE,
00050 USERTAG = EDG_WLL_QUERY_ATTR_USERTAG,
00051 TIME = EDG_WLL_QUERY_ATTR_TIME,
00052 LEVEL = EDG_WLL_QUERY_ATTR_LEVEL,
00053 HOST = EDG_WLL_QUERY_ATTR_HOST,
00054 SOURCE = EDG_WLL_QUERY_ATTR_SOURCE,
00055 INSTANCE = EDG_WLL_QUERY_ATTR_INSTANCE,
00056 EVENT_TYPE = EDG_WLL_QUERY_ATTR_EVENT_TYPE,
00057 CHKPT = EDG_WLL_QUERY_ATTR_CHKPT_TAG,
00058 RESUBMITTED = EDG_WLL_QUERY_ATTR_RESUBMITTED,
00059 PARENT = EDG_WLL_QUERY_ATTR_PARENT,
00060 EXITCODE = EDG_WLL_QUERY_ATTR_EXITCODE,
00061 JDL_ATTR = EDG_WLL_QUERY_ATTR_JDL_ATTR,
00062 };
00063
00069 enum Op {
00070 EQUAL=EDG_WLL_QUERY_OP_EQUAL,
00071 LESS=EDG_WLL_QUERY_OP_LESS,
00072 GREATER=EDG_WLL_QUERY_OP_GREATER,
00073 WITHIN=EDG_WLL_QUERY_OP_WITHIN,
00075 UNEQUAL=EDG_WLL_QUERY_OP_UNEQUAL
00076 };
00077
00078
00083 QueryRecord();
00084
00090 QueryRecord(const QueryRecord &src);
00091
00098 QueryRecord& operator=(const QueryRecord &src);
00099
00109 QueryRecord(const Attr name, const Op op, const std::string &value);
00110
00120 QueryRecord(const Attr name, const Op op, const int value);
00121
00131 QueryRecord(const Attr name, const Op op, const struct timeval &value);
00132
00142 QueryRecord(const Attr name, const Op op, const glite::wmsutils::jobid::JobId &value);
00143
00144
00155 QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value);
00156
00157
00168 QueryRecord(const Attr name, const Op op, const std::string &value_min, const std::string &value_max);
00169
00180 QueryRecord(const Attr name, const Op op, const int value_min, const int value_max);
00181
00192 QueryRecord(const Attr name, const Op op, const struct timeval &value_min, const struct timeval &value_max);
00193
00206 QueryRecord(const Attr name, const Op op, const int state, const struct timeval &value_min, const struct timeval &value_max);
00207
00208
00217 QueryRecord(const std::string &tag, const Op op, const std::string &value);
00218
00229 QueryRecord(const std::string &tag, const Op op, const std::string &value_min, const std::string &value_max);
00230
00235 ~QueryRecord();
00236
00242 static const std::string AttrName(const Attr attr) ;
00243
00244 protected:
00245
00246
00247 operator edg_wll_QueryRec() const;
00248
00249 private:
00250 Attr attr;
00251 Op oper;
00252 std::string tag_name;
00253 int state;
00254 std::string string_value;
00255 glite::wmsutils::jobid::JobId jobid_value;
00256 int int_value;
00257 struct timeval timeval_value;
00258 std::string string_value2;
00259 int int_value2;
00260 struct timeval timeval_value2;
00261 };
00262
00263
00265 enum AggOp { AGG_MIN=1, AGG_MAX, AGG_COUNT };
00266
00267
00283 class ServerConnection {
00284 public:
00312 friend class Job;
00313
00319 ServerConnection(void);
00320
00325 ServerConnection(const std::string &);
00326
00331 void open(const std::string &);
00332
00337 void close(void);
00338
00339
00340
00341
00342
00351 void setQueryServer(const std::string& host, int port);
00352
00360 void setQueryTimeout(int time);
00361
00370 void setX509Proxy(const std::string& proxy);
00371
00382 void setX509Cert(const std::string& cert, const std::string& key);
00383
00392 std::pair<std::string, int> getQueryServer() const;
00393
00402 int getQueryTimeout() const;
00403
00412 std::string getX509Proxy() const;
00413
00422 std::pair<std::string, std::string> getX509Cert() const;
00423
00424
00425
00430 virtual ~ServerConnection();
00431
00432
00433
00434
00451 std::vector<std::vector<std::pair<QueryRecord::Attr,std::string> > >
00452 getIndexedAttrs(void);
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00472 void setQueryJobsLimit(int max);
00473
00482 void setQueryEventsLimit(int max);
00483
00495 void queryEvents(const std::vector<QueryRecord>& job_cond,
00496 const std::vector<QueryRecord>& event_cond,
00497 std::vector<Event>& events) const;
00498
00502 const std::vector<Event> queryEvents(const std::vector<QueryRecord>& job_cond,
00503 const std::vector<QueryRecord>& event_cond) const;
00504
00510 const std::list<Event> queryEventsList(const std::vector<QueryRecord>& job_cond,
00511 const std::vector<QueryRecord>& event_cond) const;
00512
00513
00521 std::string queryEventsAggregate(const std::vector<QueryRecord>& job_cond,
00522 const std::vector<QueryRecord>& event_cond,
00523 enum AggOp const op,
00524 std::string const attr) const;
00525
00526
00539 void queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00540 const std::vector<std::vector<QueryRecord> >& event_cond,
00541 std::vector<Event>& eventList) const;
00542
00548 const std::vector<Event>
00549 queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00550 const std::vector<std::vector<QueryRecord> >& event_cond) const;
00551
00552
00561 void queryJobs(const std::vector<QueryRecord>& query,
00562 std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00563
00569 const std::vector<glite::wmsutils::jobid::JobId>
00570 queryJobs(const std::vector<QueryRecord>& query) const;
00571
00572
00581 void queryJobs(const std::vector<std::vector<QueryRecord> >& query,
00582 std::vector<glite::wmsutils::jobid::JobId>& jobList) const;
00583
00588 const std::vector<glite::wmsutils::jobid::JobId>
00589 queryJobs(const std::vector<std::vector<QueryRecord> >& query) const;
00590
00600 void queryJobStates(const std::vector<QueryRecord>& query,
00601 int flags,
00602 std::vector<JobStatus> & states) const;
00603
00608 const std::vector<JobStatus> queryJobStates(const std::vector<QueryRecord>& query,
00609 int flags) const;
00610
00616 const std::list<JobStatus> queryJobStatesList(const std::vector<QueryRecord>& query,
00617 int flags) const;
00618
00629 void queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00630 int flags,
00631 std::vector<JobStatus> & states) const;
00632
00637 const std::vector<JobStatus>
00638 queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00639 int flags) const;
00640
00649 void userJobStates(std::vector<JobStatus>& stateList) const;
00650 const std::vector<JobStatus> userJobStates() const;
00651
00652
00661 void userJobs(std::vector<glite::wmsutils::jobid::JobId> &jobs) const;
00662
00667 const std::vector<glite::wmsutils::jobid::JobId> userJobs() const;
00668
00677 void setParam(edg_wll_ContextParam name, int value);
00678
00687 void setParam(edg_wll_ContextParam name, const std::string &value);
00688
00697 void setParam(edg_wll_ContextParam name, const struct timeval &value);
00698
00706 int getParamInt(edg_wll_ContextParam name) const;
00707
00715 std::string getParamString(edg_wll_ContextParam name) const;
00716
00724 struct timeval getParamTime(edg_wll_ContextParam name) const;
00725
00726 protected:
00727
00728 edg_wll_Context getContext(void) const;
00729
00730 private:
00731 edg_wll_Context context;
00732 };
00733
00734 EWL_END_NAMESPACE
00735
00736 #endif