You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/14 15:13:21 UTC

[04/50] [abbrv] ignite git commit: IGNITE-3477 - Fixing flaky full API suite

IGNITE-3477 - Fixing flaky full API suite


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

Branch: refs/heads/ignite-4587
Commit: 8d2b020c7068a000c2eeaa5096e24cdf8937125d
Parents: 1469f28
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Apr 13 16:36:54 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Apr 13 16:36:54 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/H2CacheStoreStrategy.java  | 35 ++++++++++++++++----
 1 file changed, 28 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8d2b020c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java
index 0167b7d..72b049b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/H2CacheStoreStrategy.java
@@ -54,6 +54,9 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
     /** Pool to get {@link Connection}s from. */
     private final JdbcConnectionPool dataSrc;
 
+    /** */
+    private final int port;
+
     /** Script that creates CACHE table. */
     private static final String CREATE_CACHE_TABLE =
         "create table if not exists CACHE(k binary not null, v binary not null, PRIMARY KEY(k));";
@@ -75,9 +78,14 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
      * @throws IgniteCheckedException If failed.
      */
     public H2CacheStoreStrategy() throws IgniteCheckedException {
+        Server srv = null;
+
         try {
-            Server.createTcpServer().start();
-            dataSrc = H2CacheStoreSessionListenerFactory.createDataSource();
+            srv = Server.createTcpServer().start();
+
+            port = srv.getPort();
+
+            dataSrc = H2CacheStoreSessionListenerFactory.createDataSource(port);
 
             try (Connection conn = connection()) {
                 RunScript.execute(conn, new StringReader(CREATE_CACHE_TABLE));
@@ -86,7 +94,8 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
             }
         }
         catch (SQLException e) {
-            throw new IgniteCheckedException(e);
+            throw new IgniteCheckedException("Failed to set up cache store strategy" +
+                (srv == null ? "" : ": " + srv.getStatus()), e);
         }
     }
 
@@ -242,7 +251,7 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
 
     /** {@inheritDoc} */
     @Override public void updateCacheConfiguration(CacheConfiguration<Object, Object> cfg) {
-        cfg.setCacheStoreSessionListenerFactories(new H2CacheStoreSessionListenerFactory());
+        cfg.setCacheStoreSessionListenerFactories(new H2CacheStoreSessionListenerFactory(port));
     }
 
     /** {@inheritDoc} */
@@ -260,11 +269,23 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
 
     /** Serializable {@link Factory} producing H2 backed {@link CacheStoreSessionListener}s. */
     public static class H2CacheStoreSessionListenerFactory implements Factory<CacheStoreSessionListener> {
+        /** */
+        private int port;
+
+        /**
+         * @param port Port.
+         */
+        public H2CacheStoreSessionListenerFactory(int port) {
+            this.port = port;
+        }
+
         /**
          * @return Connection pool
          */
-        static JdbcConnectionPool createDataSource() {
-            JdbcConnectionPool pool = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:TestDb;LOCK_MODE=0", "sa", "");
+        static JdbcConnectionPool createDataSource(int port) {
+            JdbcConnectionPool pool = JdbcConnectionPool.create("jdbc:h2:tcp://localhost:" + port +
+                "/mem:TestDb;LOCK_MODE=0", "sa", "");
+
             pool.setMaxConnections(Integer.getInteger("H2_JDBC_CONNECTIONS", 100));
             return pool;
         }
@@ -272,7 +293,7 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
         /** {@inheritDoc} */
         @Override public CacheStoreSessionListener create() {
             CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
-            lsnr.setDataSource(createDataSource());
+            lsnr.setDataSource(createDataSource(port));
             return lsnr;
         }
     }