HDFS-11947. When constructing a thread name, BPOfferService may print a bogus warning message. Contributed by Weiwei Yang

This commit is contained in:
Tsz-Wo Nicholas Sze 2017-06-13 09:45:10 +08:00
parent eda4bf5196
commit 670224ae59
2 changed files with 11 additions and 5 deletions

View File

@ -181,14 +181,16 @@ class BPOfferService {
return nameserviceId;
}
String getBlockPoolId() {
String getBlockPoolId(boolean quiet) {
readLock();
try {
if (bpNSInfo != null) {
return bpNSInfo.getBlockPoolID();
} else {
LOG.warn("Block pool ID needed, but service not yet registered with " +
"NN, trace:", new Exception());
if (!quiet) {
LOG.warn("Block pool ID needed, but service not yet registered with "
+ "NN, trace:", new Exception());
}
return null;
}
} finally {
@ -196,6 +198,10 @@ class BPOfferService {
}
}
String getBlockPoolId() {
return getBlockPoolId(false);
}
boolean hasBlockPoolId() {
return getNamespaceInfo() != null;
}

View File

@ -553,8 +553,8 @@ class BPServiceActor implements Runnable {
private String formatThreadName(
final String action,
final InetSocketAddress addr) {
final String prefix = bpos.getBlockPoolId() != null ? bpos.getBlockPoolId()
: bpos.getNameserviceId();
String bpId = bpos.getBlockPoolId(true);
final String prefix = bpId != null ? bpId : bpos.getNameserviceId();
return prefix + " " + action + " to " + addr;
}