1717 */
1818
1919#include "exception.h"
20- #include "jclasses.h"
2120#include "jni_helper.h"
2221#include "native_mini_dfs.h"
2322#include "platform.h"
3736
3837#define MINIDFS_CLUSTER_BUILDER "org/apache/hadoop/hdfs/MiniDFSCluster$Builder"
3938#define MINIDFS_CLUSTER "org/apache/hadoop/hdfs/MiniDFSCluster"
39+ #define HADOOP_CONF "org/apache/hadoop/conf/Configuration"
4040#define HADOOP_NAMENODE "org/apache/hadoop/hdfs/server/namenode/NameNode"
41+ #define JAVA_INETSOCKETADDRESS "java/net/InetSocketAddress"
4142
4243struct NativeMiniDfsCluster {
4344 /**
@@ -59,7 +60,8 @@ static int hdfsDisableDomainSocketSecurity(void)
5960 errno = EINTERNAL ;
6061 return -1 ;
6162 }
62- jthr = invokeMethod (env , NULL , STATIC , NULL , JC_DOMAIN_SOCKET ,
63+ jthr = invokeMethod (env , NULL , STATIC , NULL ,
64+ "org/apache/hadoop/net/unix/DomainSocket" ,
6365 "disableBindPathValidation" , "()V" );
6466 if (jthr ) {
6567 errno = printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -124,6 +126,11 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
124126 "nmdCreate: new Configuration" );
125127 goto error ;
126128 }
129+ if (jthr ) {
130+ printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
131+ "nmdCreate: Configuration::setBoolean" );
132+ goto error ;
133+ }
127134 // Disable 'minimum block size' -- it's annoying in tests.
128135 (* env )-> DeleteLocalRef (env , jconfStr );
129136 jconfStr = NULL ;
@@ -133,9 +140,8 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
133140 "nmdCreate: new String" );
134141 goto error ;
135142 }
136- jthr = invokeMethod (env , NULL , INSTANCE , cobj ,
137- JC_CONFIGURATION , "setLong" , "(Ljava/lang/String;J)V" , jconfStr ,
138- 0LL );
143+ jthr = invokeMethod (env , NULL , INSTANCE , cobj , HADOOP_CONF ,
144+ "setLong" , "(Ljava/lang/String;J)V" , jconfStr , 0LL );
139145 if (jthr ) {
140146 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
141147 "nmdCreate: Configuration::setLong" );
@@ -157,7 +163,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
157163 goto error ;
158164 }
159165 }
160- jthr = findClassAndInvokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
166+ jthr = invokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
161167 "format" , "(Z)L" MINIDFS_CLUSTER_BUILDER ";" , conf -> doFormat );
162168 if (jthr ) {
163169 printExceptionAndFree (env , jthr , PRINT_EXC_ALL , "nmdCreate: "
@@ -166,7 +172,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
166172 }
167173 (* env )-> DeleteLocalRef (env , val .l );
168174 if (conf -> webhdfsEnabled ) {
169- jthr = findClassAndInvokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
175+ jthr = invokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
170176 "nameNodeHttpPort" , "(I)L" MINIDFS_CLUSTER_BUILDER ";" ,
171177 conf -> namenodeHttpPort );
172178 if (jthr ) {
@@ -177,7 +183,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
177183 (* env )-> DeleteLocalRef (env , val .l );
178184 }
179185 if (conf -> numDataNodes ) {
180- jthr = findClassAndInvokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
186+ jthr = invokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
181187 "numDataNodes" , "(I)L" MINIDFS_CLUSTER_BUILDER ";" , conf -> numDataNodes );
182188 if (jthr ) {
183189 printExceptionAndFree (env , jthr , PRINT_EXC_ALL , "nmdCreate: "
@@ -186,7 +192,7 @@ struct NativeMiniDfsCluster* nmdCreate(struct NativeMiniDfsConf *conf)
186192 }
187193 }
188194 (* env )-> DeleteLocalRef (env , val .l );
189- jthr = findClassAndInvokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
195+ jthr = invokeMethod (env , & val , INSTANCE , bld , MINIDFS_CLUSTER_BUILDER ,
190196 "build" , "()L" MINIDFS_CLUSTER ";" );
191197 if (jthr ) {
192198 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -236,7 +242,7 @@ int nmdShutdown(struct NativeMiniDfsCluster* cl)
236242 fprintf (stderr , "nmdShutdown: getJNIEnv failed\n" );
237243 return - EIO ;
238244 }
239- jthr = findClassAndInvokeMethod (env , NULL , INSTANCE , cl -> obj ,
245+ jthr = invokeMethod (env , NULL , INSTANCE , cl -> obj ,
240246 MINIDFS_CLUSTER , "shutdown" , "()V" );
241247 if (jthr ) {
242248 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -254,7 +260,7 @@ int nmdWaitClusterUp(struct NativeMiniDfsCluster *cl)
254260 fprintf (stderr , "nmdWaitClusterUp: getJNIEnv failed\n" );
255261 return - EIO ;
256262 }
257- jthr = findClassAndInvokeMethod (env , NULL , INSTANCE , cl -> obj ,
263+ jthr = invokeMethod (env , NULL , INSTANCE , cl -> obj ,
258264 MINIDFS_CLUSTER , "waitClusterUp" , "()V" );
259265 if (jthr ) {
260266 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -276,7 +282,7 @@ int nmdGetNameNodePort(const struct NativeMiniDfsCluster *cl)
276282 }
277283 // Note: this will have to be updated when HA nativeMiniDfs clusters are
278284 // supported
279- jthr = findClassAndInvokeMethod (env , & jVal , INSTANCE , cl -> obj ,
285+ jthr = invokeMethod (env , & jVal , INSTANCE , cl -> obj ,
280286 MINIDFS_CLUSTER , "getNameNodePort" , "()I" );
281287 if (jthr ) {
282288 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -301,7 +307,7 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
301307 return - EIO ;
302308 }
303309 // First get the (first) NameNode of the cluster
304- jthr = findClassAndInvokeMethod (env , & jVal , INSTANCE , cl -> obj , MINIDFS_CLUSTER ,
310+ jthr = invokeMethod (env , & jVal , INSTANCE , cl -> obj , MINIDFS_CLUSTER ,
305311 "getNameNode" , "()L" HADOOP_NAMENODE ";" );
306312 if (jthr ) {
307313 printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
@@ -312,8 +318,8 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
312318 jNameNode = jVal .l ;
313319
314320 // Then get the http address (InetSocketAddress) of the NameNode
315- jthr = findClassAndInvokeMethod (env , & jVal , INSTANCE , jNameNode , HADOOP_NAMENODE ,
316- "getHttpAddress" , "()L" JAVA_NET_ISA ";" );
321+ jthr = invokeMethod (env , & jVal , INSTANCE , jNameNode , HADOOP_NAMENODE ,
322+ "getHttpAddress" , "()L" JAVA_INETSOCKETADDRESS ";" );
317323 if (jthr ) {
318324 ret = printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
319325 "nmdGetNameNodeHttpAddress: "
@@ -322,8 +328,8 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
322328 }
323329 jAddress = jVal .l ;
324330
325- jthr = findClassAndInvokeMethod (env , & jVal , INSTANCE , jAddress ,
326- JAVA_NET_ISA , "getPort" , "()I" );
331+ jthr = invokeMethod (env , & jVal , INSTANCE , jAddress ,
332+ JAVA_INETSOCKETADDRESS , "getPort" , "()I" );
327333 if (jthr ) {
328334 ret = printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
329335 "nmdGetNameNodeHttpAddress: "
@@ -332,7 +338,7 @@ int nmdGetNameNodeHttpAddress(const struct NativeMiniDfsCluster *cl,
332338 }
333339 * port = jVal .i ;
334340
335- jthr = findClassAndInvokeMethod (env , & jVal , INSTANCE , jAddress , JAVA_NET_ISA ,
341+ jthr = invokeMethod (env , & jVal , INSTANCE , jAddress , JAVA_INETSOCKETADDRESS ,
336342 "getHostName" , "()Ljava/lang/String;" );
337343 if (jthr ) {
338344 ret = printExceptionAndFree (env , jthr , PRINT_EXC_ALL ,
0 commit comments