You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/07/30 07:33:06 UTC

[GitHub] [hbase] tedyu commented on a change in pull request #2167: HBASE-24791 Improve HFileOutputFormat2 to avoid always call getTableRelativePath method

tedyu commented on a change in pull request #2167:
URL: https://github.com/apache/hbase/pull/2167#discussion_r462583864



##########
File path: hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java
##########
@@ -274,39 +270,36 @@ public void write(ImmutableBytesWritable row, V cell) throws IOException {
 
         // create a new WAL writer, if necessary
         if (wl == null || wl.writer == null) {
+          InetSocketAddress[] favoredNodes = null;
           if (conf.getBoolean(LOCALITY_SENSITIVE_CONF_KEY, DEFAULT_LOCALITY_SENSITIVE)) {
             HRegionLocation loc = null;
-
+            String tableName = Bytes.toString(tableNameBytes);
             if (tableName != null) {
               try (Connection connection = ConnectionFactory.createConnection(conf);
-                     RegionLocator locator =
-                       connection.getRegionLocator(TableName.valueOf(tableName))) {
+                RegionLocator locator = connection.getRegionLocator(TableName.valueOf(tableName))) {
                 loc = locator.getRegionLocation(rowKey);
               } catch (Throwable e) {
-                LOG.warn("Something wrong locating rowkey {} in {}",
-                  Bytes.toString(rowKey), tableName, e);
+                LOG.warn("Something wrong locating rowkey {} in {}", Bytes.toString(rowKey),
+                  tableName, e);
                 loc = null;
-              } }
-
+              }
+            }
             if (null == loc) {
               LOG.trace("Failed get of location, use default writer {}", Bytes.toString(rowKey));
-              wl = getNewWriter(tableNameBytes, family, conf, null);
             } else {
               LOG.debug("First rowkey: [{}]", Bytes.toString(rowKey));
               InetSocketAddress initialIsa =
                   new InetSocketAddress(loc.getHostname(), loc.getPort());
               if (initialIsa.isUnresolved()) {
                 LOG.trace("Failed resolve address {}, use default writer", loc.getHostnamePort());
-                wl = getNewWriter(tableNameBytes, family, conf, null);
               } else {
                 LOG.debug("Use favored nodes writer: {}", initialIsa.getHostString());
-                wl = getNewWriter(tableNameBytes, family, conf, new InetSocketAddress[] { initialIsa
-                });
+                favoredNodes = new InetSocketAddress[] { initialIsa};

Review comment:
       Does this apply when LOCALITY_SENSITIVE_CONF_KEY check on line 274 is false ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org