utf7 commented on a change in pull request #2167:
URL: https://github.com/apache/hbase/pull/2167#discussion_r462672401
##########
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:
Yes, if the LOCALITY_SENSITIVE_CONF_KEY is false or get locality
failed,the favoredNodes will be null
if LOCALITY_SENSITIVE_CONF_KEY = true and get localicy success ,the
favoredNodes will be not null
same logic with before , just code clean
before this pr, too much `wl = getNewWriter` in the code
##########
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:
Yes, if the `LOCALITY_SENSITIVE_CONF_KEY` is false or get locality
failed,the `favoredNodes` will be null
if `LOCALITY_SENSITIVE_CONF_KEY` = true and get localicy success ,the
`favoredNodes` will be not null
same logic with before , just code clean
before this pr, too much `wl = getNewWriter` in the code
----------------------------------------------------------------
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:
[email protected]