ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [4/4] ignite git commit: IGNITE-7725 Implemented cacheGroup and dataRegion params. Added tests.
Date Mon, 19 Feb 2018 15:26:24 GMT
IGNITE-7725 Implemented cacheGroup and dataRegion params. Added tests.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/192b7078
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/192b7078
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/192b7078

Branch: refs/heads/ignite-7725
Commit: 192b70782459c762d54ca25588f3f863b754177a
Parents: cd3d5fa
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Mon Feb 19 22:26:08 2018 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Mon Feb 19 22:26:08 2018 +0700

----------------------------------------------------------------------
 .../JettyRestProcessorAbstractSelfTest.java     | 75 ++++++++++++++++----
 .../cache/CacheConfigurationOverride.java       | 32 ++++-----
 .../http/jetty/GridJettyRestHandler.java        | 16 ++---
 3 files changed, 87 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/192b7078/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
index d3fc33a..a33f019 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/processors/rest/JettyRestProcessorAbstractSelfTest.java
@@ -48,6 +48,8 @@ import org.apache.ignite.cache.query.SqlQuery;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.DataStorageConfiguration;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
@@ -148,6 +150,7 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_ASYNC;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR;
+import static org.apache.ignite.internal.processors.query.QueryUtils.TEMPLATE_PARTITIONED;
 import static org.apache.ignite.internal.processors.query.QueryUtils.TEMPLATE_REPLICATED;
 
 /**
@@ -569,8 +572,15 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      * @param wrtSync Expected cache write synchronization mode.
      * @param params Optional cache params.
      */
-    private void checkGetOrCreateAndDestroy(String cacheName, CacheMode mode, int backups,
-        CacheWriteSynchronizationMode wrtSync, String... params) throws Exception {
+    private void checkGetOrCreateAndDestroy(
+        String cacheName,
+        CacheMode mode,
+        int backups,
+        CacheWriteSynchronizationMode wrtSync,
+        String cacheGroup,
+        String dataRegion,
+        String... params
+    ) throws Exception {
         String ret = content(cacheName, GridRestCommand.GET_OR_CREATE_CACHE, params);
 
         info("GetOrCreateCache command result: " + ret);
@@ -585,6 +595,12 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         assertEquals(mode, ccfg.getCacheMode());
         assertEquals(wrtSync, ccfg.getWriteSynchronizationMode());
 
+        if (!F.isEmpty(cacheGroup))
+            assertEquals(cacheGroup, ccfg.getGroupName());
+
+        if (!F.isEmpty(dataRegion))
+            assertEquals(dataRegion, ccfg.getDataRegionName());
+
         ret = content(cacheName, GridRestCommand.DESTROY_CACHE);
 
         assertTrue(jsonResponse(ret).isNull());
@@ -595,23 +611,49 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
      * @throws Exception If failed.
      */
     public void testGetOrCreateCache() throws Exception {
-        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 0, FULL_SYNC);
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 0, FULL_SYNC, null, null);
 
-        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 3, FULL_SYNC,
-            "backups", "3");
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 3, FULL_SYNC, null, null,
+            "backups", "3"
+        );
 
-        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 2, FULL_ASYNC,
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 2, FULL_ASYNC, null, null,
             "backups", "2",
-            "writeSynchronizationMode", FULL_ASYNC.name());
+            "writeSynchronizationMode", FULL_ASYNC.name()
+        );
 
-        checkGetOrCreateAndDestroy("testCache", REPLICATED, Integer.MAX_VALUE, FULL_ASYNC,
+        checkGetOrCreateAndDestroy("testCache", REPLICATED, Integer.MAX_VALUE, FULL_ASYNC,
null, null,
             "templateName", TEMPLATE_REPLICATED,
-            "writeSynchronizationMode", FULL_ASYNC.name());
+            "writeSynchronizationMode", FULL_ASYNC.name()
+        );
 
-        checkGetOrCreateAndDestroy("testCache", REPLICATED, Integer.MAX_VALUE, FULL_ASYNC,
+        checkGetOrCreateAndDestroy("testCache", REPLICATED, Integer.MAX_VALUE, FULL_ASYNC,
null, null,
             "templateName", TEMPLATE_REPLICATED,
             "backups", "0",
-            "writeSynchronizationMode", FULL_ASYNC.name());
+            "writeSynchronizationMode", FULL_ASYNC.name()
+        );
+
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 1, FULL_ASYNC, "testGroup",
null,
+            "templateName", TEMPLATE_PARTITIONED,
+            "backups", "1",
+            "writeSynchronizationMode", FULL_ASYNC.name(),
+            "cacheGroup", "testGroup"
+        );
+
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 2, FULL_ASYNC, null, "testDataRegion",
+            "templateName", TEMPLATE_PARTITIONED,
+            "backups", "2",
+            "writeSynchronizationMode", FULL_ASYNC.name(),
+            "dataRegion", "testDataRegion"
+        );
+
+        checkGetOrCreateAndDestroy("testCache", PARTITIONED, 3, FULL_ASYNC, "testGroup",
"testDataRegion",
+            "templateName", TEMPLATE_PARTITIONED,
+            "backups", "3",
+            "writeSynchronizationMode", FULL_ASYNC.name(),
+            "cacheGroup", "testGroup",
+            "dataRegion", "testDataRegion"
+        );
     }
 
     /**
@@ -2496,11 +2538,20 @@ public abstract class JettyRestProcessorAbstractSelfTest extends AbstractRestPro
         FileSystemConfiguration igfs = new FileSystemConfiguration();
 
         igfs.setName("igfs");
-
         igfs.setIpcEndpointConfiguration(new IgfsIpcEndpointConfiguration());
 
         cfg.setFileSystemConfiguration(igfs);
 
+        DataStorageConfiguration dsCfg = new DataStorageConfiguration();
+
+        DataRegionConfiguration drCfg = new DataRegionConfiguration();
+        drCfg.setName("testDataRegion");
+        drCfg.setMaxSize(100 * 1024 * 1024);
+
+        dsCfg.setDefaultDataRegionConfiguration(drCfg);
+
+        cfg.setDataStorageConfiguration(dsCfg);
+
         return cfg;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/192b7078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConfigurationOverride.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConfigurationOverride.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConfigurationOverride.java
index fcb7aab..7bd6072 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConfigurationOverride.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheConfigurationOverride.java
@@ -32,10 +32,10 @@ public class CacheConfigurationOverride {
     private Integer backups;
 
     /** */
