From 767b91cd834dc235ce9d116ba745b90c24ebe290 Mon Sep 17 00:00:00 2001 From: Haohui Mai Date: Mon, 4 May 2015 15:47:16 -0700 Subject: [PATCH] HDFS-8321. CacheDirectives and CachePool operations should throw RetriableException in safemode. Contributed by Haohui Mai. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../hdfs/server/namenode/FSNamesystem.java | 32 +++++-------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 74456dbb45..be72b439d5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -645,6 +645,9 @@ Release 2.8.0 - UNRELEASED HDFS-8325. Misspelling of threshold in log4j.properties for tests. (Brahma Reddy Battula via aajisaka) + HDFS-8321. CacheDirectives and CachePool operations should throw + RetriableException in safemode. (wheat9) + Release 2.7.1 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 84cb905eb6..120812bc96 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -7679,10 +7679,7 @@ long addCacheDirective(CacheDirectiveInfo directive, writeLock(); try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot add cache directive", safeMode); - } + checkNameNodeSafeMode("Cannot add cache directive"); effectiveDirective = FSNDNCacheOp.addCacheDirective(this, cacheManager, directive, flags, logRetryCache); } finally { @@ -7710,10 +7707,7 @@ void modifyCacheDirective(CacheDirectiveInfo directive, writeLock(); try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot add cache directive", safeMode); - } + checkNameNodeSafeMode("Cannot add cache directive"); FSNDNCacheOp.modifyCacheDirective(this, cacheManager, directive, flags, logRetryCache); success = true; @@ -7734,10 +7728,7 @@ void removeCacheDirective(long id, boolean logRetryCache) throws IOException { writeLock(); try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot remove cache directives", safeMode); - } + checkNameNodeSafeMode("Cannot remove cache directives"); FSNDNCacheOp.removeCacheDirective(this, cacheManager, id, logRetryCache); success = true; } finally { @@ -7777,10 +7768,8 @@ void addCachePool(CachePoolInfo req, boolean logRetryCache) String poolInfoStr = null; try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot add cache pool " + req.getPoolName(), safeMode); - } + checkNameNodeSafeMode("Cannot add cache pool" + + (req == null ? null : req.getPoolName())); CachePoolInfo info = FSNDNCacheOp.addCachePool(this, cacheManager, req, logRetryCache); poolInfoStr = info.toString(); @@ -7800,10 +7789,8 @@ void modifyCachePool(CachePoolInfo req, boolean logRetryCache) boolean success = false; try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot modify cache pool " + req.getPoolName(), safeMode); - } + checkNameNodeSafeMode("Cannot modify cache pool" + + (req == null ? null : req.getPoolName())); FSNDNCacheOp.modifyCachePool(this, cacheManager, req, logRetryCache); success = true; } finally { @@ -7824,10 +7811,7 @@ void removeCachePool(String cachePoolName, boolean logRetryCache) boolean success = false; try { checkOperation(OperationCategory.WRITE); - if (isInSafeMode()) { - throw new SafeModeException( - "Cannot remove cache pool " + cachePoolName, safeMode); - } + checkNameNodeSafeMode("Cannot modify cache pool" + cachePoolName); FSNDNCacheOp.removeCachePool(this, cacheManager, cachePoolName, logRetryCache); success = true;