IGNITE-7003: Fixed SQL WAL enable/disable command usability: throw exception in case...
authordevozerov <vozerov@gridgain.com>
Fri, 26 Jan 2018 08:20:06 +0000 (11:20 +0300)
committerdevozerov <vozerov@gridgain.com>
Fri, 26 Jan 2018 12:23:51 +0000 (15:23 +0300)
modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinWalModeChangeSelfTest.java
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/WalModeChangeCommonAbstractSelfTest.java
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/ddl/DdlStatementsProcessor.java
modules/yardstick/config/benchmark-atomic.properties

index 6a3ac52..2497d68 100644 (file)
@@ -26,6 +26,7 @@ import org.apache.ignite.internal.processors.query.QueryUtils;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
+import java.sql.SQLException;
 import java.sql.Statement;
 
 /**
@@ -64,20 +65,44 @@ public class JdbcThinWalModeChangeSelfTest extends WalModeChangeAbstractSelfTest
 
     /** {@inheritDoc} */
     @Override protected boolean walEnable(Ignite node, String cacheName) {
-        String cmd = "ALTER TABLE " + cacheName + " LOGGING";
+        try {
+            String cmd = "ALTER TABLE " + cacheName + " LOGGING";
 
-        execute(node, cmd);
+            execute(node, cmd);
+
+            return true;
+        }
+        catch (RuntimeException e) {
+            if (e.getCause() != null && e.getCause() instanceof SQLException) {
+                SQLException e0 = (SQLException)e.getCause();
 
-        return false;
+                if (e0.getMessage().startsWith("Logging already enabled"))
+                    return false;
+            }
+
+            throw e;
+        }
     }
 
     /** {@inheritDoc} */
     @Override protected boolean walDisable(Ignite node, String cacheName) {
-        String cmd = "ALTER TABLE " + cacheName + " NOLOGGING";
+        try {
+            String cmd = "ALTER TABLE " + cacheName + " NOLOGGING";
 
-        execute(node, cmd);
+            execute(node, cmd);
+
+            return true;
+        }
+        catch (RuntimeException e) {
+            if (e.getCause() != null && e.getCause() instanceof SQLException) {
+                SQLException e0 = (SQLException)e.getCause();
 
-        return false;
+                if (e0.getMessage().startsWith("Logging already disabled"))
+                    return false;
+            }
+
+            throw e;
+        }
     }
 
     /**
index 4467f7e..2e458f2 100644 (file)
@@ -161,8 +161,7 @@ public abstract class WalModeChangeCommonAbstractSelfTest extends GridCommonAbst
     protected void assertWalEnable(Ignite node, String cacheName, boolean expRes) {
         boolean res = walEnable(node, cacheName);
 
-        if (!jdbc)
-            assertEquals(expRes, res);
+        assertEquals(expRes, res);
     }
 
     /**
index 2630239..ca7680a 100644 (file)
@@ -188,10 +188,18 @@ public class DdlStatementsProcessor {
 
                 IgniteCluster cluster = ctx.grid().cluster();
 
-                if (logging)
-                    cluster.enableWal(tbl.cacheName());
-                else
-                    cluster.disableWal(tbl.cacheName());
+                if (logging) {
+                    boolean res = cluster.enableWal(tbl.cacheName());
+
+                    if (!res)
+                        throw new IgniteSQLException("Logging already enabled for table: " + cmd0.tableName());
+                }
+                else {
+                    boolean res = cluster.disableWal(tbl.cacheName());
+
+                    if (!res)
+                        throw new IgniteSQLException("Logging already disabled for table: " + cmd0.tableName());
+                }
 
                 fut = new GridFinishedFuture();
             }
index 8e2413b..1f4e0c3 100644 (file)
@@ -74,7 +74,7 @@ sm=PRIMARY_SYNC
 # Run configuration.
 # Note that each benchmark is set to run for 300 seconds (5 min) with warm-up set to 60 seconds (1 minute).
 CONFIGS="\
--cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteGetBenchmark -sn IgniteNode -ds ${ver}atomic-get-${b}-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteGetBenchmark -sn IgniteNode -ds ${ver}atomic-get-${b}-backup --single-shot ,\
 -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-${b}-backup,\
 -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-${b}-backup,\
 "