Skip to content

Commit 87b93cd

Browse files
mokai87Apache9
authored andcommitted
HBASE-29686 Compatible issue of HFileOutputFormat2#configureRemoteCluster (#7415)
Signed-off-by: Duo Zhang <[email protected]> Signed-off-by: Junegunn Choi <[email protected]> Signed-off-by: Pankaj Kumar <[email protected]> Reviewed-by: chaijunjie0101 <[email protected]> (cherry picked from commit eae2198)
1 parent e554134 commit 87b93cd

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.apache.hadoop.hbase.regionserver.HStoreFile.MAJOR_COMPACTION_KEY;
2424

2525
import java.io.IOException;
26+
import java.io.UncheckedIOException;
2627
import java.io.UnsupportedEncodingException;
2728
import java.net.InetSocketAddress;
2829
import java.net.URLDecoder;
@@ -622,7 +623,7 @@ private static void writePartitions(Configuration conf, Path partitionsPath,
622623
public static void configureIncrementalLoad(Job job, Table table, RegionLocator regionLocator)
623624
throws IOException {
624625
configureIncrementalLoad(job, table.getDescriptor(), regionLocator);
625-
configureRemoteCluster(job, table.getConfiguration());
626+
configureForRemoteCluster(job, table.getConfiguration());
626627
}
627628

628629
/**
@@ -810,8 +811,34 @@ public static void configureIncrementalLoadMap(Job job, TableDescriptor tableDes
810811
* @see #REMOTE_CLUSTER_ZOOKEEPER_QUORUM_CONF_KEY
811812
* @see #REMOTE_CLUSTER_ZOOKEEPER_CLIENT_PORT_CONF_KEY
812813
* @see #REMOTE_CLUSTER_ZOOKEEPER_ZNODE_PARENT_CONF_KEY
814+
* @deprecated As of release 2.6.4, this will be removed in HBase 4.0.0 Use
815+
* {@link #configureForRemoteCluster(Job, Configuration)} instead.
813816
*/
814-
public static void configureRemoteCluster(Job job, Configuration clusterConf) throws IOException {
817+
@Deprecated
818+
public static void configureRemoteCluster(Job job, Configuration clusterConf) {
819+
try {
820+
configureForRemoteCluster(job, clusterConf);
821+
} catch (IOException e) {
822+
LOG.error("Configure remote cluster error.", e);
823+
throw new UncheckedIOException("Configure remote cluster error.", e);
824+
}
825+
}
826+
827+
/**
828+
* Configure HBase cluster key for remote cluster to load region location for locality-sensitive
829+
* if it's enabled. It's not necessary to call this method explicitly when the cluster key for
830+
* HBase cluster to be used to load region location is configured in the job configuration. Call
831+
* this method when another HBase cluster key is configured in the job configuration. For example,
832+
* you should call when you load data from HBase cluster A using {@link TableInputFormat} and
833+
* generate hfiles for HBase cluster B. Otherwise, HFileOutputFormat2 fetch location from cluster
834+
* A and locality-sensitive won't working correctly. If authentication is enabled, it obtains the
835+
* token for the specific cluster.
836+
* @param job which has configuration to be updated
837+
* @param clusterConf which contains cluster key of the HBase cluster to be locality-sensitive
838+
* @throws IOException Exception while initializing cluster credentials
839+
*/
840+
public static void configureForRemoteCluster(Job job, Configuration clusterConf)
841+
throws IOException {
815842
Configuration conf = job.getConfiguration();
816843

817844
if (!conf.getBoolean(LOCALITY_SENSITIVE_CONF_KEY, DEFAULT_LOCALITY_SENSITIVE)) {

0 commit comments

Comments
 (0)