This is an automated email from the ASF dual-hosted git repository.

nnag pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new 88b379e  Revert "GEODE-5197: Synchronized update cache service profile 
in lucene" (#2269)
88b379e is described below

commit 88b379e852b33509b8abd4e7bb82b9a1b62c26b9
Author: Nabarun Nag <nabarun...@users.noreply.github.com>
AuthorDate: Mon Aug 6 16:19:25 2018 -0700

    Revert "GEODE-5197: Synchronized update cache service profile in lucene" 
(#2269)
---
 .../apache/geode/internal/cache/LocalRegion.java   | 40 ++--------------------
 .../cache/lucene/internal/LuceneServiceImpl.java   | 29 ++++++----------
 2 files changed, 13 insertions(+), 56 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java 
b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
index 5e2a491..1642a8a 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/LocalRegion.java
@@ -499,20 +499,6 @@ public class LocalRegion extends AbstractRegion implements 
LoaderHelperFactory,
   private final Lock clientMetaDataLock = new ReentrantLock();
 
   /**
-   * Lock for updating the cache service profile for the region.
-   */
-  private final Lock cacheServiceProfileUpdateLock = new ReentrantLock();
-
-  public void executeSynchronizedOperationOnCacheProfiles(Runnable operation) {
-    cacheServiceProfileUpdateLock.lock();
-    try {
-      operation.run();
-    } finally {
-      cacheServiceProfileUpdateLock.unlock();
-    }
-  }
-
-  /**
    * There seem to be cases where a region can be created and yet the 
distributed system is not yet
    * in place...
    */
@@ -674,7 +660,7 @@ public class LocalRegion extends AbstractRegion implements 
LoaderHelperFactory,
         internalRegionArgs.isUsedForParallelGatewaySenderQueue();
     this.serialGatewaySender = internalRegionArgs.getSerialGatewaySender();
     if (internalRegionArgs.getCacheServiceProfiles() != null) {
-      addCacheServiceProfiles(internalRegionArgs);
+      
this.cacheServiceProfiles.putAll(internalRegionArgs.getCacheServiceProfiles());
     }
 
     if (!isUsedForMetaRegion && !isUsedForPartitionedRegionAdmin
@@ -699,15 +685,6 @@ public class LocalRegion extends AbstractRegion implements 
LoaderHelperFactory,
     versionVector = createRegionVersionVector();
   }
 
-  private void addCacheServiceProfiles(InternalRegionArguments 
internalRegionArgs) {
-    cacheServiceProfileUpdateLock.lock();
-    try {
-      
this.cacheServiceProfiles.putAll(internalRegionArgs.getCacheServiceProfiles());
-    } finally {
-      cacheServiceProfileUpdateLock.unlock();
-    }
-  }
-
   protected EventTracker createEventTracker() {
     return NonDistributedEventTracker.getInstance();
   }
@@ -10456,13 +10433,7 @@ public class LocalRegion extends AbstractRegion 
implements LoaderHelperFactory,
   }
 
   public void removeCacheServiceProfile(String profileID) {
-    cacheServiceProfileUpdateLock.lock();
-    try {
-      this.cacheServiceProfiles.remove(profileID);
-    } finally {
-      cacheServiceProfileUpdateLock.unlock();
-    }
-
+    this.cacheServiceProfiles.remove(profileID);
   }
 
   public AbstractGatewaySender getSerialGatewaySender() {
@@ -10524,12 +10495,7 @@ public class LocalRegion extends AbstractRegion 
implements LoaderHelperFactory,
   }
 
   public void addCacheServiceProfile(CacheServiceProfile profile) {
-    cacheServiceProfileUpdateLock.lock();
-    try {
-      this.cacheServiceProfiles.put(profile.getId(), profile);
-    } finally {
-      cacheServiceProfileUpdateLock.unlock();
-    }
+    this.cacheServiceProfiles.put(profile.getId(), profile);
   }
 
   @Override
diff --git 
a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
 
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
index 48d475b..f60b667 100644
--- 
a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
+++ 
b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/LuceneServiceImpl.java
@@ -252,10 +252,17 @@ public class LuceneServiceImpl implements 
InternalLuceneService {
     LuceneIndexCreationProfile luceneIndexCreationProfile = new 
LuceneIndexCreationProfile(
         indexName, regionPath, fields, analyzer, fieldAnalyzers, serializer);
 
-    Runnable validateIndexProfile =
-        getIndexValidationRunnable(region, indexName, 
luceneIndexCreationProfile);
-    region.executeSynchronizedOperationOnCacheProfiles(validateIndexProfile);
+    region.addCacheServiceProfile(luceneIndexCreationProfile);
 
+    try {
+      validateLuceneIndexProfile(region);
+    } catch (IllegalStateException e) {
+      region.removeCacheServiceProfile(luceneIndexCreationProfile.getId());
+      throw new UnsupportedOperationException(
+          
LocalizedStrings.LuceneIndexCreation_INDEX_CANNOT_BE_CREATED_DUE_TO_PROFILE_VIOLATION
+              .toString(indexName),
+          e);
+    }
     String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath);
     region.updatePRConfigWithNewGatewaySender(aeqId);
     LuceneIndexImpl luceneIndex = beforeDataRegionCreated(indexName, 
regionPath,
@@ -272,22 +279,6 @@ public class LuceneServiceImpl implements 
InternalLuceneService {
     createLuceneIndexOnDataRegion(region, luceneIndex);
   }
 
-  private Runnable getIndexValidationRunnable(PartitionedRegion region, String 
indexName,
-      LuceneIndexCreationProfile luceneIndexCreationProfile) {
-    return () -> {
-      region.addCacheServiceProfile(luceneIndexCreationProfile);
-      try {
-        validateLuceneIndexProfile(region);
-      } catch (IllegalStateException e) {
-        region.removeCacheServiceProfile(luceneIndexCreationProfile.getId());
-        throw new UnsupportedOperationException(
-            
LocalizedStrings.LuceneIndexCreation_INDEX_CANNOT_BE_CREATED_DUE_TO_PROFILE_VIOLATION
-                .toString(indexName),
-            e);
-      }
-    };
-  }
-
   protected void validateLuceneIndexProfile(PartitionedRegion region) {
     new CreateRegionProcessorForLucene(region).initializeRegion();
   }

Reply via email to