|
@@ -705,12 +705,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
void setImageLoaded() {
|
|
|
if(imageLoaded) return;
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
setImageLoaded(true);
|
|
|
dir.markNameCacheInitialized();
|
|
|
} finally {
|
|
|
- writeUnlock("setImageLoaded");
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, "setImageLoaded");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1288,7 +1288,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
startOpt = StartupOption.REGULAR;
|
|
|
}
|
|
|
boolean success = false;
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
// We shouldn't be calling saveNamespace if we've come up in standby state.
|
|
|
MetaRecoveryContext recovery = startOpt.createRecoveryContext();
|
|
@@ -1320,7 +1320,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
if (!success) {
|
|
|
fsImage.close();
|
|
|
}
|
|
|
- writeUnlock("loadFSImage", true);
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, "loadFSImage", true);
|
|
|
}
|
|
|
imageLoadComplete();
|
|
|
}
|
|
@@ -1391,7 +1391,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
* Stop services common to both active and standby states
|
|
|
*/
|
|
|
void stopCommonServices() {
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
if (inodeAttributeProvider != null) {
|
|
|
dir.setINodeAttributeProvider(null);
|
|
|
inodeAttributeProvider.stop();
|
|
@@ -1399,7 +1399,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
try {
|
|
|
if (blockManager != null) blockManager.close();
|
|
|
} finally {
|
|
|
- writeUnlock("stopCommonServices");
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, "stopCommonServices");
|
|
|
}
|
|
|
RetryCache.clear(retryCache);
|
|
|
}
|
|
@@ -1529,7 +1529,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
*/
|
|
|
void stopActiveServices() {
|
|
|
LOG.info("Stopping services started for active state");
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
if (blockManager != null) {
|
|
|
blockManager.stopReconstructionInitializer();
|
|
@@ -1577,7 +1577,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
blockManager.setInitializedReplQueues(false);
|
|
|
}
|
|
|
} finally {
|
|
|
- writeUnlock("stopActiveServices");
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, "stopActiveServices");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -4666,7 +4666,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
List<BlockCollection> filesToDelete = new ArrayList<>();
|
|
|
boolean changed = false;
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
final Iterator<BlockInfo> it =
|
|
|
blockManager.getCorruptReplicaBlockIterator();
|
|
@@ -4697,7 +4697,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
}
|
|
|
} finally {
|
|
|
- writeUnlock("clearCorruptLazyPersistFiles");
|
|
|
+ writeUnlock(FSNamesystemLockMode.GLOBAL, "clearCorruptLazyPersistFiles");
|
|
|
}
|
|
|
if (changed) {
|
|
|
getEditLog().logSync();
|
|
@@ -5001,12 +5001,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
}
|
|
|
|
|
|
int getNumberOfDatanodes(DatanodeReportType type) {
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.BM);
|
|
|
try {
|
|
|
return getBlockManager().getDatanodeManager().getDatanodeListForReport(
|
|
|
type).size();
|
|
|
} finally {
|
|
|
- readUnlock("getNumberOfDatanodes");
|
|
|
+ readUnlock(FSNamesystemLockMode.BM, "getNumberOfDatanodes");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -5235,12 +5235,12 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
public long getCompleteBlocksTotal() {
|
|
|
// Calculate number of blocks under construction
|
|
|
long numUCBlocks = 0;
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.GLOBAL);
|
|
|
try {
|
|
|
numUCBlocks = leaseManager.getNumUnderConstructionBlocks();
|
|
|
return getBlocksTotal() - numUCBlocks;
|
|
|
} finally {
|
|
|
- readUnlock("getCompleteBlocksTotal");
|
|
|
+ readUnlock(FSNamesystemLockMode.GLOBAL, "getCompleteBlocksTotal");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -7678,7 +7678,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
if (upgradeInfo.createdRollbackImages()) {
|
|
|
return new RollingUpgradeInfo.Bean(upgradeInfo);
|
|
|
}
|
|
|
- readLock();
|
|
|
+ readLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
// check again after acquiring the read lock.
|
|
|
upgradeInfo = getRollingUpgradeInfo();
|
|
@@ -7692,7 +7692,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
} catch (IOException ioe) {
|
|
|
LOG.warn("Encountered exception setting Rollback Image", ioe);
|
|
|
} finally {
|
|
|
- readUnlock("getRollingUpgradeStatus");
|
|
|
+ readUnlock(FSNamesystemLockMode.FS, "getRollingUpgradeStatus");
|
|
|
}
|
|
|
return new RollingUpgradeInfo.Bean(upgradeInfo);
|
|
|
}
|
|
@@ -7775,7 +7775,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
final String operationName = "finalizeRollingUpgrade";
|
|
|
checkSuperuserPrivilege(operationName);
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
checkOperation(OperationCategory.WRITE);
|
|
|
if (!isRollingUpgrade()) {
|
|
@@ -7793,7 +7793,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
getFSImage().renameCheckpoint(NameNodeFile.IMAGE_ROLLBACK,
|
|
|
NameNodeFile.IMAGE);
|
|
|
} finally {
|
|
|
- writeUnlock(operationName, getLockReportInfoSupplier(null));
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, operationName, getLockReportInfoSupplier(null));
|
|
|
}
|
|
|
|
|
|
if (!haEnabled) {
|
|
@@ -8768,7 +8768,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
|
|
|
@Override
|
|
|
public void removeXattr(long id, String xattrName) throws IOException {
|
|
|
- writeLock();
|
|
|
+ writeLock(FSNamesystemLockMode.FS);
|
|
|
try {
|
|
|
final INode inode = dir.getInode(id);
|
|
|
if (inode == null) {
|
|
@@ -8784,7 +8784,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
|
|
FSDirSatisfyStoragePolicyOp.removeSPSXattr(dir, inode, spsXAttr);
|
|
|
}
|
|
|
} finally {
|
|
|
- writeUnlock("removeXAttr");
|
|
|
+ writeUnlock(FSNamesystemLockMode.FS, "removeXAttr");
|
|
|
}
|
|
|
getEditLog().logSync();
|
|
|
}
|