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

jensdeppe 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 dc2b33d  GEODE-4656: Decribe region shows 
entry-idle-time-custom-expiry and entry-time-to-live-custom-expiry (#1455)
dc2b33d is described below

commit dc2b33d726fe4903abeb73d3de6381498896713f
Author: Jens Deppe <jde...@pivotal.io>
AuthorDate: Thu Feb 22 11:33:04 2018 -0800

    GEODE-4656: Decribe region shows entry-idle-time-custom-expiry and 
entry-time-to-live-custom-expiry (#1455)
---
 .../internal/cli/domain/RegionAttributesInfo.java  | 31 ++++++++++++++++++++++
 .../internal/cli/result/CommandResult.java         | 11 ++++----
 .../internal/cli/util/RegionAttributesNames.java   |  5 +++-
 .../cli/commands/DescribeRegionDUnitTest.java      | 28 +++++++++++++++++++
 .../cli/commands/DiskStoreCommandsDUnitTest.java   |  2 +-
 .../cli/commands/TestCustomIdleExpiry.java         | 30 +++++++++++++++++++++
 .../internal/cli/commands/TestCustomTTLExpiry.java | 30 +++++++++++++++++++++
 .../test/junit/assertions/CommandResultAssert.java | 16 +++++------
 .../internal/cli/LuceneIndexCommandsDUnitTest.java | 10 +++----
 9 files changed, 142 insertions(+), 21 deletions(-)

diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java
index faaa919..42738eb 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/domain/RegionAttributesInfo.java
@@ -28,6 +28,7 @@ import org.apache.commons.lang.StringUtils;
 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.EvictionAttributes;
 import org.apache.geode.cache.ExpirationAction;
@@ -84,6 +85,8 @@ public class RegionAttributesInfo implements Serializable {
   private String regionIdleTimeoutAction = 
ExpirationAction.INVALIDATE.toString();
 
   private boolean offHeap;
+  private String customExpiryIdleTimeoutClass = null;
+  private String customExpiryTTLClass = null;
 
   /***
    * Non-default-attribute map in the constructor
@@ -181,6 +184,16 @@ public class RegionAttributesInfo implements Serializable {
 
     }
     offHeap = ra.getOffHeap();
+
+    CustomExpiry<?, ?> customIdleTimeout = ra.getCustomEntryIdleTimeout();
+    if (customIdleTimeout != null) {
+      customExpiryIdleTimeoutClass = customIdleTimeout.getClass().getName();
+    }
+
+    CustomExpiry<?, ?> customTTL = ra.getCustomEntryTimeToLive();
+    if (customTTL != null) {
+      customExpiryTTLClass = customTTL.getClass().getName();
+    }
   }
 
 
@@ -318,6 +331,14 @@ public class RegionAttributesInfo implements Serializable {
     return offHeap;
   }
 
+  public String getCustomExpiryIdleTimeoutClass() {
+    return customExpiryIdleTimeoutClass;
+  }
+
+  public String getCustomExpiryTTLClass() {
+    return customExpiryTTLClass;
+  }
+
   @Override
   public boolean equals(Object arg0) {
     return super.equals(arg0);
@@ -493,6 +514,16 @@ public class RegionAttributesInfo implements Serializable {
           String.join(",", gatewaySenderIDs));
     }
 
+    if (StringUtils.isNotEmpty(customExpiryIdleTimeoutClass)) {
+      
nonDefaultAttributes.put(RegionAttributesNames.ENTRY_IDLE_TIME_CUSTOM_EXPIRY,
+          customExpiryIdleTimeoutClass);
+    }
+
+    if (StringUtils.isNotEmpty(customExpiryTTLClass)) {
+      
nonDefaultAttributes.put(RegionAttributesNames.ENTRY_TIME_TO_LIVE_CUSTOM_EXPIRY,
+          customExpiryTTLClass);
+    }
+
     return nonDefaultAttributes;
   }
 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
index b7aac06..ddc419d 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/result/CommandResult.java
@@ -23,6 +23,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Vector;
+import java.util.stream.Collectors;
 import java.util.zip.DataFormatException;
 
 import org.json.JSONArray;
@@ -690,19 +691,17 @@ public class CommandResult implements Result {
     this.fileToDownload = fileToDownload;
   }
 
-  public List<Object> getColumnValues(String columnName) {
-    Object[] actualValues =
-        
toArray(getTableContent().getInternalJsonObject().getJSONArray(columnName));
-    return Arrays.asList(actualValues);
+  public List<String> getColumnValues(String columnName) {
+    return 
toList(getTableContent().getInternalJsonObject().getJSONArray(columnName));
   }
 
-  private Object[] toArray(JSONArray array) {
+  public static List<String> toList(JSONArray array) {
     Object[] values = new Object[array.length()];
 
     for (int i = 0; i < array.length(); i++) {
       values[i] = array.get(i);
     }
 
-    return values;
+    return 
Arrays.stream(values).map(Object::toString).collect(Collectors.toList());
   }
 }
diff --git 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesNames.java
 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesNames.java
index 341a126..ddaf5e8 100644
--- 
a/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesNames.java
+++ 
b/geode-core/src/main/java/org/apache/geode/management/internal/cli/util/RegionAttributesNames.java
@@ -76,9 +76,12 @@ public class RegionAttributesNames {
   public static final String ENTRY_IDLE_TIMEOUT = "entry-idle-time.timeout";
   public static final String ENTRY_IDLE_TIMEOUT_ACTION = 
"entry-idle-time.action";
 
-
   // EVICTION ATTRIBUTES
   public static final String EVICTION_ACTION = "eviction-action";
   public static final String EVICTION_ALGORITHM = "eviction-algorithm";
   public static final String EVICTION_MAX_VALUE = "eviction-maximum-value";
+
+  // Expiration attributes
+  public static final String ENTRY_IDLE_TIME_CUSTOM_EXPIRY = 
"entry-idle-time-custom-expiry";
+  public static final String ENTRY_TIME_TO_LIVE_CUSTOM_EXPIRY = 
"entry-time-to-live-custom-expiry";
 }
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeRegionDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeRegionDUnitTest.java
index ad59cbc..cbdf444 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeRegionDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeRegionDUnitTest.java
@@ -18,6 +18,9 @@ import static 
org.apache.geode.management.internal.cli.i18n.CliStrings.DESCRIBE_
 import static 
org.apache.geode.management.internal.cli.i18n.CliStrings.DESCRIBE_REGION__NAME;
 import static org.assertj.core.api.Assertions.assertThat;
 
+import java.util.List;
+
+import org.json.JSONObject;
 import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
@@ -101,6 +104,8 @@ public class DescribeRegionDUnitTest {
           .addFixedPartitionAttributes(fpa).create();
       dataRegionFactory.setPartitionAttributes(pa);
 
+      dataRegionFactory.setCustomEntryIdleTimeout(new TestCustomIdleExpiry());
+
       dataRegionFactory.create(PR1);
       createLocalRegion(LOCAL_REGION);
     });
@@ -123,6 +128,9 @@ public class DescribeRegionDUnitTest {
           .addFixedPartitionAttributes(fpa).create();
       dataRegionFactory.setPartitionAttributes(pa);
 
+      dataRegionFactory.setCustomEntryIdleTimeout(new TestCustomIdleExpiry());
+      dataRegionFactory.setCustomEntryTimeToLive(new TestCustomTTLExpiry());
+
       dataRegionFactory.create(PR1);
       createRegionsWithSubRegions();
     });
@@ -158,6 +166,26 @@ public class DescribeRegionDUnitTest {
         .containsOutput(LOCAL_REGION, 
"server-1").doesNotContainOutput("server-2");
   }
 
+  @Test
+  public void describeRegionWithCustomExpiry() {
+    CommandResult result = gfsh.executeAndAssertThat("describe region --name=" 
+ PR1)
+        .statusIsSuccess().getCommandResult();
+
+    JSONObject table = result.getTableContent(0, 0, 0).getInternalJsonObject();
+    List<String> names = CommandResult.toList(table.getJSONArray("Name"));
+    
assertThat(names).containsOnlyOnce(RegionAttributesNames.ENTRY_IDLE_TIME_CUSTOM_EXPIRY);
+
+    List<String> values = CommandResult.toList(table.getJSONArray("Value"));
+    assertThat(values).containsOnlyOnce(TestCustomIdleExpiry.class.getName());
+
+    table = result.getTableContent(0, 1, 0).getInternalJsonObject();
+    names = CommandResult.toList(table.getJSONArray("Name"));
+    
assertThat(names).containsOnlyOnce(RegionAttributesNames.ENTRY_TIME_TO_LIVE_CUSTOM_EXPIRY);
+
+    values = CommandResult.toList(table.getJSONArray("Value"));
+    assertThat(values).containsOnlyOnce(TestCustomTTLExpiry.class.getName());
+  }
+
   /**
    * Asserts that a describe region command issued on a region with 
compression returns the correct
    * non default region attribute for compression and the correct codec value.
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
index 0aebe21..4d786d2 100644
--- 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DiskStoreCommandsDUnitTest.java
@@ -120,7 +120,7 @@ public class DiskStoreCommandsDUnitTest {
     gfsh.executeAndAssertThat("show missing-disk-stores").statusIsSuccess()
         .containsOutput("Missing Disk Stores", "No missing colocated region 
found");
 
-    List<Object> diskstoreIDs = gfsh.getCommandResult().getColumnValues("Disk 
Store ID");
+    List<String> diskstoreIDs = gfsh.getCommandResult().getColumnValues("Disk 
Store ID");
     assertThat(diskstoreIDs.size()).isEqualTo(1);
 
     gfsh.executeAndAssertThat("revoke missing-disk-store --id=" + 
diskstoreIDs.get(0))
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomIdleExpiry.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomIdleExpiry.java
new file mode 100644
index 0000000..e586ba3
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomIdleExpiry.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import org.apache.geode.cache.CustomExpiry;
+import org.apache.geode.cache.ExpirationAttributes;
+import org.apache.geode.cache.Region;
+
+public class TestCustomIdleExpiry implements CustomExpiry {
+  @Override
+  public ExpirationAttributes getExpiry(Region.Entry entry) {
+    return null;
+  }
+
+  @Override
+  public void close() {}
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomTTLExpiry.java
 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomTTLExpiry.java
new file mode 100644
index 0000000..69cc753
--- /dev/null
+++ 
b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/TestCustomTTLExpiry.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license
+ * agreements. See the NOTICE file distributed with this work for additional 
information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache 
License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the 
License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 
KIND, either express
+ * or implied. See the License for the specific language governing permissions 
and limitations under
+ * the License.
+ */
+
+package org.apache.geode.management.internal.cli.commands;
+
+import org.apache.geode.cache.CustomExpiry;
+import org.apache.geode.cache.ExpirationAttributes;
+import org.apache.geode.cache.Region;
+
+public class TestCustomTTLExpiry implements CustomExpiry {
+  @Override
+  public ExpirationAttributes getExpiry(Region.Entry entry) {
+    return null;
+  }
+
+  @Override
+  public void close() {}
+}
diff --git 
a/geode-core/src/test/java/org/apache/geode/test/junit/assertions/CommandResultAssert.java
 
b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/CommandResultAssert.java
index d46f92c..506eefb 100644
--- 
a/geode-core/src/test/java/org/apache/geode/test/junit/assertions/CommandResultAssert.java
+++ 
b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/CommandResultAssert.java
@@ -146,8 +146,8 @@ public class CommandResultAssert
    * </pre>
    */
   public CommandResultAssert tableHasColumnWithExactValuesInExactOrder(String 
header,
-      Object... expectedValues) {
-    List<Object> actualValues = 
actual.getCommandResult().getColumnValues(header);
+      String... expectedValues) {
+    List<String> actualValues = 
actual.getCommandResult().getColumnValues(header);
     assertThat(actualValues).containsExactly(expectedValues);
 
     return this;
@@ -174,8 +174,8 @@ public class CommandResultAssert
    * </pre>
    */
   public CommandResultAssert tableHasColumnWithExactValuesInAnyOrder(String 
header,
-      Object... expectedValues) {
-    List<Object> actualValues = 
actual.getCommandResult().getColumnValues(header);
+      String... expectedValues) {
+    List<String> actualValues = 
actual.getCommandResult().getColumnValues(header);
     assertThat(actualValues).containsExactlyInAnyOrder(expectedValues);
 
     return this;
@@ -193,10 +193,10 @@ public class CommandResultAssert
     String[] expectedValues =
         Arrays.copyOfRange(headersThenValues, numberOfColumn, 
headersThenValues.length);
 
-    Map<String, List<Object>> allValues = new HashMap<>();
+    Map<String, List<String>> allValues = new HashMap<>();
     int numberOfRows = -1;
     for (String header : headers) {
-      List<Object> columnValues = 
actual.getCommandResult().getColumnValues(header);
+      List<String> columnValues = 
actual.getCommandResult().getColumnValues(header);
       if (numberOfRows > 0) {
         assertThat(columnValues.size()).isEqualTo(numberOfRows);
       }
@@ -233,7 +233,7 @@ public class CommandResultAssert
    */
   public CommandResultAssert tableHasColumnWithValuesContaining(String header,
       String... expectedValues) {
-    List<Object> actualValues = 
actual.getCommandResult().getColumnValues(header);
+    List<String> actualValues = 
actual.getCommandResult().getColumnValues(header);
 
     for (Object actualValue : actualValues) {
       String actualValueString = (String) actualValue;
@@ -254,7 +254,7 @@ public class CommandResultAssert
    * one of the expectedValues.
    */
   public CommandResultAssert tableHasColumnOnlyWithValues(String header, 
String... expectedValues) {
-    List<Object> actualValues = 
actual.getCommandResult().getColumnValues(header);
+    List<String> actualValues = 
actual.getCommandResult().getColumnValues(header);
     assertThat(actualValues).containsOnly(expectedValues);
 
     return this;
diff --git 
a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
 
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
index 40a21c7..697d139 100755
--- 
a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
+++ 
b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java
@@ -96,7 +96,7 @@ public class LuceneIndexCommandsDUnitTest implements 
Serializable {
     CommandStringBuilder csb = new 
CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
     csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true");
     gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
-        .tableHasColumnWithExactValuesInAnyOrder("Documents", 0)
+        .tableHasColumnWithExactValuesInAnyOrder("Documents", "0")
         .tableHasColumnWithExactValuesInAnyOrder("Index Name", "index");
   }
 
@@ -143,10 +143,10 @@ public class LuceneIndexCommandsDUnitTest implements 
Serializable {
         .tableHasColumnWithExactValuesInAnyOrder("Index Name", INDEX_NAME)
         .tableHasColumnWithExactValuesInAnyOrder("Status", "Initialized")
         .tableHasColumnWithExactValuesInAnyOrder("Region Path", "/region")
-        .tableHasColumnWithExactValuesInAnyOrder("Query Executions", 1)
-        .tableHasColumnWithExactValuesInAnyOrder("Commits", 2)
-        .tableHasColumnWithExactValuesInAnyOrder("Updates", 2)
-        .tableHasColumnWithExactValuesInAnyOrder("Documents", 2);
+        .tableHasColumnWithExactValuesInAnyOrder("Query Executions", "1")
+        .tableHasColumnWithExactValuesInAnyOrder("Commits", "2")
+        .tableHasColumnWithExactValuesInAnyOrder("Updates", "2")
+        .tableHasColumnWithExactValuesInAnyOrder("Documents", "2");
 
   }
 

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

Reply via email to