HDFS-16197.Simplify getting NNStorage in FSNamesystem. (#3357)
This commit is contained in:
parent
7f6553af75
commit
edfde6eebc
|
@ -4639,6 +4639,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
return getFSImage().getEditLog();
|
return getFSImage().getEditLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NNStorage getNNStorage() {
|
||||||
|
return getFSImage().getStorage();
|
||||||
|
}
|
||||||
|
|
||||||
@Metric({"MissingBlocks", "Number of missing blocks"})
|
@Metric({"MissingBlocks", "Number of missing blocks"})
|
||||||
public long getMissingBlocksCount() {
|
public long getMissingBlocksCount() {
|
||||||
// not locking
|
// not locking
|
||||||
|
@ -4662,7 +4666,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
"Number of transactions since last checkpoint"})
|
"Number of transactions since last checkpoint"})
|
||||||
public long getTransactionsSinceLastCheckpoint() {
|
public long getTransactionsSinceLastCheckpoint() {
|
||||||
return getFSImage().getLastAppliedOrWrittenTxId() -
|
return getFSImage().getLastAppliedOrWrittenTxId() -
|
||||||
getFSImage().getStorage().getMostRecentCheckpointTxId();
|
getNNStorage().getMostRecentCheckpointTxId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Metric({"TransactionsSinceLastLogRoll",
|
@Metric({"TransactionsSinceLastLogRoll",
|
||||||
|
@ -4697,7 +4701,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
@Metric({"LastCheckpointTime",
|
@Metric({"LastCheckpointTime",
|
||||||
"Time in milliseconds since the epoch of the last checkpoint"})
|
"Time in milliseconds since the epoch of the last checkpoint"})
|
||||||
public long getLastCheckpointTime() {
|
public long getLastCheckpointTime() {
|
||||||
return getFSImage().getStorage().getMostRecentCheckpointTime();
|
return getNNStorage().getMostRecentCheckpointTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @see ClientProtocol#getStats() */
|
/** @see ClientProtocol#getStats() */
|
||||||
|
@ -4967,10 +4971,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
|
|
||||||
// if it is disabled - enable it and vice versa.
|
// if it is disabled - enable it and vice versa.
|
||||||
if(arg.equals("check")) {
|
if(arg.equals("check")) {
|
||||||
val = getFSImage().getStorage().getRestoreFailedStorage();
|
val = getNNStorage().getRestoreFailedStorage();
|
||||||
} else {
|
} else {
|
||||||
val = arg.equals("true"); // false if not
|
val = arg.equals("true"); // false if not
|
||||||
getFSImage().getStorage().setRestoreFailedStorage(val);
|
getNNStorage().setRestoreFailedStorage(val);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock(operationName, getLockReportInfoSupplier(null));
|
writeUnlock(operationName, getLockReportInfoSupplier(null));
|
||||||
|
@ -5969,11 +5973,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
NamenodeRegistration nnReg) throws IOException {
|
NamenodeRegistration nnReg) throws IOException {
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
if(getFSImage().getStorage().getNamespaceID()
|
if(getNNStorage().getNamespaceID()
|
||||||
!= bnReg.getNamespaceID())
|
!= bnReg.getNamespaceID())
|
||||||
throw new IOException("Incompatible namespaceIDs: "
|
throw new IOException("Incompatible namespaceIDs: "
|
||||||
+ " Namenode namespaceID = "
|
+ " Namenode namespaceID = "
|
||||||
+ getFSImage().getStorage().getNamespaceID() + "; "
|
+ getNNStorage().getNamespaceID() + "; "
|
||||||
+ bnReg.getRole() +
|
+ bnReg.getRole() +
|
||||||
" node namespaceID = " + bnReg.getNamespaceID());
|
" node namespaceID = " + bnReg.getNamespaceID());
|
||||||
if (bnReg.getRole() == NamenodeRole.BACKUP) {
|
if (bnReg.getRole() == NamenodeRole.BACKUP) {
|
||||||
|
@ -5997,11 +6001,11 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
writeLock();
|
writeLock();
|
||||||
try {
|
try {
|
||||||
checkOperation(OperationCategory.WRITE);
|
checkOperation(OperationCategory.WRITE);
|
||||||
if(getFSImage().getStorage().getNamespaceID()
|
if(getNNStorage().getNamespaceID()
|
||||||
!= registration.getNamespaceID())
|
!= registration.getNamespaceID())
|
||||||
throw new IOException("Incompatible namespaceIDs: "
|
throw new IOException("Incompatible namespaceIDs: "
|
||||||
+ " Namenode namespaceID = "
|
+ " Namenode namespaceID = "
|
||||||
+ getFSImage().getStorage().getNamespaceID() + "; "
|
+ getNNStorage().getNamespaceID() + "; "
|
||||||
+ registration.getRole() +
|
+ registration.getRole() +
|
||||||
" node namespaceID = " + registration.getNamespaceID());
|
" node namespaceID = " + registration.getNamespaceID());
|
||||||
getEditLog().releaseBackupStream(registration);
|
getEditLog().releaseBackupStream(registration);
|
||||||
|
@ -6635,7 +6639,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
|
|
||||||
@Override // NameNodeMXBean
|
@Override // NameNodeMXBean
|
||||||
public String getClusterId() {
|
public String getClusterId() {
|
||||||
return getFSImage().getStorage().getClusterID();
|
return getNNStorage().getClusterID();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // NameNodeMXBean
|
@Override // NameNodeMXBean
|
||||||
|
@ -6650,14 +6654,14 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
|
|
||||||
Map<File, StorageDirType> activeDirs = new HashMap<File, StorageDirType>();
|
Map<File, StorageDirType> activeDirs = new HashMap<File, StorageDirType>();
|
||||||
for (Iterator<StorageDirectory> it
|
for (Iterator<StorageDirectory> it
|
||||||
= getFSImage().getStorage().dirIterator(); it.hasNext();) {
|
= getNNStorage().dirIterator(); it.hasNext();) {
|
||||||
StorageDirectory st = it.next();
|
StorageDirectory st = it.next();
|
||||||
activeDirs.put(st.getRoot(), st.getStorageDirType());
|
activeDirs.put(st.getRoot(), st.getStorageDirType());
|
||||||
}
|
}
|
||||||
statusMap.put("active", activeDirs);
|
statusMap.put("active", activeDirs);
|
||||||
|
|
||||||
List<Storage.StorageDirectory> removedStorageDirs
|
List<Storage.StorageDirectory> removedStorageDirs
|
||||||
= getFSImage().getStorage().getRemovedStorageDirs();
|
= getNNStorage().getRemovedStorageDirs();
|
||||||
Map<File, StorageDirType> failedDirs = new HashMap<File, StorageDirType>();
|
Map<File, StorageDirType> failedDirs = new HashMap<File, StorageDirType>();
|
||||||
for (StorageDirectory st : removedStorageDirs) {
|
for (StorageDirectory st : removedStorageDirs) {
|
||||||
failedDirs.put(st.getRoot(), st.getStorageDirType());
|
failedDirs.put(st.getRoot(), st.getStorageDirType());
|
||||||
|
@ -6908,7 +6912,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
|
|
||||||
@Override // NameNodeStatusMXBean
|
@Override // NameNodeStatusMXBean
|
||||||
public String getNameDirSize() {
|
public String getNameDirSize() {
|
||||||
return getFSImage().getStorage().getNNDirectorySize();
|
return getNNStorage().getNNDirectorySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue