Merged with code in the infnforge repository
authorElisabetta Ronchieri <elisabetta.ronchieri@cnaf.infn.it>
Mon, 31 May 2004 14:03:30 +0000 (14:03 +0000)
committerElisabetta Ronchieri <elisabetta.ronchieri@cnaf.infn.it>
Mon, 31 May 2004 14:03:30 +0000 (14:03 +0000)
13 files changed:
org.glite.wms-utils.jobid/configure.ac
org.glite.wms-utils.jobid/src/jobid/JobId.cpp
org.glite.wms-utils.jobid/src/jobid/JobId.h
org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.cpp
org.glite.wms-utils.jobid/src/jobid/JobIdExceptions.h
org.glite.wms-utils.jobid/src/jobid/Makefile.am
org.glite.wms-utils.jobid/src/jobid/jobid.c
org.glite.wms-utils.jobid/src/jobid/jobid.h [new file with mode: 0755]
org.glite.wms-utils.jobid/src/jobid/manipulation.cpp
org.glite.wms-utils.jobid/src/jobid/manipulation.h
org.glite.wms-utils.jobid/src/jobid/strmd5.c
org.glite.wms-utils.jobid/test/Makefile.am
org.glite.wms-utils.jobid/test/testjobid.c

index 96f94ff..7378bf2 100755 (executable)
@@ -19,6 +19,9 @@
 #
 #       Revision history:
 #       $Log$
+#       Revision 1.1.1.1  2004/05/26 18:45:05  eronchie
+#       Import of wms jobid
+#
 #
 #
                                                                                                                                                              
@@ -53,11 +56,11 @@ AC_SUBST([BOOST_CPPFLAGS])
 BOOST_LIBS="-L$REPOSITORY/boost/1.29.1/rhel30_gcc32/lib/release -lboost_fs -lboost_thread -lpthread -lboost_regex -lc"
 AC_SUBST([BOOST_LIBS])
 
-CLASSAD_CFLAGS=-I$REPOSITORY/classads/0.9.4/rhel30_gcc32/include
+CLASSAD_CFLAGS=-I$REPOSITORY/classads/0.9.5/rhel30_gcc32/include
 AC_SUBST([CLASSAD_CFLAGS])
 CLASSAD_CPPFLAGS=$CLASSAD_CFLAGS
 AC_SUBST([CLASSAD_CPPFLAGS])
-CLASSAD_LIBS="-L$REPOSITORY/classads/0.9.4/rhel30_gcc32/lib -lclassad"
+CLASSAD_LIBS="-L$REPOSITORY/classads/0.9.5/rhel30_gcc32/lib -lclassad"
 AC_SUBST([CLASSAD_LIBS])
 
 GLOBUS_SSL_UTILS_CFLAGS="-I$STAGE/include"
@@ -67,7 +70,7 @@ AC_SUBST([GLOBUS_SSL_UTILS_CFLAGS])
 
 GLITE_WORKLOAD_CFLAGS="-I$STAGE/include"
 AC_SUBST([GLITE_WORKLOAD_CFLAGS])
-GLITE_WORKLOAD_COMMON_LIBS="-L$STAGE/lib -lglite_wl_exceptions"
+GLITE_WORKLOAD_COMMON_LIBS="-L$STAGE/lib -lglite_wms_exceptions"
 AC_SUBST([GLITE_WORKLOAD_COMMON_LIBS])
 
 GLOBUS_COMMON_NOTHR_LIBS="-L$REPOSITORY/globus/2.4.3/rhel30_gcc32/lib -lglobus_common_gcc32"
index 476042f..f4da626 100755 (executable)
@@ -4,10 +4,11 @@
  *  copyright : (C) 2002 by DATAMAT
  ***************************************************************************/
 
-#include "../jobid/JobId.h"
+#include "JobId.h"
+
 #include <iostream>
-#include "../jobid/JobIdExceptions.h"
 
