HDFS-11558. BPServiceActor thread name is too long. Contributed by Xiaobing Zhou
This commit is contained in:
parent
4d4ad0ebb7
commit
3a91376707
@ -70,7 +70,8 @@ class BPOfferService {
|
||||
* handshake.
|
||||
*/
|
||||
volatile DatanodeRegistration bpRegistration;
|
||||
|
||||
|
||||
private final String nameserviceId;
|
||||
private final DataNode dn;
|
||||
|
||||
/**
|
||||
@ -120,12 +121,16 @@ class BPOfferService {
|
||||
mWriteLock.unlock();
|
||||
}
|
||||
|
||||
BPOfferService(List<InetSocketAddress> nnAddrs,
|
||||
List<InetSocketAddress> lifelineNnAddrs, DataNode dn) {
|
||||
BPOfferService(
|
||||
final String nameserviceId,
|
||||
List<InetSocketAddress> nnAddrs,
|
||||
List<InetSocketAddress> lifelineNnAddrs,
|
||||
DataNode dn) {
|
||||
Preconditions.checkArgument(!nnAddrs.isEmpty(),
|
||||
"Must pass at least one NN.");
|
||||
Preconditions.checkArgument(nnAddrs.size() == lifelineNnAddrs.size(),
|
||||
"Must pass same number of NN addresses and lifeline addresses.");
|
||||
this.nameserviceId = nameserviceId;
|
||||
this.dn = dn;
|
||||
|
||||
for (int i = 0; i < nnAddrs.size(); ++i) {
|
||||
@ -170,6 +175,14 @@ class BPOfferService {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets nameservice id to which this {@link BPOfferService} maps to.
|
||||
* @return nameservice id, which can be null.
|
||||
*/
|
||||
String getNameserviceId() {
|
||||
return nameserviceId;
|
||||
}
|
||||
|
||||
String getBlockPoolId() {
|
||||
readLock();
|
||||
try {
|
||||
|
@ -25,7 +25,6 @@ import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@ -279,7 +278,10 @@ class BPServiceActor implements Runnable {
|
||||
// This also initializes our block pool in the DN if we are
|
||||
// the first NN connection for this BP.
|
||||
bpos.verifyAndSetNamespaceInfo(this, nsInfo);
|
||||
|
||||
|
||||
/* set thread name again to include NamespaceInfo when it's available. */
|
||||
this.bpThread.setName(formatThreadName("heartbeating", nnAddr));
|
||||
|
||||
// Second phase of the handshake with the NN.
|
||||
register(nsInfo);
|
||||
}
|
||||
@ -547,14 +549,15 @@ class BPServiceActor implements Runnable {
|
||||
lifelineSender.start();
|
||||
}
|
||||
}
|
||||
|
||||
private String formatThreadName(String action, InetSocketAddress addr) {
|
||||
Collection<StorageLocation> dataDirs =
|
||||
DataNode.getStorageLocations(dn.getConf());
|
||||
return "DataNode: [" + dataDirs.toString() + "] " +
|
||||
action + " to " + addr;
|
||||
|
||||
private String formatThreadName(
|
||||
final String action,
|
||||
final InetSocketAddress addr) {
|
||||
final String prefix = bpos.getBlockPoolId() != null ? bpos.getBlockPoolId()
|
||||
: bpos.getNameserviceId();
|
||||
return prefix + " " + action + " to " + addr;
|
||||
}
|
||||
|
||||
|
||||
//This must be called only by blockPoolManager.
|
||||
void stop() {
|
||||
shouldServiceRun = false;
|
||||
@ -1008,8 +1011,8 @@ class BPServiceActor implements Runnable {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
lifelineThread = new Thread(this, formatThreadName("lifeline",
|
||||
lifelineNnAddr));
|
||||
lifelineThread = new Thread(this,
|
||||
formatThreadName("lifeline", lifelineNnAddr));
|
||||
lifelineThread.setDaemon(true);
|
||||
lifelineThread.setUncaughtExceptionHandler(
|
||||
new Thread.UncaughtExceptionHandler() {
|
||||
|
@ -211,7 +211,7 @@ class BlockPoolManager {
|
||||
lifelineAddrs.add(nnIdToLifelineAddr != null ?
|
||||
nnIdToLifelineAddr.get(nnId) : null);
|
||||
}
|
||||
BPOfferService bpos = createBPOS(addrs, lifelineAddrs);
|
||||
BPOfferService bpos = createBPOS(nsToAdd, addrs, lifelineAddrs);
|
||||
bpByNameserviceId.put(nsToAdd, bpos);
|
||||
offerServices.add(bpos);
|
||||
}
|
||||
@ -261,8 +261,10 @@ class BlockPoolManager {
|
||||
/**
|
||||
* Extracted out for test purposes.
|
||||
*/
|
||||
protected BPOfferService createBPOS(List<InetSocketAddress> nnAddrs,
|
||||
protected BPOfferService createBPOS(
|
||||
final String nameserviceId,
|
||||
List<InetSocketAddress> nnAddrs,
|
||||
List<InetSocketAddress> lifelineNnAddrs) {
|
||||
return new BPOfferService(nnAddrs, lifelineNnAddrs, dn);
|
||||
return new BPOfferService(nameserviceId, nnAddrs, lifelineNnAddrs, dn);
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ public class TestBPOfferService {
|
||||
Mockito.eq(new InetSocketAddress(port)));
|
||||
}
|
||||
|
||||
return new BPOfferService(Lists.newArrayList(nnMap.keySet()),
|
||||
return new BPOfferService("test_ns", Lists.newArrayList(nnMap.keySet()),
|
||||
Collections.<InetSocketAddress>nCopies(nnMap.size(), null), mockDn);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,9 @@ public class TestBlockPoolManager {
|
||||
bpm = new BlockPoolManager(mockDN){
|
||||
|
||||
@Override
|
||||
protected BPOfferService createBPOS(List<InetSocketAddress> nnAddrs,
|
||||
protected BPOfferService createBPOS(
|
||||
final String nameserviceId,
|
||||
List<InetSocketAddress> nnAddrs,
|
||||
List<InetSocketAddress> lifelineNnAddrs) {
|
||||
final int idx = mockIdx++;
|
||||
doLog("create #" + idx);
|
||||
|
Loading…
x
Reference in New Issue
Block a user