Skip to content

Commit 0e035aa

Browse files
Yu ZhangGitHub AE
authored andcommitted
LIHADOOP-69035: Add router address parameter to MountTableConverter (apache#74)
1 parent b2dcc41 commit 0e035aa

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

hadoop-li-internal/hadoop-li-tools/src/main/java/org/apache/hadoop/hdfs/tools/federation/MountTableConverter.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@
5858
*/
5959
public class MountTableConverter extends Configured {
6060
private static final Logger LOG = LoggerFactory.getLogger(MountTableConverter.class);
61-
static final String ROUTER_ADMIN_ADDRESS_FORMATTER = "%s-linkfs.grid.linkedin.com:%s";
61+
static final String ROUTER_ADMIN_ADDRESS_FORMATTER = "%s:%s";
6262
static final String RBF_NS_INDICATOR = "/THIS_IS_LINKFS";
6363
private final String rbfNsSuffix;
6464
private final String keytabPrincipal;
6565
private final String keytabPath;
66-
private final String clusterName;
66+
private final String routerAddr;
6767
private final Path mountConfigPath;
6868
private final boolean dryRun;
6969
private final boolean removeOld;
@@ -84,15 +84,16 @@ public class MountTableConverter extends Configured {
8484

8585
public static final Option RBF_NAMESPACE_SUFFIX = new Option("rbfNsSuffix", true, "RBF namespace suffix");
8686

87-
public static final Option CLUSTER_NAME = new Option("cluster", true, "Cluster name used to construct router admin address");
87+
public static final Option ROUTER_ADDRESS =
88+
new Option("routerAddr", true, "Router RPC address used to construct router admin address");
8889

8990
private static final Options OPTIONS = new Options().addOption(MOUNT_CONFIG_PATH)
9091
.addOption(KEYTAB_PRINCIPAL)
9192
.addOption(KEYTAB_PATH)
9293
.addOption(DRY_RUN)
9394
.addOption(REMOVE_OLD)
9495
.addOption(RBF_NAMESPACE_SUFFIX)
95-
.addOption(CLUSTER_NAME);
96+
.addOption(ROUTER_ADDRESS);
9697

9798
public static void main(String[] args) throws Exception {
9899
Configuration conf = new HdfsConfiguration();
@@ -105,12 +106,13 @@ public static void main(String[] args) throws Exception {
105106
String keytabPath = commandLine.getOptionValue(KEYTAB_PATH.getOpt());
106107
String rbfNsSuffix = commandLine.getOptionValue(RBF_NAMESPACE_SUFFIX.getOpt());
107108
Path mountConfigPath = new Path(commandLine.getOptionValue(MOUNT_CONFIG_PATH.getOpt()));
108-
String clusterName = commandLine.getOptionValue(CLUSTER_NAME.getOpt());
109+
String routerAddr = commandLine.getOptionValue(ROUTER_ADDRESS.getOpt());
109110
boolean dryRun = commandLine.hasOption(DRY_RUN.getOpt());
110111
boolean removeOld = commandLine.hasOption(REMOVE_OLD.getOpt());
111112

112113
MountTableConverter adminTool =
113-
new MountTableConverter(conf, keytabPrincipal, keytabPath, mountConfigPath, dryRun, removeOld, rbfNsSuffix, clusterName);
114+
new MountTableConverter(conf, keytabPrincipal, keytabPath, mountConfigPath, dryRun, removeOld, rbfNsSuffix,
115+
routerAddr);
114116
adminTool.initClient();
115117
adminTool.convert();
116118
} catch (ParseException ex) {
@@ -120,30 +122,29 @@ public static void main(String[] args) throws Exception {
120122
}
121123

122124
public MountTableConverter(Configuration conf, String keytabPrincipal, String keytabPath, Path mountConfigPath,
123-
boolean dryRun, boolean removeOld, String rbfNsSuffix, String clusterName) {
125+
boolean dryRun, boolean removeOld, String rbfNsSuffix, String routerAddr) {
124126
super(conf);
125127
this.keytabPrincipal = keytabPrincipal;
126128
this.keytabPath = keytabPath;
127129
this.mountConfigPath = mountConfigPath;
128130
this.dryRun = dryRun;
129131
this.removeOld = removeOld;
130132
this.rbfNsSuffix = rbfNsSuffix;
131-
this.clusterName = clusterName;
133+
this.routerAddr = routerAddr;
132134
}
133135

134136
public void initClient() throws IOException {
135137
// Load client's minimum set of configurations to use kerberos
136138
Configuration.addDefaultResource("router-client-security.xml");
137139

138-
if (this.clusterName != null) {
139-
// If clusterName is null, will fall back to use local configuration DFS_ROUTER_ADMIN_ADDRESS_KEY, if
140+
if (this.routerAddr != null) {
141+
// If routerAddr is null, will fall back to use local configuration DFS_ROUTER_ADMIN_ADDRESS_KEY, if
140142
// DFS_ROUTER_ADMIN_ADDRESS_KEY is not set, will use DFS_ROUTER_ADMIN_ADDRESS_DEFAULT as router.admin-address.
141143
final String routerAdminAddr =
142-
String.format(ROUTER_ADMIN_ADDRESS_FORMATTER, this.clusterName, RBFConfigKeys.DFS_ROUTER_ADMIN_PORT_DEFAULT);
144+
String.format(ROUTER_ADMIN_ADDRESS_FORMATTER, this.routerAddr, RBFConfigKeys.DFS_ROUTER_ADMIN_PORT_DEFAULT);
143145
getConf().set(RBFConfigKeys.DFS_ROUTER_ADMIN_ADDRESS_KEY, routerAdminAddr);
144146
}
145147

146-
147148
UserGroupInformation.loginUserFromKeytab(keytabPrincipal, new File(keytabPath).getAbsolutePath());
148149
try {
149150
String address = getConf().getTrimmed(RBFConfigKeys.DFS_ROUTER_ADMIN_ADDRESS_KEY,

hadoop-li-internal/hadoop-li-tools/src/test/java/org/apache/hadoop/hdfs/tools/federation/TestMountTableConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static void clusterSetup() throws Exception {
5656

5757
Configuration routerConf = new Configuration();
5858
InetSocketAddress routerSocket = router.getAdminServerAddress();
59-
// clusterName is null, we use routerSocket to overwrite DFS_ROUTER_ADMIN_ADDRESS_KEY for unit tests.
59+
// routerAddr is null, we use routerSocket to overwrite DFS_ROUTER_ADMIN_ADDRESS_KEY for unit tests.
6060
routerConf.setSocketAddr(RBFConfigKeys.DFS_ROUTER_ADMIN_ADDRESS_KEY, routerSocket);
6161
converter =
6262
new MountTableConverter(routerConf, "hdfs", "/dummy.headless.keytab", new Path("file:///dummy.json"), true,
@@ -73,12 +73,12 @@ public static void tearDownCluster() {
7373

7474
@Test
7575
public void testGetRouterAdminAddr() throws IOException {
76-
String clusterName = "cluster01";
76+
String routerAddr = "0.0.0.0";
7777
String expectedRouterAdminAddr =
78-
String.format(ROUTER_ADMIN_ADDRESS_FORMATTER, clusterName, RBFConfigKeys.DFS_ROUTER_ADMIN_PORT_DEFAULT);
78+
String.format(ROUTER_ADMIN_ADDRESS_FORMATTER, routerAddr, RBFConfigKeys.DFS_ROUTER_ADMIN_PORT_DEFAULT);
7979
MountTableConverter remoteConverter =
8080
new MountTableConverter(new Configuration(), "hdfs", "/dummy.headless.keytab", new Path("file:///dummy.json"),
81-
true, false, "fed", clusterName);
81+
true, false, "fed", routerAddr);
8282

8383
remoteConverter.initClient();
8484
assertEquals(expectedRouterAdminAddr,

0 commit comments

Comments
 (0)