-    private String grpName;
+    private String cacheGroup;
 
     /** */
-    private String dataRegName;
+    private String dataRegion;
 
     /** */
     private CacheWriteSynchronizationMode writeSync;
@@ -77,16 +77,16 @@ public class CacheConfigurationOverride {
     /**
      * @return Cache group name.
      */
-    public String groupName() {
-        return grpName;
+    public String cacheGroup() {
+        return cacheGroup;
     }
 
     /**
      * @param grpName New cache group name.
      * @return {@code this} for chaining.
      */
-    public CacheConfigurationOverride groupName(String grpName) {
-        this.grpName = grpName;
+    public CacheConfigurationOverride cacheGroup(String grpName) {
+        this.cacheGroup = grpName;
 
         return this;
     }
@@ -94,16 +94,16 @@ public class CacheConfigurationOverride {
     /**
      * @return Data region name.
      */
-    public String dataRegionName() {
-        return dataRegName;
+    public String dataRegion() {
+        return dataRegion;
     }
 
     /**
      * @param dataRegName Data region name.
      * @return {@code this} for chaining.
      */
-    public CacheConfigurationOverride dataRegionName(String dataRegName) {
-        this.dataRegName = dataRegName;
+    public CacheConfigurationOverride dataRegion(String dataRegName) {
+        this.dataRegion = dataRegName;
 
         return this;
     }
@@ -140,11 +140,11 @@ public class CacheConfigurationOverride {
         if (backups != null)
             ccfg.setBackups(backups);
 
-        if (grpName != null)
-            ccfg.setGroupName(grpName);
+        if (cacheGroup != null)
+            ccfg.setGroupName(cacheGroup);
 
-        if (dataRegName != null)
-            ccfg.setDataRegionName(dataRegName);
+        if (dataRegion != null)
+            ccfg.setDataRegionName(dataRegion);
 
         if (writeSync != null)
             ccfg.setWriteSynchronizationMode(writeSync);
@@ -158,8 +158,8 @@ public class CacheConfigurationOverride {
     public boolean isEmpty() {
         return mode == null &&
             backups == null &&
-            grpName == null &&
-            dataRegName == null &&
+            cacheGroup == null &&
+            dataRegion == null &&
             writeSync == null;
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/192b7078/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
index 768c941..7bad10d 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestHandler.java
@@ -85,10 +85,10 @@ public class GridJettyRestHandler extends AbstractHandler {
     private static final String BACKUPS_PARAM = "backups";
 
     /** */
-    private static final String GROUP_NAME_PARAM = "groupName";
+    private static final String CACHE_GROUP_PARAM = "cacheGroup";
 
     /** */
-    private static final String DATA_REGION_NAME_PARAM = "dataRegionName";
+    private static final String DATA_REGION_PARAM = "dataRegion";
 
     /** */
     private static final String WRITE_SYNCHRONIZATION_MODE_PARAM = "writeSynchronizationMode";
@@ -446,16 +446,16 @@ public class GridJettyRestHandler extends AbstractHandler {
                 }
 
                 // Set cache group name.
-                String grpName = (String)params.get(GROUP_NAME_PARAM);
+                String cacheGroup = (String)params.get(CACHE_GROUP_PARAM);
 
-                if (!F.isEmpty(grpName))
-                    cfg.groupName(grpName);
+                if (!F.isEmpty(cacheGroup))
+                    cfg.cacheGroup(cacheGroup);
 
                 // Set cache data region name.
-                String dataRegName = (String)params.get(DATA_REGION_NAME_PARAM);
+                String dataRegion = (String)params.get(DATA_REGION_PARAM);
 
-                if (!F.isEmpty(dataRegName))
-                    cfg.dataRegionName(dataRegName);
+                if (!F.isEmpty(dataRegion))
+                    cfg.dataRegion(dataRegion);
 
                 // Set cache write mode.
                 String wrtSyncMode = (String)params.get(WRITE_SYNCHRONIZATION_MODE_PARAM);


Mime
View raw message