+#include "JobIdExceptions.h"
 
 COMMON_NAMESPACE_BEGIN{
 namespace jobid{
index 0caf5a1..036d2ec 100755 (executable)
 #include <iosfwd>
 
 #include "../jobid_namespace.h"
-#include "../jobid/jobid-c.h"
+#include "jobid.h"
 
 typedef struct _edg_wlc_jobid_s* edg_wlc_jobid_t;
-
 #define COMMON_JOBID_NAMESPACE_BEGIN namespace edg { namespace workload { namespace common {namespace jobid{
 COMMON_JOBID_NAMESPACE_BEGIN
 /**
index c5f19f4..06b12fc 100755 (executable)
@@ -3,7 +3,8 @@
 *  author    : Alessandro Maraschini <alessandro.maraschini@datamat.it>
 *  copyright : (C) 2002 by DATAMAT
 ***************************************************************************/
-#include "../jobid/JobIdExceptions.h"
+
+#include "JobIdExceptions.h"
 
 COMMON_NAMESPACE_BEGIN{
 namespace jobid{
index 87edb6b..be0b053 100755 (executable)
@@ -5,7 +5,7 @@
  * JobIdExceptions.h
  * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
  */
-#include "glite/workload/common/utilities/Exceptions.h"
+#include "glite/wms/common/utilities/Exceptions.h"
 
 #define COMMON_JOBID_NAMESPACE_BEGIN namespace edg { namespace workload { namespace common {namespace jobid{
 COMMON_JOBID_NAMESPACE_BEGIN
index 7f13c02..55f855d 100755 (executable)
@@ -6,26 +6,27 @@
 ## *
 ## *********************************************************************
 
-lib_LTLIBRARIES = libglite_wl_jobid.la
+lib_LTLIBRARIES = libglite_wms_jobid.la
 
-libglite_wl_jobid_la_SOURCES = \
+libglite_wms_jobid_la_SOURCES = \
        JobId.cpp \
        JobIdExceptions.cpp \
        manipulation.cpp \
        jobid.c \
        strmd5.c
 
-jobidincludedir = $(includedir)/glite/workload/jobid
+jobidincludedir = $(includedir)/glite/wms/jobid
 jobidinclude_HEADERS = \
        JobId.h \
        JobIdExceptions.h \
-       jobid-c.h \
+       jobid.h \
        manipulation.h \
        strmd5.h
 
 AM_CPPFLAGS = -I$(top_srcdir)/.. \
-       $(GLOBUS_CFLAGS) $(BOOST_CFLAGS) \
        $(GLITE_WORKLOAD_CFLAGS) \
+       $(GLOBUS_CFLAGS) \
+       $(BOOST_CFLAGS) \
        -D_GNU_SOURCE
 
 MAINTAINERCLEANFILES = Makefile.in
index a9dcd1d..1434286 100755 (executable)
@@ -10,8 +10,8 @@
 #include <sys/time.h>
 #include <unistd.h>
 
-#include "../jobid/jobid-c.h"
-#include "../jobid/strmd5.h"
+#include "jobid.h"
+#include "strmd5.h"
 
 struct _edg_wlc_JobId {
     char               *id;    /* unique job identification */
@@ -40,16 +40,18 @@ int edg_wlc_JobIdRecreate(const char* bkserver, int port, const char *unique, ed
     if (!bkserver)
         return EINVAL;
 
-    gethostname(hostname, 100);
-    he = gethostbyname(hostname);
-    assert(he->h_length > 0);
-    gettimeofday(&tv, NULL);
-    srandom(tv.tv_usec);
+    if (unique == NULL) {
+       gethostname(hostname, 100);
+       he = gethostbyname(hostname);
+       assert(he->h_length > 0);
+       gettimeofday(&tv, NULL);
+       srandom(tv.tv_usec);
 
-    skip = strlen(hostname);
-    skip += sprintf(hostname + skip, "-IP:0x%x-pid:%d-rnd:%d-time:%d:%d",
+       skip = strlen(hostname);
+       skip += sprintf(hostname + skip, "-IP:0x%x-pid:%d-rnd:%d-time:%d:%d",
                    *((int*)he->h_addr_list[0]), getpid(), (int)random(),
                    (int)tv.tv_sec, (int)tv.tv_usec);
+    }
 
     *jobId = NULL;
     out = (edg_wlc_JobId) malloc (sizeof(*out));
@@ -178,6 +180,18 @@ int edg_wlc_JobIdParse(const char *idString, edg_wlc_JobId *jobId)
     /* extract the unique part */
     out->id = strdup(pom1+1);
 
+    for (pom1 = out->BShost; *pom1; pom1++)
+       if (isspace(*pom1)) break;
+
+    for (pom2 = out->id; *pom2; pom2++)
+       if (isspace(*pom2)) break;
+
+    if (*pom1 || *pom2) {
+           free(pom);
+           edg_wlc_JobIdFree(out);
+           return EINVAL;
+    }
+
     free(pom);
     *jobId = out;
     return 0;
diff --git a/org.glite.wms-utils.jobid/src/jobid/jobid.h b/org.glite.wms-utils.jobid/src/jobid/jobid.h
new file mode 100755 (executable)
index 0000000..6f3e345
--- /dev/null
@@ -0,0 +1,109 @@
+#ifndef _EDG_JOBID_H
+#define _EDG_JOBID_H
+
+/*!
+ * \file jobid/jobid.h
+ * \brief L&B consumer API
+ */
+
+#ident "$Header$"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _edg_wlc_JobId *edg_wlc_JobId;
+
+#define EDG_WLC_JOBID_DEFAULT_PORT 9000 /**< Default port where bookkeeping server listens */
+#define EDG_WLC_JOBID_PROTO_PREFIX "https://" /**< JobId protocol prefix */
+
+
+/* All the pointer functions return malloc'ed objects (or NULL on error) */
+
+/**
+ * Create a Job ID.
+ * See the lb_draft document for details on its construction and components
+ * \param bkserver book keeping server hostname
+ * \param port port for the bk service
+ * \param jobid new created job id
+ * \ret al 0 success
+ * \retval EINVAL invalid bkserver
+ * \retval ENOMEM if memory allocation fails
+ */
+int edg_wlc_JobIdCreate(const char * bkserver, int port, edg_wlc_JobId * jobid);
+
+/**
+ * Recreate a Job ID
+ * \param bkserver bookkeeping server hostname
+ * \param port port for the bk service
+ * \param unique string which represent created jobid (if NULL then new
+ * one is created)
+ * \param jobid new created job id
+ * \retval 0 success
+ * \retval EINVAL invalid bkserver
+ * \retval ENOMEM if memory allocation fails
+ */
+int edg_wlc_JobIdRecreate(const char *bkserver, int port, const char * unique, edg_wlc_JobId * jobid);
+
+/**
+ * Create copy of Job ID
+ * \param in jobid for duplication
+ * \param jobid  duplicated jobid
+ * \retval 0 for success
+ * \retval EINVAL invalid jobid
+ * \retval ENOMEM if memory allocation fails
+ */
+int edg_wlc_JobIdDup(const edg_wlc_JobId in, edg_wlc_JobId * jobid);
+
+/*
+ * Free jobid structure
+ * \param jobid for dealocation
+ */
+void edg_wlc_JobIdFree(edg_wlc_JobId jobid);
+
+/**
+ * Parse Job ID string and creates jobid structure
+ * \param jobidstr string representation of jobid
+ * \param jobid parsed job id
+ * \retval 0 for success
+ * \retval EINVAL jobidstr can't be parsed
+ * \retval ENOMEM if memory allocation fails
+ */
+int edg_wlc_JobIdParse(const char* jobidstr, edg_wlc_JobId * jobid);
+
+/**
+ * Unparse Job ID (produce the string form of JobId).
+ * \param jobid to be converted to string
+ * \return allocated string which represents jobid
+ */
+char* edg_wlc_JobIdUnparse(const edg_wlc_JobId jobid);
+
+/**
+ * Extract bookkeeping server address (address:port)
+ * \param jobid from which the bkserver address should be extracted
+ * \retval pointer to allocated string with bkserver address
+ * \retval NULL if jobid is 0 or memory allocation fails
+ */
+char* edg_wlc_JobIdGetServer(const edg_wlc_JobId jobid);
+
+/**
+ * Extract bookkeeping server address and port
+ * \param jobid from which the bkserver address should be extracted
+ * \param srvName pointer where to return server name
+ * \param srvPort pointer where to return server port
+ *     */
+void edg_wlc_JobIdGetServerParts(const edg_wlc_JobId jobid, char **srvName, unsigned int *srvPort);
+
+/**
+ * Extract unique string 
+ * \param jobid
+ * \retval pointer to allocated unique string representing jobid
+ * \retval NULL if jobid is 0 or memory allocation fails
+ */
+char* edg_wlc_JobIdGetUnique(const edg_wlc_JobId jobid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _EDG_JOBID_H */
index 38ddca6..39af4e6 100755 (executable)
@@ -4,7 +4,7 @@
 #include <algorithm>
 
 #include "../jobid_namespace.h"
-#include "../jobid/JobId.h"
+#include "JobId.h"
 
 using namespace std;
 
index d00dfbc..f0596c0 100755 (executable)
@@ -3,7 +3,7 @@
 
 #include <string>
 
-#include "../common_namespace.h"
+#include "edg/workload/common/common_namespace.h"
 
 COMMON_NAMESPACE_BEGIN {
 
index a4f483e..cec7ef5 100755 (executable)
@@ -1,9 +1,9 @@
 #ident "$Header$"
 
+#include <openssl/md5.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <openssl/md5.h>
 
 #include "../jobid/strmd5.h"
 
index 2480d5d..93909e7 100755 (executable)
@@ -8,13 +8,13 @@
 
 STDCPP = -lstdc++
 
-WL_JOBID_TEST = testjobid 
+JOBID = $(top_builddir)/src/jobid/libglite_wms_jobid.la
 
-check_PROGRAMS = $(WL_JOBID_TEST) 
+check_PROGRAMS = testjobid 
 
 testjobid_SOURCES = testjobid.c
 testjobid_LDADD = \
-       $(top_builddir)/src/jobid/libglite_wl_jobid.la \
+       $(JOBID) \
        $(GLITE_WORKLOAD_COMMON_LIBS) \
        $(GLOBUS_LIBS) \
        $(STDCPP)
index 5f2ea54..30169f9 100755 (executable)
@@ -3,7 +3,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "../src/jobid/jobid-c.h"
+#include "../src/jobid.h"
 
 int main(int argc, char* argv[])
 {