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 @@ String getNameserviceId() {
return nameserviceId; return nameserviceId;
} }
String getBlockPoolId() { String getBlockPoolId(boolean quiet) {
readLock(); readLock();
try { try {
if (bpNSInfo != null) { if (bpNSInfo != null) {
return bpNSInfo.getBlockPoolID(); return bpNSInfo.getBlockPoolID();
} else { } else {
LOG.warn("Block pool ID needed, but service not yet registered with " + if (!quiet) {
"NN, trace:", new Exception()); LOG.warn("Block pool ID needed, but service not yet registered with "
+ "NN, trace:", new Exception());
}
return null; return null;
} }
} finally { } finally {
@ -196,6 +198,10 @@ String getBlockPoolId() {
} }
} }
String getBlockPoolId() {
return getBlockPoolId(false);
}
boolean hasBlockPoolId() { boolean hasBlockPoolId() {
return getNamespaceInfo() != null; return getNamespaceInfo() != null;
} }

View File

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