|
@@ -19,16 +19,6 @@
|
|
|
|
|
|
package org.elasticsearch.repositories.hdfs;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.net.InetSocketAddress;
|
|
|
-import java.nio.file.Files;
|
|
|
-import java.nio.file.Path;
|
|
|
-import java.security.AccessController;
|
|
|
-import java.security.PrivilegedActionException;
|
|
|
-import java.security.PrivilegedExceptionAction;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.ha.BadFencingConfigurationException;
|
|
|
import org.apache.hadoop.ha.HAServiceProtocol;
|
|
@@ -46,6 +36,16 @@ import org.elasticsearch.common.io.PathUtils;
|
|
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
|
|
import org.junit.Assert;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.security.AccessController;
|
|
|
+import java.security.PrivilegedActionException;
|
|
|
+import java.security.PrivilegedExceptionAction;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* Integration test that runs against an HA-Enabled HDFS instance
|
|
|
*/
|
|
@@ -57,13 +57,24 @@ public class HaHdfsFailoverTestSuiteIT extends ESRestTestCase {
|
|
|
String esKerberosPrincipal = System.getProperty("test.krb5.principal.es");
|
|
|
String hdfsKerberosPrincipal = System.getProperty("test.krb5.principal.hdfs");
|
|
|
String kerberosKeytabLocation = System.getProperty("test.krb5.keytab.hdfs");
|
|
|
+ String ports = System.getProperty("test.hdfs-fixture.ports");
|
|
|
+ String nn1Port = "10001";
|
|
|
+ String nn2Port = "10002";
|
|
|
+ if (ports.length() > 0) {
|
|
|
+ final Path path = PathUtils.get(ports);
|
|
|
+ final List<String> lines = AccessController.doPrivileged((PrivilegedExceptionAction<List<String>>) () -> {
|
|
|
+ return Files.readAllLines(path);
|
|
|
+ });
|
|
|
+ nn1Port = lines.get(0);
|
|
|
+ nn2Port = lines.get(1);
|
|
|
+ }
|
|
|
boolean securityEnabled = hdfsKerberosPrincipal != null;
|
|
|
|
|
|
Configuration hdfsConfiguration = new Configuration();
|
|
|
hdfsConfiguration.set("dfs.nameservices", "ha-hdfs");
|
|
|
hdfsConfiguration.set("dfs.ha.namenodes.ha-hdfs", "nn1,nn2");
|
|
|
- hdfsConfiguration.set("dfs.namenode.rpc-address.ha-hdfs.nn1", "localhost:10001");
|
|
|
- hdfsConfiguration.set("dfs.namenode.rpc-address.ha-hdfs.nn2", "localhost:10002");
|
|
|
+ hdfsConfiguration.set("dfs.namenode.rpc-address.ha-hdfs.nn1", "localhost:" + nn1Port);
|
|
|
+ hdfsConfiguration.set("dfs.namenode.rpc-address.ha-hdfs.nn2", "localhost:" + nn2Port);
|
|
|
hdfsConfiguration.set(
|
|
|
"dfs.client.failover.proxy.provider.ha-hdfs",
|
|
|
"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider"
|
|
@@ -110,8 +121,8 @@ public class HaHdfsFailoverTestSuiteIT extends ESRestTestCase {
|
|
|
securityCredentials(securityEnabled, esKerberosPrincipal) +
|
|
|
"\"conf.dfs.nameservices\": \"ha-hdfs\"," +
|
|
|
"\"conf.dfs.ha.namenodes.ha-hdfs\": \"nn1,nn2\"," +
|
|
|
- "\"conf.dfs.namenode.rpc-address.ha-hdfs.nn1\": \"localhost:10001\"," +
|
|
|
- "\"conf.dfs.namenode.rpc-address.ha-hdfs.nn2\": \"localhost:10002\"," +
|
|
|
+ "\"conf.dfs.namenode.rpc-address.ha-hdfs.nn1\": \"localhost:"+nn1Port+"\"," +
|
|
|
+ "\"conf.dfs.namenode.rpc-address.ha-hdfs.nn2\": \"localhost:"+nn2Port+"\"," +
|
|
|
"\"conf.dfs.client.failover.proxy.provider.ha-hdfs\": " +
|
|
|
"\"org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider\"" +
|
|
|
"}" +
|