extern "C" {
#endif
+#define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000"
+#define EDG_WLL_SEQ_SIZE 103 /* strlen(EDG_WLL_SEQ_NULL)+1 */
+#define EDG_WLL_SEQ_PBS_SIZE 47 /* strlen(EDG_WLL_SEQ_PBS_NULL)+1 */
+
typedef struct _edg_wll_SeqCode {
unsigned int type; /* seq code type */
unsigned int c[EDG_WLL_SOURCE__LAST]; /* glite seq. code */
- char pbs[18]; /* PBS seq. code */
- /* 0-7 date YYYYMMDD, 8-17 byte in log file */
+ char pbs[EDG_WLL_SEQ_PBS_SIZE]; /* PBS seq. code */
+ /* 0-25 TIMESTAMP=YYYYMMDDHHMMSS: */
+ /* 26-41 POS=%010u: */
+ /* 42-46 SRC=%c */
+
} edg_wll_SeqCode;
-#define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000"
-#define EDG_WLL_SEQ_SIZE 103 /* strlen(EDG_WLL_SEQ_NULL)+1 */
-
/* non-gsi one-element analogy of connPool for L&B Proxy server */
typedef struct _edg_wll_ConnProxy {
edg_wll_PlainConnection conn;
return(0);
}
+int edg_wll_compare_pbs_seq(const char *a, const char *b)
+{
+ char timestamp_a[14], pos_a[10], src_a;
+ char timestamp_b[14], pos_b[10], src_b;
+ int res;
+
+ res = sscanf(a,"TIMESTAMP=%14s:POS=%10s:SRC=%c", ×tamp_a, &pos_a, &src_a);
+
+ if (res != 3) {
+ syslog(LOG_ERR, "unparsable sequence code %s\n", a);
+ fprintf(stderr, "unparsable sequence code %s\n", a);
+ return -1;
+ }
+
+ res = sscanf(b,"TIMESTAMP=%14s:POS=%10s:SRC=%c", ×tamp_b, &pos_b, &src_b);
+
+ if (res != 3) {
+ syslog(LOG_ERR, "unparsable sequence code %s\n", b);
+ fprintf(stderr, "unparsable sequence code %s\n", b);
+ return -1;
+ }
+
+
+ /* sort event w.t.r. to timestamps */
+ if ((res = strcmp(timestamp_a,timestamp_b)) != 0) {
+ return res;
+ }
+ else {
+ /* if timestamps equal, sort if w.t.r. to file position */
+ /* if you both events come from the same log file */
+ if (src_a == src_b) {
+ /* zero mean in fact duplicate events in log */
+ return strcmp(pos_a,pos_b);
+ }
+ /* if the events come from diffrent log files */
+ /* it is possible to prioritize some src log file */
+ else {
+ /* prioritize events from pbs_mom */
+ if (src_a == 'm') return 1;
+ if (src_b == 'm') return -1;
+
+ /* other priorities comes here... */
+ }
+ }
+
+ return 0;
+}
+
int edg_wll_compare_seq(const char *a, const char *b)
{
unsigned int c[EDG_WLL_SOURCE__LAST];
int res, i;
char sca[EDG_WLL_SEQ_SIZE], scb[EDG_WLL_SEQ_SIZE];
+
+ if ( (strstr(a,"TIMESTAMP=") == a) && (strstr(b,"TIMESTAMP=") == b) )
+ return edg_wll_compare_pbs_seq(a,b);
+
if (!strstr(a, "LBS")) snprintf(sca,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",a);
else snprintf(sca,EDG_WLL_SEQ_SIZE,"%s",a);
if (!strstr(b, "LBS")) snprintf(scb,EDG_WLL_SEQ_SIZE,"%s:LBS=000000",b);
return 0;
}
-static int compare_pbs_seqcodes(char *a, char *b)
-{
- return (strcmp(a,b)); // simple minded, but should work
-}
// XXX move this defines into some common place to be reusable
#define USABLE(res) ((res) == RET_OK)
//if (compare_timestamps(js->last_pbs_event_timestamp, e->any.timestamp) > 0)
if ((js->last_seqcode != NULL) &&
- (compare_pbs_seqcodes(js->last_seqcode, e->any.seqcode) > 0) ) {
+ (edg_wll_compare_pbs_seq(js->last_seqcode, e->any.seqcode) > 0) ) {
res = RET_LATE;
}