You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by zh...@apache.org on 2019/04/08 18:26:50 UTC

[geode] branch feature/GEODE-6518 created (now 20b9bf1)

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

zhouxj pushed a change to branch feature/GEODE-6518
in repository https://gitbox.apache.org/repos/asf/geode.git.


      at 20b9bf1  GEODE-6518: when user explicitly specified some PartitionAttributes, such as redundency=1, the PartitionAttributes will not be null, but LocalMaxMemory could be null if the region is not accessor.

This branch includes the following new commits:

     new 20b9bf1  GEODE-6518: when user explicitly specified some PartitionAttributes, such as redundency=1, the PartitionAttributes will not be null, but LocalMaxMemory could be null if the region is not accessor.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[geode] 01/01: GEODE-6518: when user explicitly specified some PartitionAttributes, such as redundency=1, the PartitionAttributes will not be null, but LocalMaxMemory could be null if the region is not accessor.

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhouxj pushed a commit to branch feature/GEODE-6518
in repository https://gitbox.apache.org/repos/asf/geode.git

commit 20b9bf1c5aa11f93f266bffe3f17e8c788495d7f
Author: zhouxh <gz...@pivotal.io>
AuthorDate: Mon Apr 8 11:25:29 2019 -0700

    GEODE-6518: when user explicitly specified some PartitionAttributes, such as
    redundency=1, the PartitionAttributes will not be null, but LocalMaxMemory
    could be null if the region is not accessor.
    
    Co-authored-by: Xiaojian Zhou <gz...@pivotal.io>
    Co-authored-by: Benjamin Ross <br...@pivotal.io>
---
 .../geode/connectors/jdbc/JdbcDistributedTest.java | 38 ++++++++++++++++++++--
 .../util/internal/MappingCommandUtils.java         |  1 +
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcDistributedTest.java b/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcDistributedTest.java
index 12fa4a8..67c0a1e 100644
--- a/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcDistributedTest.java
+++ b/geode-connectors/src/acceptanceTest/java/org/apache/geode/connectors/jdbc/JdbcDistributedTest.java
@@ -23,11 +23,13 @@ import java.io.Serializable;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.DriverManager;
+import java.sql.JDBCType;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Date;
+import java.util.List;
 
 import org.junit.After;
 import org.junit.Before;
@@ -35,9 +37,14 @@ import org.junit.Rule;
 import org.junit.Test;
 
 import org.apache.geode.cache.Region;
+import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
 import org.apache.geode.cache.client.ClientCacheFactory;
 import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.connectors.jdbc.internal.JdbcConnectorService;
+import org.apache.geode.connectors.jdbc.internal.configuration.FieldMapping;
+import org.apache.geode.connectors.jdbc.internal.configuration.RegionMapping;
 import org.apache.geode.connectors.util.internal.MappingCommandUtils;
+import org.apache.geode.pdx.FieldType;
 import org.apache.geode.pdx.PdxInstance;
 import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
 import org.apache.geode.pdx.internal.AutoSerializableManager;
@@ -323,8 +330,31 @@ public abstract class JdbcDistributedTest implements Serializable {
     createTable();
     createPartitionRegionUsingGfsh();
     createJdbcDataSource();
-    createMapping(REGION_NAME, DATA_SOURCE_NAME, true);
-    startupRule.startServerVM(3, x -> x.withConnectionToLocator(locator.getPort()));
+    createMapping(REGION_NAME, DATA_SOURCE_NAME, false);
+    MemberVM server5 =
+        startupRule.startServerVM(3, x -> x.withConnectionToLocator(locator.getPort()));
+    server5.invoke(() -> {
+      RegionMapping mapping =
+          ClusterStartupRule.getCache().getService(JdbcConnectorService.class)
+              .getMappingForRegion(REGION_NAME);
+      assertThat(mapping.getDataSourceName()).isEqualTo(DATA_SOURCE_NAME);
+      assertThat(mapping.getPdxName()).isEqualTo(Employee.class.getName());
+      assertThat(mapping.getTableName()).isEqualTo(TABLE_NAME);
+      List<FieldMapping> fieldMappings = mapping.getFieldMappings();
+      assertThat(fieldMappings.size()).isEqualTo(3);
+      assertThat(fieldMappings.get(0)).isEqualTo(
+          new FieldMapping("name", FieldType.STRING.name(), "name", JDBCType.VARCHAR.name(),
+              true));
+      assertThat(fieldMappings.get(1)).isEqualTo(
+          new FieldMapping("id", FieldType.STRING.name(), "id", JDBCType.VARCHAR.name(), false));
+      assertThat(fieldMappings.get(2)).isEqualTo(
+          new FieldMapping("age", FieldType.INT.name(), "age", JDBCType.INTEGER.name(), false));
+
+      String queueName = MappingCommandUtils.createAsyncEventQueueName(REGION_NAME);
+      AsyncEventQueue queue = ClusterStartupRule.getCache().getAsyncEventQueue(queueName);
+      assertThat(queue).isNotNull();
+      assertThat(queue.getAsyncEventListener()).isInstanceOf(JdbcAsyncWriter.class);
+    });
   }
 
   @Test
@@ -751,7 +781,8 @@ public abstract class JdbcDistributedTest implements Serializable {
 
   private void createPartitionRegionUsingGfsh() {
     StringBuffer createRegionCmd = new StringBuffer();
-    createRegionCmd.append("create region --name=" + REGION_NAME + " --type=PARTITION");
+    createRegionCmd
+        .append("create region --name=" + REGION_NAME + " --type=PARTITION --redundant-copies=1");
     gfsh.executeAndAssertThat(createRegionCmd.toString()).statusIsSuccess();
   }
 
@@ -768,6 +799,7 @@ public abstract class JdbcDistributedTest implements Serializable {
       boolean synchronous, String ids) {
     final String commandStr = "create jdbc-mapping --region=" + regionName
         + " --data-source=" + connectionName
+        + " --table=" + TABLE_NAME
         + " --synchronous=" + synchronous
         + " --pdx-name=" + pdxClassName
         + ((ids != null) ? (" --id=" + ids) : "");
diff --git a/geode-connectors/src/main/java/org/apache/geode/connectors/util/internal/MappingCommandUtils.java b/geode-connectors/src/main/java/org/apache/geode/connectors/util/internal/MappingCommandUtils.java
index ddfb68b..d088369 100644
--- a/geode-connectors/src/main/java/org/apache/geode/connectors/util/internal/MappingCommandUtils.java
+++ b/geode-connectors/src/main/java/org/apache/geode/connectors/util/internal/MappingCommandUtils.java
@@ -90,6 +90,7 @@ public class MappingCommandUtils {
   public static boolean isAccessor(RegionAttributesType attributesType) {
     if (attributesType.getDataPolicy() == RegionAttributesDataPolicy.EMPTY
         || (attributesType.getPartitionAttributes() != null
+            && attributesType.getPartitionAttributes().getLocalMaxMemory() != null
             && attributesType.getPartitionAttributes().getLocalMaxMemory().equals("0"))) {
       return true;
     } else {