geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bogle...@apache.org
Subject incubator-geode git commit: GEODE-1641: The Gateway Conflict Resolver is supported again in cache.xml
Date Fri, 08 Jul 2016 21:25:33 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/develop 92d961a65 -> 71a9c14d4


GEODE-1641: The Gateway Conflict Resolver is supported again in cache.xml


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/71a9c14d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/71a9c14d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/71a9c14d

Branch: refs/heads/develop
Commit: 71a9c14d4b4a92f4c579dbd6f77fc91db31bba50
Parents: 92d961a
Author: Barry Oglesby <boglesby@pivotal.io>
Authored: Thu Jul 7 15:09:05 2016 -0700
Committer: Barry Oglesby <boglesby@pivotal.io>
Committed: Fri Jul 8 14:22:56 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/xmlcache/CacheXmlParser.java | 17 ++++++++++++++
 .../gemfire/internal/i18n/LocalizedStrings.java |  2 +-
 .../gemfire/cache30/CacheXml70DUnitTest.java    | 24 +++++++++++++++++++-
 3 files changed, 41 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/71a9c14d/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java
index 0564cb5..54b8063 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/xmlcache/CacheXmlParser.java
@@ -37,6 +37,7 @@ import javax.xml.XMLConstants;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
+import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
 import org.apache.logging.log4j.Logger;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
@@ -889,6 +890,19 @@ public class CacheXmlParser extends CacheXml implements ContentHandler
{
   }
 
   /**
+   * When a <code>gateway-conflict-resolver</code> element is encountered,
+   * create a new listener for the <code>Cache</code>.
+   */
+  private void endGatewayConflictResolver() {
+    Declarable d = createDeclarable();
+    if (!(d instanceof GatewayConflictResolver)) {
+      throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_GATEWAYCONFLICTRESOLVER.toLocalizedString(d.getClass().getName()));
+    }
+    CacheCreation c = (CacheCreation)stack.peek();
+    c.setGatewayConflictResolver((GatewayConflictResolver)d);
+  }
+
+  /**
    * When a <code>region</code> element is first encountered, we create a
    * {@link RegionCreation}and push it on the stack.
    */
@@ -3023,6 +3037,9 @@ public class CacheXmlParser extends CacheXml implements ContentHandler
{
       else if (qName.equals(REGION)) {
         endRegion();
       }
+      else if (qName.equals(GATEWAY_CONFLICT_RESOLVER)) {
+        endGatewayConflictResolver();
+      }
       else if (qName.equals(VM_ROOT_REGION)) {
         endRegion();
       }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/71a9c14d/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
index fa930f3..be1ff17 100755
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/i18n/LocalizedStrings.java
@@ -862,7 +862,7 @@ public class LocalizedStrings {
   public static final StringId AbstractRegionMap_ATTEMPT_TO_REMOVE_TOMBSTONE = new StringId(2018,
"Internal product error: attempt to directly remove a versioned tombstone from region entry
map");
   public static final StringId HostStatSampler_STATISTICS_SAMPLING_THREAD_DETECTED_A_WAKEUP_DELAY_OF_0_MS_INDICATING_A_POSSIBLE_RESOURCE_ISSUE
= new StringId(2019, "Statistics sampling thread detected a wakeup delay of {0} ms, indicating
a possible resource issue. Check the GC, memory, and CPU statistics.");
   public static final StringId ServerConnection_0__UNEXPECTED_EXCEPTION = new StringId(2020,
"{0} : Unexpected Exception");
-
+  public static final StringId CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_GATEWAYCONFLICTRESOLVER
= new StringId(2021, "A {0} is not an instance of a GatewayConflictResolver.");
   public static final StringId GemFireCacheImpl_TOMBSTONE_ERROR = new StringId(2022, "Unexpected
exception while processing tombstones");
   public static final StringId FunctionService_NO_MEMBERS_FOUND_IN_GROUPS = new StringId(2023,
"No members found in group(s) {0}");
   public static final StringId DistributionManager_Time_Skew_Warning = new StringId(2024,
"The clock for this machine may be more than 5 minutes different than the negotiated cache
time received from {0}");

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/71a9c14d/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml70DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml70DUnitTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml70DUnitTest.java
index 4492aa5..4e2cd0c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml70DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/cache30/CacheXml70DUnitTest.java
@@ -26,6 +26,9 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+import com.gemstone.gemfire.cache.util.GatewayConflictHelper;
+import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
+import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
@@ -115,6 +118,18 @@ public class CacheXml70DUnitTest extends CacheXml66DUnitTest {
   }
 
   @Test
+  public void testGatewayConflictResolver() throws CacheException {
+    CacheCreation cache = new CacheCreation();
+    cache.setGatewayConflictResolver(new MyGatewayConflictResolver());
+    testXml(cache);
+    Cache c = getCache();
+    assertNotNull(c);
+    GatewayConflictResolver gatewayConflictResolver = c.getGatewayConflictResolver();
+    assertNotNull(gatewayConflictResolver);
+    assertTrue(gatewayConflictResolver instanceof MyGatewayConflictResolver);
+  }
+
+    @Test
   public void testAsyncEventQueue() {
     getSystem();
     CacheCreation cache = new CacheCreation();
@@ -231,7 +246,14 @@ public class CacheXml70DUnitTest extends CacheXml66DUnitTest {
     public void init(Properties properties) {
     }
   }
-  
+
+  public static class MyGatewayConflictResolver implements GatewayConflictResolver, Declarable
{
+
+    public void onEvent(TimestampedEntryEvent event, GatewayConflictHelper helper) {}
+
+    public void init(Properties p) {}
+  }
+
   public static void validateAsyncEventQueue(AsyncEventQueue eventChannelFromXml, AsyncEventQueue
channel) {
     assertEquals("AsyncEventQueue id doesn't match", eventChannelFromXml.getId(), channel.getId());
     assertEquals("AsyncEventQueue batchSize doesn't match", eventChannelFromXml.getBatchSize(),
channel.getBatchSize());


Mime
View raw message