You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2015/05/23 03:49:28 UTC

[01/11] incubator-ignite git commit: Added config with client mode for Yardstick.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-891 7ab0304c8 -> 990bf9e38


Added config with client mode for Yardstick.


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

Branch: refs/heads/ignite-891
Commit: 02f3a12dbbe48f70df922f580dfa75b68add6912
Parents: d3cb5c4
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Fri May 22 13:47:18 2015 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Fri May 22 13:47:18 2015 +0300

----------------------------------------------------------------------
 .../config/benchmark-client-mode.properties     | 89 ++++++++++++++++++++
 1 file changed, 89 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/02f3a12d/modules/yardstick/config/benchmark-client-mode.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-client-mode.properties b/modules/yardstick/config/benchmark-client-mode.properties
new file mode 100644
index 0000000..8941417
--- /dev/null
+++ b/modules/yardstick/config/benchmark-client-mode.properties
@@ -0,0 +1,89 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Contains all multicast benchmarks
+#
+
+# JVM options.
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
+
+# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
+JVM_OPTS=${JVM_OPTS}" \
+-Xloggc:./gc.log \
+-XX:+PrintGCDetails \
+-verbose:gc \
+-XX:+UseParNewGC \
+-XX:+UseConcMarkSweepGC \
+-XX:+UseTLAB \
+-XX:NewSize=128m \
+-XX:MaxNewSize=128m \
+-XX:MaxTenuringThreshold=0 \
+-XX:SurvivorRatio=1024 \
+-XX:+UseCMSInitiatingOccupancyOnly \
+-XX:CMSInitiatingOccupancyFraction=60 \
+"
+#Ignite version
+ver="RELEASE-"
+
+# List of default probes.
+# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
+BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe
+
+# Packages where the specified benchmark is searched by reflection mechanism.
+BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
+
+RESTART_SERVERS=true
+
+# Probe point writer class name.
+# BENCHMARK_WRITER=
+
+# Comma-separated list of the hosts to run BenchmarkServers on.
+SERVER_HOSTS=localhost,localhost,localhost
+
+# Comma-separated list of the hosts to run BenchmarkDrivers on.
+DRIVER_HOSTS=localhost
+
+# Remote username.
+# REMOTE_USER=
+
+# Number of nodes, used to wait for the specified number of nodes to start.
+nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+
+# Run configuration which contains all benchmarks.
+# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute).
+CONFIGS="\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutTxBenchmark -sn IgniteNode -ds ${ver}tx-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -j 10 -dn IgniteAffinityCallBenchmark -sn IgniteNode -ds ${ver}affcall-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -j 10 -dn IgniteApplyBenchmark -sn IgniteNode -ds ${ver}apply-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -j 10 -dn IgniteBroadcastBenchmark -sn IgniteNode -ds ${ver}broad-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -j 10 -dn IgniteExecuteBenchmark -sn IgniteNode -ds ${ver}exec-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -j 10 -dn IgniteRunBenchmark -sn IgniteNode -ds ${ver}run-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 --client -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup\
+"


[03/11] incubator-ignite git commit: # Fixed downloaded Hive version to repair the Hadoop tests.

Posted by vk...@apache.org.
# Fixed downloaded Hive version to repair the Hadoop tests.


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

Branch: refs/heads/ignite-891
Commit: b375aaa90f31dd3ef140e10f30343a5d8f8eed57
Parents: 0acdc3d
Author: iveselovskiy <iv...@gridgain.com>
Authored: Fri May 22 15:57:11 2015 +0300
Committer: iveselovskiy <iv...@gridgain.com>
Committed: Fri May 22 15:57:11 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b375aaa9/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index 183087c..179f7f0 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -129,7 +129,7 @@ public class IgniteHadoopTestSuite extends TestSuite {
      * @throws Exception If failed.
      */
     public static void downloadHive() throws Exception {
-        String ver = IgniteSystemProperties.getString("hive.version", "0.13.1");
+        String ver = IgniteSystemProperties.getString("hive.version", "1.2.0");
 
         X.println("Will use Hive version: " + ver);
 


[04/11] incubator-ignite git commit: [IGNITE-909]: Support HadoopExternalSplit in HadoopV2Context to get pig jobs to function.

Posted by vk...@apache.org.
[IGNITE-909]: Support HadoopExternalSplit in HadoopV2Context to get pig jobs to function.


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

Branch: refs/heads/ignite-891
Commit: c2734e4135c5bda3126c0ad865eb0c8e886c16ad
Parents: b375aaa
Author: Evans Ye <in...@gmail.com>
Authored: Fri May 22 16:00:42 2015 +0300
Committer: iveselovskiy <iv...@gridgain.com>
Committed: Fri May 22 16:00:42 2015 +0300

----------------------------------------------------------------------
 .../internal/processors/hadoop/v2/HadoopV2Context.java    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c2734e41/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Context.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Context.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Context.java
index 3f8e2b6..53159b1 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Context.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/v2/HadoopV2Context.java
@@ -89,12 +89,12 @@ public class HadoopV2Context extends JobContextImpl implements MapContext, Reduc
 
                 inputSplit = new FileSplit(new Path(fileBlock.file()), fileBlock.start(), fileBlock.length(), null);
             }
-            else if (split instanceof HadoopExternalSplit)
-                throw new UnsupportedOperationException(); // TODO
-            else if (split instanceof HadoopSplitWrapper)
-                inputSplit = (InputSplit) HadoopUtils.unwrapSplit((HadoopSplitWrapper) split);
             else
-                throw new IllegalStateException();
+                try {
+                    inputSplit = (InputSplit) ((HadoopV2TaskContext)ctx).getNativeSplit(split);
+                } catch (IgniteCheckedException e) {
+                    throw new IllegalStateException(e);
+                }
         }
 
         return inputSplit;


[11/11] incubator-ignite git commit: IGNITE-891 - Cache store improvements

Posted by vk...@apache.org.
IGNITE-891 - Cache store improvements


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

Branch: refs/heads/ignite-891
Commit: 990bf9e38b405e97d0be1891be7680423208b279
Parents: b5b4523
Author: Valentin Kulichenko <vk...@gridgain.com>
Authored: Fri May 22 18:49:04 2015 -0700
Committer: Valentin Kulichenko <vk...@gridgain.com>
Committed: Fri May 22 18:49:04 2015 -0700

----------------------------------------------------------------------
 .../hibernate/CacheHibernatePersonStore.java    | 183 +--------------
 .../hibernate/CacheHibernateStoreExample.java   |  16 ++
 .../store/jdbc/CacheJdbcPersonStore.java        |  18 +-
 .../store/jdbc/CacheJdbcStoreExample.java       |   2 +-
 .../ignite/cache/store/CacheStoreSession.java   |   5 +
 .../cache/store/CacheStoreSessionListener.java  |  10 +-
 .../jdbc/CacheJdbcStoreSessionListener.java     | 143 +++++++++++
 .../jdbc/CacheStoreSessionJdbcListener.java     | 148 ------------
 .../store/GridCacheStoreManagerAdapter.java     |  32 +++
 .../CacheJdbcStoreSessionListenerSelfTest.java  | 175 ++++++++++++++
 .../CacheStoreSessionJdbcListenerSelfTest.java  | 182 --------------
 .../junits/cache/TestCacheSession.java          |  14 ++
 .../cache/TestThreadLocalCacheSession.java      |  16 ++
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +-
 .../CacheHibernateStoreSessionListener.java     | 218 +++++++++++++++++
 .../CacheStoreSessionHibernateListener.java     | 223 ------------------
 ...heHibernateStoreSessionListenerSelfTest.java | 228 ++++++++++++++++++
 ...heStoreSessionHibernateListenerSelfTest.java | 235 -------------------
 .../testsuites/IgniteHibernateTestSuite.java    |   2 +-
 .../spring/CacheSpringStoreSessionListener.java | 233 ++++++++++++++++++
 .../spring/CacheStoreSessionSpringListener.java | 235 -------------------
 ...CacheSpringStoreSessionListenerSelfTest.java | 197 ++++++++++++++++
 ...CacheStoreSessionSpringListenerSelfTest.java | 204 ----------------
 .../testsuites/IgniteSpringTestSuite.java       |   2 +-
 24 files changed, 1303 insertions(+), 1420 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
index 577301c..557ec6f 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java
@@ -21,10 +21,7 @@ import org.apache.ignite.cache.store.*;
 import org.apache.ignite.examples.datagrid.store.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.Transaction;
 import org.hibernate.*;
-import org.hibernate.cfg.*;
-import org.jetbrains.annotations.*;
 
 import javax.cache.integration.*;
 import java.util.*;
@@ -34,57 +31,30 @@ import java.util.*;
  * and deals with maps {@link UUID} to {@link Person}.
  */
 public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
-    /** Default hibernate configuration resource path. */
-    private static final String DFLT_HIBERNATE_CFG = "/org/apache/ignite/examples/datagrid/store/hibernate" +
-        "/hibernate.cfg.xml";
-
-    /** Session attribute name. */
-    private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
-
-    /** Session factory. */
-    private SessionFactory sesFactory;
-
     /** Auto-injected store session. */
     @CacheStoreSessionResource
     private CacheStoreSession ses;
 
