|
@@ -17,6 +17,7 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
#include "exception.h"
|
|
#include "exception.h"
|
|
|
|
+#include "jclasses.h"
|
|
#include "jni_helper.h"
|
|
#include "jni_helper.h"
|
|
#include "native_mini_dfs.h"
|
|
#include "native_mini_dfs.h"
|
|
#include "platform.h"
|
|
#include "platform.h"
|
|
@@ -36,9 +37,7 @@
|
|
|
|
|
|
#define MINIDFS_CLUSTER_BUILDER "org/apache/hadoop/hdfs/MiniDFSCluster$Builder"
|
|
#define MINIDFS_CLUSTER_BUILDER "org/apache/hadoop/hdfs/MiniDFSCluster$Builder"
|
|
#define MINIDFS_CLUSTER "org/apache/hadoop/hdfs/MiniDFSCluster"
|
|
#define MINIDFS_CLUSTER "org/apache/hadoop/hdfs/MiniDFSCluster"
|
|
-#define HADOOP_CONF "org/apache/hadoop/conf/Configuration"
|
|
|
|
#define HADOOP_NAMENODE "org/apache/hadoop/hdfs/server/namenode/NameNode"
|
|
#define HADOOP_NAMENODE "org/apache/hadoop/hdfs/server/namenode/NameNode"
|
|
-#define JAVA_INETSOCKETADDRESS "java/net/InetSocketAddress"
|
|
|
|
|
|
|
|
struct NativeMiniDfsCluster {
|
|
struct NativeMiniDfsCluster {
|
|
/**
|
|
/**
|
|
@@ -60,8 +59,7 @@ static int hdfsDisableDomainSocketSecurity(void)
|
|
errno = EINTERNAL;
|
|
errno = EINTERNAL;
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- jthr = invokeMethod(env, NULL, STATIC, NULL,
|
|
|
|
- "org/apache/hadoop/net/unix/DomainSocket",
|
|
|
|
|
|
+ jthr = invokeMethod(env, NULL, STATIC, NULL, JC_DOMAIN_SOCKET,
|
|
"disableBindPathValidation", "()V");
|
|
"disableBindPathValidation", "()V");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
errno = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
errno = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -126,11 +124,6 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
"nmdCreate: new Configuration");
|
|
"nmdCreate: new Configuration");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if (jthr) {
|
|
|
|
- printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
|
|
- "nmdCreate: Configuration::setBoolean");
|
|
|
|
- goto error;
|
|
|
|
- }
|
|
|
|
// Disable 'minimum block size' -- it's annoying in tests.
|
|
// Disable 'minimum block size' -- it's annoying in tests.
|
|
(*env)->DeleteLocalRef(env, jconfStr);
|
|
(*env)->DeleteLocalRef(env, jconfStr);
|
|
jconfStr = NULL;
|
|
jconfStr = NULL;
|
|
@@ -140,8 +133,9 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
"nmdCreate: new String");
|
|
"nmdCreate: new String");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- jthr = invokeMethod(env, NULL, INSTANCE, cobj, HADOOP_CONF,
|
|
|
|
- "setLong", "(Ljava/lang/String;J)V", jconfStr, 0LL);
|
|
|
|
|
|
+ jthr = invokeMethod(env, NULL, INSTANCE, cobj,
|
|
|
|
+ JC_CONFIGURATION, "setLong", "(Ljava/lang/String;J)V", jconfStr,
|
|
|
|
+ 0LL);
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
"nmdCreate: Configuration::setLong");
|
|
"nmdCreate: Configuration::setLong");
|
|
@@ -163,7 +157,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- jthr = invokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
"format", "(Z)L" MINIDFS_CLUSTER_BUILDER ";", conf->doFormat);
|
|
"format", "(Z)L" MINIDFS_CLUSTER_BUILDER ";", conf->doFormat);
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL, "nmdCreate: "
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL, "nmdCreate: "
|
|
@@ -172,7 +166,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
}
|
|
}
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
if (conf->webhdfsEnabled) {
|
|
if (conf->webhdfsEnabled) {
|
|
- jthr = invokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
"nameNodeHttpPort", "(I)L" MINIDFS_CLUSTER_BUILDER ";",
|
|
"nameNodeHttpPort", "(I)L" MINIDFS_CLUSTER_BUILDER ";",
|
|
conf->namenodeHttpPort);
|
|
conf->namenodeHttpPort);
|
|
if (jthr) {
|
|
if (jthr) {
|
|
@@ -183,7 +177,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
}
|
|
}
|
|
if (conf->numDataNodes) {
|
|
if (conf->numDataNodes) {
|
|
- jthr = invokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
"numDataNodes", "(I)L" MINIDFS_CLUSTER_BUILDER ";", conf->numDataNodes);
|
|
"numDataNodes", "(I)L" MINIDFS_CLUSTER_BUILDER ";", conf->numDataNodes);
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL, "nmdCreate: "
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL, "nmdCreate: "
|
|
@@ -192,7 +186,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
(*env)->DeleteLocalRef(env, val.l);
|
|
- jthr = invokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &val, INSTANCE, bld, MINIDFS_CLUSTER_BUILDER,
|
|
"build", "()L" MINIDFS_CLUSTER ";");
|
|
"build", "()L" MINIDFS_CLUSTER ";");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -242,7 +236,7 @@ int nmdShutdown(struct NativeMiniDfsCluster* cl)
|
|
fprintf(stderr, "nmdShutdown: getJNIEnv failed\n");
|
|
fprintf(stderr, "nmdShutdown: getJNIEnv failed\n");
|
|
return -EIO;
|
|
return -EIO;
|
|
}
|
|
}
|
|
- jthr = invokeMethod(env, NULL, INSTANCE, cl->obj,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, NULL, INSTANCE, cl->obj,
|
|
MINIDFS_CLUSTER, "shutdown", "()V");
|
|
MINIDFS_CLUSTER, "shutdown", "()V");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -260,7 +254,7 @@ int nmdWaitClusterUp(struct NativeMiniDfsCluster *cl)
|
|
fprintf(stderr, "nmdWaitClusterUp: getJNIEnv failed\n");
|
|
fprintf(stderr, "nmdWaitClusterUp: getJNIEnv failed\n");
|
|
return -EIO;
|
|
return -EIO;
|
|
}
|
|
}
|
|
- jthr = invokeMethod(env, NULL, INSTANCE, cl->obj,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, NULL, INSTANCE, cl->obj,
|
|
MINIDFS_CLUSTER, "waitClusterUp", "()V");
|
|
MINIDFS_CLUSTER, "waitClusterUp", "()V");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -282,7 +276,7 @@ int nmdGetNameNodePort(const struct NativeMiniDfsCluster *cl)
|
|
}
|
|
}
|
|
// Note: this will have to be updated when HA nativeMiniDfs clusters are
|
|
// Note: this will have to be updated when HA nativeMiniDfs clusters are
|
|
// supported
|
|
// supported
|
|
- jthr = invokeMethod(env, &jVal, INSTANCE, cl->obj,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &jVal, INSTANCE, cl->obj,
|
|
MINIDFS_CLUSTER, "getNameNodePort", "()I");
|
|
MINIDFS_CLUSTER, "getNameNodePort", "()I");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -307,7 +301,7 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
|
|
return -EIO;
|
|
return -EIO;
|
|
}
|
|
}
|
|
// First get the (first) NameNode of the cluster
|
|
// First get the (first) NameNode of the cluster
|
|
- jthr = invokeMethod(env, &jVal, INSTANCE, cl->obj, MINIDFS_CLUSTER,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &jVal, INSTANCE, cl->obj, MINIDFS_CLUSTER,
|
|
"getNameNode", "()L" HADOOP_NAMENODE ";");
|
|
"getNameNode", "()L" HADOOP_NAMENODE ";");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
@@ -318,8 +312,8 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
|
|
jNameNode = jVal.l;
|
|
jNameNode = jVal.l;
|
|
|
|
|
|
// Then get the http address (InetSocketAddress) of the NameNode
|
|
// Then get the http address (InetSocketAddress) of the NameNode
|
|
- jthr = invokeMethod(env, &jVal, INSTANCE, jNameNode, HADOOP_NAMENODE,
|
|
|
|
- "getHttpAddress", "()L" JAVA_INETSOCKETADDRESS ";");
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &jVal, INSTANCE, jNameNode, HADOOP_NAMENODE,
|
|
|
|
+ "getHttpAddress", "()L" JAVA_NET_ISA ";");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
"nmdGetNameNodeHttpAddress: "
|
|
"nmdGetNameNodeHttpAddress: "
|
|
@@ -328,8 +322,8 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
|
|
}
|
|
}
|
|
jAddress = jVal.l;
|
|
jAddress = jVal.l;
|
|
|
|
|
|
- jthr = invokeMethod(env, &jVal, INSTANCE, jAddress,
|
|
|
|
- JAVA_INETSOCKETADDRESS, "getPort", "()I");
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &jVal, INSTANCE, jAddress,
|
|
|
|
+ JAVA_NET_ISA, "getPort", "()I");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
"nmdGetNameNodeHttpAddress: "
|
|
"nmdGetNameNodeHttpAddress: "
|
|
@@ -338,7 +332,7 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
|
|
}
|
|
}
|
|
*port = jVal.i;
|
|
*port = jVal.i;
|
|
|
|
|
|
- jthr = invokeMethod(env, &jVal, INSTANCE, jAddress, JAVA_INETSOCKETADDRESS,
|
|
|
|
|
|
+ jthr = findClassAndInvokeMethod(env, &jVal, INSTANCE, jAddress, JAVA_NET_ISA,
|
|
"getHostName", "()Ljava/lang/String;");
|
|
"getHostName", "()Ljava/lang/String;");
|
|
if (jthr) {
|
|
if (jthr) {
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|
|
ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
|