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/06 13:12:38 UTC
ignite git commit: IGNITE-3477 - Fixing cache store strategy
Repository: ignite
Updated Branches:
refs/heads/ignite-3477-debug eefebb241 -> 460e744dd
IGNITE-3477 - Fixing cache store strategy
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/460e744d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/460e744d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/460e744d
Branch: refs/heads/ignite-3477-debug
Commit: 460e744dd193a5e923f6a8596043bc9d5f4d24cf
Parents: eefebb2
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Apr 6 16:12:48 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Apr 6 16:12:48 2017 +0300
----------------------------------------------------------------------
.../processors/cache/H2CacheStoreStrategy.java | 36 +++++++++++++-------
1 file changed, 24 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/460e744d/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 b16725e..6261366 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));";
@@ -78,11 +81,11 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
Server srv = null;
try {
- srv = Server.createTcpServer("-trace").start();
+ srv = Server.createTcpServer().start();
- U.debug("Created H2 server: " + srv.getStatus());
+ port = srv.getPort();
- dataSrc = H2CacheStoreSessionListenerFactory.createDataSource();
+ dataSrc = H2CacheStoreSessionListenerFactory.createDataSource(port);
try (Connection conn = connection()) {
RunScript.execute(conn, new StringReader(CREATE_CACHE_TABLE));
@@ -91,11 +94,8 @@ public class H2CacheStoreStrategy implements TestCacheStoreStrategy {
}
}
catch (SQLException e) {
- if (srv != null) {
- U.debug("Exception caught, server: " + srv.getStatus());
- }
-
- throw new IgniteCheckedException(e);
+ throw new IgniteCheckedException("Failed to set up cache store strategy" +
+ (srv == null ? "" : ": " + srv.getStatus()), e);
}
}
@@ -251,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} */
@@ -269,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(100);
return pool;
}
@@ -281,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;
}
}