-
Notifications
You must be signed in to change notification settings - Fork 0
/
gridftp-hdfs-classpath.patch
88 lines (85 loc) · 2.12 KB
/
gridftp-hdfs-classpath.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
diff -u -r gridftp-hdfs-0.5.4.orig/src/gridftp_hdfs.c gridftp-hdfs-0.5.4/src/gridftp_hdfs.c
--- gridftp-hdfs-0.5.4.orig/src/gridftp_hdfs.c 2013-07-18 09:36:45.874071731 -0400
+++ gridftp-hdfs-0.5.4/src/gridftp_hdfs.c 2013-07-18 09:36:23.388071731 -0400
@@ -10,6 +10,8 @@
#include <sys/syscall.h>
#include <signal.h>
#include <execinfo.h>
+#define __USE_XOPEN_EXTENDED
+#include <ftw.h>
#include "gridftp_hdfs.h"
@@ -137,6 +139,52 @@
}
}
+static char *hdfs_classpath = NULL;
+
+static
+int
+hdfs_add_jar(
+ const char * pathname,
+ const struct stat *statbuf,
+ int type,
+ struct FTW *info)
+{
+ long envmax = sysconf(_SC_ARG_MAX);
+ char * ext;
+
+ if (hdfs_classpath == NULL)
+ {
+ if (envmax < 0)
+ {
+ envmax = 4096;
+ }
+
+ hdfs_classpath = malloc(envmax);
+ if (hdfs_classpath == NULL)
+ {
+ globus_gfs_log_message(GLOBUS_GFS_LOG_ERR, "Unable to allocate classpath");
+ return ENOMEM;
+ }
+ hdfs_classpath[0] = 0;
+ }
+ if (type != FTW_F)
+ {
+ return 0;
+ }
+ if ((strlen(hdfs_classpath) + strlen(pathname) + 2) > envmax)
+ {
+ globus_gfs_log_message(GLOBUS_GFS_LOG_ERR, "Unable to populate classpath");
+ return E2BIG;
+ }
+ ext = strrchr(pathname, '.');
+ if (ext && strcmp(ext, ".jar") == 0)
+ {
+ strcat(hdfs_classpath, pathname);
+ strcat(hdfs_classpath, ":");
+ }
+ return 0;
+}
+
/*
* Called when the HDFS module is activated.
* Completely boilerplate.
@@ -144,6 +192,22 @@
int
hdfs_activate(void)
{
+ const char *hadoopdir = "/usr/lib/hadoop";
+ const char *hdfsdir = "/usr/lib/hadoop-hdfs";
+ char *cp=NULL;
+ size_t cplen = 0;
+
+ nftw(hadoopdir, hdfs_add_jar, 4, FTW_PHYS);
+ nftw(hdfsdir, hdfs_add_jar, 4, FTW_PHYS);
+ if (hdfs_classpath != NULL)
+ {
+ if (strlen(hdfs_classpath) > 1)
+ {
+ hdfs_classpath[strlen(hdfs_classpath)-1] = 0;
+ }
+ setenv("CLASSPATH", hdfs_classpath, 1);
+ }
+
globus_extension_registry_add(
GLOBUS_GFS_DSI_REGISTRY,
"hdfs",