diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java index 0d97d6f..7a7d8a9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java @@ -481,7 +481,7 @@ appState.getApplicationSubmissionContext().getApplicationId(); Path nodeRemovePath = getAppDir(rmAppRoot, appId); LOG.info("Removing info for app: " + appId + " at: " + nodeRemovePath); - deleteFileWithRetries(nodeRemovePath); + checkAndRemovePathWithRetries(nodeRemovePath); } @Override @@ -497,7 +497,7 @@ Path nodeCreatePath = getNodePath(rmDTSecretManagerRoot, DELEGATION_TOKEN_PREFIX + identifier.getSequenceNumber()); LOG.info("Removing RMDelegationToken_" + identifier.getSequenceNumber()); - deleteFileWithRetries(nodeCreatePath); + checkAndRemovePathWithRetries(nodeCreatePath); } @Override @@ -561,23 +561,19 @@ Path nodeCreatePath = getNodePath(rmDTSecretManagerRoot, DELEGATION_KEY_PREFIX + masterKey.getKeyId()); LOG.info("Removing RMDelegationKey_"+ masterKey.getKeyId()); - deleteFileWithRetries(nodeCreatePath); + checkAndRemovePathWithRetries(nodeCreatePath); } @Override public synchronized void deleteStore() throws Exception { - if (existsWithRetries(rootDirPath)) { - deleteFileWithRetries(rootDirPath); - } + checkAndRemovePathWithRetries(rootDirPath); } @Override public synchronized void removeApplication(ApplicationId removeAppId) throws Exception { Path nodeRemovePath = getAppDir(rmAppRoot, removeAppId); - if (existsWithRetries(nodeRemovePath)) { - deleteFileWithRetries(nodeRemovePath); - } + checkAndRemovePathWithRetries(nodeRemovePath); } private Path getAppDir(Path root, ApplicationId appId) { @@ -715,6 +711,15 @@ } }.runWithRetries(); } + + private void checkAndRemovePathWithRetries(final Path deletePath) + throws Exception { + if (existsWithRetries(dstPath)) { + deleteFileWithRetries(dstPath); + } else { + LOG.info("File doesn't exist. Skip deleting the file " + dstPath); + } + } private abstract class FSAction { abstract T run() throws Exception; @@ -804,11 +809,7 @@ } protected void replaceFile(Path srcPath, Path dstPath) throws Exception { - if (existsWithRetries(dstPath)) { - deleteFileWithRetries(dstPath); - } else { - LOG.info("File doesn't exist. Skip deleting the file " + dstPath); - } + checkAndRemovePathWithRetries(dstPath); renameFileWithRetries(srcPath, dstPath); }