00001 #ifndef __EDG_WORKLOAD_LOGGING_SERVERCONNECTION__
00002 #define __EDG_WORKLOAD_LOGGING_SERVERCONNECTION__
00003
00004 #ident "$Header: /local/reps/lcgware/workload/logging/client/ServerConnection.h,v 1.27 2003/11/20 16:29:17 salvet Exp $"
00005
00011 #include <string.h>
00012 #include <list>
00013
00014 #include "edg/workload/common/jobid/JobId.h"
00015 #include "edg/workload/logging/client/Event.h"
00016 #include "edg/workload/logging/client/JobStatus.h"
00017
00018 #include "edg/workload/logging/client/consumer.h"
00019
00020 EWL_BEGIN_NAMESPACE;
00021
00023 class QueryRecord {
00024 public:
00025 friend class ServerConnection;
00026 friend edg_wll_QueryRec *convertQueryVector(const std::vector<QueryRecord> &in);
00027
00028
00029 enum Attr {
00030 UNDEF=0,
00031 JOBID,
00032 OWNER,
00033 STATUS,
00034 LOCATION,
00035 DESTINATION,
00036 DONECODE,
00037 USERTAG,
00038 TIME,
00039 LEVEL,
00040 HOST,
00041 SOURCE,
00042 INSTANCE,
00043 EVENT_TYPE,
00044 CHKPT_TAG,
00045 RESUBMITTED,
00046 PARENT,
00047 EXITCODE,
00048 };
00049
00050 enum Op {
00051 EQUAL=EDG_WLL_QUERY_OP_EQUAL,
00052 LESS=EDG_WLL_QUERY_OP_LESS,
00053 GREATER=EDG_WLL_QUERY_OP_GREATER,
00054 WITHIN=EDG_WLL_QUERY_OP_WITHIN
00055 };
00056
00057 QueryRecord();
00058
00059
00060 QueryRecord(const QueryRecord &);
00061 QueryRecord& operator=(const QueryRecord &);
00062
00063
00064 QueryRecord(const Attr, const Op, const std::string &);
00065 QueryRecord(const Attr, const Op, const int);
00066 QueryRecord(const Attr, const Op, const struct timeval &);
00067 QueryRecord(const Attr, const Op, const edg::workload::common::jobid::JobId&);
00068
00069 QueryRecord(const Attr, const Op, const int, const struct timeval &);
00070
00071
00072 QueryRecord(const Attr, const Op, const std::string &, const std::string &);
00073 QueryRecord(const Attr, const Op, const int, const int);
00074 QueryRecord(const Attr, const Op, const struct timeval &, const struct timeval &);
00075 QueryRecord(const Attr, const Op, const int, const struct timeval &, const struct timeval &);
00076
00077
00078 QueryRecord(const std::string &, const Op, const std::string &);
00079 QueryRecord(const std::string &, const Op, const std::string &, const std::string &);
00080
00081 ~QueryRecord();
00082
00083 protected:
00084
00085
00086 operator edg_wll_QueryRec() const;
00087
00088 private:
00089 Attr attr;
00090 Op oper;
00091 std::string tag_name;
00092 int state;
00093 std::string string_value;
00094 edg::workload::common::jobid::JobId jobid_value;
00095 int int_value;
00096 struct timeval timeval_value;
00097 std::string string_value2;
00098 int int_value2;
00099 struct timeval timeval_value2;
00100 };
00101
00102
00104 enum AggOp { AGG_MIN=1, AGG_MAX, AGG_COUNT };
00105
00106
00113 class ServerConnection {
00114 public:
00115 friend class Job;
00116
00117 ServerConnection(void);
00118
00119
00120
00121
00122 ServerConnection(const std::string &);
00123
00125 void open(const std::string &);
00126
00128 void close(void);
00129
00130
00131
00132
00133
00134
00135 void setQueryServer(const std::string&, int);
00136 void setQueryTimeout(int);
00137
00138 void setX509Proxy(const std::string&);
00139 void setX509Cert(const std::string&, const std::string&);
00140
00141 std::pair<std::string, int> getQueryServer() const;
00142 int getQueryTimeout() const;
00143
00144 std::string getX509Proxy() const;
00145 std::pair<std::string, std::string> getX509Cert() const;
00146
00147
00148
00149 virtual ~ServerConnection();
00150
00151
00152
00153
00155 std::pair<std::vector<QueryRecord::Attr>,
00156 std::vector<std::string> > getIndexedAttrs(void);
00157
00159 std::pair<int,int> getLimits(void) const;
00160
00162 void setQueryJobsLimit(int);
00163 void setQueryEventsLimit(int);
00164
00170 void queryEvents(const std::vector<QueryRecord>& job_cond,
00171 const std::vector<QueryRecord>& event_cond,
00172 std::vector<Event>&) const;
00173
00174 const std::vector<Event> queryEvents(const std::vector<QueryRecord>& job_cond,
00175 const std::vector<QueryRecord>& event_cond) const;
00176
00177 const std::list<Event> queryEventsList(const std::vector<QueryRecord>& job_cond,
00178 const std::vector<QueryRecord>& event_cond) const;
00179
00180
00187 std::string queryEventsAggregate(const std::vector<QueryRecord>& job_cond,
00188 const std::vector<QueryRecord>& event_cond,
00189 enum AggOp const op,
00190 std::string const attr) const;
00191
00192
00199 void queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00200 const std::vector<std::vector<QueryRecord> >& event_cond,
00201 std::vector<Event>&) const;
00202
00203 const std::vector<Event>
00204 queryEvents(const std::vector<std::vector<QueryRecord> >& job_cond,
00205 const std::vector<std::vector<QueryRecord> >& event_cond) const;
00206
00207
00215 void queryJobs(const std::vector<QueryRecord>& query,
00216 std::vector<edg::workload::common::jobid::JobId>& ids) const;
00217
00218 const std::vector<edg::workload::common::jobid::JobId>
00219 queryJobs(const std::vector<QueryRecord>& query) const;
00220
00221
00229 void queryJobs(const std::vector<std::vector<QueryRecord> >& query,
00230 std::vector<edg::workload::common::jobid::JobId>& ids) const;
00231
00232 const std::vector<edg::workload::common::jobid::JobId>
00233 queryJobs(const std::vector<std::vector<QueryRecord> >& query) const;
00234
00242 void queryJobStates(const std::vector<QueryRecord>& query,
00243 int flags,
00244 std::vector<JobStatus> & states) const;
00245 const std::vector<JobStatus> queryJobStates(const std::vector<QueryRecord>& query,
00246 int flags) const;
00247
00248 const std::list<JobStatus> queryJobStatesList(const std::vector<QueryRecord>& query,
00249 int flags) const;
00250
00258 void queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00259 int flags,
00260 std::vector<JobStatus> & states) const;
00261 const std::vector<JobStatus>
00262 queryJobStates(const std::vector<std::vector<QueryRecord> >& query,
00263 int flags) const;
00264
00268 void userJobStates(std::vector<JobStatus>& stateList) const;
00269 const std::vector<JobStatus> userJobStates() const;
00270
00271
00275 void userJobs(std::vector<edg::workload::common::jobid::JobId> &) const;
00276 const std::vector<edg::workload::common::jobid::JobId> userJobs() const;
00277
00278 protected:
00279
00280 edg_wll_Context getContext(void) const;
00281
00282 private:
00283 edg_wll_Context context;
00284 };
00285
00286 EWL_END_NAMESPACE;
00287
00288 #endif