HDFS-5405. Fix possible RetryCache hang for caching RPC handlers in FSNamesystem. (Contributed by Andrew Wang)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4949@1535282 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew Wang 2013-10-24 05:40:28 +00:00
parent 4004a42d53
commit 222dbfe2ce
2 changed files with 13 additions and 10 deletions

View File

@ -118,3 +118,6 @@ HDFS-4949 (Unreleased)
HDFS-5404. Resolve regressions in Windows compatibility on HDFS-4949 HDFS-5404. Resolve regressions in Windows compatibility on HDFS-4949
branch. (Chris Nauroth via Andrew Wang) branch. (Chris Nauroth via Andrew Wang)
HDFS-5405. Fix possible RetryCache hang for caching RPC handlers in
FSNamesystem. (wang)

View File

@ -6922,16 +6922,16 @@ void removeSnapshottableDirs(List<INodeDirectorySnapshottable> toRemove) {
PathBasedCacheDescriptor addPathBasedCacheDirective( PathBasedCacheDescriptor addPathBasedCacheDirective(
PathBasedCacheDirective directive) throws IOException { PathBasedCacheDirective directive) throws IOException {
checkOperation(OperationCategory.WRITE);
final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null;
CacheEntryWithPayload cacheEntry = CacheEntryWithPayload cacheEntry =
RetryCache.waitForCompletion(retryCache, null); RetryCache.waitForCompletion(retryCache, null);
if (cacheEntry != null && cacheEntry.isSuccess()) { if (cacheEntry != null && cacheEntry.isSuccess()) {
return (PathBasedCacheDescriptor) cacheEntry.getPayload(); return (PathBasedCacheDescriptor) cacheEntry.getPayload();
} }
final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null;
boolean success = false; boolean success = false;
PathBasedCacheDescriptor result = null; PathBasedCacheDescriptor result = null;
checkOperation(OperationCategory.WRITE);
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -6957,14 +6957,14 @@ PathBasedCacheDescriptor addPathBasedCacheDirective(
} }
void removePathBasedCacheDescriptor(Long id) throws IOException { void removePathBasedCacheDescriptor(Long id) throws IOException {
checkOperation(OperationCategory.WRITE);
final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null;
CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
if (cacheEntry != null && cacheEntry.isSuccess()) { if (cacheEntry != null && cacheEntry.isSuccess()) {
return; return;
} }
final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null;
boolean success = false; boolean success = false;
checkOperation(OperationCategory.WRITE);
writeLock(); writeLock();
try { try {
checkOperation(OperationCategory.WRITE); checkOperation(OperationCategory.WRITE);
@ -6988,10 +6988,10 @@ void removePathBasedCacheDescriptor(Long id) throws IOException {
BatchedListEntries<PathBasedCacheDescriptor> listPathBasedCacheDescriptors( BatchedListEntries<PathBasedCacheDescriptor> listPathBasedCacheDescriptors(
long startId, String pool, String path) throws IOException { long startId, String pool, String path) throws IOException {
checkOperation(OperationCategory.READ);
final FSPermissionChecker pc = isPermissionEnabled ? final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null; getPermissionChecker() : null;
BatchedListEntries<PathBasedCacheDescriptor> results; BatchedListEntries<PathBasedCacheDescriptor> results;
checkOperation(OperationCategory.READ);
readLock(); readLock();
boolean success = false; boolean success = false;
try { try {
@ -7010,13 +7010,13 @@ BatchedListEntries<PathBasedCacheDescriptor> listPathBasedCacheDescriptors(
} }
public void addCachePool(CachePoolInfo req) throws IOException { public void addCachePool(CachePoolInfo req) throws IOException {
checkOperation(OperationCategory.WRITE);
final FSPermissionChecker pc = isPermissionEnabled ? final FSPermissionChecker pc = isPermissionEnabled ?
getPermissionChecker() : null; getPermissionChecker() : null;
CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
if (cacheEntry != null && cacheEntry.isSuccess()) { if (cacheEntry != null && cacheEntry.isSuccess()) {
return; // Return previous response return; // Return previous response
} }
checkOperation(OperationCategory.WRITE);
writeLock(); writeLock();
boolean success = false; boolean success = false;
try { try {
@ -7043,13 +7043,13 @@ public void addCachePool(CachePoolInfo req) throws IOException {
} }
public void modifyCachePool(CachePoolInfo req) throws IOException { public void modifyCachePool(CachePoolInfo req) throws IOException {
checkOperation(OperationCategory.WRITE);
final FSPermissionChecker pc = final FSPermissionChecker pc =
isPermissionEnabled ? getPermissionChecker() : null; isPermissionEnabled ? getPermissionChecker() : null;
CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
if (cacheEntry != null && cacheEntry.isSuccess()) { if (cacheEntry != null && cacheEntry.isSuccess()) {
return; // Return previous response return; // Return previous response
} }
checkOperation(OperationCategory.WRITE);
writeLock(); writeLock();
boolean success = false; boolean success = false;
try { try {
@ -7076,13 +7076,13 @@ public void modifyCachePool(CachePoolInfo req) throws IOException {
} }
public void removeCachePool(String cachePoolName) throws IOException { public void removeCachePool(String cachePoolName) throws IOException {
checkOperation(OperationCategory.WRITE);
final FSPermissionChecker pc = final FSPermissionChecker pc =
isPermissionEnabled ? getPermissionChecker() : null; isPermissionEnabled ? getPermissionChecker() : null;
CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache); CacheEntry cacheEntry = RetryCache.waitForCompletion(retryCache);
if (cacheEntry != null && cacheEntry.isSuccess()) { if (cacheEntry != null && cacheEntry.isSuccess()) {
return; // Return previous response return; // Return previous response
} }
checkOperation(OperationCategory.WRITE);
writeLock(); writeLock();
boolean success = false; boolean success = false;
try { try {