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

jinmeiliao 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 a36f6ad  GEODE-3876: gfsh command for custom expiry (#1401)
a36f6ad is described below

commit a36f6ad77ea4874f140f9961b0ceabb462299cfc
Author: jinmeiliao <jil...@pivotal.io>
AuthorDate: Mon Feb 12 09:19:07 2018 -0800

    GEODE-3876: gfsh command for custom expiry (#1401)
    
    * GEODE-3876: gfsh command for custom expiry
    
       gfsh create & alter commands now support custom expiry attributes.
    
    Signed-off-by: Sai Boorlagadda <sboorlaga...@pivotal.io>
---
 .../internal/cli/commands/AlterRegionCommand.java  |  7 +++
 .../internal/cli/commands/CreateRegionCommand.java | 15 +++++-
 .../cli/functions/RegionAlterFunction.java         | 20 ++++++++
 .../cli/functions/RegionCreateFunction.java        | 10 ++++
 .../internal/cli/functions/RegionFunctionArgs.java | 19 ++++++++
 .../management/internal/cli/i18n/CliStrings.java   | 14 ++++--
 .../geode/redis/internal/RegionProvider.java       |  4 +-
 .../sanctioned-geode-core-serializables.txt        |  2 +-
 .../internal/cli/GfshParserAutoCompletionTest.java |  2 +-
 .../cli/commands/AlterRegionCommandDUnitTest.java  | 55 +++++++++++++++++++---
 .../cli/commands/AlterRegionCommandTest.java       |  8 ++++
 .../cli/commands/CreateRegionCommandTest.java      |  6 +++
 12 files changed, 144 insertions(+), 18 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
index 1991eee..a024f92 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommand.java
@@ -23,6 +23,7 @@ import org.springframework.shell.core.annotation.CliOption;
 import org.apache.geode.cache.CacheListener;
 import org.apache.geode.cache.CacheLoader;
 import org.apache.geode.cache.CacheWriter;
+import org.apache.geode.cache.CustomExpiry;
 import org.apache.geode.cache.ExpirationAction;
 import org.apache.geode.distributed.DistributedMember;
 import org.apache.geode.internal.cache.InternalCache;
@@ -58,6 +59,10 @@ public class AlterRegionCommand implements GfshCommand {
       @CliOption(key = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION,
           specifiedDefaultValue = "INVALIDATE",
           help = CliStrings.ALTER_REGION__ENTRYEXPIRATIONTTLACTION__HELP) 
ExpirationAction entryExpirationTTLAction,
+      @CliOption(key = CliStrings.ENTRY_IDLE_TIME_CUSTOM_EXPIRY, 
specifiedDefaultValue = "",
+          help = CliStrings.ENTRY_IDLE_TIME_CUSTOM_EXPIRY_HELP) 
ClassName<CustomExpiry> entryIdleTimeCustomExpiry,
+      @CliOption(key = CliStrings.ENTRY_TTL_CUSTOM_EXPIRY, 
specifiedDefaultValue = "",
+          help = CliStrings.ENTRY_TTL_CUSTOM_EXPIRY_HELP) 
ClassName<CustomExpiry> entryTTLCustomExpiry,
       @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME,
           help = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIME__HELP) 
Integer regionExpirationIdleTime,
       @CliOption(key = CliStrings.ALTER_REGION__REGIONEXPIRATIONIDLETIMEACTION,
@@ -99,6 +104,8 @@ public class AlterRegionCommand implements GfshCommand {
     regionFunctionArgs.setEntryExpirationIdleTime(entryExpirationIdleTime,
         entryExpirationIdleTimeAction);
     regionFunctionArgs.setEntryExpirationTTL(entryExpirationTTL, 
entryExpirationTTLAction);
+    regionFunctionArgs.setEntryIdleTimeCustomExpiry(entryIdleTimeCustomExpiry);
+    regionFunctionArgs.setEntryTTLCustomExpiry(entryTTLCustomExpiry);
     regionFunctionArgs.setRegionExpirationIdleTime(regionExpirationIdleTime,
         regionExpirationIdleTimeAction);
     regionFunctionArgs.setRegionExpirationTTL(regionExpirationTTL, 
regionExpirationTTLAction);
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
index 012da67..1ffc6e5 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
@@ -28,6 +28,7 @@ import org.springframework.shell.core.annotation.CliOption;
 import org.apache.geode.cache.CacheListener;
 import org.apache.geode.cache.CacheLoader;
 import org.apache.geode.cache.CacheWriter;
+import org.apache.geode.cache.CustomExpiry;
 import org.apache.geode.cache.DataPolicy;
 import org.apache.geode.cache.EvictionAction;
 import org.apache.geode.cache.ExpirationAction;
@@ -64,7 +65,6 @@ import 
org.apache.geode.management.internal.security.ResourceOperation;
 import org.apache.geode.security.ResourcePermission;
 
 public class CreateRegionCommand implements GfshCommand {
-
   @CliCommand(value = CliStrings.CREATE_REGION, help = 
CliStrings.CREATE_REGION__HELP)
   @CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION,
       interceptor = 
"org.apache.geode.management.internal.cli.commands.CreateRegionCommand$Interceptor")
@@ -135,6 +135,10 @@ public class CreateRegionCommand implements GfshCommand {
           help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTIMETOLIVE__HELP) 
Integer entryExpirationTTL,
       @CliOption(key = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION,
           help = CliStrings.CREATE_REGION__ENTRYEXPIRATIONTTLACTION__HELP) 
ExpirationAction entryExpirationTTLAction,
+      @CliOption(key = CliStrings.ENTRY_IDLE_TIME_CUSTOM_EXPIRY,
+          help = CliStrings.ENTRY_IDLE_TIME_CUSTOM_EXPIRY_HELP) 
ClassName<CustomExpiry> entryIdleTimeCustomExpiry,
+      @CliOption(key = CliStrings.ENTRY_TTL_CUSTOM_EXPIRY,
+          help = CliStrings.ENTRY_TTL_CUSTOM_EXPIRY_HELP) 
ClassName<CustomExpiry> entryTTLCustomExpiry,
       @CliOption(key = CliStrings.CREATE_REGION__EVICTION_ACTION,
           help = CliStrings.CREATE_REGION__EVICTION_ACTION__HELP) String 
evictionAction,
       @CliOption(key = CliStrings.CREATE_REGION__EVICTION_ENTRY_COUNT,
@@ -210,6 +214,8 @@ public class CreateRegionCommand implements GfshCommand {
     functionArgs.setRegionExpirationIdleTime(regionExpirationIdleTime,
         regionExpirationIdleTimeAction);
     functionArgs.setRegionExpirationTTL(regionExpirationTTL, 
regionExpirationTTLAction);
+    functionArgs.setEntryIdleTimeCustomExpiry(entryIdleTimeCustomExpiry);
+    functionArgs.setEntryTTLCustomExpiry(entryTTLCustomExpiry);
     functionArgs.setEvictionAttributes(evictionAction, evictionMaxMemory, 
evictionEntryCount,
         evictionObjectSizer);
     functionArgs.setDiskStore(diskStore);
@@ -649,10 +655,15 @@ public class CreateRegionCommand implements GfshCommand {
           
.getParamValue(CliStrings.CREATE_REGION__REGIONEXPIRATIONIDLETIMEACTION);
       ExpirationAction regionTtlAction = (ExpirationAction) parseResult
           .getParamValue(CliStrings.CREATE_REGION__REGIONEXPIRATIONTTLACTION);
+      ClassName entryIdleExpiry =
+          (ClassName) 
parseResult.getParamValue(CliStrings.ENTRY_IDLE_TIME_CUSTOM_EXPIRY);
+      ClassName entryTTTLExpiry =
+          (ClassName) 
parseResult.getParamValue(CliStrings.ENTRY_TTL_CUSTOM_EXPIRY);
 
       if ((entryIdle != null || entryTtl != null || regionIdle != null || 
regionTtl != null
           || entryIdleAction != null || entryTtlAction != null || 
regionIdleAction != null
-          || regionTtlAction != null) && (statisticsEnabled == null || 
!statisticsEnabled)) {
+          || regionTtlAction != null || entryIdleExpiry != null || 
entryTTTLExpiry != null)
+          && (statisticsEnabled == null || !statisticsEnabled)) {
         String message =
             
LocalizedStrings.AttributesFactory_STATISTICS_MUST_BE_ENABLED_FOR_EXPIRATION
                 .toLocalizedString();
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
index 84dd2b1..2e686fe 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionAlterFunction.java
@@ -24,6 +24,7 @@ import org.apache.geode.cache.Cache;
 import org.apache.geode.cache.CacheListener;
 import org.apache.geode.cache.CacheLoader;
 import org.apache.geode.cache.CacheWriter;
+import org.apache.geode.cache.CustomExpiry;
 import org.apache.geode.cache.Region;
 import org.apache.geode.cache.execute.FunctionContext;
 import org.apache.geode.cache.execute.ResultSender;
@@ -140,6 +141,25 @@ public class RegionAlterFunction implements 
InternalFunction {
       }
     }
 
+    final ClassName<CustomExpiry> entryIdleCustomExpiry =
+        regionAlterArgs.getEntryIdleTimeCustomExpiry();
+    if (entryIdleCustomExpiry != null) {
+      if (entryIdleCustomExpiry.equals(ClassName.EMPTY)) {
+        mutator.setCustomEntryIdleTimeout(null);
+      } else {
+        mutator.setCustomEntryIdleTimeout(entryIdleCustomExpiry.newInstance());
+      }
+    }
+
+    final ClassName<CustomExpiry> entryTTLCustomExpiry = 
regionAlterArgs.getEntryTTLCustomExpiry();
+    if (entryTTLCustomExpiry != null) {
+      if (entryTTLCustomExpiry.equals(ClassName.EMPTY)) {
+        mutator.setCustomEntryTimeToLive(null);
+      } else {
+        mutator.setCustomEntryTimeToLive(entryTTLCustomExpiry.newInstance());
+      }
+    }
+
     final RegionFunctionArgs.ExpirationAttrs newRegionExpirationIdleTime =
         regionAlterArgs.getRegionExpirationIdleTime();
     if (newRegionExpirationIdleTime.isTimeOrActionSet()) {
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
index b8d0b10..9fba15c 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionCreateFunction.java
@@ -187,6 +187,16 @@ public class RegionCreateFunction implements 
InternalFunction {
     if (entryExpirationIdleTime.isTimeOrActionSet()) {
       
factory.setEntryIdleTimeout(entryExpirationIdleTime.getExpirationAttributes());
     }
+
+    if (regionCreateArgs.getEntryIdleTimeCustomExpiry() != null) {
+      factory
+          
.setCustomEntryIdleTimeout(regionCreateArgs.getEntryIdleTimeCustomExpiry().newInstance());
+    }
+
+    if (regionCreateArgs.getEntryTTLCustomExpiry() != null) {
+      
factory.setCustomEntryTimeToLive(regionCreateArgs.getEntryTTLCustomExpiry().newInstance());
+    }
+
     final RegionFunctionArgs.ExpirationAttrs entryExpirationTTL =
         regionCreateArgs.getEntryExpirationTTL();
     if (entryExpirationTTL.isTimeOrActionSet()) {
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
index f7735da..5b06ce3 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/functions/RegionFunctionArgs.java
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
 import org.apache.geode.cache.CacheListener;
 import org.apache.geode.cache.CacheLoader;
 import org.apache.geode.cache.CacheWriter;
+import org.apache.geode.cache.CustomExpiry;
 import org.apache.geode.cache.EvictionAction;
 import org.apache.geode.cache.EvictionAttributes;
 import org.apache.geode.cache.ExpirationAction;
@@ -54,6 +55,8 @@ public class RegionFunctionArgs implements Serializable {
   private Boolean statisticsEnabled;
   private ExpirationAttrs entryExpirationIdleTime;
   private ExpirationAttrs entryExpirationTTL;
+  private ClassName<CustomExpiry> entryIdleTimeCustomExpiry;
+  private ClassName<CustomExpiry> entryTTLCustomExpiry;
   private ExpirationAttrs regionExpirationIdleTime;
   private ExpirationAttrs regionExpirationTTL;
   private EvictionAttrs evictionAttributes;
@@ -447,6 +450,22 @@ public class RegionFunctionArgs implements Serializable {
     return (RegionAttributes<K, V>) this.regionAttributes;
   }
 
+  public ClassName<CustomExpiry> getEntryIdleTimeCustomExpiry() {
+    return entryIdleTimeCustomExpiry;
+  }
+
+  public void setEntryIdleTimeCustomExpiry(ClassName<CustomExpiry> 
entryIdleTimeCustomExpiry) {
+    this.entryIdleTimeCustomExpiry = entryIdleTimeCustomExpiry;
+  }
+
+  public ClassName<CustomExpiry> getEntryTTLCustomExpiry() {
+    return entryTTLCustomExpiry;
+  }
+
+  public void setEntryTTLCustomExpiry(ClassName<CustomExpiry> 
entryTTLCustomExpiry) {
+    this.entryTTLCustomExpiry = entryTTLCustomExpiry;
+  }
+
   /**
    * the difference between this and ExpirationAttributes is that this allows 
time and action to be
    * null
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
index 88db829..b502756 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/i18n/CliStrings.java
@@ -85,6 +85,12 @@ public class CliStrings {
 
   public static final String IFEXISTS_HELP =
       "If true, the command will be a no-op if the entity does not exist.";
+  public static final String ENTRY_IDLE_TIME_CUSTOM_EXPIRY = 
"entry-idle-time-custom-expiry";
+  public static final String ENTRY_TTL_CUSTOM_EXPIRY = 
"entry-time-to-live-custom-expiry";
+  public static final String ENTRY_IDLE_TIME_CUSTOM_EXPIRY_HELP =
+      "The name of the class implementing CustomExpiry for entry idle time. 
Append json string for initialization properties.";
+  public static final String ENTRY_TTL_CUSTOM_EXPIRY_HELP =
+      "The name of the class implementing CustomExpiry for entry time to live. 
Append json string for initialization properties.";
   private static final String LOG_LEVEL_VALUES =
       "Possible values for log-level include: ALL, TRACE, DEBUG, INFO, WARN, 
ERROR, FATAL, OFF.";
 
@@ -891,13 +897,13 @@ public class CliStrings {
       "Whether the server should conflate its messages to the client. A false 
value causes all server-client messages to be sent individually.";
   public static final String CREATE_REGION__CACHELISTENER = "cache-listener";
   public static final String CREATE_REGION__CACHELISTENER__HELP =
-      "Fully qualified class name of a plug-in to be instantiated for 
receiving after-event notification of changes to the region and its entries. 
Any number of cache listeners can be configured.";
+      "Fully qualified class name of a plug-in to be instantiated for 
receiving after-event notification of changes to the region and its entries. 
Append json string for initialization properties. Any number of cache listeners 
can be configured.";
   public static final String CREATE_REGION__CACHELOADER = "cache-loader";
   public static final String CREATE_REGION__CACHELOADER__HELP =
-      "Fully qualified class name of a plug-in to be instantiated for 
receiving notification of cache misses in the region. At most, one cache loader 
can be defined in each member for the region. For distributed regions, a cache 
loader may be invoked remotely from other members that have the region 
defined.";
+      "Fully qualified class name of a plug-in to be instantiated for 
receiving notification of cache misses in the region. Append json string for 
initialization properties. At most, one cache loader can be defined in each 
member for the region. For distributed regions, a cache loader may be invoked 
remotely from other members that have the region defined.";
   public static final String CREATE_REGION__CACHEWRITER = "cache-writer";
   public static final String CREATE_REGION__CACHEWRITER__HELP =
-      "Fully qualified class name of a plug-in to be instantiated for 
receiving before-event notification of changes to the region and its entries. 
The plug-in may cancel the event. At most, one cache writer can be defined in 
each member for the region.";
+      "Fully qualified class name of a plug-in to be instantiated for 
receiving before-event notification of changes to the region and its entries. 
Append json string for initialization properties. The plug-in may cancel the 
event. At most, one cache writer can be defined in each member for the region.";
   public static final String CREATE_REGION__ASYNCEVENTQUEUEID = 
"async-event-queue-id";
   public static final String CREATE_REGION__ASYNCEVENTQUEUEID__HELP =
       "IDs of the Async Event Queues that will be used for write-behind 
operations.";
@@ -3167,8 +3173,6 @@ public class CliStrings {
   public static final String START_SERVER__REDIRECT_OUTPUT__HELP =
       "Causes the member to redirect standard out and standard error to its 
own log file.";
 
-
-
   /**
    * Creates a MessageFormat with the given pattern and uses it to format the 
given argument.
    *
diff --git 
a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java 
b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
index de9f109..511a1c9 100644
--- 
a/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
+++ 
b/geode-core/src/main/java/org/apache/geode/redis/internal/RegionProvider.java
@@ -401,8 +401,8 @@ public class RegionProvider implements Closeable {
     do {
       Result result = createRegionCmd.createRegion(key, defaultRegionType, 
null, null, true, true,
           null, null, null, null, null, null, null, null, false, false, true, 
false, false, false,
-          true, null, null, null, null, null, null, null, null, null, null, 
null, false, null, null,
-          null, null, null, null, null, null, null, null, null);
+          true, null, null, null, null, null, null, null, null, null, null, 
null, null, null, false,
+          null, null, null, null, null, null, null, null, null, null, null);
 
       r = cache.getRegion(key);
       if (result.getStatus() == Status.ERROR && r == null) {
diff --git 
a/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-core-serializables.txt
 
b/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-core-serializables.txt
index 4ae3d39..599ad6f 100644
--- 
a/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-core-serializables.txt
+++ 
b/geode-core/src/main/resources/org/apache/geode/internal/sanctioned-geode-core-serializables.txt
@@ -557,7 +557,7 @@ 
org/apache/geode/management/internal/cli/functions/RegionAlterFunction,true,-484
 
org/apache/geode/management/internal/cli/functions/RegionAttributesWrapper,true,-5517424520268271436,cacheListenerClasses:java/util/List,cacheLoaderClass:org/apache/geode/management/internal/cli/domain/ClassName,cacheWriterClass:org/apache/geode/management/internal/cli/domain/ClassName,compressorClass:java/lang/String,keyConstraintClass:java/lang/String,regionAttributes:org/apache/geode/cache/RegionAttributes,valueConstraintClass:java/lang/String
 
org/apache/geode/management/internal/cli/functions/RegionCreateFunction,true,8746830191680509335
 
org/apache/geode/management/internal/cli/functions/RegionDestroyFunction,true,9172773671865750685
-org/apache/geode/management/internal/cli/functions/RegionFunctionArgs,true,2204943186081037302,asyncEventQueueIds:java/util/Set,cacheListeners:java/util/Set,cacheLoader:org/apache/geode/management/internal/cli/domain/ClassName,cacheWriter:org/apache/geode/management/internal/cli/domain/ClassName,cloningEnabled:java/lang/Boolean,compressor:java/lang/String,concurrencyChecksEnabled:java/lang/Boolean,concurrencyLevel:java/lang/Integer,diskStore:java/lang/String,diskSynchronous:java/lang/Boo
 [...]
+org/apache/geode/management/internal/cli/functions/RegionFunctionArgs,true,2204943186081037302,asyncEventQueueIds:java/util/Set,cacheListeners:java/util/Set,cacheLoader:org/apache/geode/management/internal/cli/domain/ClassName,cacheWriter:org/apache/geode/management/internal/cli/domain/ClassName,cloningEnabled:java/lang/Boolean,compressor:java/lang/String,concurrencyChecksEnabled:java/lang/Boolean,concurrencyLevel:java/lang/Integer,diskStore:java/lang/String,diskSynchronous:java/lang/Boo
 [...]
 
org/apache/geode/management/internal/cli/functions/RegionFunctionArgs$EvictionAttrs,true,9015454906371076014,evictionAction:java/lang/String,maxEntryCount:java/lang/Integer,maxMemory:java/lang/Integer,objectSizer:java/lang/String
 
org/apache/geode/management/internal/cli/functions/RegionFunctionArgs$ExpirationAttrs,true,1474255033398008063,action:org/apache/geode/cache/ExpirationAction,time:java/lang/Integer
 
org/apache/geode/management/internal/cli/functions/RegionFunctionArgs$PartitionArgs,true,5907052187323280919,partitionResolver:java/lang/String,prColocatedWith:java/lang/String,prLocalMaxMemory:java/lang/Integer,prRecoveryDelay:java/lang/Long,prRedundantCopies:java/lang/Integer,prStartupRecoveryDelay:java/lang/Long,prTotalMaxMemory:java/lang/Long,prTotalNumBuckets:java/lang/Integer
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
index b460a84..1462ac2 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserAutoCompletionTest.java
@@ -246,7 +246,7 @@ public class GfshParserAutoCompletionTest {
   public void testCompletWithRegionTypeWithSpace() throws Exception {
     buffer = "create region --name=test --type=REPLICATE ";
     candidate = parser.complete(buffer);
-    assertThat(candidate.size()).isEqualTo(43);
+    assertThat(candidate.size()).isEqualTo(45);
     assertThat(candidate.getFirstCandidate()).isEqualTo(buffer + 
"--async-event-queue-id");
   }
 
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
index f9af717..2954e65 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandDUnitTest.java
@@ -55,8 +55,8 @@ public class AlterRegionCommandDUnitTest {
   @ClassRule
   public static GfshCommandRule gfsh = new GfshCommandRule();
 
-  @Rule
-  public TemporaryFolder temporaryFolder = new TemporaryFolder();
+  @ClassRule
+  public static TemporaryFolder temporaryFolder = new TemporaryFolder();
 
   private static MemberVM locator, server1, server2, server3;
 
@@ -68,6 +68,8 @@ public class AlterRegionCommandDUnitTest {
     server3 = cluster.startServerVM(3, locator.getPort());
 
     gfsh.connectAndVerify(locator);
+
+    deployJarFilesForRegionAlter();
   }
 
   @Before
@@ -86,8 +88,6 @@ public class AlterRegionCommandDUnitTest {
   public void alterRegionResetCacheListeners() throws IOException {
     gfsh.executeAndAssertThat("create region --name=regionA 
--type=PARTITION").statusIsSuccess();
 
-    deployJarFilesForRegionAlter();
-
     String listenerABC =
         
"com.cadrdunit.RegionAlterCacheListenerA,com.cadrdunit.RegionAlterCacheListenerB,com.cadrdunit.RegionAlterCacheListenerC";
     gfsh.executeAndAssertThat("alter region --name=regionA --cache-listener=" 
+ listenerABC)
@@ -192,24 +192,55 @@ public class AlterRegionCommandDUnitTest {
         "alter region --name=regionA 
--entry-idle-time-expiration-action=invalidate")
         .statusIsError()
         .containsOutput("ERROR: Cannot set idle timeout when statistics are 
disabled.");
+
+    gfsh.executeAndAssertThat(
+        "alter region --name=regionA 
--entry-idle-time-custom-expiry=com.cadrdunit.RegionAlterCustomExpiry")
+        .statusIsError()
+        .containsOutput("ERROR: Cannot set idle timeout when statistics are 
disabled.");
   }
 
   @Test
-  public void alterRegionStatisticsEnabled() {
+  public void alterExpirationAttributesWithStatisticsEnabled() {
     gfsh.executeAndAssertThat("create region --name=regionA --type=REPLICATE 
--enable-statistics")
         .statusIsSuccess();
     gfsh.executeAndAssertThat(
         "alter region --name=regionA 
--entry-idle-time-expiration-action=invalidate")
         .statusIsSuccess();
+
+    gfsh.executeAndAssertThat(
+        "alter region --name=regionA 
--entry-idle-time-custom-expiry=com.cadrdunit.RegionAlterCustomExpiry")
+        .statusIsSuccess();
+
+    server1.invoke(() -> {
+      Region region = ClusterStartupRule.getCache().getRegion("regionA");
+      ExpirationAttributes expiry = 
region.getAttributes().getEntryIdleTimeout();
+      assertThat(expiry.getTimeout()).isEqualTo(0);
+      assertThat(expiry.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
+      
assertThat(region.getAttributes().getCustomEntryIdleTimeout().getClass().getName())
+          .isEqualTo("com.cadrdunit.RegionAlterCustomExpiry");
+    });
+
+    gfsh.executeAndAssertThat("alter region --name=regionA 
--entry-idle-time-custom-expiry=''")
+        .statusIsSuccess();
+
+    server1.invoke(() -> {
+      Region region = ClusterStartupRule.getCache().getRegion("regionA");
+      ExpirationAttributes expiry = 
region.getAttributes().getEntryIdleTimeout();
+      assertThat(expiry.getTimeout()).isEqualTo(0);
+      assertThat(expiry.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
+      assertThat(region.getAttributes().getCustomEntryIdleTimeout()).isNull();
+    });
   }
 
-  private void deployJarFilesForRegionAlter() throws IOException {
+  private static void deployJarFilesForRegionAlter() throws IOException {
     ClassBuilder classBuilder = new ClassBuilder();
     final File jarFile1 = new File(temporaryFolder.getRoot(), 
"testAlterRegion1.jar");
     final File jarFile2 = new File(temporaryFolder.getRoot(), 
"testAlterRegion2.jar");
     final File jarFile3 = new File(temporaryFolder.getRoot(), 
"testAlterRegion3.jar");
     final File jarFile4 = new File(temporaryFolder.getRoot(), 
"testAlterRegion4.jar");
     final File jarFile5 = new File(temporaryFolder.getRoot(), 
"testAlterRegion5.jar");
+    final File jarFile6 = new File(temporaryFolder.getRoot(), 
"testAlterRegion6.jar");
+
 
     byte[] jarBytes =
         
classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCacheListenerA",
@@ -245,9 +276,19 @@ public class AlterRegionCommandDUnitTest {
             + "public class RegionAlterCacheWriter extends CacheWriterAdapter 
{}");
     writeJarBytesToFile(jarFile5, jarBytes);
     gfsh.executeAndAssertThat("deploy --jar=" + 
jarFile5.getAbsolutePath()).statusIsSuccess();
+
+    jarBytes = 
classBuilder.createJarFromClassContent("com/cadrdunit/RegionAlterCustomExpiry",
+        "package com.cadrdunit;" + "import 
org.apache.geode.cache.CustomExpiry;"
+            + "import org.apache.geode.cache.Region.Entry;"
+            + "import org.apache.geode.cache.ExpirationAttributes;"
+            + "public class RegionAlterCustomExpiry implements CustomExpiry {"
+            + "public void close() {}"
+            + "public ExpirationAttributes getExpiry(Entry entry) {return 
null;}" + "}");
+    writeJarBytesToFile(jarFile6, jarBytes);
+    gfsh.executeAndAssertThat("deploy --jar=" + 
jarFile6.getAbsolutePath()).statusIsSuccess();
   }
 
-  private void writeJarBytesToFile(File jarFile, byte[] jarBytes) throws 
IOException {
+  private static void writeJarBytesToFile(File jarFile, byte[] jarBytes) 
throws IOException {
     final OutputStream outStream = new FileOutputStream(jarFile);
     outStream.write(jarBytes);
     outStream.flush();
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandTest.java
index 34a2ccf..9e86cef 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandTest.java
@@ -55,6 +55,7 @@ public class AlterRegionCommandTest {
     
assertThat(result.getParamValue("cache-writer")).isEqualTo(ClassName.EMPTY);
     assertThat(result.getParamValue("cache-listener")).isNull();
     
assertThat(result.getParamValue("cache-loader")).isEqualTo(ClassName.EMPTY);
+    assertThat(result.getParamValue("entry-idle-time-custom-expiry")).isNull();
   }
 
   @Test
@@ -63,4 +64,11 @@ public class AlterRegionCommandTest {
     GfshParseResult result = parser.parse(command);
     assertThat(result).isNull();
   }
+
+  @Test
+  public void emptyCustomExpiry() {
+    String command = "alter region --name=/Person 
--entry-idle-time-custom-expiry=''";
+    GfshParseResult result = parser.parse(command);
+    
assertThat(result.getParamValue("entry-idle-time-custom-expiry")).isEqualTo(ClassName.EMPTY);
+  }
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
index 677a0aa..fc52514 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandTest.java
@@ -365,5 +365,11 @@ public class CreateRegionCommandTest {
     parser
         .executeAndAssertThat(command, COMMAND + 
"--region-time-to-live-expiration-action=destroy")
         .statusIsError().containsOutput("Statistics must be enabled for 
expiration");
+
+    parser.executeAndAssertThat(command, COMMAND + 
"--entry-time-to-live-custom-expiry=abc")
+        .statusIsError().containsOutput("Statistics must be enabled for 
expiration");
+
+    parser.executeAndAssertThat(command, COMMAND + 
"--entry-idle-time-custom-expiry=abc")
+        .statusIsError().containsOutput("Statistics must be enabled for 
expiration");
   }
 }

-- 
To stop receiving notification emails like this one, please contact
jinmeil...@apache.org.

Reply via email to