HDFS-5494. Fix findbugs warnings for HDFS-2832.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-2832@1540924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec5eebc450
commit
e5b3171c3b
|
@ -97,3 +97,5 @@ IMPROVEMENTS:
|
||||||
|
|
||||||
HDFS-5491. Update editsStored for HDFS-2832. (Arpit Agarwal)
|
HDFS-5491. Update editsStored for HDFS-2832. (Arpit Agarwal)
|
||||||
|
|
||||||
|
HDFS-5494. Fix findbugs warnings for HDFS-2832. (Arpit Agarwal)
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ class BPServiceActor implements Runnable {
|
||||||
* reported to the NN. Access should be synchronized on this object.
|
* reported to the NN. Access should be synchronized on this object.
|
||||||
*/
|
*/
|
||||||
private final Map<String, PerStoragePendingIncrementalBR>
|
private final Map<String, PerStoragePendingIncrementalBR>
|
||||||
pendingIncrementalBRperStorage = Maps.newConcurrentMap();
|
pendingIncrementalBRperStorage = Maps.newHashMap();
|
||||||
|
|
||||||
private volatile int pendingReceivedRequests = 0;
|
private volatile int pendingReceivedRequests = 0;
|
||||||
private volatile boolean shouldServiceRun = true;
|
private volatile boolean shouldServiceRun = true;
|
||||||
|
@ -266,43 +266,54 @@ class BPServiceActor implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report received blocks and delete hints to the Namenode
|
* Report received blocks and delete hints to the Namenode for each
|
||||||
|
* storage.
|
||||||
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
private void reportReceivedDeletedBlocks() throws IOException {
|
private void reportReceivedDeletedBlocks() throws IOException {
|
||||||
// For each storage, check if there are newly received blocks and if
|
|
||||||
// so then send an incremental report to the NameNode.
|
// Generate a list of the pending reports for each storage under the lock
|
||||||
for (Map.Entry<String, PerStoragePendingIncrementalBR> entry :
|
Map<String, ReceivedDeletedBlockInfo[]> blockArrays = Maps.newHashMap();
|
||||||
pendingIncrementalBRperStorage.entrySet()) {
|
synchronized (pendingIncrementalBRperStorage) {
|
||||||
final String storageUuid = entry.getKey();
|
for (Map.Entry<String, PerStoragePendingIncrementalBR> entry :
|
||||||
final PerStoragePendingIncrementalBR perStorageMap = entry.getValue();
|
pendingIncrementalBRperStorage.entrySet()) {
|
||||||
ReceivedDeletedBlockInfo[] receivedAndDeletedBlockArray = null;
|
final String storageUuid = entry.getKey();
|
||||||
// TODO: We can probably use finer-grained synchronization now.
|
final PerStoragePendingIncrementalBR perStorageMap = entry.getValue();
|
||||||
synchronized (pendingIncrementalBRperStorage) {
|
ReceivedDeletedBlockInfo[] receivedAndDeletedBlockArray = null;
|
||||||
|
|
||||||
if (perStorageMap.getBlockInfoCount() > 0) {
|
if (perStorageMap.getBlockInfoCount() > 0) {
|
||||||
// Send newly-received and deleted blockids to namenode
|
// Send newly-received and deleted blockids to namenode
|
||||||
receivedAndDeletedBlockArray = perStorageMap.dequeueBlockInfos();
|
receivedAndDeletedBlockArray = perStorageMap.dequeueBlockInfos();
|
||||||
pendingReceivedRequests -= receivedAndDeletedBlockArray.length;
|
pendingReceivedRequests -= receivedAndDeletedBlockArray.length;
|
||||||
|
blockArrays.put(storageUuid, receivedAndDeletedBlockArray);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (receivedAndDeletedBlockArray != null) {
|
// Send incremental block reports to the Namenode outside the lock
|
||||||
StorageReceivedDeletedBlocks[] report = { new StorageReceivedDeletedBlocks(
|
for (Map.Entry<String, ReceivedDeletedBlockInfo[]> entry :
|
||||||
storageUuid, receivedAndDeletedBlockArray) };
|
blockArrays.entrySet()) {
|
||||||
boolean success = false;
|
final String storageUuid = entry.getKey();
|
||||||
try {
|
final ReceivedDeletedBlockInfo[] rdbi = entry.getValue();
|
||||||
bpNamenode.blockReceivedAndDeleted(bpRegistration, bpos.getBlockPoolId(),
|
|
||||||
report);
|
StorageReceivedDeletedBlocks[] report = { new StorageReceivedDeletedBlocks(
|
||||||
success = true;
|
storageUuid, rdbi) };
|
||||||
} finally {
|
boolean success = false;
|
||||||
|
try {
|
||||||
|
bpNamenode.blockReceivedAndDeleted(bpRegistration,
|
||||||
|
bpos.getBlockPoolId(), report);
|
||||||
|
success = true;
|
||||||
|
} finally {
|
||||||
|
if (!success) {
|
||||||
synchronized (pendingIncrementalBRperStorage) {
|
synchronized (pendingIncrementalBRperStorage) {
|
||||||
if (!success) {
|
// If we didn't succeed in sending the report, put all of the
|
||||||
// If we didn't succeed in sending the report, put all of the
|
// blocks back onto our queue, but only in the case where we
|
||||||
// blocks back onto our queue, but only in the case where we
|
// didn't put something newer in the meantime.
|
||||||
// didn't put something newer in the meantime.
|
PerStoragePendingIncrementalBR perStorageMap =
|
||||||
perStorageMap.putMissingBlockInfos(receivedAndDeletedBlockArray);
|
pendingIncrementalBRperStorage.get(storageUuid);
|
||||||
pendingReceivedRequests += perStorageMap.getBlockInfoCount();
|
perStorageMap.putMissingBlockInfos(rdbi);
|
||||||
}
|
pendingReceivedRequests += perStorageMap.getBlockInfoCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,7 @@ public class DataStorage extends Storage {
|
||||||
|
|
||||||
if (LayoutVersion.supports(Feature.ADD_DATANODE_AND_STORAGE_UUIDS,
|
if (LayoutVersion.supports(Feature.ADD_DATANODE_AND_STORAGE_UUIDS,
|
||||||
layoutVersion) && datanodeUuid != null) {
|
layoutVersion) && datanodeUuid != null) {
|
||||||
props.setProperty("datanodeUuid", datanodeUuid);
|
props.setProperty("datanodeUuid", getDatanodeUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set NamespaceID in version before federation
|
// Set NamespaceID in version before federation
|
||||||
|
@ -348,7 +348,7 @@ public class DataStorage extends Storage {
|
||||||
} else if (getDatanodeUuid().compareTo(dnUuid) != 0) {
|
} else if (getDatanodeUuid().compareTo(dnUuid) != 0) {
|
||||||
throw new InconsistentFSStateException(sd.getRoot(),
|
throw new InconsistentFSStateException(sd.getRoot(),
|
||||||
"Root " + sd.getRoot() + ": DatanodeUuid=" + dnUuid +
|
"Root " + sd.getRoot() + ": DatanodeUuid=" + dnUuid +
|
||||||
", does not match " + datanodeUuid + " from other" +
|
", does not match " + getDatanodeUuid() + " from other" +
|
||||||
" StorageDirectory.");
|
" StorageDirectory.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue