Skip to content

Commit e08b364

Browse files
bitterfoxsaintstack
authored andcommitted
HBASE-26196 Support configuration override for remote cluster of HFileOutputFormat locality sensitive (#3582)
Signed-off-by: stack <[email protected]>
1 parent 4aec407 commit e08b364

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Arrays;
3232
import java.util.List;
3333
import java.util.Map;
34+
import java.util.Map.Entry;
3435
import java.util.Set;
3536
import java.util.TreeMap;
3637
import java.util.TreeSet;
@@ -176,12 +177,14 @@ protected static byte[] combineTableNameSuffix(byte[] tableName, byte[] suffix)
176177
static final String MULTI_TABLE_HFILEOUTPUTFORMAT_CONF_KEY =
177178
"hbase.mapreduce.use.multi.table.hfileoutputformat";
178179

180+
public static final String REMOTE_CLUSTER_CONF_PREFIX =
181+
"hbase.hfileoutputformat.remote.cluster.";
179182
public static final String REMOTE_CLUSTER_ZOOKEEPER_QUORUM_CONF_KEY =
180-
"hbase.hfileoutputformat.remote.cluster.zookeeper.quorum";
183+
REMOTE_CLUSTER_CONF_PREFIX + "zookeeper.quorum";
181184
public static final String REMOTE_CLUSTER_ZOOKEEPER_CLIENT_PORT_CONF_KEY =
182-
"hbase.hfileoutputformat.remote.cluster.zookeeper." + HConstants.CLIENT_PORT_STR;
185+
REMOTE_CLUSTER_CONF_PREFIX + "zookeeper." + HConstants.CLIENT_PORT_STR;
183186
public static final String REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY =
184-
"hbase.hfileoutputformat.remote.cluster." + HConstants.ZOOKEEPER_ZNODE_PARENT;
187+
REMOTE_CLUSTER_CONF_PREFIX + HConstants.ZOOKEEPER_ZNODE_PARENT;
185188

186189
public static final String STORAGE_POLICY_PROPERTY = HStore.BLOCK_STORAGE_POLICY_KEY;
187190
public static final String STORAGE_POLICY_PROPERTY_CF_PREFIX = STORAGE_POLICY_PROPERTY + ".";
@@ -379,6 +382,23 @@ private Configuration createRemoteClusterConf(Configuration conf) {
379382
newConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, parent);
380383
}
381384

385+
for (Entry<String, String> entry : conf) {
386+
String key = entry.getKey();
387+
if (REMOTE_CLUSTER_ZOOKEEPER_QUORUM_CONF_KEY.equals(key) ||
388+
REMOTE_CLUSTER_ZOOKEEPER_CLIENT_PORT_CONF_KEY.equals(key) ||
389+
REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY.equals(key)) {
390+
// Handled them above
391+
continue;
392+
}
393+
394+
if (entry.getKey().startsWith(REMOTE_CLUSTER_CONF_PREFIX)) {
395+
String originalKey = entry.getKey().substring(REMOTE_CLUSTER_CONF_PREFIX.length());
396+
if (!originalKey.isEmpty()) {
397+
newConf.set(originalKey, entry.getValue());
398+
}
399+
}
400+
}
401+
382402
return newConf;
383403
}
384404

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
import org.apache.hadoop.hbase.regionserver.HStore;
9797
import org.apache.hadoop.hbase.regionserver.TestHRegionFileSystem;
9898
import org.apache.hadoop.hbase.regionserver.TimeRangeTracker;
99+
import org.apache.hadoop.hbase.security.SecurityConstants;
99100
import org.apache.hadoop.hbase.security.User;
100101
import org.apache.hadoop.hbase.testclassification.LargeTests;
101102
import org.apache.hadoop.hbase.testclassification.VerySlowMapReduceTests;
@@ -1612,6 +1613,11 @@ public void testMRIncrementalLoadWithLocalityMultiCluster() throws Exception {
16121613
assertEquals(confB.get(HConstants.ZOOKEEPER_ZNODE_PARENT),
16131614
jobConf.get(HFileOutputFormat2.REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY));
16141615

1616+
String bSpecificConfigKey = "my.override.config.for.b";
1617+
String bSpecificConfigValue = "b-specific-value";
1618+
jobConf.set(HFileOutputFormat2.REMOTE_CLUSTER_CONF_PREFIX + bSpecificConfigKey,
1619+
bSpecificConfigValue);
1620+
16151621
FileOutputFormat.setOutputPath(job, testDir);
16161622

16171623
assertFalse(util.getTestFileSystem().exists(testDir));
@@ -1629,6 +1635,9 @@ public void testMRIncrementalLoadWithLocalityMultiCluster() throws Exception {
16291635
config.get(HConstants.ZOOKEEPER_CLIENT_PORT));
16301636
assertEquals(confB.get(HConstants.ZOOKEEPER_ZNODE_PARENT),
16311637
config.get(HConstants.ZOOKEEPER_ZNODE_PARENT));
1638+
1639+
assertEquals(bSpecificConfigValue,
1640+
config.get(bSpecificConfigKey));
16321641
}
16331642
} finally {
16341643
utilB.deleteTable(tableName);

0 commit comments

Comments
 (0)