-    /**
-     * Default constructor.
-     */
-    public CacheHibernatePersonStore() {
-        sesFactory = new Configuration().configure(DFLT_HIBERNATE_CFG).buildSessionFactory();
-    }
-
     /** {@inheritDoc} */
     @Override public Person load(Long key) {
-        Transaction tx = transaction();
-
-        System.out.println(">>> Store load [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
+        System.out.println(">>> Store load [key=" + key + ']');
 
-        Session ses = session(tx);
+        Session hibSes = ses.attachment();
 
         try {
-            return (Person) ses.get(Person.class, key);
+            return (Person)hibSes.get(Person.class, key);
         }
         catch (HibernateException e) {
-            rollback(ses, tx);
-
-            throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
-        }
-        finally {
-            end(ses, tx);
+            throw new CacheLoaderException("Failed to load value from cache store [key=" + key + ']', e);
         }
     }
 
     /** {@inheritDoc} */
     @Override public void write(javax.cache.Cache.Entry<? extends Long, ? extends Person> entry) {
-        Transaction tx = transaction();
-
         Long key = entry.getKey();
-
         Person val = entry.getValue();
 
-        System.out.println(">>> Store put [key=" + key + ", val=" + val + ", xid=" + (tx == null ? null : tx.xid()) + ']');
+        System.out.println(">>> Store put [key=" + key + ", val=" + val + ']');
 
         if (val == null) {
             delete(key);
@@ -92,41 +62,29 @@ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
             return;
         }
 
-        Session ses = session(tx);
+        Session hibSes = ses.attachment();
 
         try {
-            ses.saveOrUpdate(val);
+            hibSes.saveOrUpdate(val);
         }
         catch (HibernateException e) {
-            rollback(ses, tx);
-
             throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
         }
-        finally {
-            end(ses, tx);
-        }
     }
 
     /** {@inheritDoc} */
     @SuppressWarnings({"JpaQueryApiInspection"})
     @Override public void delete(Object key) {
-        Transaction tx = transaction();
-
-        System.out.println(">>> Store remove [key=" + key + ", xid=" + (tx == null ? null : tx.xid()) + ']');
+        System.out.println(">>> Store remove [key=" + key + ']');
 
-        Session ses = session(tx);
+        Session hibSes = ses.attachment();
 
         try {
-            ses.createQuery("delete " + Person.class.getSimpleName() + " where key = :key")
+            hibSes.createQuery("delete " + Person.class.getSimpleName() + " where key = :key")
                 .setParameter("key", key).setFlushMode(FlushMode.ALWAYS).executeUpdate();
         }
         catch (HibernateException e) {
-            rollback(ses, tx);
-
-            throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
-        }
-        finally {
-            end(ses, tx);
+            throw new CacheWriterException("Failed to remove value from cache store [key=" + key + ']', e);
         }
     }
 
@@ -137,12 +95,12 @@ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
 
         final int entryCnt = (Integer)args[0];
 
-        Session ses = session(null);
+        Session hibSes = ses.attachment();
 
         try {
             int cnt = 0;
 
-            List res = ses.createCriteria(Person.class).list();
+            List res = hibSes.createCriteria(Person.class).list();
 
             if (res != null) {
                 Iterator iter = res.iterator();
@@ -161,120 +119,5 @@ public class CacheHibernatePersonStore extends CacheStoreAdapter<Long, Person> {
         catch (HibernateException e) {
             throw new CacheLoaderException("Failed to load values from cache store.", e);
         }
-        finally {
-            end(ses, null);
-        }
-    }
-
-    /**
-     * Rolls back hibernate session.
-     *
-     * @param ses Hibernate session.
-     * @param tx Cache ongoing transaction.
-     */
-    private void rollback(Session ses, Transaction tx) {
-        // Rollback only if there is no cache transaction,
-        // otherwise sessionEnd() will do all required work.
-        if (tx == null) {
-            org.hibernate.Transaction hTx = ses.getTransaction();
-
-            if (hTx != null && hTx.isActive())
-                hTx.rollback();
-        }
-    }
-
-    /**
-     * Ends hibernate session.
-     *
-     * @param ses Hibernate session.
-     * @param tx Cache ongoing transaction.
-     */
-    private void end(Session ses, @Nullable Transaction tx) {
-        // Commit only if there is no cache transaction,
-        // otherwise sessionEnd() will do all required work.
-        if (tx == null) {
-            org.hibernate.Transaction hTx = ses.getTransaction();
-
-            if (hTx != null && hTx.isActive())
-                hTx.commit();
-
-            ses.close();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void sessionEnd(boolean commit) {
-        Transaction tx = ses.transaction();
-
-        Map<String, Session> props = ses.properties();
-
-        Session ses = props.remove(ATTR_SES);
-
-        if (ses != null) {
-            org.hibernate.Transaction hTx = ses.getTransaction();
-
-            if (hTx != null) {
-                try {
-                    if (commit) {
-                        ses.flush();
-
-                        hTx.commit();
-                    }
-                    else
-                        hTx.rollback();
-
-                    System.out.println("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
-                }
-                catch (HibernateException e) {
-                    throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
-                        ", commit=" + commit + ']', e);
-                }
-                finally {
-                    ses.close();
-                }
-            }
-        }
-    }
-
-    /**
-     * Gets Hibernate session.
-     *
-     * @param tx Cache transaction.
-     * @return Session.
-     */
-    private Session session(@Nullable Transaction tx) {
-        Session hbSes;
-
-        if (tx != null) {
-            Map<String, Session> props = ses.properties();
-
-            hbSes = props.get(ATTR_SES);
-
-            if (hbSes == null) {
-                hbSes = sesFactory.openSession();
-
-                hbSes.beginTransaction();
-
-                // Store session in session properties, so it can be accessed
-                // for other operations on the same transaction.
-                props.put(ATTR_SES, hbSes);
-
-                System.out.println("Hibernate session open [ses=" + hbSes + ", tx=" + tx.xid() + "]");
-            }
-        }
-        else {
-            hbSes = sesFactory.openSession();
-
-            hbSes.beginTransaction();
-        }
-
-        return hbSes;
-    }
-
-    /**
-     * @return Current transaction.
-     */
-    @Nullable private Transaction transaction() {
-        return ses != null ? ses.transaction() : null;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
index 5a0cd0a..ac19072 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernateStoreExample.java
@@ -18,6 +18,8 @@
 package org.apache.ignite.examples.datagrid.store.hibernate;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.cache.store.hibernate.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.examples.*;
 import org.apache.ignite.examples.datagrid.store.*;
@@ -37,6 +39,10 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*;
  * start node with {@code examples/config/example-ignite.xml} configuration.
  */
 public class CacheHibernateStoreExample {
+    /** Hibernate configuration resource path. */
+    private static final String HIBERNATE_CFG =
+        "/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml";
+
     /** Cache name. */
     private static final String CACHE_NAME = CacheHibernateStoreExample.class.getSimpleName();
 
@@ -71,6 +77,16 @@ public class CacheHibernateStoreExample {
             // Configure Hibernate store.
             cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(CacheHibernatePersonStore.class));
 
+            cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
+                @Override public CacheStoreSessionListener create() {
+                    CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
+
+                    lsnr.setHibernateConfigurationPath(HIBERNATE_CFG);
+
+                    return lsnr;
+                }
+            });
+
             cacheCfg.setReadThrough(true);
             cacheCfg.setWriteThrough(true);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
index 856512b..6eb0386 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java
@@ -19,7 +19,6 @@ package org.apache.ignite.examples.datagrid.store.jdbc;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.store.*;
-import org.apache.ignite.cache.store.jdbc.*;
 import org.apache.ignite.examples.datagrid.store.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.resources.*;
@@ -70,7 +69,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
         System.out.println(">>> Loading key: " + key);
 
         try {
-            Connection conn = connection();
+            Connection conn = ses.attachment();
 
             try (PreparedStatement st = conn.prepareStatement("select * from PERSONS where id=?")) {
                 st.setString(1, key.toString());
@@ -97,7 +96,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
         System.out.println(">>> Putting [key=" + key + ", val=" + val +  ']');
 
         try {
-            Connection conn = connection();
+            Connection conn = ses.attachment();
 
             int updated;
 
@@ -134,7 +133,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
         System.out.println(">>> Removing key: " + key);
 
         try {
-            Connection conn = connection();
+            Connection conn = ses.attachment();
 
             try (PreparedStatement st = conn.prepareStatement("delete from PERSONS where id=?")) {
                 st.setLong(1, (Long)key);
@@ -154,7 +153,7 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
 
         final int entryCnt = (Integer)args[0];
 
-        Connection conn = connection();
+        Connection conn = ses.attachment();
 
         try (
             PreparedStatement st = conn.prepareStatement("select * from PERSONS");
@@ -176,13 +175,4 @@ public class CacheJdbcPersonStore extends CacheStoreAdapter<Long, Person> {
             throw new CacheLoaderException("Failed to load values from cache store.", e);
         }
     }
-
-    /**
-     * Gets JDBC connection attached to current session.
-     *
-     * @return Connection.
-     */
-    private Connection connection() {
-        return ses.<String, Connection>properties().get(CacheStoreSessionJdbcListener.JDBC_CONN_KEY);
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
index 82e1079..74e262c 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcStoreExample.java
@@ -77,7 +77,7 @@ public class CacheJdbcStoreExample {
             // Configure JDBC session listener.
             cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
                 @Override public CacheStoreSessionListener create() {
-                    CacheStoreSessionJdbcListener lsnr = new CacheStoreSessionJdbcListener();
+                    CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
 
                     lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:mem:example;DB_CLOSE_DELAY=-1", "", ""));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSession.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSession.java
index 640d4a3..980c6df 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSession.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSession.java
@@ -19,6 +19,7 @@ package org.apache.ignite.cache.store;
 
 import org.apache.ignite.resources.*;
 import org.apache.ignite.transactions.*;
+import org.jetbrains.annotations.*;
 
 import java.util.*;
 
@@ -51,6 +52,10 @@ public interface CacheStoreSession {
      */
     public boolean isWithinTransaction();
 
+    public void attach(@Nullable Object attachment);
+
+    @Nullable public <T> T attachment();
+
     /**
      * Gets current session properties. You can add properties directly to the
      * returned map.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSessionListener.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSessionListener.java
index 8b7cd8f..b319e55 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSessionListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStoreSessionListener.java
@@ -52,20 +52,20 @@ import javax.sql.*;
  * details):
  * <ul>
  *     <li>
- *         {@link CacheStoreSessionJdbcListener} - JDBC-based session
+ *         {@link CacheJdbcStoreSessionListener} - JDBC-based session
  *         listener. For each session it gets a new JDBC connection from
  *         provided {@link DataSource} and commits (or rolls back) it
  *         when session ends.
  *     </li>
  *     <li>
- *         {@ignitelink org.apache.ignite.cache.store.spring.CacheStoreSessionSpringListener} -
+ *         {@ignitelink org.apache.ignite.cache.store.spring.CacheSpringStoreSessionListener} -
  *         session listener based on Spring transaction management.
  *         It starts a new DB transaction for each session and commits
  *         (or rolls back) it when session ends. If there is no ongoing
  *         cache transaction, this listener is no-op.
  *     </li>
  *     <li>
- *         <@ignitelink org.apache.ignite.cache.store.hibernate.CacheStoreSessionHibernateListener} -
+ *         <@ignitelink org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListener} -
  *         Hibernate-based session listener. It creates a new Hibernate
  *         session for each Ignite session. If there is an ongoing cache
  *         transaction, a corresponding Hibernate transaction is created
@@ -89,7 +89,7 @@ import javax.sql.*;
  *         cache participates in transaction.
  *     </li>
  * </ul>
- * For example, here is how global {@link CacheStoreSessionJdbcListener}
+ * For example, here is how global {@link CacheJdbcStoreSessionListener}
  * can be configured in Spring XML configuration file:
  * <pre name="code" class="xml">
  * &lt;bean class="org.apache.ignite.configuration.IgniteConfiguration"&gt;
@@ -99,7 +99,7 @@ import javax.sql.*;
  *         &lt;list&gt;
  *             &lt;bean class="javax.cache.configuration.FactoryBuilder$SingletonFactory"&gt;
  *                 &lt;constructor-arg&gt;
- *                     &lt;bean class="org.apache.ignite.cache.store.jdbc.CacheStoreSessionJdbcListener"&gt;
+ *                     &lt;bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener"&gt;
  *                         &lt;!-- Inject external data source. --&gt;
  *                         &lt;property name="dataSource" ref="jdbc-data-source"/&gt;
  *                     &lt;/bean&gt;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListener.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListener.java
new file mode 100644
index 0000000..c59e86f
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListener.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.jdbc;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lifecycle.*;
+
+import javax.cache.*;
+import javax.cache.integration.*;
+import javax.sql.*;
+import java.sql.*;
+
+/**
+ * Cache store session listener based on JDBC connection.
+ * <p>
+ * For each session this listener gets a new JDBC connection
+ * from provided {@link DataSource} and commits (or rolls
+ * back) it when session ends.
+ * <p>
+ * The connection is saved as a store session
+  * {@link CacheStoreSession#attachment() attachment}.
+ * The listener guarantees that the connection will be
+ * available for any store operation. If there is an
+ * ongoing cache transaction, all operations within this
+ * transaction will be committed or rolled back only when
+ * session ends.
+ * <p>
+ * As an example, here is how the {@link CacheStore#write(Cache.Entry)}
+ * method can be implemented if {@link CacheJdbcStoreSessionListener}
+ * is configured:
+ * <pre name="code" class="java">
+ * private static class Store extends CacheStoreAdapter&lt;Integer, Integer&gt; {
+ *     &#64;CacheStoreSessionResource
+ *     private CacheStoreSession ses;
+ *
+ *     &#64;Override public void write(Cache.Entry&lt;? extends Integer, ? extends Integer&gt; entry) throws CacheWriterException {
+ *         // Get connection from the current session.
+ *         Connection conn = ses.attachment();
+ *
+ *         // Execute update SQL query.
+ *         try {
+ *             conn.createStatement().executeUpdate("...");
+ *         }
+ *         catch (SQLException e) {
+ *             throw new CacheWriterException("Failed to update the store.", e);
+ *         }
+ *     }
+ * }
+ * </pre>
+ * JDBC connection will be automatically created by the listener
+ * at the start of the session and closed when it ends.
+ */
+public class CacheJdbcStoreSessionListener implements CacheStoreSessionListener, LifecycleAware {
+    /** Data source. */
+    private DataSource dataSrc;
+
+    /**
+     * Sets data source.
+     * <p>
+     * This is a required parameter. If data source is not set,
+     * exception will be thrown on startup.
+     *
+     * @param dataSrc Data source.
+     */
+    public void setDataSource(DataSource dataSrc) {
+        this.dataSrc = dataSrc;
+    }
+
+    /**
+     * Gets data source.
+     *
+     * @return Data source.
+     */
+    public DataSource getDataSource() {
+        return dataSrc;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        if (dataSrc == null)
+            throw new IgniteException("Data source is required by " + getClass().getSimpleName() + '.');
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionStart(CacheStoreSession ses) {
+        if (ses.attachment() == null) {
+            try {
+                Connection conn = dataSrc.getConnection();
+
+                conn.setAutoCommit(false);
+
+                ses.attach(conn);
+            }
+            catch (SQLException e) {
+                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
+        Connection conn = ses.attachment();
+
+        if (conn != null) {
+            ses.attach(null);
+
+            try {
+                if (commit)
+                    conn.commit();
+                else
+                    conn.rollback();
+            }
+            catch (SQLException e) {
+                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
+            }
+            finally {
+                U.closeQuiet(conn);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListener.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListener.java
deleted file mode 100644
index 7920fae..0000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListener.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.jdbc;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lifecycle.*;
-
-import javax.cache.*;
-import javax.cache.integration.*;
-import javax.sql.*;
-import java.sql.*;
-import java.util.*;
-
-/**
- * Cache store session listener based on JDBC connection.
- * <p>
- * For each session this listener gets a new JDBC connection
- * from provided {@link DataSource} and commits (or rolls
- * back) it when session ends.
- * <p>
- * The connection is stored in store session
- * {@link CacheStoreSession#properties() properties} and can
- * be accessed at any moment by {@link #JDBC_CONN_KEY} key.
- * The listener guarantees that the connection will be
- * available for any store operation. If there is an
- * ongoing cache transaction, all operations within this
- * transaction will be committed or rolled back only when
- * session ends.
- * <p>
- * As an example, here is how the {@link CacheStore#write(Cache.Entry)}
- * method can be implemented if {@link CacheStoreSessionJdbcListener}
- * is configured:
- * <pre name="code" class="java">
- * private static class Store extends CacheStoreAdapter&lt;Integer, Integer&gt; {
- *     &#64;CacheStoreSessionResource
- *     private CacheStoreSession ses;
- *
- *     &#64;Override public void write(Cache.Entry&lt;? extends Integer, ? extends Integer&gt; entry) throws CacheWriterException {
- *         // Get connection from the current session.
- *         Connection conn = ses.<String, Connection>properties().get(CacheStoreSessionJdbcListener.JDBC_CONN_KEY);
- *
- *         // Execute update SQL query.
- *         try {
- *             conn.createStatement().executeUpdate("...");
- *         }
- *         catch (SQLException e) {
- *             throw new CacheWriterException("Failed to update the store.", e);
- *         }
- *     }
- * }
- * </pre>
- * JDBC connection will be automatically created by the listener
- * at the start of the session and closed when it ends.
- */
-public class CacheStoreSessionJdbcListener implements CacheStoreSessionListener, LifecycleAware {
-    /** Session key for JDBC connection. */
-    public static final String JDBC_CONN_KEY = "__jdbc_conn_";
-
-    /** Data source. */
-    private DataSource dataSrc;
-
-    /**
-     * Sets data source.
-     * <p>
-     * This is a required parameter. If data source is not set,
-     * exception will be thrown on startup.
-     *
-     * @param dataSrc Data source.
-     */
-    public void setDataSource(DataSource dataSrc) {
-        this.dataSrc = dataSrc;
-    }
-
-    /**
-     * Gets data source.
-     *
-     * @return Data source.
-     */
-    public DataSource getDataSource() {
-        return dataSrc;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start() throws IgniteException {
-        if (dataSrc == null)
-            throw new IgniteException("Data source is required by " + getClass().getSimpleName() + '.');
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() throws IgniteException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionStart(CacheStoreSession ses) {
-        Map<String, Connection> props = ses.properties();
-
-        if (!props.containsKey(JDBC_CONN_KEY)) {
-            try {
-                Connection conn = dataSrc.getConnection();
-
-                conn.setAutoCommit(false);
-
-                props.put(JDBC_CONN_KEY, conn);
-            }
-            catch (SQLException e) {
-                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
-        Connection conn = ses.<String, Connection>properties().remove(JDBC_CONN_KEY);
-
-        if (conn != null) {
-            try {
-                if (commit)
-                    conn.commit();
-                else
-                    conn.rollback();
-            }
-            catch (SQLException e) {
-                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
-            }
-            finally {
-                U.closeQuiet(conn);
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
index 8096291..11d711c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/GridCacheStoreManagerAdapter.java
@@ -855,6 +855,9 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
         private Map<Object, Object> props;
 
         /** */
+        private Object attachment;
+
+        /** */
         private boolean started;
 
         /** */
@@ -887,6 +890,20 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
         }
 
         /**
+         * @param attachment Attachment.
+         */
+        private void attach(Object attachment) {
+            this.attachment = attachment;
+        }
+
+        /**
+         * @return Attachment.
+         */
+        private Object attachment() {
+            return attachment;
+        }
+
+        /**
          * @return Cache name.
          */
         private String cacheName() {
@@ -954,6 +971,21 @@ public abstract class GridCacheStoreManagerAdapter extends GridCacheManagerAdapt
         }
 
         /** {@inheritDoc} */
+        @Override public void attach(@Nullable Object attachment) {
+            SessionData ses0 = sesHolder.get();
+
+            if (ses0 != null)
+                ses0.attach(attachment);
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public <T> T attachment() {
+            SessionData ses0 = sesHolder.get();
+
+            return ses0 != null ? (T)ses0.attachment() : null;
+        }
+
+        /** {@inheritDoc} */
         @Override public <K1, V1> Map<K1, V1> properties() {
             SessionData ses0 = sesHolder.get();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java
new file mode 100644
index 0000000..64af249
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreSessionListenerSelfTest.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.jdbc;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.h2.jdbcx.*;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.integration.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Tests for {@link CacheJdbcStoreSessionListener}.
+ */
+public class CacheJdbcStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
+        return new Factory<CacheStore<Integer, Integer>>() {
+            @Override public CacheStore<Integer, Integer> create() {
+                return new Store();
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
+        return new Factory<CacheStoreSessionListener>() {
+            @Override public CacheStoreSessionListener create() {
+                CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
+
+                lsnr.setDataSource(JdbcConnectionPool.create(URL, "", ""));
+
+                return lsnr;
+            }
+        };
+    }
+
+    /**
+     */
+    private static class Store extends CacheStoreAdapter<Integer, Integer> {
+        /** */
+        private static String SES_CONN_KEY = "ses_conn";
+
+        /** */
+        @CacheStoreSessionResource
+        private CacheStoreSession ses;
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
+            loadCacheCnt.incrementAndGet();
+
+            checkConnection();
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer load(Integer key) throws CacheLoaderException {
+            loadCnt.incrementAndGet();
+
+            checkConnection();
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
+            throws CacheWriterException {
+            writeCnt.incrementAndGet();
+
+            checkConnection();
+
+            if (write.get()) {
+                Connection conn = ses.attachment();
+
+                try {
+                    String table;
+
+                    switch (ses.cacheName()) {
+                        case "cache1":
+                            table = "Table1";
+
+                            break;
+
+                        case "cache2":
+                            if (fail.get())
+                                throw new CacheWriterException("Expected failure.");
+
+                            table = "Table2";
+
+                            break;
+
+                        default:
+                            throw new CacheWriterException("Wring cache: " + ses.cacheName());
+                    }
+
+                    PreparedStatement stmt = conn.prepareStatement(
+                        "INSERT INTO " + table + " (key, value) VALUES (?, ?)");
+
+                    stmt.setInt(1, entry.getKey());
+                    stmt.setInt(2, entry.getValue());
+
+                    stmt.executeUpdate();
+                }
+                catch (SQLException e) {
+                    throw new CacheWriterException(e);
+                }
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            deleteCnt.incrementAndGet();
+
+            checkConnection();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sessionEnd(boolean commit) {
+            assertNull(ses.attachment());
+        }
+
+        /**
+         */
+        private void checkConnection() {
+            Connection conn = ses.attachment();
+
+            assertNotNull(conn);
+
+            try {
+                assertFalse(conn.isClosed());
+                assertFalse(conn.getAutoCommit());
+            }
+            catch (SQLException e) {
+                throw new RuntimeException(e);
+            }
+
+            verifySameInstance(conn);
+        }
+
+        /**
+         * @param conn Connection.
+         */
+        private void verifySameInstance(Connection conn) {
+            Map<String, Connection> props = ses.properties();
+
+            Connection sesConn = props.get(SES_CONN_KEY);
+
+            if (sesConn == null)
+                props.put(SES_CONN_KEY, conn);
+            else {
+                assertSame(conn, sesConn);
+
+                reuseCnt.incrementAndGet();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListenerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListenerSelfTest.java
deleted file mode 100644
index e4dac88..0000000
--- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheStoreSessionJdbcListenerSelfTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.jdbc;
-
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.h2.jdbcx.*;
-
-import javax.cache.*;
-import javax.cache.configuration.*;
-import javax.cache.integration.*;
-import java.sql.*;
-import java.util.*;
-
-/**
- * Tests for {@link CacheStoreSessionJdbcListener}.
- */
-public class CacheStoreSessionJdbcListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
-        return new Factory<CacheStore<Integer, Integer>>() {
-            @Override public CacheStore<Integer, Integer> create() {
-                return new Store();
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
-        return new Factory<CacheStoreSessionListener>() {
-            @Override public CacheStoreSessionListener create() {
-                CacheStoreSessionJdbcListener lsnr = new CacheStoreSessionJdbcListener();
-
-                lsnr.setDataSource(JdbcConnectionPool.create(URL, "", ""));
-
-                return lsnr;
-            }
-        };
-    }
-
-    /**
-     */
-    private static class Store extends CacheStoreAdapter<Integer, Integer> {
-        /** */
-        private static String SES_CONN_KEY = "ses_conn";
-
-        /** */
-        @CacheStoreSessionResource
-        private CacheStoreSession ses;
-
-        /** {@inheritDoc} */
-        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
-            loadCacheCnt.incrementAndGet();
-
-            checkConnection();
-        }
-
-        /** {@inheritDoc} */
-        @Override public Integer load(Integer key) throws CacheLoaderException {
-            loadCnt.incrementAndGet();
-
-            checkConnection();
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
-            throws CacheWriterException {
-            writeCnt.incrementAndGet();
-
-            checkConnection();
-
-            if (write.get()) {
-                Connection conn = connection();
-
-                try {
-                    String table;
-
-                    switch (ses.cacheName()) {
-                        case "cache1":
-                            table = "Table1";
-
-                            break;
-
-                        case "cache2":
-                            if (fail.get())
-                                throw new CacheWriterException("Expected failure.");
-
-                            table = "Table2";
-
-                            break;
-
-                        default:
-                            throw new CacheWriterException("Wring cache: " + ses.cacheName());
-                    }
-
-                    PreparedStatement stmt = conn.prepareStatement(
-                        "INSERT INTO " + table + " (key, value) VALUES (?, ?)");
-
-                    stmt.setInt(1, entry.getKey());
-                    stmt.setInt(2, entry.getValue());
-
-                    stmt.executeUpdate();
-                }
-                catch (SQLException e) {
-                    throw new CacheWriterException(e);
-                }
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void delete(Object key) throws CacheWriterException {
-            deleteCnt.incrementAndGet();
-
-            checkConnection();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void sessionEnd(boolean commit) {
-            assertNull(connection());
-        }
-
-        /**
-         */
-        private void checkConnection() {
-            Connection conn = connection();
-
-            assertNotNull(conn);
-
-            try {
-                assertFalse(conn.isClosed());
-                assertFalse(conn.getAutoCommit());
-            }
-            catch (SQLException e) {
-                throw new RuntimeException(e);
-            }
-
-            verifySameInstance(conn);
-        }
-
-        /**
-         * @param conn Connection.
-         */
-        private void verifySameInstance(Connection conn) {
-            Map<String, Connection> props = ses.properties();
-
-            Connection sesConn = props.get(SES_CONN_KEY);
-
-            if (sesConn == null)
-                props.put(SES_CONN_KEY, conn);
-            else {
-                assertSame(conn, sesConn);
-
-                reuseCnt.incrementAndGet();
-            }
-        }
-
-        /**
-         * @return Connection.
-         */
-        private Connection connection() {
-            return ses.<String, Connection>properties().get(CacheStoreSessionJdbcListener.JDBC_CONN_KEY);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestCacheSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestCacheSession.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestCacheSession.java
index 0709880..bc7bf7d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestCacheSession.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestCacheSession.java
@@ -34,6 +34,9 @@ public class TestCacheSession implements CacheStoreSession {
     /** */
     private Map<Object, Object> props;
 
+    /** */
+    private Object attachment;
+
     /**
      *
      * @param tx Transaction.
@@ -55,6 +58,17 @@ public class TestCacheSession implements CacheStoreSession {
     }
 
     /** {@inheritDoc} */
+    @Override public void attach(@Nullable Object attachment) {
+        this.attachment = attachment;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Nullable @Override public <T> T attachment() {
+        return (T)attachment;
+    }
+
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <K, V> Map<K, V> properties() {
         if (props == null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestThreadLocalCacheSession.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestThreadLocalCacheSession.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestThreadLocalCacheSession.java
index 2bbcf1b..2047600 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestThreadLocalCacheSession.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/cache/TestThreadLocalCacheSession.java
@@ -54,6 +54,22 @@ public class TestThreadLocalCacheSession implements CacheStoreSession {
     }
 
     /** {@inheritDoc} */
+    @Override public void attach(@Nullable Object attachment) {
+        TestCacheSession ses = sesHolder.get();
+
+        if (ses != null)
+            ses.attach(attachment);
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Nullable @Override public <T> T attachment() {
+        TestCacheSession ses = sesHolder.get();
+
+        return ses!= null ? (T)ses.attachment() : null;
+    }
+
+    /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <K, V> Map<K, V> properties() {
         TestCacheSession ses = sesHolder.get();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index afb67f5..60c7a0a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -131,7 +131,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
 
         suite.addTestSuite(CacheOffheapMapEntrySelfTest.class);
 
-        suite.addTestSuite(CacheStoreSessionJdbcListenerSelfTest.class);
+        suite.addTestSuite(CacheJdbcStoreSessionListenerSelfTest.class);
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
new file mode 100644
index 0000000..61f7265
--- /dev/null
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.hibernate;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lifecycle.*;
+import org.apache.ignite.resources.*;
+import org.hibernate.*;
+import org.hibernate.cfg.*;
+
+import javax.cache.integration.*;
+import java.io.*;
+import java.net.*;
+
+/**
+ * Hibernate-based cache store session listener.
+ * <p>
+ * This listener creates a new Hibernate session for each store
+ * session. If there is an ongoing cache transaction, a corresponding
+ * Hibernate transaction is created as well.
+ * <p>
+ * The Hibernate session is saved as a store session
+ * {@link CacheStoreSession#attachment() attachment}.
+ * The listener guarantees that the session will be
+ * available for any store operation. If there is an
+ * ongoing cache transaction, all operations within this
+ * transaction will share a DB transaction.
+ * <p>
+ * As an example, here is how the {@link CacheStore#write(javax.cache.Cache.Entry)}
+ * method can be implemented if {@link CacheHibernateStoreSessionListener}
+ * is configured:
+ * <pre name="code" class="java">
+ * private static class Store extends CacheStoreAdapter&lt;Integer, Integer&gt; {
+ *     &#64;CacheStoreSessionResource
+ *     private CacheStoreSession ses;
+ *
+ *     &#64;Override public void write(Cache.Entry&lt;? extends Integer, ? extends Integer&gt; entry) throws CacheWriterException {
+ *         // Get Hibernate session from the current store session.
+ *         Session hibSes = ses.attachment();
+ *
+ *         // Persist the value.
+ *         hibSes.persist(entry.getValue());
+ *     }
+ * }
+ * </pre>
+ * Hibernate session will be automatically created by the listener
+ * at the start of the session and closed when it ends.
+ * <p>
+ * {@link CacheHibernateStoreSessionListener} requires that either
+ * {@link #setSessionFactory(SessionFactory)} session factory}
+ * or {@link #setHibernateConfigurationPath(String) Hibernate configuration file}
+ * is provided. If non of them is set, exception is thrown. Is both are provided,
+ * session factory will be used.
+ */
+public class CacheHibernateStoreSessionListener implements CacheStoreSessionListener, LifecycleAware {
+    /** Hibernate session factory. */
+    private SessionFactory sesFactory;
+
+    /** Hibernate configuration file path. */
+    private String hibernateCfgPath;
+
+    /** Logger. */
+    @LoggerResource
+    private IgniteLogger log;
+
+    /** Whether to close session on stop. */
+    private boolean closeSesOnStop;
+
+    /**
+     * Sets Hibernate session factory.
+     * <p>
+     * Either session factory or configuration file is required.
+     * If none is provided, exception will be thrown on startup.
+     *
+     * @param sesFactory Session factory.
+     */
+    public void setSessionFactory(SessionFactory sesFactory) {
+        this.sesFactory = sesFactory;
+    }
+
+    /**
+     * Gets Hibernate session factory.
+     *
+     * @return Session factory.
+     */
+    public SessionFactory getSessionFactory() {
+        return sesFactory;
+    }
+
+    /**
+     * Sets hibernate configuration path.
+     * <p>
+     * Either session factory or configuration file is required.
+     * If none is provided, exception will be thrown on startup.
+     *
+     * @param hibernateCfgPath Hibernate configuration path.
+     */
+    public void setHibernateConfigurationPath(String hibernateCfgPath) {
+        this.hibernateCfgPath = hibernateCfgPath;
+    }
+
+    /**
+     * Gets hibernate configuration path.
+     *
+     * @return Hibernate configuration path.
+     */
+    public String getHibernateConfigurationPath() {
+        return hibernateCfgPath;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("deprecation")
+    @Override public void start() throws IgniteException {
+        if (sesFactory == null && F.isEmpty(hibernateCfgPath))
+            throw new IgniteException("Either session factory or Hibernate configuration file is required by " +
+                getClass().getSimpleName() + '.');
+
+        if (!F.isEmpty(hibernateCfgPath)) {
+            if (sesFactory == null) {
+                try {
+                    URL url = new URL(hibernateCfgPath);
+
+                    sesFactory = new Configuration().configure(url).buildSessionFactory();
+                }
+                catch (MalformedURLException ignored) {
+                    // No-op.
+                }
+
+                if (sesFactory == null) {
+                    File cfgFile = new File(hibernateCfgPath);
+
+                    if (cfgFile.exists())
+                        sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
+                }
+
+                if (sesFactory == null)
+                    sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
+
+                if (sesFactory == null)
+                    throw new IgniteException("Failed to resolve Hibernate configuration file: " + hibernateCfgPath);
+
+                closeSesOnStop = true;
+            }
+            else
+                U.warn(log, "Hibernate configuration file configured in " + getClass().getSimpleName() +
+                    " will be ignored (session factory is already set).");
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        if (closeSesOnStop && sesFactory != null && !sesFactory.isClosed())
+            sesFactory.close();
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionStart(CacheStoreSession ses) {
+        if (ses.attachment() == null) {
+            try {
+                Session hibSes = sesFactory.openSession();
+
+                ses.attach(hibSes);
+
+                if (ses.isWithinTransaction())
+                    hibSes.beginTransaction();
+            }
+            catch (HibernateException e) {
+                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
+        Session hibSes = ses.attachment();
+
+        if (hibSes != null) {
+            ses.attach(null);
+
+            try {
+                Transaction tx = hibSes.getTransaction();
+
+                if (commit) {
+                    hibSes.flush();
+
+                    if (tx.isActive())
+                        tx.commit();
+                }
+                else if (tx.isActive())
+                    tx.rollback();
+            }
+            catch (HibernateException e) {
+                throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
+            }
+            finally {
+                hibSes.close();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListener.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListener.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListener.java
deleted file mode 100644
index ea1214a..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListener.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.hibernate;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lifecycle.*;
-import org.apache.ignite.resources.*;
-import org.hibernate.*;
-import org.hibernate.cfg.*;
-
-import javax.cache.integration.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-/**
- * Hibernate-based cache store session listener.
- * <p>
- * This listener creates a new Hibernate session for each store
- * session. If there is an ongoing cache transaction, a corresponding
- * Hibernate transaction is created as well.
- * <p>
- * The Hibernate session is stored in store session
- * {@link CacheStoreSession#properties() properties} and can
- * be accessed at any moment by {@link #HIBERNATE_SES_KEY} key.
- * The listener guarantees that the session will be
- * available for any store operation. If there is an
- * ongoing cache transaction, all operations within this
- * transaction will share a DB transaction.
- * <p>
- * As an example, here is how the {@link CacheStore#write(javax.cache.Cache.Entry)}
- * method can be implemented if {@link CacheStoreSessionHibernateListener}
- * is configured:
- * <pre name="code" class="java">
- * private static class Store extends CacheStoreAdapter&lt;Integer, Integer&gt; {
- *     &#64;CacheStoreSessionResource
- *     private CacheStoreSession ses;
- *
- *     &#64;Override public void write(Cache.Entry&lt;? extends Integer, ? extends Integer&gt; entry) throws CacheWriterException {
- *         // Get Hibernate session from the current store session.
- *         Session hibSes = ses.<String, Session>properties().get(CacheStoreSessionHibernateListener.HIBERNATE_SES_KEY);
- *
- *         // Persist the value.
- *         hibSes.persist(entry.getValue());
- *     }
- * }
- * </pre>
- * Hibernate session will be automatically created by the listener
- * at the start of the session and closed when it ends.
- * <p>
- * {@link CacheStoreSessionHibernateListener} requires that either
- * {@link #setSessionFactory(SessionFactory)} session factory}
- * or {@link #setHibernateConfigurationPath(String) Hibernate configuration file}
- * is provided. If non of them is set, exception is thrown. Is both are provided,
- * session factory will be used.
- */
-public class CacheStoreSessionHibernateListener implements CacheStoreSessionListener, LifecycleAware {
-    /** Session key for JDBC connection. */
-    public static final String HIBERNATE_SES_KEY = "__hibernate_ses_";
-
-    /** Hibernate session factory. */
-    private SessionFactory sesFactory;
-
-    /** Hibernate configuration file path. */
-    private String hibernateCfgPath;
-
-    /** Logger. */
-    @LoggerResource
-    private IgniteLogger log;
-
-    /** Whether to close session on stop. */
-    private boolean closeSesOnStop;
-
-    /**
-     * Sets Hibernate session factory.
-     * <p>
-     * Either session factory or configuration file is required.
-     * If none is provided, exception will be thrown on startup.
-     *
-     * @param sesFactory Session factory.
-     */
-    public void setSessionFactory(SessionFactory sesFactory) {
-        this.sesFactory = sesFactory;
-    }
-
-    /**
-     * Gets Hibernate session factory.
-     *
-     * @return Session factory.
-     */
-    public SessionFactory getSessionFactory() {
-        return sesFactory;
-    }
-
-    /**
-     * Sets hibernate configuration path.
-     * <p>
-     * Either session factory or configuration file is required.
-     * If none is provided, exception will be thrown on startup.
-     *
-     * @param hibernateCfgPath Hibernate configuration path.
-     */
-    public void setHibernateConfigurationPath(String hibernateCfgPath) {
-        this.hibernateCfgPath = hibernateCfgPath;
-    }
-
-    /**
-     * Gets hibernate configuration path.
-     *
-     * @return Hibernate configuration path.
-     */
-    public String getHibernateConfigurationPath() {
-        return hibernateCfgPath;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    @Override public void start() throws IgniteException {
-        if (sesFactory == null && F.isEmpty(hibernateCfgPath))
-            throw new IgniteException("Either session factory or Hibernate configuration file is required by " +
-                getClass().getSimpleName() + '.');
-
-        if (!F.isEmpty(hibernateCfgPath)) {
-            if (sesFactory == null) {
-                try {
-                    URL url = new URL(hibernateCfgPath);
-
-                    sesFactory = new Configuration().configure(url).buildSessionFactory();
-                }
-                catch (MalformedURLException ignored) {
-                    // No-op.
-                }
-
-                if (sesFactory == null) {
-                    File cfgFile = new File(hibernateCfgPath);
-
-                    if (cfgFile.exists())
-                        sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
-                }
-
-                if (sesFactory == null)
-                    sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
-
-                if (sesFactory == null)
-                    throw new IgniteException("Failed to resolve Hibernate configuration file: " + hibernateCfgPath);
-
-                closeSesOnStop = true;
-            }
-            else
-                U.warn(log, "Hibernate configuration file configured in " + getClass().getSimpleName() +
-                    " will be ignored (session factory is already set).");
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() throws IgniteException {
-        if (closeSesOnStop && sesFactory != null && !sesFactory.isClosed())
-            sesFactory.close();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionStart(CacheStoreSession ses) {
-        Map<String, Session> props = ses.properties();
-
-        if (!props.containsKey(HIBERNATE_SES_KEY)) {
-            try {
-                Session hibSes = sesFactory.openSession();
-
-                props.put(HIBERNATE_SES_KEY, hibSes);
-
-                if (ses.isWithinTransaction())
-                    hibSes.beginTransaction();
-            }
-            catch (HibernateException e) {
-                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
-        Session hibSes = ses.<String, Session>properties().remove(HIBERNATE_SES_KEY);
-
-        if (hibSes != null) {
-            try {
-                Transaction tx = hibSes.getTransaction();
-
-                if (commit) {
-                    hibSes.flush();
-
-                    if (tx.isActive())
-                        tx.commit();
-                }
-                else if (tx.isActive())
-                    tx.rollback();
-            }
-            catch (HibernateException e) {
-                throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
-            }
-            finally {
-                hibSes.close();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
new file mode 100644
index 0000000..c30e216
--- /dev/null
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.hibernate;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.cache.store.jdbc.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.hibernate.*;
+import org.hibernate.cfg.Configuration;
+
+import javax.cache.Cache;
+import javax.cache.configuration.*;
+import javax.cache.integration.*;
+import javax.persistence.*;
+import java.io.*;
+import java.util.*;
+
+/**
+ * Tests for {@link CacheJdbcStoreSessionListener}.
+ */
+public class CacheHibernateStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
+        return new Factory<CacheStore<Integer, Integer>>() {
+            @Override public CacheStore<Integer, Integer> create() {
+                return new Store();
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
+        return new Factory<CacheStoreSessionListener>() {
+            @Override public CacheStoreSessionListener create() {
+                CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener();
+
+                SessionFactory sesFactory = new Configuration().
+                    setProperty("hibernate.connection.url", URL).
+                    addAnnotatedClass(Table1.class).
+                    addAnnotatedClass(Table2.class).
+                    buildSessionFactory();
+
+                lsnr.setSessionFactory(sesFactory);
+
+                return lsnr;
+            }
+        };
+    }
+
+    /**
+     */
+    private static class Store extends CacheStoreAdapter<Integer, Integer> {
+        /** */
+        private static String SES_CONN_KEY = "ses_conn";
+
+        /** */
+        @CacheStoreSessionResource
+        private CacheStoreSession ses;
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
+            loadCacheCnt.incrementAndGet();
+
+            checkSession();
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer load(Integer key) throws CacheLoaderException {
+            loadCnt.incrementAndGet();
+
+            checkSession();
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
+            throws CacheWriterException {
+            writeCnt.incrementAndGet();
+
+            checkSession();
+
+            if (write.get()) {
+                Session hibSes = ses.attachment();
+
+                switch (ses.cacheName()) {
+                    case "cache1":
+                        hibSes.save(new Table1(entry.getKey(), entry.getValue()));
+
+                        break;
+
+                    case "cache2":
+                        if (fail.get())
+                            throw new CacheWriterException("Expected failure.");
+
+                        hibSes.save(new Table2(entry.getKey(), entry.getValue()));
+
+                        break;
+
+                    default:
+                        throw new CacheWriterException("Wring cache: " + ses.cacheName());
+                }
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            deleteCnt.incrementAndGet();
+
+            checkSession();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sessionEnd(boolean commit) {
+            assertNull(ses.attachment());
+        }
+
+        /**
+         */
+        private void checkSession() {
+            Session hibSes = ses.attachment();
+
+            assertNotNull(hibSes);
+
+            assertTrue(hibSes.isOpen());
+
+            Transaction tx = hibSes.getTransaction();
+
+            assertNotNull(tx);
+
+            if (ses.isWithinTransaction())
+                assertTrue(tx.isActive());
+            else
+                assertFalse(tx.isActive());
+
+            verifySameInstance(hibSes);
+        }
+
+        /**
+         * @param hibSes Session.
+         */
+        private void verifySameInstance(Session hibSes) {
+            Map<String, Session> props = ses.properties();
+
+            Session sesConn = props.get(SES_CONN_KEY);
+
+            if (sesConn == null)
+                props.put(SES_CONN_KEY, hibSes);
+            else {
+                assertSame(hibSes, sesConn);
+
+                reuseCnt.incrementAndGet();
+            }
+        }
+    }
+
+    /**
+     */
+    @Entity
+    @Table(name = "Table1")
+    private static class Table1 implements Serializable {
+        /** */
+        @Id @GeneratedValue
+        @Column(name = "id")
+        private Integer id;
+
+        /** */
+        @Column(name = "key")
+        private int key;
+
+        /** */
+        @Column(name = "value")
+        private int value;
+
+        /**
+         * @param key Key.
+         * @param value Value.
+         */
+        private Table1(int key, int value) {
+            this.key = key;
+            this.value = value;
+        }
+    }
+
+    /**
+     */
+    @Entity
+    @Table(name = "Table2")
+    private static class Table2 implements Serializable {
+        /** */
+        @Id @GeneratedValue
+        @Column(name = "id")
+        private Integer id;
+
+        /** */
+        @Column(name = "key")
+        private int key;
+
+        /** */
+        @Column(name = "value")
+        private int value;
+
+        /**
+         * @param key Key.
+         * @param value Value.
+         */
+        private Table2(int key, int value) {
+            this.key = key;
+            this.value = value;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListenerSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListenerSelfTest.java
deleted file mode 100644
index a9d465e..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheStoreSessionHibernateListenerSelfTest.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.hibernate;
-
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.cache.store.jdbc.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.hibernate.*;
-import org.hibernate.cfg.Configuration;
-
-import javax.cache.Cache;
-import javax.cache.configuration.*;
-import javax.cache.integration.*;
-import javax.persistence.*;
-import java.io.*;
-import java.util.*;
-
-/**
- * Tests for {@link CacheStoreSessionJdbcListener}.
- */
-public class CacheStoreSessionHibernateListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
-        return new Factory<CacheStore<Integer, Integer>>() {
-            @Override public CacheStore<Integer, Integer> create() {
-                return new Store();
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
-        return new Factory<CacheStoreSessionListener>() {
-            @Override public CacheStoreSessionListener create() {
-                CacheStoreSessionHibernateListener lsnr = new CacheStoreSessionHibernateListener();
-
-                SessionFactory sesFactory = new Configuration().
-                    setProperty("hibernate.connection.url", URL).
-                    addAnnotatedClass(Table1.class).
-                    addAnnotatedClass(Table2.class).
-                    buildSessionFactory();
-
-                lsnr.setSessionFactory(sesFactory);
-
-                return lsnr;
-            }
-        };
-    }
-
-    /**
-     */
-    private static class Store extends CacheStoreAdapter<Integer, Integer> {
-        /** */
-        private static String SES_CONN_KEY = "ses_conn";
-
-        /** */
-        @CacheStoreSessionResource
-        private CacheStoreSession ses;
-
-        /** {@inheritDoc} */
-        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
-            loadCacheCnt.incrementAndGet();
-
-            checkSession();
-        }
-
-        /** {@inheritDoc} */
-        @Override public Integer load(Integer key) throws CacheLoaderException {
-            loadCnt.incrementAndGet();
-
-            checkSession();
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
-            throws CacheWriterException {
-            writeCnt.incrementAndGet();
-
-            checkSession();
-
-            if (write.get()) {
-                Session hibSes = session();
-
-                switch (ses.cacheName()) {
-                    case "cache1":
-                        hibSes.save(new Table1(entry.getKey(), entry.getValue()));
-
-                        break;
-
-                    case "cache2":
-                        if (fail.get())
-                            throw new CacheWriterException("Expected failure.");
-
-                        hibSes.save(new Table2(entry.getKey(), entry.getValue()));
-
-                        break;
-
-                    default:
-                        throw new CacheWriterException("Wring cache: " + ses.cacheName());
-                }
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void delete(Object key) throws CacheWriterException {
-            deleteCnt.incrementAndGet();
-
-            checkSession();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void sessionEnd(boolean commit) {
-            assertNull(session());
-        }
-
-        /**
-         */
-        private void checkSession() {
-            Session hibSes = session();
-
-            assertNotNull(hibSes);
-
-            assertTrue(hibSes.isOpen());
-
-            Transaction tx = hibSes.getTransaction();
-
-            assertNotNull(tx);
-
-            if (ses.isWithinTransaction())
-                assertTrue(tx.isActive());
-            else
-                assertFalse(tx.isActive());
-
-            verifySameInstance(hibSes);
-        }
-
-        /**
-         * @param hibSes Session.
-         */
-        private void verifySameInstance(Session hibSes) {
-            Map<String, Session> props = ses.properties();
-
-            Session sesConn = props.get(SES_CONN_KEY);
-
-            if (sesConn == null)
-                props.put(SES_CONN_KEY, hibSes);
-            else {
-                assertSame(hibSes, sesConn);
-
-                reuseCnt.incrementAndGet();
-            }
-        }
-
-        /**
-         * @return Connection.
-         */
-        private Session session() {
-            return ses.<String, Session>properties().get(CacheStoreSessionHibernateListener.HIBERNATE_SES_KEY);
-        }
-    }
-
-    /**
-     */
-    @Entity
-    @Table(name = "Table1")
-    private static class Table1 implements Serializable {
-        /** */
-        @Id @GeneratedValue
-        @Column(name = "id")
-        private Integer id;
-
-        /** */
-        @Column(name = "key")
-        private int key;
-
-        /** */
-        @Column(name = "value")
-        private int value;
-
-        /**
-         * @param key Key.
-         * @param value Value.
-         */
-        private Table1(int key, int value) {
-            this.key = key;
-            this.value = value;
-        }
-    }
-
-    /**
-     */
-    @Entity
-    @Table(name = "Table2")
-    private static class Table2 implements Serializable {
-        /** */
-        @Id @GeneratedValue
-        @Column(name = "id")
-        private Integer id;
-
-        /** */
-        @Column(name = "key")
-        private int key;
-
-        /** */
-        @Column(name = "value")
-        private int value;
-
-        /**
-         * @param key Key.
-         * @param value Value.
-         */
-        private Table2(int key, int value) {
-            this.key = key;
-            this.value = value;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
index ed782e2..655e801 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
@@ -41,7 +41,7 @@ public class IgniteHibernateTestSuite extends TestSuite {
 
         suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class);
 
-        suite.addTestSuite(CacheStoreSessionHibernateListenerSelfTest.class);
+        suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class);
 
         return suite;
     }


[07/11] incubator-ignite git commit: # One more interop exception.

Posted by vk...@apache.org.
# One more interop exception.


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

Branch: refs/heads/ignite-891
Commit: 6ba171f2d60cf878bede42e27a4b0a0ee58948cd
Parents: 6093619
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri May 22 19:25:30 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri May 22 19:25:30 2015 +0300

----------------------------------------------------------------------
 .../internal/interop/InteropException.java      |  6 +++
 .../interop/InteropNoCallbackException.java     | 50 ++++++++++++++++++++
 2 files changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ba171f2/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
index 095c650..d74b9d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.interop;
 
 import org.apache.ignite.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
 /**
@@ -62,4 +63,9 @@ public class InteropException extends IgniteCheckedException {
     public InteropException(String msg, @Nullable Throwable cause) {
         super(msg, cause);
     }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(InteropException.class, this);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6ba171f2/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java
new file mode 100644
index 0000000..6fd614a
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropNoCallbackException.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.interop;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+/**
+ * Exception raised when interop callback is not set in native platform.
+ */
+@SuppressWarnings("UnusedDeclaration")
+public class InteropNoCallbackException extends InteropException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * Constructor.
+     */
+    public InteropNoCallbackException() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param msg Message.
+     */
+    public InteropNoCallbackException(String msg) {
+        super(msg);
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(InteropNoCallbackException.class, this);
+    }
+}


[08/11] incubator-ignite git commit: #[IGNITE-928]: Array out of bounds in IgniteUtils.filterReachable

Posted by vk...@apache.org.
#[IGNITE-928]: Array out of bounds in IgniteUtils.filterReachable


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

Branch: refs/heads/ignite-891
Commit: 050f4292f3526d2306336383c6e9e5b0d6df638e
Parents: 6ba171f
Author: iveselovskiy <iv...@gridgain.com>
Authored: Fri May 22 21:40:06 2015 +0300
Committer: iveselovskiy <iv...@gridgain.com>
Committed: Fri May 22 21:40:06 2015 +0300

----------------------------------------------------------------------
 .../ClientAbstractConnectivitySelfTest.java           | 14 ++++++++++++++
 .../org/apache/ignite/internal/util/IgniteUtils.java  |  6 ++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/050f4292/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java
index 7272b2c..5aec7e5 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/client/integration/ClientAbstractConnectivitySelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.client.integration;
 
 import org.apache.ignite.*;
 import org.apache.ignite.internal.client.*;
+import org.apache.ignite.internal.util.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -123,6 +124,19 @@ public abstract class ClientAbstractConnectivitySelfTest extends GridCommonAbstr
     }
 
     /**
+     * Simple test of address list filtering.
+     * @throws Exception
+     */
+    public void testResolveReachableOneAddress() throws Exception {
+        InetAddress addr = InetAddress.getByAddress(new byte[] {127, 0, 0, 1} );
+
+        List <InetAddress> filtered = IgniteUtils.filterReachable(Collections.singletonList(addr));
+
+        assertEquals(1, filtered.size());
+        assertEquals(addr, filtered.get(0));
+    }
+
+    /**
      * Tests correct behavior in case of 1 REST-enabled node
      * with explicitly specified loopback address setting.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/050f4292/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 673287d..0932212 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -1532,8 +1532,10 @@ public abstract class IgniteUtils {
             return Collections.emptyList();
 
         if (addrs.size() == 1) {
-            if (reachable(addrs.get(1), reachTimeout))
-                return Collections.singletonList(addrs.get(1));
+            InetAddress addr = addrs.get(0);
+
+            if (reachable(addr, reachTimeout))
+                return Collections.singletonList(addr);
 
             return Collections.emptyList();
         }


[09/11] incubator-ignite git commit: Merge branches 'ignite-891' and 'ignite-sprint-5' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-891

Posted by vk...@apache.org.
Merge branches 'ignite-891' and 'ignite-sprint-5' of https://git-wip-us.apache.org/repos/asf/incubator-ignite into ignite-891


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

Branch: refs/heads/ignite-891
Commit: b5b452354198cad9e188d80887127df15e5b95c6
Parents: 7ab0304 050f429
Author: Valentin Kulichenko <vk...@gridgain.com>
Authored: Fri May 22 13:29:09 2015 -0700
Committer: Valentin Kulichenko <vk...@gridgain.com>
Committed: Fri May 22 13:29:09 2015 -0700

----------------------------------------------------------------------
 .gitignore                                      |   3 +-
 dev-tools/slurp.sh                              |  74 +++++++++++
 dev-tools/src/main/groovy/jiraslurp.groovy      | 132 +++++++++++--------
 .../ClientAbstractConnectivitySelfTest.java     |  14 ++
 .../internal/interop/InteropException.java      |  71 ++++++++++
 .../interop/InteropNoCallbackException.java     |  50 +++++++
 .../ignite/internal/util/IgniteUtils.java       |   6 +-
 .../processors/hadoop/v2/HadoopV2Context.java   |  10 +-
 .../testsuites/IgniteHadoopTestSuite.java       |   2 +-
 .../config/benchmark-client-mode.properties     |  89 +++++++++++++
 10 files changed, 384 insertions(+), 67 deletions(-)
----------------------------------------------------------------------



[05/11] incubator-ignite git commit: # ignie-456

Posted by vk...@apache.org.
# ignie-456


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

Branch: refs/heads/ignite-891
Commit: a25353377ef44de8a31d0c88ed0e8aee0d949167
Parents: 4929c7d
Author: null <null>
Authored: Fri May 22 16:24:52 2015 +0300
Committer: null <null>
Committed: Fri May 22 16:24:52 2015 +0300

----------------------------------------------------------------------
 .gitignore                                 |   3 +-
 dev-tools/slurp.sh                         |  74 +++++++++++++
 dev-tools/src/main/groovy/jiraslurp.groovy | 132 +++++++++++++-----------
 3 files changed, 150 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2535337/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 296e130..3da8e4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,4 +19,5 @@ atlassian-ide-plugin.xml
 target
 /libs/
 pom-installed.xml
-git-patch-prop-local.sh
\ No newline at end of file
+git-patch-prop-local.sh
+/slurp.sh

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2535337/dev-tools/slurp.sh
----------------------------------------------------------------------
diff --git a/dev-tools/slurp.sh b/dev-tools/slurp.sh
new file mode 100644
index 0000000..bf1e91a
--- /dev/null
+++ b/dev-tools/slurp.sh
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#
+# Copy this script file at root of ignite repo.
+# Fill all variables.
+#
+
+#
+# Default branch name. Need to use last version of "jiraslurp" scripts.
+#
+DEFAULT_BRANCH='ignite-sprint-5'
+
+#
+# TC URL. It is 10.30.0.229 for public TC from agents.
+#
+TC_URL='10.30.0.229'
+
+#
+# Jira user name to add comments aboyt triggered builds.
+#
+JIRA_USER='tc_commenter'
+
+#
+# Jira password.
+#
+JIRA_PWD=''
+
+#
+# TC user which have permissions to trigger new builds.
+#
+TASK_RUNNER_USER='task_runner'
+
+#
+# TC user password.
+#
+TASK_RUNNER_PWD=''
+
+#
+# Space separated logins of jira useres which were approved to auto triggering patches. Like 'user1 user2 user3'.
+#
+JIRA_CONTRIBUTORS=''
+
+git fetch
+
+git checkout ${DEFAULT_BRANCH}
+
+git pull
+
+export TC_URL=${TC_URL}
+export GIT_USER_NAME=${GIT_USER_NAME}
+export GIT_USER_EMAIL=${GIT_USER_EMAIL}
+export JIRA_USER=${JIRA_USER}
+export JIRA_PWD=${JIRA_PWD}
+export TASK_RUNNER_PWD=${TASK_RUNNER_PWD}
+export TASK_RUNNER_USER=${TASK_RUNNER_USER}
+export JIRA_CONTRIBUTORS=${JIRA_CONTRIBUTORS}
+
+gradle slurp -b dev-tools/build.gradle

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a2535337/dev-tools/src/main/groovy/jiraslurp.groovy
----------------------------------------------------------------------
diff --git a/dev-tools/src/main/groovy/jiraslurp.groovy b/dev-tools/src/main/groovy/jiraslurp.groovy
index 32a6e43..d70bb32 100644
--- a/dev-tools/src/main/groovy/jiraslurp.groovy
+++ b/dev-tools/src/main/groovy/jiraslurp.groovy
@@ -14,6 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+def envVariable = { name, defaultVar ->
+    def res = System.getenv(name as String)
+
+    if (res == 'null' || res == null)
+        return defaultVar
+
+    res
+}
+
+def envVariableAsList = { name, defaultList ->
+    def list = System.getenv(name as String)?.split(' ') as List
+
+    if (list == 'null' || list == null)
+        return defaultList
+
+    list
+}
+
 /**
  * Parsing a special filter from Apache Ignite JIRA and picking up latest by ID
  * attachments to process.
@@ -25,7 +44,12 @@ final validated_filename = "${System.getProperty("user.home")}/validated-jira.tx
 final LAST_SUCCESSFUL_ARTIFACT = "guestAuth/repository/download/Ignite_PatchValidation_PatchChecker/.lastSuccessful/$validated_filename"
 
 final def JIRA_CMD = System.getProperty('JIRA_COMMAND', 'jira.sh')
-LinkedHashMap<String, String> jirasAttached = [:]
+
+// Envariement variables.
+final def TC_PROJECT_NAME = envVariable("PROJECT_NAME", "Ignite")
+
+final def CONTRIBUTORS = envVariableAsList("JIRA_CONTRIBUTORS", [])
+final def TC_BUILD_EXCLUDE_LIST = envVariableAsList("BUILD_ID_EXCLUDES", ["Ignite_RunAllTestBuilds"])
 
 /**
  * Gets jiras for which test tasks were already triggered.
@@ -37,29 +61,12 @@ def readHistory = {
 
     List validated_list = []
 
-    // TODO do not use folder.
     def validated = new File(validated_filename)
 
     if (validated.exists()) {
-        // TODO use commented way.
         validated_list = validated.text.split('\n')
     }
 
-    // TODO use it way.
-//    try {
-//        def historyUrl = "http://${System.getenv('TC_URL')}/$LAST_SUCCESSFUL_ARTIFACT"
-//
-//        println "Reading history from $historyUrl"
-//
-//        validated_list = new URL(historyUrl).text.split('\n')
-//
-//        println "Got validated list=$validated_list"
-//    }
-//    catch (Exception e) {
-//        println e.getMessage()
-//
-//    }
-
     // Let's make sure the preserved history isn't too long
     if (validated_list.size > MAX_HISTORY)
         validated_list = validated_list[validated_list.size - MAX_HISTORY..validated_list.size - 1]
@@ -74,34 +81,46 @@ def readHistory = {
  * @return <code>null</code> or <code>JIRA-###,latest_attach_id</code>
  */
 def getLatestAttachment = { jira ->
-    def latestAttr = jira.attachments[0].attachment.list().sort {
-        it.@id.toInteger()
-    }.reverse()[0]
+    def attachment = jira.attachments[0].attachment.list()
+        .sort { it.@id.toInteger() }
+        .reverse()
+        .find {
+            def fName = it.@name.toString()
+
+            CONTRIBUTORS.contains(it.@author as String) &&
+                (fName.endsWith(".patch") || fName.endsWith(".txt") || fName.endsWith(".diff"))
+        }
 
     String row = null
 
-    if (latestAttr == null) {
-        println "${jira.key} is in invalid state: patch is not available"
+    if (attachment == null) {
+        println "${jira.key} is in invalid state: there was not found '.{patch/txt/diff}'-file from approved user."
     }
     else {
-        row = "${jira.key},${latestAttr.@id}"
+        row = "${jira.key},${attachment.@id}"
     }
 }
 
-def checkForAttachments = {
+/**
+ * Checks all "Patch availiable" jiras on attached ".patch"-files from approved users.
+ */
+def findAttachments = {
+    // See https://issues.apache.org/jira/issues/?filter=12330308 (the same).
     def JIRA_FILTER =
         "https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/12330308/SearchRequest-12330308.xml?tempMax=100&field=key&field=attachments"
     def rss = new XmlSlurper().parse(JIRA_FILTER)
 
     List list = readHistory {}
 
+    LinkedHashMap<String, String> attachments = [:]
+
     rss.channel.item.each { jira ->
         String row = getLatestAttachment(jira)
 
         if (row != null && !list.contains(row)) {
             def pair = row.split(',')
 
-            jirasAttached.put(pair[0] as String, pair[1] as String)
+            attachments.put(pair[0] as String, pair[1] as String)
 
             list.add(row)
         }
@@ -114,6 +133,8 @@ def checkForAttachments = {
         validated.delete()
 
     validated << list.join('\n')
+
+    attachments
 }
 
 /**
@@ -142,6 +163,8 @@ def applyPatch = { jira, attachementURL ->
     def patchFile = new File("${jira}-${attachementURL}.patch")
 
     try {
+        println "Getting patch content."
+
         patchFile << new URL("$ATTACHMENT_URL/$attachementURL/").text
 
         try {
@@ -163,7 +186,16 @@ def applyPatch = { jira, attachementURL ->
         catch (Exception e) {
             println "Patch was not applied successfully. Aborting patch applying."
 
-            checkprocess "git am --abort".execute(null, new File("../"))
+            try {
+                checkprocess "git am --abort".execute(null, new File("../"))
+
+                print "Succsessfull: git am --abort."
+            }
+            catch (Exception e2) {
+                print "Error: git am --abort fails: "
+
+                e2.printStackTrace()
+            }
 
             throw e;
         }
@@ -181,19 +213,9 @@ def JIRA_xml = { jiranum ->
  * Gets all builds from TC project.
  */
 def getTestBuilds = { ->
-    def projName = System.getenv('PROJECT_NAME')
-
-    if (projName == null || projName == 'null')
-        projName = "Ignite"
-
     def tcURL = System.getenv('TC_URL')
-    def excludeListProp = System.getenv('BUILD_ID_EXCLUDES')
-    def excludeList = excludeListProp?.split(' ') as List
 
-    if (excludeList == null || excludeList == 'null')
-        excludeList = ["Ignite_RunAllTestBuilds"]
-
-    def project = new XmlSlurper().parse("http://$tcURL:80/guestAuth/app/rest/projects/id:$projName")
+    def project = new XmlSlurper().parse("http://$tcURL:80/guestAuth/app/rest/projects/id:$TC_PROJECT_NAME")
 
     def buildIds = []
 
@@ -202,7 +224,7 @@ def getTestBuilds = { ->
     for (int i = 0; i < count; i++) {
         def id = project.buildTypes.buildType[i].@id
 
-        if (excludeList == null || !excludeList.contains(id))
+        if (TC_BUILD_EXCLUDE_LIST == null || !TC_BUILD_EXCLUDE_LIST.contains(id))
             buildIds.add(id)
     }
 
@@ -316,10 +338,6 @@ def runAllTestBuilds = {builds, jiraNum ->
 
             def build = new XmlSlurper().parseText(response)
 
-            println "Triggered build: ${build.buildType.@name}"
-            println "Triggered build url: ${build.@webUrl}"
-            println "Triggered build branch: ${build.@branchName}"
-
             triggeredBuilds.put(build.buildType.@name, build.@webUrl)
         }
         catch (Exception e) {
@@ -338,6 +356,16 @@ def runAllTestBuilds = {builds, jiraNum ->
 
 /**
  * Main.
+ *
+ * Modes:
+ * 1. "slurp" mode - triggers all TC test builds for all jiras with valid attachment
+ * (Jira in "patch availiable" state, there is attached file from approved user with "patch" extension)
+ * 2. "patchApply" mode - gets last valid patch file from given jira number and applies it.
+ * 3. "runAllBuilds" - triggers given jira number for all TC test builds.
+ *
+ * Main workflow:
+ * 1. run in "slurp" mode
+ * 2. each triggered build uses "patchApply" mode to apply latest valid patch.
  */
 args.each {
     println "Arg=$it"
@@ -349,14 +377,14 @@ args.each {
     if (parameters.length >= 1 && parameters[0] == "slurp") {
         println "Running in 'slurp' mode."
 
-        checkForAttachments()
-
         def builds = getTestBuilds()
 
         println "Test builds to be triggered=$builds"
 
+        def attachments = findAttachments()
+
         // For each ticket with new attachment, let's trigger remove build
-        jirasAttached.each { k, v ->
+        attachments.each { k, v ->
             //  Trailing slash is important for download; only need to pass JIRA number
             println "Triggering the test builds for: $k = $ATTACHMENT_URL/$v/"
 
@@ -401,15 +429,3 @@ args.each {
         runAllTestBuilds(builds, jiraNum)
     }
 }
-
-/* Workflow:
-  1. download an attachment if JIRA num's set; otherwise get all latest attachments not mentioned in the
-     validated-jira.txt file from the last successful build
-  2. trigger test build(s) parametrised by JIRA no.
-  3. test build will download JIRA's latest attachment and apply it to currently checked out repo;
-     - build will fail with comment on JIRA if that can not apply
-     - build will post error/success comment depends on the test results
-*/
-// TODO
-//   - TC's test job needs to send a comment to JIRA
-//       $JIRA_CMD -a addComment -s https://issues.apache.org/jira -u ignite-ci -p ci-of-1gnit3 --issue IGNITE-495 --comment "Trying latest version of the jira-cli"


[06/11] incubator-ignite git commit: Merge remote-tracking branch 'origin/ignite-sprint-5' into ignite-sprint-5

Posted by vk...@apache.org.
Merge remote-tracking branch 'origin/ignite-sprint-5' into ignite-sprint-5


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

Branch: refs/heads/ignite-891
Commit: 609361932fa02880a4555788c4820ca19d742a8a
Parents: a253533 c2734e4
Author: null <null>
Authored: Fri May 22 16:25:18 2015 +0300
Committer: null <null>
Committed: Fri May 22 16:25:18 2015 +0300

----------------------------------------------------------------------
 .../internal/interop/InteropException.java      | 65 ++++++++++++++
 .../processors/cache/GridCacheAdapter.java      | 16 +++-
 .../processors/hadoop/v2/HadoopV2Context.java   | 10 +--
 .../testsuites/IgniteHadoopTestSuite.java       |  2 +-
 .../config/benchmark-client-mode.properties     | 89 ++++++++++++++++++++
 5 files changed, 172 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[02/11] incubator-ignite git commit: # Added interop checked exception.

Posted by vk...@apache.org.
# Added interop checked exception.


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

Branch: refs/heads/ignite-891
Commit: 0acdc3de22932f0bf1e12764812fd5fcad603f23
Parents: 02f3a12
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri May 22 15:34:31 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri May 22 15:34:31 2015 +0300

----------------------------------------------------------------------
 .../internal/interop/InteropException.java      | 65 ++++++++++++++++++++
 1 file changed, 65 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0acdc3de/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
new file mode 100644
index 0000000..095c650
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/interop/InteropException.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.interop;
+
+import org.apache.ignite.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Interop checked exception.
+ */
+public class InteropException extends IgniteCheckedException {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /**
+     * Create empty exception.
+     */
+    public InteropException() {
+        // No-op.
+    }
+
+    /**
+     * Creates new exception with given error message.
+     *
+     * @param msg Error message.
+     */
+    public InteropException(String msg) {
+        super(msg);
+    }
+
+    /**
+     * Creates new grid exception with given throwable as a cause and
+     * source of error message.
+     *
+     * @param cause Non-null throwable cause.
+     */
+    public InteropException(Throwable cause) {
+        this(cause.getMessage(), cause);
+    }
+
+    /**
+     * Creates new exception with given error message and optional nested exception.
+     *
+     * @param msg Error message.
+     * @param cause Optional nested exception (can be {@code null}).
+     */
+    public InteropException(String msg, @Nullable Throwable cause) {
+        super(msg, cause);
+    }
+}


[10/11] incubator-ignite git commit: IGNITE-891 - Cache store improvements

Posted by vk...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListener.java b/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListener.java
new file mode 100644
index 0000000..81736cd
--- /dev/null
+++ b/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListener.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.spring;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lifecycle.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.springframework.jdbc.core.*;
+import org.springframework.jdbc.datasource.*;
+import org.springframework.transaction.*;
+import org.springframework.transaction.support.*;
+
+import javax.cache.integration.*;
+import javax.sql.*;
+
+/**
+ * Cache store session listener based on Spring transaction management.
+ * <p>
+ * This listener starts a new DB transaction for each session and commits
+ * or rolls it back when session ends. If there is no ongoing
+ * cache transaction, this listener is no-op.
+ * <p>
+ * Store implementation can use any Spring APIs like {@link JdbcTemplate}
+ * and others. The listener will guarantee that if there is an
+ * ongoing cache transaction, all store operations within this
+ * transaction will be automatically enlisted in the same database
+ * transaction.
+ * <p>
+ * {@link CacheSpringStoreSessionListener} requires that either
+ * {@link #setTransactionManager(PlatformTransactionManager) transaction manager}
+ * or {@link #setDataSource(DataSource) data source} is configured. If non of them is
+ * provided, exception is thrown. Is both are provided, data source will be
+ * ignored.
+ * <p>
+ * If there is a transaction, a {@link TransactionStatus} object will be saved
+ * as a store session {@link CacheStoreSession#attachment() attachment}. It
+ * can be used to acquire current DB transaction status.
+ */
+public class CacheSpringStoreSessionListener implements CacheStoreSessionListener, LifecycleAware {
+    /** Transaction manager. */
+    private PlatformTransactionManager txMgr;
+
+    /** Data source. */
+    private DataSource dataSrc;
+
+    /** Propagation behavior. */
+    private int propagation = TransactionDefinition.PROPAGATION_REQUIRED;
+
+    /** Logger. */
+    @LoggerResource
+    private IgniteLogger log;
+
+    /**
+     * Sets transaction manager.
+     * <p>
+     * Either transaction manager or data source is required.
+     * If none is provided, exception will be thrown on startup.
+     *
+     * @param txMgr Transaction manager.
+     */
+    public void setTransactionManager(PlatformTransactionManager txMgr) {
+        this.txMgr = txMgr;
+    }
+
+    /**
+     * Gets transaction manager.
+     *
+     * @return Transaction manager.
+     */
+    public PlatformTransactionManager getTransactionManager() {
+        return txMgr;
+    }
+
+    /**
+     * Sets data source.
+     * <p>
+     * Either transaction manager or data source is required.
+     * If none is provided, exception will be thrown on startup.
+     *
+     * @param dataSrc Data source.
+     */
+    public void setDataSource(DataSource dataSrc) {
+        this.dataSrc = dataSrc;
+    }
+
+    /**
+     * Gets data source.
+     *
+     * @return Data source.
+     */
+    public DataSource getDataSource() {
+        return dataSrc;
+    }
+
+    /**
+     * Sets propagation behavior.
+     * <p>
+     * This parameter is optional.
+     *
+     * @param propagation Propagation behavior.
+     */
+    public void setPropagationBehavior(int propagation) {
+        this.propagation = propagation;
+    }
+
+    /**
+     * Gets propagation behavior.
+     *
+     * @return Propagation behavior.
+     */
+    public int getPropagationBehavior() {
+        return propagation;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void start() throws IgniteException {
+        if (txMgr == null && dataSrc == null)
+            throw new IgniteException("Either transaction manager or data source is required by " +
+                getClass().getSimpleName() + '.');
+
+        if (dataSrc != null) {
+            if (txMgr == null)
+                txMgr = new DataSourceTransactionManager(dataSrc);
+            else
+                U.warn(log, "Data source configured in " + getClass().getSimpleName() +
+                    " will be ignored (transaction manager is already set).");
+        }
+
+        assert txMgr != null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void stop() throws IgniteException {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionStart(CacheStoreSession ses) {
+        if (ses.isWithinTransaction()) {
+            try {
+                TransactionDefinition def = definition(ses.transaction(), ses.cacheName());
+
+                ses.attach(txMgr.getTransaction(def));
+            }
+            catch (TransactionException e) {
+                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
+        if (ses.isWithinTransaction()) {
+            TransactionStatus tx = ses.attachment();
+
+            if (tx != null) {
+                ses.attach(null);
+
+                try {
+                    if (commit)
+                        txMgr.commit(tx);
+                    else
+                        txMgr.rollback(tx);
+                }
+                catch (TransactionException e) {
+                    throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
+                }
+            }
+        }
+    }
+
+    /**
+     * Gets DB transaction isolation level based on ongoing cache transaction isolation.
+     *
+     * @return DB transaction isolation.
+     */
+    private TransactionDefinition definition(Transaction tx, String cacheName) {
+        assert tx != null;
+
+        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
+
+        def.setName("Ignite Tx [cache=" + (cacheName != null ? cacheName : "<default>") + ", id=" + tx.xid() + ']');
+        def.setIsolationLevel(isolationLevel(tx.isolation()));
+        def.setPropagationBehavior(propagation);
+
+        long timeoutSec = (tx.timeout() + 500) / 1000;
+
+        if (timeoutSec > 0 && timeoutSec < Integer.MAX_VALUE)
+            def.setTimeout((int)timeoutSec);
+
+        return def;
+    }
+
+    /**
+     * Gets DB transaction isolation level based on ongoing cache transaction isolation.
+     *
+     * @param isolation Cache transaction isolation.
+     * @return DB transaction isolation.
+     */
+    private int isolationLevel(TransactionIsolation isolation) {
+        switch (isolation) {
+            case READ_COMMITTED:
+                return TransactionDefinition.ISOLATION_READ_COMMITTED;
+
+            case REPEATABLE_READ:
+                return TransactionDefinition.ISOLATION_REPEATABLE_READ;
+
+            case SERIALIZABLE:
+                return TransactionDefinition.ISOLATION_SERIALIZABLE;
+
+            default:
+                throw new IllegalStateException(); // Will never happen.
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListener.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListener.java b/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListener.java
deleted file mode 100644
index e5201ba..0000000
--- a/modules/spring/src/main/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListener.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.spring;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.lifecycle.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
-import org.springframework.jdbc.core.*;
-import org.springframework.jdbc.datasource.*;
-import org.springframework.transaction.*;
-import org.springframework.transaction.support.*;
-
-import javax.cache.integration.*;
-import javax.sql.*;
-
-/**
- * Cache store session listener based on Spring transaction management.
- * <p>
- * This listener starts a new DB transaction for each session and commits
- * or rolls it back when session ends. If there is no ongoing
- * cache transaction, this listener is no-op.
- * <p>
- * Store implementation can use any Spring APIs like {@link JdbcTemplate}
- * and others. The listener will guarantee that if there is an
- * ongoing cache transaction, all store operations within this
- * transaction will be automatically enlisted in the same database
- * transaction.
- * <p>
- * {@link CacheStoreSessionSpringListener} requires that either
- * {@link #setTransactionManager(PlatformTransactionManager) transaction manager}
- * or {@link #setDataSource(DataSource) data source} is configured. If non of them is
- * provided, exception is thrown. Is both are provided, data source will be
- * ignored.
- * <p>
- * If there is a transaction, a {@link TransactionStatus} object will be stored
- * in store session {@link CacheStoreSession#properties() properties} and can be
- * accessed at any moment by {@link #TX_STATUS_KEY} key. This can be used to
- * acquire current DB transaction status.
- */
-public class CacheStoreSessionSpringListener implements CacheStoreSessionListener, LifecycleAware {
-    /** Session key for transaction status. */
-    public static final String TX_STATUS_KEY = "__spring_tx_status_";
-
-    /** Transaction manager. */
-    private PlatformTransactionManager txMgr;
-
-    /** Data source. */
-    private DataSource dataSrc;
-
-    /** Propagation behavior. */
-    private int propagation = TransactionDefinition.PROPAGATION_REQUIRED;
-
-    /** Logger. */
-    @LoggerResource
-    private IgniteLogger log;
-
-    /**
-     * Sets transaction manager.
-     * <p>
-     * Either transaction manager or data source is required.
-     * If none is provided, exception will be thrown on startup.
-     *
-     * @param txMgr Transaction manager.
-     */
-    public void setTransactionManager(PlatformTransactionManager txMgr) {
-        this.txMgr = txMgr;
-    }
-
-    /**
-     * Gets transaction manager.
-     *
-     * @return Transaction manager.
-     */
-    public PlatformTransactionManager getTransactionManager() {
-        return txMgr;
-    }
-
-    /**
-     * Sets data source.
-     * <p>
-     * Either transaction manager or data source is required.
-     * If none is provided, exception will be thrown on startup.
-     *
-     * @param dataSrc Data source.
-     */
-    public void setDataSource(DataSource dataSrc) {
-        this.dataSrc = dataSrc;
-    }
-
-    /**
-     * Gets data source.
-     *
-     * @return Data source.
-     */
-    public DataSource getDataSource() {
-        return dataSrc;
-    }
-
-    /**
-     * Sets propagation behavior.
-     * <p>
-     * This parameter is optional.
-     *
-     * @param propagation Propagation behavior.
-     */
-    public void setPropagationBehavior(int propagation) {
-        this.propagation = propagation;
-    }
-
-    /**
-     * Gets propagation behavior.
-     *
-     * @return Propagation behavior.
-     */
-    public int getPropagationBehavior() {
-        return propagation;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void start() throws IgniteException {
-        if (txMgr == null && dataSrc == null)
-            throw new IgniteException("Either transaction manager or data source is required by " +
-                getClass().getSimpleName() + '.');
-
-        if (dataSrc != null) {
-            if (txMgr == null)
-                txMgr = new DataSourceTransactionManager(dataSrc);
-            else
-                U.warn(log, "Data source configured in " + getClass().getSimpleName() +
-                    " will be ignored (transaction manager is already set).");
-        }
-
-        assert txMgr != null;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void stop() throws IgniteException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionStart(CacheStoreSession ses) {
-        if (ses.isWithinTransaction()) {
-            try {
-                TransactionDefinition def = definition(ses.transaction(), ses.cacheName());
-
-                ses.properties().put(TX_STATUS_KEY, txMgr.getTransaction(def));
-            }
-            catch (TransactionException e) {
-                throw new CacheWriterException("Failed to start store session [tx=" + ses.transaction() + ']', e);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
-        if (ses.isWithinTransaction()) {
-            TransactionStatus tx = ses.<String, TransactionStatus>properties().remove(TX_STATUS_KEY);
-
-            if (tx != null) {
-                try {
-                    if (commit)
-                        txMgr.commit(tx);
-                    else
-                        txMgr.rollback(tx);
-                }
-                catch (TransactionException e) {
-                    throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
-                }
-            }
-        }
-    }
-
-    /**
-     * Gets DB transaction isolation level based on ongoing cache transaction isolation.
-     *
-     * @return DB transaction isolation.
-     */
-    private TransactionDefinition definition(Transaction tx, String cacheName) {
-        assert tx != null;
-
-        DefaultTransactionDefinition def = new DefaultTransactionDefinition();
-
-        def.setName("Ignite Tx [cache=" + (cacheName != null ? cacheName : "<default>") + ", id=" + tx.xid() + ']');
-        def.setIsolationLevel(isolationLevel(tx.isolation()));
-        def.setPropagationBehavior(propagation);
-
-        long timeoutSec = (tx.timeout() + 500) / 1000;
-
-        if (timeoutSec > 0 && timeoutSec < Integer.MAX_VALUE)
-            def.setTimeout((int)timeoutSec);
-
-        return def;
-    }
-
-    /**
-     * Gets DB transaction isolation level based on ongoing cache transaction isolation.
-     *
-     * @param isolation Cache transaction isolation.
-     * @return DB transaction isolation.
-     */
-    private int isolationLevel(TransactionIsolation isolation) {
-        switch (isolation) {
-            case READ_COMMITTED:
-                return TransactionDefinition.ISOLATION_READ_COMMITTED;
-
-            case REPEATABLE_READ:
-                return TransactionDefinition.ISOLATION_REPEATABLE_READ;
-
-            case SERIALIZABLE:
-                return TransactionDefinition.ISOLATION_SERIALIZABLE;
-
-            default:
-                throw new IllegalStateException(); // Will never happen.
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListenerSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListenerSelfTest.java
new file mode 100644
index 0000000..74f5c69
--- /dev/null
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheSpringStoreSessionListenerSelfTest.java
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.store.spring;
+
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.cache.store.jdbc.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.resources.*;
+import org.springframework.jdbc.core.*;
+import org.springframework.jdbc.datasource.*;
+import org.springframework.transaction.*;
+
+import javax.cache.*;
+import javax.cache.configuration.*;
+import javax.cache.integration.*;
+import javax.sql.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Tests for {@link CacheJdbcStoreSessionListener}.
+ */
+public class CacheSpringStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
+    /** */
+    private static final DataSource DATA_SRC = new DriverManagerDataSource(URL);
+
+    /** {@inheritDoc} */
+    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
+        return new Factory<CacheStore<Integer, Integer>>() {
+            @Override public CacheStore<Integer, Integer> create() {
+                return new Store(new JdbcTemplate(DATA_SRC));
+            }
+        };
+    }
+
+    /** {@inheritDoc} */
+    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
+        return new Factory<CacheStoreSessionListener>() {
+            @Override public CacheStoreSessionListener create() {
+                CacheSpringStoreSessionListener lsnr = new CacheSpringStoreSessionListener();
+
+                lsnr.setDataSource(DATA_SRC);
+
+                return lsnr;
+            }
+        };
+    }
+
+    /**
+     */
+    private static class Store extends CacheStoreAdapter<Integer, Integer> {
+        /** */
+        private static String SES_CONN_KEY = "ses_conn";
+
+        /** */
+        private final JdbcTemplate jdbc;
+
+        /** */
+        @CacheStoreSessionResource
+        private CacheStoreSession ses;
+
+        /**
+         * @param jdbc JDBC template.
+         */
+        private Store(JdbcTemplate jdbc) {
+            this.jdbc = jdbc;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
+            loadCacheCnt.incrementAndGet();
+
+            checkTransaction();
+            checkConnection();
+        }
+
+        /** {@inheritDoc} */
+        @Override public Integer load(Integer key) throws CacheLoaderException {
+            loadCnt.incrementAndGet();
+
+            checkTransaction();
+            checkConnection();
+
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
+            throws CacheWriterException {
+            writeCnt.incrementAndGet();
+
+            checkTransaction();
+            checkConnection();
+
+            if (write.get()) {
+                String table;
+
+                switch (ses.cacheName()) {
+                    case "cache1":
+                        table = "Table1";
+
+                        break;
+
+                    case "cache2":
+                        if (fail.get())
+                            throw new CacheWriterException("Expected failure.");
+
+                        table = "Table2";
+
+                        break;
+
+                    default:
+                        throw new CacheWriterException("Wring cache: " + ses.cacheName());
+                }
+
+                jdbc.update("INSERT INTO " + table + " (key, value) VALUES (?, ?)",
+                    entry.getKey(), entry.getValue());
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public void delete(Object key) throws CacheWriterException {
+            deleteCnt.incrementAndGet();
+
+            checkTransaction();
+            checkConnection();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sessionEnd(boolean commit) {
+            assertNull(ses.attachment());
+        }
+
+        /**
+         */
+        private void checkTransaction() {
+            TransactionStatus tx = ses.attachment();
+
+            if (ses.isWithinTransaction()) {
+                assertNotNull(tx);
+                assertFalse(tx.isCompleted());
+            }
+            else
+                assertNull(tx);
+        }
+
+        /**
+         */
+        private void checkConnection() {
+            Connection conn = DataSourceUtils.getConnection(jdbc.getDataSource());
+
+            assertNotNull(conn);
+
+            try {
+                assertFalse(conn.isClosed());
+                assertEquals(!ses.isWithinTransaction(), conn.getAutoCommit());
+            }
+            catch (SQLException e) {
+                throw new RuntimeException(e);
+            }
+
+            verifySameInstance(conn);
+        }
+
+        /**
+         * @param conn Connection.
+         */
+        private void verifySameInstance(Connection conn) {
+            Map<String, Connection> props = ses.properties();
+
+            Connection sesConn = props.get(SES_CONN_KEY);
+
+            if (sesConn == null)
+                props.put(SES_CONN_KEY, conn);
+            else {
+                assertSame(conn, sesConn);
+
+                reuseCnt.incrementAndGet();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListenerSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListenerSelfTest.java
deleted file mode 100644
index 83ed249..0000000
--- a/modules/spring/src/test/java/org/apache/ignite/cache/store/spring/CacheStoreSessionSpringListenerSelfTest.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.store.spring;
-
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.cache.store.jdbc.*;
-import org.apache.ignite.lang.*;
-import org.apache.ignite.resources.*;
-import org.springframework.jdbc.core.*;
-import org.springframework.jdbc.datasource.*;
-import org.springframework.transaction.*;
-
-import javax.cache.*;
-import javax.cache.configuration.*;
-import javax.cache.integration.*;
-import javax.sql.*;
-import java.sql.*;
-import java.util.*;
-
-/**
- * Tests for {@link CacheStoreSessionJdbcListener}.
- */
-public class CacheStoreSessionSpringListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest {
-    /** */
-    private static final DataSource DATA_SRC = new DriverManagerDataSource(URL);
-
-    /** {@inheritDoc} */
-    @Override protected Factory<? extends CacheStore<Integer, Integer>> storeFactory() {
-        return new Factory<CacheStore<Integer, Integer>>() {
-            @Override public CacheStore<Integer, Integer> create() {
-                return new Store(new JdbcTemplate(DATA_SRC));
-            }
-        };
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Factory<CacheStoreSessionListener> sessionListenerFactory() {
-        return new Factory<CacheStoreSessionListener>() {
-            @Override public CacheStoreSessionListener create() {
-                CacheStoreSessionSpringListener lsnr = new CacheStoreSessionSpringListener();
-
-                lsnr.setDataSource(DATA_SRC);
-
-                return lsnr;
-            }
-        };
-    }
-
-    /**
-     */
-    private static class Store extends CacheStoreAdapter<Integer, Integer> {
-        /** */
-        private static String SES_CONN_KEY = "ses_conn";
-
-        /** */
-        private final JdbcTemplate jdbc;
-
-        /** */
-        @CacheStoreSessionResource
-        private CacheStoreSession ses;
-
-        /**
-         * @param jdbc JDBC template.
-         */
-        private Store(JdbcTemplate jdbc) {
-            this.jdbc = jdbc;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void loadCache(IgniteBiInClosure<Integer, Integer> clo, Object... args) {
-            loadCacheCnt.incrementAndGet();
-
-            checkTransaction();
-            checkConnection();
-        }
-
-        /** {@inheritDoc} */
-        @Override public Integer load(Integer key) throws CacheLoaderException {
-            loadCnt.incrementAndGet();
-
-            checkTransaction();
-            checkConnection();
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> entry)
-            throws CacheWriterException {
-            writeCnt.incrementAndGet();
-
-            checkTransaction();
-            checkConnection();
-
-            if (write.get()) {
-                String table;
-
-                switch (ses.cacheName()) {
-                    case "cache1":
-                        table = "Table1";
-
-                        break;
-
-                    case "cache2":
-                        if (fail.get())
-                            throw new CacheWriterException("Expected failure.");
-
-                        table = "Table2";
-
-                        break;
-
-                    default:
-                        throw new CacheWriterException("Wring cache: " + ses.cacheName());
-                }
-
-                jdbc.update("INSERT INTO " + table + " (key, value) VALUES (?, ?)",
-                    entry.getKey(), entry.getValue());
-            }
-        }
-
-        /** {@inheritDoc} */
-        @Override public void delete(Object key) throws CacheWriterException {
-            deleteCnt.incrementAndGet();
-
-            checkTransaction();
-            checkConnection();
-        }
-
-        /** {@inheritDoc} */
-        @Override public void sessionEnd(boolean commit) {
-            assertNull(transaction());
-        }
-
-        /**
-         */
-        private void checkTransaction() {
-            TransactionStatus tx = transaction();
-
-            if (ses.isWithinTransaction()) {
-                assertNotNull(tx);
-                assertFalse(tx.isCompleted());
-            }
-            else
-                assertNull(tx);
-        }
-
-        /**
-         * @return Transaction status.
-         */
-        private TransactionStatus transaction() {
-            return ses.<String, TransactionStatus>properties().get(CacheStoreSessionSpringListener.TX_STATUS_KEY);
-        }
-
-        /**
-         */
-        private void checkConnection() {
-            Connection conn = DataSourceUtils.getConnection(jdbc.getDataSource());
-
-            assertNotNull(conn);
-
-            try {
-                assertFalse(conn.isClosed());
-                assertEquals(!ses.isWithinTransaction(), conn.getAutoCommit());
-            }
-            catch (SQLException e) {
-                throw new RuntimeException(e);
-            }
-
-            verifySameInstance(conn);
-        }
-
-        /**
-         * @param conn Connection.
-         */
-        private void verifySameInstance(Connection conn) {
-            Map<String, Connection> props = ses.properties();
-
-            Connection sesConn = props.get(SES_CONN_KEY);
-
-            if (sesConn == null)
-                props.put(SES_CONN_KEY, conn);
-            else {
-                assertSame(conn, sesConn);
-
-                reuseCnt.incrementAndGet();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/990bf9e3/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
index 0b7e471..12dd494 100644
--- a/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
+++ b/modules/spring/src/test/java/org/apache/ignite/testsuites/IgniteSpringTestSuite.java
@@ -48,7 +48,7 @@ public class IgniteSpringTestSuite extends TestSuite {
 
         suite.addTest(new TestSuite(IgniteStartFromStreamConfigurationTest.class));
 
-        suite.addTestSuite(CacheStoreSessionSpringListenerSelfTest.class);
+        suite.addTestSuite(CacheSpringStoreSessionListenerSelfTest.class);
 
         return suite;
     }