You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/04/26 13:25:12 UTC
[01/50] [abbrv] ignite git commit: IGNITE-5058: Fixed QueryIndex
validation when QueryEntity.valueType is not set yet. This closes #1861.
Repository: ignite
Updated Branches:
refs/heads/master f328c4eea -> 402154c65
IGNITE-5058: Fixed QueryIndex validation when QueryEntity.valueType is not set yet. This closes #1861.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1968e4f5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1968e4f5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1968e4f5
Branch: refs/heads/master
Commit: 1968e4f59eea6265aaf82a3fa515eecc99a91310
Parents: 09b6507
Author: devozerov <vo...@gridgain.com>
Authored: Mon Apr 24 12:31:51 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Apr 24 12:31:51 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/QueryEntity.java | 43 ++---
.../processors/cache/GridCacheProcessor.java | 4 +
.../internal/processors/query/QuerySchema.java | 4 +-
.../internal/processors/query/QueryUtils.java | 79 ++++++++-
.../query/h2/H2IndexingAbstractGeoSelfTest.java | 2 +-
.../DynamicIndexAbstractBasicSelfTest.java | 16 +-
.../index/QueryEntityValidationSelfTest.java | 162 +++++++++++++++++++
.../IgniteCacheQuerySelfTestSuite.java | 3 +
8 files changed, 278 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index 31fe264..806cd7d 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -18,16 +18,18 @@
package org.apache.ignite.cache;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.ignite.internal.processors.query.QueryUtils;
-import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Query entity is a description of {@link org.apache.ignite.IgniteCache cache} entry (composed of key and value)
@@ -44,16 +46,20 @@ public class QueryEntity implements Serializable {
private String valType;
/** Fields available for query. A map from field name to type name. */
+ @GridToStringInclude
private LinkedHashMap<String, String> fields = new LinkedHashMap<>();
/** Set of field names that belong to the key. */
+ @GridToStringInclude
private Set<String> keyFields;
/** Aliases. */
+ @GridToStringInclude
private Map<String, String> aliases = new HashMap<>();
/** Collection of query indexes. */
- private Map<String, QueryIndex> idxs = new HashMap<>();
+ @GridToStringInclude
+ private Collection<QueryIndex> idxs;
/** Table name. */
private String tableName;
@@ -78,7 +84,7 @@ public class QueryEntity implements Serializable {
keyFields = other.keyFields != null ? new HashSet<>(other.keyFields) : null;
aliases = new HashMap<>(other.aliases);
- idxs = new HashMap<>(other.idxs);
+ idxs = other.idxs != null ? new ArrayList<>(other.idxs) : null;
tableName = other.tableName;
}
@@ -190,7 +196,7 @@ public class QueryEntity implements Serializable {
* @return Collection of index entities.
*/
public Collection<QueryIndex> getIndexes() {
- return idxs.values();
+ return idxs == null ? Collections.<QueryIndex>emptyList() : idxs;
}
/**
@@ -222,32 +228,12 @@ public class QueryEntity implements Serializable {
* @return {@code this} for chaining.
*/
public QueryEntity setIndexes(Collection<QueryIndex> idxs) {
- for (QueryIndex idx : idxs) {
- if (!F.isEmpty(idx.getFields())) {
- if (idx.getName() == null)
- idx.setName(QueryUtils.indexName(this, idx));
-
- if (idx.getIndexType() == null)
- throw new IllegalArgumentException("Index type is not set " + idx.getName());
-
- if (!this.idxs.containsKey(idx.getName()))
- this.idxs.put(idx.getName(), idx);
- else
- throw new IllegalArgumentException("Duplicate index name: " + idx.getName());
- }
- }
+ this.idxs = idxs;
return this;
}
/**
- * Clear indexes.
- */
- public void clearIndexes() {
- this.idxs.clear();
- }
-
- /**
* Gets table name for this query entity.
*
* @return table name
@@ -282,4 +268,9 @@ public class QueryEntity implements Serializable {
return this;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(QueryEntity.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 28ef22f..a555b55 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -512,6 +512,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (cc.getEvictionPolicy() != null && !cc.isOnheapCacheEnabled())
throw new IgniteCheckedException("Onheap cache must be enabled if eviction policy is configured [cacheName="
+ U.maskName(cc.getName()) + "]");
+
+ QueryUtils.validateCacheConfiguration(cc);
}
/**
@@ -1461,6 +1463,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
+ QueryUtils.prepareCacheConfiguration(cfg);
+
validate(ctx.config(), cfg, cacheType, cfgStore);
if (pluginMgr == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
index 395f077..b380131 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
@@ -111,7 +111,6 @@ public class QuerySchema implements Serializable {
idxs.add(op0.index());
- entity.clearIndexes();
entity.setIndexes(idxs);
}
@@ -142,8 +141,7 @@ public class QuerySchema implements Serializable {
newIdxs.remove(victim);
- entity.clearIndexes();
- entity.setIndexes(idxs);
+ entity.setIndexes(newIdxs);
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
index 3a7437b..e56f39f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryUtils.java
@@ -45,6 +45,7 @@ import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -162,9 +163,6 @@ public class QueryUtils {
*/
public static QueryTypeCandidate typeForQueryEntity(String space, GridCacheContext cctx, QueryEntity qryEntity,
List<Class<?>> mustDeserializeClss) throws IgniteCheckedException {
- if (F.isEmpty(qryEntity.getValueType()))
- throw new IgniteCheckedException("Value type is not set: " + qryEntity);
-
GridKernalContext ctx = cctx.kernalContext();
CacheConfiguration<?,?> ccfg = cctx.config();
@@ -797,6 +795,81 @@ public class QueryUtils {
}
/**
+ * Prepare cache configuration.
+ *
+ * @param ccfg Cache configuration.
+ */
+ @SuppressWarnings("unchecked")
+ public static void prepareCacheConfiguration(CacheConfiguration ccfg) {
+ assert ccfg != null;
+
+ Collection<QueryEntity> entities = ccfg.getQueryEntities();
+
+ if (!F.isEmpty(entities)) {
+ for (QueryEntity entity : entities) {
+ if (F.isEmpty(entity.getValueType()))
+ continue;
+
+ Collection<QueryIndex> idxs = entity.getIndexes();
+
+ if (!F.isEmpty(idxs)) {
+ for (QueryIndex idx : idxs) {
+ if (idx.getName() == null) {
+ String idxName = indexName(entity, idx);
+
+ idx.setName(idxName);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Prepare cache configuration.
+ *
+ * @param ccfg Cache configuration.
+ * @throws IgniteCheckedException If failed.
+ */
+ @SuppressWarnings("unchecked")
+ public static void validateCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException {
+ assert ccfg != null;
+
+ Collection<QueryEntity> entities = ccfg.getQueryEntities();
+
+ if (!F.isEmpty(entities)) {
+ for (QueryEntity entity : entities) {
+ if (F.isEmpty(entity.getValueType()))
+ throw new IgniteCheckedException("Value type cannot be null or empty [cacheName=" +
+ ccfg.getName() + ", queryEntity=" + entity + ']');
+
+ Collection<QueryIndex> idxs = entity.getIndexes();
+
+ if (!F.isEmpty(idxs)) {
+ Set<String> idxNames = new HashSet<>();
+
+ for (QueryIndex idx : idxs) {
+ String idxName = idx.getName();
+
+ if (idxName == null)
+ idxName = indexName(entity, idx);
+
+ assert !F.isEmpty(idxName);
+
+ if (!idxNames.add(idxName))
+ throw new IgniteCheckedException("Duplicate index name [cacheName=" + ccfg.getName() +
+ ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
+
+ if (idx.getIndexType() == null)
+ throw new IgniteCheckedException("Index type is not set [cacheName=" + ccfg.getName() +
+ ", queryEntity=" + entity + ", queryIdx=" + idx + ']');
+ }
+ }
+ }
+ }
+ }
+
+ /**
* Private constructor.
*/
private QueryUtils() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
index 80e9f93..f57d573 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -151,7 +151,7 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
Collection<QueryIndex> idxs = new ArrayList<>(entity.getIndexes());
- entity.clearIndexes();
+ entity.setIndexes(null);
IgniteCache<K, V> cache = grid(0).getOrCreateCache(ccfg);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
index fc3529b..6621bb4 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/DynamicIndexAbstractBasicSelfTest.java
@@ -670,23 +670,35 @@ public abstract class DynamicIndexAbstractBasicSelfTest extends DynamicIndexAbst
public void checkDrop(CacheMode mode, CacheAtomicityMode atomicityMode, boolean near) throws Exception {
initialize(mode, atomicityMode, near);
- QueryIndex idx = index(IDX_NAME_1, field(FIELD_NAME_1));
+ // Create target index.
+ QueryIndex idx1 = index(IDX_NAME_1, field(FIELD_NAME_1));
- dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx, false);
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx1, false);
assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1, field(FIELD_NAME_1));
assertIndexUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
+ // Create another index which must stay intact afterwards.
+ QueryIndex idx2 = index(IDX_NAME_2, field(alias(FIELD_NAME_2)));
+
+ dynamicIndexCreate(CACHE_NAME, TBL_NAME, idx2, false);
+ assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
+
+ // Load some data.
loadInitialData();
+ // Drop index.
dynamicIndexDrop(CACHE_NAME, IDX_NAME_1, false);
assertNoIndex(CACHE_NAME, TBL_NAME, IDX_NAME_1);
assertSimpleIndexOperations(SQL_SIMPLE_FIELD_1);
assertIndexNotUsed(IDX_NAME_1, SQL_SIMPLE_FIELD_1, SQL_ARG_1);
+
+ // Make sure the second index is still there.
+ assertIndex(CACHE_NAME, TBL_NAME, IDX_NAME_2, field(alias(FIELD_NAME_2)));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
new file mode 100644
index 0000000..97c9aa1
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/QueryEntityValidationSelfTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.processors.cache.index;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.concurrent.Callable;
+
+/**
+ * Tests for query entity validation.
+ */
+@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+public class QueryEntityValidationSelfTest extends GridCommonAbstractTest {
+ /** Cache name. */
+ private static final String CACHE_NAME = "cache";
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Test null value type.
+ *
+ * @throws Exception If failed.
+ */
+ public void testValueTypeNull() throws Exception {
+ final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+ QueryEntity entity = new QueryEntity();
+
+ entity.setKeyType("Key");
+
+ ccfg.setQueryEntities(Collections.singleton(entity));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ grid(0).createCache(ccfg);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, "Value type cannot be null or empty");
+ }
+
+ /**
+ * Test failure if index type is null.
+ *
+ * @throws Exception If failed.
+ */
+ public void testIndexTypeNull() throws Exception {
+ final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+ QueryEntity entity = new QueryEntity();
+
+ entity.setKeyType("Key");
+ entity.setValueType("Value");
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("a", Integer.class.getName());
+
+ entity.setFields(fields);
+
+ LinkedHashMap<String, Boolean> idxFields = new LinkedHashMap<>();
+
+ idxFields.put("a", true);
+
+ QueryIndex idx = new QueryIndex().setName("idx").setFields(idxFields).setIndexType(null);
+
+ List<QueryIndex> idxs = new ArrayList<>();
+
+ idxs.add(idx);
+
+ entity.setIndexes(idxs);
+
+ ccfg.setQueryEntities(Collections.singleton(entity));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ grid(0).createCache(ccfg);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, "Index type is not set");
+ }
+
+ /**
+ * Test duplicated index name.
+ *
+ * @throws Exception If failed.
+ */
+ public void testIndexNameDuplicate() throws Exception {
+ final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
+
+ QueryEntity entity = new QueryEntity();
+
+ entity.setKeyType("Key");
+ entity.setValueType("Value");
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("a", Integer.class.getName());
+ fields.put("b", Integer.class.getName());
+
+ entity.setFields(fields);
+
+ LinkedHashMap<String, Boolean> idx1Fields = new LinkedHashMap<>();
+ LinkedHashMap<String, Boolean> idx2Fields = new LinkedHashMap<>();
+
+ idx1Fields.put("a", true);
+ idx1Fields.put("b", true);
+
+ QueryIndex idx1 = new QueryIndex().setName("idx").setFields(idx1Fields);
+ QueryIndex idx2 = new QueryIndex().setName("idx").setFields(idx2Fields);
+
+ List<QueryIndex> idxs = new ArrayList<>();
+
+ idxs.add(idx1);
+ idxs.add(idx2);
+
+ entity.setIndexes(idxs);
+
+ ccfg.setQueryEntities(Collections.singleton(entity));
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ grid(0).createCache(ccfg);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, "Duplicate index name");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1968e4f5/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 405e1f6..862d1a2 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -93,6 +93,7 @@ import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerCoord
import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFIlterBasicSelfTest;
import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerNodeFilterCoordinatorBasicSelfTest;
import org.apache.ignite.internal.processors.cache.index.DynamicIndexServerBasicSelfTest;
+import org.apache.ignite.internal.processors.cache.index.QueryEntityValidationSelfTest;
import org.apache.ignite.internal.processors.cache.index.SchemaExchangeSelfTest;
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
@@ -130,6 +131,8 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
IgniteTestSuite suite = new IgniteTestSuite("Ignite Cache Queries Test Suite");
// Misc tests.
+ // TODO: Enable when IGNITE-1094 is fixed.
+ // suite.addTest(new TestSuite(QueryEntityValidationSelfTest.class));
suite.addTest(new TestSuite(DuplicateKeyValueClassesSelfTest.class));
// Dynamic index create/drop tests.
[06/50] [abbrv] ignite git commit: IGNITE-5066 .NET: Add continuous
query test to verify that the problem from 1.9 no longer reproduces
Posted by vo...@apache.org.
IGNITE-5066 .NET: Add continuous query test to verify that the problem from 1.9 no longer reproduces
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5a433469
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5a433469
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5a433469
Branch: refs/heads/master
Commit: 5a433469afca394fc97b59cc16dbe83b2d24f8c5
Parents: 1214d7e
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Apr 24 14:09:01 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Apr 24 14:09:01 2017 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 1 +
.../Query/Continuous/ContinuousQueryTest.cs | 115 +++++++++++++++++++
2 files changed, 116 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index f4f5e59..c6b183b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -101,6 +101,7 @@
<Compile Include="Cache\Query\CacheDmlQueriesTestSimpleName.cs" />
<Compile Include="Cache\Query\CacheLinqTestSimpleName.cs" />
<Compile Include="Cache\Query\CacheQueriesTestSimpleName.cs" />
+ <Compile Include="Cache\Query\Continuous\ContinuousQueryTest.cs" />
<Compile Include="Cache\Store\CacheStoreAdapterTest.cs" />
<Compile Include="Cache\Store\NamedNodeCacheStoreTest.cs" />
<Compile Include="Cache\TestReferenceObject.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/5a433469/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
new file mode 100644
index 0000000..5148dcc
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryTest.cs
@@ -0,0 +1,115 @@
+\ufeff/*
+ * 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.
+ */
+
+
+namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.Collections.Generic;
+ using System.Threading;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Event;
+ using Apache.Ignite.Core.Cache.Query.Continuous;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests continuous queries.
+ /// </summary>
+ [Category(TestUtils.CategoryIntensive)]
+ public class ContinuousQueryTest
+ {
+ /// <summary>
+ /// Tests same query on multiple nodes.
+ /// This tests verifies that there are no exception on Java side during event delivery.
+ /// </summary>
+ [Test]
+ public void TestSameQueryMultipleNodes()
+ {
+ using (var ignite = StartIgnite())
+ {
+ var cache = ignite.GetOrCreateCache<Guid, Data>("data");
+ cache.QueryContinuous(new ContinuousQuery<Guid, Data>(new Listener()));
+
+ using (var ignite2 = StartIgnite())
+ {
+ var cache2 = ignite2.GetOrCreateCache<Guid, Data>("data");
+ cache2.QueryContinuous(new ContinuousQuery<Guid, Data>(new Listener()));
+
+ for (var i = 0; i < 100; i++)
+ {
+ PutEntry(cache2);
+ PutEntry(cache);
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Puts the entry and verifies events.
+ /// </summary>
+ private static void PutEntry(ICache<Guid, Data> cache)
+ {
+ // Put new entry.
+ var entry = new Data {Id = Guid.NewGuid()};
+ cache.Put(entry.Id, entry);
+
+ // Wait for events.
+ Thread.Sleep(100);
+
+ ICacheEntryEvent<Guid, Data> e;
+
+ // Two listeners - two events.
+ Assert.IsTrue(Listener.Events.TryPop(out e));
+ Assert.AreEqual(entry.Id, e.Key);
+
+ Assert.IsTrue(Listener.Events.TryPop(out e));
+ Assert.AreEqual(entry.Id, e.Key);
+ }
+
+ /// <summary>
+ /// Starts the ignite.
+ /// </summary>
+ private static IIgnite StartIgnite()
+ {
+ return Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
+ {
+ BinaryConfiguration = new Core.Binary.BinaryConfiguration(typeof(Data)),
+ AutoGenerateIgniteInstanceName = true
+ });
+ }
+
+ private class Data
+ {
+ public Guid Id;
+ }
+
+ private class Listener : ICacheEntryEventListener<Guid, Data>
+ {
+ public static readonly ConcurrentStack<ICacheEntryEvent<Guid, Data>> Events
+ = new ConcurrentStack<ICacheEntryEvent<Guid, Data>>();
+
+ public void OnEvent(IEnumerable<ICacheEntryEvent<Guid, Data>> evts)
+ {
+ foreach (var e in evts)
+ {
+ Events.Push(e);
+ }
+ }
+ }
+ }
+}
[41/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
new file mode 100644
index 0000000..880d12a
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
@@ -0,0 +1,238 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.Map;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * 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;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
new file mode 100644
index 0000000..3822b31
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- Show SQL. -->
+ <property name="show_sql">true</property>
+
+ <!-- Database connection settings (private in-memory database). -->
+ <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+ <!-- Only validate the database schema on startup in production mode. -->
+ <property name="hbm2ddl.auto">update</property>
+
+ <!-- H2 dialect. -->
+ <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
+
+ <!-- Mappings. -->
+ <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/>
+ </session-factory>
+</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
new file mode 100644
index 0000000..8af9886
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains internal tests or test related classes and interfaces.
+ */
+package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
new file mode 100644
index 0000000..3791bae
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
@@ -0,0 +1,37 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ *
+ */
+public class IgniteBinaryHibernateTestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+ return IgniteHibernateTestSuite.suite();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
new file mode 100644
index 0000000..99fea56
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
@@ -0,0 +1,57 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest;
+
+/**
+ * Hibernate integration tests.
+ */
+public class IgniteHibernateTestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Hibernate Integration Test Suite");
+
+ // Hibernate L2 cache.
+ suite.addTestSuite(HibernateL2CacheSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class);
+
+ suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class);
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/README.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/README.txt b/modules/hibernate-5.1/README.txt
new file mode 100644
index 0000000..53c5d18
--- /dev/null
+++ b/modules/hibernate-5.1/README.txt
@@ -0,0 +1,48 @@
+Apache Ignite Hibernate Module
+------------------------------
+
+Apache Ignite Hibernate module provides Hibernate second-level cache (L2 cache) implementation based
+on Apache Ignite In-Memory Data Grid.
+
+To enable Hibernate module when starting a standalone node, move 'optional/ignite-hibernate5' folder to
+'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will
+be added to classpath in this case.
+
+Importing Hibernate Module In Maven Project
+-------------------------------------------
+
+If you are using Maven to manage dependencies of your project, you can add Hibernate module
+dependency like this (replace '${ignite.version}' with actual Ignite version you are
+interested in):
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ ...
+ <dependencies>
+ ...
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+
+
+LGPL dependencies
+-----------------
+
+Ignite includes the following optional LGPL dependencies:
+ - Hibernate L2 Cache Integration, http://hibernate.org/orm/
+ - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
+ - cron4j for cron-based task scheduling, http://www.sauronsoftware.it/projects/cron4j
+
+Apache binary releases cannot include LGPL dependencies. If you would like include
+optional LGPL dependencies into your release, you should download the source release
+from Ignite website and do the build with the following maven command:
+
+mvn clean package -DskipTests -Prelease,lgpl
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/licenses/apache-2.0.txt b/modules/hibernate-5.1/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/hibernate-5.1/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/pom.xml b/modules/hibernate-5.1/pom.xml
new file mode 100644
index 0000000..80299bc
--- /dev/null
+++ b/modules/hibernate-5.1/pom.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate_5.1</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>5.1.5.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.jotm</groupId>
+ <artifactId>jotm-core</artifactId>
+ <version>2.1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
new file mode 100644
index 0000000..c5829bf
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
@@ -0,0 +1,103 @@
+/*
+ * 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.hibernate;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.access.RegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of L2 cache access strategy delegating to {@link HibernateAccessStrategyAdapter}.
+ */
+public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
+ /** */
+ protected final HibernateAccessStrategyAdapter stgy;
+
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ protected HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ this.stgy = stgy;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(SessionImplementor ses, Object key, long txTs) throws CacheException {
+ return stgy.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(SessionImplementor ses, Object key, Object val, long txTs, Object ver) throws CacheException {
+ stgy.putFromLoad(key, val);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(SessionImplementor ses, Object key, Object val, long txTs, Object ver, boolean minimalPutOverride)
+ throws CacheException {
+ stgy.putFromLoad(key, val, minimalPutOverride);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockItem(SessionImplementor ses, Object key, Object ver) throws CacheException {
+ stgy.lock(key);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockRegion() throws CacheException {
+ stgy.lockRegion();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockRegion(SoftLock lock) throws CacheException {
+ stgy.unlockRegion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockItem(SessionImplementor ses, Object key, SoftLock lock) throws CacheException {
+ stgy.unlock(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(SessionImplementor ses, Object key) throws CacheException {
+ stgy.remove(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll() throws CacheException {
+ stgy.removeAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ stgy.evict(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ stgy.evictAll();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
new file mode 100644
index 0000000..be99e98
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
@@ -0,0 +1,114 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+
+/**
+ * Implementation of {@link CollectionRegion}. This region is used to store collection data.
+ * <p>
+ * L2 cache for collection can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entities. -->
+ * <mapping class="com.example.Entity"/>
+ * <mapping class="com.example.ChildEntity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entities and collection. -->
+ * <collection-cache collection="com.example.Entity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.ChildEntity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.Entity.children" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for collection can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * public class Entity {
+ * ...
+ *
+ * @javax.persistence.OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ * @javax.persistence.JoinColumn(name="PARENT_ID")
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public List<ChildEntity> getChildren() {...}
+ * }
+ * </pre>
+ * Note: the collection cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * values. For this reason, the collection cache should always be used in conjunction with
+ * the second-level cache for those entities expected to be cached as part of a collection cache.
+ */
+public class HibernateCollectionRegion extends HibernateTransactionalDataRegion implements CollectionRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ public HibernateCollectionRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Collection region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements CollectionRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object generateCacheKey(Object id,
+ CollectionPersister persister,
+ SessionFactoryImplementor factory, String tenantIdentifier) {
+ return HibernateKeyWrapper.staticCreateCollectionKey(id, persister, tenantIdentifier);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getCacheKeyId(Object cacheKey) {
+ return ((HibernateKeyWrapper)cacheKey).id();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion getRegion() {
+ return HibernateCollectionRegion.this;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
new file mode 100644
index 0000000..c669400
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
@@ -0,0 +1,128 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * Implementation of {@link EntityRegion}. This region is used to store entity data.
+ * <p>
+ * L2 cache for entity can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for entity can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateEntityRegion extends HibernateTransactionalDataRegion implements EntityRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ public HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
+ HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Entity region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements EntityRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object generateCacheKey(Object id,
+ EntityPersister persister,
+ SessionFactoryImplementor factory,
+ String tenantIdentifier) {
+ return HibernateKeyWrapper.staticCreateEntityKey(id, persister, tenantIdentifier);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getCacheKeyId(Object cacheKey) {
+ return ((HibernateKeyWrapper)cacheKey).id();
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion getRegion() {
+ return HibernateEntityRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(SessionImplementor ses, Object key, Object val, Object ver) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(SessionImplementor ses, Object key, Object val, Object ver) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(SessionImplementor ses, Object key, Object val, Object currVer, Object previousVer)
+ throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(SessionImplementor ses, Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
+ throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
new file mode 100644
index 0000000..9365157
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
@@ -0,0 +1,79 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.GeneralDataRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link GeneralDataRegion}. This interface defines common contract for {@link QueryResultsRegion}
+ * and {@link TimestampsRegion}.
+ */
+public class HibernateGeneralDataRegion extends HibernateRegion implements GeneralDataRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(SessionImplementor ses, Object key) throws CacheException {
+ try {
+ return cache.get(key);
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void put(SessionImplementor ses, Object key, Object val) throws CacheException {
+ try {
+ cache.put(key, val);
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ HibernateAccessStrategyAdapter.evict(ignite, cache, key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ try {
+ HibernateAccessStrategyAdapter.evictAll(cache);
+ }
+ catch (IgniteCheckedException e) {
+ throw HibernateRegionFactory.EXCEPTION_CONVERTER.convert(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
new file mode 100644
index 0000000..45d00e4
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
@@ -0,0 +1,109 @@
+/*
+ * 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.hibernate;
+
+import java.io.Serializable;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.hibernate.cache.internal.DefaultCacheKeysFactory;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * Hibernate cache key wrapper.
+ */
+public class HibernateKeyWrapper implements Serializable {
+ /** Key. */
+ private final Object key;
+
+ /** Entry. */
+ private final String entry;
+
+ /** */
+ private final String tenantId;
+
+ /**
+ * @param key Key.
+ * @param entry Entry.
+ * @param tenantId Tenant ID.
+ */
+ HibernateKeyWrapper(Object key, String entry, String tenantId) {
+ this.key = key;
+ this.entry = entry;
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return ID.
+ */
+ Object id() {
+ return key;
+ }
+
+ /**
+ * @param id ID.
+ * @param persister Persister.
+ * @param tenantIdentifier Tenant ID.
+ * @return Cache key.
+ * @see DefaultCacheKeysFactory#staticCreateCollectionKey(Object, CollectionPersister, SessionFactoryImplementor, String)
+ */
+ static Object staticCreateCollectionKey(Object id,
+ CollectionPersister persister,
+ String tenantIdentifier) {
+ return new HibernateKeyWrapper(id, persister.getRole(), tenantIdentifier);
+ }
+
+ /**
+ * @param id ID.
+ * @param persister Persister.
+ * @param tenantIdentifier Tenant ID.
+ * @return Cache key.
+ * @see DefaultCacheKeysFactory#staticCreateEntityKey(Object, EntityPersister, SessionFactoryImplementor, String)
+ */
+ public static Object staticCreateEntityKey(Object id, EntityPersister persister, String tenantIdentifier) {
+ return new HibernateKeyWrapper(id, persister.getRootEntityName(), tenantIdentifier);
+ }
+
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ HibernateKeyWrapper that = (HibernateKeyWrapper) o;
+
+ return (key != null ? key.equals(that.key) : that.key == null) &&
+ (entry != null ? entry.equals(that.entry) : that.entry == null) &&
+ (tenantId != null ? tenantId.equals(that.tenantId) : that.tenantId == null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = key != null ? key.hashCode() : 0;
+ res = 31 * res + (entry != null ? entry.hashCode() : 0);
+ res = 31 * res + (tenantId != null ? tenantId.hashCode() : 0);
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HibernateKeyWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
new file mode 100644
index 0000000..68816de
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
@@ -0,0 +1,113 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.internal.DefaultCacheKeysFactory;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * Implementation of {@link NaturalIdRegion}. This region is used to store naturalId data.
+ * <p>
+ * L2 cache for entity naturalId and target cache region can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * @org.hibernate.annotations.NaturalIdCache
+ * public class Entity {
+ * @org.hibernate.annotations.NaturalId
+ * private String entityCode;
+ *
+ * ...
+ * }
+ * </pre>
+ */
+public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion implements NaturalIdRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ public HibernateNaturalIdRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * NaturalId region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy implements
+ NaturalIdRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object generateCacheKey(Object[] naturalIdValues, EntityPersister persister, SessionImplementor ses) {
+ return DefaultCacheKeysFactory.staticCreateNaturalIdKey(naturalIdValues, persister, ses);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object[] getNaturalIdValues(Object cacheKey) {
+ return DefaultCacheKeysFactory.staticGetNaturalIdValues(cacheKey);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion getRegion() {
+ return HibernateNaturalIdRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(SessionImplementor ses, Object key, Object val) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(SessionImplementor ses, Object key, Object val) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(SessionImplementor ses, Object key, Object val) throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(SessionImplementor ses, Object key, Object val, SoftLock lock) throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
new file mode 100644
index 0000000..0b9a43d
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
@@ -0,0 +1,70 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.Query;
+import org.hibernate.cache.spi.QueryResultsRegion;
+
+/**
+ * Implementation of {@link QueryResultsRegion}. This region is used to store query results.
+ * <p>
+ * Query results caching can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Enable query cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * By default queries are not cached even after enabling query caching, to enable results caching for a particular
+ * query, call {@link Query#setCacheable(boolean)}:
+ * <pre name="code" class="java">
+ * Session ses = getSession();
+ *
+ * Query qry = ses.createQuery("...");
+ *
+ * qry.setCacheable(true); // Enable L2 cache for query.
+ * </pre>
+ * Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * values. For this reason, the query cache should always be used in conjunction with
+ * the second-level cache for those entities expected to be cached as part of a query result cache
+ */
+public class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ public HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
new file mode 100644
index 0000000..11a96d0
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
@@ -0,0 +1,99 @@
+/*
+ * 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.hibernate;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.Region;
+
+/**
+ * Implementation of {@link Region}. This interface defines base contract for all L2 cache regions.
+ */
+public class HibernateRegion implements Region {
+ /** */
+ protected final HibernateRegionFactory factory;
+
+ /** */
+ private final String name;
+
+ /** Cache instance. */
+ protected final HibernateCacheProxy cache;
+
+ /** Grid instance. */
+ protected Ignite ignite;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ public HibernateRegion(HibernateRegionFactory factory, String name, Ignite ignite, HibernateCacheProxy cache) {
+ this.factory = factory;
+ this.name = name;
+ this.ignite = ignite;
+ this.cache = cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy() throws CacheException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object key) {
+ return cache.containsKey(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getSizeInMemory() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountInMemory() {
+ return cache.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountOnDisk() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map toMap() {
+ return Collections.emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getTimeout() {
+ return 0;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
new file mode 100644
index 0000000..bf7d7e9
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
@@ -0,0 +1,168 @@
+/*
+ * 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.hibernate;
+
+import java.util.Properties;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.hibernate.boot.spi.SessionFactoryOptions;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.hibernate.cache.spi.access.AccessType;
+
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+
+/**
+ * Hibernate L2 cache region factory.
+ * <p>
+ * Following Hibernate settings should be specified to enable second level cache and to use this
+ * region factory for caching:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * hibernate.cache.use_second_level_cache=true
+ * hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
+ * </pre>
+ * Note that before region factory is started you need to start properly configured Ignite node in the same JVM.
+ * For example to start Ignite node one of loader provided in {@code org.apache.ignite.grid.startup} package can be used.
+ * <p>
+ * Name of Ignite instance to be used for region factory must be specified as following Hibernate property:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance name>
+ * </pre>
+ * Each Hibernate cache region must be associated with some {@link IgniteInternalCache}, by default it is assumed that
+ * for each cache region there is a {@link IgniteInternalCache} with the same name. Also it is possible to define
+ * region to cache mapping using properties with prefix {@code org.apache.ignite.hibernate.region_cache}.
+ * For example if for region with name "region1" cache with name "cache1" should be used then following
+ * Hibernate property should be specified:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.region_cache.region1=cache1
+ * </pre>
+ */
+public class HibernateRegionFactory implements RegionFactory {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ static final HibernateExceptionConverter EXCEPTION_CONVERTER = new HibernateExceptionConverter() {
+ @Override public RuntimeException convert(Exception e) {
+ return new CacheException(e);
+ }
+ };
+
+ /** Default region access type. */
+ private AccessType dfltAccessType;
+
+ /** Key transformer. */
+ private final HibernateKeyTransformer hibernate4transformer = new HibernateKeyTransformer() {
+ @Override public Object transform(Object key) {
+ return key;
+ }
+ };
+
+ /** */
+ private final HibernateAccessStrategyFactory accessStgyFactory =
+ new HibernateAccessStrategyFactory(hibernate4transformer, EXCEPTION_CONVERTER);
+
+ /** {@inheritDoc} */
+ @Override public void start(SessionFactoryOptions settings, Properties props) throws CacheException {
+ String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());
+
+ dfltAccessType = AccessType.valueOf(accessType);
+
+ accessStgyFactory.start(props);
+ }
+
+ /**
+ * @return Access strategy factory.
+ */
+ HibernateAccessStrategyFactory accessStrategyFactory() {
+ return accessStgyFactory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public AccessType getDefaultAccessType() {
+ return dfltAccessType;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion buildEntityRegion(String regionName, Properties props, CacheDataDescription metadata)
+ throws CacheException {
+ return new HibernateEntityRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateNaturalIdRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion buildCollectionRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateCollectionRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
+ throws CacheException {
+ return new HibernateQueryResultsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+
+ /** {@inheritDoc} */
+ @Override public TimestampsRegion buildTimestampsRegion(String regionName, Properties props) throws CacheException {
+ return new HibernateTimestampsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
new file mode 100644
index 0000000..8b4c243
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
@@ -0,0 +1,39 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.spi.TimestampsRegion;
+
+/**
+ * Implementation of {@link TimestampsRegion}. This region is automatically created when query
+ * caching is enabled and it holds most recent updates timestamps to queryable tables.
+ * Name of timestamps region is {@code "org.hibernate.cache.spi.UpdateTimestampsCache"}.
+ */
+public class HibernateTimestampsRegion extends HibernateGeneralDataRegion implements TimestampsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ public HibernateTimestampsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
new file mode 100644
index 0000000..275ea9e
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
@@ -0,0 +1,84 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.TransactionalDataRegion;
+import org.hibernate.cache.spi.access.AccessType;
+
+/**
+ * Implementation of {@link TransactionalDataRegion} (transactional means that
+ * data in the region is updated in connection with database transaction).
+ * This interface defines base contract for {@link EntityRegion}, {@link CollectionRegion}
+ * and {@link NaturalIdRegion}.
+ */
+public class HibernateTransactionalDataRegion extends HibernateRegion implements TransactionalDataRegion {
+ /** */
+ private final CacheDataDescription dataDesc;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ HibernateTransactionalDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache);
+
+ this.dataDesc = dataDesc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isTransactionAware() {
+ return false; // This method is not used by Hibernate.
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheDataDescription getCacheDataDescription() {
+ return dataDesc;
+ }
+
+ /**
+ * @param accessType Hibernate L2 cache access type.
+ * @return Access strategy for given access type.
+ */
+ HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
+ switch (accessType) {
+ case READ_ONLY:
+ return factory.accessStrategyFactory().createReadOnlyStrategy(cache);
+
+ case NONSTRICT_READ_WRITE:
+ return factory.accessStrategyFactory().createNonStrictReadWriteStrategy(cache);
+
+ case READ_WRITE:
+ return factory.accessStrategyFactory().createReadWriteStrategy(cache);
+
+ case TRANSACTIONAL:
+ return factory.accessStrategyFactory().createTransactionalStrategy(cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
new file mode 100644
index 0000000..1179aec
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 description. -->
+ * Contains implementation of Hibernate L2 cache. Refer to
+ * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
+ * configure and use Ignite with Hibernate.
+ */
+package org.apache.ignite.cache.hibernate;
\ No newline at end of file
[31/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
deleted file mode 100644
index c87f08f..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
+++ /dev/null
@@ -1,542 +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 java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
-import org.apache.ignite.transactions.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.SharedSessionContract;
-import org.hibernate.cfg.Configuration;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * {@link CacheStore} implementation backed by Hibernate. This implementation
- * stores objects in underlying database in {@code BLOB} format.
- * <h2 class="header">Configuration</h2>
- * Either {@link #setSessionFactory(SessionFactory)} or
- * {@link #setHibernateConfigurationPath(String)} or
- * {@link #setHibernateProperties(Properties)} should be set.
- * <p>
- * If session factory is provided it should contain
- * {@link CacheHibernateBlobStoreEntry} persistent class (via provided
- * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
- * adding {@link CacheHibernateBlobStoreEntry} to annotated classes
- * of session factory.
- * <p>
- * Path to hibernate configuration may be either an URL or a file path or
- * a classpath resource. This configuration file should include provided
- * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
- * class {@link CacheHibernateBlobStoreEntry}.
- * <p>
- * If hibernate properties are provided, mapping
- * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
- * <p>
- * Use {@link CacheHibernateBlobStoreFactory} factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
- */
-public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
- /**
- * Default connection URL
- * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
- */
- public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
- "DEFAULT_LOCK_TIMEOUT=5000";
-
- /** Default show SQL property value (value is <tt>true</tt>). */
- public static final String DFLT_SHOW_SQL = "true";
-
- /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
- public static final String DFLT_HBM2DDL_AUTO = "update";
-
- /** Session attribute name. */
- private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
-
- /** Name of Hibarname mapping resource. */
- private static final String MAPPING_RESOURCE =
- "org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml";
-
- /** Marshaller. */
- private static final Marshaller marsh = new JdkMarshaller();
-
- /** Init guard. */
- @GridToStringExclude
- private final AtomicBoolean initGuard = new AtomicBoolean();
-
- /** Init latch. */
- @GridToStringExclude
- private final CountDownLatch initLatch = new CountDownLatch(1);
-
- /** Hibernate properties. */
- @GridToStringExclude
- private Properties hibernateProps;
-
- /** Session factory. */
- @GridToStringExclude
- private SessionFactory sesFactory;
-
- /** Path to hibernate configuration file. */
- private String hibernateCfgPath;
-
- /** Log. */
- @LoggerResource
- private IgniteLogger log;
-
- /** Auto-injected store session. */
- @CacheStoreSessionResource
- private CacheStoreSession ses;
-
- /** Ignite instance. */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
- @Override public V load(K key) {
- init();
-
- Transaction tx = transaction();
-
- if (log.isDebugEnabled())
- log.debug("Store load [key=" + key + ", tx=" + tx + ']');
-
- Session ses = session(tx);
-
- try {
- CacheHibernateBlobStoreEntry entry = (CacheHibernateBlobStoreEntry)
- ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
-
- if (entry == null)
- return null;
-
- return fromBytes(entry.getValue());
- }
- catch (IgniteCheckedException | HibernateException e) {
- rollback(ses, tx);
-
- throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
- }
- finally {
- end(ses, tx);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
- init();
-
- Transaction tx = transaction();
-
- K key = entry.getKey();
- V val = entry.getValue();
-
- if (log.isDebugEnabled())
- log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
-
- if (val == null) {
- delete(key);
-
- return;
- }
-
- Session ses = session(tx);
-
- try {
- CacheHibernateBlobStoreEntry entry0 = new CacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
-
- ses.saveOrUpdate(entry0);
- }
- catch (IgniteCheckedException | 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", "JpaQlInspection"})
- @Override public void delete(Object key) {
- init();
-
- Transaction tx = transaction();
-
- if (log.isDebugEnabled())
- log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
-
- Session ses = session(tx);
-
- try {
- Object obj = ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
-
- if (obj != null)
- ses.delete(obj);
- }
- catch (IgniteCheckedException | HibernateException e) {
- rollback(ses, tx);
-
- throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
- }
- finally {
- end(ses, tx);
- }
- }
-
- /**
- * Rolls back hibernate session.
- *
- * @param ses Hibernate session.
- * @param tx Cache ongoing transaction.
- */
- private void rollback(SharedSessionContract 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, 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) {
- init();
-
- Transaction tx = transaction();
-
- Map<String, Session> props = session().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();
-
- if (log.isDebugEnabled())
- log.debug("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.
- */
- Session session(@Nullable Transaction tx) {
- Session ses;
-
- if (tx != null) {
- Map<String, Session> props = session().properties();
-
- ses = props.get(ATTR_SES);
-
- if (ses == null) {
- ses = sesFactory.openSession();
-
- ses.beginTransaction();
-
- // Store session in transaction metadata, so it can be accessed
- // for other operations on the same transaction.
- props.put(ATTR_SES, ses);
-
- if (log.isDebugEnabled())
- log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
- }
- }
- else {
- ses = sesFactory.openSession();
-
- ses.beginTransaction();
- }
-
- return ses;
- }
-
- /**
- * Sets session factory.
- *
- * @param sesFactory Session factory.
- */
- public void setSessionFactory(SessionFactory sesFactory) {
- this.sesFactory = sesFactory;
- }
-
- /**
- * Sets hibernate configuration path.
- * <p>
- * This may be either URL or file path or classpath resource.
- *
- * @param hibernateCfgPath URL or file path or classpath resource
- * pointing to hibernate configuration XML file.
- */
- public void setHibernateConfigurationPath(String hibernateCfgPath) {
- this.hibernateCfgPath = hibernateCfgPath;
- }
-
- /**
- * Sets Hibernate properties.
- *
- * @param hibernateProps Hibernate properties.
- */
- public void setHibernateProperties(Properties hibernateProps) {
- this.hibernateProps = hibernateProps;
- }
-
- /**
- * Initializes store.
- *
- * @throws IgniteException If failed to initialize.
- */
- private void init() throws IgniteException {
- if (initGuard.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Initializing cache store.");
-
- try {
- if (sesFactory != null)
- // Session factory has been provided - nothing to do.
- return;
-
- if (!F.isEmpty(hibernateCfgPath)) {
- try {
- URL url = new URL(hibernateCfgPath);
-
- sesFactory = new Configuration().configure(url).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using URL: " + url);
-
- // Session factory has been successfully initialized.
- return;
- }
- catch (MalformedURLException e) {
- if (log.isDebugEnabled())
- log.debug("Caught malformed URL exception: " + e.getMessage());
- }
-
- // Provided path is not a valid URL. File?
- File cfgFile = new File(hibernateCfgPath);
-
- if (cfgFile.exists()) {
- sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using file: " + hibernateCfgPath);
-
- // Session factory has been successfully initialized.
- return;
- }
-
- // Provided path is not a file. Classpath resource?
- sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
- }
- else {
- if (hibernateProps == null) {
- U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
-
- hibernateProps = new Properties();
-
- hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
- hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
- hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
- }
-
- Configuration cfg = new Configuration();
-
- cfg.setProperties(hibernateProps);
-
- assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
-
- cfg.addResource(MAPPING_RESOURCE);
-
- sesFactory = cfg.buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using properties: " + hibernateProps);
- }
- }
- catch (HibernateException e) {
- throw new IgniteException("Failed to initialize store.", e);
- }
- finally {
- initLatch.countDown();
- }
- }
- else if (initLatch.getCount() > 0) {
- try {
- U.await(initLatch);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new IgniteException(e);
- }
- }
-
- if (sesFactory == null)
- throw new IgniteException("Cache store was not properly initialized.");
- }
-
- /**
- * Checks availability of a classpath resource.
- *
- * @param name Resource name.
- * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
- */
- private boolean resourceAvailable(String name) {
- InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
-
- if (cfgStream == null) {
- log.error("Classpath resource not found: " + name);
-
- return false;
- }
-
- try {
- // Read a single byte to force actual content access by JVM.
- cfgStream.read();
-
- return true;
- }
- catch (IOException e) {
- log.error("Failed to read classpath resource: " + name, e);
-
- return false;
- }
- finally {
- U.close(cfgStream, log);
- }
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(CacheHibernateBlobStore.class, this);
- }
-
- /**
- * Serialize object to byte array using marshaller.
- *
- * @param obj Object to convert to byte array.
- * @return Byte array.
- * @throws IgniteCheckedException If failed to convert.
- */
- protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return U.marshal(marsh, obj);
- }
-
- /**
- * Deserialize object from byte array using marshaller.
- *
- * @param bytes Bytes to deserialize.
- * @param <X> Result object type.
- * @return Deserialized object.
- * @throws IgniteCheckedException If failed.
- */
- protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
- if (bytes == null || bytes.length == 0)
- return null;
-
- return U.unmarshal(marsh, bytes, getClass().getClassLoader());
- }
-
- /**
- * @return Current transaction.
- */
- @Nullable private Transaction transaction() {
- CacheStoreSession ses = session();
-
- return ses != null ? ses.transaction() : null;
- }
-
- /**
- * @return Store session.
- */
- private CacheStoreSession session() {
- return ses;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
deleted file mode 100644
index 5b0be43..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.apache.ignite.examples.datagrid.store" default-access="field">
- <class name="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry" table="ENTRIES">
- <id name="key"/>
-
- <property name="val"/>
- </class>
-</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
deleted file mode 100644
index d40c5ef..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
+++ /dev/null
@@ -1,89 +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 javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * Entry that is used by {@link CacheHibernateBlobStore} implementation.
- * <p>
- * Note that this is a reference implementation for tests only.
- * When running on production systems use concrete key-value types to
- * get better performance.
- */
-@Entity
-@Table(name = "ENTRIES")
-public class CacheHibernateBlobStoreEntry {
- /** Key (use concrete key type in production). */
- @Id
- @Column(length = 65535)
- private byte[] key;
-
- /** Value (use concrete value type in production). */
- @Column(length = 65535)
- private byte[] val;
-
- /**
- * Constructor.
- */
- CacheHibernateBlobStoreEntry() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param key Key.
- * @param val Value.
- */
- CacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
- this.key = key;
- this.val = val;
- }
-
- /**
- * @return Key.
- */
- public byte[] getKey() {
- return key;
- }
-
- /**
- * @param key Key.
- */
- public void setKey(byte[] key) {
- this.key = key;
- }
-
- /**
- * @return Value.
- */
- public byte[] getValue() {
- return val;
- }
-
- /**
- * @param val Value.
- */
- public void setValue(byte[] val) {
- this.val = val;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
deleted file mode 100644
index ea4df8a..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.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 java.util.Properties;
-import javax.cache.configuration.Factory;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteComponentType;
-import org.apache.ignite.internal.util.spring.IgniteSpringHelper;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.resources.SpringApplicationContextResource;
-import org.hibernate.SessionFactory;
-
-/**
- * {@link Factory} implementation for {@link CacheHibernateBlobStore}.
- *
- * Use this factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
- *
- * <h2 class="header">Java Example</h2>
- * In this example existing session factory is provided.
- * <pre name="code" class="java">
- * ...
- * CacheHibernateBlobStoreFactory<String, String> factory = new CacheHibernateBlobStoreFactory<String, String>();
- *
- * factory.setSessionFactory(sesFactory);
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM)</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="sessionFactory">
- * <bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- * <property name="hibernateProperties">
- * <value>
- * connection.url=jdbc:h2:mem:
- * show_sql=true
- * hbm2ddl.auto=true
- * hibernate.dialect=org.hibernate.dialect.H2Dialect
- * </value>
- * </property>
- * <property name="mappingResources">
- * <list>
- * <value>
- * org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
- * </value>
- * </list>
- * </property>
- * </bean>
- * </property>
- * </bean>
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory1"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="sessionFactory">
- * <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- * <property name="hibernateProperties">
- * <value>
- * connection.url=jdbc:h2:mem:
- * show_sql=true
- * hbm2ddl.auto=true
- * hibernate.dialect=org.hibernate.dialect.H2Dialect
- * </value>
- * </property>
- * <property name="annotatedClasses">
- * <list>
- * <value>
- * org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry
- * </value>
- * </list>
- * </property>
- * </bean>
- * </property>
- * </bean>
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory2"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="hibernateProperties">
- * <props>
- * <prop key="connection.url">jdbc:h2:mem:</prop>
- * <prop key="hbm2ddl.auto">update</prop>
- * <prop key="show_sql">true</prop>
- * </props>
- * </property>
- * </bean>
- * ...
- * </pre>
- * <p>
- * <img src="http://ignite.apache.org/images/spring-small.png">
- * <br>
- * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- */
-public class CacheHibernateBlobStoreFactory<K, V> implements Factory<CacheHibernateBlobStore<K, V>> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Session factory. */
- @GridToStringExclude
- private transient SessionFactory sesFactory;
-
- /** Session factory bean name. */
- private String sesFactoryBean;
-
- /** Path to hibernate configuration file. */
- private String hibernateCfgPath;
-
- /** Hibernate properties. */
- @GridToStringExclude
- private Properties hibernateProps;
-
- /** Application context. */
- @SpringApplicationContextResource
- private Object appContext;
-
- /** {@inheritDoc} */
- @Override public CacheHibernateBlobStore<K, V> create() {
- CacheHibernateBlobStore<K, V> store = new CacheHibernateBlobStore<>();
-
- store.setHibernateConfigurationPath(hibernateCfgPath);
- store.setHibernateProperties(hibernateProps);
-
- if (sesFactory != null)
- store.setSessionFactory(sesFactory);
- else if (sesFactoryBean != null) {
- if (appContext == null)
- throw new IgniteException("Spring application context resource is not injected.");
-
- IgniteSpringHelper spring;
-
- try {
- spring = IgniteComponentType.SPRING.create(false);
-
- SessionFactory sesFac = spring.loadBeanFromAppContext(appContext, sesFactoryBean);
-
- store.setSessionFactory(sesFac);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to load bean in application context [beanName=" + sesFactoryBean +
- ", igniteConfig=" + appContext + ']');
- }
- }
-
- return store;
- }
-
- /**
- * Sets session factory.
- *
- * @param sesFactory Session factory.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
- */
- public CacheHibernateBlobStoreFactory<K, V> setSessionFactory(SessionFactory sesFactory) {
- this.sesFactory = sesFactory;
-
- return this;
- }
-
- /**
- * Sets name of the data source bean.
- *
- * @param sesFactory Session factory bean name.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
- */
- public CacheHibernateBlobStoreFactory<K, V> setSessionFactoryBean(String sesFactory) {
- this.sesFactoryBean = sesFactory;
-
- return this;
- }
-
- /**
- * Sets hibernate configuration path.
- * <p>
- * This may be either URL or file path or classpath resource.
- *
- * @param hibernateCfgPath URL or file path or classpath resource
- * pointing to hibernate configuration XML file.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setHibernateConfigurationPath(String)
- */
- public CacheHibernateBlobStoreFactory<K, V> setHibernateConfigurationPath(String hibernateCfgPath) {
- this.hibernateCfgPath = hibernateCfgPath;
-
- return this;
- }
-
- /**
- * Sets Hibernate properties.
- *
- * @param hibernateProps Hibernate properties.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setHibernateProperties(Properties)
- */
- public CacheHibernateBlobStoreFactory<K, V> setHibernateProperties(Properties hibernateProps) {
- this.hibernateProps = hibernateProps;
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(CacheHibernateBlobStoreFactory.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
deleted file mode 100644
index 0f5a33c..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.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 java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lifecycle.LifecycleAware;
-import org.apache.ignite.resources.LoggerResource;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-
-/**
- * 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<Integer, Integer> {
- * @CacheStoreSessionResource
- * private CacheStoreSession ses;
- *
- * @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> 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.attach(null);
-
- if (hibSes != null) {
- try {
- Transaction tx = hibSes.getTransaction();
-
- if (commit) {
- if (hibSes.isDirty())
- 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();
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
deleted file mode 100644
index 891d99a..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +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 description. -->
- * Contains reference Hibernate-based cache store implementation.
- */
-package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/config/factory-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/config/factory-cache.xml b/modules/hibernate5/src/test/config/factory-cache.xml
deleted file mode 100644
index a251846..0000000
--- a/modules/hibernate5/src/test/config/factory-cache.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="simpleSessionFactory"
- class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactoryExt"/>
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/config/factory-cache1.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/config/factory-cache1.xml b/modules/hibernate5/src/test/config/factory-cache1.xml
deleted file mode 100644
index 7a53b1f..0000000
--- a/modules/hibernate5/src/test/config/factory-cache1.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="simpleSessionFactory1"
- class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactory"/>
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="igniteInstanceName" value="ignite1"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/config/factory-incorrect-store-cache.xml b/modules/hibernate5/src/test/config/factory-incorrect-store-cache.xml
deleted file mode 100644
index 459930c..0000000
--- a/modules/hibernate5/src/test/config/factory-incorrect-store-cache.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
deleted file mode 100644
index 0cb36e9..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
+++ /dev/null
@@ -1,409 +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.hibernate;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import javax.cache.Cache;
-import javax.persistence.Cacheable;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_ACCESS_TYPE_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_CACHE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.IGNITE_INSTANCE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.REGION_CACHE_PROPERTY;
-import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
-import static org.hibernate.cfg.AvailableSettings.GENERATE_STATISTICS;
-import static org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO;
-import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
-import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
-import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
-
-/**
- * Tests Hibernate L2 cache configuration.
- */
-public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest {
- /** */
- public static final String ENTITY1_NAME = Entity1.class.getName();
-
- /** */
- public static final String ENTITY2_NAME = Entity2.class.getName();
-
- /** */
- public static final String ENTITY3_NAME = Entity3.class.getName();
-
- /** */
- public static final String ENTITY4_NAME = Entity4.class.getName();
-
- /** */
- public static final String TIMESTAMP_CACHE = "org.hibernate.cache.spi.UpdateTimestampsCache";
-
- /** */
- public static final String QUERY_CACHE = "org.hibernate.cache.internal.StandardQueryCache";
-
- /** */
- public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
- /** If {@code true} then sets default cache in configuration. */
- private boolean dfltCache;
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrid(0);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
- cache.clear();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- cfg.setDiscoverySpi(discoSpi);
-
- cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME), cacheConfiguration(ENTITY4_NAME),
- cacheConfiguration("cache1"), cacheConfiguration("cache2"), cacheConfiguration("cache3"),
- cacheConfiguration(TIMESTAMP_CACHE), cacheConfiguration(QUERY_CACHE));
-
- return cfg;
- }
-
- /**
- * @param cacheName Cache name.
- * @return Cache configuration.
- */
- private CacheConfiguration cacheConfiguration(String cacheName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(cacheName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(ATOMIC);
-
- return cfg;
- }
- /**
- * @param igniteInstanceName Ignite instance name.
- * @return Hibernate configuration.
- */
- protected Configuration hibernateConfiguration(String igniteInstanceName) {
- Configuration cfg = new Configuration();
-
- cfg.addAnnotatedClass(Entity1.class);
- cfg.addAnnotatedClass(Entity2.class);
- cfg.addAnnotatedClass(Entity3.class);
- cfg.addAnnotatedClass(Entity4.class);
-
- cfg.setProperty(DFLT_ACCESS_TYPE_PROPERTY, AccessType.NONSTRICT_READ_WRITE.name());
-
- cfg.setProperty(HBM2DDL_AUTO, "create");
-
- cfg.setProperty(GENERATE_STATISTICS, "true");
-
- cfg.setProperty(USE_SECOND_LEVEL_CACHE, "true");
-
- cfg.setProperty(USE_QUERY_CACHE, "true");
-
- cfg.setProperty(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
-
- cfg.setProperty(RELEASE_CONNECTIONS, "on_close");
-
- cfg.setProperty(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
-
- cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
- cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
- cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
- cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
-
- if (dfltCache)
- cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
-
- return cfg;
- }
-
- /**
- * Tests property {@link HibernateRegionFactory#REGION_CACHE_PROPERTY}.
- */
- public void testPerRegionCacheProperty() {
- testCacheUsage(1, 1, 0, 1, 1);
- }
-
- /**
- * Tests property {@link HibernateRegionFactory#DFLT_CACHE_NAME_PROPERTY}.
- */
- public void testDefaultCache() {
- dfltCache = true;
-
- testCacheUsage(1, 1, 2, 0, 0);
- }
-
- /**
- * @param expCache1 Expected size of cache with name 'cache1'.
- * @param expCache2 Expected size of cache with name 'cache2'.
- * @param expCache3 Expected size of cache with name 'cache3'.
- * @param expCacheE3 Expected size of cache with name {@link #ENTITY3_NAME}.
- * @param expCacheE4 Expected size of cache with name {@link #ENTITY4_NAME}.
- */
- @SuppressWarnings("unchecked")
- private void testCacheUsage(int expCache1, int expCache2, int expCache3, int expCacheE3, int expCacheE4) {
- SessionFactory sesFactory = startHibernate(getTestIgniteInstanceName(0));
-
- try {
- Session ses = sesFactory.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity1());
- ses.save(new Entity2());
- ses.save(new Entity3());
- ses.save(new Entity4());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory.openSession();
-
- try {
- List<Entity1> list1 = ses.createCriteria(ENTITY1_NAME).list();
-
- assertEquals(1, list1.size());
-
- for (Entity1 e : list1) {
- ses.load(ENTITY1_NAME, e.getId());
- assertNotNull(e.getId());
- }
-
- List<Entity2> list2 = ses.createCriteria(ENTITY2_NAME).list();
-
- assertEquals(1, list2.size());
-
- for (Entity2 e : list2)
- assertNotNull(e.getId());
-
- List<Entity3> list3 = ses.createCriteria(ENTITY3_NAME).list();
-
- assertEquals(1, list3.size());
-
- for (Entity3 e : list3)
- assertNotNull(e.getId());
-
- List<Entity4> list4 = ses.createCriteria(ENTITY4_NAME).list();
-
- assertEquals(1, list4.size());
-
- for (Entity4 e : list4)
- assertNotNull(e.getId());
- }
- finally {
- ses.close();
- }
-
- IgniteCache<Object, Object> cache1 = grid(0).cache("cache1");
- IgniteCache<Object, Object> cache2 = grid(0).cache("cache2");
- IgniteCache<Object, Object> cache3 = grid(0).cache("cache3");
- IgniteCache<Object, Object> cacheE3 = grid(0).cache(ENTITY3_NAME);
- IgniteCache<Object, Object> cacheE4 = grid(0).cache(ENTITY4_NAME);
-
- assertEquals("Unexpected entries: " + toSet(cache1.iterator()), expCache1, cache1.size());
- assertEquals("Unexpected entries: " + toSet(cache2.iterator()), expCache2, cache2.size());
- assertEquals("Unexpected entries: " + toSet(cache3.iterator()), expCache3, cache3.size());
- assertEquals("Unexpected entries: " + toSet(cacheE3.iterator()), expCacheE3, cacheE3.size());
- assertEquals("Unexpected entries: " + toSet(cacheE4.iterator()), expCacheE4, cacheE4.size());
- }
- finally {
- sesFactory.close();
- }
- }
-
- /**
- *
- */
- private <K, V> Set<Cache.Entry<K, V>> toSet(Iterator<Cache.Entry<K, V>> iter){
- Set<Cache.Entry<K, V>> set = new HashSet<>();
-
- while (iter.hasNext())
- set.add(iter.next());
-
- return set;
- }
-
- /**
- * @param igniteInstanceName Name of the grid providing caches.
- * @return Session factory.
- */
- private SessionFactory startHibernate(String igniteInstanceName) {
- Configuration cfg = hibernateConfiguration(igniteInstanceName);
-
- StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
-
- builder.applySetting("hibernate.connection.url", CONNECTION_URL);
- builder.applySetting("hibernate.show_sql", false);
- builder.applySettings(cfg.getProperties());
-
- return cfg.buildSessionFactory(builder.build());
- }
-
- /**
- * Test Hibernate entity1.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity1 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity2.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity2 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity3.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity3 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity4.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity4 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-}
\ No newline at end of file
[14/50] [abbrv] ignite git commit: ignite-2.0 Update
classnames.properties to run code from IDE.
Posted by vo...@apache.org.
ignite-2.0 Update classnames.properties to run code from IDE.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/234bb5ad
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/234bb5ad
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/234bb5ad
Branch: refs/heads/master
Commit: 234bb5ad851d61b5f5236772a36724210dc8f445
Parents: e4a926b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 14:03:20 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 14:03:20 2017 +0700
----------------------------------------------------------------------
.../resources/META-INF/classnames.properties | 47 +++++++++++++++++---
.../resources/META-INF/classnames.properties | 1 +
2 files changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/234bb5ad/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index e45f84a..2cc83a4 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -178,6 +178,7 @@ org.apache.ignite.igfs.mapreduce.records.IgfsByteDelimiterRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsFixedLengthRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsNewLineRecordResolver
org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver
+org.apache.ignite.internal.ExecutorAwareMessage
org.apache.ignite.internal.GridClosureCallMode
org.apache.ignite.internal.GridComponent$DiscoveryDataExchangeType
org.apache.ignite.internal.GridEventConsumeHandler
@@ -322,7 +323,7 @@ org.apache.ignite.internal.managers.indexing.GridIndexingManager$1
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerAdapter
org.apache.ignite.internal.managers.loadbalancer.GridLoadBalancerManager$1
org.apache.ignite.internal.marshaller.optimized.OptimizedFieldType
-org.apache.ignite.internal.mem.OutOfMemoryException
+org.apache.ignite.internal.mem.IgniteOutOfMemoryException
org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl$Segment
org.apache.ignite.internal.pagemem.snapshot.SnapshotFinishedMessage
org.apache.ignite.internal.pagemem.snapshot.SnapshotProgressMessage
@@ -500,7 +501,6 @@ org.apache.ignite.internal.processors.cache.GridCacheProcessor$9
org.apache.ignite.internal.processors.cache.GridCacheProcessor$LocalAffinityFunction
org.apache.ignite.internal.processors.cache.GridCacheProxyImpl
org.apache.ignite.internal.processors.cache.GridCacheReturn
-org.apache.ignite.internal.processors.cache.GridCacheTryPutFailedException
org.apache.ignite.internal.processors.cache.GridCacheTtlManager$1
org.apache.ignite.internal.processors.cache.GridCacheTtlManager$GridConcurrentSkipListSetEx
org.apache.ignite.internal.processors.cache.GridCacheUpdateAtomicResult$UpdateOutcome
@@ -515,8 +515,12 @@ org.apache.ignite.internal.processors.cache.GridCacheUtils$15
org.apache.ignite.internal.processors.cache.GridCacheUtils$16
org.apache.ignite.internal.processors.cache.GridCacheUtils$17
org.apache.ignite.internal.processors.cache.GridCacheUtils$18
+org.apache.ignite.internal.processors.cache.GridCacheUtils$19
org.apache.ignite.internal.processors.cache.GridCacheUtils$2
org.apache.ignite.internal.processors.cache.GridCacheUtils$20
+org.apache.ignite.internal.processors.cache.GridCacheUtils$21
+org.apache.ignite.internal.processors.cache.GridCacheUtils$22
+org.apache.ignite.internal.processors.cache.GridCacheUtils$24
org.apache.ignite.internal.processors.cache.GridCacheUtils$3
org.apache.ignite.internal.processors.cache.GridCacheUtils$4
org.apache.ignite.internal.processors.cache.GridCacheUtils$5
@@ -915,6 +919,7 @@ org.apache.ignite.internal.processors.cache.query.jdbc.GridCacheQueryJdbcValidat
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$1
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$2
org.apache.ignite.internal.processors.cache.store.GridCacheStoreManagerAdapter$3
+org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$BatchingResult
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StatefulValue
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$StoreOperation
org.apache.ignite.internal.processors.cache.store.GridCacheWriteBehindStore$ValueStatus
@@ -1047,9 +1052,9 @@ org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$19
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$2
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$20
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$21
+org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$22
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$23
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$24
-org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$25
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$3
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$4
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$5
@@ -1069,13 +1074,25 @@ org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$Dat
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$QueueInfo
org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor$RemoveDataStructureProcessor
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$AddAndGetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$CompareAndSetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$DecrementAndGetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndAddProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndDecrementProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndIncrementProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$GetAndSetProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongImpl$IncrementAndGetProcessor
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceCompareAndSetAndGetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceCompareAndSetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl$ReferenceSetEntryProcessor
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceValue
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicSequenceImpl
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicSequenceValue
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl
-org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$5
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$StampedCompareAndSetEntryProcessor
+org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedImpl$StampedSetEntryProcessor
org.apache.ignite.internal.processors.datastructures.GridCacheAtomicStampedValue
org.apache.ignite.internal.processors.datastructures.GridCacheCountDownLatchImpl
org.apache.ignite.internal.processors.datastructures.GridCacheCountDownLatchValue
@@ -1152,6 +1169,7 @@ org.apache.ignite.internal.processors.igfs.IgfsListingEntry
org.apache.ignite.internal.processors.igfs.IgfsMetaManager$2
org.apache.ignite.internal.processors.igfs.IgfsMetaManager$3
org.apache.ignite.internal.processors.igfs.IgfsMetricsAdapter
+org.apache.ignite.internal.processors.igfs.IgfsModeResolver
org.apache.ignite.internal.processors.igfs.IgfsNodePredicate
org.apache.ignite.internal.processors.igfs.IgfsProcessor$1
org.apache.ignite.internal.processors.igfs.IgfsSamplingKey
@@ -1275,17 +1293,31 @@ org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils$Interna
org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionLockProcessor
org.apache.ignite.internal.processors.platform.websession.PlatformDotNetSessionSetAndUnlockProcessor
org.apache.ignite.internal.processors.query.GridQueryFieldMetadata
-org.apache.ignite.internal.processors.query.GridQueryProcessor$3
org.apache.ignite.internal.processors.query.GridQueryProcessor$4
org.apache.ignite.internal.processors.query.GridQueryProcessor$5
org.apache.ignite.internal.processors.query.GridQueryProcessor$6
org.apache.ignite.internal.processors.query.GridQueryProcessor$7
org.apache.ignite.internal.processors.query.GridQueryProcessor$8
+org.apache.ignite.internal.processors.query.GridQueryProcessor$9
+org.apache.ignite.internal.processors.query.GridQueryProcessor$SchemaOperation$1
org.apache.ignite.internal.processors.query.IgniteSQLException
+org.apache.ignite.internal.processors.query.QueryIndexKey
+org.apache.ignite.internal.processors.query.QuerySchema
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest
org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse
+org.apache.ignite.internal.processors.query.schema.SchemaOperationException
+org.apache.ignite.internal.processors.query.schema.SchemaOperationManager$1
+org.apache.ignite.internal.processors.query.schema.SchemaOperationWorker$1
+org.apache.ignite.internal.processors.query.schema.message.SchemaAbstractDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaOperationStatusMessage
+org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage
+org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexAbstractOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation
+org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexDropOperation
org.apache.ignite.internal.processors.resource.GridResourceIoc$AnnotationSet
org.apache.ignite.internal.processors.resource.GridResourceIoc$ResourceAnnotation
org.apache.ignite.internal.processors.rest.GridRestCommand
@@ -1696,6 +1728,7 @@ org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask
org.apache.ignite.internal.visor.cache.VisorCacheResetMetricsTask$VisorCacheResetMetricsJob
org.apache.ignite.internal.visor.cache.VisorCacheSqlIndexMetadata
org.apache.ignite.internal.visor.cache.VisorCacheSqlMetadata
+org.apache.ignite.internal.visor.cache.VisorCacheStartArg
org.apache.ignite.internal.visor.cache.VisorCacheStartTask
org.apache.ignite.internal.visor.cache.VisorCacheStartTask$VisorCacheStartJob
org.apache.ignite.internal.visor.cache.VisorCacheStartTaskArg
@@ -1726,6 +1759,7 @@ org.apache.ignite.internal.visor.event.VisorGridEventsLost
org.apache.ignite.internal.visor.event.VisorGridJobEvent
org.apache.ignite.internal.visor.event.VisorGridTaskEvent
org.apache.ignite.internal.visor.file.VisorFileBlock
+org.apache.ignite.internal.visor.file.VisorFileBlockArg
org.apache.ignite.internal.visor.file.VisorFileBlockTask
org.apache.ignite.internal.visor.file.VisorFileBlockTask$VisorFileBlockJob
org.apache.ignite.internal.visor.file.VisorFileBlockTaskArg
@@ -1750,6 +1784,7 @@ org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask
org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTask$VisorIgfsSamplingStateJob
org.apache.ignite.internal.visor.igfs.VisorIgfsSamplingStateTaskArg
org.apache.ignite.internal.visor.log.VisorLogFile
+org.apache.ignite.internal.visor.log.VisorLogSearchArg
org.apache.ignite.internal.visor.log.VisorLogSearchResult
org.apache.ignite.internal.visor.log.VisorLogSearchTask
org.apache.ignite.internal.visor.log.VisorLogSearchTask$VisorLogSearchJob
@@ -1805,6 +1840,7 @@ org.apache.ignite.internal.visor.node.VisorSpiDescription
org.apache.ignite.internal.visor.node.VisorSpisConfiguration
org.apache.ignite.internal.visor.node.VisorSuppressedError
org.apache.ignite.internal.visor.node.VisorTransactionConfiguration
+org.apache.ignite.internal.visor.query.VisorQueryArg
org.apache.ignite.internal.visor.query.VisorQueryCancelTask
org.apache.ignite.internal.visor.query.VisorQueryCancelTask$VisorCancelQueriesJob
org.apache.ignite.internal.visor.query.VisorQueryCleanupTask
@@ -1833,6 +1869,7 @@ org.apache.ignite.internal.visor.query.VisorQueryTaskArg
org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask
org.apache.ignite.internal.visor.query.VisorRunningQueriesCollectorTask$VisorCollectRunningQueriesJob
org.apache.ignite.internal.visor.query.VisorRunningQuery
+org.apache.ignite.internal.visor.query.VisorScanQueryArg
org.apache.ignite.internal.visor.query.VisorScanQueryTask
org.apache.ignite.internal.visor.query.VisorScanQueryTask$VisorScanQueryJob
org.apache.ignite.internal.visor.query.VisorScanQueryTaskArg
http://git-wip-us.apache.org/repos/asf/ignite/blob/234bb5ad/modules/hadoop/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/resources/META-INF/classnames.properties b/modules/hadoop/src/main/resources/META-INF/classnames.properties
index 051094d..a83b9ff 100644
--- a/modules/hadoop/src/main/resources/META-INF/classnames.properties
+++ b/modules/hadoop/src/main/resources/META-INF/classnames.properties
@@ -43,6 +43,7 @@ org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$13
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$14
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$15
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$16
+org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$17
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$2
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$3
org.apache.ignite.internal.processors.hadoop.impl.igfs.HadoopIgfsInProc$4
[22/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/ignite-2.0' into ignite-2.0
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/712398e1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/712398e1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/712398e1
Branch: refs/heads/master
Commit: 712398e1254867f38556c941094edb23c9b346ae
Parents: 860049d 4e4a22d
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 12:14:48 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 12:14:48 2017 +0300
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 57 ++--
.../configuration/MemoryConfiguration.java | 12 +-
.../MemoryPolicyConfiguration.java | 6 +-
.../IgniteCacheDatabaseSharedManager.java | 130 ++++----
.../cache/MemoryPolicyConfigValidationTest.java | 6 +-
.../MemoryPolicyInitializationTest.java | 307 +++++++++++++++++++
.../testsuites/IgniteCacheTestSuite2.java | 2 +
.../Cache/Configuration/MemoryConfiguration.cs | 7 +
.../Configuration/MemoryPolicyConfiguration.cs | 3 +
.../frontend/app/data/event-groups.json | 14 -
.../frontend/app/modules/cluster/Cache.js | 4 -
.../app/modules/cluster/CacheMetrics.js | 4 -
modules/web-console/web-agent/pom.xml | 2 +-
.../ignite/console/agent/AgentLauncher.java | 10 +-
14 files changed, 446 insertions(+), 118 deletions(-)
----------------------------------------------------------------------
[17/50] [abbrv] ignite git commit: IGNITE-5069: Fixed failure in
QueryWords example.
Posted by vo...@apache.org.
IGNITE-5069: Fixed failure in QueryWords example.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4739458c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4739458c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4739458c
Branch: refs/heads/master
Commit: 4739458cd23b28e435ec91608a747c612a767477
Parents: 645581e
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:21:49 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:21:49 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/examples/streaming/wordcount/QueryWords.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4739458c/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index c1ce6e1..54aa97f 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -75,7 +75,7 @@ public class QueryWords {
List<?> row = stats.get(0);
if (row.get(0) != null)
- System.out.printf("Query results [avg=%.2f, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
+ System.out.printf("Query results [avg=%d, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
// Print top 10 words.
ExamplesUtils.printQueryResults(top10);
[02/50] [abbrv] ignite git commit: IGNITE-5018 review and improve
javadocs in ML module
Posted by vo...@apache.org.
IGNITE-5018 review and improve javadocs in ML module
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/33079fc9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/33079fc9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/33079fc9
Branch: refs/heads/master
Commit: 33079fc9c6fb6970ff24e88466e5edbf41ff1a28
Parents: 1968e4f
Author: Oleg Ignatenko <oi...@gridgain.com>
Authored: Mon Apr 24 13:18:40 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Apr 24 13:18:40 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/ml/math/Algebra.java | 89 +++++++++-------
.../ignite/ml/math/IdentityValueMapper.java | 3 +-
.../java/org/apache/ignite/ml/math/Matrix.java | 33 +++---
.../org/apache/ignite/ml/math/MurmurHash.java | 16 +--
.../java/org/apache/ignite/ml/math/Tracer.java | 4 +-
.../java/org/apache/ignite/ml/math/Vector.java | 3 +-
.../decompositions/CholeskyDecomposition.java | 8 +-
.../math/decompositions/EigenDecomposition.java | 4 +-
.../ml/math/decompositions/LUDecomposition.java | 8 +-
.../ignite/ml/math/functions/Functions.java | 21 +++-
.../ml/math/impls/matrix/PivotedMatrixView.java | 3 +-
.../impls/matrix/SparseDistributedMatrix.java | 12 +--
.../storage/matrix/CacheMatrixStorage.java | 16 ++-
.../matrix/DenseOffHeapMatrixStorage.java | 15 ++-
.../storage/matrix/FunctionMatrixStorage.java | 17 +--
.../matrix/SparseLocalOnHeapMatrixStorage.java | 20 ++--
.../storage/vector/CacheVectorStorage.java | 13 +--
.../storage/vector/ConstantVectorStorage.java | 10 +-
.../storage/vector/DelegateVectorStorage.java | 1 +
.../storage/vector/FunctionVectorStorage.java | 17 +--
.../storage/vector/MatrixVectorStorage.java | 19 ++--
.../storage/vector/PivotedVectorStorage.java | 16 +--
.../SingleElementVectorDelegateStorage.java | 13 +--
.../vector/SingleElementVectorStorage.java | 11 +-
.../vector/SparseLocalOffHeapVectorStorage.java | 3 +
.../vector/SparseLocalOnHeapVectorStorage.java | 11 +-
.../ml/math/impls/vector/AbstractVector.java | 1 +
.../ml/math/impls/vector/DelegatingVector.java | 1 +
.../ml/math/impls/vector/MatrixVectorView.java | 20 ++--
.../ml/math/impls/vector/PivotedVectorView.java | 14 +--
.../ml/math/impls/vector/RandomVector.java | 4 +-
.../math/impls/vector/SingleElementVector.java | 103 +------------------
.../org/apache/ignite/ml/math/TracerTest.java | 12 ++-
.../ml/math/impls/matrix/CacheMatrixTest.java | 10 +-
.../impls/matrix/MatrixKeyMapperForTests.java | 19 ++--
.../storage/matrix/MatrixStorageFixtures.java | 19 ++--
.../SparseLocalOffHeapVectorStorageTest.java | 3 +-
.../math/impls/vector/AbstractVectorTest.java | 42 ++++----
.../ml/math/impls/vector/CacheVectorTest.java | 5 +-
39 files changed, 331 insertions(+), 308 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
index b13d9fc..c54e390 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Algebra.java
@@ -31,7 +31,8 @@ package org.apache.ignite.ml.math;
* Lifted from Apache Mahout.
*/
public class Algebra extends Constants {
- /** */ private static final double[] STIRLING_CORRECTION = {
+ /** */
+ private static final double[] STIRLING_CORRECTION = {
0.0,
8.106146679532726e-02, 4.134069595540929e-02,
2.767792568499834e-02, 2.079067210376509e-02,
@@ -50,7 +51,8 @@ public class Algebra extends Constants {
2.873449362352470e-03, 2.777674929752690e-03,
};
- /** */ private static final double[] LOG_FACTORIALS = {
+ /** */
+ private static final double[] LOG_FACTORIALS = {
0.00000000000000000, 0.00000000000000000, 0.69314718055994531,
1.79175946922805500, 3.17805383034794562, 4.78749174278204599,
6.57925121201010100, 8.52516136106541430, 10.60460290274525023,
@@ -63,7 +65,8 @@ public class Algebra extends Constants {
64.55753862700633106, 67.88974313718153498, 71.25703896716800901
};
- /** */ private static final long[] LONG_FACTORIALS = {
+ /** */
+ private static final long[] LONG_FACTORIALS = {
1L,
1L,
2L,
@@ -87,7 +90,8 @@ public class Algebra extends Constants {
2432902008176640000L
};
- /** */ private static final double[] DOUBLE_FACTORIALS = {
+ /** */
+ private static final double[] DOUBLE_FACTORIALS = {
5.109094217170944E19,
1.1240007277776077E21,
2.585201673888498E22,
@@ -337,19 +341,27 @@ public class Algebra extends Constants {
/**
* Evaluates the series of Chebyshev polynomials Ti at argument x/2. The series is given by
- * <pre>
- * N-1
- * - '
- * y = > coef[i] T (x/2)
- * - i
- * i=0
+ * <pre class="snippet">
+ * N-1
+ * - '
+ * y = > coef[i] T (x/2)
+ * - i
+ * i=0
* </pre>
* Coefficients are stored in reverse order, i.e. the zero order term is last in the array. Note N is the number of
- * coefficients, not the order. <p> If coefficients are for the interval a to b, x must have been transformed to x
+ * coefficients, not the order.
+ * <p>
+ * If coefficients are for the interval a to b, x must have been transformed to x
* -< 2(2x - b - a)/(b-a) before entering the routine. This maps x from (a, b) to (-1, 1), over which the
- * Chebyshev polynomials are defined. <p> If the coefficients are for the inverted interval, in which (a, b) is
+ * Chebyshev polynomials are defined.</p>
+ * <p>
+ * If the coefficients are for the inverted interval, in which (a, b) is
* mapped to (1/b, 1/a), the transformation required is {@code x -> 2(2ab/x - b - a)/(b-a)}. If b is infinity, this
- * becomes {@code x -> 4a/x - 1}. <p> SPEED: <p> Taking advantage of the recurrence properties of the Chebyshev
+ * becomes {@code x -> 4a/x - 1}.</p>
+ * <p>
+ * SPEED:
+ * </p>
+ * Taking advantage of the recurrence properties of the Chebyshev
* polynomials, the routine requires one more addition per loop than evaluating a nested polynomial of the same
* degree.
*
@@ -466,11 +478,11 @@ public class Algebra extends Constants {
/**
* Returns the StirlingCorrection.
- *
+ * <p>
* Correction term of the Stirling approximation for {@code log(k!)} (series in
- * 1/k, or table values for small k) with int parameter k. </p> {@code log k! = (k + 1/2)log(k + 1) - (k + 1) +
+ * 1/k, or table values for small k) with int parameter k. {@code log k! = (k + 1/2)log(k + 1) - (k + 1) +
* (1/2)log(2Pi) + STIRLING_CORRECTION(k + 1) log k! = (k + 1/2)log(k) - k + (1/2)log(2Pi) +
- * STIRLING_CORRECTION(k) }
+ * STIRLING_CORRECTION(k) } </p>
*/
public static double stirlingCorrection(int k) {
if (k > 30) {
@@ -490,21 +502,24 @@ public class Algebra extends Constants {
/**
* Evaluates the given polynomial of degree {@code N} at {@code x}, assuming coefficient of N is 1.0. Otherwise same
* as {@link #evalPoly(double, double[], int)}.
- * <pre>
- * 2 N
+ * <pre class="snippet">
+ * 2 N
* y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * where C = 1 and hence is omitted from the array.
- * N
- *
- * Coefficients are stored in reverse order:
- *
+ * 0 1 2 N
+ * </pre>
+ * where <pre class="snippet">
+ * C = 1
+ * N
+ * </pre>
+ * and hence is omitted from the array.
+ * <p>
+ * Coefficients are stored in reverse order:</p>
+ * <pre class="snippet">
* coef[0] = C , ..., coef[N-1] = C .
- * N-1 0
- *
- * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+ * N-1 0
* </pre>
+ * Calling arguments are otherwise the same as {@link #evalPoly(double, double[], int)}.
+ * <p>
* In the interest of speed, there are no checks for out of bounds arithmetic.
*
* @param x Argument to the polynomial.
@@ -522,17 +537,19 @@ public class Algebra extends Constants {
/**
* Evaluates the given polynomial of degree {@code N} at {@code x}.
- * <pre>
- * 2 N
+ * <pre class="snippet">
+ * 2 N
* y = C + C x + C x +...+ C x
- * 0 1 2 N
- *
- * Coefficients are stored in reverse order:
- *
+ * 0 1 2 N
+ * </pre>
+ * <p>
+ * Coefficients are stored in reverse order:</p>
+ * <pre class="snippet">
* coef[0] = C , ..., coef[N] = C .
- * N 0
+ * N 0
* </pre>
- * In the interest of speed, there are no checks for out of bounds arithmetic.
+ * <p>
+ * In the interest of speed, there are no checks for out of bounds arithmetic.</p>
*
* @param x Argument to the polynomial.
* @param coef Coefficients of the polynomial.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
index 00bf915..3c94edd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/IdentityValueMapper.java
@@ -21,7 +21,8 @@ package org.apache.ignite.ml.math;
* Identity value mapper.
*/
public class IdentityValueMapper implements ValueMapper<Double> {
- /** */ private static final long serialVersionUID = -8010078306142216389L;
+ /** */
+ private static final long serialVersionUID = -8010078306142216389L;
/** {@inheritDoc} */
@Override public Double fromDouble(double v) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index cc858b7..798d831 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,6 +18,7 @@
package org.apache.ignite.ml.math;
import java.io.Externalizable;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.exceptions.CardinalityException;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,17 +30,17 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
/**
* A matrix interface.
- *
+ * <p>
* Based on its flavor it can have vastly different implementations tailored for
* for different types of data (e.g. dense vs. sparse), different sizes of data or different operation
- * optimizations.
- *
+ * optimizations.</p>
+ * <p>
* Note also that not all operations can be supported by all underlying implementations. If an operation is not
* supported a {@link UnsupportedOperationException} is thrown. This exception can also be thrown in partial cases
* where an operation is unsupported only in special cases, e.g. where a given operation cannot be deterministically
- * completed in polynomial time.
- *
- * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.
+ * completed in polynomial time.</p>
+ * <p>
+ * Based on ideas from <a href="http://mahout.apache.org/">Apache Mahout</a>.</p>
*/
public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetrics, Destroyable {
/**
@@ -174,10 +175,10 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Maps all values in this matrix through a given function.
- *
- * For this matrix <code>A</code>, argument matrix <code>B</code> and the
- * function <code>F</code> this method maps every cell <code>x, y</code> as:
- * <code>A(x,y) = fun(A(x,y), B(x,y))</code>
+ * <p>
+ * For this matrix {@code A}, argument matrix {@code B} and the
+ * function {@code F} this method maps every cell {@code x, y} as:
+ * {@code A(x,y) = fun(A(x,y), B(x,y))}.</p>
*
* @param mtx Argument matrix.
* @param fun Mapping function.
@@ -306,8 +307,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Clones this matrix.
- *
- * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+ * <p>
+ * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
*
* @return New matrix of the same underlying class, the same size and the same values.
*/
@@ -315,8 +316,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Creates new empty matrix of the same underlying class but of different size.
- *
- * NOTE: new matrix will have the same flavor as the this matrix but a different ID.
+ * <p>
+ * NOTE: new matrix will have the same flavor as the this matrix but a different ID.</p>
*
* @param rows Number of rows for new matrix.
* @param cols Number of columns for new matrix.
@@ -463,8 +464,8 @@ public interface Matrix extends MetaAttributes, Externalizable, StorageOpsMetric
/**
* Creates new view into this matrix. Changes to the view will be propagated to this matrix.
*
- * @param off View offset as <code>int[x,y]</code>.
- * @param size View size as <code>int[rows, cols]</code>
+ * @param off View offset as {@code int[x,y]}.
+ * @param size View size as {@code int[rows, cols]}.
* @return New view.
* @throws CardinalityException Thrown if cardinalities mismatch.
* @throws IndexException Thrown in case of offset is out of bound.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
index c7dd36b..d1ebf53 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/MurmurHash.java
@@ -22,8 +22,8 @@ import java.nio.ByteOrder;
/**
* This is a very fast, non-cryptographic hash suitable for general hash-based lookup.
- *
- * See http://murmurhash.googlepages.com/ for mre details.
+ * <p>
+ * See http://murmurhash.googlepages.com/ for mre details.</p>
*/
public class MurmurHash {
/** Hide it. */
@@ -33,13 +33,13 @@ public class MurmurHash {
/**
* This produces exactly the same hash values as the final C+ version of MurmurHash3 and is
* thus suitable for producing the same hash values across platforms.
- *
- * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.
- *
+ * <p>
+ * The 32 bit x86 version of this hash should be the fastest variant for relatively short keys like IDs.</p>
+ * <p>
* Note - The x86 and x64 versions do _not_ produce the same results, as the algorithms are
- * optimized for their respective platforms.
- *
- * See also http://github.com/yonik/java_util for future updates to this method.
+ * optimized for their respective platforms.</p>
+ * <p>
+ * See also http://github.com/yonik/java_util for future updates to this method.</p>
*
* @param data Data to hash.
* @param off Where to start munging.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
index 007a8fe..07cc63c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Tracer.java
@@ -71,8 +71,10 @@ public class Tracer {
return defaultColorMapper(vec.minValue(), vec.maxValue());
}
- /** Default matrix color mapper implementation that map given double value
+ /**
+ * Default matrix color mapper implementation that map given double value
* to continuous red-blue (R_B) specter.
+ *
* @param mtx Matrix to be mapped.
* @return Color mapper for given matrix.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
index b5e1d69..e1c5df0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Vector.java
@@ -470,7 +470,8 @@ public interface Vector extends MetaAttributes, Externalizable, StorageOpsMetric
* @return Folded value of these vectors.
* @throws CardinalityException Thrown when cardinalities mismatch.
*/
- public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun, IgniteBiFunction<Double, Double, Double> combFun,
+ public <T> T foldMap(Vector vec, IgniteBiFunction<T, Double, T> foldFun,
+ IgniteBiFunction<Double, Double, Double> combFun,
T zeroVal);
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
index 59ebbe0..6053e1c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/CholeskyDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.NonSymmetricMatrixException;
/**
* Calculates the Cholesky decomposition of a matrix.
- *
- * This class inspired by class from Apache Common Math with similar name.
+ * <p>
+ * This class inspired by class from Apache Common Math with similar name.</p>
*
* @see <a href="http://mathworld.wolfram.com/CholeskyDecomposition.html">MathWorld</a>
* @see <a href="http://en.wikipedia.org/wiki/Cholesky_decomposition">Wikipedia</a>
@@ -55,10 +55,10 @@ public class CholeskyDecomposition extends DecompositionSupport {
/**
* Calculates the Cholesky decomposition of the given matrix.
- *
+ * <p>
* Calling this constructor is equivalent to call {@link #CholeskyDecomposition(Matrix, double, double)} with the
* thresholds set to the default values {@link #DFLT_REL_SYMMETRY_THRESHOLD} and
- * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.
+ * {@link #DFLT_ABS_POSITIVITY_THRESHOLD}.</p>
*
* @param mtx the matrix to decompose.
* @throws CardinalityException if matrix is not square.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
index 0353bff..698cbef 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/EigenDecomposition.java
@@ -24,8 +24,8 @@ import org.apache.ignite.ml.math.functions.Functions;
/**
* This class provides EigenDecomposition of given matrix. The class is based on
* class with similar name from <a href="http://mahout.apache.org/">Apache Mahout</a> library.
- * <p>
- * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a></p>
+ *
+ * @see <a href=http://mathworld.wolfram.com/EigenDecomposition.html>MathWorld</a>
*/
public class EigenDecomposition extends DecompositionSupport {
/** Row and column dimension (square matrix). */
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
index 4e9730c..02a3123 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/decompositions/LUDecomposition.java
@@ -25,8 +25,8 @@ import org.apache.ignite.ml.math.exceptions.SingularMatrixException;
/**
* Calculates the LU-decomposition of a square matrix.
* <p>
- * This class is inspired by class from Apache Common Math with similar name.
- * </p>
+ * This class is inspired by class from Apache Common Math with similar name.</p>
+ *
* @see <a href="http://mathworld.wolfram.com/LUDecomposition.html">MathWorld</a>
* @see <a href="http://en.wikipedia.org/wiki/LU_decomposition">Wikipedia</a>
*/
@@ -36,18 +36,22 @@ public class LUDecomposition extends DecompositionSupport {
/** Pivot permutation associated with LU decomposition. */
private final Vector pivot;
+
/** Parity of the permutation associated with the LU decomposition. */
private boolean even;
/** Singularity indicator. */
private boolean singular;
+
/** Cached value of L. */
private Matrix cachedL;
/** Cached value of U. */
private Matrix cachedU;
/** Cached value of P. */
private Matrix cachedP;
+
/** Original matrix. */
private Matrix matrix;
+
/** Entries of LU decomposition. */
private Matrix lu;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
index 2693fce..2f97067 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/functions/Functions.java
@@ -78,15 +78,14 @@ public final class Functions {
/** Function that returns {@code (a - b) * (a - b)} */
public static final IgniteBiFunction<Double, Double, Double> MINUS_SQUARED = (a, b) -> (a - b) * (a - b);
- /**
- * Function that returns {@code a < b ? -1 : a > b ? 1 : 0}.
- */
+ /** Function that returns {@code a < b ? -1 : a > b ? 1 : 0}. */
public static final IgniteBiFunction<Double, Double, Double> COMPARE = (a, b) -> a < b ? -1.0 : a > b ? 1.0 : 0.0;
/**
* Function that returns {@code a + b}. {@code a} is a variable, {@code b} is fixed.
*
* @param b Value to add.
+ * @return Function for this operation.
*/
public static IgniteDoubleFunction<Double> plus(final double b) {
return (a) -> a + b;
@@ -96,12 +95,18 @@ public final class Functions {
* Function that returns {@code a * b}. {@code a} is a variable, {@code b} is fixed.
*
* @param b Value to multiply to.
+ * @return Function for this operation.
*/
public static IgniteDoubleFunction<Double> mult(final double b) {
return (a) -> a * b;
}
- /** Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed. */
+ /**
+ * Function that returns {@code a / b}. {@code a} is a variable, {@code b} is fixed.
+ *
+ * @param b Value to divide to.
+ * @return Function for this operation.
+ */
public static IgniteDoubleFunction<Double> div(double b) {
return mult(1 / b);
}
@@ -109,6 +114,9 @@ public final class Functions {
/**
* Function that returns {@code a + b*constant}. {@code a} and {@code b} are variables,
* {@code constant} is fixed.
+ *
+ * @param constant Value to use in multiply.
+ * @return Function for this operation.
*/
public static IgniteBiFunction<Double, Double, Double> plusMult(double constant) {
return (a, b) -> a + b * constant;
@@ -117,12 +125,17 @@ public final class Functions {
/**
* Function that returns {@code a - b*constant}. {@code a} and {@code b} are variables,
* {@code constant} is fixed.
+ *
+ * @param constant Value to use in multiply.
+ * @return Function for this operation.
*/
public static IgniteBiFunction<Double, Double, Double> minusMult(double constant) {
return (a, b) -> a - b * constant;
}
/**
+ * Function that returns {@code Math.pow(a, b)}.
+ *
* @param b Power value.
* @return Function for given power.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
index 334291e..16bdc3e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.Vector;
@@ -63,7 +64,7 @@ public class PivotedMatrixView extends AbstractMatrix {
}
/**
- * @param mtx Parent matrix.
+ * @param mtx Parent matrix.
* @param pivot Pivot array for rows and columns.
*/
public PivotedMatrixView(Matrix mtx, int[] pivot) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
index cd75b83..10ebdd0 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/SparseDistributedMatrix.java
@@ -37,14 +37,14 @@ import org.apache.ignite.ml.math.impls.storage.matrix.SparseDistributedMatrixSto
/**
* Sparse distributed matrix implementation based on data grid.
- *
+ * <p>
* Unlike {@link CacheMatrix} that is based on existing cache, this implementation creates distributed
- * cache internally and doesn't rely on pre-existing cache.
- *
+ * cache internally and doesn't rely on pre-existing cache.</p>
+ * <p>
* You also need to call {@link #destroy()} to remove the underlying cache when you no longer need this
- * matrix.
- *
- * <b>Currently fold supports only commutative operations.<b/>
+ * matrix.</p>
+ * <p>
+ * <b>Currently fold supports only commutative operations.<b/></p>
*/
public class SparseDistributedMatrix extends AbstractMatrix implements StorageConstants {
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
index 1eec6f5..687216b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.MatrixKeyMapper;
@@ -30,11 +31,16 @@ import org.apache.ignite.ml.math.ValueMapper;
* Matrix storage based on arbitrary cache and key and value mapping functions.
*/
public class CacheMatrixStorage<K, V> implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
- /** */ private IgniteCache<K, V> cache;
- /** */ private MatrixKeyMapper<K> keyMapper;
- /** */ private ValueMapper<V> valMapper;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
+ /** */
+ private IgniteCache<K, V> cache;
+ /** */
+ private MatrixKeyMapper<K> keyMapper;
+ /** */
+ private ValueMapper<V> valMapper;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index c9e8de8..410da47 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.ml.math.MatrixStorage;
@@ -27,11 +28,15 @@ import org.apache.ignite.ml.math.MatrixStorage;
* Local, dense off-heap matrix storage.
*/
public class DenseOffHeapMatrixStorage implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
- /** */ private transient long ptr;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
+ /** */
+ private transient long ptr;
//TODO: temp solution.
- /** */ private int ptrInitHash;
+ /** */
+ private int ptrInitHash;
/** */
public DenseOffHeapMatrixStorage() {
@@ -152,7 +157,7 @@ public class DenseOffHeapMatrixStorage implements MatrixStorage {
GridUnsafe.freeMemory(ptr);
}
- /** {@inheritDoc} */
+ /** */
private long pointerOffset(int x, int y) {
return ptr + x * cols * Double.BYTES + y * Double.BYTES;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
index acd7c29..5bb2569 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
@@ -29,11 +30,15 @@ import org.apache.ignite.ml.math.functions.IntIntToDoubleFunction;
* Read-only or read-write function-based matrix storage.
*/
public class FunctionMatrixStorage implements MatrixStorage {
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
- /** */ private IntIntToDoubleFunction getFunc;
- /** */ private IntIntDoubleToVoidFunction setFunc;
+ /** */
+ private IntIntToDoubleFunction getFunc;
+ /** */
+ private IntIntDoubleToVoidFunction setFunc;
/**
*
@@ -83,14 +88,14 @@ public class FunctionMatrixStorage implements MatrixStorage {
}
/**
- *
+ * @return Getter function.
*/
public IntIntToDoubleFunction getFunction() {
return getFunc;
}
/**
- *
+ * @return Setter function.
*/
public IntIntDoubleToVoidFunction setFunction() {
return setFunc;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
index 4530900..db85b0f 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -19,11 +19,13 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
@@ -34,11 +36,15 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
/** Default zero value. */
private static final double DEFAULT_VALUE = 0.0;
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
- /** */ private int acsMode;
- /** */ private int stoMode;
+ /** */
+ private int acsMode;
+ /** */
+ private int stoMode;
/** Actual map storage. */
private Map<Integer, Map<Integer, Double>> sto;
@@ -64,16 +70,14 @@ public class SparseLocalOnHeapMatrixStorage implements MatrixStorage, StorageCon
}
/**
- *
- *
+ * @return Matrix elements storage mode.
*/
public int getStorageMode() {
return stoMode;
}
/**
- *
- *
+ * @return Matrix elements access mode.
*/
public int getAccessMode() {
return acsMode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
index f99a216..bec232d 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.ValueMapper;
@@ -32,10 +33,12 @@ import org.apache.ignite.ml.math.VectorStorage;
public class CacheVectorStorage<K, V> implements VectorStorage {
/** Storage size. */
private int size;
+
/** Key mapper. */
private VectorKeyMapper<K> keyMapper;
/** Value mapper. */
private ValueMapper<V> valMapper;
+
/** Underlying ignite cache. */
private IgniteCache<K, V> cache;
@@ -66,24 +69,21 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
}
/**
- *
- *
+ * @return Ignite cache.
*/
public IgniteCache<K, V> cache() {
return cache;
}
/**
- *
- *
+ * @return Key mapper to validate cache keys.
*/
public VectorKeyMapper<K> keyMapper() {
return keyMapper;
}
/**
- *
- *
+ * @return Value mapper to obtain vector element values.
*/
public ValueMapper<V> valueMapper() {
return valMapper;
@@ -113,6 +113,7 @@ public class CacheVectorStorage<K, V> implements VectorStorage {
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
size = in.readInt();
keyMapper = (VectorKeyMapper<K>)in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
index 31469ea..1b899a1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -27,8 +28,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Constant read-only vector storage.
*/
public class ConstantVectorStorage implements VectorStorage {
- /** */ private int size;
- /** */ private double val;
+ /** */
+ private int size;
+ /** */
+ private double val;
/**
*
@@ -49,8 +52,7 @@ public class ConstantVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Constant stored in Vector elements.
*/
public double constant() {
return val;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
index 6775d44..2a48653 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
index 0f13bb6..a17eb0b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IgniteFunction;
@@ -29,9 +30,12 @@ import org.apache.ignite.ml.math.functions.IntDoubleToVoidFunction;
* Read-only or read-write function-based vector storage.
*/
public class FunctionVectorStorage implements VectorStorage {
- /** */ private IgniteFunction<Integer, Double> getFunc;
- /** */ private IntDoubleToVoidFunction setFunc;
- /** */ private int size;
+ /** */
+ private IgniteFunction<Integer, Double> getFunc;
+ /** */
+ private IntDoubleToVoidFunction setFunc;
+ /** */
+ private int size;
/**
*
@@ -57,16 +61,14 @@ public class FunctionVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Getter function.
*/
public IgniteFunction<Integer, Double> getFunction() {
return getFunc;
}
/**
- *
- *
+ * @return Setter function.
*/
public IntDoubleToVoidFunction setFunction() {
return setFunc;
@@ -108,6 +110,7 @@ public class FunctionVectorStorage implements VectorStorage {
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
setFunc = (IntDoubleToVoidFunction)in.readObject();
getFunc = (IgniteFunction<Integer, Double>)in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
index 66aa049..59545a4 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -28,15 +29,21 @@ import org.apache.ignite.ml.math.exceptions.IndexException;
* Row, column or diagonal vector-based view of the matrix
*/
public class MatrixVectorStorage implements VectorStorage {
- /** */ private Matrix parent;
+ /** */
+ private Matrix parent;
- /** */ private int row;
- /** */ private int col;
+ /** */
+ private int row;
+ /** */
+ private int col;
- /** */ private int rowStride;
- /** */ private int colStride;
+ /** */
+ private int rowStride;
+ /** */
+ private int colStride;
- /** */ private int size;
+ /** */
+ private int size;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
index a524838..537d651 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -21,16 +21,20 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Arrays;
+
import org.apache.ignite.ml.math.VectorStorage;
/**
* Pivoted (index mapped) view over another vector storage implementation.
*/
public class PivotedVectorStorage implements VectorStorage {
- /** */ private VectorStorage sto;
+ /** */
+ private VectorStorage sto;
- /** */ private int[] pivot;
- /** */ private int[] unpivot;
+ /** */
+ private int[] pivot;
+ /** */
+ private int[] unpivot;
/**
* @param pivot Pivot array.
@@ -45,16 +49,14 @@ public class PivotedVectorStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Pivot array for this vector view.
*/
public int[] pivot() {
return pivot;
}
/**
- *
- *
+ * @return Unpivot array for this vector view.
*/
public int[] unpivot() {
return unpivot;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
index d472e3a..453c0f7 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -28,8 +29,10 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Single value view storage over another vector.
*/
public class SingleElementVectorDelegateStorage implements VectorStorage {
- /** */ private int idx;
- /** */ private Vector vec;
+ /** */
+ private int idx;
+ /** */
+ private Vector vec;
/**
*
@@ -51,16 +54,14 @@ public class SingleElementVectorDelegateStorage implements VectorStorage {
}
/**
- *
- *
+ * @return Index of the element in the parent vector.
*/
public int index() {
return idx;
}
/**
- *
- *
+ * @return Parent vector.
*/
public Vector delegate() {
return vec;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
index 854b732..6378399 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -27,9 +28,12 @@ import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
* Vector storage holding a single non-zero value at some index.
*/
public class SingleElementVectorStorage implements VectorStorage {
- /** */ private int idx;
- /** */ private double val;
- /** */ private int size;
+ /** */
+ private int idx;
+ /** */
+ private double val;
+ /** */
+ private int size;
/**
*
@@ -53,7 +57,6 @@ public class SingleElementVectorStorage implements VectorStorage {
}
/**
- *
* @return Index of the element in the parent vector.
*/
public int index() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
index 035a565..fe70fbd 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
+
import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
import org.apache.ignite.ml.math.VectorStorage;
@@ -33,8 +34,10 @@ import org.apache.ignite.ml.math.impls.vector.SparseLocalOffHeapVector;
public class SparseLocalOffHeapVectorStorage implements VectorStorage {
/** Assume 10% density. */
private static final int INIT_DENSITY = 10;
+
/** Storage capacity. */
private int size;
+
/** Local off heap map. */
private GridOffHeapMap gridOffHeapMap;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index 75318d6..d3dba8e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -19,10 +19,12 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
+
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
+
import org.apache.ignite.ml.math.StorageConstants;
import org.apache.ignite.ml.math.VectorStorage;
@@ -30,8 +32,10 @@ import org.apache.ignite.ml.math.VectorStorage;
* Sparse, local, on-heap vector storage.
*/
public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageConstants {
- /** */ private int size;
- /** */ private int acsMode;
+ /** */
+ private int size;
+ /** */
+ private int acsMode;
/** Actual map storage. */
private Map<Integer, Double> sto;
@@ -61,8 +65,7 @@ public class SparseLocalOnHeapVectorStorage implements VectorStorage, StorageCon
}
/**
- *
- *
+ * @return Vector elements access mode.
*/
public int getAccessMode() {
return acsMode;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
index 83ac837..d59964b 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -28,6 +28,7 @@ import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.IntToDoubleFunction;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
index c868160..545d728 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Spliterator;
import java.util.function.IntToDoubleFunction;
+
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
index 1eda7d8..e479945 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.IndexException;
@@ -29,13 +30,18 @@ import org.apache.ignite.ml.math.impls.storage.vector.MatrixVectorStorage;
* Row or column vector view off the matrix.
*/
public class MatrixVectorView extends AbstractVector {
- /** */ private Matrix parent;
-
- /** */ private int row;
- /** */ private int col;
-
- /** */ private int rowStride;
- /** */ private int colStride;
+ /** */
+ private Matrix parent;
+
+ /** */
+ private int row;
+ /** */
+ private int col;
+
+ /** */
+ private int rowStride;
+ /** */
+ private int colStride;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
index 5ad6b89..0d53e71 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -20,6 +20,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -30,7 +31,8 @@ import org.apache.ignite.ml.math.impls.storage.vector.PivotedVectorStorage;
* Pivoted (index mapped) view over another vector.
*/
public class PivotedVectorView extends AbstractVector {
- /** */ private Vector vec;
+ /** */
+ private Vector vec;
/**
* @param vec Parent vector.
@@ -47,7 +49,7 @@ public class PivotedVectorView extends AbstractVector {
}
/**
- * @param vec Parent vector.
+ * @param vec Parent vector.
* @param pivot Mapping from external index to internal.
*/
public PivotedVectorView(Vector vec, int[] pivot) {
@@ -79,7 +81,7 @@ public class PivotedVectorView extends AbstractVector {
/**
* @param i Index to pivot.
- * @return Mapping from external index to internal for given index.
+ * @return Mapping from external index to internal for given index.
*/
public int pivot(int i) {
return storage().pivot()[i];
@@ -104,17 +106,17 @@ public class PivotedVectorView extends AbstractVector {
int exIdx = storage().pivot()[idx];
return new Vector.Element() {
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public double get() {
return storageGet(idx);
}
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public int index() {
return exIdx;
}
- /** {@inheritDoc */
+ /** {@inheritDoc} */
@Override public void set(double val) {
storageSet(idx, val);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
index d216a90..df6f791 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
@@ -33,7 +34,8 @@ import org.apache.ignite.ml.math.Vector;
* that by default, the value is determined by a relatively simple hash of the index.
*/
public class RandomVector extends AbstractReadOnlyVector {
- /** */ private boolean fastHash;
+ /** */
+ private boolean fastHash;
/**
* @param size Vector cardinality.
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index b47dad8..21e8141 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -1,102 +1 @@
-/*
- * 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.ml.math.impls.vector;
-
-import java.util.Map;
-import org.apache.ignite.ml.math.Matrix;
-import org.apache.ignite.ml.math.Vector;
-import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
-import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
-
-/**
- * Read-write vector holding a single non-zero value at some index.
- */
-public class SingleElementVector extends AbstractVector {
- /**
- *
- */
- public SingleElementVector() {
- // No-op
- }
-
- /**
- * @param size Parent vector size.
- * @param idx Index of the parent vector element.
- * @param val Value of the vector element.
- */
- public SingleElementVector(int size, int idx, double val) {
- super(new SingleElementVectorStorage(size, idx, val));
- }
-
- /**
- * @param args Parameters to create new vector instance.
- */
- public SingleElementVector(Map<String, Object> args) {
- assert args != null;
-
- if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
- int size = (int)args.get("size");
- int idx = (int)args.get("index");
- double val = (double)args.get("value");
-
- setStorage(new SingleElementVectorStorage(size, idx, val));
- }
- else
- throw new UnsupportedOperationException("Invalid constructor argument(s).");
- }
-
- /**
- *
- *
- */
- private SingleElementVectorStorage storage() {
- return (SingleElementVectorStorage)getStorage();
- }
-
- /** {@inheritDoc} */
- @Override public Element minElement() {
- return makeElement(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public Element maxElement() {
- return makeElement(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public double sum() {
- return getX(storage().index());
- }
-
- /** {@inheritDoc} */
- @Override public int nonZeroElements() {
- return isZero(get(storage().index())) ? 0 : 1;
- }
-
- /** {@inheritDoc} */
- @Override public Vector like(int crd) {
- int idx = storage().index();
-
- return new SingleElementVector(crd, idx, getX(idx));
- }
-
- /** {@inheritDoc} */
- @Override public Matrix likeMatrix(int rows, int cols) {
- throw new UnsupportedOperationException();
- }
-}
+/*
* 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.ml.math.impls.vector;
import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
/**
* Read-write vector holding a single non-zero value at some index.
*/
public class SingleElementVector extends AbstractVector {
/**
*
*/
public SingleElementVector() {
// No-op
}
/**
* @param size Parent vector size.
* @param idx Index of the parent vector element.
* @param val Value of the vector element.
*/
public SingleElementVector(int size, int idx, double val) {
super(new SingleElementVectorStorage(size, idx, val));
}
/**
* @param args Parameters to create new vector instance.
*/
public SingleElementVector(Map<String, Object> args) {
assert args != null;
if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
int size = (int)args.get("size");
int idx = (int)args.get("index");
doub
le val = (double)args.get("value");
setStorage(new SingleElementVectorStorage(size, idx, val));
}
else
throw new UnsupportedOperationException("Invalid constructor argument(s).");
}
/**
*
*
*/
private SingleElementVectorStorage storage() {
return (SingleElementVectorStorage)getStorage();
}
/** {@inheritDoc} */
@Override public Element minElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public Element maxElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public double sum() {
return getX(storage().index());
}
/** {@inheritDoc} */
@Override public int nonZeroElements() {
return isZero(get(storage().index())) ? 0 : 1;
}
/** {@inheritDoc} */
@Override public Vector like(int crd) {
int idx = storage().index();
return new SingleElemen
tVector(crd, idx, getX(idx));
}
/** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index d7c746d..b4f7330 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -23,6 +23,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
+
import org.apache.ignite.ml.math.impls.MathTestConstants;
import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
@@ -35,8 +36,11 @@ import static org.junit.Assert.assertEquals;
* Tests for {@link Tracer}.
*/
public class TracerTest {
- /** */ private static final String DEFAULT_FORMAT = "%.10f";
- /** */ private static final double DEFAULT_DELTA = 0.000000001d;
+ /** */
+ private static final String DEFAULT_FORMAT = "%.10f";
+
+ /** */
+ private static final double DEFAULT_DELTA = 0.000000001d;
/**
* Color mapper that maps [0, 1] range into three distinct RGB segments.
@@ -153,7 +157,7 @@ public class TracerTest {
List<String> strings = Files.readAllLines(file);
Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
- String[] csvVals = reduce.get().split(",");
+ String[] csvVals = reduce.orElse("").split(",");
for (int i = 0; i < vector.size(); i++) {
Double csvVal = Double.valueOf(csvVals[i]);
@@ -181,7 +185,7 @@ public class TracerTest {
List<String> strings = Files.readAllLines(file);
Optional<String> reduce = strings.stream().reduce((s1, s2) -> s1 + s2);
- String[] csvVals = reduce.get().split(",");
+ String[] csvVals = reduce.orElse("").split(",");
for (int i = 0; i < matrix.rowSize(); i++)
for (int j = 0; j < matrix.columnSize(); j++) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
index 52badbc..a7e9488 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/CacheMatrixTest.java
@@ -291,7 +291,7 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
final CacheMatrix<Integer, Double> cacheMatrix = new CacheMatrix<>(rows, cols, cache, keyMapper, new IdentityValueMapper());
ExternalizeTest<CacheMatrix<Integer, Double>> externalizeTest = new ExternalizeTest<CacheMatrix<Integer, Double>>() {
-
+ /** {@inheritDoc} */
@Override public void externalizeTest() {
super.externalizeTest(cacheMatrix);
}
@@ -351,14 +351,18 @@ public class CacheMatrixTest extends GridCommonAbstractTest {
return new MatrixKeyMapperForTests(rows, cols);
}
- /** Init the given matrix by random values. */
+ /**
+ * Init the given matrix by random values.
+ */
private void fillMatrix(Matrix m) {
for (int i = 0; i < m.rowSize(); i++)
for (int j = 0; j < m.columnSize(); j++)
m.set(i, j, Math.random());
}
- /** Init the given matrix by zeros. */
+ /**
+ * Init the given matrix by zeros.
+ */
private void initMatrix(Matrix m) {
for (int i = 0; i < m.rowSize(); i++)
for (int j = 0; j < m.columnSize(); j++)
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
index bc628c9..cfdd0f3 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/matrix/MatrixKeyMapperForTests.java
@@ -20,31 +20,36 @@ import org.apache.ignite.ml.math.MatrixKeyMapper;
/** */
public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
- /** */ private int rows;
- /** */ private int cols;
+ /** */
+ private int rows;
+ /** */
+ private int cols;
/** */
public MatrixKeyMapperForTests() {
// No-op.
}
- /** */
+ /**
+ * @param rows Amount of rows in matrix.
+ * @param cols Amount of columns in matrix.
+ */
public MatrixKeyMapperForTests(int rows, int cols) {
this.rows = rows;
this.cols = cols;
}
- /** */
+ /** {@inheritDoc} */
@Override public Integer apply(int x, int y) {
return x * cols + y;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isValid(Integer integer) {
return (rows * cols) > integer;
}
- /** */
+ /** {@inheritDoc} */
@Override public int hashCode() {
int hash = 1;
@@ -54,7 +59,7 @@ public class MatrixKeyMapperForTests implements MatrixKeyMapper<Integer> {
return hash;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
index 03473cf..78f3dde 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -23,17 +23,18 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
+
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
import org.jetbrains.annotations.NotNull;
/**
- *
+ * Fixtures for matrix tests.
*/
class MatrixStorageFixtures {
/** */
private static final List<Supplier<Iterable<MatrixStorage>>> suppliers = Collections.singletonList(
- (Supplier<Iterable<MatrixStorage>>) SparseLocalMatrixStorageFixture::new
+ (Supplier<Iterable<MatrixStorage>>)SparseLocalMatrixStorageFixture::new
);
/** */
@@ -57,10 +58,12 @@ class MatrixStorageFixtures {
private final Integer[] rows = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 512, 1024, null};
/** */
private final Integer[] cols = new Integer[] {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1024, 512, null};
+
/** */
private final Integer[] randomAccess = new Integer[] {StorageConstants.SEQUENTIAL_ACCESS_MODE, StorageConstants.RANDOM_ACCESS_MODE, null};
/** */
private final Integer[] rowStorage = new Integer[] {StorageConstants.ROW_STORAGE_MODE, StorageConstants.COLUMN_STORAGE_MODE, null};
+
/** */
private int sizeIdx = 0;
/** */
@@ -118,19 +121,23 @@ class MatrixStorageFixtures {
", access mode=" + randomAccess[acsModeIdx] + ", storage mode=" + rowStorage[stoModeIdx] + "}";
}
- /** */ private boolean hasNextRow(int idx) {
+ /** */
+ private boolean hasNextRow(int idx) {
return rows[idx] != null;
}
- /** */ private boolean hasNextCol(int idx) {
+ /** */
+ private boolean hasNextCol(int idx) {
return cols[idx] != null;
}
- /** */ private boolean hasNextAcsMode(int idx) {
+ /** */
+ private boolean hasNextAcsMode(int idx) {
return randomAccess[idx] != null;
}
- /** */ private boolean hasNextStoMode(int idx) {
+ /** */
+ private boolean hasNextStoMode(int idx) {
return rowStorage[idx] != null;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
index 7e5fc48..0b4392e 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorageTest.java
@@ -33,7 +33,8 @@ import static org.junit.Assert.assertTrue;
* Tests for {@link SparseLocalOffHeapVectorStorage}.
*/
public class SparseLocalOffHeapVectorStorageTest extends ExternalizeTest<SparseLocalOffHeapVectorStorage> {
- /** */ private SparseLocalOffHeapVectorStorage testVectorStorage;
+ /** */
+ private SparseLocalOffHeapVectorStorage testVectorStorage;
/** */
@Before
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
index 7d12773..0707e0a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.ml.math.impls.vector;
import java.util.Arrays;
import java.util.stream.StreamSupport;
+
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
@@ -355,54 +356,55 @@ public class AbstractVectorTest {
* @param storage {@link VectorStorage}
* @return AbstractVector.
*/
+ @SuppressWarnings("ClassWithoutNoArgConstructor")
private AbstractVector getAbstractVector(VectorStorage storage) {
return new AbstractVector(storage) { // TODO: find out how to fix warning about missing constructor
- /** */
+ /** {@inheritDoc} */
@Override public boolean isDense() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isSequentialAccess() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector copy() {
return getAbstractVector(this.getStorage());
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector like(int crd) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector viewPart(int off, int len) {
return null;
}
@@ -426,52 +428,52 @@ public class AbstractVectorTest {
*/
private AbstractVector getAbstractVector() {
return new AbstractVector() { // TODO: find out how to fix warning about missing constructor
- /** */
+ /** {@inheritDoc} */
@Override public boolean isDense() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public boolean isSequentialAccess() {
return false;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector copy() {
return getAbstractVector(this.getStorage());
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector like(int crd) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector normalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize() {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector logNormalize(double power) {
return null;
}
- /** */
+ /** {@inheritDoc} */
@Override public Vector viewPart(int off, int len) {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/33079fc9/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index 0026e2b..ce9f98a 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.stream.IntStream;
+
import junit.framework.TestCase;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
@@ -48,6 +49,7 @@ public class CacheVectorTest extends GridCommonAbstractTest {
private static final String CACHE_NAME = "test-cache";
/** Cache size. */
private static final int size = MathTestConstants.STORAGE_SIZE;
+
/** Grid instance. */
private Ignite ignite;
/** Default key mapper. */
@@ -420,7 +422,8 @@ public class CacheVectorTest extends GridCommonAbstractTest {
return cache;
}
- /** */ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
+ /** */
+ private static class TestKeyMapper implements VectorKeyMapper<Integer> {
/** {@inheritDoc} */
@Override public Integer apply(int i) {
return i;
[15/50] [abbrv] ignite git commit: Fixed failures in
IgniteCacheJoinQueryWithAffinityKeyTest.
Posted by vo...@apache.org.
Fixed failures in IgniteCacheJoinQueryWithAffinityKeyTest.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8d0da14c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8d0da14c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8d0da14c
Branch: refs/heads/master
Commit: 8d0da14c547022f8c9cc429531faee59a812f9a5
Parents: 234bb5a
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:02:31 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:02:31 2017 +0300
----------------------------------------------------------------------
...IgniteCacheJoinQueryWithAffinityKeyTest.java | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8d0da14c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
index e08fa55..de81da3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheJoinQueryWithAffinityKeyTest.java
@@ -23,9 +23,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ThreadLocalRandom;
-import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheKeyConfiguration;
@@ -42,7 +40,6 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -181,22 +178,11 @@ public class IgniteCacheJoinQueryWithAffinityKeyTest extends GridCommonAbstractT
for (int i = 0; i < NODES; i++) {
log.info("Test node: " + i);
- final IgniteCache cache0 = ignite(i).cache(ccfg.getName());
+ IgniteCache cache0 = ignite(i).cache(ccfg.getName());
- if (cacheMode == REPLICATED && !ignite(i).configuration().isClientMode()) {
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
- checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
+ checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
- return null;
- }
- }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
- }
- else {
- checkPersonAccountsJoin(cache0, putData.personAccounts, affKey);
-
- checkOrganizationPersonsJoin(cache0, putData.orgPersons);
- }
+ checkOrganizationPersonsJoin(cache0, putData.orgPersons);
}
}
finally {
[32/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
deleted file mode 100644
index 1842a63..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
+++ /dev/null
@@ -1,129 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.internal.DefaultCacheKeysFactory;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * Implementation of {@link EntityRegion}. This region is used to store entity data.
- * <p>
- * L2 cache for entity can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache for entity can be enabled using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateEntityRegion extends HibernateTransactionalDataRegion implements EntityRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache,
- * @param dataDesc Region data description.
- */
- public HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
- HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * Entity region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
- implements EntityRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public Object generateCacheKey(Object id,
- EntityPersister persister,
- SessionFactoryImplementor factory,
- String tenantIdentifier) {
- return HibernateKeyWrapper.staticCreateEntityKey(id, persister, tenantIdentifier);
- }
-
- /** {@inheritDoc} */
- @Override public Object getCacheKeyId(Object cacheKey) {
- return ((HibernateKeyWrapper)cacheKey).id();
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegion getRegion() {
- return HibernateEntityRegion.this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(SharedSessionContractImplementor ses, Object key, Object val, Object ver) throws CacheException {
- return stgy.insert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterInsert(SharedSessionContractImplementor ses, Object key, Object val, Object ver) throws CacheException {
- return stgy.afterInsert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean update(SharedSessionContractImplementor ses, Object key, Object val, Object currVer, Object previousVer)
- throws CacheException {
- return stgy.update(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterUpdate(SharedSessionContractImplementor ses, Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
- throws CacheException {
- return stgy.afterUpdate(key, val, lock);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
deleted file mode 100644
index 2b34804..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
+++ /dev/null
@@ -1,72 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.GeneralDataRegion;
-import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link GeneralDataRegion}. This interface defines common contract for {@link QueryResultsRegion}
- * and {@link TimestampsRegion}.
- */
-public class HibernateGeneralDataRegion extends HibernateRegion implements GeneralDataRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(SharedSessionContractImplementor ses, Object key) throws CacheException {
- try {
- return cache.get(key);
- } catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void put(SharedSessionContractImplementor ses, Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- } catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Object key) throws CacheException {
- HibernateAccessStrategyAdapter.evict(ignite, cache, key);
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll() throws CacheException {
- HibernateAccessStrategyAdapter.evictAll(cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
deleted file mode 100644
index ecad0b6..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
+++ /dev/null
@@ -1,28 +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.hibernate;
-
-/**
- * An interface for transforming hibernate keys to Ignite keys.
- */
-public interface HibernateKeyTransformer {
- /**
- * @param key Hibernate key.
- */
- public Object transform(Object key);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
deleted file mode 100644
index ff52124..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
+++ /dev/null
@@ -1,108 +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.hibernate;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.hibernate.cache.internal.DefaultCacheKeysFactory;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * Hibernate cache key wrapper.
- */
-public class HibernateKeyWrapper {
- /** Key. */
- private final Object key;
-
- /** Entry. */
- private final String entry;
-
- /** */
- private final String tenantId;
-
- /**
- * @param key Key.
- * @param entry Entry.
- * @param tenantId Tenant ID.
- */
- HibernateKeyWrapper(Object key, String entry, String tenantId) {
- this.key = key;
- this.entry = entry;
- this.tenantId = tenantId;
- }
-
- /**
- * @return ID.
- */
- Object id() {
- return key;
- }
-
- /**
- * @param id ID.
- * @param persister Persister.
- * @param tenantIdentifier Tenant ID.
- * @return Cache key.
- * @see DefaultCacheKeysFactory#staticCreateCollectionKey(Object, CollectionPersister, SessionFactoryImplementor, String)
- */
- static Object staticCreateCollectionKey(Object id,
- CollectionPersister persister,
- String tenantIdentifier) {
- return new HibernateKeyWrapper(id, persister.getRole(), tenantIdentifier);
- }
-
- /**
- * @param id ID.
- * @param persister Persister.
- * @param tenantIdentifier Tenant ID.
- * @return Cache key.
- * @see DefaultCacheKeysFactory#staticCreateEntityKey(Object, EntityPersister, SessionFactoryImplementor, String)
- */
- public static Object staticCreateEntityKey(Object id, EntityPersister persister, String tenantIdentifier) {
- return new HibernateKeyWrapper(id, persister.getRootEntityName(), tenantIdentifier);
- }
-
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o) return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- HibernateKeyWrapper that = (HibernateKeyWrapper) o;
-
- return (key != null ? key.equals(that.key) : that.key == null) &&
- (entry != null ? entry.equals(that.entry) : that.entry == null) &&
- (tenantId != null ? tenantId.equals(that.tenantId) : that.tenantId == null);
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = key != null ? key.hashCode() : 0;
- res = 31 * res + (entry != null ? entry.hashCode() : 0);
- res = 31 * res + (tenantId != null ? tenantId.hashCode() : 0);
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(HibernateKeyWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
deleted file mode 100644
index 73ed23a..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
+++ /dev/null
@@ -1,113 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.internal.DefaultCacheKeysFactory;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.hibernate.persister.entity.EntityPersister;
-
-/**
- * Implementation of {@link NaturalIdRegion}. This region is used to store naturalId data.
- * <p>
- * L2 cache for entity naturalId and target cache region can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * @org.hibernate.annotations.NaturalIdCache
- * public class Entity {
- * @org.hibernate.annotations.NaturalId
- * private String entityCode;
- *
- * ...
- * }
- * </pre>
- */
-public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion implements NaturalIdRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache,
- * @param dataDesc Region data description.
- */
- public HibernateNaturalIdRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * NaturalId region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy implements
- NaturalIdRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public Object generateCacheKey(Object[] naturalIdValues, EntityPersister persister, SharedSessionContractImplementor ses) {
- return DefaultCacheKeysFactory.staticCreateNaturalIdKey(naturalIdValues, persister, ses);
- }
-
- /** {@inheritDoc} */
- @Override public Object[] getNaturalIdValues(Object cacheKey) {
- return DefaultCacheKeysFactory.staticGetNaturalIdValues(cacheKey);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegion getRegion() {
- return HibernateNaturalIdRegion.this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(SharedSessionContractImplementor ses, Object key, Object val) throws CacheException {
- return stgy.insert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterInsert(SharedSessionContractImplementor ses, Object key, Object val) throws CacheException {
- return stgy.afterInsert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean update(SharedSessionContractImplementor ses, Object key, Object val) throws CacheException {
- return stgy.update(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterUpdate(SharedSessionContractImplementor ses, Object key, Object val, SoftLock lock) throws CacheException {
- return stgy.afterUpdate(key, val, lock);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
deleted file mode 100644
index a36d7e7..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
+++ /dev/null
@@ -1,222 +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.hibernate;
-
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.apache.ignite.internal.util.typedef.F;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#NONSTRICT_READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateNonStrictAccessStrategy extends HibernateAccessStrategyAdapter {
- /** */
- private final ThreadLocal<WriteContext> writeCtx;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- * @param writeCtx Thread local instance used to track updates done during one Hibernate transaction.
- */
- protected HibernateNonStrictAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal writeCtx) {
- super(ignite, cache);
-
- this.writeCtx = (ThreadLocal<WriteContext>)writeCtx;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx == null)
- writeCtx.set(ctx = new WriteContext());
-
- ctx.locked(key);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- try {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null && ctx.unlocked(key)) {
- writeCtx.remove();
-
- ctx.updateCache(cache);
- }
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null) {
- ctx.updated(key, val);
-
- unlock(key, lock);
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null)
- ctx.removed(key);
- }
-
- /**
- * Information about updates done during single database transaction.
- */
- @SuppressWarnings("TypeMayBeWeakened")
- private static class WriteContext {
- /** */
- private Map<Object, Object> updates;
-
- /** */
- private Set<Object> rmvs;
-
- /** */
- private Set<Object> locked = new GridLeanSet<>();
-
- /**
- * Marks key as locked.
- *
- * @param key Key.
- */
- void locked(Object key) {
- locked.add(key);
- }
-
- /**
- * Marks key as unlocked.
- *
- * @param key Key.
- * @return {@code True} if last locked key was unlocked.
- */
- boolean unlocked(Object key) {
- locked.remove(key);
-
- return locked.isEmpty();
- }
-
- /**
- * Marks key as updated.
- *
- * @param key Key.
- * @param val Value.
- */
- void updated(Object key, Object val) {
- if (updates == null)
- updates = new GridLeanMap<>();
-
- updates.put(key, val);
- }
-
- /**
- * Marks key as removed.
- *
- * @param key Key.
- */
- void removed(Object key) {
- if (rmvs == null)
- rmvs = new GridLeanSet<>();
-
- rmvs.add(key);
- }
-
- /**
- * Updates cache.
- *
- * @param cache Cache.
- * @throws IgniteCheckedException If failed.
- */
- void updateCache(HibernateCacheProxy cache) throws IgniteCheckedException {
- if (!F.isEmpty(rmvs))
- cache.removeAll(rmvs);
-
- if (!F.isEmpty(updates))
- cache.putAll(updates);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
deleted file mode 100644
index 0b9a43d..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
+++ /dev/null
@@ -1,70 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.Query;
-import org.hibernate.cache.spi.QueryResultsRegion;
-
-/**
- * Implementation of {@link QueryResultsRegion}. This region is used to store query results.
- * <p>
- * Query results caching can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Enable query cache. -->
- * <property name="cache.use_second_level_cache">true</property>
-
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * By default queries are not cached even after enabling query caching, to enable results caching for a particular
- * query, call {@link Query#setCacheable(boolean)}:
- * <pre name="code" class="java">
- * Session ses = getSession();
- *
- * Query qry = ses.createQuery("...");
- *
- * qry.setCacheable(true); // Enable L2 cache for query.
- * </pre>
- * Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
- * values. For this reason, the query cache should always be used in conjunction with
- * the second-level cache for those entities expected to be cached as part of a query result cache
- */
-public class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
deleted file mode 100644
index cdef80e..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
+++ /dev/null
@@ -1,107 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#READ_ONLY} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with read-only access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="read-only"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
- * public class Entity { ... }
- * </pre>
-
- *
- */
-public class HibernateReadOnlyAccessStrategy extends HibernateAccessStrategyAdapter {
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- public HibernateReadOnlyAccessStrategy(Ignite ignite, HibernateCacheProxy cache) {
- super(ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
deleted file mode 100644
index ae9bd71..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
+++ /dev/null
@@ -1,328 +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.hibernate;
-
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
-
-/**
- * Implementation of {@link AccessType#READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAdapter {
- /** */
- private final ThreadLocal<TxContext> txCtx;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- * @param txCtx Thread local instance used to track updates done during one Hibernate transaction.
- */
- protected HibernateReadWriteAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal txCtx) {
- super(ignite, cache);
-
- this.txCtx = (ThreadLocal<TxContext>)txCtx;
- }
-
- /** {@inheritDoc} */
- @Override protected Object get(Object key) throws CacheException {
- boolean success = false;
-
- try {
- Object o = cache.get(key);
-
- success = true;
-
- return o;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void putFromLoad(Object key, Object val) throws CacheException {
- boolean success = false;
-
- try {
- cache.put(key, val);
-
- success = true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected SoftLock lock(Object key) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx == null)
- txCtx.set(ctx = new TxContext());
-
- lockKey(key);
-
- ctx.locked(key);
-
- success = true;
-
- return null;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null)
- unlock(ctx, key);
-
- success = true;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- boolean success = false;
- boolean res = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null) {
- cache.put(key, val);
-
- unlock(ctx, key);
-
- res = true;
- }
-
- success = true;
-
- return res;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- boolean success = false;
-
- try {
- cache.put(key, val);
-
- success = true;
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null)
- cache.remove(key);
-
- success = true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /**
- *
- * @param ctx Transaction context.
- * @param key Key.
- * @throws CacheException If failed.
- */
- private void unlock(TxContext ctx, Object key) throws CacheException {
- if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
- txCtx.remove();
-
- GridNearTxLocal tx = cache.tx();
-
- assert tx != null;
-
- try {
- tx.proxy().commit();
- }
- finally {
- tx.proxy().close();
- }
-
- assert cache.tx() == null;
- }
- }
-
- /**
- * Roll backs current transaction.
- */
- private void rollbackCurrentTx() {
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null) {
- txCtx.remove();
-
- GridNearTxLocal tx = cache.tx();
-
- if (tx != null)
- tx.proxy().rollback();
- }
- }
- catch (IgniteException e) {
- log.error("Failed to rollback cache transaction.", e);
- }
- }
-
- /**
- * @param key Key.
- * @throws IgniteCheckedException If failed.
- */
- private void lockKey(Object key) throws IgniteCheckedException {
- if (cache.tx() == null)
- cache.txStart(PESSIMISTIC, REPEATABLE_READ);
-
- cache.get(key); // Acquire distributed lock.
- }
-
- /**
- * Information about updates done during single database transaction.
- */
- @SuppressWarnings("TypeMayBeWeakened")
- private static class TxContext {
- /** */
- private Set<Object> locked = new GridLeanSet<>();
-
- /**
- * Marks key as locked.
- *
- * @param key Key.
- */
- void locked(Object key) {
- locked.add(key);
- }
-
- /**
- * Marks key as unlocked.
- *
- * @param key Key.
- * @return {@code True} if last locked key was unlocked.
- */
- boolean unlocked(Object key) {
- locked.remove(key);
-
- return locked.isEmpty();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
deleted file mode 100644
index 11a96d0..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
+++ /dev/null
@@ -1,99 +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.hibernate;
-
-import java.util.Collections;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.Region;
-
-/**
- * Implementation of {@link Region}. This interface defines base contract for all L2 cache regions.
- */
-public class HibernateRegion implements Region {
- /** */
- protected final HibernateRegionFactory factory;
-
- /** */
- private final String name;
-
- /** Cache instance. */
- protected final HibernateCacheProxy cache;
-
- /** Grid instance. */
- protected Ignite ignite;
-
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateRegion(HibernateRegionFactory factory, String name, Ignite ignite, HibernateCacheProxy cache) {
- this.factory = factory;
- this.name = name;
- this.ignite = ignite;
- this.cache = cache;
- }
-
- /** {@inheritDoc} */
- @Override public String getName() {
- return name;
- }
-
- /** {@inheritDoc} */
- @Override public void destroy() throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean contains(Object key) {
- return cache.containsKey(key);
- }
-
- /** {@inheritDoc} */
- @Override public long getSizeInMemory() {
- return -1;
- }
-
- /** {@inheritDoc} */
- @Override public long getElementCountInMemory() {
- return cache.size();
- }
-
- /** {@inheritDoc} */
- @Override public long getElementCountOnDisk() {
- return -1;
- }
-
- /** {@inheritDoc} */
- @Override public Map toMap() {
- return Collections.emptyMap();
- }
-
- /** {@inheritDoc} */
- @Override public long nextTimestamp() {
- return System.currentTimeMillis();
- }
-
- /** {@inheritDoc} */
- @Override public int getTimeout() {
- return 0;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
deleted file mode 100644
index 0cf03d7..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
+++ /dev/null
@@ -1,255 +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.hibernate;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.G;
-import org.hibernate.boot.spi.SessionFactoryOptions;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.hibernate.cache.spi.access.AccessType;
-
-import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
-
-/**
- * Hibernate L2 cache region factory.
- * <p>
- * Following Hibernate settings should be specified to enable second level cache and to use this
- * region factory for caching:
- * <pre name="code" class="brush: xml; gutter: false;">
- * hibernate.cache.use_second_level_cache=true
- * hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
- * </pre>
- * Note that before region factory is started you need to start properly configured Ignite node in the same JVM.
- * For example to start Ignite node one of loader provided in {@code org.apache.ignite.grid.startup} package can be used.
- * <p>
- * Name of Ignite instance to be used for region factory must be specified as following Hibernate property:
- * <pre name="code" class="brush: xml; gutter: false;">
- * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance name>
- * </pre>
- * Each Hibernate cache region must be associated with some {@link IgniteInternalCache}, by default it is assumed that
- * for each cache region there is a {@link IgniteInternalCache} with the same name. Also it is possible to define
- * region to cache mapping using properties with prefix {@code org.apache.ignite.hibernate.region_cache}.
- * For example if for region with name "region1" cache with name "cache1" should be used then following
- * Hibernate property should be specified:
- * <pre name="code" class="brush: xml; gutter: false;">
- * org.apache.ignite.hibernate.region_cache.region1=cache1
- * </pre>
- */
-public class HibernateRegionFactory implements RegionFactory {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Hibernate L2 cache grid name property name.
- *
- * @deprecated Use {@link #IGNITE_INSTANCE_NAME_PROPERTY}.
- * If {@link #IGNITE_INSTANCE_NAME_PROPERTY} is specified it takes precedence.
- */
- @Deprecated
- public static final String GRID_NAME_PROPERTY = "org.apache.ignite.hibernate.grid_name";
-
- /** Hibernate L2 cache Ignite instance name property name. */
- public static final String IGNITE_INSTANCE_NAME_PROPERTY = "org.apache.ignite.hibernate.ignite_instance_name";
-
- /** Default cache property name. */
- public static final String DFLT_CACHE_NAME_PROPERTY = "org.apache.ignite.hibernate.default_cache";
-
- /** Property prefix used to specify region name to cache name mapping. */
- public static final String REGION_CACHE_PROPERTY = "org.apache.ignite.hibernate.region_cache.";
-
- /** */
- public static final String DFLT_ACCESS_TYPE_PROPERTY = "org.apache.ignite.hibernate.default_access_type";
-
- /** */
- public static final String GRID_CONFIG_PROPERTY = "org.apache.ignite.hibernate.grid_config";
-
- /** Grid providing caches. */
- private Ignite ignite;
-
- /** Default cache. */
- private HibernateCacheProxy dfltCache;
-
- /** Default region access type. */
- private AccessType dfltAccessType;
-
- /** Region name to cache name mapping. */
- private final Map<String, String> regionCaches = new HashMap<>();
-
- /** Map needed to provide the same transaction context for different regions. */
- private final ThreadLocal threadLoc = new ThreadLocal();
-
- /** Key transformer. */
- private final HibernateKeyTransformer hibernate4transformer = new HibernateKeyTransformer() {
- @Override public Object transform(Object key) {
- return key;
- }
- };
-
- /** {@inheritDoc} */
- @Override public void start(SessionFactoryOptions settings, Properties props) throws CacheException {
- String gridCfg = props.getProperty(GRID_CONFIG_PROPERTY);
- String igniteInstanceName = props.getProperty(IGNITE_INSTANCE_NAME_PROPERTY);
-
- if (igniteInstanceName == null)
- igniteInstanceName = props.getProperty(GRID_NAME_PROPERTY);
-
- if (gridCfg != null) {
- try {
- ignite = G.start(gridCfg);
- }
- catch (IgniteException e) {
- throw new CacheException(e);
- }
- }
- else
- ignite = Ignition.ignite(igniteInstanceName);
-
- String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());
-
- dfltAccessType = AccessType.valueOf(accessType);
-
- for (Map.Entry<Object, Object> prop : props.entrySet()) {
- String key = prop.getKey().toString();
-
- if (key.startsWith(REGION_CACHE_PROPERTY)) {
- String regionName = key.substring(REGION_CACHE_PROPERTY.length());
-
- String cacheName = prop.getValue().toString();
-
- if (((IgniteKernal)ignite).getCache(cacheName) == null)
- throw new CacheException("Cache '" + cacheName + "' specified for region '" + regionName + "' " +
- "is not configured.");
-
- regionCaches.put(regionName, cacheName);
- }
- }
-
- String dfltCacheName = props.getProperty(DFLT_CACHE_NAME_PROPERTY);
-
- if (dfltCacheName != null) {
- IgniteInternalCache<Object, Object> dfltCache = ((IgniteKernal)ignite).getCache(dfltCacheName);
-
- if (dfltCache == null)
- throw new CacheException("Cache specified as default is not configured: " + dfltCacheName);
-
- this.dfltCache = new HibernateCacheProxy(dfltCache, hibernate4transformer);
- }
-
- IgniteLogger log = ignite.log().getLogger(HibernateRegionFactory.class);
-
- if (log.isDebugEnabled())
- log.debug("HibernateRegionFactory started [igniteInstanceName=" + igniteInstanceName + ']');
- }
-
- /** {@inheritDoc} */
- @Override public void stop() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public AccessType getDefaultAccessType() {
- return dfltAccessType;
- }
-
- /** {@inheritDoc} */
- @Override public long nextTimestamp() {
- return System.currentTimeMillis();
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegion buildEntityRegion(String regionName, Properties props, CacheDataDescription metadata)
- throws CacheException {
- return new HibernateEntityRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties props,
- CacheDataDescription metadata) throws CacheException {
- return new HibernateNaturalIdRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegion buildCollectionRegion(String regionName, Properties props,
- CacheDataDescription metadata) throws CacheException {
- return new HibernateCollectionRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
- throws CacheException {
- return new HibernateQueryResultsRegion(this, regionName, ignite, regionCache(regionName));
- }
-
- /** {@inheritDoc} */
- @Override public TimestampsRegion buildTimestampsRegion(String regionName, Properties props) throws CacheException {
- return new HibernateTimestampsRegion(this, regionName, ignite, regionCache(regionName));
- }
-
- /**
- * Reuse same thread local for the same cache across different regions.
- *
- * @param cacheName Cache name.
- * @return Thread local instance used to track updates done during one Hibernate transaction.
- */
- ThreadLocal threadLocalForCache(String cacheName) {
- return threadLoc;
- }
-
- /**
- * @param regionName L2 cache region name.
- * @return Cache for given region.
- * @throws CacheException If cache for given region is not configured.
- */
- private HibernateCacheProxy regionCache(String regionName) throws CacheException {
- String cacheName = regionCaches.get(regionName);
-
- if (cacheName == null) {
- if (dfltCache != null)
- return dfltCache;
-
- cacheName = regionName;
- }
-
- IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
- if (cache == null)
- throw new CacheException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured.");
-
- return new HibernateCacheProxy(cache, hibernate4transformer);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
deleted file mode 100644
index 8b4c243..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
+++ /dev/null
@@ -1,39 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.spi.TimestampsRegion;
-
-/**
- * Implementation of {@link TimestampsRegion}. This region is automatically created when query
- * caching is enabled and it holds most recent updates timestamps to queryable tables.
- * Name of timestamps region is {@code "org.hibernate.cache.spi.UpdateTimestampsCache"}.
- */
-public class HibernateTimestampsRegion extends HibernateGeneralDataRegion implements TimestampsRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateTimestampsRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
deleted file mode 100644
index ca52849..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
+++ /dev/null
@@ -1,141 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#TRANSACTIONAL} cache access strategy.
- * <p>
- * It is supposed that this strategy is used in JTA environment and Hibernate and
- * {@link IgniteInternalCache} corresponding to the L2 cache region are configured to use the same transaction manager.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with transactional access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="transactional"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateTransactionalAccessStrategy extends HibernateAccessStrategyAdapter {
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- public HibernateTransactionalAccessStrategy(Ignite ignite, HibernateCacheProxy cache) {
- super(ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected Object get(Object key) throws CacheException {
- try {
- return cache.get(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void putFromLoad(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected SoftLock lock(Object key) throws CacheException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- try {
- cache.remove(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
deleted file mode 100644
index 581076a..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
+++ /dev/null
@@ -1,107 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.configuration.TransactionConfiguration;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.TransactionalDataRegion;
-import org.hibernate.cache.spi.access.AccessType;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-
-/**
- * Implementation of {@link TransactionalDataRegion} (transactional means that
- * data in the region is updated in connection with database transaction).
- * This interface defines base contract for {@link EntityRegion}, {@link CollectionRegion}
- * and {@link NaturalIdRegion}.
- */
-public class HibernateTransactionalDataRegion extends HibernateRegion implements TransactionalDataRegion {
- /** */
- private final CacheDataDescription dataDesc;
-
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- * @param dataDesc Region data description.
- */
- public HibernateTransactionalDataRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache);
-
- this.dataDesc = dataDesc;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isTransactionAware() {
- return false; // This method is not used by Hibernate.
- }
-
- /** {@inheritDoc} */
- @Override public CacheDataDescription getCacheDataDescription() {
- return dataDesc;
- }
-
- /**
- * @param accessType Hibernate L2 cache access type.
- * @return Access strategy for given access type.
- */
- protected HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
- switch (accessType) {
- case READ_ONLY:
- return new HibernateReadOnlyAccessStrategy(ignite, cache);
-
- case NONSTRICT_READ_WRITE:
- return new HibernateNonStrictAccessStrategy(ignite, cache, factory.threadLocalForCache(cache.name()));
-
- case READ_WRITE:
- if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
- throw new CacheException("Hibernate READ-WRITE access strategy must have Ignite cache with " +
- "'TRANSACTIONAL' atomicity mode: " + cache.name());
-
- return new HibernateReadWriteAccessStrategy(ignite, cache, factory.threadLocalForCache(cache.name()));
-
- case TRANSACTIONAL:
- if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
- throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " +
- "'TRANSACTIONAL' atomicity mode: " + cache.name());
-
- TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration();
-
- if (txCfg == null ||
- (txCfg.getTxManagerFactory() == null
- && txCfg.getTxManagerLookupClassName() == null
- && cache.configuration().getTransactionManagerLookupClassName() == null)) {
- throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite with " +
- "Factory<TransactionManager> configured (see IgniteConfiguration." +
- "getTransactionConfiguration().setTxManagerFactory()): " + cache.name());
- }
-
- return new HibernateTransactionalAccessStrategy(ignite, cache);
-
- default:
- throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
deleted file mode 100644
index 1179aec..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
+++ /dev/null
@@ -1,24 +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 description. -->
- * Contains implementation of Hibernate L2 cache. Refer to
- * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
- * configure and use Ignite with Hibernate.
- */
-package org.apache.ignite.cache.hibernate;
\ No newline at end of file
[43/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
new file mode 100644
index 0000000..c87f08f
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -0,0 +1,542 @@
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.transactions.Transaction;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.SharedSessionContract;
+import org.hibernate.cfg.Configuration;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * {@link CacheStore} implementation backed by Hibernate. This implementation
+ * stores objects in underlying database in {@code BLOB} format.
+ * <h2 class="header">Configuration</h2>
+ * Either {@link #setSessionFactory(SessionFactory)} or
+ * {@link #setHibernateConfigurationPath(String)} or
+ * {@link #setHibernateProperties(Properties)} should be set.
+ * <p>
+ * If session factory is provided it should contain
+ * {@link CacheHibernateBlobStoreEntry} persistent class (via provided
+ * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
+ * adding {@link CacheHibernateBlobStoreEntry} to annotated classes
+ * of session factory.
+ * <p>
+ * Path to hibernate configuration may be either an URL or a file path or
+ * a classpath resource. This configuration file should include provided
+ * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
+ * class {@link CacheHibernateBlobStoreEntry}.
+ * <p>
+ * If hibernate properties are provided, mapping
+ * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
+ * <p>
+ * Use {@link CacheHibernateBlobStoreFactory} factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
+ */
+public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
+ /**
+ * Default connection URL
+ * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
+ */
+ public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
+ "DEFAULT_LOCK_TIMEOUT=5000";
+
+ /** Default show SQL property value (value is <tt>true</tt>). */
+ public static final String DFLT_SHOW_SQL = "true";
+
+ /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
+ public static final String DFLT_HBM2DDL_AUTO = "update";
+
+ /** Session attribute name. */
+ private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
+
+ /** Name of Hibarname mapping resource. */
+ private static final String MAPPING_RESOURCE =
+ "org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml";
+
+ /** Marshaller. */
+ private static final Marshaller marsh = new JdkMarshaller();
+
+ /** Init guard. */
+ @GridToStringExclude
+ private final AtomicBoolean initGuard = new AtomicBoolean();
+
+ /** Init latch. */
+ @GridToStringExclude
+ private final CountDownLatch initLatch = new CountDownLatch(1);
+
+ /** Hibernate properties. */
+ @GridToStringExclude
+ private Properties hibernateProps;
+
+ /** Session factory. */
+ @GridToStringExclude
+ private SessionFactory sesFactory;
+
+ /** Path to hibernate configuration file. */
+ private String hibernateCfgPath;
+
+ /** Log. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Auto-injected store session. */
+ @CacheStoreSessionResource
+ private CacheStoreSession ses;
+
+ /** Ignite instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
+ @Override public V load(K key) {
+ init();
+
+ Transaction tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store load [key=" + key + ", tx=" + tx + ']');
+
+ Session ses = session(tx);
+
+ try {
+ CacheHibernateBlobStoreEntry entry = (CacheHibernateBlobStoreEntry)
+ ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+ if (entry == null)
+ return null;
+
+ return fromBytes(entry.getValue());
+ }
+ catch (IgniteCheckedException | HibernateException e) {
+ rollback(ses, tx);
+
+ throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
+ }
+ finally {
+ end(ses, tx);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
+ init();
+
+ Transaction tx = transaction();
+
+ K key = entry.getKey();
+ V val = entry.getValue();
+
+ if (log.isDebugEnabled())
+ log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
+
+ if (val == null) {
+ delete(key);
+
+ return;
+ }
+
+ Session ses = session(tx);
+
+ try {
+ CacheHibernateBlobStoreEntry entry0 = new CacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
+
+ ses.saveOrUpdate(entry0);
+ }
+ catch (IgniteCheckedException | 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", "JpaQlInspection"})
+ @Override public void delete(Object key) {
+ init();
+
+ Transaction tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
+
+ Session ses = session(tx);
+
+ try {
+ Object obj = ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+ if (obj != null)
+ ses.delete(obj);
+ }
+ catch (IgniteCheckedException | HibernateException e) {
+ rollback(ses, tx);
+
+ throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
+ }
+ finally {
+ end(ses, tx);
+ }
+ }
+
+ /**
+ * Rolls back hibernate session.
+ *
+ * @param ses Hibernate session.
+ * @param tx Cache ongoing transaction.
+ */
+ private void rollback(SharedSessionContract 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, 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) {
+ init();
+
+ Transaction tx = transaction();
+
+ Map<String, Session> props = session().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();
+
+ if (log.isDebugEnabled())
+ log.debug("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.
+ */
+ Session session(@Nullable Transaction tx) {
+ Session ses;
+
+ if (tx != null) {
+ Map<String, Session> props = session().properties();
+
+ ses = props.get(ATTR_SES);
+
+ if (ses == null) {
+ ses = sesFactory.openSession();
+
+ ses.beginTransaction();
+
+ // Store session in transaction metadata, so it can be accessed
+ // for other operations on the same transaction.
+ props.put(ATTR_SES, ses);
+
+ if (log.isDebugEnabled())
+ log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
+ }
+ }
+ else {
+ ses = sesFactory.openSession();
+
+ ses.beginTransaction();
+ }
+
+ return ses;
+ }
+
+ /**
+ * Sets session factory.
+ *
+ * @param sesFactory Session factory.
+ */
+ public void setSessionFactory(SessionFactory sesFactory) {
+ this.sesFactory = sesFactory;
+ }
+
+ /**
+ * Sets hibernate configuration path.
+ * <p>
+ * This may be either URL or file path or classpath resource.
+ *
+ * @param hibernateCfgPath URL or file path or classpath resource
+ * pointing to hibernate configuration XML file.
+ */
+ public void setHibernateConfigurationPath(String hibernateCfgPath) {
+ this.hibernateCfgPath = hibernateCfgPath;
+ }
+
+ /**
+ * Sets Hibernate properties.
+ *
+ * @param hibernateProps Hibernate properties.
+ */
+ public void setHibernateProperties(Properties hibernateProps) {
+ this.hibernateProps = hibernateProps;
+ }
+
+ /**
+ * Initializes store.
+ *
+ * @throws IgniteException If failed to initialize.
+ */
+ private void init() throws IgniteException {
+ if (initGuard.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Initializing cache store.");
+
+ try {
+ if (sesFactory != null)
+ // Session factory has been provided - nothing to do.
+ return;
+
+ if (!F.isEmpty(hibernateCfgPath)) {
+ try {
+ URL url = new URL(hibernateCfgPath);
+
+ sesFactory = new Configuration().configure(url).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using URL: " + url);
+
+ // Session factory has been successfully initialized.
+ return;
+ }
+ catch (MalformedURLException e) {
+ if (log.isDebugEnabled())
+ log.debug("Caught malformed URL exception: " + e.getMessage());
+ }
+
+ // Provided path is not a valid URL. File?
+ File cfgFile = new File(hibernateCfgPath);
+
+ if (cfgFile.exists()) {
+ sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using file: " + hibernateCfgPath);
+
+ // Session factory has been successfully initialized.
+ return;
+ }
+
+ // Provided path is not a file. Classpath resource?
+ sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
+ }
+ else {
+ if (hibernateProps == null) {
+ U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
+
+ hibernateProps = new Properties();
+
+ hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
+ hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
+ hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
+ }
+
+ Configuration cfg = new Configuration();
+
+ cfg.setProperties(hibernateProps);
+
+ assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
+
+ cfg.addResource(MAPPING_RESOURCE);
+
+ sesFactory = cfg.buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using properties: " + hibernateProps);
+ }
+ }
+ catch (HibernateException e) {
+ throw new IgniteException("Failed to initialize store.", e);
+ }
+ finally {
+ initLatch.countDown();
+ }
+ }
+ else if (initLatch.getCount() > 0) {
+ try {
+ U.await(initLatch);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new IgniteException(e);
+ }
+ }
+
+ if (sesFactory == null)
+ throw new IgniteException("Cache store was not properly initialized.");
+ }
+
+ /**
+ * Checks availability of a classpath resource.
+ *
+ * @param name Resource name.
+ * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
+ */
+ private boolean resourceAvailable(String name) {
+ InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+
+ if (cfgStream == null) {
+ log.error("Classpath resource not found: " + name);
+
+ return false;
+ }
+
+ try {
+ // Read a single byte to force actual content access by JVM.
+ cfgStream.read();
+
+ return true;
+ }
+ catch (IOException e) {
+ log.error("Failed to read classpath resource: " + name, e);
+
+ return false;
+ }
+ finally {
+ U.close(cfgStream, log);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheHibernateBlobStore.class, this);
+ }
+
+ /**
+ * Serialize object to byte array using marshaller.
+ *
+ * @param obj Object to convert to byte array.
+ * @return Byte array.
+ * @throws IgniteCheckedException If failed to convert.
+ */
+ protected byte[] toBytes(Object obj) throws IgniteCheckedException {
+ return U.marshal(marsh, obj);
+ }
+
+ /**
+ * Deserialize object from byte array using marshaller.
+ *
+ * @param bytes Bytes to deserialize.
+ * @param <X> Result object type.
+ * @return Deserialized object.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
+ if (bytes == null || bytes.length == 0)
+ return null;
+
+ return U.unmarshal(marsh, bytes, getClass().getClassLoader());
+ }
+
+ /**
+ * @return Current transaction.
+ */
+ @Nullable private Transaction transaction() {
+ CacheStoreSession ses = session();
+
+ return ses != null ? ses.transaction() : null;
+ }
+
+ /**
+ * @return Store session.
+ */
+ private CacheStoreSession session() {
+ return ses;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
new file mode 100644
index 0000000..5b0be43
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.apache.ignite.examples.datagrid.store" default-access="field">
+ <class name="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry" table="ENTRIES">
+ <id name="key"/>
+
+ <property name="val"/>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
new file mode 100644
index 0000000..d40c5ef
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
@@ -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.
+ */
+
+package org.apache.ignite.cache.store.hibernate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Entry that is used by {@link CacheHibernateBlobStore} implementation.
+ * <p>
+ * Note that this is a reference implementation for tests only.
+ * When running on production systems use concrete key-value types to
+ * get better performance.
+ */
+@Entity
+@Table(name = "ENTRIES")
+public class CacheHibernateBlobStoreEntry {
+ /** Key (use concrete key type in production). */
+ @Id
+ @Column(length = 65535)
+ private byte[] key;
+
+ /** Value (use concrete value type in production). */
+ @Column(length = 65535)
+ private byte[] val;
+
+ /**
+ * Constructor.
+ */
+ CacheHibernateBlobStoreEntry() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ CacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
+ this.key = key;
+ this.val = val;
+ }
+
+ /**
+ * @return Key.
+ */
+ public byte[] getKey() {
+ return key;
+ }
+
+ /**
+ * @param key Key.
+ */
+ public void setKey(byte[] key) {
+ this.key = key;
+ }
+
+ /**
+ * @return Value.
+ */
+ public byte[] getValue() {
+ return val;
+ }
+
+ /**
+ * @param val Value.
+ */
+ public void setValue(byte[] val) {
+ this.val = val;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
new file mode 100644
index 0000000..ea4df8a
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
@@ -0,0 +1,235 @@
+/*
+ * 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 java.util.Properties;
+import javax.cache.configuration.Factory;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteComponentType;
+import org.apache.ignite.internal.util.spring.IgniteSpringHelper;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.hibernate.SessionFactory;
+
+/**
+ * {@link Factory} implementation for {@link CacheHibernateBlobStore}.
+ *
+ * Use this factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
+ *
+ * <h2 class="header">Java Example</h2>
+ * In this example existing session factory is provided.
+ * <pre name="code" class="java">
+ * ...
+ * CacheHibernateBlobStoreFactory<String, String> factory = new CacheHibernateBlobStoreFactory<String, String>();
+ *
+ * factory.setSessionFactory(sesFactory);
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM)</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="sessionFactory">
+ * <bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ * <property name="hibernateProperties">
+ * <value>
+ * connection.url=jdbc:h2:mem:
+ * show_sql=true
+ * hbm2ddl.auto=true
+ * hibernate.dialect=org.hibernate.dialect.H2Dialect
+ * </value>
+ * </property>
+ * <property name="mappingResources">
+ * <list>
+ * <value>
+ * org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
+ * </value>
+ * </list>
+ * </property>
+ * </bean>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory1"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="sessionFactory">
+ * <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
+ * <property name="hibernateProperties">
+ * <value>
+ * connection.url=jdbc:h2:mem:
+ * show_sql=true
+ * hbm2ddl.auto=true
+ * hibernate.dialect=org.hibernate.dialect.H2Dialect
+ * </value>
+ * </property>
+ * <property name="annotatedClasses">
+ * <list>
+ * <value>
+ * org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry
+ * </value>
+ * </list>
+ * </property>
+ * </bean>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory2"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="hibernateProperties">
+ * <props>
+ * <prop key="connection.url">jdbc:h2:mem:</prop>
+ * <prop key="hbm2ddl.auto">update</prop>
+ * <prop key="show_sql">true</prop>
+ * </props>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ * <p>
+ * <img src="http://ignite.apache.org/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ */
+public class CacheHibernateBlobStoreFactory<K, V> implements Factory<CacheHibernateBlobStore<K, V>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Session factory. */
+ @GridToStringExclude
+ private transient SessionFactory sesFactory;
+
+ /** Session factory bean name. */
+ private String sesFactoryBean;
+
+ /** Path to hibernate configuration file. */
+ private String hibernateCfgPath;
+
+ /** Hibernate properties. */
+ @GridToStringExclude
+ private Properties hibernateProps;
+
+ /** Application context. */
+ @SpringApplicationContextResource
+ private Object appContext;
+
+ /** {@inheritDoc} */
+ @Override public CacheHibernateBlobStore<K, V> create() {
+ CacheHibernateBlobStore<K, V> store = new CacheHibernateBlobStore<>();
+
+ store.setHibernateConfigurationPath(hibernateCfgPath);
+ store.setHibernateProperties(hibernateProps);
+
+ if (sesFactory != null)
+ store.setSessionFactory(sesFactory);
+ else if (sesFactoryBean != null) {
+ if (appContext == null)
+ throw new IgniteException("Spring application context resource is not injected.");
+
+ IgniteSpringHelper spring;
+
+ try {
+ spring = IgniteComponentType.SPRING.create(false);
+
+ SessionFactory sesFac = spring.loadBeanFromAppContext(appContext, sesFactoryBean);
+
+ store.setSessionFactory(sesFac);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to load bean in application context [beanName=" + sesFactoryBean +
+ ", igniteConfig=" + appContext + ']');
+ }
+ }
+
+ return store;
+ }
+
+ /**
+ * Sets session factory.
+ *
+ * @param sesFactory Session factory.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setSessionFactory(SessionFactory sesFactory) {
+ this.sesFactory = sesFactory;
+
+ return this;
+ }
+
+ /**
+ * Sets name of the data source bean.
+ *
+ * @param sesFactory Session factory bean name.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setSessionFactoryBean(String sesFactory) {
+ this.sesFactoryBean = sesFactory;
+
+ return this;
+ }
+
+ /**
+ * Sets hibernate configuration path.
+ * <p>
+ * This may be either URL or file path or classpath resource.
+ *
+ * @param hibernateCfgPath URL or file path or classpath resource
+ * pointing to hibernate configuration XML file.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setHibernateConfigurationPath(String)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setHibernateConfigurationPath(String hibernateCfgPath) {
+ this.hibernateCfgPath = hibernateCfgPath;
+
+ return this;
+ }
+
+ /**
+ * Sets Hibernate properties.
+ *
+ * @param hibernateProps Hibernate properties.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setHibernateProperties(Properties)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setHibernateProperties(Properties hibernateProps) {
+ this.hibernateProps = hibernateProps;
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheHibernateBlobStoreFactory.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
new file mode 100644
index 0000000..917641c
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
@@ -0,0 +1,222 @@
+/*
+ * 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 java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.LoggerResource;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+
+/**
+ * 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<Integer, Integer> {
+ * @CacheStoreSessionResource
+ * private CacheStoreSession ses;
+ *
+ * @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> 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.attach(null);
+
+ 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();
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
new file mode 100644
index 0000000..891d99a
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains reference Hibernate-based cache store implementation.
+ */
+package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/config/factory-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/config/factory-cache.xml b/modules/hibernate-4.2/src/test/config/factory-cache.xml
new file mode 100644
index 0000000..a251846
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/config/factory-cache.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="simpleSessionFactory"
+ class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactoryExt"/>
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/config/factory-cache1.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/config/factory-cache1.xml b/modules/hibernate-4.2/src/test/config/factory-cache1.xml
new file mode 100644
index 0000000..7a53b1f
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/config/factory-cache1.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="simpleSessionFactory1"
+ class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactory"/>
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="igniteInstanceName" value="ignite1"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml b/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
new file mode 100644
index 0000000..459930c
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
new file mode 100644
index 0000000..cb179c4
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
@@ -0,0 +1,409 @@
+/*
+ * 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.hibernate;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.cache.Cache;
+import javax.persistence.Cacheable;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistryBuilder;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.IGNITE_INSTANCE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
+import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
+import static org.hibernate.cfg.AvailableSettings.GENERATE_STATISTICS;
+import static org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO;
+import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
+import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
+import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
+
+/**
+ * Tests Hibernate L2 cache configuration.
+ */
+public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest {
+ /** */
+ public static final String ENTITY1_NAME = Entity1.class.getName();
+
+ /** */
+ public static final String ENTITY2_NAME = Entity2.class.getName();
+
+ /** */
+ public static final String ENTITY3_NAME = Entity3.class.getName();
+
+ /** */
+ public static final String ENTITY4_NAME = Entity4.class.getName();
+
+ /** */
+ public static final String TIMESTAMP_CACHE = "org.hibernate.cache.spi.UpdateTimestampsCache";
+
+ /** */
+ public static final String QUERY_CACHE = "org.hibernate.cache.internal.StandardQueryCache";
+
+ /** */
+ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+ /** If {@code true} then sets default cache in configuration. */
+ private boolean dfltCache;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
+ cache.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME), cacheConfiguration(ENTITY4_NAME),
+ cacheConfiguration("cache1"), cacheConfiguration("cache2"), cacheConfiguration("cache3"),
+ cacheConfiguration(TIMESTAMP_CACHE), cacheConfiguration(QUERY_CACHE));
+
+ return cfg;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration cacheConfiguration(String cacheName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(cacheName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(ATOMIC);
+
+ return cfg;
+ }
+
+ /**
+ * @param igniteInstanceName Ignite instance name.
+ * @return Hibernate configuration.
+ */
+ protected Configuration hibernateConfiguration(String igniteInstanceName) {
+ Configuration cfg = new Configuration();
+
+ cfg.addAnnotatedClass(Entity1.class);
+ cfg.addAnnotatedClass(Entity2.class);
+ cfg.addAnnotatedClass(Entity3.class);
+ cfg.addAnnotatedClass(Entity4.class);
+
+ cfg.setProperty(DFLT_ACCESS_TYPE_PROPERTY, AccessType.NONSTRICT_READ_WRITE.name());
+
+ cfg.setProperty(HBM2DDL_AUTO, "create");
+
+ cfg.setProperty(GENERATE_STATISTICS, "true");
+
+ cfg.setProperty(USE_SECOND_LEVEL_CACHE, "true");
+
+ cfg.setProperty(USE_QUERY_CACHE, "true");
+
+ cfg.setProperty(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
+
+ cfg.setProperty(RELEASE_CONNECTIONS, "on_close");
+
+ cfg.setProperty(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
+
+ cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
+ cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
+ cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
+ cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
+
+ if (dfltCache)
+ cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
+
+ return cfg;
+ }
+
+ /**
+ * Tests property {@link HibernateAccessStrategyFactory#REGION_CACHE_PROPERTY}.
+ */
+ public void testPerRegionCacheProperty() {
+ testCacheUsage(1, 1, 0, 1, 1);
+ }
+
+ /**
+ * Tests property {@link HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}.
+ */
+ public void testDefaultCache() {
+ dfltCache = true;
+
+ testCacheUsage(1, 1, 2, 0, 0);
+ }
+
+ /**
+ * @param expCache1 Expected size of cache with name 'cache1'.
+ * @param expCache2 Expected size of cache with name 'cache2'.
+ * @param expCache3 Expected size of cache with name 'cache3'.
+ * @param expCacheE3 Expected size of cache with name {@link #ENTITY3_NAME}.
+ * @param expCacheE4 Expected size of cache with name {@link #ENTITY4_NAME}.
+ */
+ @SuppressWarnings("unchecked")
+ private void testCacheUsage(int expCache1, int expCache2, int expCache3, int expCacheE3, int expCacheE4) {
+ SessionFactory sesFactory = startHibernate(getTestIgniteInstanceName(0));
+
+ try {
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity1());
+ ses.save(new Entity2());
+ ses.save(new Entity3());
+ ses.save(new Entity4());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory.openSession();
+
+ try {
+ List<Entity1> list1 = ses.createCriteria(ENTITY1_NAME).list();
+
+ assertEquals(1, list1.size());
+
+ for (Entity1 e : list1) {
+ ses.load(ENTITY1_NAME, e.getId());
+ assertNotNull(e.getId());
+ }
+
+ List<Entity2> list2 = ses.createCriteria(ENTITY2_NAME).list();
+
+ assertEquals(1, list2.size());
+
+ for (Entity2 e : list2)
+ assertNotNull(e.getId());
+
+ List<Entity3> list3 = ses.createCriteria(ENTITY3_NAME).list();
+
+ assertEquals(1, list3.size());
+
+ for (Entity3 e : list3)
+ assertNotNull(e.getId());
+
+ List<Entity4> list4 = ses.createCriteria(ENTITY4_NAME).list();
+
+ assertEquals(1, list4.size());
+
+ for (Entity4 e : list4)
+ assertNotNull(e.getId());
+ }
+ finally {
+ ses.close();
+ }
+
+ IgniteCache<Object, Object> cache1 = grid(0).cache("cache1");
+ IgniteCache<Object, Object> cache2 = grid(0).cache("cache2");
+ IgniteCache<Object, Object> cache3 = grid(0).cache("cache3");
+ IgniteCache<Object, Object> cacheE3 = grid(0).cache(ENTITY3_NAME);
+ IgniteCache<Object, Object> cacheE4 = grid(0).cache(ENTITY4_NAME);
+
+ assertEquals("Unexpected entries: " + toSet(cache1.iterator()), expCache1, cache1.size());
+ assertEquals("Unexpected entries: " + toSet(cache2.iterator()), expCache2, cache2.size());
+ assertEquals("Unexpected entries: " + toSet(cache3.iterator()), expCache3, cache3.size());
+ assertEquals("Unexpected entries: " + toSet(cacheE3.iterator()), expCacheE3, cacheE3.size());
+ assertEquals("Unexpected entries: " + toSet(cacheE4.iterator()), expCacheE4, cacheE4.size());
+ }
+ finally {
+ sesFactory.close();
+ }
+ }
+
+ /**
+ *
+ */
+ private <K, V> Set<Cache.Entry<K, V>> toSet(Iterator<Cache.Entry<K, V>> iter){
+ Set<Cache.Entry<K, V>> set = new HashSet<>();
+
+ while (iter.hasNext())
+ set.add(iter.next());
+
+ return set;
+ }
+
+ /**
+ * @param igniteInstanceName Name of the grid providing caches.
+ * @return Session factory.
+ */
+ private SessionFactory startHibernate(String igniteInstanceName) {
+ Configuration cfg = hibernateConfiguration(igniteInstanceName);
+
+ ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+ builder.applySetting("hibernate.show_sql", false);
+
+ return cfg.buildSessionFactory(builder.buildServiceRegistry());
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity1 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity2.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity2 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity3.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity3 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity4.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity4 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
new file mode 100644
index 0000000..5160220
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
@@ -0,0 +1,440 @@
+/*
+ * 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.hibernate;
+
+import java.util.Map;
+import javax.persistence.Cacheable;
+import javax.persistence.Id;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistryBuilder;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.CONNECTION_URL;
+import static org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.hibernateProperties;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+
+/**
+ *
+ */
+public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "hibernateCache";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ if (!getTestIgniteInstanceName(0).equals(igniteInstanceName))
+ cfg.setClientMode(true);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName(CACHE_NAME);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean isMultiJvm() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+
+ startGrid(1);
+ startGrid(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testL2Cache() throws Exception {
+ Ignite srv = ignite(0);
+
+ {
+ IgniteCompute client1Compute =
+ srv.compute(srv.cluster().forNodeId(ignite(1).cluster().localNode().id()));
+
+ client1Compute.run(new HibernateInsertRunnable());
+ }
+
+ {
+ IgniteCompute client2Compute =
+ srv.compute(srv.cluster().forNodeId(ignite(2).cluster().localNode().id()));
+
+ client2Compute.run(new HibernateLoadRunnable());
+ }
+
+ {
+ IgniteCompute srvCompute = srv.compute(srv.cluster().forLocal());
+
+ srvCompute.run(new HibernateLoadRunnable());
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HibernateInsertRunnable extends HibernateBaseRunnable {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ SessionFactory sesFactory = startHibernate(ignite.name());
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 1; i++) {
+ {
+ Entity1 e = new Entity1();
+ e.setId(i);
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+
+ {
+ Entity2 e = new Entity2();
+ e.setId(String.valueOf(i));
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+
+ {
+ Entity3 e = new Entity3();
+ e.setId(i);
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HibernateLoadRunnable extends HibernateBaseRunnable {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ SessionFactory sesFactory = startHibernate(ignite.name());
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 1; i++) {
+ {
+ Entity1 e = (Entity1)ses.load(Entity1.class, i);
+
+ log.info("Found: " + e.getName());
+ }
+ {
+ Entity2 e = (Entity2)ses.load(Entity2.class, String.valueOf(i));
+
+ log.info("Found: " + e.getName());
+ }
+ {
+ Entity3 e = (Entity3)ses.load(Entity3.class, (double)i);
+
+ log.info("Found: " + e.getName());
+ }
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class HibernateBaseRunnable implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** */
+ @LoggerResource
+ IgniteLogger log;
+
+ /**
+ * @param igniteInstanceName Name of the grid providing caches.
+ * @return Session factory.
+ */
+ SessionFactory startHibernate(String igniteInstanceName) {
+ log.info("Start hibernate on node: " + igniteInstanceName);
+
+ Configuration cfg = hibernateConfiguration(igniteInstanceName);
+
+ ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+
+ return cfg.buildSessionFactory(builder.buildServiceRegistry());
+ }
+
+ /**
+ * @param nodeName Ignite instance name.
+ * @return Hibernate configuration.
+ */
+ private Configuration hibernateConfiguration(String nodeName) {
+ Configuration cfg = new Configuration();
+
+ cfg.addAnnotatedClass(Entity1.class);
+ cfg.addAnnotatedClass(Entity2.class);
+ cfg.addAnnotatedClass(Entity3.class);
+
+ for (Map.Entry<String, String> e : hibernateProperties(nodeName, NONSTRICT_READ_WRITE.name()).entrySet())
+ cfg.setProperty(e.getKey(), e.getValue());
+
+ cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, CACHE_NAME);
+
+ return cfg;
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity1 {
+ /** */
+ @Id
+ private int id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity1 entity1 = (Entity1)o;
+
+ return id == entity1.id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity2 {
+ /** */
+ @Id
+ private String id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity2 entity2 = (Entity2)o;
+
+ return id.equals(entity2.id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id.hashCode();
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity3 {
+ /** */
+ @Id
+ private double id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public double getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(double id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity3 entity3 = (Entity3)o;
+
+ return Double.compare(entity3.id, id) == 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ long temp = Double.doubleToLongBits(id);
+ return (int)(temp ^ (temp >>> 32));
+ }
+ }
+}
[03/50] [abbrv] ignite git commit: IGNITE-5018 review and improve
javadocs in ML module (minor fixes)
Posted by vo...@apache.org.
IGNITE-5018 review and improve javadocs in ML module (minor fixes)
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7378bc38
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7378bc38
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7378bc38
Branch: refs/heads/master
Commit: 7378bc38abf8ec6ed8aca9c3608eec00f1a86fb2
Parents: 33079fc
Author: Anton Vinogradov <av...@apache.org>
Authored: Mon Apr 24 13:20:37 2017 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Mon Apr 24 13:20:37 2017 +0300
----------------------------------------------------------------------
modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java | 1 -
.../org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java | 1 -
.../ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java | 1 -
.../ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java | 1 -
.../ml/math/impls/storage/matrix/FunctionMatrixStorage.java | 1 -
.../math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java | 2 --
.../ignite/ml/math/impls/storage/vector/CacheVectorStorage.java | 1 -
.../ml/math/impls/storage/vector/ConstantVectorStorage.java | 1 -
.../ml/math/impls/storage/vector/DelegateVectorStorage.java | 1 -
.../ml/math/impls/storage/vector/FunctionVectorStorage.java | 1 -
.../ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java | 1 -
.../ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java | 1 -
.../impls/storage/vector/SingleElementVectorDelegateStorage.java | 1 -
.../ml/math/impls/storage/vector/SingleElementVectorStorage.java | 1 -
.../impls/storage/vector/SparseLocalOffHeapVectorStorage.java | 1 -
.../math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java | 2 --
.../org/apache/ignite/ml/math/impls/vector/AbstractVector.java | 1 -
.../org/apache/ignite/ml/math/impls/vector/DelegatingVector.java | 1 -
.../org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java | 1 -
.../org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java | 1 -
.../java/org/apache/ignite/ml/math/impls/vector/RandomVector.java | 3 +--
.../apache/ignite/ml/math/impls/vector/SingleElementVector.java | 2 +-
.../ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java | 1 -
.../ml/math/impls/storage/matrix/MatrixStorageFixtures.java | 1 -
.../apache/ignite/ml/math/impls/vector/AbstractVectorTest.java | 1 -
.../org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java | 1 -
26 files changed, 2 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
index 798d831..2cf4e63 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/Matrix.java
@@ -18,7 +18,6 @@
package org.apache.ignite.ml.math;
import java.io.Externalizable;
-
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.exceptions.CardinalityException;
import org.apache.ignite.ml.math.exceptions.IndexException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
index 16bdc3e..361bee5 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/matrix/PivotedMatrixView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
index 687216b..dcef3ff 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/CacheMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.MatrixKeyMapper;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
index 410da47..62060d1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/DenseOffHeapMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.ml.math.MatrixStorage;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
index 5bb2569..de30015 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/FunctionMatrixStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IntIntDoubleToVoidFunction;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
index db85b0f..b33cb26 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/matrix/SparseLocalOnHeapMatrixStorage.java
@@ -19,13 +19,11 @@ package org.apache.ignite.ml.math.impls.storage.matrix;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
index bec232d..c0c7152 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/CacheVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.ml.math.ValueMapper;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
index 1b899a1..0423bc5 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/ConstantVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
index 2a48653..6775d44 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/DelegateVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.VectorStorage;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
index a17eb0b..aabe3b1 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/FunctionVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.functions.IgniteFunction;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
index 59545a4..7700a7c 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/MatrixVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.IndexException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
index 537d651..1c798e4 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/PivotedVectorStorage.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Arrays;
-
import org.apache.ignite.ml.math.VectorStorage;
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
index 453c0f7..ac86e16 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorDelegateStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
index 6378399..488e158 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SingleElementVectorStorage.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
index fe70fbd..f6148c8 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOffHeapVectorStorage.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.nio.ByteBuffer;
-
import org.apache.ignite.internal.util.offheap.GridOffHeapMap;
import org.apache.ignite.internal.util.offheap.GridOffHeapMapFactory;
import org.apache.ignite.ml.math.VectorStorage;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
index d3dba8e..8400758 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/storage/vector/SparseLocalOnHeapVectorStorage.java
@@ -19,12 +19,10 @@ package org.apache.ignite.ml.math.impls.storage.vector;
import it.unimi.dsi.fastutil.ints.Int2DoubleOpenHashMap;
import it.unimi.dsi.fastutil.ints.Int2DoubleRBTreeMap;
-
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
-
import org.apache.ignite.ml.math.StorageConstants;
import org.apache.ignite.ml.math.VectorStorage;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
index d59964b..83ac837 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/AbstractVector.java
@@ -28,7 +28,6 @@ import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.function.IntToDoubleFunction;
-
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
index 545d728..c868160 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/DelegatingVector.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Spliterator;
import java.util.function.IntToDoubleFunction;
-
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
index e479945..3becbcf 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/MatrixVectorView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.IndexException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
index 0d53e71..365b5eb 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/PivotedVectorView.java
@@ -20,7 +20,6 @@ package org.apache.ignite.ml.math.impls.vector;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
index df6f791..633773e 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
@@ -21,13 +21,12 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.Map;
-
import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
import org.apache.ignite.ml.math.impls.storage.vector.RandomVectorStorage;
-import org.apache.ignite.ml.math.Vector;
/**
* Random vector. Each value is taken from {-1,0,1} with roughly equal probability. Note
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index 21e8141..3ec14a2 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@ -1 +1 @@
-/*
* 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.ml.math.impls.vector;
import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
/**
* Read-write vector holding a single non-zero value at some index.
*/
public class SingleElementVector extends AbstractVector {
/**
*
*/
public SingleElementVector() {
// No-op
}
/**
* @param size Parent vector size.
* @param idx Index of the parent vector element.
* @param val Value of the vector element.
*/
public SingleElementVector(int size, int idx, double val) {
super(new SingleElementVectorStorage(size, idx, val));
}
/**
* @param args Parameters to create new vector instance.
*/
public SingleElementVector(Map<String, Object> args) {
assert args != null;
if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
int size = (int)args.get("size");
int idx = (int)args.get("index");
doub
le val = (double)args.get("value");
setStorage(new SingleElementVectorStorage(size, idx, val));
}
else
throw new UnsupportedOperationException("Invalid constructor argument(s).");
}
/**
*
*
*/
private SingleElementVectorStorage storage() {
return (SingleElementVectorStorage)getStorage();
}
/** {@inheritDoc} */
@Override public Element minElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public Element maxElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public double sum() {
return getX(storage().index());
}
/** {@inheritDoc} */
@Override public int nonZeroElements() {
return isZero(get(storage().index())) ? 0 : 1;
}
/** {@inheritDoc} */
@Override public Vector like(int crd) {
int idx = storage().index();
return new SingleElemen
tVector(crd, idx, getX(idx));
}
/** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
+/*
* 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.ml.math.impls.vector;
import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.excepti
ons.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
/**
* Read-write vector holding a single non-zero value at some index.
*/
public class SingleElementVector extends AbstractVector {
/**
*
*/
public SingleElementVector() {
// No-op
}
/**
* @param size Parent vector size.
* @param idx Index of the parent vector element.
* @param val Value of the vector element.
*/
public SingleElementVector(int size, int idx, double val) {
super(new SingleElementVectorStorage(size, idx, val));
}
/**
* @param args Parameters to create new vector instance.
*/
public SingleElementVector(Map<String, Object> args) {
assert args != null;
if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
int size = (int)args.get("size");
int idx = (int)args.get("index");
doubl
e val = (double)args.get("value");
setStorage(new SingleElementVectorStorage(size, idx, val));
}
else
throw new UnsupportedOperationException("Invalid constructor argument(s).");
}
/**
*
*
*/
private SingleElementVectorStorage storage() {
return (SingleElementVectorStorage)getStorage();
}
/** {@inheritDoc} */
@Override public Element minElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public Element maxElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public double sum() {
return getX(storage().index());
}
/** {@inheritDoc} */
@Override public int nonZeroElements() {
return isZero(get(storage().index())) ? 0 : 1;
}
/** {@inheritDoc} */
@Override public Vector like(int crd) {
int idx = storage().index();
return new SingleElement
Vector(crd, idx, getX(idx));
}
/** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index b4f7330..0bc393f 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -23,7 +23,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;
-
import org.apache.ignite.ml.math.impls.MathTestConstants;
import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
index 78f3dde..afd6a5d 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
-
import org.apache.ignite.ml.math.MatrixStorage;
import org.apache.ignite.ml.math.StorageConstants;
import org.jetbrains.annotations.NotNull;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
index 0707e0a..a7954cd 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/AbstractVectorTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.ml.math.impls.vector;
import java.util.Arrays;
import java.util.stream.StreamSupport;
-
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.VectorStorage;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7378bc38/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
index ce9f98a..b5813d7 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/impls/vector/CacheVectorTest.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.stream.IntStream;
-
import junit.framework.TestCase;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
[46/50] [abbrv] ignite git commit: IGNITE-4774 Redesign table.
Posted by vo...@apache.org.
IGNITE-4774 Redesign table.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c829aaca
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c829aaca
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c829aaca
Branch: refs/heads/master
Commit: c829aacaf71b06b32be3345c3c70047230b9f9e5
Parents: 335f243
Author: Dmitriy Shabalin <dm...@gmail.com>
Authored: Wed Apr 26 18:41:32 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Wed Apr 26 18:41:32 2017 +0700
----------------------------------------------------------------------
.../list-of-registered-users.column-defs.js | 26 +-
.../list-of-registered-users.controller.js | 163 +++++-----
.../list-of-registered-users.tpl.pug | 25 +-
.../frontend/app/primitives/badge/index.scss | 1 +
.../frontend/app/primitives/btn/index.scss | 24 +-
.../frontend/app/primitives/dropdown/index.pug | 2 +-
.../frontend/app/primitives/dropdown/index.scss | 26 +-
.../frontend/app/primitives/panel/index.scss | 2 +-
.../app/primitives/ui-grid-header/index.scss | 10 +-
.../app/primitives/ui-grid-header/index.tpl.pug | 10 +-
.../app/primitives/ui-grid-settings/index.scss | 58 +++-
.../frontend/app/primitives/ui-grid/index.scss | 149 +++++++--
.../frontend/gulpfile.babel.js/paths.js | 1 +
.../frontend/gulpfile.babel.js/tasks/bundle.js | 2 +-
.../webpack/environments/development.js | 4 +-
.../frontend/public/images/icons/cross.svg | 1 +
.../frontend/public/images/icons/export.svg | 1 +
.../frontend/public/images/icons/gear.svg | 1 +
.../stylesheets/_bootstrap-variables.scss | 4 +-
modules/web-console/licenses/cc-by-3.0.txt | 319 +++++++++++++++++++
20 files changed, 669 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.column-defs.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.column-defs.js b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.column-defs.js
index 5bacce4..cb95735 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.column-defs.js
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.column-defs.js
@@ -50,11 +50,11 @@ const EMAIL_TEMPLATE = '<div class="ui-grid-cell-contents"><a ng-href="mailto:{{
export default [
{name: 'actions', displayName: 'Actions', categoryDisplayName: 'Actions', cellTemplate: ACTIONS_TEMPLATE, field: 'actions', minWidth: 70, width: 70, enableFiltering: false, enableSorting: false, visible: false},
- {name: 'user', displayName: 'User', categoryDisplayName: 'User', field: 'userName', cellTemplate: USER_TEMPLATE, minWidth: 160, enableFiltering: true, filter: { placeholder: 'Filter by name...' }},
+ {name: 'user', displayName: 'User', categoryDisplayName: 'User', field: 'userName', cellTemplate: USER_TEMPLATE, minWidth: 160, enableFiltering: true, pinnedLeft: true, filter: { placeholder: 'Filter by name...' }},
{name: 'email', displayName: 'Email', categoryDisplayName: 'Email', field: 'email', cellTemplate: EMAIL_TEMPLATE, minWidth: 160, enableFiltering: false, filter: { placeholder: 'Filter by email...' }},
- {name: 'company', displayName: 'Company', categoryDisplayName: 'Company', field: 'company', minWidth: 160, enableFiltering: true, filter: { placeholder: 'Filter by company...' }},
- {name: 'country', displayName: 'Country', categoryDisplayName: 'Country', field: 'countryCode', minWidth: 120, enableFiltering: true, filter: { placeholder: 'Filter by country...' }},
- {name: 'lastlogin', displayName: 'Last login', categoryDisplayName: 'Last login', field: 'lastLogin', cellFilter: 'date:"M/d/yy HH:mm"', minWidth: 105, width: 105, enableFiltering: false, visible: false},
+ {name: 'company', displayName: 'Company', categoryDisplayName: 'Company', field: 'company', minWidth: 180, enableFiltering: true, filter: { placeholder: 'Filter by company...' }},
+ {name: 'country', displayName: 'Country', categoryDisplayName: 'Country', field: 'countryCode', minWidth: 160, enableFiltering: true, filter: { placeholder: 'Filter by country...' }},
+ {name: 'lastlogin', displayName: 'Last login', categoryDisplayName: 'Last login', field: 'lastLogin', cellFilter: 'date:"M/d/yy HH:mm"', minWidth: 120, width: 120, enableFiltering: false, visible: false},
{name: 'lastactivity', displayName: 'Last activity', categoryDisplayName: 'Last activity', field: 'lastActivity', cellFilter: 'date:"M/d/yy HH:mm"', minWidth: 130, width: 130, enableFiltering: false, visible: true, sort: { direction: 'desc', priority: 0 }},
// Configurations
{name: 'cfg_clusters', displayName: 'Clusters count', categoryDisplayName: 'Configurations', headerCellTemplate: CLUSTER_HEADER_TEMPLATE, field: 'counters.clusters', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Clusters count', minWidth: 65, width: 65, enableFiltering: false, visible: false},
@@ -66,15 +66,15 @@ export default [
{name: 'qry', displayName: 'Qry', categoryDisplayName: 'Total activities', field: 'activitiesTotal["queries"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Total count of queries usages', minWidth: 70, width: 70, enableFiltering: false},
{name: 'demo', displayName: 'Demo', categoryDisplayName: 'Total activities', field: 'activitiesTotal["demo"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Total count of demo startup', minWidth: 85, width: 85, enableFiltering: false},
{name: 'dnld', displayName: 'Dnld', categoryDisplayName: 'Total activities', field: 'activitiesDetail["/agent/download"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Total count of agent downloads', minWidth: 80, width: 80, enableFiltering: false},
- {name: 'starts', displayName: 'Starts', categoryDisplayName: 'Total activities', field: 'activitiesDetail["/agent/start"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Total count of agent startup', minWidth: 80, width: 80, enableFiltering: false},
+ {name: 'starts', displayName: 'Starts', categoryDisplayName: 'Total activities', field: 'activitiesDetail["/agent/start"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Total count of agent startup', minWidth: 87, width: 87, enableFiltering: false},
// Activities Configuration
- {name: 'clusters', displayName: 'Clusters', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/clusters"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration clusters', minWidth: 80, width: 80, enableFiltering: false, visible: false},
- {name: 'model', displayName: 'Model', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/domains"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration model', minWidth: 80, width: 80, enableFiltering: false, visible: false},
- {name: 'caches', displayName: 'Caches', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/caches"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration caches', minWidth: 80, width: 80, enableFiltering: false, visible: false},
- {name: 'igfs', displayName: 'IGFS', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/igfs"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration IGFS', minWidth: 80, width: 80, enableFiltering: false, visible: false},
- {name: 'summary', displayName: 'Summary', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/summary"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration summary', minWidth: 80, width: 80, enableFiltering: false, visible: false},
+ {name: 'clusters', displayName: 'Clusters', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/clusters"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration clusters', minWidth: 100, width: 100, enableFiltering: false, visible: false},
+ {name: 'model', displayName: 'Model', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/domains"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration model', minWidth: 87, width: 87, enableFiltering: false, visible: false},
+ {name: 'caches', displayName: 'Caches', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/caches"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration caches', minWidth: 96, width: 96, enableFiltering: false, visible: false},
+ {name: 'igfs', displayName: 'IGFS', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/igfs"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration IGFS', minWidth: 85, width: 85, enableFiltering: false, visible: false},
+ {name: 'summary', displayName: 'Summary', categoryDisplayName: 'Configuration\'s activities', field: 'activitiesDetail["/configuration/summary"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Configuration summary', minWidth: 111, width: 111, enableFiltering: false, visible: false},
// Activities Queries
- {name: 'execute', displayName: 'Execute', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/execute"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Query executions', minWidth: 65, width: 80, enableFiltering: false, visible: false},
- {name: 'explain', displayName: 'Explain', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/explain"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Query explain executions', minWidth: 65, width: 80, enableFiltering: false, visible: false},
- {name: 'scan', displayName: 'Scan', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/scan"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Scan query executions', minWidth: 65, width: 80, enableFiltering: false, visible: false}
+ {name: 'execute', displayName: 'Execute', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/execute"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Query executions', minWidth: 98, width: 98, enableFiltering: false, visible: false},
+ {name: 'explain', displayName: 'Explain', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/explain"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Query explain executions', minWidth: 95, width: 95, enableFiltering: false, visible: false},
+ {name: 'scan', displayName: 'Scan', categoryDisplayName: 'Queries\' activities', field: 'activitiesDetail["/queries/scan"] || 0', type: 'number', cellClass: 'ui-grid-number-cell', headerTooltip: 'Scan query executions', minWidth: 80, width: 80, enableFiltering: false, visible: false}
];
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
index 0fc1cd6..0faa561 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.controller.js
@@ -28,10 +28,14 @@ const rowTemplate = `<div
role="{{col.isRowHeader ? 'rowheader' : 'gridcell'}}"
ui-grid-cell/>`;
+const treeAggregationFinalizerFn = function(agg) {
+ return agg.rendered = agg.value;
+};
+
export default class IgniteListOfRegisteredUsersCtrl {
- static $inject = ['$scope', '$state', '$filter', 'User', 'uiGridGroupingConstants', 'IgniteAdminData', 'IgniteNotebookData', 'IgniteConfirm', 'IgniteActivitiesUserDialog'];
+ static $inject = ['$scope', '$state', '$filter', 'User', 'uiGridGroupingConstants', 'uiGridPinningConstants', 'IgniteAdminData', 'IgniteNotebookData', 'IgniteConfirm', 'IgniteActivitiesUserDialog'];
- constructor($scope, $state, $filter, User, uiGridGroupingConstants, AdminData, NotebookData, Confirm, ActivitiesUserDialog) {
+ constructor($scope, $state, $filter, User, uiGridGroupingConstants, uiGridPinningConstants, AdminData, NotebookData, Confirm, ActivitiesUserDialog) {
const $ctrl = this;
const dtFilter = $filter('date');
@@ -45,6 +49,7 @@ export default class IgniteListOfRegisteredUsersCtrl {
endDate: new Date()
};
+ $ctrl.uiGridPinningConstants = uiGridPinningConstants;
$ctrl.uiGridGroupingConstants = uiGridGroupingConstants;
User.read().then((user) => $ctrl.user = user);
@@ -142,12 +147,12 @@ export default class IgniteListOfRegisteredUsersCtrl {
columnDefs,
categories,
+ treeRowHeaderAlwaysVisible: true,
headerTemplate,
columnVirtualizationThreshold: 30,
rowTemplate,
rowHeight: 46,
selectWithCheckboxOnly: true,
- selectionRowHeaderWidth: 52,
suppressRemoveSort: false,
enableFiltering: true,
enableSelectAll: true,
@@ -293,118 +298,118 @@ export default class IgniteListOfRegisteredUsersCtrl {
this.groupBy = 'user';
this.gridApi.grouping.clearGrouping();
- this.gridOptions.categories = this._userGridOptions.categories;
- this.gridOptions.columnDefs = this._userGridOptions.columnDefs;
+ this.gridApi.selection.clearSelectedRows();
+
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'company'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.NONE);
+ });
+
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'country'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.NONE);
+ });
+
+ this.gridOptions.categories = categories;
}
groupByCompany() {
this.groupBy = 'company';
this.gridApi.grouping.clearGrouping();
+ this.gridApi.selection.clearSelectedRows();
+
+ _.forEach(this.gridApi.grid.columns, (col) => {
+ col.enableSorting = true;
+
+ if (col.colDef.type !== 'number')
+ return;
+
+ this.gridApi.grouping.aggregateColumn(col.colDef.name, this.uiGridGroupingConstants.aggregation.SUM);
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
+ });
- this.gridApi.grouping.groupColumn('company');
this.gridApi.grouping.aggregateColumn('user', this.uiGridGroupingConstants.aggregation.COUNT);
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'user'}), (col) => {
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
+ });
- if (this._companyGridOptions) {
- this.gridOptions.categories = this._companyGridOptions.categories;
- this.gridOptions.columnDefs = this._companyGridOptions.columnDefs;
+ this.gridApi.grouping.aggregateColumn('lastactivity', this.uiGridGroupingConstants.aggregation.MAX);
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'lastactivity'}), (col) => {
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
+ });
- return;
- }
+ this.gridApi.grouping.groupColumn('company');
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'company'}), (col) => {
+ col.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.groupVal;
+ });
- const _categories = _.cloneDeep(categories);
- const _columnDefs = _.cloneDeep(columnDefs);
+ // Pinning left company.
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'company'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.LEFT);
+ });
+ // Unpinning country.
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'country'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.NONE);
+ });
+
+ const _categories = _.cloneDeep(categories);
// Cut company category.
const company = _categories.splice(3, 1)[0];
company.selectable = false;
- // Hide Actions category.
- _categories.splice(0, 1);
-
- _.forEach(_.filter(_columnDefs, {displayName: 'Actions'}), (col) => {
- col.visible = false;
- });
-
// Add company as first column.
_categories.unshift(company);
+ this.gridOptions.categories = _categories;
+ }
+
+ groupByCountry() {
+ this.groupBy = 'country';
+
+ this.gridApi.grouping.clearGrouping();
+ this.gridApi.selection.clearSelectedRows();
- _.forEach(_columnDefs, (col) => {
+ _.forEach(this.gridApi.grid.columns, (col) => {
col.enableSorting = true;
- if (col.type !== 'number')
+ if (col.colDef.type !== 'number')
return;
- col.treeAggregationType = this.uiGridGroupingConstants.aggregation.SUM;
- col.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.value;
+ this.gridApi.grouping.aggregateColumn(col.colDef.name, this.uiGridGroupingConstants.aggregation.SUM);
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
});
- // Set grouping to last activity column.
- const lastactivity = _.find(_columnDefs, { name: 'lastactivity' });
-
- if (_.nonNil(lastactivity)) {
- lastactivity.treeAggregationType = this.uiGridGroupingConstants.aggregation.MAX;
- lastactivity.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.value;
- }
-
- this._companyGridOptions = {
- categories: this.gridOptions.categories = _categories,
- columnDefs: this.gridOptions.columnDefs = _columnDefs
- };
- }
+ this.gridApi.grouping.aggregateColumn('user', this.uiGridGroupingConstants.aggregation.COUNT);
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'user'}), (col) => {
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
+ });
- groupByCountry() {
- this.groupBy = 'country';
+ this.gridApi.grouping.aggregateColumn('lastactivity', this.uiGridGroupingConstants.aggregation.MAX);
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'lastactivity'}), (col) => {
+ col.customTreeAggregationFinalizerFn = treeAggregationFinalizerFn;
+ });
- this.gridApi.grouping.clearGrouping();
this.gridApi.grouping.groupColumn('country');
- this.gridApi.grouping.aggregateColumn('user', this.uiGridGroupingConstants.aggregation.COUNT);
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'country'}), (col) => {
+ col.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.groupVal;
+ });
- if (this._countryGridOptions) {
- this.gridOptions.categories = this._countryGridOptions.categories;
- this.gridOptions.columnDefs = this._countryGridOptions.columnDefs;
+ // Pinning left country.
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'country'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.LEFT);
+ });
- return;
- }
+ // Unpinning country.
+ _.forEach(_.filter(this.gridApi.grid.columns, {name: 'company'}), (col) => {
+ this.gridApi.pinning.pinColumn(col, this.uiGridPinningConstants.container.NONE);
+ });
const _categories = _.cloneDeep(categories);
- const _columnDefs = _.cloneDeep(columnDefs);
-
- // Cut country category.
+ // Cut company category.
const country = _categories.splice(4, 1)[0];
country.selectable = false;
- // Hide Actions category.
- _categories.splice(0, 1);
-
- _.forEach(_.filter(_columnDefs, {displayName: 'Actions'}), (col) => {
- col.visible = false;
- });
-
// Add company as first column.
_categories.unshift(country);
-
- _.forEach(_columnDefs, (col) => {
- col.enableSorting = true;
-
- if (col.type !== 'number')
- return;
-
- col.treeAggregationType = this.uiGridGroupingConstants.aggregation.SUM;
- col.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.value;
- });
-
- // Set grouping to last activity column.
- const lastactivity = _.find(_columnDefs, { name: 'lastactivity' });
-
- if (_.nonNil(lastactivity)) {
- lastactivity.treeAggregationType = this.uiGridGroupingConstants.aggregation.MAX;
- lastactivity.customTreeAggregationFinalizerFn = (agg) => agg.rendered = agg.value;
- }
-
- this._countryGridOptions = {
- categories: this.gridOptions.categories = _categories,
- columnDefs: this.gridOptions.columnDefs = _columnDefs
- };
+ this.gridOptions.categories = _categories;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
index 0b8bf7e..b64a177 100644
--- a/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
+++ b/modules/web-console/frontend/app/components/list-of-registered-users/list-of-registered-users.tpl.pug
@@ -18,7 +18,7 @@ include /app/helpers/jade/mixins
mixin grid-settings()
.grid-settings
- i.fa.fa-cog(data-animation='am-flip-x' bs-dropdown='' aria-haspopup='true' aria-expanded='expanded' data-auto-close='1' data-trigger='click')
+ i.fa.gear-icon(data-animation='am-flip-x' bs-dropdown='' aria-haspopup='true' aria-expanded='expanded' data-auto-close='1' data-trigger='click')
ul.select.dropdown-menu(role='menu')
li
a(ng-click='$ctrl.gridOptions.selectedAll ? $ctrl.clearAllColumns() : $ctrl.selectAllColumns()')
@@ -51,13 +51,10 @@ mixin grid-settings()
.panel--ignite
.panel-heading.ui-grid-settings
- .panel-title(ng-hide='$ctrl.selected.length')
- span(ng-if='$ctrl.groupBy === "user"') List of registered users
- span(ng-if='$ctrl.groupBy === "company"') List of registered companies
- span(ng-if='$ctrl.groupBy === "country"') List of registered countries
- +grid-settings
- button.btn.btn--stroke(ng-click='$ctrl.exportCsv()' bs-tooltip data-title='Export table to csv')
- i.fa.fa-file-excel-o.export-icon
+ .panel-title
+ +ignite-form-field-bsdropdown('Actions', '$ctrl.action', 'action', '!$ctrl.selected.length', false, '$ctrl.actionOptions')
+ button.btn.btn--stroke(ng-click='$ctrl.exportCsv()' bs-tooltip='' data-title='Export table to csv' data-placement='top')
+ i.fa.export-icon
form.ui-grid-settings-dateperiod(name=form novalidate)
-var form = 'admin'
+ignite-form-field-datepicker('Period: from', '$ctrl.params.startDate', '"startDate"', null, '$ctrl.params.endDate')
@@ -66,11 +63,13 @@ mixin grid-settings()
-var form = 'admin'
+ignite-form-field-text('Exclude:', '$ctrl.params.companiesExclude', '"exclude"', false, false, 'Exclude by company name...')
- .panel-selected(ng-show='$ctrl.selected.length')
- .pull-right
- +ignite-form-field-bsdropdown('Actions', '$ctrl.action', 'action', false, false, '$ctrl.actionOptions')
- div
- | {{ $ctrl.selected.length }} item{{ $ctrl.selected.length > 1 ? 's' : '' }} selected
+ .ui-grid-settings--heading(ng-hide='$ctrl.selected.length')
+ span(ng-if='$ctrl.groupBy === "user"') List of registered users
+ span(ng-if='$ctrl.groupBy === "company"') List of registered companies
+ span(ng-if='$ctrl.groupBy === "country"') List of registered countries
+ +grid-settings
+ .panel-selected(ng-show='$ctrl.selected.length')
+ | {{ $ctrl.selected.length }} item{{ $ctrl.selected.length > 1 ? 's' : '' }} selected
.panel-collapse
.grid.ui-grid--ignite(ui-grid='$ctrl.gridOptions' ui-grid-resize-columns ui-grid-selection ui-grid-exporter ui-grid-pinning ui-grid-grouping)
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/badge/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/badge/index.scss b/modules/web-console/frontend/app/primitives/badge/index.scss
index 8ce477f..79082e0 100644
--- a/modules/web-console/frontend/app/primitives/badge/index.scss
+++ b/modules/web-console/frontend/app/primitives/badge/index.scss
@@ -29,6 +29,7 @@
color: white;
font-family: Roboto;
font-size: 12px;
+ font-weight: 500;
text-align: center;
line-height: 12px;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/btn/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/btn/index.scss b/modules/web-console/frontend/app/primitives/btn/index.scss
index 1eb027f..ec62df4 100644
--- a/modules/web-console/frontend/app/primitives/btn/index.scss
+++ b/modules/web-console/frontend/app/primitives/btn/index.scss
@@ -19,23 +19,39 @@
min-width: 36px;
height: 36px;
- line-height: 36px;
+ line-height: 34px;
text-align: center;
color: #ee2b27;
border: 1px solid #ee2b27;
background: initial;
+ i {
+ margin: 0;
+
+ &.export-icon {
+ display: block;
+ width: 16px;
+ height: 16px;
+ margin: auto;
+
+ background-image: url('/images/icons/export.svg');
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+ }
+
&:hover, &:focus {
color: #a8110f;
border-color: #a8110f;
+
+ i {
+ filter: hue-rotate(1deg) saturate(85) brightness(.66);
+ }
}
&:focus {
outline: none;
}
- i {
- margin: 0;
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/dropdown/index.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/dropdown/index.pug b/modules/web-console/frontend/app/primitives/dropdown/index.pug
index a6476eb..dfd229c 100644
--- a/modules/web-console/frontend/app/primitives/dropdown/index.pug
+++ b/modules/web-console/frontend/app/primitives/dropdown/index.pug
@@ -32,7 +32,7 @@ mixin ignite-form-field-bsdropdown(label, model, name, disabled, required, optio
tabindex='0'
aria-haspopup='true'
aria-expanded='false'
- )&attributes(attributes.attributes)
+ )&attributes(attributes)
a.dropdown-toggle
span !{label}
span.caret
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/dropdown/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/dropdown/index.scss b/modules/web-console/frontend/app/primitives/dropdown/index.scss
index e474534..adf87ca 100644
--- a/modules/web-console/frontend/app/primitives/dropdown/index.scss
+++ b/modules/web-console/frontend/app/primitives/dropdown/index.scss
@@ -29,6 +29,8 @@
.ignite-form-field__control {
outline: none;
+ font-size: 14px;
+
& > a {
display: inline-block;
height: 36px;
@@ -39,7 +41,7 @@
border-radius: 4px;
color: #de4538;
- line-height: 36px;
+ line-height: 34px;
.caret {
margin-left: 9px;
@@ -78,5 +80,27 @@
border-bottom: 1px solid #dddddd;
}
}
+
+ &[disabled='disabled'] {
+ opacity: .5;
+
+ & > a {
+ border-color: #c5c5c5;
+
+ color: #393939;
+ }
+
+ &:hover, &:focus {
+ & > a {
+ border-color: #c5c5c5;
+
+ color: #393939;
+ }
+ }
+
+ ul {
+ display: none !important;
+ }
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/panel/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/panel/index.scss b/modules/web-console/frontend/app/primitives/panel/index.scss
index 826d33e..d6cae27 100644
--- a/modules/web-console/frontend/app/primitives/panel/index.scss
+++ b/modules/web-console/frontend/app/primitives/panel/index.scss
@@ -19,7 +19,7 @@
.panel--ignite {
border: none;
- border-radius: 0;
+ border-radius: 0 0 4px 4px;
font-family: Roboto;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/ui-grid-header/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/ui-grid-header/index.scss b/modules/web-console/frontend/app/primitives/ui-grid-header/index.scss
index 4530c02..7b3ce7b 100644
--- a/modules/web-console/frontend/app/primitives/ui-grid-header/index.scss
+++ b/modules/web-console/frontend/app/primitives/ui-grid-header/index.scss
@@ -15,7 +15,11 @@
* limitations under the License.
*/
+@import '../../../public/stylesheets/variables';
+
.ui-grid-header--subcategories {
+ border-color: $table-border-color;
+
.ui-grid-row:nth-child(even) .ui-grid-cell.cell-total {
background-color: rgba(102,175,233,.6);
}
@@ -34,6 +38,10 @@
}
}
+ .ui-grid-header-cell:last-child .ui-grid-column-resizer.right {
+ border-color: $table-border-color;
+ }
+
.ui-grid-header-cell [role="columnheader"] {
display: flex;
@@ -81,7 +89,7 @@
}
& > div > .ui-grid-cell-contents {
- border-bottom: 1px solid #d4d4d4;
+ border-bottom: 1px solid $table-border-color;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/ui-grid-header/index.tpl.pug
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/ui-grid-header/index.tpl.pug b/modules/web-console/frontend/app/primitives/ui-grid-header/index.tpl.pug
index 1b91d9e..8a41881 100644
--- a/modules/web-console/frontend/app/primitives/ui-grid-header/index.tpl.pug
+++ b/modules/web-console/frontend/app/primitives/ui-grid-header/index.tpl.pug
@@ -20,10 +20,18 @@
.ui-grid-header-canvas
.ui-grid-header-cell-wrapper(ng-style='colContainer.headerCellWrapperStyle()')
.ui-grid-header-cell-row(role='row')
+ .ui-grid-header-cell.ui-grid-clearfix(
+ ng-if='col.colDef.name === "treeBaseRowHeaderCol" || col.colDef.name === "selectionRowHeaderCol"'
+ ng-repeat='col in colContainer.renderedColumns track by col.uid'
+ ng-class='{ disabled: !grid.options.multiSelect && col.colDef.name === "selectionRowHeaderCol"}'
+
+ col='col'
+ ui-grid-header-cell=''
+ render-index='$index'
+ )
.ui-grid-header-span.ui-grid-header-cell.ui-grid-clearfix.ui-grid-category(ng-repeat='cat in grid.options.categories', ng-if='cat.visible && \
(colContainer.renderedColumns | uiGridSubcategories: cat.name).length > 0')
div(ng-show='(colContainer.renderedColumns|uiGridSubcategories:cat.name).length > 1')
.ui-grid-cell-contents {{ cat.name }}
.ui-grid-header-cell-row
.ui-grid-header-cell.ui-grid-clearfix(ng-repeat='col in (colContainer.renderedColumns|uiGridSubcategories:cat.name) track by col.uid' ui-grid-header-cell='' col='col' render-index='$index')
- .ui-grid-header-cell.ui-grid-clearfix(ng-if='col.colDef.name === "treeBaseRowHeaderCol" || col.colDef.name === "selectionRowHeaderCol"' ng-repeat='col in colContainer.renderedColumns track by col.uid' ui-grid-header-cell='' col='col' render-index='$index' ng-class='{ disabled: !grid.options.multiSelect && col.colDef.name === "selectionRowHeaderCol"}')
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/ui-grid-settings/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/ui-grid-settings/index.scss b/modules/web-console/frontend/app/primitives/ui-grid-settings/index.scss
index 3519eb2..9cd497f 100644
--- a/modules/web-console/frontend/app/primitives/ui-grid-settings/index.scss
+++ b/modules/web-console/frontend/app/primitives/ui-grid-settings/index.scss
@@ -16,6 +16,8 @@
*/
.ui-grid-settings {
+ color: #393939;
+
ul.select.dropdown-menu {
padding: 0;
@@ -63,7 +65,7 @@
content: '';
position: absolute;
- top: 0px;
+ top: 0;
left: 3px;
width: 4px;
@@ -83,17 +85,16 @@
}
}
- .btn {
- float: right;
+ &--heading > span {
+ position: relative;
+ top: -1px;
+ }
+ .btn {
line-height: 20px;
- margin-right: 0;
}
&-filter {
- float: right;
- margin-right: 35px;
-
.ignite-form-field {
$height: 36px;
@@ -123,8 +124,6 @@
}
&-number-filter {
- float: right;
-
.ignite-form-field {
width: 180px;
margin-right: 0;
@@ -158,14 +157,51 @@
}
&-dateperiod {
- float: right;
display: block;
margin-right: 35px;
}
+
+ .btn.btn--stroke,
+ .dropdown--ignite.ignite-form-field,
+ &-filter,
+ &-number-filter,
+ &-dateperiod {
+ float: right;
+
+ margin-left: 20px;
+ margin-right: 0;
+ }
+
+ &-dateperiod {
+ margin-left: 15px;
+ margin-right: -5px;
+ }
+
+ .grid-settings {
+ i.gear-icon {
+ position: relative;
+ top: 2px;
+
+ display: block;
+ width: 16px;
+ height: 16px;
+ margin: auto;
+
+ background-image: url('/images/icons/gear.svg');
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+
+ &:hover, &:focus {
+ i.gear-icon {
+ filter: hue-rotate(1deg) saturate(85) brightness(.66);
+ }
+ }
+ }
}
.grid-settings {
display: inline-block;
margin-left: 10px;
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/app/primitives/ui-grid/index.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/primitives/ui-grid/index.scss b/modules/web-console/frontend/app/primitives/ui-grid/index.scss
index 8e2fbaa..89e5c49 100644
--- a/modules/web-console/frontend/app/primitives/ui-grid/index.scss
+++ b/modules/web-console/frontend/app/primitives/ui-grid/index.scss
@@ -40,10 +40,19 @@
border-color: transparent;
}
- .ui-grid-cell-contents {
- font-family: Roboto;
+ .ui-grid-cell,
+ .ui-grid-header-cell {
+ .ui-grid-cell-contents {
+ padding: 13px 20px;
- padding: 13px 20px;
+ text-align: left;
+ font-family: Roboto;
+ }
+ }
+
+ .ui-grid-contents-wrapper {
+ border-bottom-right-radius: 6px;
+ overflow: hidden;
}
.ui-grid-render-container-body {
@@ -57,12 +66,6 @@
text-align: right;
}
}
-
- &:first-child {
- .ui-grid-cell-contents {
- padding-left: 0;
- }
- }
}
}
@@ -70,19 +73,6 @@
.ui-grid-header-span {
background: initial;
- &:first-child {
- .ui-grid-cell-contents {
- padding-left: 0;
- }
-
- .ng-hide + .ui-grid-header-cell-row {
- .ui-grid-cell-contents,
- .ui-grid-filter-container {
- padding-left: 0;
- }
- }
- }
-
.ui-grid-cell-contents {
color: $gray-light;
font-size: 14px;
@@ -141,21 +131,31 @@
width: auto;
}
}
+
+ &:before {
+ content: '';
+
+ position: absolute;
+ top: 0;
+ right: 9px;
+ z-index: 1000;
+
+ width: 5px;
+ height: 100%;
+
+ opacity: .2;
+ box-shadow: 2px 0 3px #000;
+ border-right: 1px solid #000;
+ }
}
}
}
.ui-grid-pinned-container-left .ui-grid-header-cell:last-child {
- max-width: 52px;
- min-width: 52px;
-
border-width: 0;
}
.ui-grid-pinned-container-left .ui-grid-cell:last-child {
- min-width: 52px;
- max-width: 52px;
-
border-width: 0;
background-color: initial;
}
@@ -182,7 +182,7 @@
&.ui-grid-row-selected > [ui-grid-row] > .ui-grid-cell {
background-color: #e5f2f9;
- box-shadow: 0 -1px 0 0 rgba(117, 117, 117, 0.25), 0 1px 0 0 rgba(117, 117, 117, 0.25);
+ box-shadow: 0 -1px 0 0 #c6cfd8, 0 1px 0 0 #c6cfd8;
}
}
@@ -305,15 +305,23 @@
.ui-grid-header-cell-row {
.ui-grid-header-cell {
border-right: none;
- padding-top: 12px;
&.disabled {
- opacity: .5;
+ opacity: .2;
.ui-grid-icon-ok {
cursor: default;
}
}
+
+ &:last-child {
+ .ui-grid-header-cell {
+ .ui-grid-column-resizer {
+ right: -1px;
+ opacity: 0;
+ }
+ }
+ }
}
}
}
@@ -322,8 +330,87 @@
.ui-grid-row {
.ui-grid-cell {
border-bottom: none;
+
+ &:nth-child(2) {
+ overflow: visible;
+ }
+ }
+ }
+ }
+
+ .ui-grid-tree-header-row {
+ .ui-grid-selection-row-header-buttons {
+ opacity: .2;
+ cursor: default;
+ }
+
+ & ~ .ui-grid-row:not(.ui-grid-tree-header-row) {
+ position: relative;
+
+ &::before {
+ content: '';
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: 1;
+
+ width: 4px;
+ height: 46px;
+
+ background: #0067b9;
+ box-shadow: 0 -1px 0 0 rgba(0, 0, 0, .3), 0 -1px 0 0 rgba(0, 103, 185, 1);
}
}
}
}
+
+ .ui-grid-tree-header-row {
+ font-weight: normal !important;
+ }
+
+ input[type="text"].ui-grid-filter-input {
+ display: block;
+ width: 100%;
+ height: 28px;
+ padding: 3px 3px;
+
+ border: 1px solid #ccc;
+ border-radius: 4px;
+ background-color: #fff;
+ background-image: none;
+
+ color: #393939;
+ text-align: left;
+ font-size: 14px;
+ line-height: 1.42857;
+
+ box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
+ transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s;
+
+ &::placeholder {
+ color: #999;
+ }
+
+ &:focus {
+ outline: none;
+
+ box-shadow: none;
+ border-color: #66afe9;
+ }
+ }
+
+ .ui-grid-icon-cancel {
+ &:before {
+ content: '';
+
+ display: block;
+ width: 16px;
+ height: 16px;
+ margin: 8px 5px;
+
+ background-image: url('/images/icons/cross.svg');
+ background-repeat: no-repeat;
+ background-position: center;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/gulpfile.babel.js/paths.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/paths.js b/modules/web-console/frontend/gulpfile.babel.js/paths.js
index 627b2f9..92b354a 100644
--- a/modules/web-console/frontend/gulpfile.babel.js/paths.js
+++ b/modules/web-console/frontend/gulpfile.babel.js/paths.js
@@ -39,6 +39,7 @@ const appModulePaths = [
];
const resourcePaths = [
+ './public/**/*.svg',
'./public/**/*.png',
'./public/*.ico'
];
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js b/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
index ac3ac76..07244b9 100644
--- a/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
+++ b/modules/web-console/frontend/gulpfile.babel.js/tasks/bundle.js
@@ -28,7 +28,7 @@ gulp.task('bundle', (cb) => {
if (process.env.NODE_ENV === 'development') {
// Important! Call webpack and WebpackDevServer must be inline.
new WebpackDevServer(webpack(webpackConfig), devServerConfig)
- .listen(devServerConfig.port, 'localhost', cb);
+ .listen(devServerConfig.port, devServerConfig.host || 'localhost', cb);
}
else
webpack(webpackConfig, cb);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js b/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
index c837c43..87094a8 100644
--- a/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
+++ b/modules/web-console/frontend/gulpfile.babel.js/webpack/environments/development.js
@@ -18,7 +18,8 @@
import {destDir} from '../../paths';
const backendPort = 3000;
-const devServerPort = 9000;
+const devServerPort = process.env.PORT || 9000;
+const devServerHost = process.env.HOST;
export default {
devtool: 'source-map',
@@ -56,6 +57,7 @@ export default {
colors: true,
chunks: false
},
+ host: devServerHost,
port: devServerPort
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/public/images/icons/cross.svg
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/images/icons/cross.svg b/modules/web-console/frontend/public/images/icons/cross.svg
new file mode 100644
index 0000000..1a10375
--- /dev/null
+++ b/modules/web-console/frontend/public/images/icons/cross.svg
@@ -0,0 +1 @@
+<svg id="cross-icon" width="12" height="12" viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg"><path fill="#757575" d="M10.791 0L6 4.791 1.209 0 0 1.209 4.791 6 0 10.791 1.209 12 6 7.209 10.791 12 12 10.791 7.209 6 12 1.209z" fill-rule="evenodd"/></svg>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/public/images/icons/export.svg
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/images/icons/export.svg b/modules/web-console/frontend/public/images/icons/export.svg
new file mode 100644
index 0000000..359c3df
--- /dev/null
+++ b/modules/web-console/frontend/public/images/icons/export.svg
@@ -0,0 +1 @@
+<svg id="export-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#ee2b27" d="M10.4 61.6v380.8l280.1 49.8V11.8L10.4 61.6zm161 270.5l-23.5-61.7-23.1 58.5H92.7l37.5-81.6-34.8-80h33l21.3 55.2 25.3-59.9 31.7-1.6-39.6 85.5 41.2 88.3-36.9-2.7zM489.3 61.1H300v27.8h71.2V139H300v15.1h71.2v50.1H300v15.1h71.2v50.1H300v15.1h71.2v50.2H300v15.4h71.2v50.1H300v32.2h189.3c5.4 0 9.7-4.5 9.7-10V71.2c0-5.6-4.4-10.1-9.7-10.1zm-23.1 339.2h-80.3v-50.1h80.3v50.1zm0-65.5h-80.3v-50.2h80.3v50.2zm0-65.2h-80.3v-50.1h80.3v50.1zm0-65.3h-80.3v-50.2h80.3v50.2zm0-65.2h-80.3V88.9h80.3v50.2z"/></svg>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/public/images/icons/gear.svg
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/images/icons/gear.svg b/modules/web-console/frontend/public/images/icons/gear.svg
new file mode 100644
index 0000000..a9a7269
--- /dev/null
+++ b/modules/web-console/frontend/public/images/icons/gear.svg
@@ -0,0 +1 @@
+<svg id="gear-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><style>.st0{fill:#424242}</style><path class="st0" d="M14.1 8.8c0-.3.1-.5.1-.8 0-.3 0-.5-.1-.8l1.7-1.3c.2-.1.2-.3.1-.5l-1.6-2.8c-.1-.2-.3-.2-.5-.2l-2 .8c-.4-.3-.9-.6-1.4-.8L10.1.3C10 .1 9.8 0 9.6 0H6.4c-.3 0-.4.1-.5.3l-.3 2.2c-.5.2-1 .5-1.4.8l-2-.8c-.2-.1-.4-.1-.5.1L.1 5.4c-.1.2-.1.4.1.5l1.7 1.3c0 .3-.1.5-.1.8 0 .3 0 .5.1.8L.2 10.1c-.2.1-.2.3-.1.5l1.6 2.8c.1.2.3.2.5.2l2-.8c.4.3.9.6 1.4.8l.3 2.1c.1.2.2.3.5.3h3.3c.2 0 .4-.1.4-.3l.3-2.1c.5-.2 1-.5 1.4-.8l2 .8c.2.1.4 0 .5-.2l1.6-2.8c.1-.2.1-.4-.1-.5l-1.7-1.3zM8 11c-1.7 0-3-1.3-3-3s1.3-3 3-3 3 1.3 3 3-1.3 3-3 3z"/></svg>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss b/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss
index e308de3..d6a51e3 100644
--- a/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss
+++ b/modules/web-console/frontend/public/stylesheets/_bootstrap-variables.scss
@@ -29,7 +29,7 @@ $gray-base: #000 !default;
$gray-darker: lighten($gray-base, 13.5%) !default; // #222
$gray-dark: lighten($gray-base, 20%) !default; // #333
$gray: lighten($gray-base, 33.5%) !default; // #555
-$gray-light: lighten($gray-base, 46.7%) !default; // #777
+$gray-light: lighten($gray-base, 46%) !default; // #757575
$gray-lighter: lighten($gray-base, 93.5%) !default; // #eee
$brand-primary: #ec1c24 !default;
@@ -46,7 +46,7 @@ $brand-danger: #d9534f !default;
//** Background color for `<body>`.
$body-bg: #f9f9f9 !default;
//** Global text color on `<body>`.
-$text-color: $gray-dark !default;
+$text-color: #393939 !default;
//** Global textual link color.
$link-color: $brand-primary !default;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c829aaca/modules/web-console/licenses/cc-by-3.0.txt
----------------------------------------------------------------------
diff --git a/modules/web-console/licenses/cc-by-3.0.txt b/modules/web-console/licenses/cc-by-3.0.txt
new file mode 100644
index 0000000..bd32fa8
--- /dev/null
+++ b/modules/web-console/licenses/cc-by-3.0.txt
@@ -0,0 +1,319 @@
+Creative Commons Legal Code
+
+Attribution 3.0 Unported
+
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+ LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+ REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
+ DAMAGES RESULTING FROM ITS USE.
+
+License
+
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
+COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
+COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
+AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
+
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
+TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
+BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
+CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
+CONDITIONS.
+
+1. Definitions
+
+ a. "Adaptation" means a work based upon the Work, or upon the Work and
+ other pre-existing works, such as a translation, adaptation,
+ derivative work, arrangement of music or other alterations of a
+ literary or artistic work, or phonogram or performance and includes
+ cinematographic adaptations or any other form in which the Work may be
+ recast, transformed, or adapted including in any form recognizably
+ derived from the original, except that a work that constitutes a
+ Collection will not be considered an Adaptation for the purpose of
+ this License. For the avoidance of doubt, where the Work is a musical
+ work, performance or phonogram, the synchronization of the Work in
+ timed-relation with a moving image ("synching") will be considered an
+ Adaptation for the purpose of this License.
+ b. "Collection" means a collection of literary or artistic works, such as
+ encyclopedias and anthologies, or performances, phonograms or
+ broadcasts, or other works or subject matter other than works listed
+ in Section 1(f) below, which, by reason of the selection and
+ arrangement of their contents, constitute intellectual creations, in
+ which the Work is included in its entirety in unmodified form along
+ with one or more other contributions, each constituting separate and
+ independent works in themselves, which together are assembled into a
+ collective whole. A work that constitutes a Collection will not be
+ considered an Adaptation (as defined above) for the purposes of this
+ License.
+ c. "Distribute" means to make available to the public the original and
+ copies of the Work or Adaptation, as appropriate, through sale or
+ other transfer of ownership.
+ d. "Licensor" means the individual, individuals, entity or entities that
+ offer(s) the Work under the terms of this License.
+ e. "Original Author" means, in the case of a literary or artistic work,
+ the individual, individuals, entity or entities who created the Work
+ or if no individual or entity can be identified, the publisher; and in
+ addition (i) in the case of a performance the actors, singers,
+ musicians, dancers, and other persons who act, sing, deliver, declaim,
+ play in, interpret or otherwise perform literary or artistic works or
+ expressions of folklore; (ii) in the case of a phonogram the producer
+ being the person or legal entity who first fixes the sounds of a
+ performance or other sounds; and, (iii) in the case of broadcasts, the
+ organization that transmits the broadcast.
+ f. "Work" means the literary and/or artistic work offered under the terms
+ of this License including without limitation any production in the
+ literary, scientific and artistic domain, whatever may be the mode or
+ form of its expression including digital form, such as a book,
+ pamphlet and other writing; a lecture, address, sermon or other work
+ of the same nature; a dramatic or dramatico-musical work; a
+ choreographic work or entertainment in dumb show; a musical
+ composition with or without words; a cinematographic work to which are
+ assimilated works expressed by a process analogous to cinematography;
+ a work of drawing, painting, architecture, sculpture, engraving or
+ lithography; a photographic work to which are assimilated works
+ expressed by a process analogous to photography; a work of applied
+ art; an illustration, map, plan, sketch or three-dimensional work
+ relative to geography, topography, architecture or science; a
+ performance; a broadcast; a phonogram; a compilation of data to the
+ extent it is protected as a copyrightable work; or a work performed by
+ a variety or circus performer to the extent it is not otherwise
+ considered a literary or artistic work.
+ g. "You" means an individual or entity exercising rights under this
+ License who has not previously violated the terms of this License with
+ respect to the Work, or who has received express permission from the
+ Licensor to exercise rights under this License despite a previous
+ violation.
+ h. "Publicly Perform" means to perform public recitations of the Work and
+ to communicate to the public those public recitations, by any means or
+ process, including by wire or wireless means or public digital
+ performances; to make available to the public Works in such a way that
+ members of the public may access these Works from a place and at a
+ place individually chosen by them; to perform the Work to the public
+ by any means or process and the communication to the public of the
+ performances of the Work, including by public digital performance; to
+ broadcast and rebroadcast the Work by any means including signs,
+ sounds or images.
+ i. "Reproduce" means to make copies of the Work by any means including
+ without limitation by sound or visual recordings and the right of
+ fixation and reproducing fixations of the Work, including storage of a
+ protected performance or phonogram in digital form or other electronic
+ medium.
+
+2. Fair Dealing Rights. Nothing in this License is intended to reduce,
+limit, or restrict any uses free from copyright or rights arising from
+limitations or exceptions that are provided for in connection with the
+copyright protection under copyright law or other applicable laws.
+
+3. License Grant. Subject to the terms and conditions of this License,
+Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
+perpetual (for the duration of the applicable copyright) license to
+exercise the rights in the Work as stated below:
+
+ a. to Reproduce the Work, to incorporate the Work into one or more
+ Collections, and to Reproduce the Work as incorporated in the
+ Collections;
+ b. to create and Reproduce Adaptations provided that any such Adaptation,
+ including any translation in any medium, takes reasonable steps to
+ clearly label, demarcate or otherwise identify that changes were made
+ to the original Work. For example, a translation could be marked "The
+ original work was translated from English to Spanish," or a
+ modification could indicate "The original work has been modified.";
+ c. to Distribute and Publicly Perform the Work including as incorporated
+ in Collections; and,
+ d. to Distribute and Publicly Perform Adaptations.
+ e. For the avoidance of doubt:
+
+ i. Non-waivable Compulsory License Schemes. In those jurisdictions in
+ which the right to collect royalties through any statutory or
+ compulsory licensing scheme cannot be waived, the Licensor
+ reserves the exclusive right to collect such royalties for any
+ exercise by You of the rights granted under this License;
+ ii. Waivable Compulsory License Schemes. In those jurisdictions in
+ which the right to collect royalties through any statutory or
+ compulsory licensing scheme can be waived, the Licensor waives the
+ exclusive right to collect such royalties for any exercise by You
+ of the rights granted under this License; and,
+ iii. Voluntary License Schemes. The Licensor waives the right to
+ collect royalties, whether individually or, in the event that the
+ Licensor is a member of a collecting society that administers
+ voluntary licensing schemes, via that society, from any exercise
+ by You of the rights granted under this License.
+
+The above rights may be exercised in all media and formats whether now
+known or hereafter devised. The above rights include the right to make
+such modifications as are technically necessary to exercise the rights in
+other media and formats. Subject to Section 8(f), all rights not expressly
+granted by Licensor are hereby reserved.
+
+4. Restrictions. The license granted in Section 3 above is expressly made
+subject to and limited by the following restrictions:
+
+ a. You may Distribute or Publicly Perform the Work only under the terms
+ of this License. You must include a copy of, or the Uniform Resource
+ Identifier (URI) for, this License with every copy of the Work You
+ Distribute or Publicly Perform. You may not offer or impose any terms
+ on the Work that restrict the terms of this License or the ability of
+ the recipient of the Work to exercise the rights granted to that
+ recipient under the terms of the License. You may not sublicense the
+ Work. You must keep intact all notices that refer to this License and
+ to the disclaimer of warranties with every copy of the Work You
+ Distribute or Publicly Perform. When You Distribute or Publicly
+ Perform the Work, You may not impose any effective technological
+ measures on the Work that restrict the ability of a recipient of the
+ Work from You to exercise the rights granted to that recipient under
+ the terms of the License. This Section 4(a) applies to the Work as
+ incorporated in a Collection, but this does not require the Collection
+ apart from the Work itself to be made subject to the terms of this
+ License. If You create a Collection, upon notice from any Licensor You
+ must, to the extent practicable, remove from the Collection any credit
+ as required by Section 4(b), as requested. If You create an
+ Adaptation, upon notice from any Licensor You must, to the extent
+ practicable, remove from the Adaptation any credit as required by
+ Section 4(b), as requested.
+ b. If You Distribute, or Publicly Perform the Work or any Adaptations or
+ Collections, You must, unless a request has been made pursuant to
+ Section 4(a), keep intact all copyright notices for the Work and
+ provide, reasonable to the medium or means You are utilizing: (i) the
+ name of the Original Author (or pseudonym, if applicable) if supplied,
+ and/or if the Original Author and/or Licensor designate another party
+ or parties (e.g., a sponsor institute, publishing entity, journal) for
+ attribution ("Attribution Parties") in Licensor's copyright notice,
+ terms of service or by other reasonable means, the name of such party
+ or parties; (ii) the title of the Work if supplied; (iii) to the
+ extent reasonably practicable, the URI, if any, that Licensor
+ specifies to be associated with the Work, unless such URI does not
+ refer to the copyright notice or licensing information for the Work;
+ and (iv) , consistent with Section 3(b), in the case of an Adaptation,
+ a credit identifying the use of the Work in the Adaptation (e.g.,
+ "French translation of the Work by Original Author," or "Screenplay
+ based on original Work by Original Author"). The credit required by
+ this Section 4 (b) may be implemented in any reasonable manner;
+ provided, however, that in the case of a Adaptation or Collection, at
+ a minimum such credit will appear, if a credit for all contributing
+ authors of the Adaptation or Collection appears, then as part of these
+ credits and in a manner at least as prominent as the credits for the
+ other contributing authors. For the avoidance of doubt, You may only
+ use the credit required by this Section for the purpose of attribution
+ in the manner set out above and, by exercising Your rights under this
+ License, You may not implicitly or explicitly assert or imply any
+ connection with, sponsorship or endorsement by the Original Author,
+ Licensor and/or Attribution Parties, as appropriate, of You or Your
+ use of the Work, without the separate, express prior written
+ permission of the Original Author, Licensor and/or Attribution
+ Parties.
+ c. Except as otherwise agreed in writing by the Licensor or as may be
+ otherwise permitted by applicable law, if You Reproduce, Distribute or
+ Publicly Perform the Work either by itself or as part of any
+ Adaptations or Collections, You must not distort, mutilate, modify or
+ take other derogatory action in relation to the Work which would be
+ prejudicial to the Original Author's honor or reputation. Licensor
+ agrees that in those jurisdictions (e.g. Japan), in which any exercise
+ of the right granted in Section 3(b) of this License (the right to
+ make Adaptations) would be deemed to be a distortion, mutilation,
+ modification or other derogatory action prejudicial to the Original
+ Author's honor and reputation, the Licensor will waive or not assert,
+ as appropriate, this Section, to the fullest extent permitted by the
+ applicable national law, to enable You to reasonably exercise Your
+ right under Section 3(b) of this License (right to make Adaptations)
+ but not otherwise.
+
+5. Representations, Warranties and Disclaimer
+
+UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
+OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
+KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
+INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
+FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
+LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
+WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
+OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
+
+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
+LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
+ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
+ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. Termination
+
+ a. This License and the rights granted hereunder will terminate
+ automatically upon any breach by You of the terms of this License.
+ Individuals or entities who have received Adaptations or Collections
+ from You under this License, however, will not have their licenses
+ terminated provided such individuals or entities remain in full
+ compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
+ survive any termination of this License.
+ b. Subject to the above terms and conditions, the license granted here is
+ perpetual (for the duration of the applicable copyright in the Work).
+ Notwithstanding the above, Licensor reserves the right to release the
+ Work under different license terms or to stop distributing the Work at
+ any time; provided, however that any such election will not serve to
+ withdraw this License (or any other license that has been, or is
+ required to be, granted under the terms of this License), and this
+ License will continue in full force and effect unless terminated as
+ stated above.
+
+8. Miscellaneous
+
+ a. Each time You Distribute or Publicly Perform the Work or a Collection,
+ the Licensor offers to the recipient a license to the Work on the same
+ terms and conditions as the license granted to You under this License.
+ b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
+ offers to the recipient a license to the original Work on the same
+ terms and conditions as the license granted to You under this License.
+ c. If any provision of this License is invalid or unenforceable under
+ applicable law, it shall not affect the validity or enforceability of
+ the remainder of the terms of this License, and without further action
+ by the parties to this agreement, such provision shall be reformed to
+ the minimum extent necessary to make such provision valid and
+ enforceable.
+ d. No term or provision of this License shall be deemed waived and no
+ breach consented to unless such waiver or consent shall be in writing
+ and signed by the party to be charged with such waiver or consent.
+ e. This License constitutes the entire agreement between the parties with
+ respect to the Work licensed here. There are no understandings,
+ agreements or representations with respect to the Work not specified
+ here. Licensor shall not be bound by any additional provisions that
+ may appear in any communication from You. This License may not be
+ modified without the mutual written agreement of the Licensor and You.
+ f. The rights granted under, and the subject matter referenced, in this
+ License were drafted utilizing the terminology of the Berne Convention
+ for the Protection of Literary and Artistic Works (as amended on
+ September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
+ Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
+ and the Universal Copyright Convention (as revised on July 24, 1971).
+ These rights and subject matter take effect in the relevant
+ jurisdiction in which the License terms are sought to be enforced
+ according to the corresponding provisions of the implementation of
+ those treaty provisions in the applicable national law. If the
+ standard suite of rights granted under applicable copyright law
+ includes additional rights not granted under this License, such
+ additional rights are deemed to be included in the License; this
+ License is not intended to restrict the license of any rights under
+ applicable law.
+
+
+Creative Commons Notice
+
+ Creative Commons is not a party to this License, and makes no warranty
+ whatsoever in connection with the Work. Creative Commons will not be
+ liable to You or any party on any legal theory for any damages
+ whatsoever, including without limitation any general, special,
+ incidental or consequential damages arising in connection to this
+ license. Notwithstanding the foregoing two (2) sentences, if Creative
+ Commons has expressly identified itself as the Licensor hereunder, it
+ shall have all rights and obligations of Licensor.
+
+ Except for the limited purpose of indicating to the public that the
+ Work is licensed under the CCPL, Creative Commons does not authorize
+ the use by either party of the trademark "Creative Commons" or any
+ related trademark or logo of Creative Commons without the prior
+ written consent of Creative Commons. Any permitted use will be in
+ compliance with Creative Commons' then-current trademark usage
+ guidelines, as may be published on its website or otherwise made
+ available upon request from time to time. For the avoidance of doubt,
+ this trademark restriction does not form part of this License.
+
+ Creative Commons may be contacted at https://creativecommons.org/.
\ No newline at end of file
[42/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
new file mode 100644
index 0000000..7ac790c
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
@@ -0,0 +1,1954 @@
+/*
+ * 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.hibernate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.NaturalId;
+import org.hibernate.annotations.NaturalIdCache;
+import org.hibernate.cache.spi.GeneralDataRegion;
+import org.hibernate.cache.spi.TransactionalDataRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.exception.ConstraintViolationException;
+import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.stat.NaturalIdCacheStatistics;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.IGNITE_INSTANCE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
+import static org.hibernate.cfg.Environment.CACHE_REGION_FACTORY;
+import static org.hibernate.cfg.Environment.GENERATE_STATISTICS;
+import static org.hibernate.cfg.Environment.HBM2DDL_AUTO;
+import static org.hibernate.cfg.Environment.RELEASE_CONNECTIONS;
+import static org.hibernate.cfg.Environment.USE_QUERY_CACHE;
+import static org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE;
+
+/**
+ *
+ * Tests Hibernate L2 cache.
+ */
+public class HibernateL2CacheSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+ /** */
+ public static final String ENTITY_NAME = Entity.class.getName();
+
+ /** */
+ public static final String ENTITY2_NAME = Entity2.class.getName();
+
+ /** */
+ public static final String VERSIONED_ENTITY_NAME = VersionedEntity.class.getName();
+
+ /** */
+ public static final String PARENT_ENTITY_NAME = ParentEntity.class.getName();
+
+ /** */
+ public static final String CHILD_COLLECTION_REGION = ENTITY_NAME + ".children";
+
+ /** */
+ public static final String NATURAL_ID_REGION =
+ "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity##NaturalId";
+
+ /** */
+ public static final String NATURAL_ID_REGION2 =
+ "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity2##NaturalId";
+
+ /** */
+ private SessionFactory sesFactory1;
+
+ /** */
+ private SessionFactory sesFactory2;
+
+ /**
+ * First Hibernate test entity.
+ */
+ @javax.persistence.Entity
+ @NaturalIdCache
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class Entity {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /** */
+ private Collection<ChildEntity> children;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public Entity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ public Entity(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ @NaturalId(mutable = true)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Children.
+ */
+ @OneToMany(cascade=javax.persistence.CascadeType.ALL, fetch=FetchType.LAZY)
+ @JoinColumn(name="ENTITY_ID")
+ public Collection<ChildEntity> getChildren() {
+ return children;
+ }
+
+ /**
+ * @param children Children.
+ */
+ public void setChildren(Collection<ChildEntity> children) {
+ this.children = children;
+ }
+ }
+
+ /**
+ * Second Hibernate test entity.
+ */
+ @javax.persistence.Entity
+ @NaturalIdCache
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class Entity2 {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /** */
+ private Collection<ChildEntity> children;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public Entity2() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ public Entity2(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ @NaturalId(mutable = true)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Hibernate child entity referenced by {@link Entity}.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings("PublicInnerClass")
+ public static class ChildEntity {
+ /** */
+ private int id;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public ChildEntity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ */
+ public ChildEntity(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Hibernate entity referencing {@link Entity}.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings("PublicInnerClass")
+ public static class ParentEntity {
+ /** */
+ private int id;
+
+ /** */
+ private Entity entity;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public ParentEntity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param entity Referenced entity.
+ */
+ public ParentEntity(int id, Entity entity) {
+ this.id = id;
+ this.entity = entity;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Referenced entity.
+ */
+ @OneToOne
+ public Entity getEntity() {
+ return entity;
+ }
+
+ /**
+ * @param entity Referenced entity.
+ */
+ public void setEntity(Entity entity) {
+ this.entity = entity;
+ }
+ }
+
+ /**
+ * Hibernate entity.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class VersionedEntity {
+ /** */
+ private int id;
+
+ /** */
+ private long ver;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public VersionedEntity() {
+ }
+
+ /**
+ * @param id ID.
+ */
+ public VersionedEntity(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Version.
+ */
+ @javax.persistence.Version
+ public long getVersion() {
+ return ver;
+ }
+
+ /**
+ * @param ver Version.
+ */
+ public void setVersion(long ver) {
+ this.ver = ver;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"),
+ generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"),
+ transactionalRegionConfiguration(ENTITY_NAME),
+ transactionalRegionConfiguration(ENTITY2_NAME),
+ transactionalRegionConfiguration(VERSIONED_ENTITY_NAME),
+ transactionalRegionConfiguration(PARENT_ENTITY_NAME),
+ transactionalRegionConfiguration(CHILD_COLLECTION_REGION),
+ transactionalRegionConfiguration(NATURAL_ID_REGION),
+ transactionalRegionConfiguration(NATURAL_ID_REGION2));
+
+ return cfg;
+ }
+
+ /**
+ * @param regionName Region name.
+ * @return Cache configuration for {@link GeneralDataRegion}.
+ */
+ private CacheConfiguration generalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(regionName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(ATOMIC);
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setBackups(1);
+
+ cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+ return cfg;
+ }
+
+ /**
+ * @param regionName Region name.
+ * @return Cache configuration for {@link TransactionalDataRegion}.
+ */
+ protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(regionName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(TRANSACTIONAL);
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setBackups(1);
+
+ cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+ return cfg;
+ }
+
+ /**
+ * @param accessType Hibernate L2 cache access type.
+ * @param igniteInstanceName Ignite instance name.
+ * @return Hibernate configuration.
+ */
+ private Configuration hibernateConfiguration(AccessType accessType,
+ String igniteInstanceName) {
+ Configuration cfg = new Configuration();
+
+ cfg.addAnnotatedClass(Entity.class);
+ cfg.addAnnotatedClass(Entity2.class);
+ cfg.addAnnotatedClass(VersionedEntity.class);
+ cfg.addAnnotatedClass(ChildEntity.class);
+ cfg.addAnnotatedClass(ParentEntity.class);
+
+ cfg.setCacheConcurrencyStrategy(ENTITY_NAME, accessType.getExternalName());
+ cfg.setCacheConcurrencyStrategy(ENTITY2_NAME, accessType.getExternalName());
+ cfg.setCacheConcurrencyStrategy(VERSIONED_ENTITY_NAME, accessType.getExternalName());
+ cfg.setCacheConcurrencyStrategy(PARENT_ENTITY_NAME, accessType.getExternalName());
+ cfg.setCollectionCacheConcurrencyStrategy(CHILD_COLLECTION_REGION, accessType.getExternalName());
+
+ for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
+ cfg.setProperty(e.getKey(), e.getValue());
+
+ // Use the same cache for Entity and Entity2.
+ cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);
+
+ return cfg;
+ }
+
+ /**
+ * @return Hibernate registry builder.
+ */
+ protected ServiceRegistryBuilder registryBuilder() {
+ ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+
+ return builder;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ cleanup();
+ }
+
+ /**
+ * @return Hibernate L2 cache access types to test.
+ */
+ protected AccessType[] accessTypes() {
+ return new AccessType[]{AccessType.READ_ONLY, AccessType.NONSTRICT_READ_WRITE, AccessType.READ_WRITE};
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollectionCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testCollectionCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ private void testCollectionCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, Integer> idToChildCnt = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ Entity e = new Entity(i, "name-" + i);
+
+ Collection<ChildEntity> children = new ArrayList<>();
+
+ for (int j = 0; j < 3; j++)
+ children.add(new ChildEntity());
+
+ e.setChildren(children);
+
+ idToChildCnt.put(e.getId(), e.getChildren().size());
+
+ ses.save(e);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Load children, this should populate cache.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ List<Entity> list = ses.createCriteria(ENTITY_NAME).list();
+
+ assertEquals(idToChildCnt.size(), list.size());
+
+ for (Entity e : list)
+ assertEquals((int)idToChildCnt.get(e.getId()), e.getChildren().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 3, 0);
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ // Update children for one entity.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.getChildren().remove(e1.getChildren().iterator().next());
+
+ ses.update(e1);
+
+ idToChildCnt.put(e1.getId(), e1.getChildren().size());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
+
+ // Update children for the same entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.getChildren().remove(e1.getChildren().iterator().next());
+
+ ses.update(e1);
+
+ idToChildCnt.put(e1.getId(), e1.getChildren().size());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEntityCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testEntityCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testEntityCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, String> idToName = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 2; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ idToName.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates and inserts in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed1");
+
+ ses.update(e0);
+
+ idToName.put(0, e0.getName());
+
+ ses.save(new Entity(2, "name-2"));
+
+ idToName.put(2, "name-2");
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-1-changed1");
+
+ ses.update(e1);
+
+ idToName.put(1, e1.getName());
+
+ ses.save(new Entity(3, "name-3"));
+
+ idToName.put(3, "name-3");
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates, inserts and deletes in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity(4, "name-4"));
+
+ idToName.put(4, "name-4");
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed2");
+
+ ses.update(e0);
+
+ idToName.put(e0.getId(), e0.getName());
+
+ ses.delete(ses.load(Entity.class, 1));
+
+ idToName.remove(1);
+
+ Entity e2 = (Entity)ses.load(Entity.class, 2);
+
+ e2.setName("name-2-changed1");
+
+ ses.update(e2);
+
+ idToName.put(e2.getId(), e2.getName());
+
+ ses.delete(ses.load(Entity.class, 3));
+
+ idToName.remove(3);
+
+ ses.save(new Entity(5, "name-5"));
+
+ idToName.put(5, "name-5");
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 1, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 1, 3);
+
+ // Try to update the same entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed3");
+
+ ses.update(e0);
+
+ idToName.put(e0.getId(), e0.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTwoEntitiesSameCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testTwoEntitiesSameCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testTwoEntitiesSameCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ Map<Integer, String> idToName1 = new HashMap<>();
+ Map<Integer, String> idToName2 = new HashMap<>();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 2; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+ ses.save(new Entity2(i, name));
+
+ idToName1.put(i, name);
+ idToName2.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates both entities in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 0);
+
+ e.setName("name-0-changed1");
+
+ ses.update(e);
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 0);
+
+ e2.setName("name-e2-0-changed1");
+
+ ses.update(e2);
+
+ idToName1.put(0, e.getName());
+ idToName2.put(0, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Remove entity1 and insert entity2 in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 0);
+
+ ses.delete(e);
+
+ Entity2 e2 = new Entity2(2, "name-2");
+
+ ses.save(e2);
+
+ idToName1.remove(0);
+ idToName2.put(2, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ // Update, remove, insert in single transaction, transaction fails.
+
+ Entity e = (Entity)ses.load(Entity.class, 1);
+
+ e.setName("name-1-changed1");
+
+ ses.update(e); // Valid update.
+
+ ses.save(new Entity(2, "name-2")); // Valid insert.
+
+ ses.delete(ses.load(Entity2.class, 0)); // Valid delete.
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
+
+ e2.setName("name-2"); // Invalid update, not-unique name.
+
+ ses.update(e2);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 2, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 2, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory2.openSession();
+
+ try {
+ // Update, remove, insert in single transaction.
+
+ tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 1);
+
+ e.setName("name-1-changed1");
+
+ ses.update(e);
+
+ idToName1.put(1, e.getName());
+
+ ses.save(new Entity(2, "name-2"));
+
+ idToName1.put(2, "name-2");
+
+ ses.delete(ses.load(Entity2.class, 0));
+
+ idToName2.remove(0);
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
+
+ e2.setName("name-e2-2-changed");
+
+ ses.update(e2);
+
+ idToName2.put(1, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 0, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 0, 100);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testVersionedEntity() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testVersionedEntity(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testVersionedEntity(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ VersionedEntity e0 = new VersionedEntity(0);
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(e0);
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ long ver;
+
+ try {
+ ver = ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion();
+ }
+ finally {
+ ses.close();
+ }
+
+ SecondLevelCacheStatistics stats1 =
+ sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+ SecondLevelCacheStatistics stats2 =
+ sesFactory2.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+
+ assertEquals(1, stats1.getElementCountInMemory());
+ assertEquals(1, stats2.getElementCountInMemory());
+
+ ses = sesFactory2.openSession();
+
+ try {
+ assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(1, stats2.getElementCountInMemory());
+ assertEquals(1, stats2.getHitCount());
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ e0.setVersion(ver - 1);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ ses.update(e0);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (StaleObjectStateException e) {
+ log.info("Expected exception: " + e);
+ }
+ finally {
+ tx.rollback();
+
+ ses.close();
+ }
+
+ sesFactory1.getStatistics().clear();
+
+ stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(1, stats1.getElementCountInMemory());
+ assertEquals(1, stats1.getHitCount());
+ assertEquals(1, stats2.getElementCountInMemory());
+ assertEquals(1, stats2.getHitCount());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNaturalIdCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testNaturalIdCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testNaturalIdCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<String, Integer> nameToId = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ nameToId.put(name, i);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ try {
+ for (Map.Entry<String, Integer> e : nameToId.entrySet())
+ ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-100");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-100");
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ // Update naturalId.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ nameToId.remove(e1.getName());
+
+ e1.setName("name-1-changed1");
+
+ nameToId.put(e1.getName(), e1.getId());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-1");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-1");
+
+ // Update entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ nameToId.remove(e1.getName());
+
+ e1.setName("name-1-changed2");
+
+ nameToId.put(e1.getName(), e1.getId());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-1-changed1");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-1-changed1");
+
+ // Try invalid NaturalId update.
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-0"); // Invalid update (duplicated name).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId);
+ assertNaturalIdCache(sesFactory1, nameToId);
+
+ // Delete entity.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ tx = ses.beginTransaction();
+
+ Entity e2 = (Entity)ses.load(Entity.class, 2);
+
+ ses.delete(e2);
+
+ nameToId.remove(e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-2");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-2");
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEntityCacheTransactionFails() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testEntityCacheTransactionFails(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testEntityCacheTransactionFails(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, String> idToName = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ idToName.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ ses.save(new Entity(3, "name-3")); // Valid insert.
+
+ ses.save(new Entity(0, "name-0")); // Invalid insert (duplicated ID).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e0.setName("name-10"); // Valid update.
+ e1.setName("name-2"); // Invalid update (violates unique constraint).
+
+ ses.update(e0);
+ ses.update(e1);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Create parent entity referencing Entity with ID = 0.
+
+ tx = ses.beginTransaction();
+
+ ses.save(new ParentEntity(0, (Entity) ses.load(Entity.class, 0)));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ ses.save(new Entity(3, "name-3")); // Valid insert.
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-10"); // Valid update.
+
+ ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ ses.delete(ses.load(Entity.class, 1)); // Valid delete.
+
+ idToName.remove(1);
+
+ ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testQueryCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testQueryCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 5; i++)
+ ses.save(new Entity(i, "name-" + i));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Run some queries.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(2, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+
+ // Run queries using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(2, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+
+ Query qry3 = ses.createQuery("from " + ENTITY_NAME + " where id > 1");
+
+ qry3.setCacheable(true);
+
+ assertEquals(3, qry3.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(2, sesFactory2.getStatistics().getQueryCacheHitCount());
+ assertEquals(1, sesFactory2.getStatistics().getQueryCacheMissCount());
+ assertEquals(1, sesFactory2.getStatistics().getQueryCachePutCount());
+
+ // Update entity, it should invalidate query cache.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity(5, "name-5"));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Run queries.
+
+ ses = sesFactory1.openSession();
+
+ sesFactory1.getStatistics().clear();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(3, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+
+ // Clear query cache using another SessionFactory.
+
+ sesFactory2.getCache().evictDefaultQueryRegion();
+
+ ses = sesFactory1.openSession();
+
+ // Run queries again.
+
+ sesFactory1.getStatistics().clear();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(3, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRegionClear() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testRegionClear(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testRegionClear(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ final int ENTITY_CNT = 100;
+
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < ENTITY_CNT; i++) {
+ Entity e = new Entity(i, "name-" + i);
+
+ Collection<ChildEntity> children = new ArrayList<>();
+
+ for (int j = 0; j < 3; j++)
+ children.add(new ChildEntity());
+
+ e.setChildren(children);
+
+ ses.save(e);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ loadEntities(sesFactory2, ENTITY_CNT);
+
+ SecondLevelCacheStatistics stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
+ SecondLevelCacheStatistics stats2 = sesFactory2.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
+
+ NaturalIdCacheStatistics idStats1 =
+ sesFactory1.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+ NaturalIdCacheStatistics idStats2 =
+ sesFactory2.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+
+ SecondLevelCacheStatistics colStats1 =
+ sesFactory1.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+ SecondLevelCacheStatistics colStats2 =
+ sesFactory2.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+
+ assertEquals(ENTITY_CNT, stats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, stats2.getElementCountInMemory());
+
+ assertEquals(ENTITY_CNT, idStats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, idStats2.getElementCountInMemory());
+
+ assertEquals(ENTITY_CNT, colStats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, colStats2.getElementCountInMemory());
+
+ // Test cache is cleared after update query.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.createQuery("delete from " + ENTITY_NAME + " where name='no such name'").executeUpdate();
+
+ ses.createQuery("delete from " + ChildEntity.class.getName() + " where id=-1").executeUpdate();
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, stats1.getElementCountInMemory());
+ assertEquals(0, stats2.getElementCountInMemory());
+
+ assertEquals(0, idStats1.getElementCountInMemory());
+ assertEquals(0, idStats2.getElementCountInMemory());
+
+ assertEquals(0, colStats1.getElementCountInMemory());
+ assertEquals(0, colStats2.getElementCountInMemory());
+
+ // Load some data in cache.
+
+ loadEntities(sesFactory1, 10);
+
+ assertEquals(10, stats1.getElementCountInMemory());
+ assertEquals(10, stats2.getElementCountInMemory());
+ assertEquals(10, idStats1.getElementCountInMemory());
+ assertEquals(10, idStats2.getElementCountInMemory());
+
+ // Test evictAll method.
+
+ sesFactory2.getCache().evictEntityRegion(ENTITY_NAME);
+
+ assertEquals(0, stats1.getElementCountInMemory());
+ assertEquals(0, stats2.getElementCountInMemory());
+
+ sesFactory2.getCache().evictNaturalIdRegion(ENTITY_NAME);
+
+ assertEquals(0, idStats1.getElementCountInMemory());
+ assertEquals(0, idStats2.getElementCountInMemory());
+
+ sesFactory2.getCache().evictCollectionRegion(CHILD_COLLECTION_REGION);
+
+ assertEquals(0, colStats1.getElementCountInMemory());
+ assertEquals(0, colStats2.getElementCountInMemory());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param nameToId Name-ID mapping.
+ * @param absentNames Absent entities' names.
+ */
+ private void assertNaturalIdCache(SessionFactory sesFactory, Map<String, Integer> nameToId, String... absentNames) {
+ sesFactory.getStatistics().clear();
+
+ NaturalIdCacheStatistics stats =
+ sesFactory.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+
+ long hitBefore = stats.getHitCount();
+
+ long missBefore = stats.getMissCount();
+
+ final Session ses = sesFactory.openSession();
+
+ try {
+ for (Map.Entry<String, Integer> e : nameToId.entrySet())
+ assertEquals((int)e.getValue(), ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId());
+
+ for (String name : absentNames)
+ assertNull((ses.bySimpleNaturalId(Entity.class).load(name)));
+
+ assertEquals(nameToId.size() + hitBefore, stats.getHitCount());
+
+ assertEquals(absentNames.length + missBefore, stats.getMissCount());
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param idToChildCnt Number of children per entity.
+ * @param expHit Expected cache hits.
+ * @param expMiss Expected cache misses.
+ */
+ @SuppressWarnings("unchecked")
+ private void assertCollectionCache(SessionFactory sesFactory, Map<Integer, Integer> idToChildCnt, int expHit,
+ int expMiss) {
+ sesFactory.getStatistics().clear();
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ for(Map.Entry<Integer, Integer> e : idToChildCnt.entrySet()) {
+ Entity entity = (Entity)ses.load(Entity.class, e.getKey());
+
+ assertEquals((int)e.getValue(), entity.getChildren().size());
+ }
+ }
+ finally {
+ ses.close();
+ }
+
+ SecondLevelCacheStatistics stats =
+ sesFactory.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+
+ assertEquals(expHit, stats.getHitCount());
+
+ assertEquals(expMiss, stats.getMissCount());
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param cnt Number of entities to load.
+ */
+ private void loadEntities(SessionFactory sesFactory, int cnt) {
+ Session ses = sesFactory.openSession();
+
+ try {
+ for (int i = 0; i < cnt; i++) {
+ Entity e = (Entity)ses.load(Entity.class, i);
+
+ assertEquals("name-" + i, e.getName());
+
+ assertFalse(e.getChildren().isEmpty());
+
+ ses.bySimpleNaturalId(Entity.class).load(e.getName());
+ }
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * @param entityName Entity name.
+ * @param sesFactory Session factory.
+ * @param idToName ID to name mapping.
+ * @param absentIds Absent entities' IDs.
+ */
+ private void assertEntityCache(String entityName, SessionFactory sesFactory, Map<Integer, String> idToName,
+ Integer... absentIds) {
+ assert entityName.equals(ENTITY_NAME) || entityName.equals(ENTITY2_NAME) : entityName;
+
+ sesFactory.getStatistics().clear();
+
+ final Session ses = sesFactory.openSession();
+
+ final boolean entity1 = entityName.equals(ENTITY_NAME);
+
+ try {
+ if (entity1) {
+ for (Map.Entry<Integer, String> e : idToName.entrySet())
+ assertEquals(e.getValue(), ((Entity)ses.load(Entity.class, e.getKey())).getName());
+ }
+ else {
+ for (Map.Entry<Integer, String> e : idToName.entrySet())
+ assertEquals(e.getValue(), ((Entity2)ses.load(Entity2.class, e.getKey())).getName());
+ }
+
+ for (final int id : absentIds) {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ if (entity1)
+ ((Entity)ses.load(Entity.class, id)).getName();
+ else
+ ((Entity2)ses.load(Entity2.class, id)).getName();
+
+ return null;
+ }
+ }, ObjectNotFoundException.class, null);
+ }
+
+ SecondLevelCacheStatistics stats = sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
+
+ assertEquals(idToName.size(), stats.getHitCount());
+
+ assertEquals(absentIds.length, stats.getMissCount());
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * Creates session factories.
+ *
+ * @param accessType Cache access type.
+ */
+ private void createSessionFactories(AccessType accessType) {
+ sesFactory1 = startHibernate(accessType, getTestIgniteInstanceName(0));
+
+ sesFactory2 = startHibernate(accessType, getTestIgniteInstanceName(1));
+ }
+
+ /**
+ * Starts Hibernate.
+ *
+ * @param accessType Cache access type.
+ * @param igniteInstanceName Ignite instance name.
+ * @return Session factory.
+ */
+ private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
+ Configuration cfg = hibernateConfiguration(accessType, igniteInstanceName);
+
+ ServiceRegistryBuilder builder = registryBuilder();
+
+ builder.applySetting("hibernate.show_sql", false);
+
+ return cfg.buildSessionFactory(builder.buildServiceRegistry());
+ }
+
+ /**
+ * Closes session factories and clears data from caches.
+ *
+ * @throws Exception If failed.
+ */
+ private void cleanup() throws Exception {
+ if (sesFactory1 != null)
+ sesFactory1.close();
+
+ sesFactory1 = null;
+
+ if (sesFactory2 != null)
+ sesFactory2.close();
+
+ sesFactory2 = null;
+
+ for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
+ cache.clear();
+ }
+
+ /**
+ * @param igniteInstanceName Node name.
+ * @param dfltAccessType Default cache access type.
+ * @return Properties map.
+ */
+ static Map<String, String> hibernateProperties(String igniteInstanceName, String dfltAccessType) {
+ Map<String, String> map = new HashMap<>();
+
+ map.put(HBM2DDL_AUTO, "create");
+ map.put(GENERATE_STATISTICS, "true");
+ map.put(USE_SECOND_LEVEL_CACHE, "true");
+ map.put(USE_QUERY_CACHE, "true");
+ map.put(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
+ map.put(RELEASE_CONNECTIONS, "on_close");
+ map.put(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
+ map.put(DFLT_ACCESS_TYPE_PROPERTY, dfltAccessType);
+
+ return map;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
new file mode 100644
index 0000000..deca893
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.hibernate;
+
+import java.util.Collections;
+import javax.cache.configuration.Factory;
+import javax.transaction.Synchronization;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import org.apache.commons.dbcp.managed.BasicManagedDataSource;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.h2.jdbcx.JdbcDataSource;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
+import org.hibernate.engine.transaction.spi.TransactionFactory;
+import org.hibernate.service.ServiceRegistryBuilder;
+import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
+import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform;
+import org.hibernate.service.jta.platform.spi.JtaPlatform;
+import org.jetbrains.annotations.Nullable;
+import org.objectweb.jotm.Jotm;
+
+/**
+ *
+ * Tests Hibernate L2 cache with TRANSACTIONAL access mode (Hibernate and Cache are configured
+ * to used the same TransactionManager).
+ */
+public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfTest {
+ /** */
+ private static Jotm jotm;
+
+ /**
+ */
+ private static class TestJtaPlatform extends AbstractJtaPlatform {
+ /** {@inheritDoc} */
+ @Override protected TransactionManager locateTransactionManager() {
+ return jotm.getTransactionManager();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected UserTransaction locateUserTransaction() {
+ return jotm.getUserTransaction();
+ }
+ }
+
+ /**
+ */
+ @SuppressWarnings("PublicInnerClass")
+ public static class TestTmFactory implements Factory<TransactionManager> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public TransactionManager create() {
+ return jotm.getTransactionManager();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ jotm = new Jotm(true, false);
+
+ super.beforeTestsStarted();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ if (jotm != null)
+ jotm.stop();
+
+ jotm = null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.getTransactionConfiguration().setTxManagerFactory(new TestTmFactory());
+ cfg.getTransactionConfiguration().setUseJtaSynchronization(useJtaSynchronization());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = super.transactionalRegionConfiguration(regionName);
+
+ cfg.setNearConfiguration(null);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override protected ServiceRegistryBuilder registryBuilder() {
+ ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+
+ DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
+
+ BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.
+
+ dataSrc.setTransactionManager(jotm.getTransactionManager());
+
+ dataSrc.setDefaultAutoCommit(false);
+
+ JdbcDataSource h2DataSrc = new JdbcDataSource();
+
+ h2DataSrc.setURL(CONNECTION_URL);
+
+ dataSrc.setXaDataSourceInstance(h2DataSrc);
+
+ connProvider.setDataSource(dataSrc);
+
+ connProvider.configure(Collections.emptyMap());
+
+ builder.addService(ConnectionProvider.class, connProvider);
+
+ builder.addService(JtaPlatform.class, new TestJtaPlatform());
+
+ builder.addService(TransactionFactory.class, new JtaTransactionFactory());
+
+ return builder;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected AccessType[] accessTypes() {
+ return new AccessType[]{AccessType.TRANSACTIONAL};
+ }
+
+ /**
+ * @return Whether to use {@link Synchronization}.
+ */
+ protected boolean useJtaSynchronization() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
new file mode 100644
index 0000000..44899f9
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.hibernate;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Tests Hibernate L2 cache with TRANSACTIONAL access mode and {@link Synchronization}
+ * instead of XA resource.
+ */
+public class HibernateL2CacheTransactionalUseSyncSelfTest extends HibernateL2CacheTransactionalSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean useJtaSynchronization() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
new file mode 100644
index 0000000..d5496af
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.processors.cache.integration.IgniteCacheStoreNodeRestartAbstractTest;
+
+public class CacheHibernateBlobStoreNodeRestartTest extends IgniteCacheStoreNodeRestartAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheStore getStore() {
+ return new CacheHibernateBlobStore();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
new file mode 100644
index 0000000..77025a1
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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 java.io.File;
+import java.net.URL;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
+import org.hibernate.FlushMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+
+/**
+ * Cache store test.
+ */
+public class CacheHibernateBlobStoreSelfTest extends
+ GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> {
+ /**
+ * @throws Exception If failed.
+ */
+ public CacheHibernateBlobStoreSelfTest() throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ Session s = store.session(null);
+
+ if (s == null)
+ return;
+
+ try {
+ s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
+ .setFlushMode(FlushMode.ALWAYS).executeUpdate();
+
+ Transaction hTx = s.getTransaction();
+
+ if (hTx != null && hTx.isActive())
+ hTx.commit();
+ }
+ finally {
+ s.close();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheHibernateBlobStore<Object, Object> store() {
+ return new CacheHibernateBlobStore<>();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByUrl() throws Exception {
+ URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH +
+ "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ assert url != null;
+
+ store.setHibernateConfigurationPath(url.toString());
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByFile() throws Exception {
+ URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH +
+ "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ assert url != null;
+
+ File file = new File(url.toURI());
+
+ store.setHibernateConfigurationPath(file.getAbsolutePath());
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByResource() throws Exception {
+ store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ @Override public void testSimpleMultithreading() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1757");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
new file mode 100644
index 0000000..f6c8a2d
--- /dev/null
+++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
@@ -0,0 +1,288 @@
+/*
+ * 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 java.io.Serializable;
+import java.sql.Connection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Cache;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionBuilder;
+import org.hibernate.SessionFactory;
+import org.hibernate.StatelessSession;
+import org.hibernate.StatelessSessionBuilder;
+import org.hibernate.TypeHelper;
+import org.hibernate.engine.spi.FilterDefinition;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.metadata.CollectionMetadata;
+import org.hibernate.stat.Statistics;
+
+/**
+ * Test for Cache jdbc blob store factory.
+ */
+public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest {
+ /** Cache name. */
+ private static final String CACHE_NAME = "test";
+
+ /** */
+ static final String MODULE_PATH = "modules/hibernate-4.2/";
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheConfiguration() throws Exception {
+ try (Ignite ignite1 = startGrid(0)) {
+ IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration());
+
+ checkStore(cache1);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testXmlConfiguration() throws Exception {
+ try (Ignite ignite = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache.xml")) {
+ try(Ignite ignite1 = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache1.xml")) {
+ checkStore(ignite.<Integer, String>cache(CACHE_NAME), DummySessionFactoryExt.class);
+
+ checkStore(ignite1.<Integer, String>cache(CACHE_NAME), DummySessionFactory.class);
+ }
+ }
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncorrectBeanConfiguration() throws Exception {
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try(Ignite ignite =
+ Ignition.start(MODULE_PATH + "/src/test/config/factory-incorrect-store-cache.xml")) {
+ ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
+ getCacheStoreFactory().create();
+ }
+ return null;
+ }
+ }, IgniteException.class, "Failed to load bean in application context");
+ }
+
+ /**
+ * @return Cache configuration with store.
+ */
+ private CacheConfiguration<Integer, String> cacheConfiguration() {
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ CacheHibernateBlobStoreFactory<Integer, String> factory = new CacheHibernateBlobStoreFactory();
+
+ factory.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ cfg.setCacheStoreFactory(factory);
+
+ return cfg;
+ }
+
+ /**
+ * @param cache Ignite cache.
+ * @param dataSrcClass Data source class.
+ * @throws Exception If store parameters is not the same as in configuration xml.
+ */
+ private void checkStore(IgniteCache<Integer, String> cache, Class<?> dataSrcClass) throws Exception {
+ CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache
+ .getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create();
+
+ assertEquals(dataSrcClass,
+ GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "sesFactory").getClass());
+ }
+
+ /**
+ * @param cache Ignite cache.
+ * @throws Exception If store parameters is not the same as in configuration xml.
+ */
+ private void checkStore(IgniteCache<Integer, String> cache) throws Exception {
+ CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache.getConfiguration(CacheConfiguration.class)
+ .getCacheStoreFactory().create();
+
+ assertEquals("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml",
+ GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "hibernateCfgPath"));
+ }
+
+ /**
+ *
+ */
+ public static class DummySessionFactoryExt extends DummySessionFactory {
+ /** */
+ public DummySessionFactoryExt() {
+ // No-op.
+ }
+ }
+
+ /**
+ *
+ */
+ public static class DummySessionFactory implements SessionFactory {
+ /** {@inheritDoc} */
+ @Override public SessionFactoryOptions getSessionFactoryOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public SessionBuilder withOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Session openSession() throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Session getCurrentSession() throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSessionBuilder withStatelessOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSession openStatelessSession() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSession openStatelessSession(Connection conn) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassMetadata getClassMetadata(Class entityCls) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassMetadata getClassMetadata(String entityName) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionMetadata getCollectionMetadata(String roleName) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, ClassMetadata> getAllClassMetadata() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map getAllCollectionMetadata() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statistics getStatistics() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cache getCache() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Class persistentCls) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Class persistentCls, Serializable id) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictEntity(String entityName) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictEntity(String entityName, Serializable id) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictCollection(String roleName) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictCollection(String roleName, Serializable id) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictQueries(String cacheRegion) throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictQueries() throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set getDefinedFilterNames() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsFetchProfileDefinition(String name) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public TypeHelper getTypeHelper() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reference getReference() throws NamingException {
+ return null;
+ }
+ }
+}
\ No newline at end of file
[18/50] [abbrv] ignite git commit: IGNITE-5025 - Do not allow null
names for memory policies
Posted by vo...@apache.org.
IGNITE-5025 - Do not allow null names for memory policies
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1dc9e698
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1dc9e698
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1dc9e698
Branch: refs/heads/master
Commit: 1dc9e69851c19610e9357e35ae17ef2599733e5f
Parents: 4739458
Author: Sergey Chugunov <se...@gmail.com>
Authored: Tue Apr 25 11:17:24 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Apr 25 11:23:30 2017 +0300
----------------------------------------------------------------------
.../configuration/MemoryConfiguration.java | 12 +-
.../MemoryPolicyConfiguration.java | 6 +-
.../IgniteCacheDatabaseSharedManager.java | 130 ++++----
.../cache/MemoryPolicyConfigValidationTest.java | 6 +-
.../MemoryPolicyInitializationTest.java | 307 +++++++++++++++++++
.../testsuites/IgniteCacheTestSuite2.java | 2 +
.../Cache/Configuration/MemoryConfiguration.cs | 7 +
.../Configuration/MemoryPolicyConfiguration.cs | 3 +
8 files changed, 415 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
index cd7c1fe..f88a95a 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryConfiguration.java
@@ -71,6 +71,9 @@ public class MemoryConfiguration implements Serializable {
/** Default memory page size. */
public static final int DFLT_PAGE_SIZE = 2 * 1024;
+ /** This name is assigned to default MemoryPolicy if no user-defined default MemPlc is specified */
+ public static final String DFLT_MEM_PLC_DEFAULT_NAME = "default";
+
/** Size of a memory chunk reserved for system cache needs. */
private long sysCacheMemSize = DFLT_SYS_CACHE_MEM_SIZE;
@@ -81,7 +84,7 @@ public class MemoryConfiguration implements Serializable {
private int concLvl;
/** A name of the memory policy that defines the default memory region. */
- private String dfltMemPlcName;
+ private String dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
/** Memory policies. */
private MemoryPolicyConfiguration[] memPlcs;
@@ -98,6 +101,8 @@ public class MemoryConfiguration implements Serializable {
/**
* Sets the size of a memory chunk reserved for system cache needs.
*
+ * Default value is {@link #DFLT_SYS_CACHE_MEM_SIZE}
+ *
* @param sysCacheMemSize Size in bytes.
*/
public MemoryConfiguration setSystemCacheMemorySize(long sysCacheMemSize) {
@@ -119,6 +124,8 @@ public class MemoryConfiguration implements Serializable {
/**
* Changes the page size.
*
+ * Default value is {@link #DFLT_PAGE_SIZE}
+ *
* @param pageSize Page size in bytes.
*/
public MemoryConfiguration setPageSize(int pageSize) {
@@ -164,7 +171,6 @@ public class MemoryConfiguration implements Serializable {
public MemoryPolicyConfiguration createDefaultPolicyConfig() {
MemoryPolicyConfiguration memPlc = new MemoryPolicyConfiguration();
- memPlc.setName(null);
memPlc.setSize(DFLT_MEMORY_POLICY_SIZE);
return memPlc;
@@ -207,6 +213,8 @@ public class MemoryConfiguration implements Serializable {
* {@link MemoryConfiguration#setMemoryPolicies(MemoryPolicyConfiguration...)} method and change the name of the
* default memory policy with {@code MemoryConfiguration#setDefaultMemoryPolicyName(String)}.
*
+ * If nothing is specified by user, it is set to {@link #DFLT_MEM_PLC_DEFAULT_NAME} value.
+ *
* @param dfltMemPlcName Name of a memory policy to be used as default one.
*/
public MemoryConfiguration setDefaultMemoryPolicyName(String dfltMemPlcName) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
index 6d5fe8c..d0adcf9 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/MemoryPolicyConfiguration.java
@@ -19,6 +19,8 @@ package org.apache.ignite.configuration;
import java.io.Serializable;
import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
/**
* This class allows defining custom memory policies' configurations with various parameters for Apache Ignite
* page memory (see {@link MemoryConfiguration}. For each configured memory policy Apache Ignite instantiates
@@ -61,7 +63,7 @@ public final class MemoryPolicyConfiguration implements Serializable {
private static final long serialVersionUID = 0L;
/** Memory policy name. */
- private String name;
+ private String name = DFLT_MEM_PLC_DEFAULT_NAME;
/** Memory policy maximum size. */
private long size;
@@ -93,6 +95,8 @@ public final class MemoryPolicyConfiguration implements Serializable {
/**
* Sets memory policy name. The name must be non empty and must not be equal to the reserved 'sysMemPlc' one.
*
+ * If not specified, {@link MemoryConfiguration#DFLT_MEM_PLC_DEFAULT_NAME} value is used.
+ *
* @param name Memory policy name.
*/
public MemoryPolicyConfiguration setName(String name) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index 705e74c..ae594fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -57,12 +57,14 @@ import org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupp
import org.apache.ignite.mxbean.MemoryMetricsMXBean;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
/**
*
*/
public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdapter implements IgniteChangeGlobalStateSupport {
/** MemoryPolicyConfiguration name reserved for internal caches. */
- private static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
+ static final String SYSTEM_MEMORY_POLICY_NAME = "sysMemPlc";
/** Minimum size of memory chunk */
private static final long MIN_PAGE_MEMORY_SIZE = 1024 * 1024;
@@ -109,6 +111,8 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
initPageMemoryPolicies(memCfg);
+ registerMetricsMBeans();
+
startMemoryPolicies();
initPageMemoryDataStructures(memCfg);
@@ -116,6 +120,34 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
}
/**
+ * Registers MBeans for all MemoryMetrics configured in this instance.
+ */
+ private void registerMetricsMBeans() {
+ IgniteConfiguration cfg = cctx.gridConfig();
+
+ for (MemoryMetrics memMetrics : memMetricsMap.values())
+ registerMetricsMBean((MemoryMetricsImpl) memMetrics, cfg);
+ }
+
+ /**
+ * @param memMetrics Memory metrics.
+ */
+ private void registerMetricsMBean(MemoryMetricsImpl memMetrics, IgniteConfiguration cfg) {
+ try {
+ U.registerMBean(
+ cfg.getMBeanServer(),
+ cfg.getIgniteInstanceName(),
+ "MemoryMetrics",
+ memMetrics.getName(),
+ memMetrics,
+ MemoryMetricsMXBean.class);
+ }
+ catch (JMException e) {
+ log.warning("Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'");
+ }
+ }
+
+ /**
* @param dbCfg Database config.
*/
protected void initPageMemoryDataStructures(MemoryConfiguration dbCfg) throws IgniteCheckedException {
@@ -172,87 +204,81 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
if (memPlcsCfgs == null) {
//reserve place for default and system memory policies
memPlcMap = U.newHashMap(2);
-
memMetricsMap = U.newHashMap(2);
- MemoryPolicyConfiguration dfltPlcCfg = dbCfg.createDefaultPolicyConfig();
-
- MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(dfltPlcCfg);
-
- registerMetricsMBean(memMetrics);
-
- dfltMemPlc = createDefaultMemoryPolicy(dbCfg, dfltPlcCfg, memMetrics);
-
- memPlcMap.put(null, dfltMemPlc);
- memMetricsMap.put(null, memMetrics);
+ addMemoryPolicy(dbCfg,
+ dbCfg.createDefaultPolicyConfig(),
+ DFLT_MEM_PLC_DEFAULT_NAME);
log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
}
else {
String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
- if (dfltMemPlcName == null) {
+ if (DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltMemPlcName) && !hasCustomDefaultMemoryPolicy(memPlcsCfgs)) {
//reserve additional place for default and system memory policies
memPlcMap = U.newHashMap(memPlcsCfgs.length + 2);
memMetricsMap = U.newHashMap(memPlcsCfgs.length + 2);
- MemoryPolicyConfiguration dfltPlcCfg = dbCfg.createDefaultPolicyConfig();
-
- MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(dfltPlcCfg);
+ addMemoryPolicy(dbCfg,
+ dbCfg.createDefaultPolicyConfig(),
+ DFLT_MEM_PLC_DEFAULT_NAME);
- dfltMemPlc = createDefaultMemoryPolicy(dbCfg, dfltPlcCfg, memMetrics);
- memPlcMap.put(null, dfltMemPlc);
- memMetricsMap.put(null, memMetrics);
-
- log.warning("No user-defined default MemoryPolicy found; system default of 1GB size will be used.");
+ log.warning("No user-defined default MemoryPolicy found; system default will be allocated.");
}
else {
- //reserve additional place for system memory policy only
+ //reserve additional space for system memory policy only
memPlcMap = U.newHashMap(memPlcsCfgs.length + 1);
- memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);;
+ memMetricsMap = U.newHashMap(memPlcsCfgs.length + 1);
}
- for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs) {
- MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
+ for (MemoryPolicyConfiguration memPlcCfg : memPlcsCfgs)
+ addMemoryPolicy(dbCfg, memPlcCfg, memPlcCfg.getName());
+ }
- MemoryPolicy memPlc = initMemory(dbCfg, memPlcCfg, memMetrics);
+ addMemoryPolicy(dbCfg,
+ createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize()),
+ SYSTEM_MEMORY_POLICY_NAME);
+ }
- memPlcMap.put(memPlcCfg.getName(), memPlc);
+ /**
+ * @param dbCfg Database config.
+ * @param memPlcCfg Memory policy config.
+ * @param memPlcName Memory policy name.
+ */
+ private void addMemoryPolicy(MemoryConfiguration dbCfg,
+ MemoryPolicyConfiguration memPlcCfg,
+ String memPlcName) {
+ String dfltMemPlcName = dbCfg.getDefaultMemoryPolicyName();
- memMetricsMap.put(memPlcCfg.getName(), memMetrics);
+ if (dfltMemPlcName == null)
+ dfltMemPlcName = DFLT_MEM_PLC_DEFAULT_NAME;
- if (memPlcCfg.getName().equals(dfltMemPlcName))
- dfltMemPlc = memPlc;
- }
- }
+ MemoryMetricsImpl memMetrics = new MemoryMetricsImpl(memPlcCfg);
- MemoryPolicyConfiguration sysPlcCfg = createSystemMemoryPolicy(dbCfg.getSystemCacheMemorySize());
+ MemoryPolicy memPlc = initMemory(dbCfg, memPlcCfg, memMetrics);
- MemoryMetricsImpl sysMemMetrics = new MemoryMetricsImpl(sysPlcCfg);
+ memPlcMap.put(memPlcName, memPlc);
- memPlcMap.put(SYSTEM_MEMORY_POLICY_NAME, initMemory(dbCfg, sysPlcCfg, sysMemMetrics));
+ memMetricsMap.put(memPlcName, memMetrics);
- memMetricsMap.put(SYSTEM_MEMORY_POLICY_NAME, sysMemMetrics);
+ if (memPlcName.equals(dfltMemPlcName))
+ dfltMemPlc = memPlc;
+ else if (memPlcName.equals(DFLT_MEM_PLC_DEFAULT_NAME))
+ log.warning("Memory Policy with name 'default' isn't used as a default. " +
+ "Please check Memory Policies configuration.");
}
/**
- * @param memMetrics Mem metrics.
+ * @param memPlcsCfgs User-defined memory policy configurations.
*/
- private void registerMetricsMBean(MemoryMetricsImpl memMetrics) {
- IgniteConfiguration cfg = cctx.gridConfig();
-
- try {
- U.registerMBean(
- cfg.getMBeanServer(),
- cfg.getIgniteInstanceName(),
- "MemoryMetrics",
- memMetrics.getName(),
- memMetrics,
- MemoryMetricsMXBean.class);
- }
- catch (JMException e) {
- log.warning("Failed to register MBean for MemoryMetrics with name: '" + memMetrics.getName() + "'");
+ private boolean hasCustomDefaultMemoryPolicy(MemoryPolicyConfiguration[] memPlcsCfgs) {
+ for (MemoryPolicyConfiguration memPlcsCfg : memPlcsCfgs) {
+ if (DFLT_MEM_PLC_DEFAULT_NAME.equals(memPlcsCfg.getName()))
+ return true;
}
+
+ return false;
}
/**
@@ -305,7 +331,7 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
* @throws IgniteCheckedException In case of validation violation.
*/
private static void checkDefaultPolicyConfiguration(String dfltPlcName, Set<String> plcNames) throws IgniteCheckedException {
- if (dfltPlcName != null) {
+ if (!DFLT_MEM_PLC_DEFAULT_NAME.equals(dfltPlcName)) {
if (dfltPlcName.isEmpty())
throw new IgniteCheckedException("User-defined default MemoryPolicy name must be non-empty");
if (!plcNames.contains(dfltPlcName))
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
index c0f74d0..154e562 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MemoryPolicyConfigValidationTest.java
@@ -43,7 +43,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
break;
- case RESERVED_MEMORY_POLICY_MISUSE:
+ case SYSTEM_MEMORY_POLICY_NAME_MISUSE:
plcs = createPlcWithReservedNameMisuseCfg();
break;
@@ -147,7 +147,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
* 'sysMemPlc' name is reserved for MemoryPolicyConfiguration for system caches.
*/
public void testReservedMemoryPolicyMisuse() throws Exception {
- violationType = ValidationViolationType.RESERVED_MEMORY_POLICY_MISUSE;
+ violationType = ValidationViolationType.SYSTEM_MEMORY_POLICY_NAME_MISUSE;
doTest(violationType);
}
@@ -217,7 +217,7 @@ public class MemoryPolicyConfigValidationTest extends GridCommonAbstractTest {
NAMES_CONFLICT("Two MemoryPolicies have the same name: "),
/** */
- RESERVED_MEMORY_POLICY_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
+ SYSTEM_MEMORY_POLICY_NAME_MISUSE("'sysMemPlc' policy name is reserved for internal use."),
/** */
TOO_SMALL_MEMORY_SIZE("MemoryPolicy must have size more than 1MB: "),
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
new file mode 100644
index 0000000..1e3f328
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/database/MemoryPolicyInitializationTest.java
@@ -0,0 +1,307 @@
+/*
+ * 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.processors.cache.database;
+
+import java.util.Collection;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.configuration.MemoryConfiguration.DFLT_MEM_PLC_DEFAULT_NAME;
+
+/**
+ *
+ */
+public class MemoryPolicyInitializationTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CUSTOM_NON_DEFAULT_MEM_PLC_NAME = "custom_mem_plc";
+
+ /** */
+ private static final long USER_CUSTOM_MEM_PLC_SIZE = 10 * 1024 * 1024;
+
+ /** */
+ private static final long USER_DEFAULT_MEM_PLC_SIZE = 99 * 1024 * 1024;
+
+ /** */
+ private MemoryConfiguration memCfg;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.setMemoryConfiguration(memCfg);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ memCfg = null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration.
+ */
+ public void testNoConfigProvided() throws Exception {
+ memCfg = null;
+
+ IgniteEx ignite = startGrid(0);
+
+ Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+
+ assertTrue(allMemPlcs.size() == 2);
+
+ verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+ }
+
+ /**
+ * Verifies that expected memory policies are allocated when used provides MemoryPolicyConfiguration
+ * with non-default custom MemoryPolicy.
+ */
+ public void testCustomConfigNoDefault() throws Exception {
+ prepareCustomNoDefaultConfig();
+
+ IgniteEx ignite = startGrid(0);
+
+ Collection<MemoryPolicy> allMemPlcs = ignite.context().cache().context().database().memoryPolicies();
+
+ assertTrue(allMemPlcs.size() == 3);
+
+ verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+ assertTrue("Custom non-default memory policy is not presented",
+ isMemoryPolicyPresented(allMemPlcs, CUSTOM_NON_DEFAULT_MEM_PLC_NAME));
+ }
+
+ /**
+ * User is allowed to configure memory policy with 'default' name,
+ * in that case Ignite instance will use this user-defined memory policy as a default one.
+ */
+ public void testCustomConfigOverridesDefault() throws Exception {
+ prepareCustomConfigWithOverridingDefault();
+
+ IgniteEx ignite = startGrid(0);
+
+ IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+
+ Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+
+ assertTrue(allMemPlcs.size() == 2);
+
+ verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+ MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+
+ assertTrue(dfltMemPlc.config().getSize() == USER_DEFAULT_MEM_PLC_SIZE);
+ }
+
+ /**
+ * User is allowed to define fully custom memory policy and make it default by setting its name to memory config.
+ *
+ * At the same time user still can create a memory policy with name 'default'
+ * which although won't be used as default.
+ */
+ public void testCustomConfigOverridesDefaultNameAndDeclaresDefault() throws Exception {
+ prepareCustomConfigWithOverriddenDefaultName();
+
+ IgniteEx ignite = startGrid(0);
+
+ IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
+
+ Collection<MemoryPolicy> allMemPlcs = dbMgr.memoryPolicies();
+
+ assertTrue(allMemPlcs.size() == 3);
+
+ verifyDefaultAndSystemMemoryPolicies(allMemPlcs);
+
+ MemoryPolicy dfltMemPlc = U.field(dbMgr, "dfltMemPlc");
+
+ assertTrue(dfltMemPlc.config().getSize() == USER_CUSTOM_MEM_PLC_SIZE);
+ }
+
+ /**
+ * Test for verification that caches with not specified memory policy name,
+ * with specified default memory policy name and specified custom memory policy name
+ * all started with correct memory policy.
+ */
+ public void testCachesOnOverriddenMemoryPolicy() throws Exception {
+ prepareCustomConfigWithOverridingDefaultAndCustom();
+
+ IgniteEx ignite = startGrid(0);
+
+ CacheConfiguration cache1Cfg = new CacheConfiguration()
+ .setName("cache1");
+
+ IgniteCache cache1 = ignite.createCache(cache1Cfg);
+
+ verifyCacheMemoryPolicy(cache1, DFLT_MEM_PLC_DEFAULT_NAME);
+
+ CacheConfiguration cache2Cfg = new CacheConfiguration()
+ .setName("cache2")
+ .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ IgniteCache cache2 = ignite.createCache(cache2Cfg);
+
+ verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ CacheConfiguration cache3Cfg = new CacheConfiguration()
+ .setName("cache3")
+ .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+
+ IgniteCache cache3 = ignite.createCache(cache3Cfg);
+
+ verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+ }
+
+ /**
+ * Test for verification that caches with not specified memory policy name,
+ * with specified default memory policy name and specified custom memory policy name
+ * all started with correct memory policy.
+ */
+ public void testCachesOnUserDefinedDefaultMemoryPolicy() throws Exception {
+ prepareCustomConfigWithOverriddenDefaultName();
+
+ IgniteEx ignite = startGrid(0);
+
+ CacheConfiguration cache1Cfg = new CacheConfiguration()
+ .setName("cache1");
+
+ IgniteCache cache1 = ignite.createCache(cache1Cfg);
+
+ verifyCacheMemoryPolicy(cache1, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ CacheConfiguration cache2Cfg = new CacheConfiguration()
+ .setName("cache2")
+ .setMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ IgniteCache cache2 = ignite.createCache(cache2Cfg);
+
+ verifyCacheMemoryPolicy(cache2, CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ CacheConfiguration cache3Cfg = new CacheConfiguration()
+ .setName("cache3")
+ .setMemoryPolicyName(DFLT_MEM_PLC_DEFAULT_NAME);
+
+ IgniteCache cache3 = ignite.createCache(cache3Cfg);
+
+ verifyCacheMemoryPolicy(cache3, DFLT_MEM_PLC_DEFAULT_NAME);
+ }
+
+ /**
+ * @param cache Cache.
+ * @param plcName Policy name.
+ */
+ private void verifyCacheMemoryPolicy(IgniteCache cache, String plcName) {
+ GridCacheContext ctx = U.field(cache, "ctx");
+
+ assertEquals(plcName, ctx.memoryPolicy().config().getName());
+ }
+
+ /**
+ *
+ */
+ private void prepareCustomConfigWithOverriddenDefaultName() {
+ memCfg = new MemoryConfiguration();
+
+ memCfg.setDefaultMemoryPolicyName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME);
+
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+ .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+ .setSize(USER_CUSTOM_MEM_PLC_SIZE),
+
+ new MemoryPolicyConfiguration()
+ .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+ .setSize(USER_DEFAULT_MEM_PLC_SIZE)
+ );
+ }
+
+
+ /**
+ *
+ */
+ private void prepareCustomConfigWithOverridingDefault() {
+ memCfg = new MemoryConfiguration();
+
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+ .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+ .setSize(USER_DEFAULT_MEM_PLC_SIZE)
+ );
+ }
+
+ /**
+ *
+ */
+ private void prepareCustomConfigWithOverridingDefaultAndCustom() {
+ memCfg = new MemoryConfiguration();
+
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+ .setName(DFLT_MEM_PLC_DEFAULT_NAME)
+ .setSize(USER_DEFAULT_MEM_PLC_SIZE),
+
+ new MemoryPolicyConfiguration()
+ .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+ .setSize(USER_CUSTOM_MEM_PLC_SIZE)
+ );
+ }
+
+ /**
+ * @param allMemPlcs Collection of all memory policies.
+ */
+ private void verifyDefaultAndSystemMemoryPolicies(Collection<MemoryPolicy> allMemPlcs) {
+ assertTrue("Default memory policy is not presented",
+ isMemoryPolicyPresented(allMemPlcs, DFLT_MEM_PLC_DEFAULT_NAME));
+
+ assertTrue("System memory policy is not presented",
+ isMemoryPolicyPresented(allMemPlcs, IgniteCacheDatabaseSharedManager.SYSTEM_MEMORY_POLICY_NAME));
+ }
+
+ /**
+ *
+ */
+ private void prepareCustomNoDefaultConfig() {
+ memCfg = new MemoryConfiguration();
+
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration()
+ .setName(CUSTOM_NON_DEFAULT_MEM_PLC_NAME)
+ .setSize(USER_CUSTOM_MEM_PLC_SIZE)
+ );
+ }
+
+ /**
+ * @param memPlcs Collection of memory policies.
+ * @param nameToVerify Excepted name of memory policy.
+ */
+ private boolean isMemoryPolicyPresented(Collection<MemoryPolicy> memPlcs, String nameToVerify) {
+ for (MemoryPolicy memPlc : memPlcs) {
+ if (nameToVerify.equals(memPlc.config().getName()))
+ return true;
+ }
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index 89e8f01..04a3753 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.cache.IgniteCachePartitionMapUpdate
import org.apache.ignite.internal.processors.cache.IgniteDynamicCacheAndNodeStop;
import org.apache.ignite.internal.processors.cache.IgniteOnePhaseCommitInvokeTest;
import org.apache.ignite.internal.processors.cache.MemoryPolicyConfigValidationTest;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicyInitializationTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.CacheLoadingConcurrentGridStartSelfTestAllowOverwrite;
import org.apache.ignite.internal.processors.cache.distributed.CacheLockReleaseNodeLeaveTest;
@@ -250,6 +251,7 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(NearCacheSyncUpdateTest.class));
suite.addTest(new TestSuite(CacheConfigurationLeakTest.class));
suite.addTest(new TestSuite(MemoryPolicyConfigValidationTest.class));
+ suite.addTest(new TestSuite(MemoryPolicyInitializationTest.class));
suite.addTest(new TestSuite(CacheMemoryPolicyConfigurationTest.class));
suite.addTest(new TestSuite(CacheEnumOperationsSingleNodeTest.class));
suite.addTest(new TestSuite(CacheEnumOperationsTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
index 9b1016d..9c4bb35 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryConfiguration.cs
@@ -56,12 +56,18 @@ namespace Apache.Ignite.Core.Cache.Configuration
public const int DefaultPageSize = 2 * 1024;
/// <summary>
+ /// The default value for <see cref="DefaultMemoryPolicyName"/>.
+ /// </summary>
+ public const string DefaultDefaultMemoryPolicyName = "default";
+
+ /// <summary>
/// Initializes a new instance of the <see cref="MemoryConfiguration"/> class.
/// </summary>
public MemoryConfiguration()
{
SystemCacheMemorySize = DefaultSystemCacheMemorySize;
PageSize = DefaultPageSize;
+ DefaultMemoryPolicyName = DefaultDefaultMemoryPolicyName;
}
/// <summary>
@@ -140,6 +146,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
/// <summary>
/// Gets or sets the name of the default memory policy in <see cref="MemoryPolicies"/>.
/// </summary>
+ [DefaultValue(DefaultDefaultMemoryPolicyName)]
public string DefaultMemoryPolicyName { get; set; }
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1dc9e698/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
index 9e21910..fe4e91f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/MemoryPolicyConfiguration.cs
@@ -42,6 +42,7 @@ namespace Apache.Ignite.Core.Cache.Configuration
{
EvictionThreshold = DefaultEvictionThreshold;
EmptyPagesPoolSize = DefaultEmptyPagesPoolSize;
+ Name = MemoryConfiguration.DefaultDefaultMemoryPolicyName;
}
/// <summary>
@@ -73,7 +74,9 @@ namespace Apache.Ignite.Core.Cache.Configuration
/// <summary>
/// Gets or sets the memory policy name.
+ /// Defaults to <see cref="MemoryConfiguration.DefaultDefaultMemoryPolicyName"/>.
/// </summary>
+ [DefaultValue(MemoryConfiguration.DefaultDefaultMemoryPolicyName)]
public string Name { get; set; }
/// <summary>
[07/50] [abbrv] ignite git commit: IGNITE-3521: IGFS: Removed
"maxSpace" property. This closes #1854.
Posted by vo...@apache.org.
IGNITE-3521: IGFS: Removed "maxSpace" property. This closes #1854.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7c249d7b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7c249d7b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7c249d7b
Branch: refs/heads/master
Commit: 7c249d7bbb3c6f65e2781e0da3cd21c62d2ce078
Parents: 5a43346
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Mon Apr 24 15:17:49 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Mon Apr 24 15:17:49 2017 +0300
----------------------------------------------------------------------
.../configuration/FileSystemConfiguration.java | 25 ----
.../org/apache/ignite/igfs/IgfsMetrics.java | 5 +-
.../processors/cache/GridCacheAdapter.java | 14 ---
.../processors/cache/GridCacheProcessor.java | 5 +-
.../processors/cache/GridCacheProxyImpl.java | 12 --
.../processors/cache/IgniteInternalCache.java | 7 --
.../dht/GridDhtTransactionalCacheAdapter.java | 1 -
.../dht/preloader/GridDhtPartitionDemander.java | 12 --
.../distributed/near/GridNearCacheAdapter.java | 5 -
.../processors/igfs/IgfsDataManager.java | 36 +-----
.../internal/visor/igfs/VisorIgfsMetrics.java | 3 +-
.../visor/node/VisorIgfsConfiguration.java | 13 --
.../processors/igfs/IgfsMaxSizeSelfTest.java | 121 -------------------
.../processors/igfs/IgfsSizeSelfTest.java | 50 +++++---
.../ignite/testsuites/IgniteIgfsTestSuite.java | 3 -
.../HadoopIgfs20FileSystemAbstractSelfTest.java | 1 -
.../cache/hibernate/HibernateCacheProxy.java | 5 -
.../cache/hibernate/HibernateCacheProxy.java | 5 -
18 files changed, 47 insertions(+), 276 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
index af5be3c..e36f857 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/FileSystemConfiguration.java
@@ -136,9 +136,6 @@ public class FileSystemConfiguration {
/** Path modes. */
private Map<String, IgfsMode> pathModes;
- /** Maximum space. */
- private long maxSpace;
-
/** Maximum range length. */
private long maxTaskRangeLen;
@@ -187,7 +184,6 @@ public class FileSystemConfiguration {
secondaryFs = cfg.getSecondaryFileSystem();
ipcEndpointCfg = cfg.getIpcEndpointConfiguration();
ipcEndpointEnabled = cfg.isIpcEndpointEnabled();
- maxSpace = cfg.getMaxSpaceSize();
maxTaskRangeLen = cfg.getMaximumTaskRangeLength();
metaCacheCfg = cfg.getMetaCacheConfiguration();
mgmtPort = cfg.getManagementPort();
@@ -682,27 +678,6 @@ public class FileSystemConfiguration {
}
/**
- * Get maximum space available for data cache to store file system entries.
- *
- * @return Maximum space available for data cache.
- */
- public long getMaxSpaceSize() {
- return maxSpace;
- }
-
- /**
- * Set maximum space in bytes available in data cache.
- *
- * @param maxSpace Maximum space available in data cache.
- * @return {@code this} for chaining.
- */
- public FileSystemConfiguration setMaxSpaceSize(long maxSpace) {
- this.maxSpace = maxSpace;
-
- return this;
- }
-
- /**
* Get maximum default range size of a file being split during IGFS task execution. When IGFS task is about to
* be executed, it requests file block locations first. Each location is defined as {@link org.apache.ignite.igfs.mapreduce.IgfsFileRange} which
* has length. In case this parameter is set to positive value, then IGFS will split single file range into smaller
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
index 3283eaf..28225fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/igfs/IgfsMetrics.java
@@ -32,9 +32,8 @@ public interface IgfsMetrics {
public long localSpaceSize();
/**
- * Gets maximum amount of data that can be stored on local node. This metrics is either
- * equal to {@link org.apache.ignite.configuration.FileSystemConfiguration#getMaxSpaceSize()}, or, if it is {@code 0}, equal to
- * {@code 80%} of maximum heap size allocated for JVM.
+ * Gets maximum amount of data that can be stored on local node. This metrics is related to
+ * to the {@link org.apache.ignite.configuration.MemoryPolicyConfiguration#getSize()} of the IGFS data cache.
*
* @return Maximum IGFS local space size.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index c9f7430..b364df8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -278,9 +278,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** Current IGFS data cache size. */
private LongAdder8 igfsDataCacheSize;
- /** Max space for IGFS. */
- private long igfsDataSpaceMax;
-
/** Asynchronous operations limit semaphore. */
private Semaphore asyncOpsSem;
@@ -338,12 +335,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (!ctx.isNear()) {
igfsDataCache = true;
igfsDataCacheSize = new LongAdder8();
-
- igfsDataSpaceMax = igfsCfg.getMaxSpaceSize();
-
- // Do we have limits?
- if (igfsDataSpaceMax <= 0)
- igfsDataSpaceMax = Long.MAX_VALUE;
}
break;
@@ -4363,11 +4354,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
- @Override public long igfsDataSpaceMax() {
- return igfsDataSpaceMax;
- }
-
- /** {@inheritDoc} */
@Override public boolean isMongoDataCache() {
return mongoDataCache;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index a555b55..4b79361 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -738,10 +738,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
else
cacheType = CacheType.USER;
- if (cacheType != CacheType.USER)
- cfg.setMemoryPolicyName(sharedCtx.database().systemMemoryPolicyName());
-
- if (cacheType != CacheType.USER)
+ if (cacheType != CacheType.USER && cfg.getMemoryPolicyName() == null)
cfg.setMemoryPolicyName(sharedCtx.database().systemMemoryPolicyName());
boolean template = cfg.getName() != null && cfg.getName().endsWith("*");
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 2979a57..837c22a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -454,18 +454,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
- @Override public long igfsDataSpaceMax() {
- CacheOperationContext prev = gate.enter(opCtx);
-
- try {
- return delegate.igfsDataSpaceMax();
- }
- finally {
- gate.leave(prev);
- }
- }
-
- /** {@inheritDoc} */
@Override public boolean isMongoDataCache() {
CacheOperationContext prev = gate.enter(opCtx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index ce65fd2..cc7fd3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -1719,13 +1719,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
public long igfsDataSpaceUsed();
/**
- * Get maximum space available for IGFS.
- *
- * @return Amount of space available for IGFS in bytes.
- */
- public long igfsDataSpaceMax();
-
- /**
* Checks whether this cache is Mongo data cache.
*
* @return {@code True} if this cache is mongo data cache.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 6af1ef7..c91eb7a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -55,7 +55,6 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSing
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTransactionalCache;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxRemote;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest;
-import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index d71a3ad..75cbd00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -56,7 +56,6 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteInClosure;
@@ -744,17 +743,6 @@ public class GridDhtPartitionDemander {
if (log.isDebugEnabled())
log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + pick.id() + ']');
- if (cctx.dht().isIgfsDataCache() &&
- cctx.dht().igfsDataSpaceUsed() > cctx.dht().igfsDataSpaceMax()) {
- LT.error(log, null, "Failed to rebalance IGFS data cache (IGFS space size exceeded maximum " +
- "value, will ignore rebalance entries)");
-
- if (cached.markObsoleteIfEmpty(null))
- cached.context().cache().removeEntry(cached);
-
- return true;
- }
-
if (preloadPred == null || preloadPred.apply(entry)) {
if (cached.initialValue(
entry.value(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index f4ba043..59d986a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -403,11 +403,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
}
/** {@inheritDoc} */
- @Override public long igfsDataSpaceMax() {
- return dht().igfsDataSpaceMax();
- }
-
- /** {@inheritDoc} */
@Override public void onIgfsDataSizeChanged(long delta) {
dht().onIgfsDataSizeChanged(delta);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
index acd0a1f..7fa2355 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsDataManager.java
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.managers.communication.GridIoPolicy;
import org.apache.ignite.internal.managers.communication.GridMessageListener;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.database.MemoryPolicy;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerCacheUpdaters;
import org.apache.ignite.internal.processors.igfs.data.IgfsDataPutProcessor;
@@ -242,7 +243,11 @@ public class IgfsDataManager extends IgfsManager {
* @return Maximum number of bytes for IGFS data cache.
*/
public long maxSpaceSize() {
- return (igfsCtx.configuration().getMaxSpaceSize() <= 0) ? 0 : dataCachePrj.igfsDataSpaceMax();
+ MemoryPolicy plc = dataCachePrj.context().memoryPolicy();
+
+ long size = plc != null ? plc.config().getSize() : 0;
+
+ return (size <= 0) ? 0 : size ;
}
/**
@@ -1022,27 +1027,6 @@ public class IgfsDataManager extends IgfsManager {
*/
private void processPartialBlockWrite(IgniteUuid fileId, IgfsBlockKey colocatedKey, int startOff,
byte[] data, int blockSize) throws IgniteCheckedException {
- if (dataCachePrj.igfsDataSpaceUsed() >= dataCachePrj.igfsDataSpaceMax()) {
- final WriteCompletionFuture completionFut = pendingWrites.get(fileId);
-
- if (completionFut == null) {
- if (log.isDebugEnabled())
- log.debug("Missing completion future for file write request (most likely exception occurred " +
- "which will be thrown upon stream close) [fileId=" + fileId + ']');
-
- return;
- }
-
- IgfsOutOfSpaceException e = new IgfsOutOfSpaceException("Failed to write data block " +
- "(IGFS maximum data size exceeded) [used=" + dataCachePrj.igfsDataSpaceUsed() +
- ", allowed=" + dataCachePrj.igfsDataSpaceMax() + ']');
-
- completionFut.onDone(new IgniteCheckedException("Failed to write data (not enough space on node): " +
- igfsCtx.kernalContext().localNodeId(), e));
-
- return;
- }
-
// No affinity key present, just concat and return.
if (colocatedKey.affinityKey() == null) {
dataCachePrj.invoke(colocatedKey, new UpdateProcessor(startOff, data));
@@ -1097,14 +1081,6 @@ public class IgfsDataManager extends IgfsManager {
@SuppressWarnings("unchecked")
private IgniteInternalFuture<?> storeBlocksAsync(Map<IgfsBlockKey, byte[]> blocks) {
assert !blocks.isEmpty();
-
- if (dataCachePrj.igfsDataSpaceUsed() >= dataCachePrj.igfsDataSpaceMax()) {
- return new GridFinishedFuture<Object>(
- new IgfsOutOfSpaceException("Failed to write data block (IGFS maximum data size " +
- "exceeded) [used=" + dataCachePrj.igfsDataSpaceUsed() +
- ", allowed=" + dataCachePrj.igfsDataSpaceMax() + ']'));
- }
-
return dataCachePrj.putAllAsync(blocks);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
index 6ce5d80..f90ca89 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/igfs/VisorIgfsMetrics.java
@@ -22,6 +22,7 @@ import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.igfs.IgfsMetrics;
+import org.apache.ignite.internal.processors.igfs.IgfsEx;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.visor.VisorDataTransferObject;
@@ -91,7 +92,7 @@ public class VisorIgfsMetrics extends VisorDataTransferObject {
IgfsMetrics m = igfs.metrics();
- totalSpaceSz = igfs.configuration().getMaxSpaceSize();
+ totalSpaceSz = ((IgfsEx)igfs).context().data().maxSpaceSize();
usedSpaceSz = m.localSpaceSize();
foldersCnt = m.directoriesCount();
filesCnt = m.filesCount();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
index 3b97129..db91982 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorIgfsConfiguration.java
@@ -92,9 +92,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
/** IPC endpoint enabled flag. */
private boolean ipcEndpointEnabled;
- /** Maximum space. */
- private long maxSpace;
-
/** Management port. */
private int mgmtPort;
@@ -135,7 +132,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
ipcEndpointCfg = endpointCfg != null ? endpointCfg.toString() : null;
ipcEndpointEnabled = igfs.isIpcEndpointEnabled();
- maxSpace = igfs.getMaxSpaceSize();
mgmtPort = igfs.getManagementPort();
seqReadsBeforePrefetch = igfs.getSequentialReadsBeforePrefetch();
}
@@ -277,13 +273,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
}
/**
- * @return Maximum space.
- */
- public long getMaxSpace() {
- return maxSpace;
- }
-
- /**
* @return Management port.
*/
public int getManagementPort() {
@@ -316,7 +305,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
out.writeLong(fragmentizerThrottlingDelay);
U.writeString(out, ipcEndpointCfg);
out.writeBoolean(ipcEndpointEnabled);
- out.writeLong(maxSpace);
out.writeInt(mgmtPort);
out.writeInt(seqReadsBeforePrefetch);
}
@@ -340,7 +328,6 @@ public class VisorIgfsConfiguration extends VisorDataTransferObject {
fragmentizerThrottlingDelay = in.readLong();
ipcEndpointCfg = U.readString(in);
ipcEndpointEnabled = in.readBoolean();
- maxSpace = in.readLong();
mgmtPort = in.readInt();
seqReadsBeforePrefetch = in.readInt();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
deleted file mode 100644
index 2e0be3f..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsMaxSizeSelfTest.java
+++ /dev/null
@@ -1,121 +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.internal.processors.igfs;
-
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.FileSystemConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
-import org.apache.ignite.internal.IgniteEx;
-
-/**
- * Check max size limit.
- */
-@SuppressWarnings("ConstantConditions")
-public class IgfsMaxSizeSelfTest extends IgfsCommonAbstractTest {
- /** Work directory. */
- private static long maxSize;
-
- /** {@inheritDoc} */
- @SuppressWarnings("unchecked")
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
- igfsCfg.setName("test");
-
- if (maxSize > 0)
- igfsCfg.setMaxSpaceSize(maxSize);
-
- CacheConfiguration dataCacheCfg = defaultCacheConfiguration();
-
- dataCacheCfg.setName("dataCache");
- dataCacheCfg.setCacheMode(CacheMode.PARTITIONED);
- dataCacheCfg.setNearConfiguration(null);
- dataCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(2));
- dataCacheCfg.setBackups(0);
- dataCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
- CacheConfiguration metaCacheCfg = defaultCacheConfiguration();
-
- metaCacheCfg.setName("metaCache");
- metaCacheCfg.setNearConfiguration(null);
- metaCacheCfg.setCacheMode(CacheMode.REPLICATED);
- metaCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- metaCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-
- igfsCfg.setDataCacheConfiguration(dataCacheCfg);
- igfsCfg.setMetaCacheConfiguration(metaCacheCfg);
-
- cfg.setFileSystemConfiguration(igfsCfg);
- cfg.setIgniteInstanceName(igniteInstanceName);
-
- return cfg;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDefaultOrZero() throws Exception {
- IgniteEx ig = startGrid(0);
-
- try {
- assertEquals(0, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNegative() throws Exception {
- maxSize = -1;
-
- IgniteEx ig = startGrid(0);
-
- try {
- assertEquals(0, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testPositive() throws Exception {
- maxSize = 1 << 20;
-
- IgniteEx ig = startGrid(0);
-
- try {
- assertEquals(maxSize, ((IgfsImpl)ig.igfsx("test")).globalSpace().spaceTotal());
- }
- finally {
- stopAllGrids();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
index 645f341..fbe0872 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsSizeSelfTest.java
@@ -17,6 +17,8 @@
package org.apache.ignite.internal.processors.igfs;
+import java.io.IOException;
+import java.util.concurrent.Callable;
import org.apache.ignite.Ignite;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -24,17 +26,20 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
import org.apache.ignite.igfs.IgfsInputStream;
-import org.apache.ignite.igfs.IgfsOutOfSpaceException;
import org.apache.ignite.igfs.IgfsOutputStream;
import org.apache.ignite.igfs.IgfsPath;
import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.mem.IgniteOutOfMemoryException;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
@@ -42,14 +47,12 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.jsr166.ThreadLocalRandom8;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.Callable;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -87,14 +90,13 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
/** Whether near cache is enabled (applicable for PARTITIONED cache only). */
private boolean nearEnabled;
- /** IGFS maximum space. */
- private long igfsMaxData;
+ /** Mem policy setter. */
+ private IgniteInClosure<IgniteConfiguration> memIgfsdDataPlcSetter;
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
cacheMode = null;
nearEnabled = false;
- igfsMaxData = 0;
mgmtPort = 11400;
}
@@ -113,7 +115,6 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
igfsCfg.setName(IGFS_NAME);
igfsCfg.setBlockSize(BLOCK_SIZE);
igfsCfg.setFragmentizerEnabled(false);
- igfsCfg.setMaxSpaceSize(igfsMaxData);
igfsCfg.setManagementPort(++mgmtPort);
CacheConfiguration dataCfg = defaultCacheConfiguration();
@@ -150,6 +151,9 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
cfg.setDiscoverySpi(discoSpi);
cfg.setFileSystemConfiguration(igfsCfg);
+ if (memIgfsdDataPlcSetter != null)
+ memIgfsdDataPlcSetter.apply(cfg);
+
return cfg;
}
@@ -221,7 +225,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
cacheMode = PARTITIONED;
nearEnabled = false;
- check();
+ checkOversize();
}
/**
@@ -232,7 +236,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
public void testReplicatedOversize() throws Exception {
cacheMode = REPLICATED;
- check();
+ checkOversize();
}
/**
@@ -386,15 +390,32 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
* @throws Exception If failed.
*/
private void checkOversize() throws Exception {
- igfsMaxData = BLOCK_SIZE;
+ final long maxSize = 32 * 1024 * 1024;
+
+ memIgfsdDataPlcSetter = new IgniteInClosure<IgniteConfiguration>() {
+ @Override public void apply(IgniteConfiguration cfg) {
+ String memPlcName = "igfsDataMemPlc";
+
+ cfg.setMemoryConfiguration(new MemoryConfiguration().setMemoryPolicies(
+ new MemoryPolicyConfiguration().setSize(maxSize).setName(memPlcName)));
+
+ FileSystemConfiguration igfsCfg = cfg.getFileSystemConfiguration()[0];
+
+ igfsCfg.getDataCacheConfiguration().setMemoryPolicyName(memPlcName);
+
+ cfg.setCacheConfiguration(new CacheConfiguration().setName("QQQ").setMemoryPolicyName(memPlcName));
+ }
+ };
startUp();
final IgfsPath path = new IgfsPath("/file");
+ final int writeChunkSize = (int)(maxSize / 1024);
+
// This write is expected to be successful.
IgfsOutputStream os = igfs(0).create(path, false);
- os.write(chunk(BLOCK_SIZE - 1));
+ os.write(chunk(writeChunkSize));
os.close();
// This write must be successful as well.
@@ -408,7 +429,9 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
IgfsOutputStream osErr = igfs(0).append(path, false);
try {
- osErr.write(chunk(BLOCK_SIZE));
+ for (int i = 0; i < maxSize / writeChunkSize * GRID_CNT; ++i)
+ osErr.write(chunk(writeChunkSize));
+
osErr.close();
return null;
@@ -425,8 +448,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
U.closeQuiet(osErr);
}
}
- }, IgfsOutOfSpaceException.class, "Failed to write data block (IGFS maximum data size exceeded) [used=" +
- igfsMaxData + ", allowed=" + igfsMaxData + ']');
+ }, IgniteOutOfMemoryException.class, "Not enough memory allocated");
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index 7efc7de..b16f7e9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -32,7 +32,6 @@ import org.apache.ignite.internal.processors.igfs.IgfsCacheSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsDualAsyncClientSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsDualSyncClientSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsLocalSecondaryFileSystemProxyClientSelfTest;
-import org.apache.ignite.internal.processors.igfs.IgfsMaxSizeSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsPrimaryClientSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsDataManagerSelfTest;
import org.apache.ignite.internal.processors.igfs.IgfsDualAsyncSelfTest;
@@ -150,8 +149,6 @@ public class IgniteIgfsTestSuite extends TestSuite {
// TODO: Enable when IGFS failover is fixed.
//suite.addTestSuite(IgfsBackupFailoverSelfTest.class);
- suite.addTestSuite(IgfsMaxSizeSelfTest.class);
-
suite.addTestSuite(IgfsProxySelfTest.class);
suite.addTestSuite(IgfsLocalSecondaryFileSystemProxySelfTest.class);
suite.addTestSuite(IgfsLocalSecondaryFileSystemProxyClientSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
index 77e6757..016fadf 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/impl/igfs/HadoopIgfs20FileSystemAbstractSelfTest.java
@@ -305,7 +305,6 @@ public abstract class HadoopIgfs20FileSystemAbstractSelfTest extends IgfsCommonA
cfg.setName("igfs");
cfg.setPrefetchBlocks(1);
- cfg.setMaxSpaceSize(64 * 1024 * 1024);
cfg.setDefaultMode(mode);
cfg.setMetaCacheConfiguration(metaCacheConfiguration(igniteInstanceName));
cfg.setDataCacheConfiguration(dataCacheConfiguration(igniteInstanceName));
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index 48fc1f8..7204083 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -627,11 +627,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
}
/** {@inheritDoc} */
- @Override public long igfsDataSpaceMax() {
- return delegate.igfsDataSpaceMax();
- }
-
- /** {@inheritDoc} */
@Override public boolean isMongoDataCache() {
return delegate.isMongoDataCache();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7c249d7b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
index 48fc1f8..7204083 100644
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -627,11 +627,6 @@ public class HibernateCacheProxy implements IgniteInternalCache<Object, Object>
}
/** {@inheritDoc} */
- @Override public long igfsDataSpaceMax() {
- return delegate.igfsDataSpaceMax();
- }
-
- /** {@inheritDoc} */
@Override public boolean isMongoDataCache() {
return delegate.isMongoDataCache();
}
[05/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/ignite-2.0' into ignite-2.0
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/ignite-2.0' into ignite-2.0
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1214d7e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1214d7e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1214d7e7
Branch: refs/heads/master
Commit: 1214d7e7e0d0853559e0017366efaf10927aa898
Parents: 3192806 7378bc3
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 13:21:36 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 13:21:36 2017 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/ml/math/Algebra.java | 89 +++++++++-------
.../ignite/ml/math/IdentityValueMapper.java | 3 +-
.../java/org/apache/ignite/ml/math/Matrix.java | 32 +++---
.../org/apache/ignite/ml/math/MurmurHash.java | 16 +--
.../java/org/apache/ignite/ml/math/Tracer.java | 4 +-
.../java/org/apache/ignite/ml/math/Vector.java | 3 +-
.../decompositions/CholeskyDecomposition.java | 8 +-
.../math/decompositions/EigenDecomposition.java | 4 +-
.../ml/math/decompositions/LUDecomposition.java | 8 +-
.../ignite/ml/math/functions/Functions.java | 21 +++-
.../ml/math/impls/matrix/PivotedMatrixView.java | 2 +-
.../impls/matrix/SparseDistributedMatrix.java | 12 +--
.../storage/matrix/CacheMatrixStorage.java | 15 ++-
.../matrix/DenseOffHeapMatrixStorage.java | 14 ++-
.../storage/matrix/FunctionMatrixStorage.java | 16 +--
.../matrix/SparseLocalOnHeapMatrixStorage.java | 18 ++--
.../storage/vector/CacheVectorStorage.java | 12 +--
.../storage/vector/ConstantVectorStorage.java | 9 +-
.../storage/vector/FunctionVectorStorage.java | 16 +--
.../storage/vector/MatrixVectorStorage.java | 18 ++--
.../storage/vector/PivotedVectorStorage.java | 15 +--
.../SingleElementVectorDelegateStorage.java | 12 +--
.../vector/SingleElementVectorStorage.java | 10 +-
.../vector/SparseLocalOffHeapVectorStorage.java | 2 +
.../vector/SparseLocalOnHeapVectorStorage.java | 9 +-
.../ml/math/impls/vector/MatrixVectorView.java | 19 ++--
.../ml/math/impls/vector/PivotedVectorView.java | 13 +--
.../ml/math/impls/vector/RandomVector.java | 5 +-
.../math/impls/vector/SingleElementVector.java | 103 +------------------
.../org/apache/ignite/ml/math/TracerTest.java | 11 +-
.../ml/math/impls/matrix/CacheMatrixTest.java | 10 +-
.../impls/matrix/MatrixKeyMapperForTests.java | 19 ++--
.../storage/matrix/MatrixStorageFixtures.java | 18 ++--
.../SparseLocalOffHeapVectorStorageTest.java | 3 +-
.../math/impls/vector/AbstractVectorTest.java | 41 ++++----
.../ml/math/impls/vector/CacheVectorTest.java | 4 +-
36 files changed, 305 insertions(+), 309 deletions(-)
----------------------------------------------------------------------
[34/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
deleted file mode 100644
index 13956dc..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
+++ /dev/null
@@ -1,1949 +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.hibernate;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.ObjectNotFoundException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.Transaction;
-import org.hibernate.annotations.NaturalId;
-import org.hibernate.annotations.NaturalIdCache;
-import org.hibernate.cache.spi.GeneralDataRegion;
-import org.hibernate.cache.spi.TransactionalDataRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.exception.ConstraintViolationException;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.stat.NaturalIdCacheStatistics;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_ACCESS_TYPE_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.IGNITE_INSTANCE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.REGION_CACHE_PROPERTY;
-import static org.hibernate.cfg.Environment.CACHE_REGION_FACTORY;
-import static org.hibernate.cfg.Environment.GENERATE_STATISTICS;
-import static org.hibernate.cfg.Environment.HBM2DDL_AUTO;
-import static org.hibernate.cfg.Environment.RELEASE_CONNECTIONS;
-import static org.hibernate.cfg.Environment.USE_QUERY_CACHE;
-import static org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE;
-
-/**
- *
- * Tests Hibernate L2 cache.
- */
-public class HibernateL2CacheSelfTest extends GridCommonAbstractTest {
- /** */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
- /** */
- public static final String ENTITY_NAME = Entity.class.getName();
-
- /** */
- public static final String ENTITY2_NAME = Entity2.class.getName();
-
- /** */
- public static final String VERSIONED_ENTITY_NAME = VersionedEntity.class.getName();
-
- /** */
- public static final String PARENT_ENTITY_NAME = ParentEntity.class.getName();
-
- /** */
- public static final String CHILD_COLLECTION_REGION = ENTITY_NAME + ".children";
-
- /** */
- public static final String NATURAL_ID_REGION =
- "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity##NaturalId";
-
- /** */
- public static final String NATURAL_ID_REGION2 =
- "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity2##NaturalId";
-
- /** */
- private SessionFactory sesFactory1;
-
- /** */
- private SessionFactory sesFactory2;
-
- /**
- * First Hibernate test entity.
- */
- @javax.persistence.Entity
- @NaturalIdCache
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class Entity {
- /** */
- private int id;
-
- /** */
- private String name;
-
- /** */
- private Collection<ChildEntity> children;
-
- /**
- * Default constructor required by Hibernate.
- */
- public Entity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param name Name.
- */
- public Entity(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Name.
- */
- @NaturalId(mutable = true)
- public String getName() {
- return name;
- }
-
- /**
- * @param name Name.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Children.
- */
- @OneToMany(cascade=javax.persistence.CascadeType.ALL, fetch=FetchType.LAZY)
- @JoinColumn(name="ENTITY_ID")
- public Collection<ChildEntity> getChildren() {
- return children;
- }
-
- /**
- * @param children Children.
- */
- public void setChildren(Collection<ChildEntity> children) {
- this.children = children;
- }
- }
-
- /**
- * Second Hibernate test entity.
- */
- @javax.persistence.Entity
- @NaturalIdCache
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class Entity2 {
- /** */
- private int id;
-
- /** */
- private String name;
-
- /** */
- private Collection<ChildEntity> children;
-
- /**
- * Default constructor required by Hibernate.
- */
- public Entity2() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param name Name.
- */
- public Entity2(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Name.
- */
- @NaturalId(mutable = true)
- public String getName() {
- return name;
- }
-
- /**
- * @param name Name.
- */
- public void setName(String name) {
- this.name = name;
- }
- }
-
- /**
- * Hibernate child entity referenced by {@link Entity}.
- */
- @javax.persistence.Entity
- @SuppressWarnings("PublicInnerClass")
- public static class ChildEntity {
- /** */
- private int id;
-
- /**
- * Default constructor required by Hibernate.
- */
- public ChildEntity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- */
- public ChildEntity(int id) {
- this.id = id;
- }
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Hibernate entity referencing {@link Entity}.
- */
- @javax.persistence.Entity
- @SuppressWarnings("PublicInnerClass")
- public static class ParentEntity {
- /** */
- private int id;
-
- /** */
- private Entity entity;
-
- /**
- * Default constructor required by Hibernate.
- */
- public ParentEntity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param entity Referenced entity.
- */
- public ParentEntity(int id, Entity entity) {
- this.id = id;
- this.entity = entity;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Referenced entity.
- */
- @OneToOne
- public Entity getEntity() {
- return entity;
- }
-
- /**
- * @param entity Referenced entity.
- */
- public void setEntity(Entity entity) {
- this.entity = entity;
- }
- }
-
- /**
- * Hibernate entity.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class VersionedEntity {
- /** */
- private int id;
-
- /** */
- private long ver;
-
- /**
- * Default constructor required by Hibernate.
- */
- public VersionedEntity() {
- }
-
- /**
- * @param id ID.
- */
- public VersionedEntity(int id) {
- this.id = id;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Version.
- */
- @javax.persistence.Version
- public long getVersion() {
- return ver;
- }
-
- /**
- * @param ver Version.
- */
- public void setVersion(long ver) {
- this.ver = ver;
- }
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(discoSpi);
-
- cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"),
- generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"),
- transactionalRegionConfiguration(ENTITY_NAME),
- transactionalRegionConfiguration(ENTITY2_NAME),
- transactionalRegionConfiguration(VERSIONED_ENTITY_NAME),
- transactionalRegionConfiguration(PARENT_ENTITY_NAME),
- transactionalRegionConfiguration(CHILD_COLLECTION_REGION),
- transactionalRegionConfiguration(NATURAL_ID_REGION),
- transactionalRegionConfiguration(NATURAL_ID_REGION2));
-
- return cfg;
- }
-
- /**
- * @param regionName Region name.
- * @return Cache configuration for {@link GeneralDataRegion}.
- */
- private CacheConfiguration generalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(regionName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(ATOMIC);
-
- cfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setBackups(1);
-
- cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- return cfg;
- }
-
- /**
- * @param regionName Region name.
- * @return Cache configuration for {@link TransactionalDataRegion}.
- */
- protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(regionName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(TRANSACTIONAL);
-
- cfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setBackups(1);
-
- cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- return cfg;
- }
-
- /**
- * @param accessType Hibernate L2 cache access type.
- * @param igniteInstanceName Ignite instance name.
- * @return Hibernate configuration.
- */
- private Configuration hibernateConfiguration(AccessType accessType,
- String igniteInstanceName) {
- Configuration cfg = new Configuration();
-
- cfg.addAnnotatedClass(Entity.class);
- cfg.addAnnotatedClass(Entity2.class);
- cfg.addAnnotatedClass(VersionedEntity.class);
- cfg.addAnnotatedClass(ChildEntity.class);
- cfg.addAnnotatedClass(ParentEntity.class);
-
- cfg.setCacheConcurrencyStrategy(ENTITY_NAME, accessType.getExternalName());
- cfg.setCacheConcurrencyStrategy(ENTITY2_NAME, accessType.getExternalName());
- cfg.setCacheConcurrencyStrategy(VERSIONED_ENTITY_NAME, accessType.getExternalName());
- cfg.setCacheConcurrencyStrategy(PARENT_ENTITY_NAME, accessType.getExternalName());
- cfg.setCollectionCacheConcurrencyStrategy(CHILD_COLLECTION_REGION, accessType.getExternalName());
-
- cfg.setProperty(HBM2DDL_AUTO, "create");
-
- cfg.setProperty(GENERATE_STATISTICS, "true");
-
- cfg.setProperty(USE_SECOND_LEVEL_CACHE, "true");
-
- cfg.setProperty(USE_QUERY_CACHE, "true");
-
- cfg.setProperty(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
-
- cfg.setProperty(RELEASE_CONNECTIONS, "on_close");
-
- cfg.setProperty(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
-
- // Use the same cache for Entity and Entity2.
- cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);
-
- cfg.setProperty(DFLT_ACCESS_TYPE_PROPERTY, accessType.name());
-
- return cfg;
- }
-
- /**
- * @return Hibernate registry builder.
- */
- protected ServiceRegistryBuilder registryBuilder() {
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
-
- builder.applySetting("hibernate.connection.url", CONNECTION_URL);
-
- return builder;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(2);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- cleanup();
- }
-
- /**
- * @return Hibernate L2 cache access types to test.
- */
- protected AccessType[] accessTypes() {
- return new AccessType[]{AccessType.READ_ONLY, AccessType.NONSTRICT_READ_WRITE, AccessType.READ_WRITE};
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollectionCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testCollectionCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- @SuppressWarnings("unchecked")
- private void testCollectionCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, Integer> idToChildCnt = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- Entity e = new Entity(i, "name-" + i);
-
- Collection<ChildEntity> children = new ArrayList<>();
-
- for (int j = 0; j < 3; j++)
- children.add(new ChildEntity());
-
- e.setChildren(children);
-
- idToChildCnt.put(e.getId(), e.getChildren().size());
-
- ses.save(e);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Load children, this should populate cache.
-
- ses = sesFactory1.openSession();
-
- try {
- List<Entity> list = ses.createCriteria(ENTITY_NAME).list();
-
- assertEquals(idToChildCnt.size(), list.size());
-
- for (Entity e : list)
- assertEquals((int)idToChildCnt.get(e.getId()), e.getChildren().size());
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 3, 0);
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- // Update children for one entity.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.getChildren().remove(e1.getChildren().iterator().next());
-
- ses.update(e1);
-
- idToChildCnt.put(e1.getId(), e1.getChildren().size());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
-
- // Update children for the same entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.getChildren().remove(e1.getChildren().iterator().next());
-
- ses.update(e1);
-
- idToChildCnt.put(e1.getId(), e1.getChildren().size());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testEntityCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testEntityCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testEntityCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, String> idToName = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 2; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- idToName.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates and inserts in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed1");
-
- ses.update(e0);
-
- idToName.put(0, e0.getName());
-
- ses.save(new Entity(2, "name-2"));
-
- idToName.put(2, "name-2");
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-1-changed1");
-
- ses.update(e1);
-
- idToName.put(1, e1.getName());
-
- ses.save(new Entity(3, "name-3"));
-
- idToName.put(3, "name-3");
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates, inserts and deletes in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity(4, "name-4"));
-
- idToName.put(4, "name-4");
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed2");
-
- ses.update(e0);
-
- idToName.put(e0.getId(), e0.getName());
-
- ses.delete(ses.load(Entity.class, 1));
-
- idToName.remove(1);
-
- Entity e2 = (Entity)ses.load(Entity.class, 2);
-
- e2.setName("name-2-changed1");
-
- ses.update(e2);
-
- idToName.put(e2.getId(), e2.getName());
-
- ses.delete(ses.load(Entity.class, 3));
-
- idToName.remove(3);
-
- ses.save(new Entity(5, "name-5"));
-
- idToName.put(5, "name-5");
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 1, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 1, 3);
-
- // Try to update the same entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed3");
-
- ses.update(e0);
-
- idToName.put(e0.getId(), e0.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTwoEntitiesSameCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testTwoEntitiesSameCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testTwoEntitiesSameCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- Map<Integer, String> idToName1 = new HashMap<>();
- Map<Integer, String> idToName2 = new HashMap<>();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 2; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
- ses.save(new Entity2(i, name));
-
- idToName1.put(i, name);
- idToName2.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates both entities in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 0);
-
- e.setName("name-0-changed1");
-
- ses.update(e);
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 0);
-
- e2.setName("name-e2-0-changed1");
-
- ses.update(e2);
-
- idToName1.put(0, e.getName());
- idToName2.put(0, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory1.openSession();
-
- try {
- // Remove entity1 and insert entity2 in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 0);
-
- ses.delete(e);
-
- Entity2 e2 = new Entity2(2, "name-2");
-
- ses.save(e2);
-
- idToName1.remove(0);
- idToName2.put(2, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- // Update, remove, insert in single transaction, transaction fails.
-
- Entity e = (Entity)ses.load(Entity.class, 1);
-
- e.setName("name-1-changed1");
-
- ses.update(e); // Valid update.
-
- ses.save(new Entity(2, "name-2")); // Valid insert.
-
- ses.delete(ses.load(Entity2.class, 0)); // Valid delete.
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
-
- e2.setName("name-2"); // Invalid update, not-unique name.
-
- ses.update(e2);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 2, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 2, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory2.openSession();
-
- try {
- // Update, remove, insert in single transaction.
-
- tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 1);
-
- e.setName("name-1-changed1");
-
- ses.update(e);
-
- idToName1.put(1, e.getName());
-
- ses.save(new Entity(2, "name-2"));
-
- idToName1.put(2, "name-2");
-
- ses.delete(ses.load(Entity2.class, 0));
-
- idToName2.remove(0);
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
-
- e2.setName("name-e2-2-changed");
-
- ses.update(e2);
-
- idToName2.put(1, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 0, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 0, 100);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testVersionedEntity() throws Exception {
- for (AccessType accessType : accessTypes())
- testVersionedEntity(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testVersionedEntity(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- VersionedEntity e0 = new VersionedEntity(0);
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(e0);
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- long ver;
-
- try {
- ver = ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion();
- }
- finally {
- ses.close();
- }
-
- SecondLevelCacheStatistics stats1 =
- sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
- SecondLevelCacheStatistics stats2 =
- sesFactory2.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
-
- assertEquals(1, stats1.getElementCountInMemory());
- assertEquals(1, stats2.getElementCountInMemory());
-
- ses = sesFactory2.openSession();
-
- try {
- assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
- }
- finally {
- ses.close();
- }
-
- assertEquals(1, stats2.getElementCountInMemory());
- assertEquals(1, stats2.getHitCount());
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- e0.setVersion(ver - 1);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- ses.update(e0);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (StaleObjectStateException e) {
- log.info("Expected exception: " + e);
- }
- finally {
- tx.rollback();
-
- ses.close();
- }
-
- sesFactory1.getStatistics().clear();
-
- stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
-
- ses = sesFactory1.openSession();
-
- try {
- assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
- }
- finally {
- ses.close();
- }
-
- assertEquals(1, stats1.getElementCountInMemory());
- assertEquals(1, stats1.getHitCount());
- assertEquals(1, stats2.getElementCountInMemory());
- assertEquals(1, stats2.getHitCount());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNaturalIdCache() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1084");
-
- for (AccessType accessType : accessTypes())
- testNaturalIdCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testNaturalIdCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<String, Integer> nameToId = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- nameToId.put(name, i);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- try {
- for (Map.Entry<String, Integer> e : nameToId.entrySet())
- ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-100");
- assertNaturalIdCache(sesFactory1, nameToId, "name-100");
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- // Update naturalId.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- nameToId.remove(e1.getName());
-
- e1.setName("name-1-changed1");
-
- nameToId.put(e1.getName(), e1.getId());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-1");
- assertNaturalIdCache(sesFactory1, nameToId, "name-1");
-
- // Update entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- nameToId.remove(e1.getName());
-
- e1.setName("name-1-changed2");
-
- nameToId.put(e1.getName(), e1.getId());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-1-changed1");
- assertNaturalIdCache(sesFactory1, nameToId, "name-1-changed1");
-
- // Try invalid NaturalId update.
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-0"); // Invalid update (duplicated name).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId);
- assertNaturalIdCache(sesFactory1, nameToId);
-
- // Delete entity.
-
- ses = sesFactory2.openSession();
-
- try {
- tx = ses.beginTransaction();
-
- Entity e2 = (Entity)ses.load(Entity.class, 2);
-
- ses.delete(e2);
-
- nameToId.remove(e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-2");
- assertNaturalIdCache(sesFactory1, nameToId, "name-2");
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testEntityCacheTransactionFails() throws Exception {
- for (AccessType accessType : accessTypes())
- testEntityCacheTransactionFails(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testEntityCacheTransactionFails(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, String> idToName = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- idToName.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- ses.save(new Entity(3, "name-3")); // Valid insert.
-
- ses.save(new Entity(0, "name-0")); // Invalid insert (duplicated ID).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- Entity e0 = (Entity)ses.load(Entity.class, 0);
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e0.setName("name-10"); // Valid update.
- e1.setName("name-2"); // Invalid update (violates unique constraint).
-
- ses.update(e0);
- ses.update(e1);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
-
- ses = sesFactory1.openSession();
-
- try {
- // Create parent entity referencing Entity with ID = 0.
-
- tx = ses.beginTransaction();
-
- ses.save(new ParentEntity(0, (Entity) ses.load(Entity.class, 0)));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- ses.save(new Entity(3, "name-3")); // Valid insert.
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-10"); // Valid update.
-
- ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- ses.delete(ses.load(Entity.class, 1)); // Valid delete.
-
- idToName.remove(1);
-
- ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testQueryCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testQueryCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testQueryCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 5; i++)
- ses.save(new Entity(i, "name-" + i));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Run some queries.
-
- ses = sesFactory1.openSession();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(2, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
-
- // Run queries using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(2, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
-
- Query qry3 = ses.createQuery("from " + ENTITY_NAME + " where id > 1");
-
- qry3.setCacheable(true);
-
- assertEquals(3, qry3.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(2, sesFactory2.getStatistics().getQueryCacheHitCount());
- assertEquals(1, sesFactory2.getStatistics().getQueryCacheMissCount());
- assertEquals(1, sesFactory2.getStatistics().getQueryCachePutCount());
-
- // Update entity, it should invalidate query cache.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity(5, "name-5"));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Run queries.
-
- ses = sesFactory1.openSession();
-
- sesFactory1.getStatistics().clear();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(3, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
-
- // Clear query cache using another SessionFactory.
-
- sesFactory2.getCache().evictDefaultQueryRegion();
-
- ses = sesFactory1.openSession();
-
- // Run queries again.
-
- sesFactory1.getStatistics().clear();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(3, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRegionClear() throws Exception {
- for (AccessType accessType : accessTypes())
- testRegionClear(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testRegionClear(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- final int ENTITY_CNT = 100;
-
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < ENTITY_CNT; i++) {
- Entity e = new Entity(i, "name-" + i);
-
- Collection<ChildEntity> children = new ArrayList<>();
-
- for (int j = 0; j < 3; j++)
- children.add(new ChildEntity());
-
- e.setChildren(children);
-
- ses.save(e);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- loadEntities(sesFactory2, ENTITY_CNT);
-
- SecondLevelCacheStatistics stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
- SecondLevelCacheStatistics stats2 = sesFactory2.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
-
- NaturalIdCacheStatistics idStats1 =
- sesFactory1.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
- NaturalIdCacheStatistics idStats2 =
- sesFactory2.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
-
- SecondLevelCacheStatistics colStats1 =
- sesFactory1.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
- SecondLevelCacheStatistics colStats2 =
- sesFactory2.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
-
- assertEquals(ENTITY_CNT, stats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, stats2.getElementCountInMemory());
-
- assertEquals(ENTITY_CNT, idStats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, idStats2.getElementCountInMemory());
-
- assertEquals(ENTITY_CNT, colStats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, colStats2.getElementCountInMemory());
-
- // Test cache is cleared after update query.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.createQuery("delete from " + ENTITY_NAME + " where name='no such name'").executeUpdate();
-
- ses.createQuery("delete from " + ChildEntity.class.getName() + " where id=-1").executeUpdate();
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, stats1.getElementCountInMemory());
- assertEquals(0, stats2.getElementCountInMemory());
-
- assertEquals(0, idStats1.getElementCountInMemory());
- assertEquals(0, idStats2.getElementCountInMemory());
-
- assertEquals(0, colStats1.getElementCountInMemory());
- assertEquals(0, colStats2.getElementCountInMemory());
-
- // Load some data in cache.
-
- loadEntities(sesFactory1, 10);
-
- assertEquals(10, stats1.getElementCountInMemory());
- assertEquals(10, stats2.getElementCountInMemory());
- assertEquals(10, idStats1.getElementCountInMemory());
- assertEquals(10, idStats2.getElementCountInMemory());
-
- // Test evictAll method.
-
- sesFactory2.getCache().evictEntityRegion(ENTITY_NAME);
-
- assertEquals(0, stats1.getElementCountInMemory());
- assertEquals(0, stats2.getElementCountInMemory());
-
- sesFactory2.getCache().evictNaturalIdRegion(ENTITY_NAME);
-
- assertEquals(0, idStats1.getElementCountInMemory());
- assertEquals(0, idStats2.getElementCountInMemory());
-
- sesFactory2.getCache().evictCollectionRegion(CHILD_COLLECTION_REGION);
-
- assertEquals(0, colStats1.getElementCountInMemory());
- assertEquals(0, colStats2.getElementCountInMemory());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @param sesFactory Session factory.
- * @param nameToId Name-ID mapping.
- * @param absentNames Absent entities' names.
- */
- private void assertNaturalIdCache(SessionFactory sesFactory, Map<String, Integer> nameToId, String... absentNames) {
- sesFactory.getStatistics().clear();
-
- NaturalIdCacheStatistics stats =
- sesFactory.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
-
- long hitBefore = stats.getHitCount();
-
- long missBefore = stats.getMissCount();
-
- final Session ses = sesFactory.openSession();
-
- try {
- for (Map.Entry<String, Integer> e : nameToId.entrySet())
- assertEquals((int)e.getValue(), ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId());
-
- for (String name : absentNames)
- assertNull((ses.bySimpleNaturalId(Entity.class).load(name)));
-
- assertEquals(nameToId.size() + hitBefore, stats.getHitCount());
-
- assertEquals(absentNames.length + missBefore, stats.getMissCount());
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * @param sesFactory Session factory.
- * @param idToChildCnt Number of children per entity.
- * @param expHit Expected cache hits.
- * @param expMiss Expected cache misses.
- */
- @SuppressWarnings("unchecked")
- private void assertCollectionCache(SessionFactory sesFactory, Map<Integer, Integer> idToChildCnt, int expHit,
- int expMiss) {
- sesFactory.getStatistics().clear();
-
- Session ses = sesFactory.openSession();
-
- try {
- for(Map.Entry<Integer, Integer> e : idToChildCnt.entrySet()) {
- Entity entity = (Entity)ses.load(Entity.class, e.getKey());
-
- assertEquals((int)e.getValue(), entity.getChildren().size());
- }
- }
- finally {
- ses.close();
- }
-
- SecondLevelCacheStatistics stats =
- sesFactory.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
-
- assertEquals(expHit, stats.getHitCount());
-
- assertEquals(expMiss, stats.getMissCount());
- }
-
- /**
- * @param sesFactory Session factory.
- * @param cnt Number of entities to load.
- */
- private void loadEntities(SessionFactory sesFactory, int cnt) {
- Session ses = sesFactory.openSession();
-
- try {
- for (int i = 0; i < cnt; i++) {
- Entity e = (Entity)ses.load(Entity.class, i);
-
- assertEquals("name-" + i, e.getName());
-
- assertFalse(e.getChildren().isEmpty());
-
- ses.bySimpleNaturalId(Entity.class).load(e.getName());
- }
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * @param entityName Entity name.
- * @param sesFactory Session factory.
- * @param idToName ID to name mapping.
- * @param absentIds Absent entities' IDs.
- */
- private void assertEntityCache(String entityName, SessionFactory sesFactory, Map<Integer, String> idToName,
- Integer... absentIds) {
- assert entityName.equals(ENTITY_NAME) || entityName.equals(ENTITY2_NAME) : entityName;
-
- sesFactory.getStatistics().clear();
-
- final Session ses = sesFactory.openSession();
-
- final boolean entity1 = entityName.equals(ENTITY_NAME);
-
- try {
- if (entity1) {
- for (Map.Entry<Integer, String> e : idToName.entrySet())
- assertEquals(e.getValue(), ((Entity)ses.load(Entity.class, e.getKey())).getName());
- }
- else {
- for (Map.Entry<Integer, String> e : idToName.entrySet())
- assertEquals(e.getValue(), ((Entity2)ses.load(Entity2.class, e.getKey())).getName());
- }
-
- for (final int id : absentIds) {
- GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override public Void call() throws Exception {
- if (entity1)
- ((Entity)ses.load(Entity.class, id)).getName();
- else
- ((Entity2)ses.load(Entity2.class, id)).getName();
-
- return null;
- }
- }, ObjectNotFoundException.class, null);
- }
-
- SecondLevelCacheStatistics stats = sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
-
- assertEquals(idToName.size(), stats.getHitCount());
-
- assertEquals(absentIds.length, stats.getMissCount());
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * Creates session factories.
- *
- * @param accessType Cache access type.
- */
- private void createSessionFactories(AccessType accessType) {
- sesFactory1 = startHibernate(accessType, getTestIgniteInstanceName(0));
-
- sesFactory2 = startHibernate(accessType, getTestIgniteInstanceName(1));
- }
-
- /**
- * Starts Hibernate.
- *
- * @param accessType Cache access type.
- * @param igniteInstanceName Ignite instance name.
- * @return Session factory.
- */
- private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
- Configuration cfg = hibernateConfiguration(accessType, igniteInstanceName);
-
- ServiceRegistryBuilder builder = registryBuilder();
-
- builder.applySetting("hibernate.show_sql", false);
-
- return cfg.buildSessionFactory(builder.buildServiceRegistry());
- }
-
- /**
- * Closes session factories and clears data from caches.
- *
- * @throws Exception If failed.
- */
- private void cleanup() throws Exception {
- if (sesFactory1 != null)
- sesFactory1.close();
-
- sesFactory1 = null;
-
- if (sesFactory2 != null)
- sesFactory2.close();
-
- sesFactory2 = null;
-
- for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
- cache.clear();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
deleted file mode 100644
index deca893..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
+++ /dev/null
@@ -1,154 +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.hibernate;
-
-import java.util.Collections;
-import javax.cache.configuration.Factory;
-import javax.transaction.Synchronization;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import org.apache.commons.dbcp.managed.BasicManagedDataSource;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.h2.jdbcx.JdbcDataSource;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
-import org.hibernate.engine.transaction.spi.TransactionFactory;
-import org.hibernate.service.ServiceRegistryBuilder;
-import org.hibernate.service.jdbc.connections.internal.DatasourceConnectionProviderImpl;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.service.jta.platform.internal.AbstractJtaPlatform;
-import org.hibernate.service.jta.platform.spi.JtaPlatform;
-import org.jetbrains.annotations.Nullable;
-import org.objectweb.jotm.Jotm;
-
-/**
- *
- * Tests Hibernate L2 cache with TRANSACTIONAL access mode (Hibernate and Cache are configured
- * to used the same TransactionManager).
- */
-public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfTest {
- /** */
- private static Jotm jotm;
-
- /**
- */
- private static class TestJtaPlatform extends AbstractJtaPlatform {
- /** {@inheritDoc} */
- @Override protected TransactionManager locateTransactionManager() {
- return jotm.getTransactionManager();
- }
-
- /** {@inheritDoc} */
- @Override protected UserTransaction locateUserTransaction() {
- return jotm.getUserTransaction();
- }
- }
-
- /**
- */
- @SuppressWarnings("PublicInnerClass")
- public static class TestTmFactory implements Factory<TransactionManager> {
- /** */
- private static final long serialVersionUID = 0;
-
- /** {@inheritDoc} */
- @Override public TransactionManager create() {
- return jotm.getTransactionManager();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- jotm = new Jotm(true, false);
-
- super.beforeTestsStarted();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- if (jotm != null)
- jotm.stop();
-
- jotm = null;
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.getTransactionConfiguration().setTxManagerFactory(new TestTmFactory());
- cfg.getTransactionConfiguration().setUseJtaSynchronization(useJtaSynchronization());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = super.transactionalRegionConfiguration(regionName);
-
- cfg.setNearConfiguration(null);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected ServiceRegistryBuilder registryBuilder() {
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
-
- DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
-
- BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.
-
- dataSrc.setTransactionManager(jotm.getTransactionManager());
-
- dataSrc.setDefaultAutoCommit(false);
-
- JdbcDataSource h2DataSrc = new JdbcDataSource();
-
- h2DataSrc.setURL(CONNECTION_URL);
-
- dataSrc.setXaDataSourceInstance(h2DataSrc);
-
- connProvider.setDataSource(dataSrc);
-
- connProvider.configure(Collections.emptyMap());
-
- builder.addService(ConnectionProvider.class, connProvider);
-
- builder.addService(JtaPlatform.class, new TestJtaPlatform());
-
- builder.addService(TransactionFactory.class, new JtaTransactionFactory());
-
- return builder;
- }
-
- /** {@inheritDoc} */
- @Override protected AccessType[] accessTypes() {
- return new AccessType[]{AccessType.TRANSACTIONAL};
- }
-
- /**
- * @return Whether to use {@link Synchronization}.
- */
- protected boolean useJtaSynchronization() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
deleted file mode 100644
index 44899f9..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
+++ /dev/null
@@ -1,31 +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.hibernate;
-
-import javax.transaction.Synchronization;
-
-/**
- * Tests Hibernate L2 cache with TRANSACTIONAL access mode and {@link Synchronization}
- * instead of XA resource.
- */
-public class HibernateL2CacheTransactionalUseSyncSelfTest extends HibernateL2CacheTransactionalSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean useJtaSynchronization() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
deleted file mode 100644
index d5496af..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
+++ /dev/null
@@ -1,46 +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.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.processors.cache.integration.IgniteCacheStoreNodeRestartAbstractTest;
-
-public class CacheHibernateBlobStoreNodeRestartTest extends IgniteCacheStoreNodeRestartAbstractTest {
- /** {@inheritDoc} */
- @Override protected CacheStore getStore() {
- return new CacheHibernateBlobStore();
- }
-
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return CacheMode.PARTITIONED;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheAtomicityMode atomicityMode() {
- return CacheAtomicityMode.ATOMIC;
- }
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
deleted file mode 100644
index d3d2b52..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++ /dev/null
@@ -1,113 +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 java.io.File;
-import java.net.URL;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
-import org.hibernate.FlushMode;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-/**
- * Cache store test.
- */
-public class CacheHibernateBlobStoreSelfTest extends
- GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> {
- /**
- * @throws Exception If failed.
- */
- public CacheHibernateBlobStoreSelfTest() throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- Session s = store.session(null);
-
- if (s == null)
- return;
-
- try {
- s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
- .setFlushMode(FlushMode.ALWAYS).executeUpdate();
-
- Transaction hTx = s.getTransaction();
-
- if (hTx != null && hTx.isActive())
- hTx.commit();
- }
- finally {
- s.close();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected CacheHibernateBlobStore<Object, Object> store() {
- return new CacheHibernateBlobStore<>();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByUrl() throws Exception {
- URL url = U.resolveIgniteUrl(
- "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- assert url != null;
-
- store.setHibernateConfigurationPath(url.toString());
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByFile() throws Exception {
- URL url = U.resolveIgniteUrl(
- "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- assert url != null;
-
- File file = new File(url.toURI());
-
- store.setHibernateConfigurationPath(file.getAbsolutePath());
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByResource() throws Exception {
- store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- @Override public void testSimpleMultithreading() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1757");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
deleted file mode 100644
index 3a2244e..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
+++ /dev/null
@@ -1,285 +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 java.io.Serializable;
-import java.sql.Connection;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.Cache;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionBuilder;
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-import org.hibernate.StatelessSessionBuilder;
-import org.hibernate.TypeHelper;
-import org.hibernate.engine.spi.FilterDefinition;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.metadata.CollectionMetadata;
-import org.hibernate.stat.Statistics;
-
-/**
- * Test for Cache jdbc blob store factory.
- */
-public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest {
- /** Cache name. */
- private static final String CACHE_NAME = "test";
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheConfiguration() throws Exception {
- try (Ignite ignite1 = startGrid(0)) {
- IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration());
-
- checkStore(cache1);
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testXmlConfiguration() throws Exception {
- try (Ignite ignite = Ignition.start("modules/hibernate/src/test/config/factory-cache.xml")) {
- try(Ignite ignite1 = Ignition.start("modules/hibernate/src/test/config/factory-cache1.xml")) {
- checkStore(ignite.<Integer, String>cache(CACHE_NAME), DummySessionFactoryExt.class);
-
- checkStore(ignite1.<Integer, String>cache(CACHE_NAME), DummySessionFactory.class);
- }
- }
- }
-
-
- /**
- * @throws Exception If failed.
- */
- public void testIncorrectBeanConfiguration() throws Exception {
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
- try(Ignite ignite =
- Ignition.start("modules/hibernate/src/test/config/factory-incorrect-store-cache.xml")) {
- ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
- getCacheStoreFactory().create();
- }
- return null;
- }
- }, IgniteException.class, "Failed to load bean in application context");
- }
-
- /**
- * @return Cache configuration with store.
- */
- private CacheConfiguration<Integer, String> cacheConfiguration() {
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- CacheHibernateBlobStoreFactory<Integer, String> factory = new CacheHibernateBlobStoreFactory();
-
- factory.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- cfg.setCacheStoreFactory(factory);
-
- return cfg;
- }
-
- /**
- * @param cache Ignite cache.
- * @param dataSrcClass Data source class.
- * @throws Exception If store parameters is not the same as in configuration xml.
- */
- private void checkStore(IgniteCache<Integer, String> cache, Class<?> dataSrcClass) throws Exception {
- CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache
- .getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create();
-
- assertEquals(dataSrcClass,
- GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "sesFactory").getClass());
- }
-
- /**
- * @param cache Ignite cache.
- * @throws Exception If store parameters is not the same as in configuration xml.
- */
- private void checkStore(IgniteCache<Integer, String> cache) throws Exception {
- CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache.getConfiguration(CacheConfiguration.class)
- .getCacheStoreFactory().create();
-
- assertEquals("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml",
- GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "hibernateCfgPath"));
- }
-
- /**
- *
- */
- public static class DummySessionFactoryExt extends DummySessionFactory {
- /** */
- public DummySessionFactoryExt() {
- // No-op.
- }
- }
-
- /**
- *
- */
- public static class DummySessionFactory implements SessionFactory {
- /** {@inheritDoc} */
- @Override public SessionFactoryOptions getSessionFactoryOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public SessionBuilder withOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Session openSession() throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Session getCurrentSession() throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSessionBuilder withStatelessOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSession openStatelessSession() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSession openStatelessSession(Connection connection) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public ClassMetadata getClassMetadata(Class entityClass) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public ClassMetadata getClassMetadata(String entityName) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public CollectionMetadata getCollectionMetadata(String roleName) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, ClassMetadata> getAllClassMetadata() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Map getAllCollectionMetadata() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Statistics getStatistics() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void close() throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public boolean isClosed() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public Cache getCache() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Class persistentClass) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Class persistentClass, Serializable id) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictEntity(String entityName) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictEntity(String entityName, Serializable id) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictCollection(String roleName) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictCollection(String roleName, Serializable id) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictQueries(String cacheRegion) throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public void evictQueries() throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public Set getDefinedFilterNames() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsFetchProfileDefinition(String name) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public TypeHelper getTypeHelper() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Reference getReference() throws NamingException {
- return null;
- }
- }
-}
\ No newline at end of file
[26/50] [abbrv] ignite git commit: Formatting
Posted by vo...@apache.org.
Formatting
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7d33dd50
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7d33dd50
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7d33dd50
Branch: refs/heads/master
Commit: 7d33dd50b152eed29d9995dfd37403cda27f46a2
Parents: 1ccb943
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 26 06:31:25 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 26 06:31:25 2017 +0300
----------------------------------------------------------------------
.../examples/datagrid/CacheQueryExample.java | 54 +++++++++++---------
1 file changed, 30 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7d33dd50/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
index 85d74e0..aa52cc1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheQueryExample.java
@@ -90,23 +90,24 @@ public class CacheQueryExample {
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
- CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg = new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
+ CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg =
+ new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
colPersonCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
colPersonCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
- CacheConfiguration<AffinityKey<Long>, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
+ CacheConfiguration<Long, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
personCacheCfg.setIndexedTypes(Long.class, Person.class);
- // Auto-close cache at the end of the example.
- try (
- IgniteCache<Long, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
- IgniteCache<AffinityKey<Long>, Person> colPersonCache = ignite.getOrCreateCache(colPersonCacheCfg);
- IgniteCache<AffinityKey<Long>, Person> personCache = ignite.getOrCreateCache(personCacheCfg)
- ) {
- // Populate cache.
+ try {
+ // Create caches.
+ ignite.getOrCreateCache(orgCacheCfg);
+ ignite.getOrCreateCache(colPersonCacheCfg);
+ ignite.getOrCreateCache(personCacheCfg);
+
+ // Populate caches.
initialize();
// Example for SCAN-based query based on a predicate.
@@ -115,16 +116,19 @@ public class CacheQueryExample {
// Example for SQL-based querying employees based on salary ranges.
sqlQuery();
- // Example for SQL-based querying employees for a given organization (includes SQL join for collocated objects).
+ // Example for SQL-based querying employees for a given organization
+ // (includes SQL join for collocated objects).
sqlQueryWithJoin();
- // Example for SQL-based querying employees for a given organization (includes distributed SQL join).
+ // Example for SQL-based querying employees for a given organization
+ // (includes distributed SQL join).
sqlQueryWithDistributedJoin();
// Example for TEXT-based querying for a given string in peoples resumes.
textQuery();
- // Example for SQL-based querying to calculate average salary among all employees within a company.
+ // Example for SQL-based querying to calculate average salary
+ // among all employees within a company.
sqlQueryWithAggregation();
// Example for SQL-based fields queries that return only required
@@ -135,7 +139,7 @@ public class CacheQueryExample {
sqlFieldsQueryWithJoin();
}
finally {
- // Distributed cache could be removed from cluster only by #destroyCache() call.
+ // Distributed cache could be removed from cluster only by Ignite.destroyCache() call.
ignite.destroyCache(COLLOCATED_PERSON_CACHE);
ignite.destroyCache(PERSON_CACHE);
ignite.destroyCache(ORG_CACHE);
@@ -146,10 +150,11 @@ public class CacheQueryExample {
}
/**
- * Example for scan query based on a predicate.
+ * Example for scan query based on a predicate using binary objects.
*/
private static void scanQuery() {
- IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
+ IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite()
+ .cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
ScanQuery<BinaryObject, BinaryObject> scan = new ScanQuery<>(
new IgniteBiPredicate<BinaryObject, BinaryObject>() {
@@ -167,7 +172,7 @@ public class CacheQueryExample {
* Example for SQL queries based on salary ranges.
*/
private static void sqlQuery() {
- IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+ IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// SQL clause which selects salaries based on range.
String sql = "salary > ? and salary <= ?";
@@ -205,10 +210,11 @@ public class CacheQueryExample {
}
/**
- * Example for SQL queries based on all employees working for a specific organization (query uses distributed join).
+ * Example for SQL queries based on all employees working
+ * for a specific organization (query uses distributed join).
*/
private static void sqlQueryWithDistributedJoin() {
- IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+ IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// SQL clause query which joins on 2 types to select people for a specific organization.
String joinSql =
@@ -234,15 +240,15 @@ public class CacheQueryExample {
* Example for TEXT queries using LUCENE-based indexing of people's resumes.
*/
private static void textQuery() {
- IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+ IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// Query for all people with "Master Degree" in their resumes.
- QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> masters =
- cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Master"));
+ QueryCursor<Cache.Entry<Long, Person>> masters =
+ cache.query(new TextQuery<Long, Person>(Person.class, "Master"));
// Query for all people with "Bachelor Degree" in their resumes.
- QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> bachelors =
- cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Bachelor"));
+ QueryCursor<Cache.Entry<Long, Person>> bachelors =
+ cache.query(new TextQuery<Long, Person>(Person.class, "Bachelor"));
print("Following people have 'Master Degree' in their resumes: ", masters.getAll());
print("Following people have 'Bachelor Degree' in their resumes: ", bachelors.getAll());
@@ -273,7 +279,7 @@ public class CacheQueryExample {
* fields instead of whole key-value pairs.
*/
private static void sqlFieldsQuery() {
- IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
+ IgniteCache<Long, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// Execute query to get names of all employees.
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(
[23/50] [abbrv] ignite git commit: IGNITE-4523 Allow distributed SQL
query execution over explicit set of partitions - Fixes #1858.
Posted by vo...@apache.org.
IGNITE-4523 Allow distributed SQL query execution over explicit set of partitions - Fixes #1858.
Signed-off-by: Sergi Vladykin <se...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5ef610c0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5ef610c0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5ef610c0
Branch: refs/heads/master
Commit: 5ef610c07c947c7cf4884b946ef1649e5ce4da34
Parents: 712398e
Author: ascherbakoff <al...@gmail.com>
Authored: Tue Apr 25 14:01:33 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Tue Apr 25 14:01:33 2017 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/query/Query.java | 48 ++
.../ignite/cache/query/SqlFieldsQuery.java | 26 +
.../org/apache/ignite/cache/query/SqlQuery.java | 26 +
.../processors/cache/IgniteCacheProxy.java | 14 +
.../processors/query/GridQueryProcessor.java | 4 +-
.../ignite/internal/util/GridIntIterator.java | 33 +
.../ignite/internal/util/GridIntList.java | 21 +-
.../ignite/internal/util/IgniteUtils.java | 21 +-
.../processors/query/h2/IgniteH2Indexing.java | 14 +-
.../query/h2/twostep/GridMapQueryExecutor.java | 5 +-
.../h2/twostep/GridReduceQueryExecutor.java | 222 ++++++-
.../h2/twostep/msg/GridH2QueryRequest.java | 64 +-
...stributedPartitionQueryAbstractSelfTest.java | 655 +++++++++++++++++++
...utedPartitionQueryConfigurationSelfTest.java | 92 +++
...butedPartitionQueryNodeRestartsSelfTest.java | 114 ++++
...eCacheDistributedPartitionQuerySelfTest.java | 90 +++
.../IgniteCacheQueryNodeRestartSelfTest2.java | 8 +
.../IgniteCacheQuerySelfTestSuite.java | 6 +
18 files changed, 1419 insertions(+), 44 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
index 71161e7..c9ed464 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/Query.java
@@ -18,7 +18,10 @@
package org.apache.ignite.cache.query;
import java.io.Serializable;
+import java.util.Arrays;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
@@ -93,6 +96,51 @@ public abstract class Query<R> implements Serializable {
return this;
}
+ /**
+ * Prepares the partitions.
+ *
+ * @param parts Partitions.
+ */
+ protected int[] prepare(int[] parts) {
+ if (parts == null)
+ return null;
+
+ A.notEmpty(parts, "Partitions");
+
+ boolean sorted = true;
+
+ // Try to do validation in one pass, if array is already sorted.
+ for (int i = 0; i < parts.length; i++) {
+ if (i < parts.length - 1)
+ if (parts[i] > parts[i + 1])
+ sorted = false;
+ else if (sorted)
+ validateDups(parts[i], parts[i + 1]);
+
+ A.ensure(0 <= parts[i] && parts[i] < CacheConfiguration.MAX_PARTITIONS_COUNT, "Illegal partition");
+ }
+
+ // Sort and validate again.
+ if (!sorted) {
+ Arrays.sort(parts);
+
+ for (int i = 0; i < parts.length; i++) {
+ if (i < parts.length - 1)
+ validateDups(parts[i], parts[i + 1]);
+ }
+ }
+
+ return parts;
+ }
+
+ /**
+ * @param p1 Part 1.
+ * @param p2 Part 2.
+ */
+ private void validateDups(int p1, int p2) {
+ A.ensure(p1 != p2, "Partition duplicates are not allowed: " + p1);
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(Query.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
index 8c3a4fe..9a7211b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlFieldsQuery.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
/**
* SQL Fields query. This query can return specific fields of data based
@@ -70,6 +71,9 @@ public class SqlFieldsQuery extends Query<List<?>> {
/** */
private boolean replicatedOnly;
+ /** Partitions for query */
+ private int[] parts;
+
/**
* Constructs SQL fields query.
*
@@ -261,6 +265,28 @@ public class SqlFieldsQuery extends Query<List<?>> {
return replicatedOnly;
}
+ /**
+ * Gets partitions for query, in ascending order.
+ */
+ @Nullable public int[] getPartitions() {
+ return parts;
+ }
+
+ /**
+ * Sets partitions for a query.
+ * The query will be executed only on nodes which are primary for specified partitions.
+ * <p>
+ * Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet.
+ *
+ * @param parts Partitions.
+ * @return {@code this} for chaining.
+ */
+ public SqlFieldsQuery setPartitions(@Nullable int... parts) {
+ this.parts = prepare(parts);
+
+ return this;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(SqlFieldsQuery.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
index 944c70e..a5994b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/SqlQuery.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.processors.query.QueryUtils;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.Nullable;
/**
* SQL Query.
@@ -56,6 +57,9 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
/** */
private boolean replicatedOnly;
+ /** Partitions for query */
+ private int[] parts;
+
/**
* Constructs query for the given type name and SQL query.
*
@@ -250,6 +254,28 @@ public final class SqlQuery<K, V> extends Query<Cache.Entry<K, V>> {
return replicatedOnly;
}
+ /**
+ * Gets partitions for query, in ascending order.
+ */
+ @Nullable public int[] getPartitions() {
+ return parts;
+ }
+
+ /**
+ * Sets partitions for a query.
+ * The query will be executed only on nodes which are primary for specified partitions.
+ * <p>
+ * Note what passed array'll be sorted in place for performance reasons, if it wasn't sorted yet.
+ *
+ * @param parts Partitions.
+ * @return {@code this} for chaining.
+ */
+ public SqlQuery setPartitions(@Nullable int... parts) {
+ this.parts = prepare(parts);
+
+ return this;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(SqlQuery.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index b38520d..dfe817e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -776,6 +776,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
if (qry instanceof SqlQuery) {
final SqlQuery p = (SqlQuery)qry;
+ if (p.isReplicatedOnly() && p.getPartitions() != null)
+ throw new CacheException("Partitions are not supported in replicated only mode.");
+
+ if (p.isDistributedJoins() && p.getPartitions() != null)
+ throw new CacheException(
+ "Using both partitions and distributed JOINs is not supported for the same query");
+
if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
return (QueryCursor<R>)ctx.kernalContext().query().queryLocal(ctx, p,
opCtxCall != null && opCtxCall.isKeepBinary());
@@ -786,6 +793,13 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
if (qry instanceof SqlFieldsQuery) {
SqlFieldsQuery p = (SqlFieldsQuery)qry;
+ if (p.isReplicatedOnly() && p.getPartitions() != null)
+ throw new CacheException("Partitions are not supported in replicated only mode.");
+
+ if (p.isDistributedJoins() && p.getPartitions() != null)
+ throw new CacheException(
+ "Using both partitions and distributed JOINs is not supported for the same query");
+
if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
return (QueryCursor<R>)ctx.kernalContext().query().queryLocalFields(ctx, p);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
index 015646d..448639b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/GridQueryProcessor.java
@@ -1754,7 +1754,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
qry.getArgs(),
cctx.name());
- return idx.queryLocalSql(cctx, qry, idx.backupFilter(requestTopVer.get(), null), keepBinary);
+ return idx.queryLocalSql(cctx, qry, idx.backupFilter(requestTopVer.get(), qry.getPartitions()), keepBinary);
}
}, true);
}
@@ -1938,7 +1938,7 @@ public class GridQueryProcessor extends GridProcessorAdapter {
GridQueryCancel cancel = new GridQueryCancel();
final QueryCursor<List<?>> cursor = idx.queryLocalSqlFields(cctx, qry,
- idx.backupFilter(requestTopVer.get(), null), cancel);
+ idx.backupFilter(requestTopVer.get(), qry.getPartitions()), cancel);
return new QueryCursorImpl<List<?>>(new Iterable<List<?>>() {
@Override public Iterator<List<?>> iterator() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
new file mode 100644
index 0000000..ea863e7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntIterator.java
@@ -0,0 +1,33 @@
+/*
+ * 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.util;
+
+/**
+ * Iterator over integer primitives.
+ */
+public interface GridIntIterator {
+ /**
+ * @return {@code true} if the iteration has more elements.
+ */
+ public boolean hasNext();
+
+ /**
+ * @return Next int.
+ */
+ public int next();
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
index 968b88e..e5b7b1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridIntList.java
@@ -582,5 +582,22 @@ public class GridIntList implements Message, Externalizable {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
return 2;
- }
-}
+ }
+
+ /**
+ * @return Iterator.
+ */
+ public GridIntIterator iterator() {
+ return new GridIntIterator() {
+ int c = 0;
+
+ @Override public boolean hasNext() {
+ return c < idx;
+ }
+
+ @Override public int next() {
+ return arr[c++];
+ }
+ };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/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 7d7d071..59d334a 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
@@ -10094,4 +10094,23 @@ public abstract class IgniteUtils {
throw new IgniteCheckedException(e);
}
}
-}
+
+ /**
+ * Returns {@link GridIntIterator} for range of primitive integers.
+ * @param start Start.
+ * @param cnt Count.
+ */
+ public static GridIntIterator forRange(final int start, final int cnt) {
+ return new GridIntIterator() {
+ int c = 0;
+
+ @Override public boolean hasNext() {
+ return c < cnt;
+ }
+
+ @Override public int next() {
+ return start + c++;
+ }
+ };
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 798ca9b..361b55b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1471,6 +1471,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* @param qry Query.
* @param keepCacheObj Flag to keep cache object.
* @param enforceJoinOrder Enforce join order of tables.
+ * @param parts Partitions.
* @return Iterable result.
*/
private Iterable<List<?>> runQueryTwoStep(
@@ -1480,11 +1481,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
final boolean enforceJoinOrder,
final int timeoutMillis,
final GridQueryCancel cancel,
- final Object[] params
+ final Object[] params,
+ final int[] parts
) {
return new Iterable<List<?>>() {
@Override public Iterator<List<?>> iterator() {
- return rdcQryExec.query(cctx, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params);
+ return rdcQryExec.query(cctx, qry, keepCacheObj, enforceJoinOrder, timeoutMillis, cancel, params, parts);
}
};
}
@@ -1515,6 +1517,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
fqry.setArgs(qry.getArgs());
fqry.setPageSize(qry.getPageSize());
fqry.setDistributedJoins(qry.isDistributedJoins());
+ fqry.setPartitions(qry.getPartitions());
fqry.setLocal(qry.isLocal());
if (qry.getTimeout() > 0)
@@ -1730,7 +1733,8 @@ public class IgniteH2Indexing implements GridQueryIndexing {
cancel = new GridQueryCancel();
QueryCursorImpl<List<?>> cursor = new QueryCursorImpl<>(
- runQueryTwoStep(cctx, twoStepQry, cctx.keepBinary(), enforceJoinOrder, qry.getTimeout(), cancel, qry.getArgs()),
+ runQueryTwoStep(cctx, twoStepQry, cctx.keepBinary(), enforceJoinOrder, qry.getTimeout(), cancel,
+ qry.getArgs(), qry.getPartitions()),
cancel);
cursor.fieldsMeta(meta);
@@ -1750,12 +1754,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
if (caches.isEmpty())
return; // Nothing to check
- GridCacheSharedContext sharedContext = ctx.cache().context();
+ GridCacheSharedContext sharedCtx = ctx.cache().context();
int expectedParallelism = 0;
for (int i = 0; i < caches.size(); i++) {
- GridCacheContext cctx = sharedContext.cacheContext(caches.get(i));
+ GridCacheContext cctx = sharedCtx.cacheContext(caches.get(i));
assert cctx != null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index e4347b5..45d8f50 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -426,8 +426,11 @@ public class GridMapQueryExecutor {
* @param req Query request.
*/
private void onQueryRequest(final ClusterNode node, final GridH2QueryRequest req) throws IgniteCheckedException {
+ int[] qryParts = req.queryPartitions();
+
final Map<UUID,int[]> partsMap = req.partitions();
- final int[] parts = partsMap == null ? null : partsMap.get(ctx.localNodeId());
+
+ final int[] parts = qryParts == null ? partsMap == null ? null : partsMap.get(ctx.localNodeId()) : qryParts;
assert !F.isEmpty(req.caches());
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index d307c00..3d81cb5 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.Arrays;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -73,6 +74,8 @@ import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQuery
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest;
import org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse;
import org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest;
+import org.apache.ignite.internal.util.GridIntIterator;
+import org.apache.ignite.internal.util.GridIntList;
import org.apache.ignite.internal.util.GridSpinBusyLock;
import org.apache.ignite.internal.util.typedef.CIX2;
import org.apache.ignite.internal.util.typedef.F;
@@ -80,6 +83,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiClosure;
import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.h2.command.ddl.CreateTableData;
import org.h2.engine.Session;
@@ -113,6 +117,9 @@ public class GridReduceQueryExecutor {
private static final String MERGE_INDEX_SORTED = "merge_sorted";
/** */
+ private static final Set<ClusterNode> UNMAPPED_PARTS = Collections.emptySet();
+
+ /** */
private GridKernalContext ctx;
/** */
@@ -376,21 +383,78 @@ public class GridReduceQueryExecutor {
}
/**
+ * @param topVer Topology version.
+ * @param cctx Cache context.
+ * @param parts Partitions.
+ */
+ private Map<ClusterNode, IntArray> stableDataNodesMap(AffinityTopologyVersion topVer,
+ final GridCacheContext<?, ?> cctx, @Nullable final int[] parts) {
+
+ Map<ClusterNode, IntArray> mapping = new HashMap<>();
+
+ // Explicit partitions mapping is not applicable to replicated cache.
+ if (cctx.isReplicated()) {
+ for (ClusterNode clusterNode : cctx.affinity().assignment(topVer).primaryPartitionNodes())
+ mapping.put(clusterNode, null);
+
+ return mapping;
+ }
+
+ List<List<ClusterNode>> assignment = cctx.affinity().assignment(topVer).assignment();
+
+ boolean needPartsFilter = parts != null;
+
+ GridIntIterator iter = needPartsFilter ? new GridIntList(parts).iterator() :
+ U.forRange(0, cctx.affinity().partitions());
+
+ while(iter.hasNext()) {
+ int partId = iter.next();
+
+ List<ClusterNode> partNodes = assignment.get(partId);
+
+ if (partNodes.size() > 0) {
+ ClusterNode prim = partNodes.get(0);
+
+ if (!needPartsFilter) {
+ mapping.put(prim, null);
+
+ continue;
+ }
+
+ IntArray partIds = mapping.get(prim);
+
+ if (partIds == null) {
+ partIds = new IntArray();
+
+ mapping.put(prim, partIds);
+ }
+
+ partIds.add(partId);
+ }
+ }
+
+ return mapping;
+ }
+
+ /**
* @param isReplicatedOnly If we must only have replicated caches.
* @param topVer Topology version.
* @param cctx Cache context for main space.
* @param extraSpaces Extra spaces.
+ * @param parts Partitions.
* @return Data nodes or {@code null} if repartitioning started and we need to retry.
*/
- private Collection<ClusterNode> stableDataNodes(
- boolean isReplicatedOnly,
- AffinityTopologyVersion topVer,
- final GridCacheContext<?, ?> cctx,
- List<Integer> extraSpaces
- ) {
- Set<ClusterNode> nodes = new HashSet<>(cctx.affinity().assignment(topVer).primaryPartitionNodes());
+ private Map<ClusterNode, IntArray> stableDataNodes(
+ boolean isReplicatedOnly,
+ AffinityTopologyVersion topVer,
+ final GridCacheContext<?, ?> cctx,
+ List<Integer> extraSpaces,
+ int[] parts) {
+ Map<ClusterNode, IntArray> map = stableDataNodesMap(topVer, cctx, parts);
- if (F.isEmpty(nodes))
+ Set<ClusterNode> nodes = map.keySet();
+
+ if (F.isEmpty(map))
throw new CacheException("Failed to find data nodes for cache: " + cctx.name());
if (!F.isEmpty(extraSpaces)) {
@@ -406,7 +470,7 @@ public class GridReduceQueryExecutor {
throw new CacheException("Queries running on replicated cache should not contain JOINs " +
"with partitioned tables [rCache=" + cctx.name() + ", pCache=" + extraSpace + "]");
- Collection<ClusterNode> extraNodes = extraCctx.affinity().assignment(topVer).primaryPartitionNodes();
+ Set<ClusterNode> extraNodes = stableDataNodesMap(topVer, extraCctx, parts).keySet();
if (F.isEmpty(extraNodes))
throw new CacheException("Failed to find data nodes for cache: " + extraSpace);
@@ -414,7 +478,7 @@ public class GridReduceQueryExecutor {
if (isReplicatedOnly && extraCctx.isReplicated()) {
nodes.retainAll(extraNodes);
- if (nodes.isEmpty()) {
+ if (map.isEmpty()) {
if (isPreloadingActive(cctx, extraSpaces))
return null; // Retry.
else
@@ -431,7 +495,7 @@ public class GridReduceQueryExecutor {
", cache2=" + extraSpace + "]");
}
else if (!isReplicatedOnly && !extraCctx.isReplicated()) {
- if (extraNodes.size() != nodes.size() || !nodes.containsAll(extraNodes))
+ if (!extraNodes.equals(nodes))
if (isPreloadingActive(cctx, extraSpaces))
return null; // Retry.
else
@@ -443,7 +507,7 @@ public class GridReduceQueryExecutor {
}
}
- return nodes;
+ return map;
}
/**
@@ -454,6 +518,7 @@ public class GridReduceQueryExecutor {
* @param timeoutMillis Timeout in milliseconds.
* @param cancel Query cancel.
* @param params Query parameters.
+ * @param parts Partitions.
* @return Rows iterator.
*/
public Iterator<List<?>> query(
@@ -463,13 +528,17 @@ public class GridReduceQueryExecutor {
boolean enforceJoinOrder,
int timeoutMillis,
GridQueryCancel cancel,
- Object[] params
+ Object[] params,
+ final int[] parts
) {
if (F.isEmpty(params))
params = EMPTY_PARAMS;
final boolean isReplicatedOnly = qry.isReplicatedOnly();
+ // Fail if all caches are replicated and explicit partitions are set.
+
+
for (int attempt = 0;; attempt++) {
if (attempt != 0) {
try {
@@ -494,11 +563,30 @@ public class GridReduceQueryExecutor {
List<Integer> extraSpaces = qry.extraCaches();
- Collection<ClusterNode> nodes;
+ Collection<ClusterNode> nodes = null;
// Explicit partition mapping for unstable topology.
Map<ClusterNode, IntArray> partsMap = null;
+ // Explicit partitions mapping for query.
+ Map<ClusterNode, IntArray> qryMap = null;
+
+ // Partitions are not supported for queries over all replicated caches.
+ if (cctx.isReplicated() && parts != null) {
+ boolean failIfReplicatedOnly = true;
+
+ for (Integer cacheId : extraSpaces) {
+ if (!cacheContext(cacheId).isReplicated()) {
+ failIfReplicatedOnly = false;
+
+ break;
+ }
+ }
+
+ if (failIfReplicatedOnly)
+ throw new CacheException("Partitions are not supported for replicated caches");
+ }
+
if (qry.isLocal())
nodes = singletonList(ctx.discovery().localNode());
else {
@@ -508,11 +596,18 @@ public class GridReduceQueryExecutor {
else {
partsMap = partitionedUnstableDataNodes(cctx, extraSpaces);
- nodes = partsMap == null ? null : partsMap.keySet();
+ if (partsMap != null) {
+ qryMap = narrowForQuery(partsMap, parts);
+
+ nodes = qryMap == null ? null : qryMap.keySet();
+ }
}
+ } else {
+ qryMap = stableDataNodes(isReplicatedOnly, topVer, cctx, extraSpaces, parts);
+
+ if (qryMap != null)
+ nodes = qryMap.keySet();
}
- else
- nodes = stableDataNodes(isReplicatedOnly, topVer, cctx, extraSpaces);
if (nodes == null)
continue; // Retry.
@@ -633,19 +728,18 @@ public class GridReduceQueryExecutor {
if (send(nodes,
new GridH2QueryRequest()
- .requestId(qryReqId)
- .topologyVersion(topVer)
- .pageSize(r.pageSize)
- .caches(qry.caches())
- .tables(distributedJoins ? qry.tables() : null)
- .partitions(convert(partsMap))
- .queries(mapQrys)
- .parameters(params)
- .flags(flags)
- .timeout(timeoutMillis),
- null,
- false)) {
-
+ .requestId(qryReqId)
+ .topologyVersion(topVer)
+ .pageSize(r.pageSize)
+ .caches(qry.caches())
+ .tables(distributedJoins ? qry.tables() : null)
+ .partitions(convert(partsMap))
+ .queries(mapQrys)
+ .parameters(params)
+ .flags(flags)
+ .timeout(timeoutMillis),
+ parts == null ? null : new ExplicitPartitionsSpecializer(qryMap),
+ false)) {
awaitAllReplies(r, nodes, cancel);
Object state = r.state.get();
@@ -1034,7 +1128,13 @@ public class GridReduceQueryExecutor {
List<ClusterNode> owners = cctx.topology().owners(p);
if (F.isEmpty(owners)) {
- if (!F.isEmpty(dataNodes(cctx.name(), NONE)))
+ // Handle special case: no mapping is configured for a partition.
+ if (F.isEmpty(cctx.affinity().assignment(NONE).get(p))) {
+ partLocs[p] = UNMAPPED_PARTS; // Mark unmapped partition.
+
+ continue;
+ }
+ else if (!F.isEmpty(dataNodes(cctx.name(), NONE)))
return null; // Retry.
throw new CacheException("Failed to find data nodes [cache=" + cctx.name() + ", part=" + p + "]");
@@ -1059,6 +1159,9 @@ public class GridReduceQueryExecutor {
for (int p = 0, parts = extraCctx.affinity().partitions(); p < parts; p++) {
List<ClusterNode> owners = extraCctx.topology().owners(p);
+ if (partLocs[p] == UNMAPPED_PARTS)
+ continue; // Skip unmapped partitions.
+
if (F.isEmpty(owners)) {
if (!F.isEmpty(dataNodes(extraCctx.name(), NONE)))
return null; // Retry.
@@ -1090,6 +1193,9 @@ public class GridReduceQueryExecutor {
return null; // Retry.
for (Set<ClusterNode> partLoc : partLocs) {
+ if (partLoc == UNMAPPED_PARTS)
+ continue; // Skip unmapped partition.
+
partLoc.retainAll(dataNodes);
if (partLoc.isEmpty())
@@ -1105,6 +1211,10 @@ public class GridReduceQueryExecutor {
for (int p = 0; p < partLocs.length; p++) {
Set<ClusterNode> pl = partLocs[p];
+ // Skip unmapped partitions.
+ if (pl == UNMAPPED_PARTS)
+ continue;
+
assert !F.isEmpty(pl) : pl;
ClusterNode n = pl.size() == 1 ? F.first(pl) : F.rand(pl);
@@ -1429,4 +1539,52 @@ public class GridReduceQueryExecutor {
state(e, null);
}
}
-}
+
+ /** */
+ private Map<ClusterNode, IntArray> narrowForQuery(Map<ClusterNode, IntArray> partsMap, int[] parts) {
+ if (parts == null)
+ return partsMap;
+
+ Map<ClusterNode, IntArray> cp = U.newHashMap(partsMap.size());
+
+ for (Map.Entry<ClusterNode, IntArray> entry : partsMap.entrySet()) {
+ IntArray filtered = new IntArray(parts.length);
+
+ IntArray orig = entry.getValue();
+
+ for (int i = 0; i < orig.size(); i++) {
+ int p = orig.get(i);
+
+ if (Arrays.binarySearch(parts, p) >= 0)
+ filtered.add(p);
+ }
+
+ if (filtered.size() > 0)
+ cp.put(entry.getKey(), filtered);
+ }
+
+ return cp.isEmpty() ? null : cp;
+ }
+
+ /** */
+ private static class ExplicitPartitionsSpecializer implements IgniteBiClosure<ClusterNode, Message, Message> {
+ /** Partitions map. */
+ private final Map<ClusterNode, IntArray> partsMap;
+
+ /**
+ * @param partsMap Partitions map.
+ */
+ public ExplicitPartitionsSpecializer(Map<ClusterNode, IntArray> partsMap) {
+ this.partsMap = partsMap;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Message apply(ClusterNode node, Message msg) {
+ GridH2QueryRequest rq = new GridH2QueryRequest((GridH2QueryRequest)msg);
+
+ rq.queryPartitions(toArray(partsMap.get(node)));
+
+ return rq;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
index 9e7dcbf..6741d89 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
@@ -17,6 +17,7 @@
package org.apache.ignite.internal.processors.query.h2.twostep.msg;
+import java.io.Externalizable;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.List;
@@ -92,6 +93,10 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
@GridDirectMap(keyType = UUID.class, valueType = int[].class)
private Map<UUID, int[]> parts;
+ /** Query partitions. */
+ @GridToStringInclude
+ private int[] qryParts;
+
/** */
private int pageSize;
@@ -120,6 +125,32 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
private byte[] paramsBytes;
/**
+ * Required by {@link Externalizable}
+ */
+ public GridH2QueryRequest() {
+ // No-op.
+ }
+
+ /**
+ * @param req Request.
+ * @return {@code this}.
+ */
+ public GridH2QueryRequest(GridH2QueryRequest req) {
+ this.reqId = req.reqId;
+ this.caches = req.caches;
+ this.topVer = req.topVer;
+ this.parts = req.parts;
+ this.qryParts = req.qryParts;
+ this.pageSize = req.pageSize;
+ this.qrys = req.qrys;
+ this.flags = req.flags;
+ this.tbls = req.tbls;
+ this.timeout = req.timeout;
+ this.params = req.params;
+ this.paramsBytes = req.paramsBytes;
+ }
+
+ /**
* @return Parameters.
*/
public Object[] parameters() {
@@ -225,6 +256,23 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
}
/**
+ * @return Query partitions.
+ */
+ public int[] queryPartitions() {
+ return qryParts;
+ }
+
+ /**
+ * @param qryParts Query partitions.
+ * @return {@code this}.
+ */
+ public GridH2QueryRequest queryPartitions(int[] qryParts) {
+ this.qryParts = qryParts;
+
+ return this;
+ }
+
+ /**
* @param pageSize Page size.
* @return {@code this}.
*/
@@ -403,6 +451,12 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
writer.incrementState();
+
+ case 10:
+ if (!writer.writeIntArray("qryParts", qryParts))
+ return false;
+
+ writer.incrementState();
}
return true;
@@ -496,6 +550,14 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
reader.incrementState();
+
+ case 10:
+ qryParts = reader.readIntArray("qryParts");
+
+ if (!reader.isLastRead())
+ return false;
+
+ reader.incrementState();
}
return reader.afterMessageRead(GridH2QueryRequest.class);
@@ -508,7 +570,7 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 10;
+ return 11;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
new file mode 100644
index 0000000..708fb1d
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryAbstractSelfTest.java
@@ -0,0 +1,655 @@
+/*
+ * 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.processors.cache.distributed.near;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import java.util.UUID;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cache.affinity.AffinityKeyMapped;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.util.AttributeNodeFilter;
+import org.jsr166.ThreadLocalRandom8;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ * Abstract test for queries over explicit partitions.
+ */
+public abstract class IgniteCacheDistributedPartitionQueryAbstractSelfTest extends GridCommonAbstractTest {
+ /** Join query for test. */
+ private static final String JOIN_QRY = "select cl._KEY, de.depositId, de.regionId from " +
+ "\"cl\".Client cl, \"de\".Deposit de, \"re\".Region re where cl.clientId=de.clientId and de.regionId=re._KEY";
+
+ /** Region node attribute name. */
+ private static final String REGION_ATTR_NAME = "reg";
+
+ /** Grids count. */
+ protected static final int GRIDS_COUNT = 10;
+
+ /** IP finder. */
+ private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** Partitions per region distribution. */
+ protected static final int[] PARTS_PER_REGION = new int[] {10, 20, 30, 40, 24};
+
+ /** Unmapped region id. */
+ protected static final int UNMAPPED_REGION = PARTS_PER_REGION.length;
+
+ /** Clients per partition. */
+ protected static final int CLIENTS_PER_PARTITION = 1;
+
+ /** Total clients. */
+ private static final int TOTAL_CLIENTS;
+
+ /** Affinity function to use on partitioned caches. */
+ private static final AffinityFunction AFFINITY = new RegionAwareAffinityFunction();
+
+ /** Partitions count. */
+ private static final int PARTS_COUNT;
+
+ /** Regions to partitions mapping. */
+ protected static final NavigableMap<Integer, List<Integer>> REGION_TO_PART_MAP = new TreeMap<>();
+
+ /** Query threads count. */
+ protected static final int QUERY_THREADS_CNT = 4;
+
+ /** Restarting threads count. */
+ protected static final int RESTART_THREADS_CNT = 2;
+
+ /** Node stop time. */
+ protected static final int NODE_RESTART_TIME = 1_000;
+
+ static {
+ int total = 0, parts = 0, p = 0, regionId = 1;
+
+ for (int regCnt : PARTS_PER_REGION) {
+ total += regCnt * CLIENTS_PER_PARTITION;
+
+ parts += regCnt;
+
+ REGION_TO_PART_MAP.put(regionId++, Arrays.asList(p, regCnt));
+
+ p += regCnt;
+ }
+
+ /** Last region was left empty intentionally, see {@link #UNMAPPED_REGION} */
+ TOTAL_CLIENTS = total - PARTS_PER_REGION[PARTS_PER_REGION.length - 1] * CLIENTS_PER_PARTITION;
+
+ PARTS_COUNT = parts;
+ }
+
+ /** Deposits per client. */
+ public static final int DEPOSITS_PER_CLIENT = 10;
+
+ /** Rnd. */
+ protected GridRandom rnd = new GridRandom();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ MemoryConfiguration memCfg = new MemoryConfiguration();
+ memCfg.setDefaultMemoryPolicyName("default");
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(20 * 1024 * 1024));
+
+ cfg.setMemoryConfiguration(memCfg);
+
+ TcpDiscoverySpi spi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
+ spi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(spi);
+
+ /** Clients cache */
+ CacheConfiguration<ClientKey, Client> clientCfg = new CacheConfiguration<>();
+ clientCfg.setName("cl");
+ clientCfg.setWriteSynchronizationMode(FULL_SYNC);
+ clientCfg.setAtomicityMode(TRANSACTIONAL);
+ clientCfg.setRebalanceMode(SYNC);
+ clientCfg.setBackups(2);
+ clientCfg.setAffinity(AFFINITY);
+ clientCfg.setIndexedTypes(ClientKey.class, Client.class);
+
+ /** Deposits cache */
+ CacheConfiguration<DepositKey, Deposit> depoCfg = new CacheConfiguration<>();
+ depoCfg.setName("de");
+ depoCfg.setWriteSynchronizationMode(FULL_SYNC);
+ depoCfg.setAtomicityMode(TRANSACTIONAL);
+ depoCfg.setRebalanceMode(SYNC);
+ depoCfg.setBackups(2);
+ depoCfg.setAffinity(AFFINITY);
+ depoCfg.setIndexedTypes(DepositKey.class, Deposit.class);
+
+ /** Regions cache. Uses default affinity. */
+ CacheConfiguration<Integer, Region> regionCfg = new CacheConfiguration<>();
+ regionCfg.setName("re");
+ regionCfg.setWriteSynchronizationMode(FULL_SYNC);
+ regionCfg.setAtomicityMode(TRANSACTIONAL);
+ regionCfg.setRebalanceMode(SYNC);
+ regionCfg.setCacheMode(CacheMode.REPLICATED);
+ regionCfg.setIndexedTypes(Integer.class, Region.class);
+
+ cfg.setCacheConfiguration(clientCfg, depoCfg, regionCfg);
+
+ if ("client".equals(gridName))
+ cfg.setClientMode(true);
+ else {
+ Integer reg = regionForGrid(gridName);
+
+ cfg.setUserAttributes(F.asMap(REGION_ATTR_NAME, reg));
+
+ log().info("Assigned region " + reg + " to grid " + gridName);
+ }
+
+ return cfg;
+ }
+
+ /** */
+ private static final class RegionAwareAffinityFunction implements AffinityFunction {
+ /** {@inheritDoc} */
+ @Override public void reset() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partitions() {
+ return PARTS_COUNT;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int partition(Object key) {
+ Integer regionId;
+
+ if (key instanceof RegionKey)
+ regionId = ((RegionKey)key).regionId;
+ else if (key instanceof BinaryObject) {
+ BinaryObject bo = (BinaryObject)key;
+
+ regionId = bo.field("regionId");
+ }
+ else
+ throw new IgniteException("Unsupported key for region aware affinity");
+
+ List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+ Integer cnt = range.get(1);
+
+ return U.safeAbs(key.hashCode() % cnt) + range.get(0); // Assign partition in region's range.
+ }
+
+ /** {@inheritDoc} */
+ @Override public List<List<ClusterNode>> assignPartitions(AffinityFunctionContext affCtx) {
+ List<ClusterNode> nodes = affCtx.currentTopologySnapshot();
+
+ List<List<ClusterNode>> assignment = new ArrayList<>(PARTS_COUNT);
+
+ for (int p = 0; p < PARTS_COUNT; p++) {
+ // Get region for partition.
+ int regionId = regionForPart(p);
+
+ // Filter all nodes for region.
+ AttributeNodeFilter f = new AttributeNodeFilter(REGION_ATTR_NAME, regionId);
+
+ List<ClusterNode> regionNodes = new ArrayList<>();
+
+ for (ClusterNode node : nodes)
+ if (f.apply(node))
+ regionNodes.add(node);
+
+ final int cp = p;
+
+ Collections.sort(regionNodes, new Comparator<ClusterNode>() {
+ @Override public int compare(ClusterNode o1, ClusterNode o2) {
+ return Long.compare(hash(cp, o1), hash(cp, o2));
+ }
+ });
+
+ assignment.add(regionNodes);
+ }
+
+ return assignment;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeNode(UUID nodeId) {
+ // No-op.
+ }
+
+ /**
+ * @param part Partition.
+ */
+ protected int regionForPart(int part) {
+ for (Map.Entry<Integer, List<Integer>> entry : REGION_TO_PART_MAP.entrySet()) {
+ List<Integer> range = entry.getValue();
+
+ if (range.get(0) <= part && part < range.get(0) + range.get(1))
+ return entry.getKey();
+ }
+
+ throw new IgniteException("Failed to find zone for partition");
+ }
+
+ /**
+ * @param part Partition.
+ * @param obj Object.
+ */
+ private long hash(int part, Object obj) {
+ long x = ((long)part << 32) | obj.hashCode();
+ x ^= x >>> 12;
+ x ^= x << 25;
+ x ^= x >>> 27;
+ return x * 2685821657736338717L;
+ }
+ }
+
+ /**
+ * Assigns a region to grid part.
+ *
+ * @param gridName Grid name.
+ */
+ protected Integer regionForGrid(String gridName) {
+ char c = gridName.charAt(gridName.length() - 1);
+ switch (c) {
+ case '0':
+ return 1;
+ case '1':
+ case '2':
+ return 2;
+ case '3':
+ case '4':
+ case '5':
+ return 3;
+ default:
+ return 4;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ int sum1 = 0;
+ for (List<Integer> range : REGION_TO_PART_MAP.values())
+ sum1 += range.get(1);
+
+ assertEquals("Illegal partition per region distribution", PARTS_COUNT, sum1);
+
+ startGridsMultiThreaded(GRIDS_COUNT);
+
+ startGrid("client");
+
+ // Fill caches.
+ int clientId = 1;
+ int depositId = 1;
+ int regionId = 1;
+ int p = 1; // Percents counter. Log message will be printed 10 times.
+
+ try (IgniteDataStreamer<ClientKey, Client> clStr = grid(0).dataStreamer("cl");
+ IgniteDataStreamer<DepositKey, Deposit> depStr = grid(0).dataStreamer("de")) {
+ for (int cnt : PARTS_PER_REGION) {
+ // Last region was left empty intentionally.
+ if (regionId < PARTS_PER_REGION.length) {
+ for (int i = 0; i < cnt * CLIENTS_PER_PARTITION; i++) {
+ ClientKey ck = new ClientKey(clientId, regionId);
+
+ Client cl = new Client();
+ cl.firstName = "First_Name_" + clientId;
+ cl.lastName = "Last_Name_" + clientId;
+ cl.passport = clientId * 1_000;
+
+ clStr.addData(ck, cl);
+
+ for (int j = 0; j < DEPOSITS_PER_CLIENT; j++) {
+ DepositKey dk = new DepositKey(depositId++, new ClientKey(clientId, regionId));
+
+ Deposit depo = new Deposit();
+ depo.amount = ThreadLocalRandom8.current().nextLong(1_000_001);
+ depStr.addData(dk, depo);
+ }
+
+ if (clientId / (float)TOTAL_CLIENTS >= p / 10f) {
+ log().info("Loaded " + clientId + " of " + TOTAL_CLIENTS);
+
+ p++;
+ }
+
+ clientId++;
+ }
+ }
+
+ Region region = new Region();
+ region.name = "Region_" + regionId;
+ region.code = regionId * 10;
+
+ grid(0).cache("re").put(regionId, region);
+
+ regionId++;
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @param orig Originator.
+ */
+ protected void doTestRegionQuery(Ignite orig) {
+ IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+ for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+ SqlQuery<ClientKey, Client> qry1 = new SqlQuery<>(Client.class, "regionId=?");
+ qry1.setArgs(regionId);
+
+ List<Cache.Entry<ClientKey, Client>> clients1 = cl.query(qry1).getAll();
+
+ int expRegionCnt = regionId == 5 ? 0 : PARTS_PER_REGION[regionId - 1] * CLIENTS_PER_PARTITION;
+
+ assertEquals("Region " + regionId + " count", expRegionCnt, clients1.size());
+
+ validateClients(regionId, clients1);
+
+ // Repeat the same query with partition set condition.
+ List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+ SqlQuery<ClientKey, Client> qry2 = new SqlQuery<>(Client.class, "1=1");
+ qry2.setPartitions(createRange(range.get(0), range.get(1)));
+
+ try {
+ List<Cache.Entry<ClientKey, Client>> clients2 = cl.query(qry2).getAll();
+
+ assertEquals("Region " + regionId + " count with partition set", expRegionCnt, clients2.size());
+
+ // Query must produce only results from single region.
+ validateClients(regionId, clients2);
+
+ if (regionId == UNMAPPED_REGION)
+ fail();
+ } catch (CacheException ignored) {
+ if (regionId != UNMAPPED_REGION)
+ fail();
+ }
+ }
+ }
+
+ /** */
+ protected int[] createRange(int start, int cnt) {
+ int[] vals = new int[cnt];
+
+ for (int i = 0; i < cnt; i++)
+ vals[i] = start + i;
+
+ return vals;
+ }
+
+ /**
+ * @param orig Originator.
+ */
+ protected void doTestPartitionsQuery(Ignite orig) {
+ IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+ for (int regionId = 1; regionId <= PARTS_PER_REGION.length; regionId++) {
+ log().info("Running test queries for region " + regionId);
+
+ List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+ int[] parts = createRange(range.get(0), range.get(1));
+
+ int off = rnd.nextInt(parts.length);
+
+ int p1 = parts[off], p2 = parts[(off + (1 + rnd.nextInt(parts.length-1))) % parts.length];
+
+ log().info("Parts: " + p1 + " " + p2);
+
+ SqlQuery<ClientKey, Client> qry = new SqlQuery<>(Client.class, "1=1");
+
+ qry.setPartitions(p1, p2);
+
+ try {
+ List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry).getAll();
+
+ // Query must produce only results from two partitions.
+ for (Cache.Entry<ClientKey, Client> client : clients) {
+ int p = orig.affinity("cl").partition(client.getKey());
+
+ assertTrue("Incorrect partition for key", p == p1 || p == p2);
+ }
+
+ if (regionId == UNMAPPED_REGION)
+ fail();
+ } catch (CacheException ignored) {
+ if (regionId != UNMAPPED_REGION)
+ fail();
+ }
+ }
+ }
+
+ /**
+ * @param orig Query originator.
+ * @param regionIds Region ids.
+ */
+ protected void doTestJoinQuery(Ignite orig, int... regionIds) {
+ IgniteCache<ClientKey, Client> cl = orig.cache("cl");
+
+ if (regionIds == null) {
+ regionIds = new int[PARTS_PER_REGION.length];
+
+ for (int i = 0; i < regionIds.length; i++)
+ regionIds[i] = i + 1;
+ }
+
+ for (int regionId : regionIds) {
+ List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+ SqlFieldsQuery qry = new SqlFieldsQuery(JOIN_QRY);
+
+ int[] pSet = createRange(range.get(0), 1 + rnd.nextInt(range.get(1) - 1));
+
+ qry.setPartitions(pSet);
+
+ try {
+ List<List<?>> rows = cl.query(qry).getAll();
+
+ for (List<?> row : rows) {
+ ClientKey key = (ClientKey)row.get(0);
+
+ int p = orig.affinity("cl").partition(key);
+
+ assertTrue(Arrays.binarySearch(pSet, p) >= 0);
+ }
+
+ // Query must produce only results from single region.
+ for (List<?> row : rows)
+ assertEquals("Region id", regionId, ((Integer)row.get(2)).intValue());
+
+ if (regionId == UNMAPPED_REGION)
+ fail();
+ }
+ catch (CacheException ignored) {
+ if (X.hasCause(ignored, InterruptedException.class, IgniteInterruptedCheckedException.class))
+ return; // Allow interruptions.
+
+ if (regionId != UNMAPPED_REGION)
+ fail();
+ }
+ }
+ }
+
+ /**
+ * @param regionId Region id.
+ * @param clients Clients.
+ */
+ protected void validateClients(int regionId, List<Cache.Entry<ClientKey, Client>> clients) {
+ for (Cache.Entry<ClientKey, Client> entry : clients) {
+ List<Integer> range = REGION_TO_PART_MAP.get(regionId);
+
+ int start = range.get(0) * CLIENTS_PER_PARTITION;
+ int end = start + range.get(1) * CLIENTS_PER_PARTITION;
+
+ int clientId = entry.getKey().clientId;
+
+ assertTrue("Client id in range", start < clientId && start <= end);
+ }
+ }
+
+ /** */
+ protected static class ClientKey extends RegionKey {
+ /** Client id. */
+ @QuerySqlField(index = true)
+ protected int clientId;
+
+ /**
+ * @param clientId Client id.
+ * @param regionId Region id.
+ */
+ public ClientKey(int clientId, int regionId) {
+ this.clientId = clientId;
+ this.regionId = regionId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ ClientKey clientKey = (ClientKey)o;
+
+ return clientId == clientKey.clientId;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return clientId;
+ }
+ }
+
+ /** */
+ protected static class DepositKey extends RegionKey {
+ @QuerySqlField(index = true)
+ protected int depositId;
+
+ @QuerySqlField(index = true)
+ protected int clientId;
+
+ /** Client id. */
+ @AffinityKeyMapped
+ protected ClientKey clientKey;
+
+ /**
+ * @param depositId Client id.
+ * @param clientKey Client key.
+ */
+ public DepositKey(int depositId, ClientKey clientKey) {
+ this.depositId = depositId;
+ this.clientId = clientKey.clientId;
+ this.regionId = clientKey.regionId;
+ this.clientKey = clientKey;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ DepositKey that = (DepositKey)o;
+
+ return depositId == that.depositId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return depositId;
+ }
+ }
+
+ /** */
+ protected static class RegionKey implements Serializable {
+ /** Region id. */
+ @QuerySqlField(index = true)
+ protected int regionId;
+ }
+
+ /** */
+ protected static class Client {
+ @QuerySqlField
+ protected String firstName;
+
+ @QuerySqlField
+ protected String lastName;
+
+ @QuerySqlField(index = true)
+ protected int passport;
+ }
+
+ /** */
+ protected static class Deposit {
+ @QuerySqlField
+ protected long amount;
+ }
+
+ /** */
+ protected static class Region {
+ @QuerySqlField
+ protected String name;
+
+ @QuerySqlField
+ protected int code;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
new file mode 100644
index 0000000..0253fe8
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryConfigurationSelfTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.processors.cache.distributed.near;
+
+import java.util.Arrays;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests cache query configuration.
+ */
+public class IgniteCacheDistributedPartitionQueryConfigurationSelfTest extends GridCommonAbstractTest {
+ /** Tests partition validation. */
+ public void testPartitions() {
+ final SqlFieldsQuery qry = new SqlFieldsQuery("select 1");
+
+ // Empty set is not allowed.
+ failIfNotThrown(new Runnable() {
+ @Override public void run() {
+ qry.setPartitions();
+ }
+ });
+
+ // Duplicates are not allowed.
+ failIfNotThrown(new Runnable() {
+ @Override public void run() {
+ qry.setPartitions(0, 1, 2, 1);
+ }
+ });
+
+ // Values out of range are not allowed.
+ failIfNotThrown(new Runnable() {
+ @Override public void run() {
+ qry.setPartitions(-1, 0, 1);
+ }
+ });
+
+ // Duplicates with unordered input are not allowed.
+ failIfNotThrown(new Runnable() {
+ @Override public void run() {
+ qry.setPartitions(3, 2, 2);
+ }
+ });
+
+ // Values out of range are not allowed.
+ failIfNotThrown(new Runnable() {
+ @Override public void run() {
+ qry.setPartitions(-1, 0, 1);
+ }
+ });
+
+ // Expecting ordered set.
+ int[] tmp = new int[] {6, 2 ,3};
+ qry.setPartitions(tmp);
+
+ assertTrue(Arrays.equals(new int[]{2, 3, 6}, tmp));
+
+ // If already ordered expecting same instance.
+ qry.setPartitions((tmp = new int[] {0, 1, 2}));
+
+ assertTrue(tmp == qry.getPartitions());
+ }
+
+ /**
+ * @param r Runnable.
+ */
+ private void failIfNotThrown(Runnable r) {
+ try {
+ r.run();
+
+ fail();
+ }
+ catch (Exception ignored) {
+ // No-op.
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
new file mode 100644
index 0000000..68f9842
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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.processors.cache.distributed.near;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicIntegerArray;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
+import org.apache.ignite.internal.IgniteInternalFuture;
+
+/**
+ * Tests distributed queries over set of partitions on unstable topology.
+ */
+public class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest
+ extends IgniteCacheDistributedPartitionQueryAbstractSelfTest {
+ /**
+ * Tests join query within region on unstable topology.
+ */
+ public void testJoinQueryUnstableTopology() throws Exception {
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ final AtomicIntegerArray states = new AtomicIntegerArray(GRIDS_COUNT);
+
+ final Ignite client = grid("client");
+
+ final AtomicInteger cnt = new AtomicInteger();
+
+ IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+ @Override
+ public void run() {
+ while (!stop.get()) {
+ doTestJoinQuery(client, rnd.nextInt(PARTS_PER_REGION.length) + 1);
+
+ int cur = cnt.incrementAndGet();
+
+ if (cur % 100 == 0)
+ log().info("Queries count: " + cur);
+ }
+ }
+ }, QUERY_THREADS_CNT);
+
+ final AtomicIntegerArray restartStats = new AtomicIntegerArray(GRIDS_COUNT);
+
+ IgniteInternalFuture<?> fut2 = multithreadedAsync(new Callable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ while (!stop.get()) {
+ int grid = rnd.nextInt(GRIDS_COUNT);
+
+ String name = getTestIgniteInstanceName(grid);
+
+ Integer regionId = regionForGrid(name);
+
+ // Restart nodes only from region with enough number of nodes.
+ if (regionId != 3 && regionId != 4)
+ continue;
+
+ if (states.compareAndSet(grid, 0, 1)) {
+ restartStats.incrementAndGet(grid);
+
+ try {
+ stopGrid(grid);
+
+ Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
+
+ startGrid(grid);
+
+ Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
+ } finally {
+ states.set(grid, 0);
+ }
+ }
+ }
+
+ return null;
+ }
+ }, RESTART_THREADS_CNT);
+
+ try {
+ fut2.get(60, TimeUnit.SECONDS);
+ } catch (IgniteFutureTimeoutCheckedException ignored) {
+ stop.set(true);
+ }
+
+ try {
+ fut.get();
+ } finally {
+ log().info("Queries count: " + cnt.get());
+
+ for (int i = 0; i < GRIDS_COUNT; i++)
+ log().info("Grid [name = " + getTestIgniteInstanceName(i) + ", idx=" + i + " ] restarts count: " +
+ restartStats.get(i));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
new file mode 100644
index 0000000..00c3848
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheDistributedPartitionQuerySelfTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.processors.cache.distributed.near;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.SqlQuery;
+
+/**
+ * Tests distributed queries over set of partitions on stable topology.
+ */
+public class IgniteCacheDistributedPartitionQuerySelfTest extends IgniteCacheDistributedPartitionQueryAbstractSelfTest {
+ /** Tests query within region. */
+ public void testRegionQuery() {
+ doTestRegionQuery(grid(0));
+ }
+
+ /** Tests query within region (client). */
+ public void testRegionQueryClient() throws Exception {
+ doTestRegionQuery(grid("client"));
+ }
+
+ /** Test query within partitions. */
+ public void testPartitionsQuery() {
+ doTestPartitionsQuery(grid(0));
+ }
+
+ /** Test query within partitions (client). */
+ public void testPartitionsQueryClient() throws Exception {
+ doTestPartitionsQuery(grid("client"));
+ }
+
+ /** Tests join query within region. */
+ public void testJoinQuery() {
+ doTestJoinQuery(grid(0));
+ }
+
+ /** Tests join query within region. */
+ public void testJoinQueryClient() throws Exception {
+ doTestJoinQuery(grid("client"));
+ }
+
+ /** Tests local query over partitions. */
+ public void testLocalQuery() {
+ Affinity<Object> affinity = grid(0).affinity("cl");
+
+ int[] parts = affinity.primaryPartitions(grid(0).localNode());
+
+ Arrays.sort(parts);
+
+ IgniteCache<ClientKey, Client> cl = grid(0).cache("cl");
+
+ SqlQuery<ClientKey, Client> qry1 = new SqlQuery<>(Client.class, "1=1");
+ qry1.setLocal(true);
+ qry1.setPartitions(parts[0]);
+
+ List<Cache.Entry<ClientKey, Client>> clients = cl.query(qry1).getAll();
+
+ for (Cache.Entry<ClientKey, Client> client : clients)
+ assertEquals("Incorrect partition", parts[0], affinity.partition(client.getKey()));
+
+ SqlFieldsQuery qry2 = new SqlFieldsQuery("select cl._KEY, cl._VAL from \"cl\".Client cl");
+ qry2.setLocal(true);
+ qry2.setPartitions(parts[0]);
+
+ List<List<?>> rows = cl.query(qry2).getAll();
+
+ for (List<?> row : rows)
+ assertEquals("Incorrect partition", parts[0], affinity.partition(row.get(0)));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
index 6fc9c39..001f40b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
@@ -33,6 +33,8 @@ import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -89,6 +91,12 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
+ MemoryConfiguration memCfg = new MemoryConfiguration();
+ memCfg.setDefaultMemoryPolicyName("default");
+ memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setName("default").setSize(50 * 1024 * 1024));
+
+ c.setMemoryConfiguration(memCfg);
+
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
http://git-wip-us.apache.org/repos/asf/ignite/blob/5ef610c0/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
index 862d1a2..032e544 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
@@ -68,6 +68,8 @@ import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheA
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedQueryCancelSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheP
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryAbstractDistributedJoinSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheDistributedPartitionQueryConfigurationSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNoRebalanceSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryROSelfTest;
@@ -277,6 +280,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(IgniteQueryDedicatedPoolTest.class);
suite.addTestSuite(IgniteSqlEntryCacheModeAgnosticTest.class);
suite.addTestSuite(QueryEntityCaseMismatchTest.class);
+ suite.addTestSuite(IgniteCacheDistributedPartitionQuerySelfTest.class);
+ suite.addTestSuite(IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest.class);
+ suite.addTestSuite(IgniteCacheDistributedPartitionQueryConfigurationSelfTest.class);
return suite;
}
[10/50] [abbrv] ignite git commit: Removed unused swap-related code.
Posted by vo...@apache.org.
Removed unused swap-related code.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/34020433
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/34020433
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/34020433
Branch: refs/heads/master
Commit: 340204333624ecbc4166e52a83056885c673373c
Parents: b58d584
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 16:49:02 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 16:49:02 2017 +0300
----------------------------------------------------------------------
.../cache/GridCacheBatchSwapEntry.java | 76 -----
.../processors/cache/GridCacheEntryEx.java | 23 --
.../cache/GridCacheEvictionManager.java | 95 +-----
.../processors/cache/GridCacheMapEntry.java | 73 ----
.../processors/cache/GridCacheSwapEntry.java | 82 -----
.../cache/GridCacheSwapEntryImpl.java | 339 -------------------
.../cache/IgniteCacheOffheapManager.java | 3 -
.../cache/IgniteCacheOffheapManagerImpl.java | 5 -
.../processors/cache/GridCacheTestEntryEx.java | 15 -
9 files changed, 9 insertions(+), 702 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
deleted file mode 100644
index 01c9bab..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheBatchSwapEntry.java
+++ /dev/null
@@ -1,76 +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.internal.processors.cache;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Entry for batch swap operations.
- */
-public class GridCacheBatchSwapEntry extends GridCacheSwapEntryImpl {
- /** Key. */
- private KeyCacheObject key;
-
- /** Partition. */
- private int part;
-
- /**
- * Creates batch swap entry.
- *
- * @param key Key.
- * @param part Partition id.
- * @param valBytes Value bytes.
- * @param type Value type.
- * @param ver Version.
- * @param ttl Time to live.
- * @param expireTime Expire time.
- * @param keyClsLdrId Key class loader ID.
- * @param valClsLdrId Optional value class loader ID.
- */
- public GridCacheBatchSwapEntry(KeyCacheObject key,
- int part,
- ByteBuffer valBytes,
- byte type,
- GridCacheVersion ver,
- long ttl,
- long expireTime,
- IgniteUuid keyClsLdrId,
- @Nullable IgniteUuid valClsLdrId) {
- super(valBytes, type, ver, ttl, expireTime, keyClsLdrId, valClsLdrId);
-
- this.key = key;
- this.part = part;
- }
-
- /**
- * @return Key.
- */
- public KeyCacheObject key() {
- return key;
- }
-
- /**
- * @return Partition id.
- */
- public int partition() {
- return part;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 1eab04e..6a5b4b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -221,16 +221,6 @@ public interface GridCacheEntryEx {
boolean evictOffheap) throws IgniteCheckedException;
/**
- * Evicts entry when batch evict is performed. When called, does not write entry data to swap, but instead
- * returns batch swap entry if entry was marked obsolete.
- *
- * @param obsoleteVer Version to mark obsolete with.
- * @return Swap entry if this entry was marked obsolete, {@code null} if entry was not evicted.
- * @throws IgniteCheckedException If failed.
- */
- public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer) throws IgniteCheckedException;
-
- /**
* This method should be called each time entry is marked obsolete
* other than by calling {@link #markObsolete(GridCacheVersion)}.
*/
@@ -695,19 +685,6 @@ public interface GridCacheEntryEx {
boolean fromStore) throws IgniteCheckedException, GridCacheEntryRemovedException;
/**
- * Sets new value if current version is <tt>0</tt> using swap entry data.
- * Note that this method does not update cache index.
- *
- * @param key Key.
- * @param unswapped Swap entry to set entry state from.
- * @return {@code True} if initial value was set.
- * @throws IgniteCheckedException In case of error.
- * @throws GridCacheEntryRemovedException If entry was removed.
- */
- public boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped)
- throws IgniteCheckedException, GridCacheEntryRemovedException;
-
- /**
* Create versioned entry for this cache entry.
*
* @param keepBinary Keep binary flag.
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 0deae07..8ba10a2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -17,12 +17,7 @@
package org.apache.ignite.internal.processors.cache;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
import java.util.Set;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.eviction.EvictionFilter;
@@ -31,8 +26,8 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
import org.apache.ignite.internal.util.GridBusyLock;
-import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -260,96 +255,24 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter implements
/** {@inheritDoc} */
@Override public void batchEvict(Collection<?> keys, @Nullable GridCacheVersion obsoleteVer)
throws IgniteCheckedException {
- List<GridCacheEntryEx> locked = new ArrayList<>(keys.size());
-
- Set<GridCacheEntryEx> notRmv = null;
-
- Collection<GridCacheBatchSwapEntry> swapped = new ArrayList<>(keys.size());
-
boolean recordable = cctx.events().isRecordable(EVT_CACHE_ENTRY_EVICTED);
GridCacheAdapter cache = cctx.cache();
- Map<Object, GridCacheEntryEx> cached = U.newLinkedHashMap(keys.size());
-
// Get all participating entries to avoid deadlock.
for (Object k : keys) {
KeyCacheObject cacheKey = cctx.toCacheKeyObject(k);
- GridCacheEntryEx e = cache.peekEx(cacheKey);
-
- if (e != null)
- cached.put(k, e);
- }
-
- try {
- for (GridCacheEntryEx entry : cached.values()) {
- // Do not evict internal entries.
- if (entry.key().internal())
- continue;
-
- // Lock entry.
- GridUnsafe.monitorEnter(entry);
-
- locked.add(entry);
-
- if (entry.obsolete()) {
- if (notRmv == null)
- notRmv = new HashSet<>();
-
- notRmv.add(entry);
-
- continue;
- }
-
- if (obsoleteVer == null)
- obsoleteVer = cctx.versions().next();
-
- GridCacheBatchSwapEntry swapEntry = entry.evictInBatchInternal(obsoleteVer);
-
- if (swapEntry != null) {
- assert entry.obsolete() : entry;
-
- swapped.add(swapEntry);
-
- if (log.isDebugEnabled())
- log.debug("Entry was evicted [entry=" + entry + ", localNode=" + cctx.nodeId() + ']');
- }
- else if (!entry.obsolete()) {
- if (notRmv == null)
- notRmv = new HashSet<>();
-
- notRmv.add(entry);
- }
- }
-
- // Batch write to swap.
- if (!swapped.isEmpty())
- cctx.offheap().writeAll(swapped);
- }
- finally {
- // Unlock entries in reverse order.
- for (ListIterator<GridCacheEntryEx> it = locked.listIterator(locked.size()); it.hasPrevious(); ) {
- GridCacheEntryEx e = it.previous();
-
- GridUnsafe.monitorExit(e);
- }
-
- // Remove entries and fire events outside the locks.
- for (GridCacheEntryEx entry : locked) {
- if (entry.obsolete() && (notRmv == null || !notRmv.contains(entry))) {
- entry.onMarkedObsolete();
-
- cache.removeEntry(entry);
+ GridCacheEntryEx entry = cache.peekEx(cacheKey);
- if (plcEnabled)
- notifyPolicy(entry);
+ if (entry != null && entry.evictInternal(GridCacheVersionManager.EVICT_VER, null, false)) {
+ if (plcEnabled)
+ notifyPolicy(entry);
- if (recordable)
- cctx.events().addEvent(entry.partition(), entry.key(), cctx.nodeId(), (IgniteUuid)null, null,
- EVT_CACHE_ENTRY_EVICTED, null, false, entry.rawGet(), entry.hasValue(), null, null, null,
- false);
- }
+ if (recordable)
+ cctx.events().addEvent(entry.partition(), entry.key(), cctx.nodeId(), (IgniteUuid)null, null,
+ EVT_CACHE_ENTRY_EVICTED, null, false, entry.rawGet(), entry.hasValue(), null, null, null,
+ false);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 856ac993..21c58fa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -2709,31 +2709,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
/** {@inheritDoc} */
- @Override public synchronized boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped) throws
- IgniteCheckedException,
- GridCacheEntryRemovedException {
- checkObsolete();
-
- if (isNew()) {
- CacheObject val = unswapped.value();
-
- val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx);
-
- // Version does not change for load ops.
- update(val,
- unswapped.expireTime(),
- unswapped.ttl(),
- unswapped.version(),
- true
- );
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
@Override public synchronized GridCacheVersionedEntryEx versionedEntry(final boolean keepBinary)
throws IgniteCheckedException, GridCacheEntryRemovedException {
boolean isNew = isStartVersion();
@@ -3518,54 +3493,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return false;
}
- /** {@inheritDoc} */
- @Override public final GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
- throws IgniteCheckedException {
- assert Thread.holdsLock(this);
- assert !obsolete();
-
- GridCacheBatchSwapEntry ret = null;
-
- try {
- if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
- if (!isStartVersion() && hasValueUnlocked()) {
- IgniteUuid valClsLdrId = null;
- IgniteUuid keyClsLdrId = null;
-
- if (cctx.deploymentEnabled()) {
- if (val != null) {
- valClsLdrId = cctx.deploy().getClassLoaderId(
- U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false)));
- }
-
- keyClsLdrId = cctx.deploy().getClassLoaderId(
- U.detectObjectClassLoader(keyValue(false)));
- }
-
- IgniteBiTuple<byte[], Byte> valBytes = valueBytes0();
-
- ret = new GridCacheBatchSwapEntry(key(),
- partition(),
- ByteBuffer.wrap(valBytes.get1()),
- valBytes.get2(),
- ver,
- ttlExtras(),
- expireTimeExtras(),
- keyClsLdrId,
- valClsLdrId);
- }
-
- value(null);
- }
- }
- catch (GridCacheEntryRemovedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Got removed entry when evicting (will simply return): " + this);
- }
-
- return ret;
- }
-
/**
* @param filter Entry filter.
* @return {@code True} if entry is visitable.
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
deleted file mode 100644
index 73519eb..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
+++ /dev/null
@@ -1,82 +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.internal.processors.cache;
-
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Swap entry.
- */
-public interface GridCacheSwapEntry {
- /**
- * @return Value bytes.
- */
- public byte[] valueBytes();
-
- /**
- * @return Object type.
- */
- public byte type();
-
- /**
- * @param valBytes Value bytes.
- */
- public void valueBytes(@Nullable byte[] valBytes);
-
- /**
- * @return Value.
- */
- public CacheObject value();
-
- /**
- * @param val Value.
- */
- public void value(CacheObject val);
-
- /**
- * @return Version.
- */
- public GridCacheVersion version();
-
- /**
- * @return Time to live.
- */
- public long ttl();
-
- /**
- * @return Expire time.
- */
- public long expireTime();
-
- /**
- * @return Class loader ID for entry key ({@code null} for local class loader).
- */
- @Nullable public IgniteUuid keyClassLoaderId();
-
- /**
- * @return Class loader ID for entry value ({@code null} for local class loader).
- */
- @Nullable public IgniteUuid valueClassLoaderId();
-
- /**
- * @return If entry is offheap based returns offheap address, otherwise 0.
- */
- public long offheapPointer();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
deleted file mode 100644
index 410a6ee..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
+++ /dev/null
@@ -1,339 +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.internal.processors.cache;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
-import org.apache.ignite.internal.processors.cache.version.GridCacheVersionEx;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteUuid;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Swap entry.
- */
-public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
- /** */
- static final int EXPIRE_TIME_OFFSET = 8;
-
- /** */
- static final int VERSION_OFFSET = 16;
-
- /** */
- static final int VERSION_SIZE = 16;
-
- /** */
- static final int VERSION_EX_SIZE = 32;
-
- /** */
- static final int GUID_SIZE = 24;
-
- /** Value bytes. */
- private ByteBuffer valBytes;
-
- /** Value. */
- private CacheObject val;
-
- /** Type. */
- private byte type;
-
- /** Class loader ID. */
- private IgniteUuid keyClsLdrId;
-
- /** Class loader ID. */
- private IgniteUuid valClsLdrId;
-
- /** Version. */
- private GridCacheVersion ver;
-
- /** Time to live. */
- private long ttl;
-
- /** Expire time. */
- private long expireTime;
-
- /**
- * @param valBytes Value.
- * @param type Type.
- * @param ver Version.
- * @param ttl Entry time to live.
- * @param expireTime Expire time.
- * @param keyClsLdrId Class loader ID for entry key (can be {@code null} for local class loader).
- * @param valClsLdrId Class loader ID for entry value (can be {@code null} for local class loader).
- */
- public GridCacheSwapEntryImpl(
- ByteBuffer valBytes,
- byte type,
- GridCacheVersion ver,
- long ttl,
- long expireTime,
- @Nullable IgniteUuid keyClsLdrId,
- @Nullable IgniteUuid valClsLdrId) {
- this.valBytes = valBytes;
- this.type = type;
- this.ver = ver;
- this.ttl = ttl;
- this.expireTime = expireTime;
- this.valClsLdrId = valClsLdrId;
- this.keyClsLdrId = keyClsLdrId;
- }
-
- /**
- * @param bytes Entry bytes.
- * @return TTL.
- */
- public static long timeToLive(byte[] bytes) {
- return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF);
- }
-
- /**
- * @param bytes Entry bytes.
- * @return Expire time.
- */
- public static long expireTime(byte[] bytes) {
- return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
- }
-
- /**
- * @param bytes Entry bytes.
- * @return Version.
- */
- public static GridCacheVersion version(byte[] bytes) {
- long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
- boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
-
- return U.readVersion(bytes, off, verEx);
- }
-
- /**
- * @param bytes Entry bytes.
- * @return Value if value is byte array, otherwise {@code null}.
- */
- @Nullable public static IgniteBiTuple<byte[], Byte> getValue(byte[] bytes) {
- long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
- boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
-
- off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
- int arrLen = GridUnsafe.getInt(bytes, off);
-
- off += 4;
-
- byte type = GridUnsafe.getByte(bytes, off++);
-
- byte[] valBytes = new byte[arrLen];
-
- GridUnsafe.copyMemory(bytes, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
- return new IgniteBiTuple<>(valBytes, type);
- }
-
- /** {@inheritDoc} */
- @Override public byte[] valueBytes() {
- if (valBytes != null) {
- assert valBytes.capacity() == valBytes.limit();
-
- return valBytes.array();
- }
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void valueBytes(@Nullable byte[] valBytes) {
- this.valBytes = valBytes != null ? ByteBuffer.wrap(valBytes) : null;
- }
-
- /** {@inheritDoc} */
- @Override public CacheObject value() {
- return val;
- }
-
- /** {@inheritDoc} */
- @Override public void value(CacheObject val) {
- this.val = val;
- }
-
- /** {@inheritDoc} */
- @Override public byte type() {
- return type;
- }
-
- /** {@inheritDoc} */
- @Override public GridCacheVersion version() {
- return ver;
- }
-
- /** {@inheritDoc} */
- @Override public long ttl() {
- return ttl;
- }
-
- /** {@inheritDoc} */
- @Override public long expireTime() {
- return expireTime;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public IgniteUuid keyClassLoaderId() {
- return keyClsLdrId;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public IgniteUuid valueClassLoaderId() {
- return valClsLdrId;
- }
-
- /** {@inheritDoc} */
- @Override public long offheapPointer() {
- return 0;
- }
-
- /**
- * @return Entry bytes.
- */
- public byte[] marshal() {
- // Ttl + expire time + Ex Version flag + Version.
- int size = 16 + 1 + ((ver instanceof GridCacheVersionEx) ? VERSION_EX_SIZE : VERSION_SIZE);
-
- size += 1; // Plain byte array flag.
-
- int len = valBytes.limit();
-
- size += len + 4; // Value bytes.
-
- size += (valClsLdrId == null ? 1 : (1 + GUID_SIZE));
-
- size += (keyClsLdrId == null ? 1 : (1 + GUID_SIZE));
-
- byte[] arr = new byte[size];
-
- long off = GridUnsafe.BYTE_ARR_OFF;
-
- GridUnsafe.putLong(arr, off, ttl);
-
- off += 8;
-
- GridUnsafe.putLong(arr, off, expireTime);
-
- off += 8;
-
- off = U.writeVersion(arr, off, ver);
-
- GridUnsafe.putInt(arr, off, len);
-
- off += 4;
-
- GridUnsafe.putByte(arr, off++, type);
-
- GridUnsafe.copyMemory(valBytes.array(), GridUnsafe.BYTE_ARR_OFF, arr, off, len);
-
- off += len;
-
- off = U.writeGridUuid(arr, off, valClsLdrId);
-
- U.writeGridUuid(arr, off, keyClsLdrId);
-
- return arr;
- }
-
- /**
- * @param arr Entry bytes.
- * @param valOnly If {@code true} unmarshalls only entry value.
- * @return Entry.
- */
- public static GridCacheSwapEntryImpl unmarshal(byte[] arr, boolean valOnly) {
- if (valOnly) {
- long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
-
- boolean verEx = GridUnsafe.getByte(arr, off++) != 0;
-
- off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
- int arrLen = GridUnsafe.getInt(arr, off);
-
- off += 4;
-
- byte type = GridUnsafe.getByte(arr, off++);
-
- byte[] valBytes = new byte[arrLen];
-
- GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
- return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
- type,
- null,
- 0L,
- 0L,
- null,
- null);
- }
-
- long off = GridUnsafe.BYTE_ARR_OFF;
-
- long ttl = GridUnsafe.getLong(arr, off);
-
- off += 8;
-
- long expireTime = GridUnsafe.getLong(arr, off);
-
- off += 8;
-
- boolean verEx = GridUnsafe.getBoolean(arr, off++);
-
- GridCacheVersion ver = U.readVersion(arr, off, verEx);
-
- off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
-
- int arrLen = GridUnsafe.getInt(arr, off);
-
- off += 4;
-
- byte type = GridUnsafe.getByte(arr, off++);
-
- byte[] valBytes = new byte[arrLen];
-
- GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
-
- off += arrLen;
-
- IgniteUuid valClsLdrId = U.readGridUuid(arr, off);
-
- off += valClsLdrId == null ? 1 : (1 + GUID_SIZE);
-
- IgniteUuid keyClsLdrId = U.readGridUuid(arr, off);
-
- return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
- type,
- ver,
- ttl,
- expireTime,
- keyClsLdrId,
- valClsLdrId);
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridCacheSwapEntryImpl.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index 4a98f6a..9eb5368 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -239,9 +239,6 @@ public interface IgniteCacheOffheapManager extends GridCacheManager {
*/
public GridAtomicLong globalRemoveId();
- // TODO GG-10884: moved from GridCacheSwapManager.
- void writeAll(Iterable<GridCacheBatchSwapEntry> swapped) throws IgniteCheckedException;
-
/**
* @param idxName Index name.
* @return Root page for index tree.
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 73edbe1..650f65e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -431,11 +431,6 @@ public class IgniteCacheOffheapManagerImpl extends GridCacheManagerAdapter imple
return 0;
}
- /** {@inheritDoc} */
- @Override public void writeAll(Iterable<GridCacheBatchSwapEntry> swapped) throws IgniteCheckedException {
- // No-op.
- }
-
/**
* @param primary {@code True} if need return primary entries.
* @param backup {@code True} if need return backup entries.
http://git-wip-us.apache.org/repos/asf/ignite/blob/34020433/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index a060f7e..53764ca 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -376,14 +376,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
return false;
}
- /** {@inheritDoc} */
- @Override public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
- throws IgniteCheckedException {
- assert false;
-
- return null;
- }
-
/** @inheritDoc */
@Override public boolean isNew() {
assert false; return false;
@@ -663,13 +655,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
}
/** @inheritDoc */
- @Override public boolean initialValue(KeyCacheObject key, GridCacheSwapEntry unswapped) {
- assert false;
-
- return false;
- }
-
- /** @inheritDoc */
@Override public GridCacheVersionedEntryEx versionedEntry(final boolean keepBinary) throws IgniteCheckedException {
return null;
}
[27/50] [abbrv] ignite git commit: ignite-2.0 - Javadoc fix + code
style
Posted by vo...@apache.org.
ignite-2.0 - Javadoc fix + code style
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4be320ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4be320ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4be320ac
Branch: refs/heads/master
Commit: 4be320ac44f29b927f8b487caa00479fa6add3ff
Parents: 7d33dd5
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Apr 26 10:59:13 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Apr 26 10:59:13 2017 +0300
----------------------------------------------------------------------
.../h2/twostep/msg/GridH2QueryRequest.java | 26 ++++++++++----------
1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4be320ac/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
index 6741d89..17bb9f6 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/msg/GridH2QueryRequest.java
@@ -133,21 +133,20 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
/**
* @param req Request.
- * @return {@code this}.
*/
public GridH2QueryRequest(GridH2QueryRequest req) {
- this.reqId = req.reqId;
- this.caches = req.caches;
- this.topVer = req.topVer;
- this.parts = req.parts;
- this.qryParts = req.qryParts;
- this.pageSize = req.pageSize;
- this.qrys = req.qrys;
- this.flags = req.flags;
- this.tbls = req.tbls;
- this.timeout = req.timeout;
- this.params = req.params;
- this.paramsBytes = req.paramsBytes;
+ reqId = req.reqId;
+ caches = req.caches;
+ topVer = req.topVer;
+ parts = req.parts;
+ qryParts = req.qryParts;
+ pageSize = req.pageSize;
+ qrys = req.qrys;
+ flags = req.flags;
+ tbls = req.tbls;
+ timeout = req.timeout;
+ params = req.params;
+ paramsBytes = req.paramsBytes;
}
/**
@@ -359,6 +358,7 @@ public class GridH2QueryRequest implements Message, GridCacheQueryMarshallable {
}
/** {@inheritDoc} */
+ @SuppressWarnings("IfMayBeConditional")
@Override public void unmarshall(Marshaller m, GridKernalContext ctx) {
if (params != null)
return;
[28/50] [abbrv] ignite git commit: ignite-2.0 - Fixing tests
Posted by vo...@apache.org.
ignite-2.0 - Fixing tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9cd761e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9cd761e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9cd761e
Branch: refs/heads/master
Commit: c9cd761e05ffcd4310e8df60ca62337e30507829
Parents: 4be320a
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Wed Apr 26 12:46:29 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Apr 26 12:46:29 2017 +0300
----------------------------------------------------------------------
.../datastructures/GridCacheLockImpl.java | 6 ++
.../handlers/cache/GridCacheCommandHandler.java | 4 +-
...eAbstractDataStructuresFailoverSelfTest.java | 64 ++++++++++++--------
.../tcp/ipfinder/zk/ZookeeperIpFinderTest.java | 5 +-
4 files changed, 51 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
index 3f1a0dd..0192354 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheLockImpl.java
@@ -197,6 +197,9 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
outgoingSignals.put(condition, cnt + 1);
}
+ /**
+ * @param condition Condition.
+ */
protected void addOutgoingSignalAll(String condition) {
outgoingSignals.put(condition, 0);
}
@@ -329,6 +332,9 @@ public final class GridCacheLockImpl implements GridCacheLockEx, IgniteChangeGlo
return thisNode.equals(getOwnerNode()) || thisNode.equals(newOwnerID);
}
+ /**
+ * @param newOwnerThreadId New owner thread id.
+ */
protected void setCurrentOwnerThread(long newOwnerThreadId) {
currentOwnerThreadId = newOwnerThreadId;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
index 79b395d..18cd6af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/handlers/cache/GridCacheCommandHandler.java
@@ -299,7 +299,9 @@ public class GridCacheCommandHandler extends GridRestCommandHandlerAdapter {
return col;
}
- throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal + ", old=" + origVal + ']');
+ throw new IgniteCheckedException("Incompatible types [appendVal=" + appendVal +
+ ",type=" + (appendVal != null ? appendVal.getClass().getSimpleName() : "NULL") + ", old=" + origVal +
+ ",type= " + (origVal != null ? origVal.getClass().getSimpleName() : "NULL") + ']');
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
index cb4f6fc..b38f07e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
@@ -33,7 +33,6 @@ import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteAtomicReference;
import org.apache.ignite.IgniteAtomicSequence;
import org.apache.ignite.IgniteAtomicStamped;
-import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteCountDownLatch;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteInterruptedException;
@@ -44,11 +43,13 @@ import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.AtomicConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.typedef.CA;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.PA;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteCallable;
@@ -60,6 +61,7 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
/**
* Failover tests for cache data structures.
@@ -408,7 +410,7 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
* @throws Exception If failed.
*/
public void testSemaphoreFailoverSafe() throws Exception {
- try (IgniteSemaphore semaphore = grid(0).semaphore(STRUCTURE_NAME, 20, true, true)) {
+ try (final IgniteSemaphore semaphore = grid(0).semaphore(STRUCTURE_NAME, 20, true, true)) {
Ignite g = startGrid(NEW_IGNITE_INSTANCE_NAME);
IgniteSemaphore semaphore2 = g.semaphore(STRUCTURE_NAME, 20, true, false);
@@ -419,7 +421,11 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
stopGrid(NEW_IGNITE_INSTANCE_NAME);
- assertEquals(20, semaphore.availablePermits());
+ waitForCondition(new PA() {
+ @Override public boolean apply() {
+ return semaphore.availablePermits() == 20;
+ }
+ }, 2000);
}
}
@@ -736,10 +742,16 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
/**
* @throws Exception If failed.
*/
- private void doTestReentrantLock(ConstantTopologyChangeWorker topWorker, final boolean failoverSafe, final boolean fair) throws Exception {
- try (IgniteLock lock = grid(0).reentrantLock(STRUCTURE_NAME, failoverSafe, fair, true)) {
- IgniteInternalFuture<?> fut = topWorker.startChangingTopology(new IgniteClosure<Ignite, Object>() {
- @Override public Object apply(Ignite ignite) {
+ private void doTestReentrantLock(
+ final ConstantTopologyChangeWorker topWorker,
+ final boolean failoverSafe,
+ final boolean fair
+ ) throws Exception {
+ IgniteEx ig = grid(0);
+
+ try (IgniteLock lock = ig.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, true)) {
+ IgniteInternalFuture<?> fut = topWorker.startChangingTopology(new IgniteClosure<Ignite, Void>() {
+ @Override public Void apply(Ignite ignite) {
final IgniteLock l = ignite.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false);
final AtomicBoolean done = new AtomicBoolean(false);
@@ -767,33 +779,33 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
});
while (!fut.isDone()) {
- while (true) {
- try {
- lock.lock();
- }
- catch (IgniteException e) {
- // Exception may happen in non-failoversafe mode.
- if (failoverSafe)
- throw e;
- }
- finally {
- // Broken lock cannot be used in non-failoversafe mode.
- if(!lock.isBroken() || failoverSafe) {
- assertTrue(lock.isHeldByCurrentThread());
+ try {
+ lock.lock();
+ }
+ catch (IgniteException e) {
+ // Exception may happen in non-failoversafe mode.
+ if (failoverSafe)
+ throw e;
+ }
+ finally {
+ // Broken lock cannot be used in non-failoversafe mode.
+ if(!lock.isBroken() || failoverSafe) {
+ assertTrue(lock.isHeldByCurrentThread());
- lock.unlock();
+ lock.unlock();
- assertFalse(lock.isHeldByCurrentThread());
- }
- break;
+ assertFalse(lock.isHeldByCurrentThread());
}
}
}
fut.get();
- for (Ignite g : G.allGrids())
- assertFalse(g.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false).isHeldByCurrentThread());
+ for (Ignite g : G.allGrids()){
+ IgniteLock l = g.reentrantLock(STRUCTURE_NAME, failoverSafe, fair, false);
+
+ assertTrue(g.name(), !l.isHeldByCurrentThread() || lock.isBroken());
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c9cd761e/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
index 3aa3ce8..20947c4 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/zk/ZookeeperIpFinderTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.testframework.GridTestUtils;
@@ -366,7 +367,9 @@ public class ZookeeperIpFinderTest extends GridCommonAbstractTest {
try {
return 0 == zkCurator.getChildren().forPath(SERVICES_IGNITE_ZK_PATH).size();
}
- catch (Exception ignored) {
+ catch (Exception e) {
+ U.error(log, "Failed to wait for zk condition", e);
+
return false;
}
}
[49/50] [abbrv] ignite git commit: ignite-4799 TcpDiscoverySpi:
removed missedHeartbeats properties,
heartbeatFrequency (instead use IgiteConfiguration.metricsUpdateFrequency).
Added IgiteConfiguration.clientFailureDetectionTimeout.
Posted by vo...@apache.org.
ignite-4799 TcpDiscoverySpi: removed missedHeartbeats properties, heartbeatFrequency (instead use IgiteConfiguration.metricsUpdateFrequency). Added IgiteConfiguration.clientFailureDetectionTimeout.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6998785a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6998785a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6998785a
Branch: refs/heads/master
Commit: 6998785a8861387b7ad83527a381dc5b772cf76f
Parents: c829aac
Author: Alexander Belyak <al...@xored.com>
Authored: Wed Apr 26 15:43:42 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 26 15:43:42 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/gridify/AbstractAopTest.java | 4 +-
.../gridify/ExternalNonSpringAopSelfTest.java | 6 +-
.../clients/src/test/resources/spring-cache.xml | 1 -
.../apache/ignite/cluster/ClusterMetrics.java | 4 +-
.../org/apache/ignite/cluster/ClusterNode.java | 11 +-
.../configuration/IgniteConfiguration.java | 52 ++-
.../org/apache/ignite/events/EventType.java | 2 +-
.../processors/job/GridJobProcessor.java | 18 +-
.../utils/PlatformConfigurationUtils.java | 32 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 32 ++
.../spi/IgniteSpiOperationTimeoutHelper.java | 8 +-
.../jobstealing/JobStealingCollisionSpi.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 6 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 31 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 142 ++++----
.../spi/discovery/tcp/TcpDiscoverySpi.java | 143 ++------
.../spi/discovery/tcp/TcpDiscoverySpiMBean.java | 26 +-
.../tcp/internal/TcpDiscoveryNode.java | 33 +-
.../TcpDiscoveryClientHeartbeatMessage.java | 72 ----
.../TcpDiscoveryClientMetricsUpdateMessage.java | 72 ++++
.../messages/TcpDiscoveryHeartbeatMessage.java | 338 -------------------
.../TcpDiscoveryMetricsUpdateMessage.java | 338 +++++++++++++++++++
.../adaptive/AdaptiveLoadBalancingSpi.java | 12 +-
.../resources/META-INF/classnames.properties | 8 +-
.../core/src/test/config/load/dsi-load-base.xml | 3 +-
.../src/test/config/load/merge-sort-base.xml | 7 +-
.../config/streamer/spring-streamer-base.xml | 5 +-
.../java/org/apache/ignite/GridTestJob.java | 19 ++
.../java/org/apache/ignite/GridTestTask.java | 18 +-
.../internal/ClusterNodeMetricsSelfTest.java | 10 +-
.../ignite/internal/GridAffinityMappedTest.java | 5 +-
.../internal/GridAffinityP2PSelfTest.java | 3 +-
.../ignite/internal/GridAffinitySelfTest.java | 3 +-
.../GridCancelledJobsMetricsSelfTest.java | 4 +-
...ridFailFastNodeFailureDetectionSelfTest.java | 4 +-
.../GridJobCollisionCancelSelfTest.java | 2 +-
.../GridDiscoveryManagerAliveCacheSelfTest.java | 4 +-
.../GridCacheAbstractFailoverSelfTest.java | 4 +-
.../cache/GridCacheAbstractSelfTest.java | 4 +-
.../cache/GridCacheMvccManagerSelfTest.java | 3 +-
.../cache/IgniteCacheAbstractTest.java | 10 +-
.../binary/BinaryMetadataUpdatesFlowTest.java | 4 +-
.../CacheLateAffinityAssignmentTest.java | 3 +-
.../GridCacheNodeFailureAbstractTest.java | 3 +-
.../distributed/IgniteCache150ClientsTest.java | 2 +-
.../IgniteCacheNearRestartRollbackSelfTest.java | 2 +-
...dCacheColocatedTxSingleThreadedSelfTest.java | 2 +-
.../dht/GridCacheDhtPreloadDelayedSelfTest.java | 2 +-
.../GridCacheDhtPreloadMessageCountTest.java | 2 +-
.../atomic/IgniteCacheAtomicProtocolTest.java | 2 +-
.../near/GridCacheNearMultiGetSelfTest.java | 2 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 2 +-
...achePartitionedTxSingleThreadedSelfTest.java | 2 +-
.../cache/query/IndexingSpiQuerySelfTest.java | 4 +-
.../service/GridServiceClientNodeTest.java | 7 +-
...ridSingleSplitsNewNodesAbstractLoadTest.java | 11 +-
...idSingleSplitsNewNodesMulticastLoadTest.java | 9 +-
.../p2p/GridP2PSameClassLoaderSelfTest.java | 2 +-
.../discovery/AbstractDiscoverySelfTest.java | 19 +-
...lientDiscoverySpiFailureTimeoutSelfTest.java | 245 +++++++++++++-
.../tcp/TcpClientDiscoverySpiSelfTest.java | 79 ++++-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 18 +-
.../tcp/TcpDiscoverySpiConfigSelfTest.java | 4 +-
.../TcpDiscoverySpiFailureTimeoutSelfTest.java | 51 +--
.../testframework/junits/GridAbstractTest.java | 10 +-
.../webapp/META-INF/ignite-webapp-config.xml | 1 -
.../Cache/CacheMetricsTest.cs | 3 +-
.../IgniteConfigurationSerializerTest.cs | 1 -
.../IgniteConfigurationTest.cs | 1 -
.../Discovery/Tcp/TcpDiscoverySpi.cs | 15 -
.../IgniteConfigurationSection.xsd | 5 -
.../Datagrid/MultiTieredCacheExample.cs | 2 +-
.../ignite/p2p/GridP2PDisabledSelfTest.java | 4 +-
.../webapp2/META-INF/ignite-webapp-config.xml | 1 -
74 files changed, 1135 insertions(+), 886 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java
index 2008eff..33f2cdd 100644
--- a/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java
+++ b/modules/aop/src/test/java/org/apache/ignite/gridify/AbstractAopTest.java
@@ -54,9 +54,9 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest {
cfg.setDeploymentSpi(new LocalDeploymentSpi());
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(500);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+ cfg.setMetricsUpdateFrequency(500);
cfg.setDeploymentMode(depMode);
return cfg;
@@ -738,4 +738,4 @@ public abstract class AbstractAopTest extends GridCommonAbstractTest {
return true;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java b/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java
index b53501b..44fa48d 100644
--- a/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java
+++ b/modules/aop/src/test/java/org/test/gridify/ExternalNonSpringAopSelfTest.java
@@ -524,9 +524,7 @@ public class ExternalNonSpringAopSelfTest extends GridCommonAbstractTest {
IgniteConfiguration cfg = super.getConfiguration();
cfg.setDeploymentSpi(new LocalDeploymentSpi());
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(500);
-
- cfg.setDeploymentMode(depMode);
+ cfg.setMetricsUpdateFrequency(500);
cfg.setDeploymentMode(depMode);
@@ -539,4 +537,4 @@ public class ExternalNonSpringAopSelfTest extends GridCommonAbstractTest {
@Override public String getTestIgniteInstanceName() {
return "ExternalAopTarget";
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/clients/src/test/resources/spring-cache.xml
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/resources/spring-cache.xml b/modules/clients/src/test/resources/spring-cache.xml
index 4dbae6e..8cbc688 100644
--- a/modules/clients/src/test/resources/spring-cache.xml
+++ b/modules/clients/src/test/resources/spring-cache.xml
@@ -148,7 +148,6 @@
<property name="bucketName" value="YOUR_BUCKET_NAME_IP_FINDER"/>
</bean>
</property>
- <property name="heartbeatFrequency" value="2000"/>
</bean>
</property>
-->
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
index 50c09be..7dd4707 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterMetrics.java
@@ -29,8 +29,8 @@ import org.apache.ignite.configuration.IgniteConfiguration;
* <p>
* Node metrics for any node can be accessed via {@link ClusterNode#metrics()}
* method. Keep in mind that there will be a certain network delay (usually
- * equal to heartbeat delay) for the accuracy of node metrics. However, when accessing
- * metrics on local node {@link IgniteCluster#localNode() Grid.localNode().getMetrics()}
+ * equal to metrics update delay) for the accuracy of node metrics. However, when accessing
+ * metrics on local node {@link IgniteCluster#localNode() IgniteCluster.localNode().getMetrics()}
* the metrics are always accurate and up to date.
* <p>
* Local node metrics are registered as {@code MBean} and can be accessed from
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
index bfc395d..e122ff6 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
@@ -87,9 +87,8 @@ import org.jetbrains.annotations.Nullable;
* <h1 class="header">Cluster Node Metrics</h1>
* Cluster node metrics (see {@link #metrics()}) are updated frequently for all nodes
* and can be used to get dynamic information about a node. The frequency of update
- * is often directly related to the heartbeat exchange between nodes. So if, for example,
- * default {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi} is used,
- * the metrics data will be updated every {@code 2} seconds by default.
+ * is controlled by {@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsUpdateFrequency()} parameter.
+ * The metrics data will be updated every {@code 2} seconds by default.
* <p>
* Grid node metrics provide information that can frequently change,
* such as Heap and Non-Heap memory utilization, CPU load, number of active and waiting
@@ -145,9 +144,9 @@ public interface ClusterNode {
* method and use it during {@link org.apache.ignite.compute.ComputeTask#map(List, Object)} or during collision
* resolution.
* <p>
- * Node metrics are updated with some delay which is directly related to heartbeat
- * frequency. For example, when used with default
- * {@link org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi} the update will happen every {@code 2} seconds.
+ * Node metrics are updated with some delay which is controlled by
+ * {@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsUpdateFrequency()} parameter.
+ * By default the update will happen every {@code 2} seconds.
*
* @return Runtime metrics snapshot for this node.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 17927b9..9f68399 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -200,6 +200,10 @@ public class IgniteConfiguration {
@SuppressWarnings("UnnecessaryBoxing")
public static final Long DFLT_FAILURE_DETECTION_TIMEOUT = new Long(10_000);
+ /** Default failure detection timeout for client nodes in millis. */
+ @SuppressWarnings("UnnecessaryBoxing")
+ public static final Long DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT = new Long(30_000);
+
/** Optional local Ignite instance name. */
private String igniteInstanceName;
@@ -386,6 +390,9 @@ public class IgniteConfiguration {
/** Failure detection timeout. */
private Long failureDetectionTimeout = DFLT_FAILURE_DETECTION_TIMEOUT;
+ /** Failure detection timeout for client nodes. */
+ private Long clientFailureDetectionTimeout = DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT;
+
/** Property names to include into node attributes. */
private String[] includeProps;
@@ -491,6 +498,7 @@ public class IgniteConfiguration {
cacheSanityCheckEnabled = cfg.isCacheSanityCheckEnabled();
callbackPoolSize = cfg.getAsyncCallbackPoolSize();
classLdr = cfg.getClassLoader();
+ clientFailureDetectionTimeout = cfg.getClientFailureDetectionTimeout();
clientMode = cfg.isClientMode();
connectorCfg = cfg.getConnectorConfiguration();
consistentId = cfg.getConsistentId();
@@ -1288,20 +1296,13 @@ public class IgniteConfiguration {
}
/**
- * Gets job metrics update frequency in milliseconds.
+ * Gets Ignite metrics update frequency in milliseconds.
* <p>
* Updating metrics too frequently may have negative performance impact.
* <p>
- * The following values are accepted:
- * <ul>
- * <li>{@code -1} job metrics are never updated.</li>
- * <li>{@code 0} job metrics are updated on each job start and finish.</li>
- * <li>Positive value defines the actual update frequency. If not provided, then default value
- * {@link #DFLT_METRICS_UPDATE_FREQ} is used.</li>
- * </ul>
* If not provided, then default value {@link #DFLT_METRICS_UPDATE_FREQ} is used.
*
- * @return Job metrics update frequency in milliseconds.
+ * @return Metrics update frequency in milliseconds.
* @see #DFLT_METRICS_UPDATE_FREQ
*/
public long getMetricsUpdateFrequency() {
@@ -1309,15 +1310,13 @@ public class IgniteConfiguration {
}
/**
- * Sets job metrics update frequency in milliseconds.
+ * Sets Ignite metrics update frequency in milliseconds.
* <p>
- * If set to {@code -1} job metrics are never updated.
- * If set to {@code 0} job metrics are updated on each job start and finish.
* Positive value defines the actual update frequency.
* If not provided, then default value
* {@link #DFLT_METRICS_UPDATE_FREQ} is used.
*
- * @param metricsUpdateFreq Job metrics update frequency in milliseconds.
+ * @param metricsUpdateFreq Metrics update frequency in milliseconds.
* @return {@code this} for chaining.
*/
public IgniteConfiguration setMetricsUpdateFrequency(long metricsUpdateFreq) {
@@ -1835,6 +1834,33 @@ public class IgniteConfiguration {
}
/**
+ * Returns failure detection timeout for client nodes used by {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi}.
+ * <p>
+ * Default is {@link #DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT}.
+ *
+ * @see #setClientFailureDetectionTimeout(long)
+ * @return Failure detection timeout for client nodes in milliseconds.
+ */
+ public Long getClientFailureDetectionTimeout() {
+ return clientFailureDetectionTimeout;
+ }
+
+ /**
+ * Sets failure detection timeout to use in {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi}.
+ * <p>
+ * Failure detection timeout is used to determine how long the communication or discovery SPIs should wait before
+ * considering a remote connection failed.
+ *
+ * @param clientFailureDetectionTimeout Failure detection timeout in milliseconds.
+ * @return {@code this} for chaining.
+ */
+ public IgniteConfiguration setClientFailureDetectionTimeout(long clientFailureDetectionTimeout) {
+ this.clientFailureDetectionTimeout = clientFailureDetectionTimeout;
+
+ return this;
+ }
+
+ /**
* Returns failure detection timeout used by {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi}.
* <p>
* Default is {@link #DFLT_FAILURE_DETECTION_TIMEOUT}.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/events/EventType.java b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
index e506371..1960692 100644
--- a/modules/core/src/main/java/org/apache/ignite/events/EventType.java
+++ b/modules/core/src/main/java/org/apache/ignite/events/EventType.java
@@ -136,7 +136,7 @@ public interface EventType {
* Built-in event type: node metrics updated.
* <br>
* Generated when node's metrics are updated. In most cases this callback
- * is invoked with every heartbeat received from a node (including local node).
+ * is invoked with every metrics update received from a node (including local node).
* <p>
* NOTE: all types in range <b>from 1 to 1000 are reserved</b> for
* internal Ignite events and should not be used by user-defined events.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 369ca22..e0bc4d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -855,8 +855,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
}
});
- if (metricsUpdateFreq > -1L)
- updateJobMetrics();
+ updateJobMetrics();
}
finally {
handlingCollision.set(Boolean.FALSE);
@@ -867,24 +866,21 @@ public class GridJobProcessor extends GridProcessorAdapter {
*
*/
private void updateJobMetrics() {
- assert metricsUpdateFreq > -1L;
+ assert metricsUpdateFreq > 0L;
- if (metricsUpdateFreq == 0L)
+ long now = U.currentTimeMillis();
+ long lastUpdate = metricsLastUpdateTstamp.get();
+
+ if (now - lastUpdate > metricsUpdateFreq && metricsLastUpdateTstamp.compareAndSet(lastUpdate, now))
updateJobMetrics0();
- else {
- long now = U.currentTimeMillis();
- long lastUpdate = metricsLastUpdateTstamp.get();
- if (now - lastUpdate > metricsUpdateFreq && metricsLastUpdateTstamp.compareAndSet(lastUpdate, now))
- updateJobMetrics0();
- }
}
/**
*
*/
private void updateJobMetrics0() {
- assert metricsUpdateFreq > -1L;
+ assert metricsUpdateFreq > 0L;
GridJobMetricsSnapshot m = new GridJobMetricsSnapshot();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 4186eb9..eb3e716 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -531,7 +531,8 @@ public class PlatformConfigurationUtils {
if (in.readBoolean())
cfg.setClientMode(in.readBoolean());
int[] eventTypes = in.readIntArray();
- if (eventTypes != null) cfg.setIncludeEventTypes(eventTypes);
+ if (eventTypes != null)
+ cfg.setIncludeEventTypes(eventTypes);
if (in.readBoolean())
cfg.setMetricsExpireTime(in.readLong());
if (in.readBoolean())
@@ -556,8 +557,10 @@ public class PlatformConfigurationUtils {
cfg.setDaemon(in.readBoolean());
if (in.readBoolean())
cfg.setLateAffinityAssignment(in.readBoolean());
- if (in.readBoolean())
+ if (in.readBoolean()) {
+ cfg.setClientFailureDetectionTimeout(in.readLong());
cfg.setFailureDetectionTimeout(in.readLong());
+ }
readCacheConfigurations(in, cfg);
readDiscoveryConfiguration(in, cfg);
@@ -752,12 +755,9 @@ public class PlatformConfigurationUtils {
disco.setReconnectCount(in.readInt());
disco.setLocalPort(in.readInt());
disco.setLocalPortRange(in.readInt());
- disco.setMaxMissedHeartbeats(in.readInt());
- disco.setMaxMissedClientHeartbeats(in.readInt());
disco.setStatisticsPrintFrequency(in.readLong());
disco.setIpFinderCleanFrequency(in.readLong());
disco.setThreadPriority(in.readInt());
- disco.setHeartbeatFrequency(in.readLong());
disco.setTopHistorySize(in.readInt());
cfg.setDiscoverySpi(disco);
@@ -960,7 +960,8 @@ public class PlatformConfigurationUtils {
w.writeLong(cfg.getMetricsUpdateFrequency());
w.writeBoolean(true);
w.writeInt(cfg.getNetworkSendRetryCount());
- w.writeBoolean(true);w.writeLong(cfg.getNetworkSendRetryDelay());
+ w.writeBoolean(true);
+ w.writeLong(cfg.getNetworkSendRetryDelay());
w.writeBoolean(true);
w.writeLong(cfg.getNetworkTimeout());
w.writeString(cfg.getWorkDirectory());
@@ -970,6 +971,7 @@ public class PlatformConfigurationUtils {
w.writeBoolean(true);
w.writeBoolean(cfg.isLateAffinityAssignment());
w.writeBoolean(true);
+ w.writeLong(cfg.getClientFailureDetectionTimeout());
w.writeLong(cfg.getFailureDetectionTimeout());
CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
@@ -1063,17 +1065,17 @@ public class PlatformConfigurationUtils {
else
w.writeBoolean(false);
- EventStorageSpi eventStorageSpi = cfg.getEventStorageSpi();
+ EventStorageSpi evtStorageSpi = cfg.getEventStorageSpi();
- if (eventStorageSpi == null) {
+ if (evtStorageSpi == null)
w.writeByte((byte) 0);
- } else if (eventStorageSpi instanceof NoopEventStorageSpi) {
+ else if (evtStorageSpi instanceof NoopEventStorageSpi)
w.writeByte((byte) 1);
- } else if (eventStorageSpi instanceof MemoryEventStorageSpi) {
+ else if (evtStorageSpi instanceof MemoryEventStorageSpi) {
w.writeByte((byte) 2);
- w.writeLong(((MemoryEventStorageSpi)eventStorageSpi).getExpireCount());
- w.writeLong(((MemoryEventStorageSpi)eventStorageSpi).getExpireAgeMs());
+ w.writeLong(((MemoryEventStorageSpi)evtStorageSpi).getExpireCount());
+ w.writeLong(((MemoryEventStorageSpi)evtStorageSpi).getExpireAgeMs());
}
writeMemoryConfiguration(w, cfg.getMemoryConfiguration());
@@ -1135,9 +1137,8 @@ public class PlatformConfigurationUtils {
w.writeInt(ttl);
}
}
- else {
+ else
w.writeBoolean(false);
- }
w.writeLong(tcp.getSocketTimeout());
w.writeLong(tcp.getAckTimeout());
@@ -1151,12 +1152,9 @@ public class PlatformConfigurationUtils {
w.writeInt(tcp.getReconnectCount());
w.writeInt(tcp.getLocalPort());
w.writeInt(tcp.getLocalPortRange());
- w.writeInt(tcp.getMaxMissedHeartbeats());
- w.writeInt(tcp.getMaxMissedClientHeartbeats());
w.writeLong(tcp.getStatisticsPrintFrequency());
w.writeLong(tcp.getIpFinderCleanFrequency());
w.writeInt(tcp.getThreadPriority());
- w.writeLong(tcp.getHeartbeatFrequency());
w.writeInt((int)tcp.getTopHistorySize());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
index ec56f4f..81f5c28 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
@@ -95,6 +95,12 @@ public abstract class IgniteSpiAdapter implements IgniteSpi {
private boolean failureDetectionTimeoutEnabled = true;
/**
+ * Failure detection timeout for client nodes. Initialized with the value of
+ * {@link IgniteConfiguration#getClientFailureDetectionTimeout()}.
+ */
+ private long clientFailureDetectionTimeout;
+
+ /**
* Failure detection timeout. Initialized with the value of
* {@link IgniteConfiguration#getFailureDetectionTimeout()}.
*/
@@ -648,12 +654,29 @@ public abstract class IgniteSpiAdapter implements IgniteSpi {
// Because U.currentTimeInMillis() is updated once in 10 milliseconds.
log.warning("Failure detection timeout is too low, it may lead to unpredictable behaviour " +
"[failureDetectionTimeout=" + failureDetectionTimeout + ']');
+ else if (failureDetectionTimeout <= ignite.configuration().getMetricsUpdateFrequency())
+ log.warning("'IgniteConfiguration.failureDetectionTimeout' should be greater then " +
+ "'IgniteConfiguration.metricsUpdateFrequency' to prevent unnecessary status checking.");
}
// Intentionally compare references using '!=' below
else if (ignite.configuration().getFailureDetectionTimeout() !=
IgniteConfiguration.DFLT_FAILURE_DETECTION_TIMEOUT)
log.warning("Failure detection timeout will be ignored (one of SPI parameters has been set explicitly)");
+ clientFailureDetectionTimeout = ignite.configuration().getClientFailureDetectionTimeout();
+
+ if (clientFailureDetectionTimeout <= 0)
+ throw new IgniteSpiException("Invalid client failure detection timeout value: " +
+ clientFailureDetectionTimeout);
+ else if (clientFailureDetectionTimeout <= 10)
+ // Because U.currentTimeInMillis() is updated once in 10 milliseconds.
+ log.warning("Client failure detection timeout is too low, it may lead to unpredictable behaviour " +
+ "[clientFailureDetectionTimeout=" + clientFailureDetectionTimeout + ']');
+
+ if (clientFailureDetectionTimeout < ignite.configuration().getMetricsUpdateFrequency())
+ throw new IgniteSpiException("Inconsistent configuration " +
+ "('IgniteConfiguration.clientFailureDetectionTimeout' must be greater or equal to " +
+ "'IgniteConfiguration.metricsUpdateFrequency').");
}
/**
@@ -675,6 +698,15 @@ public abstract class IgniteSpiAdapter implements IgniteSpi {
}
/**
+ * Returns client failure detection timeout set to use for network related operations.
+ *
+ * @return client failure detection timeout in milliseconds or {@code 0} if the timeout is disabled.
+ */
+ public long clientFailureDetectionTimeout() {
+ return clientFailureDetectionTimeout;
+ }
+
+ /**
* Returns failure detection timeout set to use for network related operations.
*
* @return failure detection timeout in milliseconds or {@code 0} if the timeout is disabled.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
index e17b0dd..c685ea9 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
@@ -45,10 +45,12 @@ public class IgniteSpiOperationTimeoutHelper {
* Constructor.
*
* @param adapter SPI adapter.
+ * @param srvOp {@code True} if communicates with server node.
*/
- public IgniteSpiOperationTimeoutHelper(IgniteSpiAdapter adapter) {
+ public IgniteSpiOperationTimeoutHelper(IgniteSpiAdapter adapter, boolean srvOp) {
failureDetectionTimeoutEnabled = adapter.failureDetectionTimeoutEnabled();
- failureDetectionTimeout = adapter.failureDetectionTimeout();
+ failureDetectionTimeout = srvOp ? adapter.failureDetectionTimeout() :
+ adapter.clientFailureDetectionTimeout();
}
/**
@@ -99,4 +101,4 @@ public class IgniteSpiOperationTimeoutHelper {
return e instanceof IgniteSpiOperationTimeoutException || e instanceof SocketTimeoutException ||
X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketException.class);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingCollisionSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingCollisionSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingCollisionSpi.java
index 8a02225..6f2c099 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingCollisionSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/collision/jobstealing/JobStealingCollisionSpi.java
@@ -88,7 +88,7 @@ import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
* {@link org.apache.ignite.spi.failover.jobstealing.JobStealingFailoverSpi JobStealingFailoverSpi}.
* Also note that job metrics update should be enabled in order for this SPI
* to work properly (i.e. {@link org.apache.ignite.configuration.IgniteConfiguration#getMetricsUpdateFrequency() IgniteConfiguration#getMetricsUpdateFrequency()}
- * should be set to {@code 0} or greater value).
+ * should be set to positive value).
* The responsibility of Job Stealing Failover SPI is to properly route <b>stolen</b>
* jobs to the nodes that initially requested (<b>stole</b>) these jobs. The
* SPI maintains a counter of how many times a jobs was stolen and
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 1fedf83..be897d6 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -2727,7 +2727,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
long connTimeout0 = connTimeout;
- IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(this);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(this,
+ !node.isClient());
while (true) {
GridCommunicationClient client;
@@ -2918,7 +2919,8 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
int attempt = 1;
- IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(this);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(this,
+ !node.isClient());
while (!conn) { // Reconnection on handshake timeout.
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 34ee414..b5b4c77 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -81,7 +81,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientAckResponse;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientHeartbeatMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientMetricsUpdateMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingRequest;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingResponse;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientReconnectMessage;
@@ -89,7 +89,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessa
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeRequest;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeResponse;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage;
@@ -272,9 +272,9 @@ class ClientImpl extends TcpDiscoveryImpl {
}
timer.schedule(
- new HeartbeatSender(),
- spi.hbFreq,
- spi.hbFreq);
+ new MetricsSender(),
+ spi.metricsUpdateFreq,
+ spi.metricsUpdateFreq);
spi.printStartInfo();
}
@@ -597,7 +597,7 @@ class ClientImpl extends TcpDiscoveryImpl {
UUID locNodeId = getLocalNodeId();
- IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
while (true) {
boolean openSock = false;
@@ -861,13 +861,14 @@ class ClientImpl extends TcpDiscoveryImpl {
}
/**
- * Heartbeat sender.
+ * Metrics sender.
*/
- private class HeartbeatSender extends TimerTask {
+ private class MetricsSender extends TimerTask {
/** {@inheritDoc} */
@Override public void run() {
if (!spi.getSpiContext().isStopping() && sockWriter.isOnline()) {
- TcpDiscoveryClientHeartbeatMessage msg = new TcpDiscoveryClientHeartbeatMessage(getLocalNodeId(),
+ TcpDiscoveryClientMetricsUpdateMessage msg = new TcpDiscoveryClientMetricsUpdateMessage(
+ getLocalNodeId(),
spi.metricsProvider.metrics());
msg.client(true);
@@ -1829,8 +1830,8 @@ class ClientImpl extends TcpDiscoveryImpl {
processNodeLeftMessage((TcpDiscoveryNodeLeftMessage)msg);
else if (msg instanceof TcpDiscoveryNodeFailedMessage)
processNodeFailedMessage((TcpDiscoveryNodeFailedMessage)msg);
- else if (msg instanceof TcpDiscoveryHeartbeatMessage)
- processHeartbeatMessage((TcpDiscoveryHeartbeatMessage)msg);
+ else if (msg instanceof TcpDiscoveryMetricsUpdateMessage)
+ processMetricsUpdateMessage((TcpDiscoveryMetricsUpdateMessage)msg);
else if (msg instanceof TcpDiscoveryClientReconnectMessage)
processClientReconnectMessage((TcpDiscoveryClientReconnectMessage)msg);
else if (msg instanceof TcpDiscoveryCustomEventMessage)
@@ -2152,7 +2153,7 @@ class ClientImpl extends TcpDiscoveryImpl {
/**
* @param msg Message.
*/
- private void processHeartbeatMessage(TcpDiscoveryHeartbeatMessage msg) {
+ private void processMetricsUpdateMessage(TcpDiscoveryMetricsUpdateMessage msg) {
if (spi.getSpiContext().isStopping())
return;
@@ -2160,16 +2161,16 @@ class ClientImpl extends TcpDiscoveryImpl {
assert msg.senderNodeId() != null;
if (log.isDebugEnabled())
- log.debug("Received heartbeat response: " + msg);
+ log.debug("Received metrics response: " + msg);
}
else {
long tstamp = U.currentTimeMillis();
if (msg.hasMetrics()) {
- for (Map.Entry<UUID, TcpDiscoveryHeartbeatMessage.MetricsSet> e : msg.metrics().entrySet()) {
+ for (Map.Entry<UUID, TcpDiscoveryMetricsUpdateMessage.MetricsSet> e : msg.metrics().entrySet()) {
UUID nodeId = e.getKey();
- TcpDiscoveryHeartbeatMessage.MetricsSet metricsSet = e.getValue();
+ TcpDiscoveryMetricsUpdateMessage.MetricsSet metricsSet = e.getValue();
Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics(nodeId) ?
msg.cacheMetrics().get(nodeId) : Collections.<Integer, CacheMetrics>emptyMap();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 47c13e1..6a10ec2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -106,7 +106,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientAckResponse;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientHeartbeatMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientMetricsUpdateMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingRequest;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingResponse;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientReconnectMessage;
@@ -116,7 +116,7 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDiscardMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeRequest;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeResponse;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryLoopbackProblemMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage;
@@ -612,7 +612,8 @@ class ServerImpl extends TcpDiscoveryImpl {
UUID locNodeId = getLocalNodeId();
- IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi,
+ clientNodeId == null);
if (F.contains(spi.locNodeAddrs, addr)) {
if (clientNodeId == null)
@@ -991,7 +992,9 @@ class ServerImpl extends TcpDiscoveryImpl {
for (InetSocketAddress addr : addrs) {
try {
- Integer res = sendMessageDirectly(joinReq, addr);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
+
+ Integer res = sendMessageDirectly(joinReq, addr, timeoutHelper);
assert res != null;
@@ -1104,10 +1107,12 @@ class ServerImpl extends TcpDiscoveryImpl {
*
* @param msg Message to send.
* @param addr Address to send message to.
+ * @param timeoutHelper Operation timeout helper.
* @return Response read from the recipient or {@code null} if no response is supposed.
* @throws IgniteSpiException If an error occurs.
*/
- @Nullable private Integer sendMessageDirectly(TcpDiscoveryAbstractMessage msg, InetSocketAddress addr)
+ @Nullable private Integer sendMessageDirectly(TcpDiscoveryAbstractMessage msg, InetSocketAddress addr,
+ IgniteSpiOperationTimeoutHelper timeoutHelper)
throws IgniteSpiException {
assert msg != null;
assert addr != null;
@@ -1124,8 +1129,6 @@ class ServerImpl extends TcpDiscoveryImpl {
UUID locNodeId = getLocalNodeId();
- IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
-
int reconCnt = 0;
while (true){
@@ -1731,7 +1734,7 @@ class ServerImpl extends TcpDiscoveryImpl {
* @return {@code True} if recordable in debug mode.
*/
private boolean recordable(TcpDiscoveryAbstractMessage msg) {
- return !(msg instanceof TcpDiscoveryHeartbeatMessage) &&
+ return !(msg instanceof TcpDiscoveryMetricsUpdateMessage) &&
!(msg instanceof TcpDiscoveryStatusCheckMessage) &&
!(msg instanceof TcpDiscoveryDiscardMessage) &&
!(msg instanceof TcpDiscoveryConnectionCheckMessage);
@@ -1759,7 +1762,7 @@ class ServerImpl extends TcpDiscoveryImpl {
* @param msg Message.
* @param nodeId Node ID.
*/
- private static void removeMetrics(TcpDiscoveryHeartbeatMessage msg, UUID nodeId) {
+ private static void removeMetrics(TcpDiscoveryMetricsUpdateMessage msg, UUID nodeId) {
msg.removeMetrics(nodeId);
msg.removeCacheMetrics(nodeId);
}
@@ -2384,11 +2387,11 @@ class ServerImpl extends TcpDiscoveryImpl {
/** Last time status message has been sent. */
private long lastTimeStatusMsgSent;
- /** Incoming heartbeats check frequency. */
- private long hbCheckFreq = (long)spi.maxMissedHbs * spi.hbFreq + 50;
+ /** Incoming metrics check frequency. */
+ private long metricsCheckFreq = 3 * spi.metricsUpdateFreq + 50;
- /** Last time heartbeat message has been sent. */
- private long lastTimeHbMsgSent;
+ /** Last time metrics update message has been sent. */
+ private long lastTimeMetricsUpdateMsgSent;
/** Time when the last status message has been sent. */
private long lastTimeConnCheckMsgSent;
@@ -2483,7 +2486,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (spi.failureDetectionTimeoutEnabled())
connCheckThreshold = spi.failureDetectionTimeout();
else
- connCheckThreshold = Math.min(spi.getSocketTimeout(), spi.getHeartbeatFrequency());
+ connCheckThreshold = Math.min(spi.getSocketTimeout(), spi.metricsUpdateFreq);
for (int i = 3; i > 0; i--) {
connCheckFreq = connCheckThreshold / i;
@@ -2502,7 +2505,7 @@ class ServerImpl extends TcpDiscoveryImpl {
* @param msg Message to process.
*/
@Override protected void processMessage(TcpDiscoveryAbstractMessage msg) {
- sendHeartbeatMessage();
+ sendMetricsUpdateMessage();
DebugLogger log = messageLogger(msg);
@@ -2555,8 +2558,8 @@ class ServerImpl extends TcpDiscoveryImpl {
else if (msg instanceof TcpDiscoveryNodeFailedMessage)
processNodeFailedMessage((TcpDiscoveryNodeFailedMessage)msg);
- else if (msg instanceof TcpDiscoveryHeartbeatMessage)
- processHeartbeatMessage((TcpDiscoveryHeartbeatMessage)msg);
+ else if (msg instanceof TcpDiscoveryMetricsUpdateMessage)
+ processMetricsUpdateMessage((TcpDiscoveryMetricsUpdateMessage)msg);
else if (msg instanceof TcpDiscoveryStatusCheckMessage)
processStatusCheckMessage((TcpDiscoveryStatusCheckMessage)msg);
@@ -2594,9 +2597,9 @@ class ServerImpl extends TcpDiscoveryImpl {
checkConnection();
- sendHeartbeatMessage();
+ sendMetricsUpdateMessage();
- checkHeartbeatsReceiving();
+ checkMetricsReceiving();
checkPendingCustomMessages();
@@ -2750,7 +2753,7 @@ class ServerImpl extends TcpDiscoveryImpl {
while (true) {
if (sock == null) {
if (timeoutHelper == null)
- timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
+ timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
nextNodeExists = false;
@@ -2918,7 +2921,7 @@ class ServerImpl extends TcpDiscoveryImpl {
pendingMsgs.discardId, pendingMsgs.customDiscardId);
if (timeoutHelper == null)
- timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
+ timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
try {
spi.writeToSocket(sock, out, pendingMsg, timeoutHelper.nextTimeoutChunk(
@@ -2958,7 +2961,7 @@ class ServerImpl extends TcpDiscoveryImpl {
long tstamp = U.currentTimeMillis();
if (timeoutHelper == null)
- timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi);
+ timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
if (!failedNodes.isEmpty()) {
for (TcpDiscoveryNode failedNode : failedNodes) {
@@ -3817,7 +3820,9 @@ class ServerImpl extends TcpDiscoveryImpl {
for (InetSocketAddress addr : spi.getNodeAddresses(node, U.sameMacs(locNode, node))) {
try {
- sendMessageDirectly(msg, addr);
+ IgniteSpiOperationTimeoutHelper timeoutHelper = new IgniteSpiOperationTimeoutHelper(spi, true);
+
+ sendMessageDirectly(msg, addr, timeoutHelper);
node.lastSuccessfulAddress(addr);
@@ -3853,7 +3858,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (node != null) {
node.clientRouterNodeId(msg.routerNodeId());
- node.aliveCheck(spi.maxMissedClientHbs);
+ node.clientAliveTime(spi.clientFailureDetectionTimeout());
}
if (isLocalNodeCoordinator()) {
@@ -4083,7 +4088,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
if (msg.client())
- node.aliveCheck(spi.maxMissedClientHbs);
+ node.clientAliveTime(spi.clientFailureDetectionTimeout());
boolean topChanged = ring.add(node);
@@ -4830,7 +4835,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
if (locNodeId.equals(msg.creatorNodeId()) && msg.senderNodeId() == null &&
- U.currentTimeMillis() - locNode.lastUpdateTime() < spi.hbFreq) {
+ U.currentTimeMillis() - locNode.lastUpdateTime() < spi.metricsUpdateFreq) {
if (log.isDebugEnabled())
log.debug("Status check message discarded (local node receives updates).");
@@ -4873,11 +4878,11 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
- * Processes regular heartbeat message.
+ * Processes regular metrics update message.
*
- * @param msg Heartbeat message.
+ * @param msg Metrics update message.
*/
- private void processHeartbeatMessage(TcpDiscoveryHeartbeatMessage msg) {
+ private void processMetricsUpdateMessage(TcpDiscoveryMetricsUpdateMessage msg) {
assert msg != null;
assert !msg.client();
@@ -4886,7 +4891,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (ring.node(msg.creatorNodeId()) == null) {
if (log.isDebugEnabled())
- log.debug("Discarding heartbeat message issued by unknown node [msg=" + msg +
+ log.debug("Discarding metrics update message issued by unknown node [msg=" + msg +
", ring=" + ring + ']');
return;
@@ -4894,14 +4899,14 @@ class ServerImpl extends TcpDiscoveryImpl {
if (isLocalNodeCoordinator() && !locNodeId.equals(msg.creatorNodeId())) {
if (log.isDebugEnabled())
- log.debug("Discarding heartbeat message issued by non-coordinator node: " + msg);
+ log.debug("Discarding metrics update message issued by non-coordinator node: " + msg);
return;
}
if (!isLocalNodeCoordinator() && locNodeId.equals(msg.creatorNodeId())) {
if (log.isDebugEnabled())
- log.debug("Discarding heartbeat message issued by local node (node is no more coordinator): " +
+ log.debug("Discarding metrics update message issued by local node (node is no more coordinator): " +
msg);
return;
@@ -4909,7 +4914,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (locNodeId.equals(msg.creatorNodeId()) && !hasMetrics(msg, locNodeId) && msg.senderNodeId() != null) {
if (log.isTraceEnabled())
- log.trace("Discarding heartbeat message that has made two passes: " + msg);
+ log.trace("Discarding metrics update message that has made two passes: " + msg);
return;
}
@@ -4918,10 +4923,10 @@ class ServerImpl extends TcpDiscoveryImpl {
if (spiStateCopy() == CONNECTED) {
if (msg.hasMetrics()) {
- for (Map.Entry<UUID, TcpDiscoveryHeartbeatMessage.MetricsSet> e : msg.metrics().entrySet()) {
+ for (Map.Entry<UUID, TcpDiscoveryMetricsUpdateMessage.MetricsSet> e : msg.metrics().entrySet()) {
UUID nodeId = e.getKey();
- TcpDiscoveryHeartbeatMessage.MetricsSet metricsSet = e.getValue();
+ TcpDiscoveryMetricsUpdateMessage.MetricsSet metricsSet = e.getValue();
Map<Integer, CacheMetrics> cacheMetrics = msg.hasCacheMetrics(nodeId) ?
msg.cacheMetrics().get(nodeId) : Collections.<Integer, CacheMetrics>emptyMap();
@@ -4960,11 +4965,11 @@ class ServerImpl extends TcpDiscoveryImpl {
for (TcpDiscoveryNode clientNode : ring.clientNodes()) {
if (clientNode.visible()) {
if (clientNodeIds.contains(clientNode.id()))
- clientNode.aliveCheck(spi.maxMissedClientHbs);
+ clientNode.clientAliveTime(spi.clientFailureDetectionTimeout());
else {
- int aliveCheck = clientNode.decrementAliveCheck();
+ boolean aliveCheck = clientNode.isClientAlive();
- if (aliveCheck <= 0 && isLocalNodeCoordinator()) {
+ if (!aliveCheck && isLocalNodeCoordinator()) {
boolean failedNode;
synchronized (mux) {
@@ -4972,6 +4977,12 @@ class ServerImpl extends TcpDiscoveryImpl {
}
if (!failedNode) {
+ U.warn(log, "Failing client node due to not receiving metrics updates " +
+ "from client node within " +
+ "'IgniteConfiguration.clientFailureDetectionTimeout' " +
+ "(consider increasing configuration property) " +
+ "[timeout=" + spi.clientFailureDetectionTimeout() + ", node=" + clientNode + ']');
+
TcpDiscoveryNodeFailedMessage nodeFailedMsg = new TcpDiscoveryNodeFailedMessage(
locNodeId, clientNode.id(), clientNode.internalOrder());
@@ -5027,7 +5038,7 @@ class ServerImpl extends TcpDiscoveryImpl {
/**
* @param msg Message.
*/
- private boolean hasMetrics(TcpDiscoveryHeartbeatMessage msg, UUID nodeId) {
+ private boolean hasMetrics(TcpDiscoveryMetricsUpdateMessage msg, UUID nodeId) {
return msg.hasMetrics(nodeId) || msg.hasCacheMetrics(nodeId);
}
@@ -5338,34 +5349,34 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
- * Sends heartbeat message if needed.
+ * Sends metrics update message if needed.
*/
- private void sendHeartbeatMessage() {
- long elapsed = (lastTimeHbMsgSent + spi.hbFreq) - U.currentTimeMillis();
+ private void sendMetricsUpdateMessage() {
+ long elapsed = (lastTimeMetricsUpdateMsgSent + spi.metricsUpdateFreq) - U.currentTimeMillis();
if (elapsed > 0 || !isLocalNodeCoordinator())
return;
- TcpDiscoveryHeartbeatMessage msg = new TcpDiscoveryHeartbeatMessage(getConfiguredNodeId());
+ TcpDiscoveryMetricsUpdateMessage msg = new TcpDiscoveryMetricsUpdateMessage(getConfiguredNodeId());
msg.verify(getLocalNodeId());
msgWorker.addMessage(msg);
- lastTimeHbMsgSent = U.currentTimeMillis();
+ lastTimeMetricsUpdateMsgSent = U.currentTimeMillis();
}
/**
- * Check the last time a heartbeat message received. If the time is bigger than {@code hbCheckTimeout} than
- * {@link TcpDiscoveryStatusCheckMessage} is sent across the ring.
+ * Checks the last time a metrics update message received. If the time is bigger than {@code metricsCheckFreq}
+ * than {@link TcpDiscoveryStatusCheckMessage} is sent across the ring.
*/
- private void checkHeartbeatsReceiving() {
+ private void checkMetricsReceiving() {
if (lastTimeStatusMsgSent < locNode.lastUpdateTime())
lastTimeStatusMsgSent = locNode.lastUpdateTime();
long updateTime = Math.max(lastTimeStatusMsgSent, lastRingMsgTime);
- long elapsed = (updateTime + hbCheckFreq) - U.currentTimeMillis();
+ long elapsed = (updateTime + metricsCheckFreq) - U.currentTimeMillis();
if (elapsed > 0)
return;
@@ -5548,6 +5559,8 @@ class ServerImpl extends TcpDiscoveryImpl {
ClientMessageWorker clientMsgWrk = null;
+ boolean srvSock;
+
try {
InputStream in;
@@ -5618,7 +5631,7 @@ class ServerImpl extends TcpDiscoveryImpl {
TcpDiscoveryPingResponse res = new TcpDiscoveryPingResponse(locNodeId);
IgniteSpiOperationTimeoutHelper timeoutHelper =
- new IgniteSpiOperationTimeoutHelper(spi);
+ new IgniteSpiOperationTimeoutHelper(spi, true);
if (req.clientNodeId() != null) {
ClientMessageWorker clientWorker = clientMsgWorkers.get(req.clientNodeId());
@@ -5638,6 +5651,8 @@ class ServerImpl extends TcpDiscoveryImpl {
// Handshake.
TcpDiscoveryHandshakeRequest req = (TcpDiscoveryHandshakeRequest)msg;
+ srvSock = !req.client();
+
UUID nodeId = req.creatorNodeId();
this.nodeId = nodeId;
@@ -5648,8 +5663,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (req.client())
res.clientAck(true);
- spi.writeToSocket(sock, res, spi.failureDetectionTimeoutEnabled() ?
- spi.failureDetectionTimeout() : spi.getSocketTimeout());
+ spi.writeToSocket(sock, res, spi.getEffectiveSocketTimeout(srvSock));
// It can happen if a remote node is stopped and it has a loopback address in the list of addresses,
// the local node sends a handshake request message on the loopback address, so we get here.
@@ -5764,8 +5778,7 @@ class ServerImpl extends TcpDiscoveryImpl {
return;
}
- long sockTimeout = spi.failureDetectionTimeoutEnabled() ? spi.failureDetectionTimeout() :
- spi.getSocketTimeout();
+ long sockTimeout = spi.getEffectiveSocketTimeout(srvSock);
while (!isInterrupted()) {
try {
@@ -5950,10 +5963,10 @@ class ServerImpl extends TcpDiscoveryImpl {
continue;
}
- TcpDiscoveryClientHeartbeatMessage heartbeatMsg = null;
+ TcpDiscoveryClientMetricsUpdateMessage metricsUpdateMsg = null;
- if (msg instanceof TcpDiscoveryClientHeartbeatMessage)
- heartbeatMsg = (TcpDiscoveryClientHeartbeatMessage)msg;
+ if (msg instanceof TcpDiscoveryClientMetricsUpdateMessage)
+ metricsUpdateMsg = (TcpDiscoveryClientMetricsUpdateMessage)msg;
else
msgWorker.addMessage(msg);
@@ -5968,8 +5981,8 @@ class ServerImpl extends TcpDiscoveryImpl {
else
spi.writeToSocket(msg, sock, RES_OK, sockTimeout);
- if (heartbeatMsg != null)
- processClientHeartbeatMessage(heartbeatMsg);
+ if (metricsUpdateMsg != null)
+ processClientMetricsUpdateMessage(metricsUpdateMsg);
}
catch (IgniteCheckedException e) {
if (log.isDebugEnabled())
@@ -6037,11 +6050,11 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
- * Processes client heartbeat message.
+ * Processes client metrics update message.
*
- * @param msg Heartbeat message.
+ * @param msg Client metrics update message.
*/
- private void processClientHeartbeatMessage(TcpDiscoveryClientHeartbeatMessage msg) {
+ private void processClientMetricsUpdateMessage(TcpDiscoveryClientMetricsUpdateMessage msg) {
assert msg.client();
ClientMessageWorker wrk = clientMsgWorkers.get(msg.creatorNodeId());
@@ -6049,7 +6062,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (wrk != null)
wrk.metrics(msg.metrics());
else if (log.isDebugEnabled())
- log.debug("Received heartbeat message from unknown client node: " + msg);
+ log.debug("Received client metrics update message from unknown client node: " + msg);
}
/**
@@ -6286,7 +6299,7 @@ class ServerImpl extends TcpDiscoveryImpl {
+ getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
spi.writeToSocket(sock, msg, msgBytes, spi.failureDetectionTimeoutEnabled() ?
- spi.failureDetectionTimeout() : spi.getSocketTimeout());
+ spi.clientFailureDetectionTimeout() : spi.getSocketTimeout());
}
}
else {
@@ -6296,8 +6309,7 @@ class ServerImpl extends TcpDiscoveryImpl {
assert topologyInitialized(msg) : msg;
- spi.writeToSocket(sock, msg, msgBytes, spi.failureDetectionTimeoutEnabled() ?
- spi.failureDetectionTimeout() : spi.getSocketTimeout());
+ spi.writeToSocket(sock, msg, msgBytes, spi.getEffectiveSocketTimeout(false));
}
boolean clientFailed = msg instanceof TcpDiscoveryNodeFailedMessage &&
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 25804c7..46d6f06 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -138,7 +138,6 @@ import static org.apache.ignite.IgniteSystemProperties.getBoolean;
* configuration parameters may be used. As an example, for stable low-latency networks the following more aggressive
* settings are recommended (which allows failure detection time ~200ms):
* <ul>
- * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)}) - 100ms</li>
* <li>Socket timeout (see {@link #setSocketTimeout(long)}) - 200ms</li>
* <li>Message acknowledgement timeout (see {@link #setAckTimeout(long)}) - 50ms</li>
* </ul>
@@ -166,8 +165,6 @@ import static org.apache.ignite.IgniteSystemProperties.getBoolean;
* <li>Local port to bind to (see {@link #setLocalPort(int)})</li>
* <li>Local port range to try binding to if previous ports are in use
* (see {@link #setLocalPortRange(int)})</li>
- * <li>Heartbeat frequency (see {@link #setHeartbeatFrequency(long)})</li>
- * <li>Max missed heartbeats (see {@link #setMaxMissedHeartbeats(int)})</li>
* <li>Number of times node tries to (re)establish connection to another node
* (see {@link #setReconnectCount(int)})</li>
* <li>Network timeout (see {@link #setNetworkTimeout(long)})</li>
@@ -241,8 +238,11 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
/** Default value for thread priority (value is <tt>10</tt>). */
public static final int DFLT_THREAD_PRI = 10;
- /** Default heartbeat messages issuing frequency (value is <tt>2000ms</tt>). */
- public static final long DFLT_HEARTBEAT_FREQ = 2000;
+ /**
+ * Default metrics update messages issuing frequency
+ * (value is {@link IgniteConfiguration#DFLT_METRICS_UPDATE_FREQ}).
+ */
+ public static final long DFLT_METRICS_UPDATE_FREQ = IgniteConfiguration.DFLT_METRICS_UPDATE_FREQ;
/** Default size of topology snapshots history. */
public static final int DFLT_TOP_HISTORY_SIZE = 1000;
@@ -262,12 +262,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
/** Default reconnect attempts count (value is <tt>10</tt>). */
public static final int DFLT_RECONNECT_CNT = 10;
- /** Default max heartbeats count node can miss without initiating status check (value is <tt>1</tt>). */
- public static final int DFLT_MAX_MISSED_HEARTBEATS = 1;
-
- /** Default max heartbeats count node can miss without failing client node (value is <tt>5</tt>). */
- public static final int DFLT_MAX_MISSED_CLIENT_HEARTBEATS = 5;
-
/** Default IP finder clean frequency in milliseconds (value is <tt>60,000ms</tt>). */
public static final long DFLT_IP_FINDER_CLEAN_FREQ = 60 * 1000;
@@ -302,8 +296,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
/** Thread priority for all threads started by SPI. */
protected int threadPri = DFLT_THREAD_PRI;
- /** Heartbeat messages issuing frequency. */
- protected long hbFreq = DFLT_HEARTBEAT_FREQ;
+ /** Metrics update messages issuing frequency. */
+ protected long metricsUpdateFreq = DFLT_METRICS_UPDATE_FREQ;
/** Size of topology snapshots history. */
protected int topHistSize = DFLT_TOP_HISTORY_SIZE;
@@ -361,12 +355,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
/** Maximum message acknowledgement timeout. */
private long maxAckTimeout = DFLT_MAX_ACK_TIMEOUT;
- /** Max heartbeats count node can miss without initiating status check. */
- protected int maxMissedHbs = DFLT_MAX_MISSED_HEARTBEATS;
-
- /** Max heartbeats count node can miss without failing client node. */
- protected int maxMissedClientHbs = DFLT_MAX_MISSED_CLIENT_HEARTBEATS;
-
/** IP finder clean frequency. */
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
protected long ipFinderCleanFreq = DFLT_IP_FINDER_CLEAN_FREQ;
@@ -731,56 +719,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
}
/**
- * Gets max heartbeats count node can miss without initiating status check.
- *
- * @return Max missed heartbeats.
- */
- public int getMaxMissedHeartbeats() {
- return maxMissedHbs;
- }
-
- /**
- * Sets max heartbeats count node can miss without initiating status check.
- * <p>
- * If not provided, default value is {@link #DFLT_MAX_MISSED_HEARTBEATS}.
- * <p>
- * Affected server nodes only.
- *
- * @param maxMissedHbs Max missed heartbeats.
- * @return {@code this} for chaining.
- */
- @IgniteSpiConfiguration(optional = true)
- public TcpDiscoverySpi setMaxMissedHeartbeats(int maxMissedHbs) {
- this.maxMissedHbs = maxMissedHbs;
-
- return this;
- }
-
- /**
- * Gets max heartbeats count node can miss without failing client node.
- *
- * @return Max missed client heartbeats.
- */
- public int getMaxMissedClientHeartbeats() {
- return maxMissedClientHbs;
- }
-
- /**
- * Sets max heartbeats count node can miss without failing client node.
- * <p>
- * If not provided, default value is {@link #DFLT_MAX_MISSED_CLIENT_HEARTBEATS}.
- *
- * @param maxMissedClientHbs Max missed client heartbeats.
- * @return {@code this} for chaining.
- */
- @IgniteSpiConfiguration(optional = true)
- public TcpDiscoverySpi setMaxMissedClientHeartbeats(int maxMissedClientHbs) {
- this.maxMissedClientHbs = maxMissedClientHbs;
-
- return this;
- }
-
- /**
* Gets statistics print frequency.
*
* @return Statistics print frequency in milliseconds.
@@ -966,22 +904,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
}
/**
- * Sets delay between issuing of heartbeat messages. SPI sends heartbeat messages
- * in configurable time interval to other nodes to notify them about its state.
- * <p>
- * If not provided, default value is {@link #DFLT_HEARTBEAT_FREQ}.
- *
- * @param hbFreq Heartbeat frequency in milliseconds.
- * @return {@code this} for chaining.
- */
- @IgniteSpiConfiguration(optional = true)
- public TcpDiscoverySpi setHeartbeatFrequency(long hbFreq) {
- this.hbFreq = hbFreq;
-
- return this;
- }
-
- /**
* @return Size of topology snapshots history.
*/
public long getTopHistorySize() {
@@ -1180,6 +1102,20 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
}
/**
+ * Gets effective or resulting socket timeout with considering failure detection timeout
+ *
+ * @param srvrOperation {@code True} if socket connect to server node,
+ * {@code False} if socket connect to client node.
+ * @return Resulting socket timeout.
+ */
+ public long getEffectiveSocketTimeout(boolean srvrOperation) {
+ if (failureDetectionTimeoutEnabled())
+ return srvrOperation ? failureDetectionTimeout() : clientFailureDetectionTimeout();
+ else
+ return sockTimeout;
+ }
+
+ /**
* Gets message acknowledgement timeout.
*
* @return Message acknowledgement timeout.
@@ -1207,19 +1143,11 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
}
/**
- * Gets delay between heartbeat messages sent by coordinator.
- *
- * @return Time period in milliseconds.
- */
- public long getHeartbeatFrequency() {
- return hbFreq;
- }
-
- /**
* Gets {@link org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder} (string representation).
*
* @return IPFinder (string representation).
- */public String getIpFinderFormatted() {
+ */
+ public String getIpFinderFormatted() {
return ipFinder.toString();
}
@@ -1939,6 +1867,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
impl = new ServerImpl(this);
}
+ metricsUpdateFreq = ignite.configuration().getMetricsUpdateFrequency();
+
if (!failureDetectionTimeoutEnabled()) {
assertParameter(sockTimeout > 0, "sockTimeout > 0");
assertParameter(ackTimeout > 0, "ackTimeout > 0");
@@ -1948,14 +1878,13 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
assertParameter(netTimeout > 0, "networkTimeout > 0");
assertParameter(ipFinder != null, "ipFinder != null");
- assertParameter(hbFreq > 0, "heartbeatFreq > 0");
+ assertParameter(metricsUpdateFreq > 0, "metricsUpdateFreq > 0" +
+ " (inited from igniteConfiguration.metricsUpdateFrequency)");
assertParameter(ipFinderCleanFreq > 0, "ipFinderCleanFreq > 0");
assertParameter(locPort > 1023, "localPort > 1023");
assertParameter(locPortRange >= 0, "localPortRange >= 0");
assertParameter(locPort + locPortRange <= 0xffff, "locPort + locPortRange <= 0xffff");
- assertParameter(maxMissedHbs > 0, "maxMissedHeartbeats > 0");
- assertParameter(maxMissedClientHbs > 0, "maxMissedClientHeartbeats > 0");
assertParameter(threadPri > 0, "threadPri > 0");
assertParameter(statsPrintFreq >= 0, "statsPrintFreq >= 0");
@@ -2000,8 +1929,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
log.debug(configInfo("ipFinder", ipFinder));
log.debug(configInfo("ipFinderCleanFreq", ipFinderCleanFreq));
- log.debug(configInfo("heartbeatFreq", hbFreq));
- log.debug(configInfo("maxMissedHeartbeats", maxMissedHbs));
+ log.debug(configInfo("metricsUpdateFreq", metricsUpdateFreq));
log.debug(configInfo("statsPrintFreq", statsPrintFreq));
}
@@ -2336,21 +2264,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi {
}
/** {@inheritDoc} */
- @Override public long getHeartbeatFrequency() {
- return TcpDiscoverySpi.this.getHeartbeatFrequency();
- }
-
- /** {@inheritDoc} */
- @Override public int getMaxMissedHeartbeats() {
- return TcpDiscoverySpi.this.getMaxMissedHeartbeats();
- }
-
- /** {@inheritDoc} */
- @Override public int getMaxMissedClientHeartbeats() {
- return TcpDiscoverySpi.this.getMaxMissedClientHeartbeats();
- }
-
- /** {@inheritDoc} */
@Override public long getStatisticsPrintFrequency() {
return TcpDiscoverySpi.this.getStatisticsPrintFrequency();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
index 1427929..a05ecde 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java
@@ -28,14 +28,6 @@ import org.jetbrains.annotations.Nullable;
*/
public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean {
/**
- * Gets delay between heartbeat messages sent by coordinator.
- *
- * @return Time period in milliseconds.
- */
- @MXBeanDescription("Heartbeat frequency.")
- public long getHeartbeatFrequency();
-
- /**
* Gets current SPI state.
*
* @return Current SPI state.
@@ -84,22 +76,6 @@ public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean {
public int getLocalPortRange();
/**
- * Gets max heartbeats count node can miss without initiating status check.
- *
- * @return Max missed heartbeats.
- */
- @MXBeanDescription("Max missed heartbeats.")
- public int getMaxMissedHeartbeats();
-
- /**
- * Gets max heartbeats count node can miss without failing client node.
- *
- * @return Max missed client heartbeats.
- */
- @MXBeanDescription("Max missed client heartbeats.")
- public int getMaxMissedClientHeartbeats();
-
- /**
* Gets thread priority. All threads within SPI will be started with it.
*
* @return Thread priority.
@@ -281,4 +257,4 @@ public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean {
*/
@MXBeanDescription("Client mode.")
public boolean isClientMode() throws IllegalStateException;
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
index d778854..6882821 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java
@@ -102,7 +102,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
/** Node order in the topology (internal). */
private volatile long intOrder;
- /** The most recent time when heartbeat message was received from the node. */
+ /** The most recent time when metrics update message was received from the node. */
@GridToStringExclude
private volatile long lastUpdateTime = U.currentTimeMillis();
@@ -123,9 +123,9 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
/** Version. */
private IgniteProductVersion ver;
- /** Alive check (used by clients). */
+ /** Alive check time (used by clients). */
@GridToStringExclude
- private transient int aliveCheck;
+ private transient long aliveCheckTime;
/** Client router node ID. */
@GridToStringExclude
@@ -291,9 +291,8 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
* Gets collections of cache metrics for this node. Note that node cache metrics are constantly updated
* and provide up to date information about caches.
* <p>
- * Cache metrics are updated with some delay which is directly related to heartbeat
- * frequency. For example, when used with default
- * {@link TcpDiscoverySpi} the update will happen every {@code 2} seconds.
+ * Cache metrics are updated with some delay which is directly related to metrics update
+ * frequency. For example, by default the update will happen every {@code 2} seconds.
*
* @return Runtime metrics snapshots for this node.
*/
@@ -414,7 +413,7 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
/**
* Gets node last update time.
*
- * @return Time of the last heartbeat.
+ * @return Time of the last metrics update.
*/
public long lastUpdateTime() {
return lastUpdateTime;
@@ -473,23 +472,25 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste
}
/**
- * Decrements alive check value and returns new one.
+ * Test alive check time value.
*
- * @return Alive check value.
+ * @return {@code True} if client alive, {@code False} otherwise.
*/
- public int decrementAliveCheck() {
- assert isClient();
+ public boolean isClientAlive() {
+ assert isClient() : this;
- return --aliveCheck;
+ return (aliveCheckTime - U.currentTimeMillis()) >= 0;
}
/**
- * @param aliveCheck Alive check value.
+ * Set client alive time.
+ *
+ * @param aliveTime Alive time interval.
*/
- public void aliveCheck(int aliveCheck) {
- assert isClient();
+ public void clientAliveTime(long aliveTime) {
+ assert isClient() : this;
- this.aliveCheck = aliveCheck;
+ this.aliveCheckTime = U.currentTimeMillis() + aliveTime;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
deleted file mode 100644
index ade5468..0000000
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientHeartbeatMessage.java
+++ /dev/null
@@ -1,72 +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.spi.discovery.tcp.messages;
-
-import java.util.UUID;
-import org.apache.ignite.cluster.ClusterMetrics;
-import org.apache.ignite.internal.ClusterMetricsSnapshot;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Heartbeat message.
- * <p>
- * Client sends his heartbeats in this message.
- */
-public class TcpDiscoveryClientHeartbeatMessage extends TcpDiscoveryAbstractMessage {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- private final byte[] metrics;
-
- /**
- * Constructor.
- *
- * @param creatorNodeId Creator node.
- * @param metrics Metrics.
- */
- public TcpDiscoveryClientHeartbeatMessage(UUID creatorNodeId, ClusterMetrics metrics) {
- super(creatorNodeId);
-
- this.metrics = ClusterMetricsSnapshot.serialize(metrics);
- }
-
- /**
- * Gets metrics map.
- *
- * @return Metrics map.
- */
- public ClusterMetrics metrics() {
- return ClusterMetricsSnapshot.deserialize(metrics, 0);
- }
-
- /** {@inheritDoc} */
- @Override public boolean highPriority() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean traceLogLevel() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(TcpDiscoveryClientHeartbeatMessage.class, this, "super", super.toString());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientMetricsUpdateMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientMetricsUpdateMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientMetricsUpdateMessage.java
new file mode 100644
index 0000000..b56cd01
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientMetricsUpdateMessage.java
@@ -0,0 +1,72 @@
+/*
+ * 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.spi.discovery.tcp.messages;
+
+import java.util.UUID;
+import org.apache.ignite.cluster.ClusterMetrics;
+import org.apache.ignite.internal.ClusterMetricsSnapshot;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Metrics update message.
+ * <p>
+ * Client sends his metrics in this message.
+ */
+public class TcpDiscoveryClientMetricsUpdateMessage extends TcpDiscoveryAbstractMessage {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final byte[] metrics;
+
+ /**
+ * Constructor.
+ *
+ * @param creatorNodeId Creator node.
+ * @param metrics Metrics.
+ */
+ public TcpDiscoveryClientMetricsUpdateMessage(UUID creatorNodeId, ClusterMetrics metrics) {
+ super(creatorNodeId);
+
+ this.metrics = ClusterMetricsSnapshot.serialize(metrics);
+ }
+
+ /**
+ * Gets metrics map.
+ *
+ * @return Metrics map.
+ */
+ public ClusterMetrics metrics() {
+ return ClusterMetricsSnapshot.deserialize(metrics, 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean highPriority() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean traceLogLevel() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TcpDiscoveryClientMetricsUpdateMessage.class, this, "super", super.toString());
+ }
+}
\ No newline at end of file
[48/50] [abbrv] ignite git commit: ignite-4799 TcpDiscoverySpi:
removed missedHeartbeats properties,
heartbeatFrequency (instead use IgiteConfiguration.metricsUpdateFrequency).
Added IgiteConfiguration.clientFailureDetectionTimeout.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
deleted file mode 100644
index 0ae253a..0000000
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryHeartbeatMessage.java
+++ /dev/null
@@ -1,338 +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.spi.discovery.tcp.messages;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.UUID;
-import org.apache.ignite.cache.CacheMetrics;
-import org.apache.ignite.cluster.ClusterMetrics;
-import org.apache.ignite.internal.ClusterMetricsSnapshot;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.T2;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-
-/**
- * Heartbeat message.
- * <p>
- * It is sent by coordinator node across the ring once a configured period.
- * Message makes two passes:
- * <ol>
- * <li>During first pass, all nodes add their metrics to the message and
- * update local metrics with metrics currently present in the message.</li>
- * <li>During second pass, all nodes update all metrics present in the message
- * and remove their own metrics from the message.</li>
- * </ol>
- * When message reaches coordinator second time it is discarded (it finishes the
- * second pass).
- */
-@TcpDiscoveryRedirectToClient
-public class TcpDiscoveryHeartbeatMessage extends TcpDiscoveryAbstractMessage {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Map to store nodes metrics. */
- @GridToStringExclude
- private final Map<UUID, MetricsSet> metrics = new HashMap<>();
-
- /** Client node IDs. */
- private final Collection<UUID> clientNodeIds = new HashSet<>();
-
- /** Cahce metrics by node. */
- @GridToStringExclude
- private final Map<UUID, Map<Integer, CacheMetrics>> cacheMetrics = new HashMap<>();
-
- /**
- * Constructor.
- *
- * @param creatorNodeId Creator node.
- */
- public TcpDiscoveryHeartbeatMessage(UUID creatorNodeId) {
- super(creatorNodeId);
- }
-
- /**
- * Sets metrics for particular node.
- *
- * @param nodeId Node ID.
- * @param metrics Node metrics.
- */
- public void setMetrics(UUID nodeId, ClusterMetrics metrics) {
- assert nodeId != null;
- assert metrics != null;
- assert !this.metrics.containsKey(nodeId);
-
- this.metrics.put(nodeId, new MetricsSet(metrics));
- }
-
- /**
- * Sets cache metrics for particular node.
- *
- * @param nodeId Node ID.
- * @param metrics Node cache metrics.
- */
- public void setCacheMetrics(UUID nodeId, Map<Integer, CacheMetrics> metrics) {
- assert nodeId != null;
- assert metrics != null;
- assert !this.cacheMetrics.containsKey(nodeId);
-
- if (!F.isEmpty(metrics))
- this.cacheMetrics.put(nodeId, metrics);
- }
-
- /**
- * Sets metrics for a client node.
- *
- * @param nodeId Server node ID.
- * @param clientNodeId Client node ID.
- * @param metrics Node metrics.
- */
- public void setClientMetrics(UUID nodeId, UUID clientNodeId, ClusterMetrics metrics) {
- assert nodeId != null;
- assert clientNodeId != null;
- assert metrics != null;
- assert this.metrics.containsKey(nodeId);
-
- this.metrics.get(nodeId).addClientMetrics(clientNodeId, metrics);
- }
-
- /**
- * Removes metrics for particular node from the message.
- *
- * @param nodeId Node ID.
- */
- public void removeMetrics(UUID nodeId) {
- assert nodeId != null;
-
- metrics.remove(nodeId);
- }
-
- /**
- * Removes cache metrics for particular node from the message.
- *
- * @param nodeId Node ID.
- */
- public void removeCacheMetrics(UUID nodeId) {
- assert nodeId != null;
-
- cacheMetrics.remove(nodeId);
- }
-
- /**
- * Gets metrics map.
- *
- * @return Metrics map.
- */
- public Map<UUID, MetricsSet> metrics() {
- return metrics;
- }
-
- /**
- * Gets cache metrics map.
- *
- * @return Cache metrics map.
- */
- public Map<UUID, Map<Integer, CacheMetrics>> cacheMetrics() {
- return cacheMetrics;
- }
-
- /**
- * @return {@code True} if this message contains metrics.
- */
- public boolean hasMetrics() {
- return !metrics.isEmpty();
- }
-
- /**
- * @return {@code True} this message contains cache metrics.
- */
- public boolean hasCacheMetrics() {
- return !cacheMetrics.isEmpty();
- }
-
- /**
- * @return {@code True} if this message contains metrics.
- */
- public boolean hasMetrics(UUID nodeId) {
- assert nodeId != null;
-
- return metrics.get(nodeId) != null;
- }
-
- /**
- * @param nodeId Node ID.
- *
- * @return {@code True} if this message contains cache metrics for particular node.
- */
- public boolean hasCacheMetrics(UUID nodeId) {
- assert nodeId != null;
-
- return cacheMetrics.get(nodeId) != null;
- }
-
- /**
- * Gets client node IDs for particular node.
- *
- * @return Client node IDs.
- */
- public Collection<UUID> clientNodeIds() {
- return clientNodeIds;
- }
-
- /**
- * Adds client node ID.
- *
- * @param clientNodeId Client node ID.
- */
- public void addClientNodeId(UUID clientNodeId) {
- clientNodeIds.add(clientNodeId);
- }
-
- /** {@inheritDoc} */
- @Override public boolean traceLogLevel() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean highPriority() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(TcpDiscoveryHeartbeatMessage.class, this, "super", super.toString());
- }
-
- /**
- * @param nodeId Node ID.
- * @param metrics Metrics.
- * @return Serialized metrics.
- */
- private static byte[] serializeMetrics(UUID nodeId, ClusterMetrics metrics) {
- assert nodeId != null;
- assert metrics != null;
-
- byte[] buf = new byte[16 + ClusterMetricsSnapshot.METRICS_SIZE];
-
- U.longToBytes(nodeId.getMostSignificantBits(), buf, 0);
- U.longToBytes(nodeId.getLeastSignificantBits(), buf, 8);
-
- ClusterMetricsSnapshot.serialize(buf, 16, metrics);
-
- return buf;
- }
-
- /**
- */
- @SuppressWarnings("PublicInnerClass")
- public static class MetricsSet implements Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Metrics. */
- private byte[] metrics;
-
- /** Client metrics. */
- private Collection<byte[]> clientMetrics;
-
- /**
- */
- public MetricsSet() {
- // No-op.
- }
-
- /**
- * @param metrics Metrics.
- */
- public MetricsSet(ClusterMetrics metrics) {
- assert metrics != null;
-
- this.metrics = ClusterMetricsSnapshot.serialize(metrics);
- }
-
- /**
- * @return Deserialized metrics.
- */
- public ClusterMetrics metrics() {
- return ClusterMetricsSnapshot.deserialize(metrics, 0);
- }
-
- /**
- * @return Client metrics.
- */
- public Collection<T2<UUID, ClusterMetrics>> clientMetrics() {
- return F.viewReadOnly(clientMetrics, new C1<byte[], T2<UUID, ClusterMetrics>>() {
- @Override public T2<UUID, ClusterMetrics> apply(byte[] bytes) {
- UUID nodeId = new UUID(U.bytesToLong(bytes, 0), U.bytesToLong(bytes, 8));
-
- return new T2<>(nodeId, ClusterMetricsSnapshot.deserialize(bytes, 16));
- }
- });
- }
-
- /**
- * @param nodeId Client node ID.
- * @param metrics Client metrics.
- */
- private void addClientMetrics(UUID nodeId, ClusterMetrics metrics) {
- assert nodeId != null;
- assert metrics != null;
-
- if (clientMetrics == null)
- clientMetrics = new ArrayList<>();
-
- clientMetrics.add(serializeMetrics(nodeId, metrics));
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeByteArray(out, metrics);
-
- out.writeInt(clientMetrics != null ? clientMetrics.size() : -1);
-
- if (clientMetrics != null) {
- for (byte[] arr : clientMetrics)
- U.writeByteArray(out, arr);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- metrics = U.readByteArray(in);
-
- int clientMetricsSize = in.readInt();
-
- if (clientMetricsSize >= 0) {
- clientMetrics = new ArrayList<>(clientMetricsSize);
-
- for (int i = 0; i < clientMetricsSize; i++)
- clientMetrics.add(U.readByteArray(in));
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryMetricsUpdateMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryMetricsUpdateMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryMetricsUpdateMessage.java
new file mode 100644
index 0000000..9bf33cf
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryMetricsUpdateMessage.java
@@ -0,0 +1,338 @@
+/*
+ * 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.spi.discovery.tcp.messages;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cluster.ClusterMetrics;
+import org.apache.ignite.internal.ClusterMetricsSnapshot;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.C1;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * Metrics update message.
+ * <p>
+ * It is sent by coordinator node across the ring once a configured period.
+ * Message makes two passes:
+ * <ol>
+ * <li>During first pass, all nodes add their metrics to the message and
+ * update local metrics with metrics currently present in the message.</li>
+ * <li>During second pass, all nodes update all metrics present in the message
+ * and remove their own metrics from the message.</li>
+ * </ol>
+ * When message reaches coordinator second time it is discarded (it finishes the
+ * second pass).
+ */
+@TcpDiscoveryRedirectToClient
+public class TcpDiscoveryMetricsUpdateMessage extends TcpDiscoveryAbstractMessage {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Map to store nodes metrics. */
+ @GridToStringExclude
+ private final Map<UUID, MetricsSet> metrics = new HashMap<>();
+
+ /** Client node IDs. */
+ private final Collection<UUID> clientNodeIds = new HashSet<>();
+
+ /** Cahce metrics by node. */
+ @GridToStringExclude
+ private final Map<UUID, Map<Integer, CacheMetrics>> cacheMetrics = new HashMap<>();
+
+ /**
+ * Constructor.
+ *
+ * @param creatorNodeId Creator node.
+ */
+ public TcpDiscoveryMetricsUpdateMessage(UUID creatorNodeId) {
+ super(creatorNodeId);
+ }
+
+ /**
+ * Sets metrics for particular node.
+ *
+ * @param nodeId Node ID.
+ * @param metrics Node metrics.
+ */
+ public void setMetrics(UUID nodeId, ClusterMetrics metrics) {
+ assert nodeId != null;
+ assert metrics != null;
+ assert !this.metrics.containsKey(nodeId);
+
+ this.metrics.put(nodeId, new MetricsSet(metrics));
+ }
+
+ /**
+ * Sets cache metrics for particular node.
+ *
+ * @param nodeId Node ID.
+ * @param metrics Node cache metrics.
+ */
+ public void setCacheMetrics(UUID nodeId, Map<Integer, CacheMetrics> metrics) {
+ assert nodeId != null;
+ assert metrics != null;
+ assert !this.cacheMetrics.containsKey(nodeId);
+
+ if (!F.isEmpty(metrics))
+ this.cacheMetrics.put(nodeId, metrics);
+ }
+
+ /**
+ * Sets metrics for a client node.
+ *
+ * @param nodeId Server node ID.
+ * @param clientNodeId Client node ID.
+ * @param metrics Node metrics.
+ */
+ public void setClientMetrics(UUID nodeId, UUID clientNodeId, ClusterMetrics metrics) {
+ assert nodeId != null;
+ assert clientNodeId != null;
+ assert metrics != null;
+ assert this.metrics.containsKey(nodeId);
+
+ this.metrics.get(nodeId).addClientMetrics(clientNodeId, metrics);
+ }
+
+ /**
+ * Removes metrics for particular node from the message.
+ *
+ * @param nodeId Node ID.
+ */
+ public void removeMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ metrics.remove(nodeId);
+ }
+
+ /**
+ * Removes cache metrics for particular node from the message.
+ *
+ * @param nodeId Node ID.
+ */
+ public void removeCacheMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ cacheMetrics.remove(nodeId);
+ }
+
+ /**
+ * Gets metrics map.
+ *
+ * @return Metrics map.
+ */
+ public Map<UUID, MetricsSet> metrics() {
+ return metrics;
+ }
+
+ /**
+ * Gets cache metrics map.
+ *
+ * @return Cache metrics map.
+ */
+ public Map<UUID, Map<Integer, CacheMetrics>> cacheMetrics() {
+ return cacheMetrics;
+ }
+
+ /**
+ * @return {@code True} if this message contains metrics.
+ */
+ public boolean hasMetrics() {
+ return !metrics.isEmpty();
+ }
+
+ /**
+ * @return {@code True} this message contains cache metrics.
+ */
+ public boolean hasCacheMetrics() {
+ return !cacheMetrics.isEmpty();
+ }
+
+ /**
+ * @return {@code True} if this message contains metrics.
+ */
+ public boolean hasMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ return metrics.get(nodeId) != null;
+ }
+
+ /**
+ * @param nodeId Node ID.
+ *
+ * @return {@code True} if this message contains cache metrics for particular node.
+ */
+ public boolean hasCacheMetrics(UUID nodeId) {
+ assert nodeId != null;
+
+ return cacheMetrics.get(nodeId) != null;
+ }
+
+ /**
+ * Gets client node IDs for particular node.
+ *
+ * @return Client node IDs.
+ */
+ public Collection<UUID> clientNodeIds() {
+ return clientNodeIds;
+ }
+
+ /**
+ * Adds client node ID.
+ *
+ * @param clientNodeId Client node ID.
+ */
+ public void addClientNodeId(UUID clientNodeId) {
+ clientNodeIds.add(clientNodeId);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean traceLogLevel() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean highPriority() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TcpDiscoveryMetricsUpdateMessage.class, this, "super", super.toString());
+ }
+
+ /**
+ * @param nodeId Node ID.
+ * @param metrics Metrics.
+ * @return Serialized metrics.
+ */
+ private static byte[] serializeMetrics(UUID nodeId, ClusterMetrics metrics) {
+ assert nodeId != null;
+ assert metrics != null;
+
+ byte[] buf = new byte[16 + ClusterMetricsSnapshot.METRICS_SIZE];
+
+ U.longToBytes(nodeId.getMostSignificantBits(), buf, 0);
+ U.longToBytes(nodeId.getLeastSignificantBits(), buf, 8);
+
+ ClusterMetricsSnapshot.serialize(buf, 16, metrics);
+
+ return buf;
+ }
+
+ /**
+ */
+ @SuppressWarnings("PublicInnerClass")
+ public static class MetricsSet implements Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Metrics. */
+ private byte[] metrics;
+
+ /** Client metrics. */
+ private Collection<byte[]> clientMetrics;
+
+ /**
+ */
+ public MetricsSet() {
+ // No-op.
+ }
+
+ /**
+ * @param metrics Metrics.
+ */
+ public MetricsSet(ClusterMetrics metrics) {
+ assert metrics != null;
+
+ this.metrics = ClusterMetricsSnapshot.serialize(metrics);
+ }
+
+ /**
+ * @return Deserialized metrics.
+ */
+ public ClusterMetrics metrics() {
+ return ClusterMetricsSnapshot.deserialize(metrics, 0);
+ }
+
+ /**
+ * @return Client metrics.
+ */
+ public Collection<T2<UUID, ClusterMetrics>> clientMetrics() {
+ return F.viewReadOnly(clientMetrics, new C1<byte[], T2<UUID, ClusterMetrics>>() {
+ @Override public T2<UUID, ClusterMetrics> apply(byte[] bytes) {
+ UUID nodeId = new UUID(U.bytesToLong(bytes, 0), U.bytesToLong(bytes, 8));
+
+ return new T2<>(nodeId, ClusterMetricsSnapshot.deserialize(bytes, 16));
+ }
+ });
+ }
+
+ /**
+ * @param nodeId Client node ID.
+ * @param metrics Client metrics.
+ */
+ private void addClientMetrics(UUID nodeId, ClusterMetrics metrics) {
+ assert nodeId != null;
+ assert metrics != null;
+
+ if (clientMetrics == null)
+ clientMetrics = new ArrayList<>();
+
+ clientMetrics.add(serializeMetrics(nodeId, metrics));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ U.writeByteArray(out, metrics);
+
+ out.writeInt(clientMetrics != null ? clientMetrics.size() : -1);
+
+ if (clientMetrics != null) {
+ for (byte[] arr : clientMetrics)
+ U.writeByteArray(out, arr);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ metrics = U.readByteArray(in);
+
+ int clientMetricsSize = in.readInt();
+
+ if (clientMetricsSize >= 0) {
+ clientMetrics = new ArrayList<>(clientMetricsSize);
+
+ for (int i = 0; i < clientMetricsSize; i++)
+ clientMetrics.add(U.readByteArray(in));
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/adaptive/AdaptiveLoadBalancingSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/adaptive/AdaptiveLoadBalancingSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/adaptive/AdaptiveLoadBalancingSpi.java
index cfd4fc7..1a3a7fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/adaptive/AdaptiveLoadBalancingSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/loadbalancing/adaptive/AdaptiveLoadBalancingSpi.java
@@ -97,13 +97,13 @@ import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED;
* You should tune these values based on the level of accuracy needed vs. the additional memory
* that would be required for storing metrics.
* <p>
- * You should also keep in mind that metrics for remote nodes are delayed (usually by the
- * heartbeat frequency). So if it is acceptable in your environment, set the heartbeat frequency
- * to be more inline with job execution time. Generally, the more often heartbeats between nodes
+ * You should also keep in mind that metrics for remote nodes are delayed (usually by the metrics
+ * update frequency). So if it is acceptable in your environment, set the metrics update frequency
+ * to be more inline with job execution time. Generally, the more often metrics update between nodes
* are exchanged, the more precise the metrics are. However, you should keep in mind that if
- * heartbeats are exchanged too often then it may create unnecessary traffic in the network.
- * Heartbeats (or metrics update frequency) can be configured via underlying
- * {@link org.apache.ignite.spi.discovery.DiscoverySpi} used in your grid.
+ * metrics update are exchanged too often then it may create unnecessary traffic in the network.
+ * Metrics update frequency can be configured via underlying
+ * {@link org.apache.ignite.configuration.IgniteConfiguration} used in your grid.
* <p>
* Here is an example of how probing can be implemented to use
* number of active and waiting jobs as probing mechanism:
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 2cc83a4..bc1e534 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -1962,7 +1962,7 @@ org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAuthFailedMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCheckFailedMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientAckResponse
-org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientHeartbeatMessage
+org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientMetricsUpdateMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingRequest
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientPingResponse
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryClientReconnectMessage
@@ -1972,9 +1972,9 @@ org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDiscardMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryDuplicateIdMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeRequest
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHandshakeResponse
-org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage
-org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage$MetricsSet
-org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage$MetricsSet$1
+org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage
+org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage$MetricsSet
+org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage$MetricsSet$1
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryJoinRequestMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryLoopbackProblemMessage
org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/config/load/dsi-load-base.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/load/dsi-load-base.xml b/modules/core/src/test/config/load/dsi-load-base.xml
index c57b5e0..7d7f2ba 100644
--- a/modules/core/src/test/config/load/dsi-load-base.xml
+++ b/modules/core/src/test/config/load/dsi-load-base.xml
@@ -48,10 +48,11 @@
<property name="ackTimeout" value="4000"/>
<property name="socketTimeout" value="4000"/>
- <property name="heartbeatFrequency" value="6000"/>
</bean>
</property>
+ <property name="metricsUpdateFrequency" value="6000"/>
+
<property name="lifecycleBeans" ref="lifecycleBeans"/>
<property name="peerClassLoadingEnabled" value="false"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/config/load/merge-sort-base.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/load/merge-sort-base.xml b/modules/core/src/test/config/load/merge-sort-base.xml
index aba0108..44b26bb 100644
--- a/modules/core/src/test/config/load/merge-sort-base.xml
+++ b/modules/core/src/test/config/load/merge-sort-base.xml
@@ -68,6 +68,10 @@
<property name="peerClassLoadingThreadPoolSize" value="100"/>
+ <property name="metricsUpdateFrequency" value="10000"/>
+
+ <property name="failureDetectionTimeout" value="60000"/>
+
<!-- Discovery SPI configuration. -->
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
@@ -75,9 +79,6 @@
<property name="socketTimeout" value="5000"/>
<property name="ackTimeout" value="5000"/>
- <property name="heartbeatFrequency" value="10000"/>
- <property name="maxMissedHeartbeats" value="6"/>
-
<property name="statisticsPrintFrequency" value="60000"/>
<property name="ipFinder">
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/config/streamer/spring-streamer-base.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/config/streamer/spring-streamer-base.xml b/modules/core/src/test/config/streamer/spring-streamer-base.xml
index 746dd95..ddb96a7 100644
--- a/modules/core/src/test/config/streamer/spring-streamer-base.xml
+++ b/modules/core/src/test/config/streamer/spring-streamer-base.xml
@@ -66,12 +66,13 @@
<constructor-arg value="127.0.0.1"/>
</bean>
+ <property name="failureDetectionTimeout" value="45000"/>
+ <property name="metricsUpdateFrequency" value="15000"/>
+
<bean id="discoSpi" class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ackTimeout" value="5000"/>
<property name="socketTimeout" value="5000"/>
<property name="reconnectCount" value="5"/>
- <property name="heartbeatFrequency" value="15000"/>
- <property name="maxMissedHeartbeats" value="3"/>
<property name="ipFinder">
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/GridTestJob.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/GridTestJob.java b/modules/core/src/test/java/org/apache/ignite/GridTestJob.java
index a4dbe53..3750585 100644
--- a/modules/core/src/test/java/org/apache/ignite/GridTestJob.java
+++ b/modules/core/src/test/java/org/apache/ignite/GridTestJob.java
@@ -20,6 +20,8 @@ package org.apache.ignite;
import org.apache.ignite.compute.ComputeJobAdapter;
import org.apache.ignite.resources.LoggerResource;
+import java.util.concurrent.CountDownLatch;
+
/**
* Test job.
*/
@@ -28,6 +30,8 @@ public class GridTestJob extends ComputeJobAdapter {
@LoggerResource
private IgniteLogger log;
+ CountDownLatch latch;
+
/** */
public GridTestJob() {
// No-op.
@@ -40,10 +44,25 @@ public class GridTestJob extends ComputeJobAdapter {
super(arg);
}
+ /**
+ * @param arg Job argument.
+ */
+ public GridTestJob(String arg, CountDownLatch latch) {
+ super(arg);
+ this.latch = latch;
+ }
+
/** {@inheritDoc} */
@Override public String execute() {
if (log.isDebugEnabled())
log.debug("Executing job [job=" + this + ", arg=" + argument(0) + ']');
+ if (latch != null) {
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+ // Nothing to do
+ }
+ }
return argument(0);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/GridTestTask.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/GridTestTask.java b/modules/core/src/test/java/org/apache/ignite/GridTestTask.java
index dbe34c6..8dc0569 100644
--- a/modules/core/src/test/java/org/apache/ignite/GridTestTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/GridTestTask.java
@@ -20,6 +20,8 @@ package org.apache.ignite;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
import org.apache.ignite.compute.ComputeJob;
import org.apache.ignite.compute.ComputeJobResult;
import org.apache.ignite.compute.ComputeTaskSplitAdapter;
@@ -33,6 +35,20 @@ public class GridTestTask extends ComputeTaskSplitAdapter<Object, Object> {
@LoggerResource
private IgniteLogger log;
+ /**
+ * Optional latch to wait for
+ */
+ CountDownLatch latch;
+
+ public GridTestTask (CountDownLatch latch) {
+ super();
+ this.latch = latch;
+ }
+
+ public GridTestTask() {
+ super();
+ }
+
/** {@inheritDoc} */
@Override public Collection<? extends ComputeJob> split(int gridSize, Object arg) {
if (log.isDebugEnabled())
@@ -41,7 +57,7 @@ public class GridTestTask extends ComputeTaskSplitAdapter<Object, Object> {
Collection<ComputeJob> refs = new ArrayList<>(gridSize);
for (int i = 0; i < gridSize; i++)
- refs.add(new GridTestJob(arg.toString() + i + 1));
+ refs.add(new GridTestJob(arg.toString() + i + 1, latch));
return refs;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
index dafc41f..d204a39 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/ClusterNodeMetricsSelfTest.java
@@ -87,7 +87,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
cfg.setDiscoverySpi(spi);
cfg.setCacheConfiguration();
- cfg.setMetricsUpdateFrequency(0);
+ cfg.setMetricsUpdateFrequency(500);
CacheConfiguration<Integer, Object> ccfg = defaultCacheConfiguration();
ccfg.setName(CACHE_NAME);
@@ -173,16 +173,18 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
public void testSingleTaskMetrics() throws Exception {
Ignite ignite = grid();
- ignite.compute().execute(new GridTestTask(), "testArg");
+ final CountDownLatch taskLatch = new CountDownLatch(2);
+ ignite.compute().executeAsync(new GridTestTask(taskLatch), "testArg");
// Let metrics update twice.
- final CountDownLatch latch = new CountDownLatch(2);
+ final CountDownLatch latch = new CountDownLatch(3);
ignite.events().localListen(new IgnitePredicate<Event>() {
@Override public boolean apply(Event evt) {
assert evt.type() == EVT_NODE_METRICS_UPDATED;
latch.countDown();
+ taskLatch.countDown();
return true;
}
@@ -203,7 +205,7 @@ public class ClusterNodeMetricsSelfTest extends GridCommonAbstractTest {
assert metrics.getAverageWaitingJobs() == 0;
assert metrics.getCurrentActiveJobs() == 0;
assert metrics.getCurrentCancelledJobs() == 0;
- assert metrics.getCurrentJobExecuteTime() == 0;
+ assert metrics.getCurrentJobExecuteTime() > 0;
assert metrics.getCurrentJobWaitTime() == 0;
assert metrics.getCurrentWaitingJobs() == 0;
assert metrics.getMaximumActiveJobs() == 1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
index f6f641b..7535228 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
@@ -54,10 +54,13 @@ public class GridAffinityMappedTest extends GridCommonAbstractTest {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+
disco.setIpFinder(ipFinder);
+
cfg.setDiscoverySpi(disco);
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
+
if (igniteInstanceName.endsWith("1"))
cfg.setCacheConfiguration(); // Empty cache configuration.
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
index 4e4586f..216c50e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
@@ -85,11 +85,12 @@ public class GridAffinityP2PSelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
disco.setIpFinder(ipFinder);
c.setDiscoverySpi(disco);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
+
c.setDeploymentMode(depMode);
if (igniteInstanceName.endsWith("1"))
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
index d2df1be..92933f9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
@@ -49,11 +49,12 @@ public class GridAffinitySelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
disco.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(disco);
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
+
if (igniteInstanceName.endsWith("1"))
cfg.setClientMode(true);
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
index 39677c5..a5d60cc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridCancelledJobsMetricsSelfTest.java
@@ -72,7 +72,7 @@ public class GridCancelledJobsMetricsSelfTest extends GridCommonAbstractTest {
assert discoSpi instanceof TcpDiscoverySpi;
- ((TcpDiscoverySpi)discoSpi).setHeartbeatFrequency(500);
+ cfg.setMetricsUpdateFrequency(500);
return cfg;
}
@@ -221,4 +221,4 @@ public class GridCancelledJobsMetricsSelfTest extends GridCommonAbstractTest {
tmp.onExternalCollision();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java
index 4d503bd..79dc81a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridFailFastNodeFailureDetectionSelfTest.java
@@ -49,7 +49,6 @@ public class GridFailFastNodeFailureDetectionSelfTest extends GridCommonAbstract
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(IP_FINDER);
- disco.setHeartbeatFrequency(10_000);
// Set parameters for fast ping failure.
disco.setSocketTimeout(100);
@@ -57,6 +56,7 @@ public class GridFailFastNodeFailureDetectionSelfTest extends GridCommonAbstract
disco.setReconnectCount(2);
cfg.setDiscoverySpi(disco);
+ cfg.setMetricsUpdateFrequency(10_000);
return cfg;
}
@@ -129,4 +129,4 @@ public class GridFailFastNodeFailureDetectionSelfTest extends GridCommonAbstract
U.invoke(comm.getClass(), comm, "simulateNodeFailure");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/GridJobCollisionCancelSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridJobCollisionCancelSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridJobCollisionCancelSelfTest.java
index c213464..80b5599 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridJobCollisionCancelSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridJobCollisionCancelSelfTest.java
@@ -102,7 +102,7 @@ public class GridJobCollisionCancelSelfTest extends GridCommonAbstractTest {
// Should be exactly the same as Jobs number.
assert cancelCnt <= SPLIT_COUNT : "Invalid cancel count: " + cancelCnt;
- // One per start and one per stop and some that come with heartbeats.
+ // One per start and one per stop and some that come with metrics update.
assert colResolutionCnt > SPLIT_COUNT + 1:
"Invalid collision resolution count: " + colResolutionCnt;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
index f0c50eb..1847303 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAliveCacheSelfTest.java
@@ -101,15 +101,15 @@ public class GridDiscoveryManagerAliveCacheSelfTest extends GridCommonAbstractTe
if (clientMode && ((igniteInstanceName.charAt(igniteInstanceName.length() - 1) - '0') & 1) != 0)
cfg.setClientMode(true);
else
- disc.setMaxMissedClientHeartbeats(50);
+ cfg.setClientFailureDetectionTimeout(50000);
- disc.setHeartbeatFrequency(500);
disc.setIpFinder(IP_FINDER);
disc.setAckTimeout(1000);
disc.setSocketTimeout(1000);
cfg.setCacheConfiguration(cCfg);
cfg.setDiscoverySpi(disc);
+ cfg.setMetricsUpdateFrequency(500);
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
index ccb879e..57a2420 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFailoverSelfTest.java
@@ -78,13 +78,13 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setNetworkTimeout(60_000);
+ cfg.setMetricsUpdateFrequency(30_000);
TcpDiscoverySpi discoSpi = (TcpDiscoverySpi)cfg.getDiscoverySpi();
discoSpi.setSocketTimeout(30_000);
discoSpi.setAckTimeout(30_000);
discoSpi.setNetworkTimeout(60_000);
- discoSpi.setHeartbeatFrequency(30_000);
discoSpi.setReconnectCount(2);
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
@@ -386,4 +386,4 @@ public abstract class GridCacheAbstractFailoverSelfTest extends GridCacheAbstrac
private IgniteCache<String,Integer> cache(Ignite g) {
return g.cache(null);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
index 95f8bb8..c40d44d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractSelfTest.java
@@ -201,9 +201,9 @@ public abstract class GridCacheAbstractSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java
index 47b9473..957828c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManagerSelfTest.java
@@ -51,10 +51,11 @@ public class GridCacheMvccManagerSelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
+
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
cfg.setCacheConfiguration(cacheConfiguration());
return cfg;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
index 688e1cc..5133f61 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java
@@ -93,17 +93,17 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest {
TcpDiscoverySpi disco = new TcpDiscoverySpi().setForceServerMode(true);
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
-
disco.setIpFinder(ipFinder);
if (isDebug())
disco.setAckTimeout(Integer.MAX_VALUE);
- MemoryEventStorageSpi eventSpi = new MemoryEventStorageSpi();
- eventSpi.setExpireCount(100);
+ MemoryEventStorageSpi evtSpi = new MemoryEventStorageSpi();
+ evtSpi.setExpireCount(100);
+
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
- cfg.setEventStorageSpi(eventSpi);
+ cfg.setEventStorageSpi(evtSpi);
cfg.setDiscoverySpi(disco);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataUpdatesFlowTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataUpdatesFlowTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataUpdatesFlowTest.java
index b76279d..e0fc205 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataUpdatesFlowTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataUpdatesFlowTest.java
@@ -147,9 +147,9 @@ public class BinaryMetadataUpdatesFlowTest extends GridCommonAbstractTest {
}
};
- discoSpi.setHeartbeatFrequency(1000);
-
cfg.setDiscoverySpi(discoSpi);
+
+ cfg.setMetricsUpdateFrequency(1000);
}
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index c68c8d0..9c24073 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -158,11 +158,12 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
discoSpi.setForceServerMode(forceSrvMode);
discoSpi.setIpFinder(ipFinder);
- discoSpi.setMaxMissedClientHeartbeats(100);
discoSpi.setNetworkTimeout(60_000);
cfg.setDiscoverySpi(discoSpi);
+ cfg.setClientFailureDetectionTimeout(100000);
+
CacheConfiguration[] ccfg;
if (cacheC != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
index e11e198..cd475fe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
@@ -87,10 +87,9 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
-
disco.setIpFinder(ipFinder);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(disco);
c.setDeploymentMode(DeploymentMode.SHARED);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
index aaacd2d..6d7ec90 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCache150ClientsTest.java
@@ -67,8 +67,8 @@ public class IgniteCache150ClientsTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setJoinTimeout(0);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setMaxMissedClientHeartbeats(200);
+ cfg.setClientFailureDetectionTimeout(200000);
cfg.setClientMode(!igniteInstanceName.equals(getTestIgniteInstanceName(0)));
CacheConfiguration[] ccfgs = new CacheConfiguration[CACHES];
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
index bbbcfd7..907922c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheNearRestartRollbackSelfTest.java
@@ -71,8 +71,8 @@ public class IgniteCacheNearRestartRollbackSelfTest extends GridCommonAbstractTe
TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
discoSpi.setIpFinder(IP_FINDER);
- discoSpi.setMaxMissedClientHeartbeats(50);
+ cfg.setClientFailureDetectionTimeout(50000);
cfg.setDiscoverySpi(discoSpi);
cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName));
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java
index ba9f9e4..644fabd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedTxSingleThreadedSelfTest.java
@@ -64,8 +64,8 @@ public class GridCacheColocatedTxSingleThreadedSelfTest extends IgniteTxSingleTh
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
- spi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(spi);
c.setCacheConfiguration(cc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
index b9afd65..3bdce46 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
@@ -93,8 +93,8 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(disco);
c.setCacheConfiguration(cc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
index f223c9b..af7aff4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
@@ -66,8 +66,8 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(ipFinder);
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(disco);
c.setCacheConfiguration(cc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index 591858a..6fdb354 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -82,7 +82,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
cfg.setConsistentId(gridName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setMaxMissedClientHeartbeats(1000);
+ cfg.setClientFailureDetectionTimeout(Integer.MAX_VALUE);
TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
index d041ae2..61cc580 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
@@ -82,8 +82,8 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
- spi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(spi);
c.setCacheConfiguration(cc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index e4ed64b..a6b8d79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -106,8 +106,8 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
- spi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
cfg.setDiscoverySpi(spi);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java
index 62e11a7..ef472a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSingleThreadedSelfTest.java
@@ -63,8 +63,8 @@ public class GridCachePartitionedTxSingleThreadedSelfTest extends IgniteTxSingle
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(ipFinder);
- spi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ c.setFailureDetectionTimeout(Integer.MAX_VALUE);
c.setDiscoverySpi(spi);
c.setCacheConfiguration(cc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
index 62adb77..7349a4e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/IndexingSpiQuerySelfTest.java
@@ -74,12 +74,12 @@ public class IndexingSpiQuerySelfTest extends TestCase {
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
- disco.setMaxMissedHeartbeats(Integer.MAX_VALUE);
-
disco.setIpFinder(ipFinder);
cfg.setDiscoverySpi(disco);
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
+
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
index 08f2709..1d6cbae 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceClientNodeTest.java
@@ -42,10 +42,11 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setMaxMissedClientHeartbeats(30);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(1000);
+
+ cfg.setClientFailureDetectionTimeout(30000);
cfg.setClientMode(client);
+ cfg.setMetricsUpdateFrequency(1000);
return cfg;
}
@@ -150,4 +151,4 @@ public class GridServiceClientNodeTest extends GridCommonAbstractTest {
assertTrue(latch.await(5000, TimeUnit.MILLISECONDS));
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
index 6fb7cdf..fedb4ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesAbstractLoadTest.java
@@ -41,11 +41,6 @@ public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommo
*/
protected abstract DiscoverySpi getDiscoverySpi(IgniteConfiguration cfg);
- /**
- * @return Discovery spi heartbeat frequency.
- */
- protected abstract int getHeartbeatFrequency();
-
/** {@inheritDoc} */
@SuppressWarnings("ConstantConditions")
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
@@ -120,11 +115,11 @@ public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommo
startGrid(idx);
- Thread.sleep(getHeartbeatFrequency() * 3);
+ Thread.sleep(grid(idx).configuration().getMetricsUpdateFrequency() * 3);
stopGrid(idx);
- Thread.sleep(getHeartbeatFrequency() * 3);
+ Thread.sleep(grid(idx).configuration().getMetricsUpdateFrequency() * 3);
}
}
catch (Throwable e) {
@@ -175,4 +170,4 @@ public abstract class GridSingleSplitsNewNodesAbstractLoadTest extends GridCommo
G.stop(getTestIgniteInstanceName(), false);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java
index 6d2c7aa..77142dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/direct/newnodes/GridSingleSplitsNewNodesMulticastLoadTest.java
@@ -33,13 +33,6 @@ public class GridSingleSplitsNewNodesMulticastLoadTest extends GridSingleSplitsN
assert discoSpi instanceof TcpDiscoverySpi : "Wrong default SPI implementation.";
- ((TcpDiscoverySpi)discoSpi).setHeartbeatFrequency(getHeartbeatFrequency());
-
return discoSpi;
}
-
- /** {@inheritDoc} */
- @Override protected int getHeartbeatFrequency() {
- return 3000;
- }
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PSameClassLoaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PSameClassLoaderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PSameClassLoaderSelfTest.java
index a126b4b..d2878e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PSameClassLoaderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/p2p/GridP2PSameClassLoaderSelfTest.java
@@ -71,8 +71,8 @@ public class GridP2PSameClassLoaderSelfTest extends GridCommonAbstractTest {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setDeploymentMode(depMode);
+ cfg.setMetricsUpdateFrequency(500);
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(500);
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(FINDER);
cfg.setCacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
index daa3ec0..fa1a2ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
@@ -219,11 +219,11 @@ public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends Gri
}
/**
- * Tests whether local node heartbeats cause METRICS_UPDATE event.
+ * Tests whether local node metrics update cause METRICS_UPDATE event.
*
* @throws Exception If test failed.
*/
- public void testLocalHeartbeat() throws Exception {
+ public void testLocalMetricsUpdate() throws Exception {
AtomicInteger[] locUpdCnts = new AtomicInteger[getSpiCount()];
int i = 0;
@@ -231,7 +231,7 @@ public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends Gri
for (final DiscoverySpi spi : spis) {
final AtomicInteger spiCnt = new AtomicInteger(0);
- DiscoverySpiListener locHeartbeatLsnr = new DiscoverySpiListener() {
+ DiscoverySpiListener locMetricsUpdateLsnr = new DiscoverySpiListener() {
/** {@inheritDoc} */
@Override public void onLocalNodeInitialized(ClusterNode locNode) {
// No-op.
@@ -249,17 +249,16 @@ public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends Gri
locUpdCnts[i] = spiCnt;
- spi.setListener(locHeartbeatLsnr);
+ spi.setListener(locMetricsUpdateLsnr);
i++;
}
- // Sleep fro 3 Heartbeats.
+ // Sleep for 3 metrics update.
Thread.sleep(getMaxDiscoveryTime() * 3);
- for (AtomicInteger cnt : locUpdCnts) {
- assert cnt.get() > 1 : "One of the SPIs did not get at least 2 METRICS_UPDATE events from local node";
- }
+ for (AtomicInteger cnt : locUpdCnts)
+ assertTrue("One of the SPIs did not get at least 2 METRICS_UPDATE events from local node", cnt.get() > 1);
}
/**
@@ -491,9 +490,9 @@ public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends Gri
}
for (IgniteTestResources rscrs : spiRsrcs) {
- MBeanServer mBeanServer = rscrs.getMBeanServer();
+ MBeanServer mBeanSrv = rscrs.getMBeanServer();
- mBeanServer.unregisterMBean(new ObjectName(HTTP_ADAPTOR_MBEAN_NAME));
+ mBeanSrv.unregisterMBean(new ObjectName(HTTP_ADAPTOR_MBEAN_NAME));
rscrs.stopThreads();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
index a0545f5..689ac72 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiFailureTimeoutSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.spi.discovery.tcp;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
@@ -28,15 +29,18 @@ import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingRequest;
import org.jetbrains.annotations.Nullable;
@@ -53,8 +57,14 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
private final static long FAILURE_THRESHOLD = 10_000;
/** */
+ private final static long CLIENT_FAILURE_THRESHOLD = 30_000;
+
+ /** Failure detection timeout for nodes configuration. */
private static long failureThreshold = FAILURE_THRESHOLD;
+ /** Client failure detection timeout for nodes configuration. */
+ private static long clientFailureThreshold = CLIENT_FAILURE_THRESHOLD;
+
/** */
private static boolean useTestSpi;
@@ -64,6 +74,11 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
}
/** {@inheritDoc} */
+ @Override protected long clientFailureDetectionTimeout() {
+ return clientFailureThreshold;
+ }
+
+ /** {@inheritDoc} */
@Override protected long failureDetectionTimeout() {
return failureThreshold;
}
@@ -74,6 +89,11 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
}
/** {@inheritDoc} */
+ @Override protected long awaitClientTime() {
+ return clientFailureDetectionTimeout() + FAILURE_AWAIT_TIME;
+ }
+
+ /** {@inheritDoc} */
@Override protected TcpDiscoverySpi getDiscoverySpi() {
return useTestSpi ? new TestTcpDiscoverySpi2() : super.getDiscoverySpi();
}
@@ -88,12 +108,12 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
checkNodes(1, 1);
assertTrue(((TcpDiscoverySpi)(G.ignite("server-0").configuration().getDiscoverySpi())).
- failureDetectionTimeoutEnabled());
+ failureDetectionTimeoutEnabled());
assertEquals(failureDetectionTimeout(),
((TcpDiscoverySpi)(G.ignite("server-0").configuration().getDiscoverySpi())).failureDetectionTimeout());
assertTrue(((TcpDiscoverySpi)(G.ignite("client-0").configuration().getDiscoverySpi())).
- failureDetectionTimeoutEnabled());
+ failureDetectionTimeoutEnabled());
assertEquals(failureDetectionTimeout(),
((TcpDiscoverySpi)(G.ignite("client-0").configuration().getDiscoverySpi())).failureDetectionTimeout());
}
@@ -127,6 +147,123 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
}
/**
+ * Test failure detection time between server and client if client fail with failure detection.
+ *
+ * @throws Exception in case of error.
+ */
+ public void testFailureTimeoutServerClient() throws Exception {
+ failureThreshold = 3000;
+ clientFailureThreshold = 2000;
+
+ try {
+ startServerNodes(1);
+
+ startClientNodes(1);
+
+ checkNodes(1, 1);
+
+ Ignite srvNode = G.ignite("server-0");
+ final TcpDiscoverySpi srvSpi = (TcpDiscoverySpi) srvNode.configuration().getDiscoverySpi();
+
+ Ignite clientNode = G.ignite("client-0");
+ final TcpDiscoverySpi clientSpi = (TcpDiscoverySpi)clientNode.configuration().getDiscoverySpi();
+
+ long failureTime = U.currentTimeMillis();
+
+ final long[] failureDetectTime = new long[1];
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ clientSpi.simulateNodeFailure();
+
+ srvNode.events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ failureDetectTime[0] = U.currentTimeMillis();
+
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+
+ assertTrue("Can't get node failure event", latch.await(15000, TimeUnit.MILLISECONDS));
+
+ long detectTime = failureDetectTime[0] - failureTime;
+
+ assertTrue("Client node failure detected too fast: " + detectTime + "ms",
+ detectTime > clientFailureThreshold - 200);
+ assertTrue("Client node failure detected too slow: " + detectTime + "ms",
+ detectTime < clientFailureThreshold + 5000);
+ }
+ finally {
+ failureThreshold = FAILURE_THRESHOLD;
+ clientFailureThreshold = CLIENT_FAILURE_THRESHOLD;
+ }
+ }
+
+ /**
+ * Test failure detection time between servers with failure detection.
+ *
+ * @throws Exception in case of error.
+ */
+ public void testFailureTimeout3Server() throws Exception {
+ failureThreshold = 1000;
+ clientFailureThreshold = 10000;
+ useTestSpi = true;
+
+ try {
+ startServerNodes(3);
+
+ checkNodes(3, 0);
+
+ Ignite srv0 = G.ignite("server-0");
+ final TestTcpDiscoverySpi2 spi0 = (TestTcpDiscoverySpi2)srv0.configuration().getDiscoverySpi();
+
+ final Ignite srv1 = G.ignite("server-1");
+ final TestTcpDiscoverySpi2 spi1 = (TestTcpDiscoverySpi2)srv1.configuration().getDiscoverySpi();
+
+ Ignite srv2 = G.ignite("server-2");
+ final TestTcpDiscoverySpi2 spi2 = (TestTcpDiscoverySpi2)srv2.configuration().getDiscoverySpi();
+
+ long failureTime = U.currentTimeMillis();
+
+ final AtomicLong failureDetectTime = new AtomicLong();
+ final CountDownLatch latch = new CountDownLatch(2);
+
+ spi1.writeToSocketDelay = 2000;
+
+ for (Ignite srv : new Ignite[]{srv0, srv2}) {
+ srv.events().localListen(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ DiscoveryEvent evt0 = (DiscoveryEvent)evt;
+
+ assertEquals(srv1.cluster().localNode().id(), evt0.eventNode().id());
+
+ failureDetectTime.compareAndSet(0, U.currentTimeMillis());
+
+ latch.countDown();
+
+ return true;
+ }
+ }, EVT_NODE_FAILED);
+ }
+
+ assertTrue("Can't get node failure event", latch.await(15000, TimeUnit.MILLISECONDS));
+
+ long detectTime = failureDetectTime.get() - failureTime;
+
+ assertTrue("Server node failure detected too fast: " + detectTime + "ms",
+ detectTime > failureThreshold - 100);
+ assertTrue("Server node failure detected too slow: " + detectTime + "ms",
+ detectTime < clientFailureThreshold);
+ }
+ finally {
+ failureThreshold = FAILURE_THRESHOLD;
+ clientFailureThreshold = CLIENT_FAILURE_THRESHOLD;
+ useTestSpi = false;
+ }
+ }
+
+ /**
* @throws Exception in case of error.
*/
private void checkFailureThresholdWorkability() throws Exception {
@@ -288,15 +425,114 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
*/
private static class TestTcpDiscoverySpi2 extends TcpDiscoverySpi {
/** */
- private long readDelay;
+ private volatile long readDelay;
+
+ private volatile long writeToSocketDelay;
/** */
private Exception err;
+ /** */
+ @Override protected void writeToSocket(
+ Socket sock,
+ TcpDiscoveryAbstractMessage msg,
+ byte[] data,
+ long timeout
+ ) throws IOException {
+ if (writeToSocketDelay > 0) {
+ try {
+ U.dumpStack(log, "Before sleep [msg=" + msg +
+ ", arrLen=" + (data != null ? data.length : "n/a") + ']');
+
+ Thread.sleep(writeToSocketDelay);
+ }
+ catch (InterruptedException e) {
+ // Nothing to do.
+ }
+ }
+
+ if (sock.getSoTimeout() >= writeToSocketDelay)
+ super.writeToSocket(sock, msg, data, timeout);
+ else
+ throw new SocketTimeoutException("Write to socket delay timeout exception.");
+ }
+
+ /** */
+ @Override protected void writeToSocket(Socket sock,
+ OutputStream out,
+ TcpDiscoveryAbstractMessage msg,
+ long timeout) throws IOException, IgniteCheckedException {
+ if (writeToSocketDelay > 0) {
+ try {
+ U.dumpStack(log, "Before sleep [msg=" + msg + ']');
+
+ Thread.sleep(writeToSocketDelay);
+ }
+ catch (InterruptedException e) {
+ // Nothing to do.
+ }
+ }
+
+ if (sock.getSoTimeout() >= writeToSocketDelay)
+ super.writeToSocket(sock, out, msg, timeout);
+ else
+ throw new SocketTimeoutException("Write to socket delay timeout exception.");
+ }
+
+ /** */
+ @Override protected void writeToSocket(
+ Socket sock,
+ TcpDiscoveryAbstractMessage msg,
+ long timeout
+ ) throws IOException, IgniteCheckedException {
+ if (writeToSocketDelay > 0) {
+ try {
+ U.dumpStack(log, "Before sleep [msg=" + msg + ']');
+
+ Thread.sleep(writeToSocketDelay);
+ }
+ catch (InterruptedException e) {
+ // Nothing to do.
+ }
+ }
+
+ if (sock.getSoTimeout() >= writeToSocketDelay)
+ super.writeToSocket(sock, msg, timeout);
+ else
+ throw new SocketTimeoutException("Write to socket delay timeout exception.");
+ }
+
+ /** */
+ @Override protected void writeToSocket(
+ TcpDiscoveryAbstractMessage msg,
+ Socket sock,
+ int res,
+ long timeout
+ ) throws IOException {
+ if (writeToSocketDelay > 0) {
+ try {
+ U.dumpStack(log, "Before sleep [msg=" + msg + ']');
+
+ Thread.sleep(writeToSocketDelay);
+ }
+ catch (InterruptedException e) {
+ // Nothing to do.
+ }
+ }
+
+ if (sock.getSoTimeout() >= writeToSocketDelay)
+ super.writeToSocket(msg, sock, res, timeout);
+ else
+ throw new SocketTimeoutException("Write to socket delay timeout exception.");
+ }
+
/** {@inheritDoc} */
@Override protected <T> T readMessage(Socket sock, @Nullable InputStream in, long timeout)
throws IOException, IgniteCheckedException {
- if (readDelay < failureDetectionTimeout()) {
+ long currTimeout = getLocalNode().isClient() ?
+ clientFailureDetectionTimeout() : failureDetectionTimeout();
+
+ if (readDelay < currTimeout) {
try {
return super.readMessage(sock, in, timeout);
}
@@ -329,6 +565,7 @@ public class TcpClientDiscoverySpiFailureTimeoutSelfTest extends TcpClientDiscov
*/
private void reset() {
readDelay = 0;
+ writeToSocketDelay = 0;
err = null;
}
}
[38/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
new file mode 100644
index 0000000..0010425
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
@@ -0,0 +1,242 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.Map;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest;
+import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.resource.transaction.spi.TransactionStatus;
+
+/**
+ * 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())
+ assertEquals(TransactionStatus.ACTIVE, tx.getStatus());
+ else
+ assertFalse("Unexpected status: " + tx.getStatus(), tx.getStatus() == TransactionStatus.ACTIVE);
+
+ 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(strategy = GenerationType.IDENTITY)
+ @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(strategy = GenerationType.IDENTITY)
+ @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;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
new file mode 100644
index 0000000..3822b31
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- Show SQL. -->
+ <property name="show_sql">true</property>
+
+ <!-- Database connection settings (private in-memory database). -->
+ <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
+
+ <!-- Only validate the database schema on startup in production mode. -->
+ <property name="hbm2ddl.auto">update</property>
+
+ <!-- H2 dialect. -->
+ <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
+
+ <!-- Mappings. -->
+ <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/>
+ </session-factory>
+</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
new file mode 100644
index 0000000..8af9886
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains internal tests or test related classes and interfaces.
+ */
+package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
new file mode 100644
index 0000000..d539511
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
@@ -0,0 +1,37 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ *
+ */
+public class IgniteBinaryHibernate5TestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+ return IgniteHibernate5TestSuite.suite();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
new file mode 100644
index 0000000..3d7c4ee
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
@@ -0,0 +1,57 @@
+/*
+ * 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.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest;
+import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest;
+import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest;
+
+/**
+ * Hibernate integration tests.
+ */
+public class IgniteHibernate5TestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Hibernate5 Integration Test Suite");
+
+ // Hibernate L2 cache.
+ suite.addTestSuite(HibernateL2CacheSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class);
+ suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class);
+
+ suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class);
+
+ suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class);
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/pom.xml b/modules/hibernate-core/pom.xml
new file mode 100644
index 0000000..91ec68b
--- /dev/null
+++ b/modules/hibernate-core/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
new file mode 100644
index 0000000..557b018
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
@@ -0,0 +1,340 @@
+/*
+ * 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.hibernate;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Common interface used to implement Hibernate L2 cache access strategies.
+ * <p>
+ * The expected sequences of steps related to various CRUD operations executed by Hibernate are:
+ * <p>
+ * Insert:
+ * <ul>
+ * <li>Start DB transaction.</li>
+ * <li>Execute database insert.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#insert}.</li>
+ * <li>Commit DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#afterInsert}.</li>
+ * </ul>
+ * In case if some step fails and DB transaction is rolled back then
+ * {@link HibernateAccessStrategyAdapter#afterInsert} is not called.
+ * <p>
+ * Update:
+ * <ul>
+ * <li>Start DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#lock}.</li>
+ * <li>Execute database update.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#update}.</li>
+ * <li>Commit DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#afterUpdate}.</li>
+ * </ul>
+ * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
+ * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
+ * <p>
+ * Delete:
+ * <ul>
+ * <li>Start DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#lock} for removing key.</li>
+ * <li>Execute database delete.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#remove}.</li>
+ * <li>Commit DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#unlock}.</li>
+ * </ul>
+ * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
+ * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
+ * <p>
+ * In case if custom SQL update query is executed Hibernate clears entire cache region,
+ * for this case operations sequence is:
+ * <ul>
+ * <li>Start DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#lockRegion}.</li>
+ * <li>Execute database query.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#removeAll}.</li>
+ * <li>Commit DB transaction.</li>
+ * <li>Call {@link HibernateAccessStrategyAdapter#unlockRegion}.</li>
+ * </ul>
+ */
+public abstract class HibernateAccessStrategyAdapter {
+ /** */
+ protected final HibernateCacheProxy cache;
+
+ /** */
+ private final HibernateExceptionConverter eConverter;
+
+ /** Grid. */
+ protected final Ignite ignite;
+
+ /** */
+ protected final IgniteLogger log;
+
+ /**
+ * @param ignite Node.
+ * @param cache Cache.
+ * @param eConverter Exception converter.
+ */
+ protected HibernateAccessStrategyAdapter(Ignite ignite,
+ HibernateCacheProxy cache,
+ HibernateExceptionConverter eConverter) {
+ this.cache = cache;
+ this.ignite = ignite;
+ this.eConverter = eConverter;
+
+ log = ignite.log().getLogger(getClass());
+ }
+
+ /**
+ * @param e Exception.
+ * @return Runtime exception to be thrown.
+ */
+ final RuntimeException convertException(Exception e) {
+ return eConverter.convert(e);
+ }
+
+ /**
+ * @param key Key.
+ * @return Cached value.
+ */
+ @Nullable public Object get(Object key) {
+ try {
+ return cache.get(key);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /**
+ * @param key Key.
+ * @param val Value.
+ * @param minimalPutOverride MinimalPut flag
+ */
+ public void putFromLoad(Object key, Object val, boolean minimalPutOverride) {
+ putFromLoad(key, val);
+ }
+
+ /**
+ * Puts in cache value loaded from the database.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ public void putFromLoad(Object key, Object val) {
+ try {
+ cache.put(key, val);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /**
+ * Called during database transaction execution before Hibernate attempts to update or remove given key.
+ *
+ * @param key Key.
+ */
+ public abstract void lock(Object key);
+
+ /**
+ * Called after Hibernate failed to update or successfully removed given key.
+ *
+ * @param key Key.
+ */
+ public abstract void unlock(Object key);
+
+ /**
+ * Called after Hibernate updated object in the database but before transaction completed.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return {@code True} if operation updated cache.
+ */
+ public abstract boolean update(Object key, Object val);
+
+ /**
+ * Called after Hibernate updated object in the database and transaction successfully completed.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return {@code True} if operation updated cache.
+ */
+ public abstract boolean afterUpdate(Object key, Object val);
+
+ /**
+ * Called after Hibernate inserted object in the database but before transaction completed.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return {@code True} if operation updated cache.
+ */
+ public abstract boolean insert(Object key, Object val);
+
+ /**
+ * Called after Hibernate inserted object in the database and transaction successfully completed.
+ *
+ * @param key Key.
+ * @param val Value.
+ * @return {@code True} if operation updated cache.
+ */
+ public abstract boolean afterInsert(Object key, Object val);
+
+ /**
+ * Called after Hibernate removed object from database but before transaction completed.
+ *
+ * @param key Key,
+ */
+ public abstract void remove(Object key);
+
+ /**
+ * Called to remove object from cache without regard to transaction.
+ *
+ * @param key Key.
+ */
+ public void evict(Object key) {
+ evict(ignite, cache, key);
+ }
+
+ /**
+ * Called to remove all data from cache without regard to transaction.
+ */
+ public void evictAll() {
+ try {
+ evictAll(cache);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /**
+ * Called during database transaction execution to clear entire cache region after
+ * Hibernate executed database update, but before transaction completed.
+ */
+ public final void removeAll() {
+ evictAll();
+ }
+
+ /**
+ * Called during database transaction execution before Hibernate executed
+ * update operation which should invalidate entire cache region.
+ */
+ public void lockRegion() {
+ // No-op.
+ }
+
+ /**
+ * Called after transaction clearing entire cache region completed.
+ */
+ public void unlockRegion() {
+ // No-op.
+ }
+
+ /**
+ * Called to remove object from cache without regard to transaction.
+ *
+ * @param ignite Grid.
+ * @param cache Cache.
+ * @param key Key.
+ */
+ public static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) {
+ key = cache.keyTransformer().transform(key);
+
+ ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name()));
+ }
+
+ /**
+ * Called to remove all data from cache without regard to transaction.
+ *
+ * @param cache Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ public static void evictAll(IgniteInternalCache<Object, Object> cache) throws IgniteCheckedException {
+ cache.clear();
+ }
+
+ /**
+ * Callable invalidates given key.
+ */
+ private static class ClearKeyCallable implements IgniteCallable<Void>, Externalizable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ private Object key;
+
+ /** */
+ private String cacheName;
+
+ /**
+ * Empty constructor required by {@link Externalizable}.
+ */
+ public ClearKeyCallable() {
+ // No-op.
+ }
+
+ /**
+ * @param key Key to clear.
+ * @param cacheName Cache name.
+ */
+ private ClearKeyCallable(Object key, String cacheName) {
+ this.key = key;
+ this.cacheName = cacheName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Void call() throws IgniteCheckedException {
+ IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
+
+ assert cache != null;
+
+ cache.clearLocally(key);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(key);
+
+ U.writeString(out, cacheName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ key = in.readObject();
+
+ cacheName = U.readString(in);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java
new file mode 100644
index 0000000..0226c1c
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyFactory.java
@@ -0,0 +1,235 @@
+/*
+ * 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.hibernate;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.util.typedef.G;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+
+/**
+ * Access strategy factory.
+ */
+public class HibernateAccessStrategyFactory {
+ /** */
+ private final HibernateKeyTransformer keyTransformer;
+
+ /** */
+ private final HibernateExceptionConverter eConverter;
+
+ /**
+ * Hibernate L2 cache grid name property name.
+ *
+ * @deprecated Use {@link #IGNITE_INSTANCE_NAME_PROPERTY}.
+ * If {@link #IGNITE_INSTANCE_NAME_PROPERTY} is specified it takes precedence.
+ */
+ @Deprecated
+ public static final String GRID_NAME_PROPERTY = "org.apache.ignite.hibernate.grid_name";
+
+ /** Hibernate L2 cache Ignite instance name property name. */
+ public static final String IGNITE_INSTANCE_NAME_PROPERTY = "org.apache.ignite.hibernate.ignite_instance_name";
+
+ /** Default cache property name. */
+ public static final String DFLT_CACHE_NAME_PROPERTY = "org.apache.ignite.hibernate.default_cache";
+
+ /** Property prefix used to specify region name to cache name mapping. */
+ public static final String REGION_CACHE_PROPERTY = "org.apache.ignite.hibernate.region_cache.";
+
+ /** */
+ public static final String DFLT_ACCESS_TYPE_PROPERTY = "org.apache.ignite.hibernate.default_access_type";
+
+ /** */
+ public static final String GRID_CONFIG_PROPERTY = "org.apache.ignite.hibernate.grid_config";
+
+ /** Grid providing caches. */
+ private Ignite ignite;
+
+ /** Default cache. */
+ private HibernateCacheProxy dfltCache;
+
+ /** Region name to cache name mapping. */
+ private final Map<String, String> regionCaches = new HashMap<>();
+
+ /** */
+ private final ThreadLocal threadLoc = new ThreadLocal();
+
+ /** */
+ private final ConcurrentHashMap<String, ThreadLocal> threadLocMap = new ConcurrentHashMap<>();
+
+ /**
+ * @param keyTransformer Key transformer.
+ * @param eConverter Exception converter.
+ */
+ HibernateAccessStrategyFactory(HibernateKeyTransformer keyTransformer, HibernateExceptionConverter eConverter) {
+ this.keyTransformer = keyTransformer;
+ this.eConverter = eConverter;
+ }
+
+ /**
+ * @param props Properties.
+ */
+ public void start(Properties props) {
+ String gridCfg = props.getProperty(GRID_CONFIG_PROPERTY);
+ String igniteInstanceName = props.getProperty(IGNITE_INSTANCE_NAME_PROPERTY);
+
+ if (igniteInstanceName == null)
+ igniteInstanceName = props.getProperty(GRID_NAME_PROPERTY);
+
+ if (gridCfg != null) {
+ try {
+ ignite = G.start(gridCfg);
+ }
+ catch (IgniteException e) {
+ throw eConverter.convert(e);
+ }
+ }
+ else
+ ignite = Ignition.ignite(igniteInstanceName);
+
+ for (Map.Entry<Object, Object> prop : props.entrySet()) {
+ String key = prop.getKey().toString();
+
+ if (key.startsWith(REGION_CACHE_PROPERTY)) {
+ String regionName = key.substring(REGION_CACHE_PROPERTY.length());
+
+ String cacheName = prop.getValue().toString();
+
+ if (((IgniteKernal)ignite).getCache(cacheName) == null)
+ throw new IllegalArgumentException("Cache '" + cacheName + "' specified for region '" + regionName + "' " +
+ "is not configured.");
+
+ regionCaches.put(regionName, cacheName);
+ }
+ }
+
+ String dfltCacheName = props.getProperty(DFLT_CACHE_NAME_PROPERTY);
+
+ if (dfltCacheName != null) {
+ IgniteInternalCache<Object, Object> dfltCache = ((IgniteKernal)ignite).getCache(dfltCacheName);
+
+ if (dfltCache == null)
+ throw new IllegalArgumentException("Cache specified as default is not configured: " + dfltCacheName);
+
+ this.dfltCache = new HibernateCacheProxy(dfltCache, keyTransformer);
+ }
+
+ IgniteLogger log = ignite.log().getLogger(getClass());
+
+ if (log.isDebugEnabled())
+ log.debug("HibernateRegionFactory started [igniteInstanceName=" + igniteInstanceName + ']');
+ }
+
+ /**
+ * @return Ignite node.
+ */
+ public Ignite node() {
+ return ignite;
+ }
+
+ /**
+ * @param regionName L2 cache region name.
+ * @return Cache for given region.
+ */
+ HibernateCacheProxy regionCache(String regionName) {
+ String cacheName = regionCaches.get(regionName);
+
+ if (cacheName == null) {
+ if (dfltCache != null)
+ return dfltCache;
+
+ cacheName = regionName;
+ }
+
+ IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
+
+ if (cache == null)
+ throw new IllegalArgumentException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured.");
+
+ return new HibernateCacheProxy(cache, keyTransformer);
+ }
+
+ /**
+ * @param cache Cache.
+ * @return Access strategy implementation.
+ */
+ HibernateAccessStrategyAdapter createReadOnlyStrategy(HibernateCacheProxy cache) {
+ return new HibernateReadOnlyAccessStrategy(ignite, cache, eConverter);
+ }
+
+ /**
+ * @param cache Cache.
+ * @return Access strategy implementation.
+ */
+ HibernateAccessStrategyAdapter createNonStrictReadWriteStrategy(HibernateCacheProxy cache) {
+ ThreadLocal threadLoc = threadLocMap.get(cache.name());
+
+ if (threadLoc == null) {
+ ThreadLocal old = threadLocMap.putIfAbsent(cache.name(), threadLoc = new ThreadLocal());
+
+ if (old != null)
+ threadLoc = old;
+ }
+
+ return new HibernateNonStrictAccessStrategy(ignite, cache, threadLoc, eConverter);
+ }
+
+ /**
+ * @param cache Cache.
+ * @return Access strategy implementation.
+ */
+ HibernateAccessStrategyAdapter createReadWriteStrategy(HibernateCacheProxy cache) {
+ if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
+ throw new IllegalArgumentException("Hibernate READ-WRITE access strategy must have Ignite cache with " +
+ "'TRANSACTIONAL' atomicity mode: " + cache.name());
+
+ return new HibernateReadWriteAccessStrategy(ignite, cache, threadLoc, eConverter);
+ }
+
+ /**
+ * @param cache Cache.
+ * @return Access strategy implementation.
+ */
+ HibernateAccessStrategyAdapter createTransactionalStrategy(HibernateCacheProxy cache) {
+ if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
+ throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " +
+ "'TRANSACTIONAL' atomicity mode: " + cache.name());
+
+ TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration();
+
+ if (txCfg == null ||
+ (txCfg.getTxManagerFactory() == null
+ && txCfg.getTxManagerLookupClassName() == null
+ && cache.configuration().getTransactionManagerLookupClassName() == null)) {
+ throw new IllegalArgumentException("Hibernate TRANSACTIONAL access strategy must have Ignite with " +
+ "Factory<TransactionManager> configured (see IgniteConfiguration." +
+ "getTransactionConfiguration().setTxManagerFactory()): " + cache.name());
+ }
+
+ return new HibernateTransactionalAccessStrategy(ignite, cache, eConverter);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
new file mode 100644
index 0000000..3d439dd
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
@@ -0,0 +1,801 @@
+/*
+ * 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.hibernate;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import javax.cache.Cache;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.cache.CacheMetrics;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.mxbean.CacheMetricsMXBean;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Hibernate cache proxy used to substitute hibernate keys with ignite keys.
+ */
+public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> {
+ /** Delegate. */
+ private final IgniteInternalCache<Object, Object> delegate;
+
+ /** Transformer. */
+ private final HibernateKeyTransformer keyTransformer;
+
+ /**
+ * @param delegate Delegate.
+ * @param keyTransformer Key keyTransformer.
+ */
+ HibernateCacheProxy(
+ IgniteInternalCache<Object, Object> delegate,
+ HibernateKeyTransformer keyTransformer
+ ) {
+ assert delegate != null;
+ assert keyTransformer != null;
+
+ this.delegate = delegate;
+ this.keyTransformer = keyTransformer;
+ }
+
+ /**
+ * @return HibernateKeyTransformer
+ */
+ public HibernateKeyTransformer keyTransformer(){
+ return keyTransformer;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String name() {
+ return delegate.name();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean skipStore() {
+ return delegate.skipStore();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache setSkipStore(boolean skipStore) {
+ return delegate.setSkipStore(skipStore);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isEmpty() {
+ return delegate.isEmpty();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsKey(Object key) {
+ return delegate.containsKey(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> containsKeyAsync(Object key) {
+ return delegate.containsKeyAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsKeys(Collection keys) {
+ return delegate.containsKey(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection keys) {
+ return delegate.containsKeysAsync(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object localPeek(
+ Object key,
+ CachePeekMode[] peekModes,
+ @Nullable IgniteCacheExpiryPolicy plc
+ ) throws IgniteCheckedException {
+ return delegate.localPeek(keyTransformer.transform(key), peekModes, plc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable<Cache.Entry<Object, Object>> localEntries(
+ CachePeekMode[] peekModes
+ ) throws IgniteCheckedException {
+ return delegate.localEntries(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key) throws IgniteCheckedException {
+ return delegate.get(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public CacheEntry getEntry(Object key) throws IgniteCheckedException {
+ return delegate.getEntry(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getAsync(Object key) {
+ return delegate.getAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<CacheEntry<Object, Object>> getEntryAsync(Object key) {
+ return delegate.getEntryAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map getAll(@Nullable Collection keys) throws IgniteCheckedException {
+ return delegate.getAll(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<CacheEntry<Object, Object>> getEntries(
+ @Nullable Collection keys) throws IgniteCheckedException {
+ return delegate.getEntries(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Map<Object, Object>> getAllAsync(@Nullable Collection keys) {
+ return delegate.getAllAsync(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Collection<CacheEntry<Object,Object>>> getEntriesAsync(
+ @Nullable Collection keys
+ ) {
+ return delegate.getEntriesAsync(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException {
+ return delegate.getAndPut(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getAndPutAsync(Object key, Object val) {
+ return delegate.getAndPutAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean put(Object key, Object val) throws IgniteCheckedException {
+ return delegate.put(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> putAsync(Object key, Object val) {
+ return delegate.putAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException {
+ return delegate.getAndPutIfAbsent(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getAndPutIfAbsentAsync(Object key, Object val) {
+ return delegate.getAndPutIfAbsentAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putIfAbsent(Object key, Object val) throws IgniteCheckedException {
+ return delegate.putIfAbsent(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(Object key, Object val) {
+ return delegate.putIfAbsentAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getAndReplace(Object key, Object val) throws IgniteCheckedException {
+ return delegate.getAndReplace(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getAndReplaceAsync(Object key, Object val) {
+ return delegate.getAndReplaceAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(Object key, Object val) throws IgniteCheckedException {
+ return delegate.replace(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object val) {
+ return delegate.replaceAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean replace(Object key, Object oldVal, Object newVal) throws IgniteCheckedException {
+ return delegate.replace(keyTransformer.transform(key), oldVal, newVal);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object oldVal, Object newVal) {
+ return delegate.replaceAsync(keyTransformer.transform(key), oldVal, newVal);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void putAll(@Nullable Map m) throws IgniteCheckedException {
+ delegate.putAll(transform(m));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> putAllAsync(@Nullable Map m) {
+ return delegate.putAllAsync(transform(m));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set keySet() {
+ return delegate.keySet();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set keySetx() {
+ return delegate.keySetx();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set primaryKeySet() {
+ return delegate.primaryKeySet();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterable values() {
+ return delegate.values();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set<Cache.Entry<Object, Object>> entrySet() {
+ return delegate.entrySet();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Set<Cache.Entry<Object,Object>> entrySet(int part) {
+ return delegate.entrySet(part);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set<Cache.Entry<Object, Object>> entrySetx(CacheEntryPredicate... filter) {
+ return delegate.entrySetx(filter);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Transaction txStart(
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation
+ ) {
+ return delegate.txStart(concurrency, isolation);
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridNearTxLocal txStartEx(
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation
+ ) {
+ return delegate.txStartEx(concurrency, isolation);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Transaction txStart(
+ TransactionConcurrency concurrency,
+ TransactionIsolation isolation,
+ long timeout,
+ int txSize
+ ) {
+ return delegate.txStart(concurrency, isolation, timeout, txSize);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public GridNearTxLocal tx() {
+ return delegate.tx();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean evict(Object key) {
+ return delegate.evict(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll(@Nullable Collection keys) {
+ delegate.evictAll(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
+ delegate.clearLocally(srv, near, readers);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean clearLocally(Object key) {
+ return delegate.clearLocally(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearLocallyAll(Set keys, boolean srv, boolean near, boolean readers) {
+ delegate.clearLocallyAll((Set<?>)transform(keys), srv, near, readers);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear(Object key) throws IgniteCheckedException {
+ delegate.clear(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clearAll(Set keys) throws IgniteCheckedException {
+ delegate.clearAll((Set<?>)transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear() throws IgniteCheckedException {
+ delegate.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> clearAsync() {
+ return delegate.clearAsync();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> clearAsync(Object key) {
+ return delegate.clearAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> clearAllAsync(Set keys) {
+ return delegate.clearAllAsync((Set<?>)transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getAndRemove(Object key) throws IgniteCheckedException {
+ return delegate.getAndRemove(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getAndRemoveAsync(Object key) {
+ return delegate.getAndRemoveAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean remove(Object key) throws IgniteCheckedException {
+ return delegate.remove(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> removeAsync(Object key) {
+ return delegate.removeAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean remove(Object key, Object val) throws IgniteCheckedException {
+ return delegate.remove(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> removeAsync(Object key, Object val) {
+ return delegate.removeAsync(keyTransformer.transform(key), val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll(@Nullable Collection keys) throws IgniteCheckedException {
+ delegate.removeAll(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection keys) {
+ return delegate.removeAllAsync(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll() throws IgniteCheckedException {
+ delegate.removeAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> removeAllAsync() {
+ return delegate.removeAllAsync();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException {
+ return delegate.lock(keyTransformer.transform(key), timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> lockAsync(Object key, long timeout) {
+ return delegate.lockAsync(keyTransformer.transform(key), timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean lockAll(@Nullable Collection keys, long timeout) throws IgniteCheckedException {
+ return delegate.lockAll(transform(keys), timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection keys, long timeout) {
+ return delegate.lockAllAsync(transform(keys), timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlock(Object key) throws IgniteCheckedException {
+ delegate.unlock(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockAll(@Nullable Collection keys) throws IgniteCheckedException {
+ delegate.unlockAll(transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isLocked(Object key) {
+ return delegate.isLocked(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isLockedByThread(Object key) {
+ return delegate.isLockedByThread(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public int size() {
+ return delegate.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long sizeLong() {
+ return delegate.sizeLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.localSize(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.localSizeLong(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.localSizeLong(partition, peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.size(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.sizeLong(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
+ return delegate.sizeLong(partition, peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) {
+ return delegate.sizeAsync(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes) {
+ return delegate.sizeLongAsync(peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Long> sizeLongAsync(int partition, CachePeekMode[] peekModes) {
+ return delegate.sizeLongAsync(partition, peekModes);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int nearSize() {
+ return delegate.nearSize();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int primarySize() {
+ return delegate.primarySize();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long primarySizeLong() {
+ return delegate.primarySizeLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheConfiguration configuration() {
+ return delegate.configuration();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Affinity affinity() {
+ return delegate.affinity();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheMetrics clusterMetrics() {
+ return delegate.clusterMetrics();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheMetrics clusterMetrics(ClusterGroup grp) {
+ return delegate.clusterMetrics(grp);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheMetrics localMetrics() {
+ return delegate.localMetrics();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheMetricsMXBean clusterMxBean() {
+ return delegate.clusterMxBean();
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheMetricsMXBean localMxBean() {
+ return delegate.localMxBean();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long offHeapEntriesCount() {
+ return delegate.offHeapEntriesCount();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long offHeapAllocatedSize() {
+ return delegate.offHeapAllocatedSize();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> rebalance() {
+ return delegate.rebalance();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache forSubjectId(UUID subjId) {
+ return delegate.forSubjectId(subjId);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getForcePrimary(Object key) throws IgniteCheckedException {
+ return delegate.getForcePrimary(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture getForcePrimaryAsync(Object key) {
+ return delegate.getForcePrimaryAsync(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map getAllOutTx(Set keys) throws IgniteCheckedException {
+ return delegate.getAllOutTx((Set<?>)transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Map<Object, Object>> getAllOutTxAsync(Set keys) {
+ return delegate.getAllOutTxAsync((Set<?>)transform(keys));
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isIgfsDataCache() {
+ return delegate.isIgfsDataCache();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long igfsDataSpaceUsed() {
+ return delegate.igfsDataSpaceUsed();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMongoDataCache() {
+ return delegate.isMongoDataCache();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMongoMetaCache() {
+ return delegate.isMongoMetaCache();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public ExpiryPolicy expiry() {
+ return delegate.expiry();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache withExpiryPolicy(ExpiryPolicy plc) {
+ return delegate.withExpiryPolicy(plc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache withNoRetries() {
+ return delegate.withNoRetries();
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridCacheContext context() {
+ return delegate.context();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void localLoadCache(
+ @Nullable IgniteBiPredicate p,
+ @Nullable Object... args
+ ) throws IgniteCheckedException {
+ delegate.localLoadCache(p, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> localLoadCacheAsync(
+ @Nullable IgniteBiPredicate p,
+ @Nullable Object... args
+ ) {
+ return delegate.localLoadCacheAsync(p, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object getTopologySafe(Object key) throws IgniteCheckedException {
+ return delegate.getTopologySafe(keyTransformer.transform(key));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Integer> lostPartitions() {
+ return delegate.lostPartitions();
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public EntryProcessorResult invoke(
+ @Nullable AffinityTopologyVersion topVer,
+ Object key,
+ EntryProcessor entryProcessor,
+ Object... args
+ ) throws IgniteCheckedException {
+ return delegate.invoke(topVer, key, entryProcessor, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Map> invokeAllAsync(Map map, Object... args) {
+ return delegate.invokeAllAsync(map, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map invokeAll(Map map, Object... args) throws IgniteCheckedException {
+ return delegate.invokeAll(map, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Map> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) {
+ return delegate.invokeAllAsync((Set<?>)transform(keys), entryProcessor, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map invokeAll(Set keys, EntryProcessor entryProcessor, Object... args) throws IgniteCheckedException {
+ return delegate.invokeAll((Set<?>)transform(keys), entryProcessor, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<EntryProcessorResult> invokeAsync(
+ Object key,
+ EntryProcessor entryProcessor,
+ Object... args
+ ) {
+ return delegate.invokeAsync(keyTransformer.transform(key), entryProcessor, args);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public EntryProcessorResult invoke(
+ Object key,
+ EntryProcessor entryProcessor,
+ Object... args
+ ) throws IgniteCheckedException {
+ return delegate.invoke(keyTransformer.transform(key), entryProcessor, args);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterator<Cache.Entry<Object,Object>> scanIterator(
+ boolean keepBinary,
+ @Nullable IgniteBiPredicate p
+ ) throws IgniteCheckedException {
+ return delegate.scanIterator(keepBinary, p);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map drMap) throws IgniteCheckedException {
+ return delegate.removeAllConflictAsync(drMap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAllConflict(Map drMap) throws IgniteCheckedException {
+ delegate.removeAllConflictAsync(drMap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<?> putAllConflictAsync(Map drMap) throws IgniteCheckedException {
+ return delegate.putAllConflictAsync(drMap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void putAllConflict(Map drMap) throws IgniteCheckedException {
+ delegate.putAllConflict(drMap);
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache keepBinary() {
+ return delegate.keepBinary();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalCache cache() {
+ return delegate.cache();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Iterator iterator() {
+ return delegate.iterator();
+ }
+
+ /**
+ * @param keys Keys.
+ */
+ private Collection<Object> transform(Collection<Object> keys) {
+ Collection<Object> res = new LinkedList<>();
+
+ for (Object o : keys)
+ res.add(keyTransformer.transform(o));
+
+ return res;
+ }
+
+ /**
+ * @param map Map.
+ */
+ private Map<Object, Object> transform(Map<Object, Object> map) {
+ Map<Object, Object> res = new HashMap<>();
+
+ Set<Map.Entry<Object, Object>> ents = map.entrySet();
+
+ for (Map.Entry<Object, Object> e : ents)
+ res.put(keyTransformer.transform(e.getKey()), e.getValue());
+
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateExceptionConverter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateExceptionConverter.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateExceptionConverter.java
new file mode 100644
index 0000000..110bec5
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateExceptionConverter.java
@@ -0,0 +1,29 @@
+/*
+ * 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.hibernate;
+
+/**
+ * Converts Ignite errors into Hibernate runtime exceptions.
+ */
+public interface HibernateExceptionConverter {
+ /**
+ * @param e Exception.
+ * @return Converted exception.
+ */
+ public RuntimeException convert(Exception e);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
new file mode 100644
index 0000000..97fc0e9
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
@@ -0,0 +1,29 @@
+/*
+ * 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.hibernate;
+
+/**
+ * An interface for transforming hibernate keys to Ignite keys.
+ */
+public interface HibernateKeyTransformer {
+ /**
+ * @param key Hibernate key.
+ * @return Transformed key.
+ */
+ public Object transform(Object key);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
new file mode 100644
index 0000000..06c6f3d
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
@@ -0,0 +1,230 @@
+/*
+ * 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.hibernate;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.util.GridLeanSet;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Implementation of NONSTRICT_READ_WRITE cache access strategy.
+ * <p>
+ * Configuration of L2 cache and per-entity cache access strategy can be set in the
+ * Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache access strategy can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateNonStrictAccessStrategy extends HibernateAccessStrategyAdapter {
+ /** */
+ private final ThreadLocal<WriteContext> writeCtx;
+
+ /**
+ * @param ignite Grid.
+ * @param cache Cache.
+ * @param writeCtx Thread local instance used to track updates done during one Hibernate transaction.
+ * @param eConverter Exception converter.
+ */
+ HibernateNonStrictAccessStrategy(Ignite ignite,
+ HibernateCacheProxy cache,
+ ThreadLocal writeCtx,
+ HibernateExceptionConverter eConverter) {
+ super(ignite, cache, eConverter);
+
+ this.writeCtx = (ThreadLocal<WriteContext>)writeCtx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void lock(Object key) {
+ WriteContext ctx = writeCtx.get();
+
+ if (ctx == null)
+ writeCtx.set(ctx = new WriteContext());
+
+ ctx.locked(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlock(Object key) {
+ try {
+ WriteContext ctx = writeCtx.get();
+
+ if (ctx != null && ctx.unlocked(key)) {
+ writeCtx.remove();
+
+ ctx.updateCache(cache);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val) {
+ WriteContext ctx = writeCtx.get();
+
+ if (ctx != null) {
+ ctx.updated(key, val);
+
+ unlock(key);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) {
+ try {
+ cache.put(key, val);
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) {
+ WriteContext ctx = writeCtx.get();
+
+ if (ctx != null)
+ ctx.removed(key);
+ }
+
+ /**
+ * Information about updates done during single database transaction.
+ */
+ @SuppressWarnings("TypeMayBeWeakened")
+ private static class WriteContext {
+ /** */
+ @GridToStringInclude
+ private Map<Object, Object> updates;
+
+ /** */
+ @GridToStringInclude
+ private Set<Object> rmvs;
+
+ /** */
+ @GridToStringInclude
+ private Set<Object> locked = new GridLeanSet<>();
+
+ /**
+ * Marks key as locked.
+ *
+ * @param key Key.
+ */
+ void locked(Object key) {
+ locked.add(key);
+ }
+
+ /**
+ * Marks key as unlocked.
+ *
+ * @param key Key.
+ * @return {@code True} if last locked key was unlocked.
+ */
+ boolean unlocked(Object key) {
+ locked.remove(key);
+
+ return locked.isEmpty();
+ }
+
+ /**
+ * Marks key as updated.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ void updated(Object key, Object val) {
+ if (updates == null)
+ updates = new LinkedHashMap<>();
+
+ updates.put(key, val);
+ }
+
+ /**
+ * Marks key as removed.
+ *
+ * @param key Key.
+ */
+ void removed(Object key) {
+ if (rmvs == null)
+ rmvs = new GridLeanSet<>();
+
+ rmvs.add(key);
+ }
+
+ /**
+ * Updates cache.
+ *
+ * @param cache Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ void updateCache(HibernateCacheProxy cache) throws IgniteCheckedException {
+ if (!F.isEmpty(rmvs))
+ cache.removeAll(rmvs);
+
+ if (!F.isEmpty(updates))
+ cache.putAll(updates);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(WriteContext.class, this);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
new file mode 100644
index 0000000..a0957fd
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
@@ -0,0 +1,105 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+
+/**
+ * Implementation of READ_ONLY cache access strategy.
+ * <p>
+ * Configuration of L2 cache and per-entity cache access strategy can be set in the
+ * Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with read-only access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="read-only"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache access strategy can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
+ * public class Entity { ... }
+ * </pre>
+ *
+ */
+public class HibernateReadOnlyAccessStrategy extends HibernateAccessStrategyAdapter {
+ /**
+ * @param ignite Node.
+ * @param cache Cache.
+ * @param eConverter Exception converter.
+ */
+ public HibernateReadOnlyAccessStrategy(Ignite ignite,
+ HibernateCacheProxy cache,
+ HibernateExceptionConverter eConverter) {
+ super(ignite, cache, eConverter);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) {
+ try {
+ cache.put(key, val);
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void lock(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlock(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) {
+ throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val) {
+ throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
+ }
+}
\ No newline at end of file
[29/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
deleted file mode 100644
index c4d6120..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
+++ /dev/null
@@ -1,241 +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 java.io.Serializable;
-import java.util.Map;
-import javax.cache.Cache;
-import javax.cache.configuration.Factory;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest;
-import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
-import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-
-/**
- * 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(strategy = GenerationType.IDENTITY)
- @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(strategy = GenerationType.IDENTITY)
- @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;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
deleted file mode 100644
index 3822b31..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
- <session-factory>
- <!-- Show SQL. -->
- <property name="show_sql">true</property>
-
- <!-- Database connection settings (private in-memory database). -->
- <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
- <!-- Only validate the database schema on startup in production mode. -->
- <property name="hbm2ddl.auto">update</property>
-
- <!-- H2 dialect. -->
- <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
-
- <!-- Mappings. -->
- <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/>
- </session-factory>
-</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
deleted file mode 100644
index 8af9886..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +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 description. -->
- * Contains internal tests or test related classes and interfaces.
- */
-package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java b/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
deleted file mode 100644
index d539511..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernate5TestSuite.java
+++ /dev/null
@@ -1,37 +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.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.testframework.config.GridTestProperties;
-
-/**
- *
- */
-public class IgniteBinaryHibernate5TestSuite extends TestSuite {
- /**
- * @return Test suite.
- * @throws Exception If failed.
- */
- public static TestSuite suite() throws Exception {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
-
- return IgniteHibernate5TestSuite.suite();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java b/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
deleted file mode 100644
index 3d7c4ee..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/testsuites/IgniteHibernate5TestSuite.java
+++ /dev/null
@@ -1,57 +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.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest;
-
-/**
- * Hibernate integration tests.
- */
-public class IgniteHibernate5TestSuite extends TestSuite {
- /**
- * @return Test suite.
- * @throws Exception Thrown in case of the failure.
- */
- public static TestSuite suite() throws Exception {
- TestSuite suite = new TestSuite("Hibernate5 Integration Test Suite");
-
- // Hibernate L2 cache.
- suite.addTestSuite(HibernateL2CacheSelfTest.class);
- suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class);
- suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class);
- suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class);
-
- suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class);
-
- suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class);
-
- suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class);
-
- suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class);
-
- return suite;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/osgi-karaf/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/modules/osgi-karaf/src/main/resources/features.xml b/modules/osgi-karaf/src/main/resources/features.xml
index f6bdf2b..9846d97 100644
--- a/modules/osgi-karaf/src/main/resources/features.xml
+++ b/modules/osgi-karaf/src/main/resources/features.xml
@@ -110,7 +110,7 @@
NOTE: Take into account that certain parts of Hibernate are offered under the LGPL license.]]>
</details>
<feature>hibernate</feature>
- <bundle start="true">mvn:org.apache.ignite/ignite-hibernate/${project.version}</bundle>
+ <bundle start="true">mvn:org.apache.ignite/ignite-hibernate_4.2/${project.version}</bundle>
</feature>
<feature name="ignite-indexing" version="${project.version}" description="Apache Ignite :: Indexing">
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index e1bb73e..8a05342 100644
--- a/pom.xml
+++ b/pom.xml
@@ -91,6 +91,7 @@
<module>modules/flink</module>
<module>modules/kubernetes</module>
<module>modules/zeromq</module>
+ <module>modules/hibernate-core</module>
</modules>
<profiles>
@@ -100,8 +101,8 @@
<module>examples</module>
<module>modules/benchmarks</module>
<module>modules/geospatial</module>
- <module>modules/hibernate5</module>
- <module>modules/hibernate</module>
+ <module>modules/hibernate-4.2</module>
+ <module>modules/hibernate-5.1</module>
<module>modules/schedule</module>
<module>modules/web-console/web-agent</module>
<module>modules/yardstick</module>
@@ -197,8 +198,8 @@
<profile>
<id>lgpl</id>
<modules>
- <module>modules/hibernate</module>
- <module>modules/hibernate5</module>
+ <module>modules/hibernate-4.2</module>
+ <module>modules/hibernate-5.1</module>
<module>modules/geospatial</module>
<module>modules/schedule</module>
</modules>
[20/50] [abbrv] ignite git commit: IGNITE-5064 Removed obsolete
EventTypes + minor cleanup.
Posted by vo...@apache.org.
IGNITE-5064 Removed obsolete EventTypes + minor cleanup.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4e4a22d9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4e4a22d9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4e4a22d9
Branch: refs/heads/master
Commit: 4e4a22d9aad4fdbfbcefc4eeacb65f8cffa181f2
Parents: 8a5266e
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 16:12:01 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 16:12:01 2017 +0700
----------------------------------------------------------------------
.../web-console/frontend/app/data/event-groups.json | 14 --------------
.../web-console/frontend/app/modules/cluster/Cache.js | 4 ----
.../frontend/app/modules/cluster/CacheMetrics.js | 4 ----
modules/web-console/web-agent/pom.xml | 2 +-
.../apache/ignite/console/agent/AgentLauncher.java | 10 +++++-----
5 files changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/data/event-groups.json
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/data/event-groups.json b/modules/web-console/frontend/app/data/event-groups.json
index 8d0c878..094fd28 100644
--- a/modules/web-console/frontend/app/data/event-groups.json
+++ b/modules/web-console/frontend/app/data/event-groups.json
@@ -97,8 +97,6 @@
"EVT_CACHE_OBJECT_REMOVED",
"EVT_CACHE_OBJECT_LOCKED",
"EVT_CACHE_OBJECT_UNLOCKED",
- "EVT_CACHE_OBJECT_SWAPPED",
- "EVT_CACHE_OBJECT_UNSWAPPED",
"EVT_CACHE_OBJECT_EXPIRED"
]
},
@@ -136,18 +134,6 @@
]
},
{
- "label": "EVTS_SWAPSPACE",
- "value": "EVTS_SWAPSPACE",
- "class": "org.apache.ignite.events.EventType",
- "events": [
- "EVT_SWAP_SPACE_CLEARED",
- "EVT_SWAP_SPACE_DATA_REMOVED",
- "EVT_SWAP_SPACE_DATA_READ",
- "EVT_SWAP_SPACE_DATA_STORED",
- "EVT_SWAP_SPACE_DATA_EVICTED"
- ]
- },
- {
"label": "EVTS_IGFS",
"value": "EVTS_IGFS",
"class": "org.apache.ignite.events.EventType",
http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/modules/cluster/Cache.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/cluster/Cache.js b/modules/web-console/frontend/app/modules/cluster/Cache.js
index 4918a7c..f954ad2 100644
--- a/modules/web-console/frontend/app/modules/cluster/Cache.js
+++ b/modules/web-console/frontend/app/modules/cluster/Cache.js
@@ -40,10 +40,6 @@ export default class Cache {
this.offHeapPrimarySize = cache.offHeapPrimaryEntriesCount || 0;
this.offHeapBackupSize = cache.offHeapBackupEntriesCount || 0;
- // Swap.
- this.swapSize = cache.swapSize;
- this.swapKeys = cache.swapKeys;
-
const m = cache.metrics;
// Read/write metrics.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
index 90d3a9b..160b7d1 100644
--- a/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
+++ b/modules/web-console/frontend/app/modules/cluster/CacheMetrics.js
@@ -40,10 +40,6 @@ export default class CacheMetrics {
this.offHeapPrimarySize = cache.offHeapPrimaryEntriesCount || 0;
this.offHeapBackupSize = cache.offHeapBackupEntriesCount || 0;
- // Swap.
- this.swapSize = cache.swapSize;
- this.swapKeys = cache.swapKeys;
-
const m = cache.metrics;
// Read/write metrics.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/web-agent/pom.xml
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/pom.xml b/modules/web-console/web-agent/pom.xml
index 697e58f..49e0ef0 100644
--- a/modules/web-console/web-agent/pom.xml
+++ b/modules/web-console/web-agent/pom.xml
@@ -61,7 +61,7 @@
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
- <version>3.6.0</version>
+ <version>3.7.0</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/4e4a22d9/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
index 65b8192..4db26ba 100644
--- a/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
+++ b/modules/web-console/web-agent/src/main/java/org/apache/ignite/console/agent/AgentLauncher.java
@@ -33,9 +33,9 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.Arrays;
-import java.util.Scanner;
import java.util.Collection;
import java.util.List;
+import java.util.Scanner;
import java.util.concurrent.CountDownLatch;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -65,7 +65,7 @@ import static org.apache.ignite.console.agent.AgentUtils.fromJSON;
import static org.apache.ignite.console.agent.AgentUtils.toJSON;
/**
- * Control Center Agent launcher.
+ * Ignite Web Agent launcher.
*/
public class AgentLauncher {
/** */
@@ -235,7 +235,7 @@ public class AgentLauncher {
* @param fmt Format string.
* @param args Arguments.
*/
- private static String readLine(String fmt, Object ... args) {
+ private static String readLine(String fmt, Object... args) {
if (System.console() != null)
return System.console().readLine(fmt, args);
@@ -248,7 +248,7 @@ public class AgentLauncher {
* @param fmt Format string.
* @param args Arguments.
*/
- private static char[] readPassword(String fmt, Object ... args) {
+ private static char[] readPassword(String fmt, Object... args) {
if (System.console() != null)
return System.console().readPassword(fmt, args);
@@ -339,7 +339,7 @@ public class AgentLauncher {
case "http":
case "https":
final String username = System.getProperty(uri.getScheme() + ".proxyUsername");
- final char[] pwd = System.getProperty(uri.getScheme() + ".proxyPassword", "").toCharArray();
+ final char[] pwd = System.getProperty(uri.getScheme() + ".proxyPassword", "").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override protected PasswordAuthentication getPasswordAuthentication() {
[24/50] [abbrv] ignite git commit: IGNITE-5036: @QuerySqlField and
@QueryTextField can no longer be applied to methods. This closes #1863.
Posted by vo...@apache.org.
IGNITE-5036: @QuerySqlField and @QueryTextField can no longer be applied to methods. This closes #1863.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9649733c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9649733c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9649733c
Branch: refs/heads/master
Commit: 9649733ce561166e308b53393e252d7efa087964
Parents: 5ef610c
Author: tledkov-gridgain <tl...@gridgain.com>
Authored: Tue Apr 25 17:34:05 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 17:34:05 2017 +0300
----------------------------------------------------------------------
.../examples/IndexingBridgeMethodTest.java | 93 --------------------
.../IgniteExamplesJ8SelfTestSuite.java | 2 -
.../cassandra/common/PropertyMappingHelper.java | 21 +----
.../persistence/KeyPersistenceSettings.java | 18 ++--
.../store/cassandra/persistence/PojoField.java | 21 +----
.../cassandra/persistence/PojoKeyField.java | 7 --
.../cassandra/persistence/PojoValueField.java | 6 --
.../persistence/ValuePersistenceSettings.java | 12 ++-
.../org/apache/ignite/tests/pojos/Person.java | 10 ++-
.../org/apache/ignite/tests/pojos/Product.java | 7 --
.../apache/ignite/tests/pojos/ProductOrder.java | 8 --
.../internal/jdbc2/JdbcResultSetSelfTest.java | 2 +-
.../cache/query/annotations/QuerySqlField.java | 2 +-
.../cache/query/annotations/QueryTextField.java | 4 +-
.../configuration/CacheConfiguration.java | 26 ------
.../cache/GridCacheQueryTestValue.java | 2 +-
.../IgniteCacheAbstractFieldsQuerySelfTest.java | 29 +-----
.../cache/IgniteCacheDistributedJoinTest.java | 6 +-
18 files changed, 30 insertions(+), 246 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java b/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
deleted file mode 100644
index 2837ed6..0000000
--- a/examples/src/test/java8/org/apache/ignite/java8/examples/IndexingBridgeMethodTest.java
+++ /dev/null
@@ -1,93 +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.java8.examples;
-
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.query.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Test covering bridge methods changes in Java 8.
- */
-public class IndexingBridgeMethodTest extends GridCommonAbstractTest {
- /**
- * @throws Exception If failed.
- */
- public void testBridgeMethod() throws Exception {
- Ignite ignite = startGrid();
-
- CacheConfiguration<Integer, MyType> ccfg = new CacheConfiguration<>();
-
- ccfg.setName("mytype");
- ccfg.setIndexedTypes(Integer.class, MyType.class);
-
- IgniteCache<Integer,MyType> c = ignite.getOrCreateCache(ccfg);
-
- for (int i = 0; i < 100; i++)
- c.put(i, new MyType(i));
-
- assertEquals(100L, c.query(new SqlFieldsQuery(
- "select count(*) from MyType")).getAll().get(0).get(0));
- assertEquals(15, c.query(new SqlFieldsQuery(
- "select id from MyType where _key = 15")).getAll().get(0).get(0));
- assertEquals(25, c.query(new SqlFieldsQuery(
- "select _key from MyType where id = 25")).getAll().get(0).get(0));
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /**
- * Classes implementing this method, will have bridge method.
- */
- private static interface HasId<T extends Number> {
- /**
- * @return ID.
- */
- public T getId();
- }
-
- /**
- *
- */
- private static class MyType implements HasId<Integer> {
- /** */
- private int id;
-
- /**
- * @param id Id.
- */
- private MyType(int id) {
- this.id = id;
- }
-
- /**
- * @return ID.
- */
- @QuerySqlField(index = true)
- @Override public Integer getId() {
- return id;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
----------------------------------------------------------------------
diff --git a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
index 7b62ea8..9a5f36a 100644
--- a/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
+++ b/examples/src/test/java8/org/apache/ignite/java8/testsuites/IgniteExamplesJ8SelfTestSuite.java
@@ -24,7 +24,6 @@ import org.apache.ignite.java8.examples.CacheExamplesMultiNodeSelfTest;
import org.apache.ignite.java8.examples.CacheExamplesSelfTest;
import org.apache.ignite.java8.examples.EventsExamplesMultiNodeSelfTest;
import org.apache.ignite.java8.examples.EventsExamplesSelfTest;
-import org.apache.ignite.java8.examples.IndexingBridgeMethodTest;
import org.apache.ignite.java8.examples.MessagingExamplesSelfTest;
import org.apache.ignite.testframework.GridTestUtils;
@@ -46,7 +45,6 @@ public class IgniteExamplesJ8SelfTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Examples Test Suite");
- suite.addTest(new TestSuite(IndexingBridgeMethodTest.class));
suite.addTest(new TestSuite(CacheExamplesSelfTest.class));
suite.addTest(new TestSuite(BasicExamplesSelfTest.class));
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
index 64b784b..cb89bf0 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/common/PropertyMappingHelper.java
@@ -20,7 +20,6 @@ package org.apache.ignite.cache.store.cassandra.common;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Row;
import java.beans.PropertyDescriptor;
-import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
@@ -103,25 +102,12 @@ public class PropertyMappingHelper {
* Extracts all property descriptors from a class.
*
* @param clazz class which property descriptors should be extracted.
- * @param primitive boolean flag indicating that only property descriptors for primitive properties should be extracted.
+ * @param primitive boolean flag indicating that only property descriptors for primitive properties
+ * should be extracted.
*
* @return list of class property descriptors
*/
public static List<PropertyDescriptor> getPojoPropertyDescriptors(Class clazz, boolean primitive) {
- return getPojoPropertyDescriptors(clazz, null, primitive);
- }
-
- /**
- * Extracts all property descriptors having specific annotation from a class.
- *
- * @param clazz class which property descriptors should be extracted.
- * @param annotation annotation to look for.
- * @param primitive boolean flag indicating that only property descriptors for primitive properties should be extracted.
- *
- * @return list of class property descriptors
- */
- public static <T extends Annotation> List<PropertyDescriptor> getPojoPropertyDescriptors(Class clazz,
- Class<T> annotation, boolean primitive) {
PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(clazz);
List<PropertyDescriptor> list = new ArrayList<>(descriptors == null ? 1 : descriptors.length);
@@ -133,8 +119,7 @@ public class PropertyMappingHelper {
if (descriptor.getReadMethod() == null || (primitive && !isPrimitivePropertyDescriptor(descriptor)))
continue;
- if (annotation == null || descriptor.getReadMethod().getAnnotation(annotation) != null)
- list.add(descriptor);
+ list.add(descriptor);
}
return list;
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
index c614abf..c12c3e8 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/KeyPersistenceSettings.java
@@ -22,8 +22,6 @@ import java.util.LinkedList;
import java.util.List;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.affinity.AffinityKeyMapped;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -214,12 +212,8 @@ public class KeyPersistenceSettings extends PersistenceSettings {
if (el == null) {
for (PropertyDescriptor desc : descriptors) {
- boolean valid = desc.getWriteMethod() != null ||
- desc.getReadMethod().getAnnotation(QuerySqlField.class) != null ||
- desc.getReadMethod().getAnnotation(AffinityKeyMapped.class) != null;
-
- // Skip POJO field if it's read-only and is not annotated with @QuerySqlField or @AffinityKeyMapped.
- if (valid)
+ // Skip POJO field if it's read-only
+ if (desc.getWriteMethod() != null)
list.add(new PojoKeyField(desc));
}
@@ -256,11 +250,8 @@ public class KeyPersistenceSettings extends PersistenceSettings {
* @return POJO field descriptors for partition key.
*/
private List<PropertyDescriptor> getPartitionKeyDescriptors() {
- List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(),
- AffinityKeyMapped.class, true);
-
- primitivePropDescriptors = primitivePropDescriptors != null && !primitivePropDescriptors.isEmpty() ?
- primitivePropDescriptors : PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
+ List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(
+ getJavaClass(), true);
boolean valid = false;
@@ -281,6 +272,7 @@ public class KeyPersistenceSettings extends PersistenceSettings {
}
/**
+ * @param partKeyFields List of fields.
* @return POJO field descriptors for cluster key.
*/
private List<PropertyDescriptor> getClusterKeyDescriptors(List<PojoField> partKeyFields) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
index 99b96d5..566c0b9 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoField.java
@@ -21,9 +21,7 @@ import com.datastax.driver.core.DataType;
import com.datastax.driver.core.Row;
import java.beans.PropertyDescriptor;
import java.io.Serializable;
-import java.lang.reflect.Method;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
import org.apache.ignite.cache.store.cassandra.serializer.Serializer;
import org.w3c.dom.Element;
@@ -86,19 +84,9 @@ public abstract class PojoField implements Serializable {
public PojoField(PropertyDescriptor desc) {
this.name = desc.getName();
- Method rdMthd = desc.getReadMethod();
-
- QuerySqlField sqlField = rdMthd != null && rdMthd.getAnnotation(QuerySqlField.class) != null
- ? rdMthd.getAnnotation(QuerySqlField.class)
- : desc.getWriteMethod() == null ? null : desc.getWriteMethod().getAnnotation(QuerySqlField.class);
-
- col = sqlField != null && sqlField.name() != null &&
- !sqlField.name().trim().isEmpty() ? sqlField.name() : name.toLowerCase();
+ col = name.toLowerCase();
init(desc);
-
- if (sqlField != null)
- init(sqlField);
}
/**
@@ -202,13 +190,6 @@ public abstract class PojoField implements Serializable {
}
/**
- * Initializes field info from annotation.
- *
- * @param sqlField {@link QuerySqlField} annotation.
- */
- protected abstract void init(QuerySqlField sqlField);
-
- /**
* Initializes field info from property descriptor.
*
* @param desc {@link PropertyDescriptor} descriptor.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
index ec37411..bf1d40e 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoKeyField.java
@@ -18,7 +18,6 @@
package org.apache.ignite.cache.store.cassandra.persistence;
import java.beans.PropertyDescriptor;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.w3c.dom.Element;
/**
@@ -78,10 +77,4 @@ public class PojoKeyField extends PojoField {
public SortOrder getSortOrder() {
return sortOrder;
}
-
- /** {@inheritDoc} */
- @Override protected void init(QuerySqlField sqlField) {
- if (sqlField.descending())
- sortOrder = SortOrder.DESC;
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
index fcdd408..9d25b60 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/PojoValueField.java
@@ -18,7 +18,6 @@
package org.apache.ignite.cache.store.cassandra.persistence;
import java.beans.PropertyDescriptor;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.w3c.dom.Element;
/**
@@ -135,9 +134,4 @@ public class PojoValueField extends PojoField {
return builder.append(";").toString();
}
-
- /** {@inheritDoc} */
- @Override protected void init(QuerySqlField sqlField) {
- // No-op.
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
index f117fb6..b737e2c 100644
--- a/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
+++ b/modules/cassandra/store/src/main/java/org/apache/ignite/cache/store/cassandra/persistence/ValuePersistenceSettings.java
@@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.apache.ignite.cache.store.cassandra.common.PropertyMappingHelper;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -85,13 +84,12 @@ public class ValuePersistenceSettings extends PersistenceSettings {
List<PojoField> list = new LinkedList<>();
if (fieldNodes == null || fieldNodes.getLength() == 0) {
- List<PropertyDescriptor> primitivePropDescriptors = PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
- for (PropertyDescriptor desc : primitivePropDescriptors) {
- boolean valid = desc.getWriteMethod() != null ||
- desc.getReadMethod().getAnnotation(QuerySqlField.class) != null;
+ List<PropertyDescriptor> primitivePropDescriptors =
+ PropertyMappingHelper.getPojoPropertyDescriptors(getJavaClass(), true);
- // Skip POJO field if it's read-only and is not annotated with @QuerySqlField.
- if (valid)
+ for (PropertyDescriptor desc : primitivePropDescriptors) {
+ // Skip POJO field if it's read-only
+ if (desc.getWriteMethod() != null)
list.add(new PojoValueField(desc));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
index 16b64bd..89d4851 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Person.java
@@ -17,8 +17,6 @@
package org.apache.ignite.tests.pojos;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
@@ -40,6 +38,9 @@ public class Person implements Externalizable {
private String lastName;
/** */
+ private String fullName;
+
+ /** */
private int age;
/** */
@@ -178,6 +179,7 @@ public class Person implements Externalizable {
@SuppressWarnings("UnusedDeclaration")
public void setFirstName(String name) {
firstName = name;
+ fullName = firstName + " " + lastName;
}
/** */
@@ -190,6 +192,7 @@ public class Person implements Externalizable {
@SuppressWarnings("UnusedDeclaration")
public void setLastName(String name) {
lastName = name;
+ fullName = firstName + " " + lastName;
}
/** */
@@ -200,9 +203,8 @@ public class Person implements Externalizable {
/** */
@SuppressWarnings("UnusedDeclaration")
- @QuerySqlField
public String getFullName() {
- return firstName + " " + lastName;
+ return fullName;
}
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
index f8eadf4..624b27b 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/Product.java
@@ -17,8 +17,6 @@
package org.apache.ignite.tests.pojos;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
/**
* Simple POJO to store information about product
*/
@@ -72,7 +70,6 @@ public class Product {
}
/** */
- @QuerySqlField(index = true)
public long getId() {
return id;
}
@@ -83,7 +80,6 @@ public class Product {
}
/** */
- @QuerySqlField
public String getType() {
return type;
}
@@ -94,7 +90,6 @@ public class Product {
}
/** */
- @QuerySqlField(index = true)
public String getTitle() {
return title;
}
@@ -105,7 +100,6 @@ public class Product {
}
/** */
- @QuerySqlField
public String getDescription() {
return description;
}
@@ -116,7 +110,6 @@ public class Product {
}
/** */
- @QuerySqlField
public float getPrice() {
return price;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
index bafc8f3..31c881e 100644
--- a/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
+++ b/modules/cassandra/store/src/test/java/org/apache/ignite/tests/pojos/ProductOrder.java
@@ -17,8 +17,6 @@
package org.apache.ignite.tests.pojos;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -91,7 +89,6 @@ public class ProductOrder {
}
/** */
- @QuerySqlField(index = true)
public long getId() {
return id;
}
@@ -102,7 +99,6 @@ public class ProductOrder {
}
/** */
- @QuerySqlField(index = true)
public long getProductId() {
return productId;
}
@@ -113,7 +109,6 @@ public class ProductOrder {
}
/** */
- @QuerySqlField
public Date getDate() {
return date;
}
@@ -124,7 +119,6 @@ public class ProductOrder {
}
/** */
- @QuerySqlField
public int getAmount() {
return amount;
}
@@ -135,13 +129,11 @@ public class ProductOrder {
}
/** */
- @QuerySqlField
public float getPrice() {
return price;
}
/** */
- @QuerySqlField
public String getDayMillisecond() {
return FORMAT.format(date);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
index 64a077e..8fb651d 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcResultSetSelfTest.java
@@ -654,10 +654,10 @@ public class JdbcResultSetSelfTest extends GridCommonAbstractTest {
protected boolean boolVal3;
/** */
+ @QuerySqlField(index = false)
protected boolean boolVal4;
/** */
- @QuerySqlField(index = false)
public boolean isBoolVal4() {
return boolVal4;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
index 48402b5..94dbea1 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QuerySqlField.java
@@ -31,7 +31,7 @@ import org.apache.ignite.internal.processors.cache.query.CacheQuery;
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.FIELD})
+@Target({ElementType.FIELD})
public @interface QuerySqlField {
/**
* Specifies whether cache should maintain an index for this field or not.
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
index 55809b6..1e01b6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/query/annotations/QueryTextField.java
@@ -25,14 +25,14 @@ import java.lang.annotation.Target;
import org.apache.ignite.internal.processors.cache.query.CacheQuery;
/**
- * Annotation for fields or getters to be indexed for full text
+ * Annotation for fields to be indexed for full text
* search using Lucene. For more information
* refer to {@link CacheQuery} documentation.
* @see CacheQuery
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
+@Target({ElementType.FIELD, ElementType.TYPE})
public @interface QueryTextField {
// No-op.
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 219e0b1..8a3874f 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -2141,32 +2141,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
processAnnotation(key, sqlAnn, txtAnn, cls, c, field.getType(), prop, type);
}
}
-
- for (Method mtd : c.getDeclaredMethods()) {
- if (mtd.isBridge())
- continue;
-
- QuerySqlField sqlAnn = mtd.getAnnotation(QuerySqlField.class);
- QueryTextField txtAnn = mtd.getAnnotation(QueryTextField.class);
-
- if (sqlAnn != null || txtAnn != null) {
- if (mtd.getParameterTypes().length != 0)
- throw new CacheException("Getter with QuerySqlField " +
- "annotation cannot have parameters: " + mtd);
-
- ClassProperty prop = new ClassProperty(mtd);
-
- prop.parent(parent);
-
- // Add parent property before its possible nested properties so that
- // resulting parent column comes before columns corresponding to those
- // nested properties in the resulting table - that way nested
- // properties override will happen properly (first parent, then children).
- type.addProperty(prop, key, true);
-
- processAnnotation(key, sqlAnn, txtAnn, cls, c, mtd.getReturnType(), prop, type);
- }
- }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
index 4d19b1a..116049f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheQueryTestValue.java
@@ -32,6 +32,7 @@ public class GridCacheQueryTestValue implements Serializable {
private String field1;
/** */
+ @QuerySqlField
private int field2;
/** */
@@ -72,7 +73,6 @@ public class GridCacheQueryTestValue implements Serializable {
*
* @return Field.
*/
- @QuerySqlField
public int getField2() {
return field2;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
index 8c8828d..fedeef6 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractFieldsQuerySelfTest.java
@@ -310,7 +310,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
Map<String, String> fields = meta.fields("Organization");
assert fields != null;
- assertEquals("Fields: " + fields, 5, fields.size());
+ assertEquals("Fields: " + fields, 4, fields.size());
if (binaryMarshaller) {
assert Object.class.getName().equals(fields.get("_VAL"));
@@ -605,7 +605,7 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
int cnt = 0;
for (List<?> row : res) {
- assertEquals(10, row.size());
+ assertEquals(9, row.size());
if (cnt == 0) {
assert new AffinityKey<>("p1", "o1").equals(row.get(0));
@@ -860,23 +860,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
/**
* @throws Exception If failed.
*/
- public void testMethodAnnotationWithoutGet() throws Exception {
- if (!binaryMarshaller) {
- QueryCursor<List<?>> qry =
- orgCache.query(sqlFieldsQuery("select methodField from Organization where methodField='name-A'")
- .setPageSize(10));
-
- List<List<?>> flds = qry.getAll();
-
- assertEquals(1, flds.size());
-
- assertEquals("name-A", flds.get(0).get(0));
- }
- }
-
- /**
- * @throws Exception If failed.
- */
public void testPaginationGet() throws Exception {
QueryCursor<List<?>> qry =
intCache.query(sqlFieldsQuery("select _key, _val from Integer").setPageSize(10));
@@ -1060,14 +1043,6 @@ public abstract class IgniteCacheAbstractFieldsQuerySelfTest extends GridCommonA
this.name = name;
}
- /**
- * @return Generated method value.
- */
- @QuerySqlField
- public String methodField() {
- return "name-" + name;
- }
-
/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (this == o)
http://git-wip-us.apache.org/repos/asf/ignite/blob/9649733c/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
index a553c3f..e69b5ec 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheDistributedJoinTest.java
@@ -234,12 +234,15 @@ public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest {
*/
public static class X {
/** */
+ @QuerySqlField(index = true)
public long a;
/** */
+ @QuerySqlField(index = true)
public long b;
/** */
+ @QuerySqlField(index = true)
public long c;
/**
@@ -254,19 +257,16 @@ public class IgniteCacheDistributedJoinTest extends GridCommonAbstractTest {
}
/** */
- @QuerySqlField(index = true)
public long getA() {
return a;
}
/** */
- @QuerySqlField(index = true)
public long getB() {
return b;
}
/** */
- @QuerySqlField(index = true)
public long getC() {
return c;
}
[25/50] [abbrv] ignite git commit: Formatting
Posted by vo...@apache.org.
Formatting
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1ccb943b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1ccb943b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1ccb943b
Branch: refs/heads/master
Commit: 1ccb943b48cb5ce385b767f0a888980d2d7bd9e0
Parents: 9649733
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Apr 26 06:02:23 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Apr 26 06:02:23 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/examples/streaming/wordcount/QueryWords.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1ccb943b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
index 54aa97f..94949b4 100644
--- a/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
+++ b/examples/src/main/java/org/apache/ignite/examples/streaming/wordcount/QueryWords.java
@@ -75,7 +75,8 @@ public class QueryWords {
List<?> row = stats.get(0);
if (row.get(0) != null)
- System.out.printf("Query results [avg=%d, min=%d, max=%d]%n", row.get(0), row.get(1), row.get(2));
+ System.out.printf("Query results [avg=%d, min=%d, max=%d]%n",
+ row.get(0), row.get(1), row.get(2));
// Print top 10 words.
ExamplesUtils.printQueryResults(top10);
[36/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
deleted file mode 100644
index ad5b191..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
+++ /dev/null
@@ -1,112 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-
-/**
- * Implementation of {@link EntityRegion}. This region is used to store entity data.
- * <p>
- * L2 cache for entity can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache for entity can be enabled using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateEntityRegion extends HibernateTransactionalDataRegion implements EntityRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache,
- * @param dataDesc Region data description.
- */
- public HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
- HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * Entity region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
- implements EntityRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegion getRegion() {
- return HibernateEntityRegion.this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(Object key, Object val, Object ver) throws CacheException {
- return stgy.insert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterInsert(Object key, Object val, Object ver) throws CacheException {
- return stgy.afterInsert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean update(Object key, Object val, Object currVer, Object previousVer)
- throws CacheException {
- return stgy.update(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterUpdate(Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
- throws CacheException {
- return stgy.afterUpdate(key, val, lock);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
deleted file mode 100644
index 2f1a11d..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
+++ /dev/null
@@ -1,71 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.GeneralDataRegion;
-import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link GeneralDataRegion}. This interface defines common contract for {@link QueryResultsRegion}
- * and {@link TimestampsRegion}.
- */
-public class HibernateGeneralDataRegion extends HibernateRegion implements GeneralDataRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(Object key) throws CacheException {
- try {
- return cache.get(key);
- } catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void put(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- } catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Object key) throws CacheException {
- HibernateAccessStrategyAdapter.evict(ignite, cache, key);
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll() throws CacheException {
- HibernateAccessStrategyAdapter.evictAll(cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
deleted file mode 100644
index ecad0b6..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyTransformer.java
+++ /dev/null
@@ -1,28 +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.hibernate;
-
-/**
- * An interface for transforming hibernate keys to Ignite keys.
- */
-public interface HibernateKeyTransformer {
- /**
- * @param key Hibernate key.
- */
- public Object transform(Object key);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
deleted file mode 100644
index 7de440e..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
+++ /dev/null
@@ -1,72 +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.hibernate;
-
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Hibernate cache key wrapper.
- */
-public class HibernateKeyWrapper {
- /** Key. */
- private final Object key;
-
- /** Entry. */
- private final String entry;
-
- /** */
- private final String tenantId;
-
- /**
- * @param key Key.
- * @param entry Entry.
- * @param tenantId Tenant ID.
- */
- HibernateKeyWrapper(Object key, String entry, String tenantId) {
- this.key = key;
- this.entry = entry;
- this.tenantId = tenantId;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o) return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- HibernateKeyWrapper that = (HibernateKeyWrapper) o;
-
- return (key != null ? key.equals(that.key) : that.key == null) &&
- (entry != null ? entry.equals(that.entry) : that.entry == null) &&
- (tenantId != null ? tenantId.equals(that.tenantId) : that.tenantId == null);
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = key != null ? key.hashCode() : 0;
- res = 31 * res + (entry != null ? entry.hashCode() : 0);
- res = 31 * res + (tenantId != null ? tenantId.hashCode() : 0);
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(HibernateKeyWrapper.class, this);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
deleted file mode 100644
index 862a422..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
+++ /dev/null
@@ -1,100 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-
-/**
- * Implementation of {@link NaturalIdRegion}. This region is used to store naturalId data.
- * <p>
- * L2 cache for entity naturalId and target cache region can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * @org.hibernate.annotations.NaturalIdCache
- * public class Entity {
- * @org.hibernate.annotations.NaturalId
- * private String entityCode;
- *
- * ...
- * }
- * </pre>
- */
-public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion implements NaturalIdRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache,
- * @param dataDesc Region data description.
- */
- public HibernateNaturalIdRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * NaturalId region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy implements
- NaturalIdRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegion getRegion() {
- return HibernateNaturalIdRegion.this;
- }
-
- /** {@inheritDoc} */
- @Override public boolean insert(Object key, Object val) throws CacheException {
- return stgy.insert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterInsert(Object key, Object val) throws CacheException {
- return stgy.afterInsert(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean update(Object key, Object val) throws CacheException {
- return stgy.update(key, val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- return stgy.afterUpdate(key, val, lock);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
deleted file mode 100644
index a36d7e7..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
+++ /dev/null
@@ -1,222 +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.hibernate;
-
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.apache.ignite.internal.util.typedef.F;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#NONSTRICT_READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateNonStrictAccessStrategy extends HibernateAccessStrategyAdapter {
- /** */
- private final ThreadLocal<WriteContext> writeCtx;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- * @param writeCtx Thread local instance used to track updates done during one Hibernate transaction.
- */
- protected HibernateNonStrictAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal writeCtx) {
- super(ignite, cache);
-
- this.writeCtx = (ThreadLocal<WriteContext>)writeCtx;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx == null)
- writeCtx.set(ctx = new WriteContext());
-
- ctx.locked(key);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- try {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null && ctx.unlocked(key)) {
- writeCtx.remove();
-
- ctx.updateCache(cache);
- }
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null) {
- ctx.updated(key, val);
-
- unlock(key, lock);
-
- return true;
- }
-
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- WriteContext ctx = writeCtx.get();
-
- if (ctx != null)
- ctx.removed(key);
- }
-
- /**
- * Information about updates done during single database transaction.
- */
- @SuppressWarnings("TypeMayBeWeakened")
- private static class WriteContext {
- /** */
- private Map<Object, Object> updates;
-
- /** */
- private Set<Object> rmvs;
-
- /** */
- private Set<Object> locked = new GridLeanSet<>();
-
- /**
- * Marks key as locked.
- *
- * @param key Key.
- */
- void locked(Object key) {
- locked.add(key);
- }
-
- /**
- * Marks key as unlocked.
- *
- * @param key Key.
- * @return {@code True} if last locked key was unlocked.
- */
- boolean unlocked(Object key) {
- locked.remove(key);
-
- return locked.isEmpty();
- }
-
- /**
- * Marks key as updated.
- *
- * @param key Key.
- * @param val Value.
- */
- void updated(Object key, Object val) {
- if (updates == null)
- updates = new GridLeanMap<>();
-
- updates.put(key, val);
- }
-
- /**
- * Marks key as removed.
- *
- * @param key Key.
- */
- void removed(Object key) {
- if (rmvs == null)
- rmvs = new GridLeanSet<>();
-
- rmvs.add(key);
- }
-
- /**
- * Updates cache.
- *
- * @param cache Cache.
- * @throws IgniteCheckedException If failed.
- */
- void updateCache(HibernateCacheProxy cache) throws IgniteCheckedException {
- if (!F.isEmpty(rmvs))
- cache.removeAll(rmvs);
-
- if (!F.isEmpty(updates))
- cache.putAll(updates);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
deleted file mode 100644
index 0b9a43d..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
+++ /dev/null
@@ -1,70 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.Query;
-import org.hibernate.cache.spi.QueryResultsRegion;
-
-/**
- * Implementation of {@link QueryResultsRegion}. This region is used to store query results.
- * <p>
- * Query results caching can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Enable query cache. -->
- * <property name="cache.use_second_level_cache">true</property>
-
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * By default queries are not cached even after enabling query caching, to enable results caching for a particular
- * query, call {@link Query#setCacheable(boolean)}:
- * <pre name="code" class="java">
- * Session ses = getSession();
- *
- * Query qry = ses.createQuery("...");
- *
- * qry.setCacheable(true); // Enable L2 cache for query.
- * </pre>
- * Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
- * values. For this reason, the query cache should always be used in conjunction with
- * the second-level cache for those entities expected to be cached as part of a query result cache
- */
-public class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
deleted file mode 100644
index cdef80e..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
+++ /dev/null
@@ -1,107 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#READ_ONLY} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with read-only access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="read-only"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
- * public class Entity { ... }
- * </pre>
-
- *
- */
-public class HibernateReadOnlyAccessStrategy extends HibernateAccessStrategyAdapter {
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- public HibernateReadOnlyAccessStrategy(Ignite ignite, HibernateCacheProxy cache) {
- super(ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
deleted file mode 100644
index ae9bd71..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
+++ /dev/null
@@ -1,328 +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.hibernate;
-
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
-
-/**
- * Implementation of {@link AccessType#READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with read-write access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAdapter {
- /** */
- private final ThreadLocal<TxContext> txCtx;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- * @param txCtx Thread local instance used to track updates done during one Hibernate transaction.
- */
- protected HibernateReadWriteAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal txCtx) {
- super(ignite, cache);
-
- this.txCtx = (ThreadLocal<TxContext>)txCtx;
- }
-
- /** {@inheritDoc} */
- @Override protected Object get(Object key) throws CacheException {
- boolean success = false;
-
- try {
- Object o = cache.get(key);
-
- success = true;
-
- return o;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void putFromLoad(Object key, Object val) throws CacheException {
- boolean success = false;
-
- try {
- cache.put(key, val);
-
- success = true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected SoftLock lock(Object key) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx == null)
- txCtx.set(ctx = new TxContext());
-
- lockKey(key);
-
- ctx.locked(key);
-
- success = true;
-
- return null;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null)
- unlock(ctx, key);
-
- success = true;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- boolean success = false;
- boolean res = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null) {
- cache.put(key, val);
-
- unlock(ctx, key);
-
- res = true;
- }
-
- success = true;
-
- return res;
- }
- catch (Exception e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- boolean success = false;
-
- try {
- cache.put(key, val);
-
- success = true;
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- boolean success = false;
-
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null)
- cache.remove(key);
-
- success = true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- finally {
- if (!success)
- rollbackCurrentTx();
- }
- }
-
- /**
- *
- * @param ctx Transaction context.
- * @param key Key.
- * @throws CacheException If failed.
- */
- private void unlock(TxContext ctx, Object key) throws CacheException {
- if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
- txCtx.remove();
-
- GridNearTxLocal tx = cache.tx();
-
- assert tx != null;
-
- try {
- tx.proxy().commit();
- }
- finally {
- tx.proxy().close();
- }
-
- assert cache.tx() == null;
- }
- }
-
- /**
- * Roll backs current transaction.
- */
- private void rollbackCurrentTx() {
- try {
- TxContext ctx = txCtx.get();
-
- if (ctx != null) {
- txCtx.remove();
-
- GridNearTxLocal tx = cache.tx();
-
- if (tx != null)
- tx.proxy().rollback();
- }
- }
- catch (IgniteException e) {
- log.error("Failed to rollback cache transaction.", e);
- }
- }
-
- /**
- * @param key Key.
- * @throws IgniteCheckedException If failed.
- */
- private void lockKey(Object key) throws IgniteCheckedException {
- if (cache.tx() == null)
- cache.txStart(PESSIMISTIC, REPEATABLE_READ);
-
- cache.get(key); // Acquire distributed lock.
- }
-
- /**
- * Information about updates done during single database transaction.
- */
- @SuppressWarnings("TypeMayBeWeakened")
- private static class TxContext {
- /** */
- private Set<Object> locked = new GridLeanSet<>();
-
- /**
- * Marks key as locked.
- *
- * @param key Key.
- */
- void locked(Object key) {
- locked.add(key);
- }
-
- /**
- * Marks key as unlocked.
- *
- * @param key Key.
- * @return {@code True} if last locked key was unlocked.
- */
- boolean unlocked(Object key) {
- locked.remove(key);
-
- return locked.isEmpty();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
deleted file mode 100644
index 11a96d0..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
+++ /dev/null
@@ -1,99 +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.hibernate;
-
-import java.util.Collections;
-import java.util.Map;
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.Region;
-
-/**
- * Implementation of {@link Region}. This interface defines base contract for all L2 cache regions.
- */
-public class HibernateRegion implements Region {
- /** */
- protected final HibernateRegionFactory factory;
-
- /** */
- private final String name;
-
- /** Cache instance. */
- protected final HibernateCacheProxy cache;
-
- /** Grid instance. */
- protected Ignite ignite;
-
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateRegion(HibernateRegionFactory factory, String name, Ignite ignite, HibernateCacheProxy cache) {
- this.factory = factory;
- this.name = name;
- this.ignite = ignite;
- this.cache = cache;
- }
-
- /** {@inheritDoc} */
- @Override public String getName() {
- return name;
- }
-
- /** {@inheritDoc} */
- @Override public void destroy() throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean contains(Object key) {
- return cache.containsKey(key);
- }
-
- /** {@inheritDoc} */
- @Override public long getSizeInMemory() {
- return -1;
- }
-
- /** {@inheritDoc} */
- @Override public long getElementCountInMemory() {
- return cache.size();
- }
-
- /** {@inheritDoc} */
- @Override public long getElementCountOnDisk() {
- return -1;
- }
-
- /** {@inheritDoc} */
- @Override public Map toMap() {
- return Collections.emptyMap();
- }
-
- /** {@inheritDoc} */
- @Override public long nextTimestamp() {
- return System.currentTimeMillis();
- }
-
- /** {@inheritDoc} */
- @Override public int getTimeout() {
- return 0;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
deleted file mode 100644
index 263359b..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
+++ /dev/null
@@ -1,266 +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.hibernate;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.G;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CacheKey;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.QueryResultsRegion;
-import org.hibernate.cache.spi.RegionFactory;
-import org.hibernate.cache.spi.TimestampsRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Settings;
-
-import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
-
-/**
- * Hibernate L2 cache region factory.
- * <p>
- * Following Hibernate settings should be specified to enable second level cache and to use this
- * region factory for caching:
- * <pre name="code" class="brush: xml; gutter: false;">
- * hibernate.cache.use_second_level_cache=true
- * hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
- * </pre>
- * Note that before region factory is started you need to start properly configured Ignite node in the same JVM.
- * For example to start Ignite node one of loader provided in {@code org.apache.ignite.grid.startup} package can be used.
- * <p>
- * Name of Ignite instance to be used for region factory must be specified as following Hibernate property:
- * <pre name="code" class="brush: xml; gutter: false;">
- * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance name>
- * </pre>
- * Each Hibernate cache region must be associated with some {@link IgniteInternalCache}, by default it is assumed that
- * for each cache region there is a {@link IgniteInternalCache} with the same name. Also it is possible to define
- * region to cache mapping using properties with prefix {@code org.apache.ignite.hibernate.region_cache}.
- * For example if for region with name "region1" cache with name "cache1" should be used then following
- * Hibernate property should be specified:
- * <pre name="code" class="brush: xml; gutter: false;">
- * org.apache.ignite.hibernate.region_cache.region1=cache1
- * </pre>
- */
-public class HibernateRegionFactory implements RegionFactory {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * Hibernate L2 cache grid name property name.
- *
- * @deprecated Use {@link #IGNITE_INSTANCE_NAME_PROPERTY}.
- * If {@link #IGNITE_INSTANCE_NAME_PROPERTY} is specified it takes precedence.
- */
- @Deprecated
- public static final String GRID_NAME_PROPERTY = "org.apache.ignite.hibernate.grid_name";
-
- /** Hibernate L2 cache Ignite instance name property name. */
- public static final String IGNITE_INSTANCE_NAME_PROPERTY = "org.apache.ignite.hibernate.ignite_instance_name";
-
- /** Default cache property name. */
- public static final String DFLT_CACHE_NAME_PROPERTY = "org.apache.ignite.hibernate.default_cache";
-
- /** Property prefix used to specify region name to cache name mapping. */
- public static final String REGION_CACHE_PROPERTY = "org.apache.ignite.hibernate.region_cache.";
-
- /** */
- public static final String DFLT_ACCESS_TYPE_PROPERTY = "org.apache.ignite.hibernate.default_access_type";
-
- /** */
- public static final String GRID_CONFIG_PROPERTY = "org.apache.ignite.hibernate.grid_config";
-
- /** Grid providing caches. */
- private Ignite ignite;
-
- /** Default cache. */
- private HibernateCacheProxy dfltCache;
-
- /** Default region access type. */
- private AccessType dfltAccessType;
-
- /** Region name to cache name mapping. */
- private final Map<String, String> regionCaches = new HashMap<>();
-
- /** Map needed to provide the same transaction context for different regions. */
- private final ThreadLocal threadLoc = new ThreadLocal();
-
- /** Key transformer. */
- private final HibernateKeyTransformer hibernate4transformer = new HibernateKeyTransformer() {
- @Override public Object transform(Object key) {
- if (key instanceof CacheKey) {
- CacheKey cacheKey = (CacheKey)key;
-
- return new HibernateKeyWrapper(
- cacheKey.getKey(),
- cacheKey.getEntityOrRoleName(),
- cacheKey.getTenantId()
- );
- }
-
- return key;
- }
- };
-
- /** {@inheritDoc} */
- @Override public void start(Settings settings, Properties props) throws CacheException {
- String gridCfg = props.getProperty(GRID_CONFIG_PROPERTY);
- String igniteInstanceName = props.getProperty(IGNITE_INSTANCE_NAME_PROPERTY);
-
- if (igniteInstanceName == null)
- igniteInstanceName = props.getProperty(GRID_NAME_PROPERTY);
-
- if (gridCfg != null) {
- try {
- ignite = G.start(gridCfg);
- }
- catch (IgniteException e) {
- throw new CacheException(e);
- }
- }
- else
- ignite = Ignition.ignite(igniteInstanceName);
-
- String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());
-
- dfltAccessType = AccessType.valueOf(accessType);
-
- for (Map.Entry<Object, Object> prop : props.entrySet()) {
- String key = prop.getKey().toString();
-
- if (key.startsWith(REGION_CACHE_PROPERTY)) {
- String regionName = key.substring(REGION_CACHE_PROPERTY.length());
-
- String cacheName = prop.getValue().toString();
-
- if (((IgniteKernal)ignite).getCache(cacheName) == null)
- throw new CacheException("Cache '" + cacheName + "' specified for region '" + regionName + "' " +
- "is not configured.");
-
- regionCaches.put(regionName, cacheName);
- }
- }
-
- String dfltCacheName = props.getProperty(DFLT_CACHE_NAME_PROPERTY);
-
- if (dfltCacheName != null) {
- IgniteInternalCache<Object, Object> dfltCache = ((IgniteKernal)ignite).getCache(dfltCacheName);
-
- if (dfltCache == null)
- throw new CacheException("Cache specified as default is not configured: " + dfltCacheName);
-
- this.dfltCache = new HibernateCacheProxy(dfltCache, hibernate4transformer);
- }
-
- IgniteLogger log = ignite.log().getLogger(HibernateRegionFactory.class);
-
- if (log.isDebugEnabled())
- log.debug("HibernateRegionFactory started [igniteInstanceName=" + igniteInstanceName + ']');
- }
-
- /** {@inheritDoc} */
- @Override public void stop() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMinimalPutsEnabledByDefault() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public AccessType getDefaultAccessType() {
- return dfltAccessType;
- }
-
- /** {@inheritDoc} */
- @Override public long nextTimestamp() {
- return System.currentTimeMillis();
- }
-
- /** {@inheritDoc} */
- @Override public EntityRegion buildEntityRegion(String regionName, Properties props, CacheDataDescription metadata)
- throws CacheException {
- return new HibernateEntityRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties props,
- CacheDataDescription metadata) throws CacheException {
- return new HibernateNaturalIdRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegion buildCollectionRegion(String regionName, Properties props,
- CacheDataDescription metadata) throws CacheException {
- return new HibernateCollectionRegion(this, regionName, ignite, regionCache(regionName), metadata);
- }
-
- /** {@inheritDoc} */
- @Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
- throws CacheException {
- return new HibernateQueryResultsRegion(this, regionName, ignite, regionCache(regionName));
- }
-
- /** {@inheritDoc} */
- @Override public TimestampsRegion buildTimestampsRegion(String regionName, Properties props) throws CacheException {
- return new HibernateTimestampsRegion(this, regionName, ignite, regionCache(regionName));
- }
-
- /**
- * Reuse same thread local for the same cache across different regions.
- *
- * @param cacheName Cache name.
- * @return Thread local instance used to track updates done during one Hibernate transaction.
- */
- ThreadLocal threadLocalForCache(String cacheName) {
- return threadLoc;
- }
-
- /**
- * @param regionName L2 cache region name.
- * @return Cache for given region.
- * @throws CacheException If cache for given region is not configured.
- */
- private HibernateCacheProxy regionCache(String regionName) throws CacheException {
- String cacheName = regionCaches.get(regionName);
-
- if (cacheName == null) {
- if (dfltCache != null)
- return dfltCache;
-
- cacheName = regionName;
- }
-
- IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
- if (cache == null)
- throw new CacheException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured.");
-
- return new HibernateCacheProxy(cache, hibernate4transformer);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
deleted file mode 100644
index 8b4c243..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
+++ /dev/null
@@ -1,39 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.spi.TimestampsRegion;
-
-/**
- * Implementation of {@link TimestampsRegion}. This region is automatically created when query
- * caching is enabled and it holds most recent updates timestamps to queryable tables.
- * Name of timestamps region is {@code "org.hibernate.cache.spi.UpdateTimestampsCache"}.
- */
-public class HibernateTimestampsRegion extends HibernateGeneralDataRegion implements TimestampsRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- */
- public HibernateTimestampsRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache) {
- super(factory, name, ignite, cache);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
deleted file mode 100644
index ca52849..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
+++ /dev/null
@@ -1,141 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#TRANSACTIONAL} cache access strategy.
- * <p>
- * It is supposed that this strategy is used in JTA environment and Hibernate and
- * {@link IgniteInternalCache} corresponding to the L2 cache region are configured to use the same transaction manager.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entity. -->
- * <mapping class="com.example.Entity"/>
- *
- * <!-- Enable L2 cache with transactional access strategy for entity. -->
- * <class-cache class="com.example.Entity" usage="transactional"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateTransactionalAccessStrategy extends HibernateAccessStrategyAdapter {
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- public HibernateTransactionalAccessStrategy(Ignite ignite, HibernateCacheProxy cache) {
- super(ignite, cache);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected Object get(Object key) throws CacheException {
- try {
- return cache.get(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void putFromLoad(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected SoftLock lock(Object key) throws CacheException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected boolean update(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected boolean insert(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
-
- return true;
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override protected void remove(Object key) throws CacheException {
- try {
- cache.remove(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
deleted file mode 100644
index 581076a..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
+++ /dev/null
@@ -1,107 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.configuration.TransactionConfiguration;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.EntityRegion;
-import org.hibernate.cache.spi.NaturalIdRegion;
-import org.hibernate.cache.spi.TransactionalDataRegion;
-import org.hibernate.cache.spi.access.AccessType;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-
-/**
- * Implementation of {@link TransactionalDataRegion} (transactional means that
- * data in the region is updated in connection with database transaction).
- * This interface defines base contract for {@link EntityRegion}, {@link CollectionRegion}
- * and {@link NaturalIdRegion}.
- */
-public class HibernateTransactionalDataRegion extends HibernateRegion implements TransactionalDataRegion {
- /** */
- private final CacheDataDescription dataDesc;
-
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- * @param dataDesc Region data description.
- */
- public HibernateTransactionalDataRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache);
-
- this.dataDesc = dataDesc;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isTransactionAware() {
- return false; // This method is not used by Hibernate.
- }
-
- /** {@inheritDoc} */
- @Override public CacheDataDescription getCacheDataDescription() {
- return dataDesc;
- }
-
- /**
- * @param accessType Hibernate L2 cache access type.
- * @return Access strategy for given access type.
- */
- protected HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
- switch (accessType) {
- case READ_ONLY:
- return new HibernateReadOnlyAccessStrategy(ignite, cache);
-
- case NONSTRICT_READ_WRITE:
- return new HibernateNonStrictAccessStrategy(ignite, cache, factory.threadLocalForCache(cache.name()));
-
- case READ_WRITE:
- if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
- throw new CacheException("Hibernate READ-WRITE access strategy must have Ignite cache with " +
- "'TRANSACTIONAL' atomicity mode: " + cache.name());
-
- return new HibernateReadWriteAccessStrategy(ignite, cache, factory.threadLocalForCache(cache.name()));
-
- case TRANSACTIONAL:
- if (cache.configuration().getAtomicityMode() != TRANSACTIONAL)
- throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " +
- "'TRANSACTIONAL' atomicity mode: " + cache.name());
-
- TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration();
-
- if (txCfg == null ||
- (txCfg.getTxManagerFactory() == null
- && txCfg.getTxManagerLookupClassName() == null
- && cache.configuration().getTransactionManagerLookupClassName() == null)) {
- throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite with " +
- "Factory<TransactionManager> configured (see IgniteConfiguration." +
- "getTransactionConfiguration().setTxManagerFactory()): " + cache.name());
- }
-
- return new HibernateTransactionalAccessStrategy(ignite, cache);
-
- default:
- throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
deleted file mode 100644
index 1179aec..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
+++ /dev/null
@@ -1,24 +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 description. -->
- * Contains implementation of Hibernate L2 cache. Refer to
- * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
- * configure and use Ignite with Hibernate.
- */
-package org.apache.ignite.cache.hibernate;
\ No newline at end of file
[37/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
new file mode 100644
index 0000000..491553d
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
@@ -0,0 +1,326 @@
+/*
+ * 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.hibernate;
+
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
+import org.apache.ignite.internal.util.GridLeanSet;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Implementation of READ_WRITE cache access strategy.
+ * <p>
+ * Configuration of L2 cache and per-entity cache access strategy can be set in the
+ * Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache access strategy can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAdapter {
+ /** */
+ private final ThreadLocal<TxContext> txCtx;
+
+ /**
+ * @param ignite Grid.
+ * @param cache Cache.
+ * @param txCtx Thread local instance used to track updates done during one Hibernate transaction.
+ * @param eConverter Exception converter.
+ */
+ protected HibernateReadWriteAccessStrategy(Ignite ignite,
+ HibernateCacheProxy cache,
+ ThreadLocal txCtx,
+ HibernateExceptionConverter eConverter) {
+ super(ignite, cache, eConverter);
+
+ this.txCtx = (ThreadLocal<TxContext>)txCtx;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object get(Object key) {
+ boolean success = false;
+
+ try {
+ Object o = cache.get(key);
+
+ success = true;
+
+ return o;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void putFromLoad(Object key, Object val) {
+ boolean success = false;
+
+ try {
+ cache.put(key, val);
+
+ success = true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void lock(Object key) {
+ boolean success = false;
+
+ try {
+ TxContext ctx = txCtx.get();
+
+ if (ctx == null)
+ txCtx.set(ctx = new TxContext());
+
+ lockKey(key);
+
+ ctx.locked(key);
+
+ success = true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlock(Object key) {
+ boolean success = false;
+
+ try {
+ TxContext ctx = txCtx.get();
+
+ if (ctx != null)
+ unlock(ctx, key);
+
+ success = true;
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val) {
+ boolean success = false;
+ boolean res = false;
+
+ try {
+ TxContext ctx = txCtx.get();
+
+ if (ctx != null) {
+ cache.put(key, val);
+
+ unlock(ctx, key);
+
+ res = true;
+ }
+
+ success = true;
+
+ return res;
+ }
+ catch (Exception e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) {
+ boolean success = false;
+
+ try {
+ cache.put(key, val);
+
+ success = true;
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) {
+ boolean success = false;
+
+ try {
+ TxContext ctx = txCtx.get();
+
+ if (ctx != null)
+ cache.remove(key);
+
+ success = true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ finally {
+ if (!success)
+ rollbackCurrentTx();
+ }
+ }
+
+ /**
+ *
+ * @param ctx Transaction context.
+ * @param key Key.
+ */
+ private void unlock(TxContext ctx, Object key) {
+ if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
+ txCtx.remove();
+
+ GridNearTxLocal tx = cache.tx();
+
+ assert tx != null;
+
+ try {
+ tx.proxy().commit();
+ }
+ finally {
+ tx.proxy().close();
+ }
+
+ assert cache.tx() == null;
+ }
+ }
+
+ /**
+ * Roll backs current transaction.
+ */
+ private void rollbackCurrentTx() {
+ try {
+ TxContext ctx = txCtx.get();
+
+ if (ctx != null) {
+ txCtx.remove();
+
+ GridNearTxLocal tx = cache.tx();
+
+ if (tx != null)
+ tx.proxy().rollback();
+ }
+ }
+ catch (IgniteException e) {
+ log.error("Failed to rollback cache transaction.", e);
+ }
+ }
+
+ /**
+ * @param key Key.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void lockKey(Object key) throws IgniteCheckedException {
+ if (cache.tx() == null)
+ cache.txStart(PESSIMISTIC, REPEATABLE_READ);
+
+ cache.get(key); // Acquire distributed lock.
+ }
+
+ /**
+ * Information about updates done during single database transaction.
+ */
+ @SuppressWarnings("TypeMayBeWeakened")
+ private static class TxContext {
+ /** */
+ private Set<Object> locked = new GridLeanSet<>();
+
+ /**
+ * Marks key as locked.
+ *
+ * @param key Key.
+ */
+ void locked(Object key) {
+ locked.add(key);
+ }
+
+ /**
+ * Marks key as unlocked.
+ *
+ * @param key Key.
+ * @return {@code True} if last locked key was unlocked.
+ */
+ boolean unlocked(Object key) {
+ locked.remove(key);
+
+ return locked.isEmpty();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
new file mode 100644
index 0000000..6f4935b
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalAccessStrategy.java
@@ -0,0 +1,141 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {TRANSACTIONAL cache access strategy.
+ * <p>
+ * It is supposed that this strategy is used in JTA environment and Hibernate and
+ * {@link IgniteInternalCache} corresponding to the L2 cache region are configured to use the same transaction manager.
+ * <p>
+ * Configuration of L2 cache and per-entity cache access strategy can be set in the
+ * Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with transactional access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="transactional"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache access strategy can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.TRANSACTIONAL)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateTransactionalAccessStrategy extends HibernateAccessStrategyAdapter {
+ /**
+ * @param ignite Grid.
+ * @param cache Cache.
+ * @param eConverter Exception converter.
+ */
+ HibernateTransactionalAccessStrategy(Ignite ignite,
+ HibernateCacheProxy cache,
+ HibernateExceptionConverter eConverter) {
+ super(ignite, cache, eConverter);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key) {
+ try {
+ return cache.get(key);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void putFromLoad(Object key, Object val) {
+ try {
+ cache.put(key, val);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void lock(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlock(Object key) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) {
+ try {
+ cache.put(key, val);
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) {
+ try {
+ cache.put(key, val);
+
+ return true;
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) {
+ try {
+ cache.remove(key);
+ }
+ catch (IgniteCheckedException e) {
+ throw convertException(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
new file mode 100644
index 0000000..1179aec
--- /dev/null
+++ b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 description. -->
+ * Contains implementation of Hibernate L2 cache. Refer to
+ * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
+ * configure and use Ignite with Hibernate.
+ */
+package org.apache.ignite.cache.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/README.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate/README.txt b/modules/hibernate/README.txt
deleted file mode 100644
index 8e90dab..0000000
--- a/modules/hibernate/README.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-Apache Ignite Hibernate Module
-------------------------------
-
-Apache Ignite Hibernate module provides Hibernate second-level cache (L2 cache) implementation based
-on Apache Ignite In-Memory Data Grid.
-
-To enable Hibernate module when starting a standalone node, move 'optional/ignite-hibernate' folder to
-'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will
-be added to classpath in this case.
-
-Importing Hibernate Module In Maven Project
--------------------------------------------
-
-If you are using Maven to manage dependencies of your project, you can add Hibernate module
-dependency like this (replace '${ignite.version}' with actual Ignite version you are
-interested in):
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
- ...
- <dependencies>
- ...
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
- <version>${ignite.version}</version>
- </dependency>
- ...
- </dependencies>
- ...
-</project>
-
-
-LGPL dependencies
------------------
-
-Ignite includes the following optional LGPL dependencies:
- - Hibernate L2 Cache Integration, http://hibernate.org/orm/
- - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
- - cron4j for cron-based task scheduling, http://www.sauronsoftware.it/projects/cron4j
-
-Apache binary releases cannot include LGPL dependencies. If you would like include
-optional LGPL dependencies into your release, you should download the source release
-from Ignite website and do the build with the following maven command:
-
-mvn clean package -DskipTests -Prelease,lgpl
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate/licenses/apache-2.0.txt b/modules/hibernate/licenses/apache-2.0.txt
deleted file mode 100644
index d645695..0000000
--- a/modules/hibernate/licenses/apache-2.0.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml
deleted file mode 100644
index 75dacb1..0000000
--- a/modules/hibernate/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<!--
- POM file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-parent</artifactId>
- <version>1</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <artifactId>ignite-hibernate</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <url>http://ignite.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>4.2.6.Final</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-jta</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.jotm</groupId>
- <artifactId>jotm-core</artifactId>
- <version>2.1.9</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>${h2.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <version>1.5</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-spring</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-log4j</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- <testResource>
- <directory>src/test/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- </testResources>
-
- <plugins>
- <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
deleted file mode 100644
index 7186cfb..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
+++ /dev/null
@@ -1,98 +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.hibernate;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.RegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of L2 cache access strategy delegating to {@link HibernateAccessStrategyAdapter}.
- */
-public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
- /** */
- protected final HibernateAccessStrategyAdapter stgy;
-
- /**
- * @param stgy Access strategy implementation.
- */
- protected HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
- this.stgy = stgy;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(Object key, long txTs) throws CacheException {
- return stgy.get(key);
- }
-
- /** {@inheritDoc} */
- @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver) throws CacheException {
- stgy.putFromLoad(key, val);
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver, boolean minimalPutOverride)
- throws CacheException {
- stgy.putFromLoad(key, val, minimalPutOverride);
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public SoftLock lockItem(Object key, Object ver) throws CacheException {
- return stgy.lock(key);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public SoftLock lockRegion() throws CacheException {
- return stgy.lockRegion();
- }
-
- /** {@inheritDoc} */
- @Override public void unlockRegion(SoftLock lock) throws CacheException {
- stgy.unlockRegion(lock);
- }
-
- /** {@inheritDoc} */
- @Override public void unlockItem(Object key, SoftLock lock) throws CacheException {
- stgy.unlock(key, lock);
- }
-
- /** {@inheritDoc} */
- @Override public void remove(Object key) throws CacheException {
- stgy.remove(key);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll() throws CacheException {
- stgy.removeAll();
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Object key) throws CacheException {
- stgy.evict(key);
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll() throws CacheException {
- stgy.evictAll();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
deleted file mode 100644
index f6c1d0e..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
+++ /dev/null
@@ -1,379 +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.hibernate;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
-import org.hibernate.cache.spi.access.RegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Common interface used to implement Hibernate L2 cache access strategies ({@link RegionAccessStrategy},
- * {@link EntityRegionAccessStrategy} and {@link CollectionRegionAccessStrategy}).
- * <p>
- * The expected sequences of steps related to various CRUD operations executed by Hibernate are:
- * <p>
- * Insert:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Execute database insert.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#insert}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#afterInsert}.</li>
- * </ul>
- * In case if some step fails and DB transaction is rolled back then
- * {@link HibernateAccessStrategyAdapter#afterInsert} is not called.
- * <p>
- * Update:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lock}.</li>
- * <li>Execute database update.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#update}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#afterUpdate}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * Delete:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lock} for removing key.</li>
- * <li>Execute database delete.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#remove}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#unlock}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * In case if custom SQL update query is executed Hibernate clears entire cache region,
- * for this case operations sequence is:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lockRegion}.</li>
- * <li>Execute database query.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#removeAll}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#unlockRegion}.</li>
- * </ul>
- */
-public abstract class HibernateAccessStrategyAdapter {
- /** */
- protected final HibernateCacheProxy cache;
-
- /** Grid. */
- protected final Ignite ignite;
-
- /** */
- protected final IgniteLogger log;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- protected HibernateAccessStrategyAdapter(Ignite ignite, HibernateCacheProxy cache) {
- this.cache = cache;
- this.ignite = ignite;
-
- log = ignite.log();
- }
-
- /**
- * Gets value from cache. Used by {@link RegionAccessStrategy#get}.
- *
- * @param key Key.
- * @return Cached value.
- * @throws CacheException If failed.
- */
- @Nullable protected Object get(Object key) throws CacheException {
- try {
- return cache.get(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
- *
- * @param key Key.
- * @param val Value.
- * @param minimalPutOverride MinimalPut flag
- * @throws CacheException If failed.
- */
- protected void putFromLoad(Object key, Object val, boolean minimalPutOverride) throws CacheException {
- putFromLoad(key, val);
- }
-
- /**
- * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
- *
- * @param key Key.
- * @param val Value.
- * @throws CacheException If failed.
- */
- protected void putFromLoad(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Called during database transaction execution before Hibernate attempts to update or remove given key.
- * Used by {@link RegionAccessStrategy#lockItem}.
- *
- * @param key Key.
- * @return Lock representation or {@code null}.
- * @throws CacheException If failed.
- */
- @Nullable protected abstract SoftLock lock(Object key) throws CacheException;
-
- /**
- * Called after Hibernate failed to update or successfully removed given key.
- * Used by {@link RegionAccessStrategy#unlockItem}.
- *
- * @param key Key.
- * @param lock The lock previously obtained from {@link #lock}
- * @throws CacheException If failed.
- */
- protected abstract void unlock(Object key, SoftLock lock) throws CacheException;
-
- /**
- * Called after Hibernate updated object in the database but before transaction completed.
- * Used by {@link EntityRegionAccessStrategy#update} and {@link NaturalIdRegionAccessStrategy#update}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean update(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate updated object in the database and transaction successfully completed.
- * Used by {@link EntityRegionAccessStrategy#afterUpdate} and {@link NaturalIdRegionAccessStrategy#afterUpdate}.
- *
- * @param key Key.
- * @param val Value.
- * @param lock The lock previously obtained from {@link #lock}
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException;
-
- /**
- * Called after Hibernate inserted object in the database but before transaction completed.
- * Used by {@link EntityRegionAccessStrategy#insert} and {@link NaturalIdRegionAccessStrategy#insert}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean insert(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate inserted object in the database and transaction successfully completed.
- * Used by {@link EntityRegionAccessStrategy#afterInsert} and {@link NaturalIdRegionAccessStrategy#afterInsert}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean afterInsert(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate removed object from database but before transaction completed.
- * Used by {@link RegionAccessStrategy#remove}.
- *
- * @param key Key,
- * @throws CacheException If failed.
- */
- protected abstract void remove(Object key) throws CacheException;
-
- /**
- * Called to remove object from cache without regard to transaction.
- * Used by {@link RegionAccessStrategy#evict}.
- *
- * @param key Key.
- * @throws CacheException If failed.
- */
- protected void evict(Object key) throws CacheException {
- evict(ignite, cache, key);
- }
-
- /**
- * Called to remove all data from cache without regard to transaction.
- * Used by {@link RegionAccessStrategy#evictAll}.
- *
- * @throws CacheException If failed.
- */
- protected void evictAll() throws CacheException {
- evictAll(cache);
- }
-
- /**
- * Called during database transaction execution before Hibernate executed
- * update operation which should invalidate entire cache region.
- * Used by {@link RegionAccessStrategy#lockRegion}.
- *
- * @throws CacheException If failed.
- * @return Lock representation or {@code null}.
- */
- @Nullable protected SoftLock lockRegion() throws CacheException {
- return null;
- }
-
- /**
- * Called after transaction clearing entire cache region completed.
- * Used by {@link RegionAccessStrategy#unlockRegion}.
- *
- * @param lock The lock previously obtained from {@link #lockRegion}
- * @throws CacheException If failed.
- */
- protected void unlockRegion(SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /**
- * Called during database transaction execution to clear entire cache region after
- * Hibernate executed database update, but before transaction completed.
- * Used by {@link RegionAccessStrategy#removeAll}.
- *
- * @throws CacheException If failed.
- */
- protected final void removeAll() throws CacheException {
- evictAll();
- }
-
- /**
- * Called to remove object from cache without regard to transaction.
- *
- * @param ignite Grid.
- * @param cache Cache.
- * @param key Key.
- * @throws CacheException If failed.
- */
- static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) throws CacheException {
- try {
- key = cache.keyTransformer().transform(key);
-
- ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name()));
- }
- catch (IgniteException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Called to remove all data from cache without regard to transaction.
- *
- * @param cache Cache.
- * @throws CacheException If failed.
- */
- static void evictAll(IgniteInternalCache<Object,Object> cache) throws CacheException {
- try {
- cache.clear();
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Callable invalidates given key.
- */
- private static class ClearKeyCallable implements IgniteCallable<Void>, Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** */
- private Object key;
-
- /** */
- private String cacheName;
-
- /**
- * Empty constructor required by {@link Externalizable}.
- */
- public ClearKeyCallable() {
- // No-op.
- }
-
- /**
- * @param key Key to clear.
- * @param cacheName Cache name.
- */
- private ClearKeyCallable(Object key, String cacheName) {
- this.key = key;
- this.cacheName = cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() throws IgniteCheckedException {
- IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
- assert cache != null;
-
- cache.clearLocally(key);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(key);
-
- U.writeString(out, cacheName);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- key = in.readObject();
-
- cacheName = U.readString(in);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
deleted file mode 100644
index 7204083..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ /dev/null
@@ -1,801 +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.hibernate;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import javax.cache.Cache;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorResult;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CacheMetrics;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.mxbean.CacheMetricsMXBean;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Hibernate cache proxy used to substitute hibernate keys with ignite keys.
- */
-public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> {
- /** Delegate. */
- private final IgniteInternalCache<Object, Object> delegate;
-
- /** Transformer. */
- private final HibernateKeyTransformer keyTransformer;
-
- /**
- * @param delegate Delegate.
- * @param keyTransformer Key keyTransformer.
- */
- HibernateCacheProxy(
- IgniteInternalCache<Object, Object> delegate,
- HibernateKeyTransformer keyTransformer
- ) {
- assert delegate != null;
- assert keyTransformer != null;
-
- this.delegate = delegate;
- this.keyTransformer = keyTransformer;
- }
-
- /**
- * @return HibernateKeyTransformer
- */
- HibernateKeyTransformer keyTransformer(){
- return keyTransformer;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return delegate.name();
- }
-
- /** {@inheritDoc} */
- @Override public boolean skipStore() {
- return delegate.skipStore();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache setSkipStore(boolean skipStore) {
- return delegate.setSkipStore(skipStore);
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return delegate.isEmpty();
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsKey(Object key) {
- return delegate.containsKey(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> containsKeyAsync(Object key) {
- return delegate.containsKeyAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsKeys(Collection keys) {
- return delegate.containsKey(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection keys) {
- return delegate.containsKeysAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object localPeek(
- Object key,
- CachePeekMode[] peekModes,
- @Nullable IgniteCacheExpiryPolicy plc
- ) throws IgniteCheckedException {
- return delegate.localPeek(keyTransformer.transform(key), peekModes, plc);
- }
-
- /** {@inheritDoc} */
- @Override public Iterable<Cache.Entry<Object, Object>> localEntries(
- CachePeekMode[] peekModes
- ) throws IgniteCheckedException {
- return delegate.localEntries(peekModes);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(Object key) throws IgniteCheckedException {
- return delegate.get(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public CacheEntry getEntry(Object key) throws IgniteCheckedException {
- return delegate.getEntry(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAsync(Object key) {
- return delegate.getAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<CacheEntry<Object, Object>> getEntryAsync(Object key) {
- return delegate.getEntryAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Map getAll(@Nullable Collection keys) throws IgniteCheckedException {
- return delegate.getAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<CacheEntry<Object, Object>> getEntries(
- @Nullable Collection keys) throws IgniteCheckedException {
- return delegate.getEntries(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map<Object, Object>> getAllAsync(@Nullable Collection keys) {
- return delegate.getAllAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Collection<CacheEntry<Object,Object>>> getEntriesAsync(
- @Nullable Collection keys
- ) {
- return delegate.getEntriesAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndPut(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndPutAsync(Object key, Object val) {
- return delegate.getAndPutAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean put(Object key, Object val) throws IgniteCheckedException {
- return delegate.put(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> putAsync(Object key, Object val) {
- return delegate.putAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndPutIfAbsent(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndPutIfAbsentAsync(Object key, Object val) {
- return delegate.getAndPutIfAbsentAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean putIfAbsent(Object key, Object val) throws IgniteCheckedException {
- return delegate.putIfAbsent(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(Object key, Object val) {
- return delegate.putIfAbsentAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndReplace(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndReplace(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndReplaceAsync(Object key, Object val) {
- return delegate.getAndReplaceAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(Object key, Object val) throws IgniteCheckedException {
- return delegate.replace(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object val) {
- return delegate.replaceAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(Object key, Object oldVal, Object newVal) throws IgniteCheckedException {
- return delegate.replace(keyTransformer.transform(key), oldVal, newVal);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object oldVal, Object newVal) {
- return delegate.replaceAsync(keyTransformer.transform(key), oldVal, newVal);
- }
-
- /** {@inheritDoc} */
- @Override public void putAll(@Nullable Map m) throws IgniteCheckedException {
- delegate.putAll(transform(m));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> putAllAsync(@Nullable Map m) {
- return delegate.putAllAsync(transform(m));
- }
-
- /** {@inheritDoc} */
- @Override public Set keySet() {
- return delegate.keySet();
- }
-
- /** {@inheritDoc} */
- @Override public Set keySetx() {
- return delegate.keySetx();
- }
-
- /** {@inheritDoc} */
- @Override public Set primaryKeySet() {
- return delegate.primaryKeySet();
- }
-
- /** {@inheritDoc} */
- @Override public Iterable values() {
- return delegate.values();
- }
-
- /** {@inheritDoc} */
- @Override public Set<Cache.Entry<Object, Object>> entrySet() {
- return delegate.entrySet();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Set<Cache.Entry<Object,Object>> entrySet(int part) {
- return delegate.entrySet(part);
- }
-
- /** {@inheritDoc} */
- @Override public Set<Cache.Entry<Object, Object>> entrySetx(CacheEntryPredicate... filter) {
- return delegate.entrySetx(filter);
- }
-
- /** {@inheritDoc} */
- @Override public Transaction txStart(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation
- ) {
- return delegate.txStart(concurrency, isolation);
- }
-
- /** {@inheritDoc} */
- @Override public GridNearTxLocal txStartEx(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation
- ) {
- return delegate.txStartEx(concurrency, isolation);
- }
-
- /** {@inheritDoc} */
- @Override public Transaction txStart(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation,
- long timeout,
- int txSize
- ) {
- return delegate.txStart(concurrency, isolation, timeout, txSize);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public GridNearTxLocal tx() {
- return delegate.tx();
- }
-
- /** {@inheritDoc} */
- @Override public boolean evict(Object key) {
- return delegate.evict(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll(@Nullable Collection keys) {
- delegate.evictAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
- delegate.clearLocally(srv, near, readers);
- }
-
- /** {@inheritDoc} */
- @Override public boolean clearLocally(Object key) {
- return delegate.clearLocally(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void clearLocallyAll(Set keys, boolean srv, boolean near, boolean readers) {
- delegate.clearLocallyAll((Set<?>)transform(keys), srv, near, readers);
- }
-
- /** {@inheritDoc} */
- @Override public void clear(Object key) throws IgniteCheckedException {
- delegate.clear(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void clearAll(Set keys) throws IgniteCheckedException {
- delegate.clearAll((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void clear() throws IgniteCheckedException {
- delegate.clear();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync() {
- return delegate.clearAsync();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync(Object key) {
- return delegate.clearAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAllAsync(Set keys) {
- return delegate.clearAllAsync((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndRemove(Object key) throws IgniteCheckedException {
- return delegate.getAndRemove(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndRemoveAsync(Object key) {
- return delegate.getAndRemoveAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean remove(Object key) throws IgniteCheckedException {
- return delegate.remove(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> removeAsync(Object key) {
- return delegate.removeAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean remove(Object key, Object val) throws IgniteCheckedException {
- return delegate.remove(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> removeAsync(Object key, Object val) {
- return delegate.removeAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll(@Nullable Collection keys) throws IgniteCheckedException {
- delegate.removeAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection keys) {
- return delegate.removeAllAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll() throws IgniteCheckedException {
- delegate.removeAll();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllAsync() {
- return delegate.removeAllAsync();
- }
-
- /** {@inheritDoc} */
- @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException {
- return delegate.lock(keyTransformer.transform(key), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> lockAsync(Object key, long timeout) {
- return delegate.lockAsync(keyTransformer.transform(key), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public boolean lockAll(@Nullable Collection keys, long timeout) throws IgniteCheckedException {
- return delegate.lockAll(transform(keys), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection keys, long timeout) {
- return delegate.lockAllAsync(transform(keys), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public void unlock(Object key) throws IgniteCheckedException {
- delegate.unlock(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void unlockAll(@Nullable Collection keys) throws IgniteCheckedException {
- delegate.unlockAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isLocked(Object key) {
- return delegate.isLocked(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isLockedByThread(Object key) {
- return delegate.isLockedByThread(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return delegate.size();
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong() {
- return delegate.sizeLong();
- }
-
- /** {@inheritDoc} */
- @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSize(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSizeLong(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSizeLong(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.size(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.sizeLong(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.sizeLong(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) {
- return delegate.sizeAsync(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes) {
- return delegate.sizeLongAsync(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Long> sizeLongAsync(int partition, CachePeekMode[] peekModes) {
- return delegate.sizeLongAsync(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public int nearSize() {
- return delegate.nearSize();
- }
-
- /** {@inheritDoc} */
- @Override public int primarySize() {
- return delegate.primarySize();
- }
-
- /** {@inheritDoc} */
- @Override public long primarySizeLong() {
- return delegate.primarySizeLong();
- }
-
- /** {@inheritDoc} */
- @Override public CacheConfiguration configuration() {
- return delegate.configuration();
- }
-
- /** {@inheritDoc} */
- @Override public Affinity affinity() {
- return delegate.affinity();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics clusterMetrics() {
- return delegate.clusterMetrics();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics clusterMetrics(ClusterGroup grp) {
- return delegate.clusterMetrics(grp);
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics localMetrics() {
- return delegate.localMetrics();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetricsMXBean clusterMxBean() {
- return delegate.clusterMxBean();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetricsMXBean localMxBean() {
- return delegate.localMxBean();
- }
-
- /** {@inheritDoc} */
- @Override public long offHeapEntriesCount() {
- return delegate.offHeapEntriesCount();
- }
-
- /** {@inheritDoc} */
- @Override public long offHeapAllocatedSize() {
- return delegate.offHeapAllocatedSize();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> rebalance() {
- return delegate.rebalance();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache forSubjectId(UUID subjId) {
- return delegate.forSubjectId(subjId);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getForcePrimary(Object key) throws IgniteCheckedException {
- return delegate.getForcePrimary(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getForcePrimaryAsync(Object key) {
- return delegate.getForcePrimaryAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Map getAllOutTx(Set keys) throws IgniteCheckedException {
- return delegate.getAllOutTx((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map<Object, Object>> getAllOutTxAsync(Set keys) {
- return delegate.getAllOutTxAsync((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isIgfsDataCache() {
- return delegate.isIgfsDataCache();
- }
-
- /** {@inheritDoc} */
- @Override public long igfsDataSpaceUsed() {
- return delegate.igfsDataSpaceUsed();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMongoDataCache() {
- return delegate.isMongoDataCache();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMongoMetaCache() {
- return delegate.isMongoMetaCache();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public ExpiryPolicy expiry() {
- return delegate.expiry();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache withExpiryPolicy(ExpiryPolicy plc) {
- return delegate.withExpiryPolicy(plc);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache withNoRetries() {
- return delegate.withNoRetries();
- }
-
- /** {@inheritDoc} */
- @Override public GridCacheContext context() {
- return delegate.context();
- }
-
- /** {@inheritDoc} */
- @Override public void localLoadCache(
- @Nullable IgniteBiPredicate p,
- @Nullable Object... args
- ) throws IgniteCheckedException {
- delegate.localLoadCache(p, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> localLoadCacheAsync(
- @Nullable IgniteBiPredicate p,
- @Nullable Object... args
- ) {
- return delegate.localLoadCacheAsync(p, args);
- }
-
- /** {@inheritDoc} */
- @Override public Object getTopologySafe(Object key) throws IgniteCheckedException {
- return delegate.getTopologySafe(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Integer> lostPartitions() {
- return delegate.lostPartitions();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public EntryProcessorResult invoke(
- @Nullable AffinityTopologyVersion topVer,
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) throws IgniteCheckedException {
- return delegate.invoke(topVer, key, entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map> invokeAllAsync(Map map, Object... args) {
- return delegate.invokeAllAsync(map, args);
- }
-
- /** {@inheritDoc} */
- @Override public Map invokeAll(Map map, Object... args) throws IgniteCheckedException {
- return delegate.invokeAll(map, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) {
- return delegate.invokeAllAsync((Set<?>)transform(keys), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public Map invokeAll(Set keys, EntryProcessor entryProcessor, Object... args) throws IgniteCheckedException {
- return delegate.invokeAll((Set<?>)transform(keys), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<EntryProcessorResult> invokeAsync(
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) {
- return delegate.invokeAsync(keyTransformer.transform(key), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public EntryProcessorResult invoke(
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) throws IgniteCheckedException {
- return delegate.invoke(keyTransformer.transform(key), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public Iterator<Cache.Entry<Object,Object>> scanIterator(
- boolean keepBinary,
- @Nullable IgniteBiPredicate p
- ) throws IgniteCheckedException {
- return delegate.scanIterator(keepBinary, p);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map drMap) throws IgniteCheckedException {
- return delegate.removeAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAllConflict(Map drMap) throws IgniteCheckedException {
- delegate.removeAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> putAllConflictAsync(Map drMap) throws IgniteCheckedException {
- return delegate.putAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public void putAllConflict(Map drMap) throws IgniteCheckedException {
- delegate.putAllConflict(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache keepBinary() {
- return delegate.keepBinary();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache cache() {
- return delegate.cache();
- }
-
- /** {@inheritDoc} */
- @Override public Iterator iterator() {
- return delegate.iterator();
- }
-
- /**
- * @param keys Keys.
- */
- private Collection<Object> transform(Collection<Object> keys) {
- Collection<Object> res = new LinkedList<>();
-
- for (Object o : keys)
- res.add(keyTransformer.transform(o));
-
- return res;
- }
-
- /**
- * @param map Map.
- */
- private Map<Object, Object> transform(Map<Object, Object> map) {
- Map<Object, Object> res = new HashMap<>();
-
- Set<Map.Entry<Object, Object>> ents = map.entrySet();
-
- for (Map.Entry<Object, Object> e : ents)
- res.put(keyTransformer.transform(e.getKey()), e.getValue());
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
deleted file mode 100644
index eb35a2c..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
+++ /dev/null
@@ -1,100 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-
-/**
- * Implementation of {@link CollectionRegion}. This region is used to store collection data.
- * <p>
- * L2 cache for collection can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entities. -->
- * <mapping class="com.example.Entity"/>
- * <mapping class="com.example.ChildEntity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entities and collection. -->
- * <collection-cache collection="com.example.Entity" usage="nonstrict-read-write"/>
- * <collection-cache collection="com.example.ChildEntity" usage="nonstrict-read-write"/>
- * <collection-cache collection="com.example.Entity.children" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache for collection can be enabled using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * public class Entity {
- * ...
- *
- * @javax.persistence.OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
- * @javax.persistence.JoinColumn(name="PARENT_ID")
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public List<ChildEntity> getChildren() {...}
- * }
- * </pre>
- * Note: the collection cache does not cache the state of the actual entities in the cache, it caches only identifier
- * values. For this reason, the collection cache should always be used in conjunction with
- * the second-level cache for those entities expected to be cached as part of a collection cache.
- */
-public class HibernateCollectionRegion extends HibernateTransactionalDataRegion implements CollectionRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- * @param dataDesc Region data description.
- */
- public HibernateCollectionRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * Collection region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
- implements CollectionRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegion getRegion() {
- return HibernateCollectionRegion.this;
- }
- }
-}
\ No newline at end of file
[30/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
deleted file mode 100644
index f847c97..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
+++ /dev/null
@@ -1,1948 +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.hibernate;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import javax.persistence.FetchType;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToMany;
-import javax.persistence.OneToOne;
-import javax.persistence.PersistenceException;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.ObjectNotFoundException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.annotations.NaturalId;
-import org.hibernate.annotations.NaturalIdCache;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cache.spi.GeneralDataRegion;
-import org.hibernate.cache.spi.TransactionalDataRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Environment;
-import org.hibernate.exception.ConstraintViolationException;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
-import org.hibernate.stat.NaturalIdCacheStatistics;
-import org.hibernate.stat.SecondLevelCacheStatistics;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_ACCESS_TYPE_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.IGNITE_INSTANCE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.REGION_CACHE_PROPERTY;
-import static org.hibernate.cfg.Environment.CACHE_REGION_FACTORY;
-import static org.hibernate.cfg.Environment.GENERATE_STATISTICS;
-import static org.hibernate.cfg.Environment.HBM2DDL_AUTO;
-import static org.hibernate.cfg.Environment.RELEASE_CONNECTIONS;
-import static org.hibernate.cfg.Environment.USE_QUERY_CACHE;
-import static org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE;
-
-/**
- *
- * Tests Hibernate L2 cache.
- */
-public class HibernateL2CacheSelfTest extends GridCommonAbstractTest {
- /** */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
- /** */
- public static final String ENTITY_NAME = Entity.class.getName();
-
- /** */
- public static final String ENTITY2_NAME = Entity2.class.getName();
-
- /** */
- public static final String VERSIONED_ENTITY_NAME = VersionedEntity.class.getName();
-
- /** */
- public static final String CHILD_ENTITY_NAME = ChildEntity.class.getName();
-
- /** */
- public static final String PARENT_ENTITY_NAME = ParentEntity.class.getName();
-
- /** */
- public static final String CHILD_COLLECTION_REGION = ENTITY_NAME + ".children";
-
- /** */
- public static final String NATURAL_ID_REGION =
- "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity##NaturalId";
-
- /** */
- public static final String NATURAL_ID_REGION2 =
- "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity2##NaturalId";
-
- /** */
- private SessionFactory sesFactory1;
-
- /** */
- private SessionFactory sesFactory2;
-
- /**
- * First Hibernate test entity.
- */
- @javax.persistence.Entity
- @NaturalIdCache
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class Entity {
- /** */
- private int id;
-
- /** */
- private String name;
-
- /** */
- private Collection<ChildEntity> children;
-
- /**
- * Default constructor required by Hibernate.
- */
- public Entity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param name Name.
- */
- public Entity(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Name.
- */
- @NaturalId(mutable = true)
- public String getName() {
- return name;
- }
-
- /**
- * @param name Name.
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @return Children.
- */
- @OneToMany(cascade=javax.persistence.CascadeType.ALL, fetch=FetchType.LAZY)
- @JoinColumn(name="ENTITY_ID")
- public Collection<ChildEntity> getChildren() {
- return children;
- }
-
- /**
- * @param children Children.
- */
- public void setChildren(Collection<ChildEntity> children) {
- this.children = children;
- }
- }
-
- /**
- * Second Hibernate test entity.
- */
- @javax.persistence.Entity
- @NaturalIdCache
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class Entity2 {
- /** */
- private int id;
-
- /** */
- private String name;
-
- /** */
- private Collection<ChildEntity> children;
-
- /**
- * Default constructor required by Hibernate.
- */
- public Entity2() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param name Name.
- */
- public Entity2(int id, String name) {
- this.id = id;
- this.name = name;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Name.
- */
- @NaturalId(mutable = true)
- public String getName() {
- return name;
- }
-
- /**
- * @param name Name.
- */
- public void setName(String name) {
- this.name = name;
- }
- }
-
- /**
- * Hibernate child entity referenced by {@link Entity}.
- */
- @javax.persistence.Entity
- @SuppressWarnings("PublicInnerClass")
- public static class ChildEntity {
- /** */
- private int id;
-
- /**
- * Default constructor required by Hibernate.
- */
- public ChildEntity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- */
- public ChildEntity(int id) {
- this.id = id;
- }
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Hibernate entity referencing {@link Entity}.
- */
- @javax.persistence.Entity
- @SuppressWarnings("PublicInnerClass")
- public static class ParentEntity {
- /** */
- private int id;
-
- /** */
- private Entity entity;
-
- /**
- * Default constructor required by Hibernate.
- */
- public ParentEntity() {
- // No-op.
- }
-
- /**
- * @param id ID.
- * @param entity Referenced entity.
- */
- public ParentEntity(int id, Entity entity) {
- this.id = id;
- this.entity = entity;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Referenced entity.
- */
- @OneToOne
- public Entity getEntity() {
- return entity;
- }
-
- /**
- * @param entity Referenced entity.
- */
- public void setEntity(Entity entity) {
- this.entity = entity;
- }
- }
-
- /**
- * Hibernate entity.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- public static class VersionedEntity {
- /** */
- private int id;
-
- /** */
- private long ver;
-
- /**
- * Default constructor required by Hibernate.
- */
- public VersionedEntity() {
- }
-
- /**
- * @param id ID.
- */
- public VersionedEntity(int id) {
- this.id = id;
- }
-
- /**
- * @return ID.
- */
- @Id
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
-
- /**
- * @return Version.
- */
- @javax.persistence.Version
- public long getVersion() {
- return ver;
- }
-
- /**
- * @param ver Version.
- */
- public void setVersion(long ver) {
- this.ver = ver;
- }
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(discoSpi);
-
- cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"),
- generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"),
- transactionalRegionConfiguration(ENTITY_NAME),
- transactionalRegionConfiguration(ENTITY2_NAME),
- transactionalRegionConfiguration(VERSIONED_ENTITY_NAME),
- transactionalRegionConfiguration(PARENT_ENTITY_NAME),
- transactionalRegionConfiguration(CHILD_ENTITY_NAME),
- transactionalRegionConfiguration(CHILD_COLLECTION_REGION),
- transactionalRegionConfiguration(NATURAL_ID_REGION),
- transactionalRegionConfiguration(NATURAL_ID_REGION2));
-
- return cfg;
- }
-
- /**
- * @param regionName Region name.
- * @return Cache configuration for {@link GeneralDataRegion}.
- */
- private CacheConfiguration generalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(regionName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(ATOMIC);
-
- cfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setBackups(1);
-
- cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- return cfg;
- }
-
- /**
- * @param regionName Region name.
- * @return Cache configuration for {@link TransactionalDataRegion}.
- */
- protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(regionName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(TRANSACTIONAL);
-
- cfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setBackups(1);
-
- cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
-
- return cfg;
- }
-
- /**
- * @return Hibernate registry builder.
- */
- protected StandardServiceRegistryBuilder registryBuilder() {
- StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
-
- builder.applySetting("hibernate.connection.url", CONNECTION_URL);
-
- return builder;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(2);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- cleanup();
- }
-
- /**
- * @return Hibernate L2 cache access types to test.
- */
- protected AccessType[] accessTypes() {
- return new AccessType[]{AccessType.READ_ONLY, AccessType.NONSTRICT_READ_WRITE, AccessType.READ_WRITE};
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollectionCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testCollectionCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- @SuppressWarnings("unchecked")
- private void testCollectionCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, Integer> idToChildCnt = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- Entity e = new Entity(i, "name-" + i);
-
- Collection<ChildEntity> children = new ArrayList<>();
-
- for (int j = 0; j < 3; j++)
- children.add(new ChildEntity());
-
- e.setChildren(children);
-
- idToChildCnt.put(e.getId(), e.getChildren().size());
-
- ses.save(e);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Load children, this should populate cache.
-
- ses = sesFactory1.openSession();
-
- try {
- List<Entity> list = ses.createCriteria(ENTITY_NAME).list();
-
- assertEquals(idToChildCnt.size(), list.size());
-
- for (Entity e : list)
- assertEquals((int)idToChildCnt.get(e.getId()), e.getChildren().size());
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 3, 0);
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- // Update children for one entity.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.getChildren().remove(e1.getChildren().iterator().next());
-
- ses.update(e1);
-
- idToChildCnt.put(e1.getId(), e1.getChildren().size());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
-
- // Update children for the same entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.getChildren().remove(e1.getChildren().iterator().next());
-
- ses.update(e1);
-
- idToChildCnt.put(e1.getId(), e1.getChildren().size());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
- assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testEntityCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testEntityCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testEntityCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, String> idToName = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 2; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- idToName.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates and inserts in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed1");
-
- ses.update(e0);
-
- idToName.put(0, e0.getName());
-
- ses.save(new Entity(2, "name-2"));
-
- idToName.put(2, "name-2");
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-1-changed1");
-
- ses.update(e1);
-
- idToName.put(1, e1.getName());
-
- ses.save(new Entity(3, "name-3"));
-
- idToName.put(3, "name-3");
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates, inserts and deletes in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity(4, "name-4"));
-
- idToName.put(4, "name-4");
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed2");
-
- ses.update(e0);
-
- idToName.put(e0.getId(), e0.getName());
-
- ses.delete(ses.load(Entity.class, 1));
-
- idToName.remove(1);
-
- Entity e2 = (Entity)ses.load(Entity.class, 2);
-
- e2.setName("name-2-changed1");
-
- ses.update(e2);
-
- idToName.put(e2.getId(), e2.getName());
-
- ses.delete(ses.load(Entity.class, 3));
-
- idToName.remove(3);
-
- ses.save(new Entity(5, "name-5"));
-
- idToName.put(5, "name-5");
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 1, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 1, 3);
-
- // Try to update the same entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e0 = (Entity)ses.load(Entity.class, 0);
-
- e0.setName("name-0-changed3");
-
- ses.update(e0);
-
- idToName.put(e0.getId(), e0.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTwoEntitiesSameCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testTwoEntitiesSameCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testTwoEntitiesSameCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- Map<Integer, String> idToName1 = new HashMap<>();
- Map<Integer, String> idToName2 = new HashMap<>();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 2; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
- ses.save(new Entity2(i, name));
-
- idToName1.put(i, name);
- idToName2.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- try {
- // Updates both entities in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 0);
-
- e.setName("name-0-changed1");
-
- ses.update(e);
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 0);
-
- e2.setName("name-e2-0-changed1");
-
- ses.update(e2);
-
- idToName1.put(0, e.getName());
- idToName2.put(0, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory1.openSession();
-
- try {
- // Remove entity1 and insert entity2 in single transaction.
-
- Transaction tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 0);
-
- ses.delete(e);
-
- Entity2 e2 = new Entity2(2, "name-2");
-
- ses.save(e2);
-
- idToName1.remove(0);
- idToName2.put(2, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- // Update, remove, insert in single transaction, transaction fails.
-
- Entity e = (Entity)ses.load(Entity.class, 1);
-
- e.setName("name-1-changed1");
-
- ses.update(e); // Valid update.
-
- ses.save(new Entity(2, "name-2")); // Valid insert.
-
- ses.delete(ses.load(Entity2.class, 0)); // Valid delete.
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
-
- e2.setName("name-2"); // Invalid update, not-unique name.
-
- ses.update(e2);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 2, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 2, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
-
- ses = sesFactory2.openSession();
-
- try {
- // Update, remove, insert in single transaction.
-
- tx = ses.beginTransaction();
-
- Entity e = (Entity)ses.load(Entity.class, 1);
-
- e.setName("name-1-changed1");
-
- ses.update(e);
-
- idToName1.put(1, e.getName());
-
- ses.save(new Entity(2, "name-2"));
-
- idToName1.put(2, "name-2");
-
- ses.delete(ses.load(Entity2.class, 0));
-
- idToName2.remove(0);
-
- Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
-
- e2.setName("name-e2-2-changed");
-
- ses.update(e2);
-
- idToName2.put(1, e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
-
- assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 0, 100);
- assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 0, 100);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testVersionedEntity() throws Exception {
- for (AccessType accessType : accessTypes())
- testVersionedEntity(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testVersionedEntity(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- VersionedEntity e0 = new VersionedEntity(0);
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(e0);
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- long ver;
-
- try {
- ver = ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion();
- }
- finally {
- ses.close();
- }
-
- SecondLevelCacheStatistics stats1 =
- sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
- SecondLevelCacheStatistics stats2 =
- sesFactory2.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
-
- assertEquals(1, stats1.getElementCountInMemory());
- assertEquals(1, stats2.getElementCountInMemory());
-
- ses = sesFactory2.openSession();
-
- try {
- assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
- }
- finally {
- ses.close();
- }
-
- assertEquals(1, stats2.getElementCountInMemory());
- assertEquals(1, stats2.getHitCount());
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- e0.setVersion(ver - 1);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- ses.update(e0);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
- }
- finally {
- tx.rollback();
-
- ses.close();
- }
-
- sesFactory1.getStatistics().clear();
-
- stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
-
- ses = sesFactory1.openSession();
-
- try {
- assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
- }
- finally {
- ses.close();
- }
-
- assertEquals(1, stats1.getElementCountInMemory());
- assertEquals(1, stats1.getHitCount());
- assertEquals(1, stats2.getElementCountInMemory());
- assertEquals(1, stats2.getHitCount());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNaturalIdCache() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1084");
-
- for (AccessType accessType : accessTypes())
- testNaturalIdCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testNaturalIdCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<String, Integer> nameToId = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- nameToId.put(name, i);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- try {
- for (Map.Entry<String, Integer> e : nameToId.entrySet())
- ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-100");
- assertNaturalIdCache(sesFactory1, nameToId, "name-100");
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- // Update naturalId.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- nameToId.remove(e1.getName());
-
- e1.setName("name-1-changed1");
-
- nameToId.put(e1.getName(), e1.getId());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-1");
- assertNaturalIdCache(sesFactory1, nameToId, "name-1");
-
- // Update entity using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- nameToId.remove(e1.getName());
-
- e1.setName("name-1-changed2");
-
- nameToId.put(e1.getName(), e1.getId());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-1-changed1");
- assertNaturalIdCache(sesFactory1, nameToId, "name-1-changed1");
-
- // Try invalid NaturalId update.
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-0"); // Invalid update (duplicated name).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (ConstraintViolationException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId);
- assertNaturalIdCache(sesFactory1, nameToId);
-
- // Delete entity.
-
- ses = sesFactory2.openSession();
-
- try {
- tx = ses.beginTransaction();
-
- Entity e2 = (Entity)ses.load(Entity.class, 2);
-
- ses.delete(e2);
-
- nameToId.remove(e2.getName());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertNaturalIdCache(sesFactory2, nameToId, "name-2");
- assertNaturalIdCache(sesFactory1, nameToId, "name-2");
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testEntityCacheTransactionFails() throws Exception {
- for (AccessType accessType : accessTypes())
- testEntityCacheTransactionFails(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testEntityCacheTransactionFails(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- Map<Integer, String> idToName = new HashMap<>();
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 3; i++) {
- String name = "name-" + i;
-
- ses.save(new Entity(i, name));
-
- idToName.put(i, name);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
-
- ses = sesFactory1.openSession();
-
- Transaction tx = ses.beginTransaction();
-
- try {
- ses.save(new Entity(3, "name-3")); // Valid insert.
-
- ses.save(new Entity(0, "name-0")); // Invalid insert (duplicated ID).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
-
- if (accessType == AccessType.READ_ONLY)
- return;
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- Entity e0 = (Entity)ses.load(Entity.class, 0);
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e0.setName("name-10"); // Valid update.
- e1.setName("name-2"); // Invalid update (violates unique constraint).
-
- ses.update(e0);
- ses.update(e1);
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
-
- ses = sesFactory1.openSession();
-
- try {
- // Create parent entity referencing Entity with ID = 0.
-
- tx = ses.beginTransaction();
-
- ses.save(new ParentEntity(0, (Entity) ses.load(Entity.class, 0)));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- ses.save(new Entity(3, "name-3")); // Valid insert.
-
- Entity e1 = (Entity)ses.load(Entity.class, 1);
-
- e1.setName("name-10"); // Valid update.
-
- ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
-
- ses = sesFactory1.openSession();
-
- tx = ses.beginTransaction();
-
- try {
- ses.delete(ses.load(Entity.class, 1)); // Valid delete.
-
- idToName.remove(1);
-
- ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
-
- tx.commit();
-
- fail("Commit must fail.");
- }
- catch (PersistenceException e) {
- log.info("Expected exception: " + e);
-
- tx.rollback();
- }
- finally {
- ses.close();
- }
-
- assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
- assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testQueryCache() throws Exception {
- for (AccessType accessType : accessTypes())
- testQueryCache(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testQueryCache(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < 5; i++)
- ses.save(new Entity(i, "name-" + i));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Run some queries.
-
- ses = sesFactory1.openSession();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(2, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
-
- // Run queries using another SessionFactory.
-
- ses = sesFactory2.openSession();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(2, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
-
- Query qry3 = ses.createQuery("from " + ENTITY_NAME + " where id > 1");
-
- qry3.setCacheable(true);
-
- assertEquals(3, qry3.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(2, sesFactory2.getStatistics().getQueryCacheHitCount());
- assertEquals(1, sesFactory2.getStatistics().getQueryCacheMissCount());
- assertEquals(1, sesFactory2.getStatistics().getQueryCachePutCount());
-
- // Update entity, it should invalidate query cache.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity(5, "name-5"));
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- // Run queries.
-
- ses = sesFactory1.openSession();
-
- sesFactory1.getStatistics().clear();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(3, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
-
- // Clear query cache using another SessionFactory.
-
- sesFactory2.getCache().evictDefaultQueryRegion();
-
- ses = sesFactory1.openSession();
-
- // Run queries again.
-
- sesFactory1.getStatistics().clear();
-
- try {
- Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
-
- qry1.setCacheable(true);
-
- assertEquals(3, qry1.list().size());
-
- Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
-
- qry2.setCacheable(true);
-
- assertEquals(1, qry2.list().size());
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
- assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRegionClear() throws Exception {
- for (AccessType accessType : accessTypes())
- testRegionClear(accessType);
- }
-
- /**
- * @param accessType Cache access type.
- * @throws Exception If failed.
- */
- private void testRegionClear(AccessType accessType) throws Exception {
- createSessionFactories(accessType);
-
- try {
- final int ENTITY_CNT = 100;
-
- Session ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- for (int i = 0; i < ENTITY_CNT; i++) {
- Entity e = new Entity(i, "name-" + i);
-
- Collection<ChildEntity> children = new ArrayList<>();
-
- for (int j = 0; j < 3; j++)
- children.add(new ChildEntity());
-
- e.setChildren(children);
-
- ses.save(e);
- }
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- loadEntities(sesFactory2, ENTITY_CNT);
-
- SecondLevelCacheStatistics stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
- SecondLevelCacheStatistics stats2 = sesFactory2.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
-
- NaturalIdCacheStatistics idStats1 =
- sesFactory1.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
- NaturalIdCacheStatistics idStats2 =
- sesFactory2.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
-
- SecondLevelCacheStatistics colStats1 =
- sesFactory1.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
- SecondLevelCacheStatistics colStats2 =
- sesFactory2.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
-
- assertEquals(ENTITY_CNT, stats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, stats2.getElementCountInMemory());
-
- assertEquals(ENTITY_CNT, idStats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, idStats2.getElementCountInMemory());
-
- assertEquals(ENTITY_CNT, colStats1.getElementCountInMemory());
- assertEquals(ENTITY_CNT, colStats2.getElementCountInMemory());
-
- // Test cache is cleared after update query.
-
- ses = sesFactory1.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.createQuery("delete from " + ENTITY_NAME + " where name='no such name'").executeUpdate();
-
- ses.createQuery("delete from " + ChildEntity.class.getName() + " where id=-1").executeUpdate();
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- assertEquals(0, stats1.getElementCountInMemory());
- assertEquals(0, stats2.getElementCountInMemory());
-
- assertEquals(0, idStats1.getElementCountInMemory());
- assertEquals(0, idStats2.getElementCountInMemory());
-
- assertEquals(0, colStats1.getElementCountInMemory());
- assertEquals(0, colStats2.getElementCountInMemory());
-
- // Load some data in cache.
-
- loadEntities(sesFactory1, 10);
-
- assertEquals(10, stats1.getElementCountInMemory());
- assertEquals(10, stats2.getElementCountInMemory());
- assertEquals(10, idStats1.getElementCountInMemory());
- assertEquals(10, idStats2.getElementCountInMemory());
-
- // Test evictAll method.
-
- sesFactory2.getCache().evictEntityRegion(ENTITY_NAME);
-
- assertEquals(0, stats1.getElementCountInMemory());
- assertEquals(0, stats2.getElementCountInMemory());
-
- sesFactory2.getCache().evictNaturalIdRegion(ENTITY_NAME);
-
- assertEquals(0, idStats1.getElementCountInMemory());
- assertEquals(0, idStats2.getElementCountInMemory());
-
- sesFactory2.getCache().evictCollectionRegion(CHILD_COLLECTION_REGION);
-
- assertEquals(0, colStats1.getElementCountInMemory());
- assertEquals(0, colStats2.getElementCountInMemory());
- }
- finally {
- cleanup();
- }
- }
-
- /**
- * @param sesFactory Session factory.
- * @param nameToId Name-ID mapping.
- * @param absentNames Absent entities' names.
- */
- private void assertNaturalIdCache(SessionFactory sesFactory, Map<String, Integer> nameToId, String... absentNames) {
- sesFactory.getStatistics().clear();
-
- NaturalIdCacheStatistics stats =
- sesFactory.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
-
- long hitBefore = stats.getHitCount();
-
- long missBefore = stats.getMissCount();
-
- final Session ses = sesFactory.openSession();
-
- try {
- for (Map.Entry<String, Integer> e : nameToId.entrySet())
- assertEquals((int)e.getValue(), ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId());
-
- for (String name : absentNames)
- assertNull((ses.bySimpleNaturalId(Entity.class).load(name)));
-
- assertEquals(nameToId.size() + hitBefore, stats.getHitCount());
-
- assertEquals(absentNames.length + missBefore, stats.getMissCount());
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * @param sesFactory Session factory.
- * @param idToChildCnt Number of children per entity.
- * @param expHit Expected cache hits.
- * @param expMiss Expected cache misses.
- */
- @SuppressWarnings("unchecked")
- private void assertCollectionCache(SessionFactory sesFactory, Map<Integer, Integer> idToChildCnt, int expHit,
- int expMiss) {
- sesFactory.getStatistics().clear();
-
- Session ses = sesFactory.openSession();
-
- try {
- for(Map.Entry<Integer, Integer> e : idToChildCnt.entrySet()) {
- Entity entity = (Entity)ses.load(Entity.class, e.getKey());
-
- assertEquals((int)e.getValue(), entity.getChildren().size());
- }
- }
- finally {
- ses.close();
- }
-
- SecondLevelCacheStatistics stats =
- sesFactory.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
-
- assertEquals(expHit, stats.getHitCount());
-
- assertEquals(expMiss, stats.getMissCount());
- }
-
- /**
- * @param sesFactory Session factory.
- * @param cnt Number of entities to load.
- */
- private void loadEntities(SessionFactory sesFactory, int cnt) {
- Session ses = sesFactory.openSession();
-
- try {
- for (int i = 0; i < cnt; i++) {
- Entity e = (Entity)ses.load(Entity.class, i);
-
- assertEquals("name-" + i, e.getName());
-
- assertFalse(e.getChildren().isEmpty());
-
- ses.bySimpleNaturalId(Entity.class).load(e.getName());
- }
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * @param entityName Entity name.
- * @param sesFactory Session factory.
- * @param idToName ID to name mapping.
- * @param absentIds Absent entities' IDs.
- */
- private void assertEntityCache(String entityName, SessionFactory sesFactory, Map<Integer, String> idToName,
- Integer... absentIds) {
- assert entityName.equals(ENTITY_NAME) || entityName.equals(ENTITY2_NAME) : entityName;
-
- sesFactory.getStatistics().clear();
-
- final Session ses = sesFactory.openSession();
-
- final boolean entity1 = entityName.equals(ENTITY_NAME);
-
- try {
- if (entity1) {
- for (Map.Entry<Integer, String> e : idToName.entrySet())
- assertEquals(e.getValue(), ((Entity)ses.load(Entity.class, e.getKey())).getName());
- }
- else {
- for (Map.Entry<Integer, String> e : idToName.entrySet())
- assertEquals(e.getValue(), ((Entity2)ses.load(Entity2.class, e.getKey())).getName());
- }
-
- for (final int id : absentIds) {
- GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override public Void call() throws Exception {
- if (entity1)
- ((Entity)ses.load(Entity.class, id)).getName();
- else
- ((Entity2)ses.load(Entity2.class, id)).getName();
-
- return null;
- }
- }, ObjectNotFoundException.class, null);
- }
-
- SecondLevelCacheStatistics stats = sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
-
- assertEquals(idToName.size(), stats.getHitCount());
-
- assertEquals(absentIds.length, stats.getMissCount());
- }
- finally {
- ses.close();
- }
- }
-
- /**
- * Creates session factories.
- *
- * @param accessType Cache access type.
- */
- private void createSessionFactories(AccessType accessType) {
- sesFactory1 = startHibernate(accessType, getTestIgniteInstanceName(0));
-
- sesFactory2 = startHibernate(accessType, getTestIgniteInstanceName(1));
- }
-
- /**
- * Starts Hibernate.
- *
- * @param accessType Cache access type.
- * @param igniteInstanceName Ignite instance name.
- * @return Session factory.
- */
- private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
- StandardServiceRegistryBuilder builder = registryBuilder();
-
- builder.applySetting(HBM2DDL_AUTO, "create");
- builder.applySetting(GENERATE_STATISTICS, "true");
- builder.applySetting(USE_SECOND_LEVEL_CACHE, "true");
- builder.applySetting(USE_QUERY_CACHE, "true");
- builder.applySetting(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
- builder.applySetting(RELEASE_CONNECTIONS, "on_close");
- builder.applySetting(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
- // Use the same cache for Entity and Entity2.
- builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);
- builder.applySetting(DFLT_ACCESS_TYPE_PROPERTY, accessType.name());
- builder.applySetting(Environment.DIALECT, "org.hibernate.dialect.H2Dialect");
- builder.applySetting("hibernate.show_sql", false);
-
- StandardServiceRegistry srvcRegistry = builder.build();
-
- MetadataSources metadataSources = new MetadataSources(srvcRegistry);
-
- for (Class entityClass : getAnnotatedClasses())
- metadataSources.addAnnotatedClass(entityClass);
-
- Metadata metadata = metadataSources.buildMetadata();
-
- for (PersistentClass entityBinding : metadata.getEntityBindings()) {
- if (!entityBinding.isInherited())
- ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
- }
-
- for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
- collectionBinding.setCacheConcurrencyStrategy( accessType.getExternalName() );
-
- return metadata.buildSessionFactory();
- }
-
- /**
- * @return Entities classes.
- */
- private Class[] getAnnotatedClasses() {
- return new Class[]{Entity.class, Entity2.class, VersionedEntity.class, ChildEntity.class, ParentEntity.class};
- }
-
- /**
- * Closes session factories and clears data from caches.
- *
- * @throws Exception If failed.
- */
- private void cleanup() throws Exception {
- if (sesFactory1 != null)
- sesFactory1.close();
-
- sesFactory1 = null;
-
- if (sesFactory2 != null)
- sesFactory2.close();
-
- sesFactory2 = null;
-
- for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
- cache.clear();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
deleted file mode 100644
index 5175292..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
+++ /dev/null
@@ -1,154 +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.hibernate;
-
-import java.util.Collections;
-import javax.cache.configuration.Factory;
-import javax.transaction.Synchronization;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import org.apache.commons.dbcp.managed.BasicManagedDataSource;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.h2.jdbcx.JdbcDataSource;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Environment;
-import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
-import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
-import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
-import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
-import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
-import org.jetbrains.annotations.Nullable;
-import org.objectweb.jotm.Jotm;
-
-/**
- *
- * Tests Hibernate L2 cache with TRANSACTIONAL access mode (Hibernate and Cache are configured
- * to used the same TransactionManager).
- */
-public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfTest {
- /** */
- private static Jotm jotm;
-
- /**
- */
- private static class TestJtaPlatform extends AbstractJtaPlatform {
- /** {@inheritDoc} */
- @Override protected TransactionManager locateTransactionManager() {
- return jotm.getTransactionManager();
- }
-
- /** {@inheritDoc} */
- @Override protected UserTransaction locateUserTransaction() {
- return jotm.getUserTransaction();
- }
- }
-
- /**
- */
- @SuppressWarnings("PublicInnerClass")
- public static class TestTmFactory implements Factory<TransactionManager> {
- /** */
- private static final long serialVersionUID = 0;
-
- /** {@inheritDoc} */
- @Override public TransactionManager create() {
- return jotm.getTransactionManager();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- jotm = new Jotm(true, false);
-
- super.beforeTestsStarted();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- super.afterTestsStopped();
-
- if (jotm != null)
- jotm.stop();
-
- jotm = null;
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- cfg.getTransactionConfiguration().setTxManagerFactory(new TestTmFactory());
- cfg.getTransactionConfiguration().setUseJtaSynchronization(useJtaSynchronization());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
- CacheConfiguration cfg = super.transactionalRegionConfiguration(regionName);
-
- cfg.setNearConfiguration(null);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override protected StandardServiceRegistryBuilder registryBuilder() {
- StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
-
- DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
-
- BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.
-
- dataSrc.setTransactionManager(jotm.getTransactionManager());
-
- dataSrc.setDefaultAutoCommit(false);
-
- JdbcDataSource h2DataSrc = new JdbcDataSource();
-
- h2DataSrc.setURL(CONNECTION_URL);
-
- dataSrc.setXaDataSourceInstance(h2DataSrc);
-
- connProvider.setDataSource(dataSrc);
-
- connProvider.configure(Collections.emptyMap());
-
- builder.addService(ConnectionProvider.class, connProvider);
-
- builder.addService(JtaPlatform.class, new TestJtaPlatform());
-
- builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());
-
- return builder;
- }
-
- /** {@inheritDoc} */
- @Override protected AccessType[] accessTypes() {
- return new AccessType[]{AccessType.TRANSACTIONAL};
- }
-
- /**
- * @return Whether to use {@link Synchronization}.
- */
- protected boolean useJtaSynchronization() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
deleted file mode 100644
index 44899f9..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
+++ /dev/null
@@ -1,31 +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.hibernate;
-
-import javax.transaction.Synchronization;
-
-/**
- * Tests Hibernate L2 cache with TRANSACTIONAL access mode and {@link Synchronization}
- * instead of XA resource.
- */
-public class HibernateL2CacheTransactionalUseSyncSelfTest extends HibernateL2CacheTransactionalSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean useJtaSynchronization() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
deleted file mode 100644
index d5496af..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
+++ /dev/null
@@ -1,46 +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.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.processors.cache.integration.IgniteCacheStoreNodeRestartAbstractTest;
-
-public class CacheHibernateBlobStoreNodeRestartTest extends IgniteCacheStoreNodeRestartAbstractTest {
- /** {@inheritDoc} */
- @Override protected CacheStore getStore() {
- return new CacheHibernateBlobStore();
- }
-
- /** {@inheritDoc} */
- @Override protected CacheMode cacheMode() {
- return CacheMode.PARTITIONED;
- }
-
- /** {@inheritDoc} */
- @Override protected CacheAtomicityMode atomicityMode() {
- return CacheAtomicityMode.ATOMIC;
- }
-
- /** {@inheritDoc} */
- @Override protected NearCacheConfiguration nearConfiguration() {
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
deleted file mode 100644
index d3d2b52..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++ /dev/null
@@ -1,113 +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 java.io.File;
-import java.net.URL;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
-import org.hibernate.FlushMode;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-
-/**
- * Cache store test.
- */
-public class CacheHibernateBlobStoreSelfTest extends
- GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> {
- /**
- * @throws Exception If failed.
- */
- public CacheHibernateBlobStoreSelfTest() throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- Session s = store.session(null);
-
- if (s == null)
- return;
-
- try {
- s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
- .setFlushMode(FlushMode.ALWAYS).executeUpdate();
-
- Transaction hTx = s.getTransaction();
-
- if (hTx != null && hTx.isActive())
- hTx.commit();
- }
- finally {
- s.close();
- }
- }
-
- /** {@inheritDoc} */
- @Override protected CacheHibernateBlobStore<Object, Object> store() {
- return new CacheHibernateBlobStore<>();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByUrl() throws Exception {
- URL url = U.resolveIgniteUrl(
- "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- assert url != null;
-
- store.setHibernateConfigurationPath(url.toString());
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByFile() throws Exception {
- URL url = U.resolveIgniteUrl(
- "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- assert url != null;
-
- File file = new File(url.toURI());
-
- store.setHibernateConfigurationPath(file.getAbsolutePath());
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testConfigurationByResource() throws Exception {
- store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- // Store will be implicitly initialized.
- store.load("key");
- }
-
- @Override public void testSimpleMultithreading() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1757");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
deleted file mode 100644
index d158f81..0000000
--- a/modules/hibernate5/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
+++ /dev/null
@@ -1,326 +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 java.sql.Connection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.persistence.EntityGraph;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceUnitUtil;
-import javax.persistence.Query;
-import javax.persistence.SynchronizationType;
-import javax.persistence.criteria.CriteriaBuilder;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.Ignition;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.Cache;
-import org.hibernate.HibernateException;
-import org.hibernate.Metamodel;
-import org.hibernate.Session;
-import org.hibernate.SessionBuilder;
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-import org.hibernate.StatelessSessionBuilder;
-import org.hibernate.TypeHelper;
-import org.hibernate.boot.spi.SessionFactoryOptions;
-import org.hibernate.engine.spi.FilterDefinition;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.metadata.CollectionMetadata;
-import org.hibernate.stat.Statistics;
-
-/**
- * Test for Cache jdbc blob store factory.
- */
-public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest {
- /** Cache name. */
- private static final String CACHE_NAME = "test";
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheConfiguration() throws Exception {
- try (Ignite ignite1 = startGrid(0)) {
- IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration());
-
- checkStore(cache1);
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testXmlConfiguration() throws Exception {
- try (Ignite ignite = Ignition.start("modules/hibernate/src/test/config/factory-cache.xml")) {
- try(Ignite ignite1 = Ignition.start("modules/hibernate/src/test/config/factory-cache1.xml")) {
- checkStore(ignite.<Integer, String>cache(CACHE_NAME), DummySessionFactoryExt.class);
-
- checkStore(ignite1.<Integer, String>cache(CACHE_NAME), DummySessionFactory.class);
- }
- }
- }
-
-
- /**
- * @throws Exception If failed.
- */
- public void testIncorrectBeanConfiguration() throws Exception {
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
- try(Ignite ignite =
- Ignition.start("modules/hibernate/src/test/config/factory-incorrect-store-cache.xml")) {
- ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
- getCacheStoreFactory().create();
- }
- return null;
- }
- }, IgniteException.class, "Failed to load bean in application context");
- }
-
- /**
- * @return Cache configuration with store.
- */
- private CacheConfiguration<Integer, String> cacheConfiguration() {
- CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
-
- CacheHibernateBlobStoreFactory<Integer, String> factory = new CacheHibernateBlobStoreFactory();
-
- factory.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
- cfg.setCacheStoreFactory(factory);
-
- return cfg;
- }
-
- /**
- * @param cache Ignite cache.
- * @param dataSrcClass Data source class.
- * @throws Exception If store parameters is not the same as in configuration xml.
- */
- private void checkStore(IgniteCache<Integer, String> cache, Class<?> dataSrcClass) throws Exception {
- CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache
- .getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create();
-
- assertEquals(dataSrcClass,
- GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "sesFactory").getClass());
- }
-
- /**
- * @param cache Ignite cache.
- * @throws Exception If store parameters is not the same as in configuration xml.
- */
- private void checkStore(IgniteCache<Integer, String> cache) throws Exception {
- CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache.getConfiguration(CacheConfiguration.class)
- .getCacheStoreFactory().create();
-
- assertEquals("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml",
- GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "hibernateCfgPath"));
- }
-
- /**
- *
- */
- public static class DummySessionFactoryExt extends DummySessionFactory {
- /** */
- public DummySessionFactoryExt() {
- // No-op.
- }
- }
-
- /**
- *
- */
- public static class DummySessionFactory implements SessionFactory {
- /** {@inheritDoc} */
- @Override public SessionFactoryOptions getSessionFactoryOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public SessionBuilder withOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Session openSession() throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Session getCurrentSession() throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSessionBuilder withStatelessOptions() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSession openStatelessSession() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public StatelessSession openStatelessSession(Connection conn) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public ClassMetadata getClassMetadata(Class entityCls) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public ClassMetadata getClassMetadata(String entityName) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public CollectionMetadata getCollectionMetadata(String roleName) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, ClassMetadata> getAllClassMetadata() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Map getAllCollectionMetadata() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Statistics getStatistics() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void close() throws HibernateException {
- }
-
- /** {@inheritDoc} */
- @Override public boolean isClosed() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public Cache getCache() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Set getDefinedFilterNames() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsFetchProfileDefinition(String name) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public TypeHelper getTypeHelper() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Reference getReference() throws NamingException {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public EntityManager createEntityManager() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public EntityManager createEntityManager(Map map) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public EntityManager createEntityManager(SynchronizationType synchronizationType) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public CriteriaBuilder getCriteriaBuilder() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public boolean isOpen() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override public Map<String, Object> getProperties() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public PersistenceUnitUtil getPersistenceUnitUtil() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void addNamedQuery(String s, Query qry) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public <T> T unwrap(Class<T> aCls) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public <T> void addNamedEntityGraph(String s, EntityGraph<T> entityGraph) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public <T> List<EntityGraph<? super T>> findEntityGraphsByType(Class<T> entityCls) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public Metamodel getMetamodel() {
- return null;
- }
- }
-}
\ No newline at end of file
[21/50] [abbrv] ignite git commit: IGNITE-3521: IGFS: removed
"maxSpaceSize" remnants from XML files.
Posted by vo...@apache.org.
IGNITE-3521: IGFS: removed "maxSpaceSize" remnants from XML files.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/860049dc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/860049dc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/860049dc
Branch: refs/heads/master
Commit: 860049dc76f86e3d9339eb8b4a4d5a0a6439f1d1
Parents: 4739458
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 12:14:22 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 12:14:22 2017 +0300
----------------------------------------------------------------------
.../src/test/java/org/apache/ignite/spring/sprint-exclude.xml | 2 --
1 file changed, 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/860049dc/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
index adc87a9..37b460f 100644
--- a/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
+++ b/modules/spring/src/test/java/org/apache/ignite/spring/sprint-exclude.xml
@@ -34,8 +34,6 @@
<bean class="org.apache.ignite.configuration.FileSystemConfiguration">
<property name="name" value="test"/>
- <property name="maxSpaceSize" value="#{100L * 1024 * 1024}"/>
-
<!-- Loopback endpoint. -->
<property name="ipcEndpointConfiguration">
<bean class="org.apache.ignite.igfs.IgfsIpcEndpointConfiguration">
[50/50] [abbrv] ignite git commit: Merge branch 'ignite-2.0'
Posted by vo...@apache.org.
Merge branch 'ignite-2.0'
# Conflicts:
# modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeConfigSelfTest.java
# modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorMultiNodeSelfTest.java
# modules/hibernate-4.2/pom.xml
# modules/hibernate-5.1/pom.xml
# modules/ml/src/main/java/org/apache/ignite/ml/math/ValueMapper.java
# modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/RandomVector.java
# modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
# modules/ml/src/test/java/org/apache/ignite/ml/math/impls/storage/matrix/MatrixStorageFixtures.java
# pom.xml
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/402154c6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/402154c6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/402154c6
Branch: refs/heads/master
Commit: 402154c657a06e581e4a0bf24ada42010ec60ac0
Parents: f328c4e 6998785
Author: devozerov <vo...@gridgain.com>
Authored: Wed Apr 26 16:13:13 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Wed Apr 26 16:13:13 2017 +0300
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 5 +-
assembly/release-fabric-base.xml | 5 -
config/dotnet/default-dotnet.xml | 45 -
examples/pom-standalone-lgpl.xml | 2 +-
examples/pom-standalone.xml | 2 +-
examples/pom.xml | 38 +-
.../hibernate/HibernateL2CacheExample.java | 12 +-
.../examples/datagrid/CacheQueryExample.java | 54 +-
.../streaming/wordcount/QueryWords.java | 3 +-
.../examples/IndexingBridgeMethodTest.java | 93 -
.../IgniteExamplesJ8SelfTestSuite.java | 2 -
.../apache/ignite/gridify/AbstractAopTest.java | 4 +-
.../gridify/ExternalNonSpringAopSelfTest.java | 6 +-
.../benchmarks/jmh/tree/BPlusTreeBenchmark.java | 1 +
.../cassandra/common/PropertyMappingHelper.java | 21 +-
.../persistence/KeyPersistenceSettings.java | 18 +-
.../store/cassandra/persistence/PojoField.java | 21 +-
.../cassandra/persistence/PojoKeyField.java | 7 -
.../cassandra/persistence/PojoValueField.java | 6 -
.../persistence/ValuePersistenceSettings.java | 12 +-
.../org/apache/ignite/tests/pojos/Person.java | 10 +-
.../org/apache/ignite/tests/pojos/Product.java | 7 -
.../apache/ignite/tests/pojos/ProductOrder.java | 8 -
.../jdbc2/JdbcAbstractDmlStatementSelfTest.java | 92 +-
...BinaryMarshallerInsertStatementSelfTest.java | 9 +-
...cBinaryMarshallerMergeStatementSelfTest.java | 9 +-
.../jdbc2/JdbcDynamicIndexAbstractSelfTest.java | 367 ++++
...namicIndexAtomicPartitionedNearSelfTest.java | 26 +
...bcDynamicIndexAtomicPartitionedSelfTest.java | 39 +
...dbcDynamicIndexAtomicReplicatedSelfTest.java | 39 +
...dexTransactionalPartitionedNearSelfTest.java | 26 +
...icIndexTransactionalPartitionedSelfTest.java | 39 +
...micIndexTransactionalReplicatedSelfTest.java | 39 +
.../jdbc2/JdbcInsertStatementSelfTest.java | 4 +-
.../internal/jdbc2/JdbcResultSetSelfTest.java | 2 +-
.../JettyRestProcessorAbstractSelfTest.java | 10 +
.../jdbc/suite/IgniteJdbcDriverTestSuite.java | 8 +
.../clients/src/test/resources/spring-cache.xml | 1 -
.../src/main/java/org/apache/ignite/Ignite.java | 1 -
.../java/org/apache/ignite/IgniteCache.java | 11 -
.../java/org/apache/ignite/IgniteCompute.java | 14 +
.../org/apache/ignite/IgniteFileSystem.java | 6 +-
.../apache/ignite/IgniteSystemProperties.java | 8 +
.../org/apache/ignite/cache/QueryEntity.java | 101 +-
.../org/apache/ignite/cache/QueryIndex.java | 9 +
.../org/apache/ignite/cache/query/Query.java | 48 +
.../ignite/cache/query/SqlFieldsQuery.java | 26 +
.../org/apache/ignite/cache/query/SqlQuery.java | 26 +
.../cache/query/annotations/QuerySqlField.java | 2 +-
.../cache/query/annotations/QueryTextField.java | 4 +-
.../store/jdbc/CacheAbstractJdbcStore.java | 66 +-
.../cache/store/jdbc/CacheJdbcPojoStore.java | 1 -
.../apache/ignite/cluster/ClusterMetrics.java | 4 +-
.../org/apache/ignite/cluster/ClusterNode.java | 11 +-
.../configuration/CacheConfiguration.java | 138 +-
.../configuration/DataPageEvictionMode.java | 10 +-
.../configuration/ExecutorConfiguration.java | 115 +
.../configuration/FileSystemConfiguration.java | 259 +--
.../configuration/IgniteConfiguration.java | 82 +-
.../configuration/MemoryConfiguration.java | 27 +-
.../MemoryPolicyConfiguration.java | 40 +-
.../org/apache/ignite/events/CacheEvent.java | 3 -
.../java/org/apache/ignite/events/Event.java | 1 -
.../org/apache/ignite/events/EventType.java | 111 +-
.../apache/ignite/events/SwapSpaceEvent.java | 105 -
.../org/apache/ignite/igfs/IgfsMetrics.java | 5 +-
.../igfs/secondary/IgfsSecondaryFileSystem.java | 4 +-
.../local/LocalIgfsSecondaryFileSystem.java | 2 +-
.../ignite/internal/ExecutorAwareMessage.java | 31 +
.../apache/ignite/internal/GridComponent.java | 5 +-
.../ignite/internal/GridJobExecuteRequest.java | 32 +-
.../ignite/internal/GridKernalContext.java | 15 +
.../ignite/internal/GridKernalContextImpl.java | 25 +-
.../ignite/internal/GridTaskSessionImpl.java | 15 +-
.../org/apache/ignite/internal/GridTopic.java | 5 +-
.../ignite/internal/IgniteComputeImpl.java | 71 +-
.../org/apache/ignite/internal/IgniteEx.java | 2 +-
.../apache/ignite/internal/IgniteKernal.java | 38 +-
.../org/apache/ignite/internal/IgnitionEx.java | 84 +
.../managers/communication/GridIoManager.java | 25 +-
.../managers/communication/GridIoMessage.java | 13 +
.../communication/GridIoMessageFactory.java | 14 +-
.../managers/communication/GridIoPolicy.java | 3 +
.../managers/indexing/GridIndexingManager.java | 44 -
.../optimized/OptimizedMarshaller.java | 3 +-
.../mem/IgniteOutOfMemoryException.java | 51 +
.../internal/mem/OutOfMemoryException.java | 51 -
.../pagemem/impl/PageMemoryNoStoreImpl.java | 16 +-
.../cache/CacheAffinitySharedManager.java | 3 +-
.../processors/cache/CacheMetricsImpl.java | 21 -
.../cache/CachePartitionExchangeWorkerTask.java | 6 +-
.../cache/DynamicCacheChangeRequest.java | 23 +-
.../cache/DynamicCacheDescriptor.java | 50 +-
.../processors/cache/GridCacheAdapter.java | 29 +-
.../processors/cache/GridCacheAtomicFuture.java | 5 -
.../cache/GridCacheBatchSwapEntry.java | 76 -
.../processors/cache/GridCacheContext.java | 23 -
.../processors/cache/GridCacheEntryEx.java | 36 +-
.../GridCacheEntryInfoCollectSwapListener.java | 70 -
.../cache/GridCacheEvictionManager.java | 95 +-
.../processors/cache/GridCacheMapEntry.java | 92 +-
.../processors/cache/GridCacheMvccManager.java | 10 +-
.../GridCachePartitionExchangeManager.java | 36 +-
.../processors/cache/GridCacheProcessor.java | 156 +-
.../processors/cache/GridCacheProxyImpl.java | 24 -
.../cache/GridCacheSharedContext.java | 8 +-
.../processors/cache/GridCacheSwapEntry.java | 82 -
.../cache/GridCacheSwapEntryImpl.java | 339 ---
.../processors/cache/GridCacheSwapListener.java | 33 -
.../cache/GridCacheTryPutFailedException.java | 28 -
.../processors/cache/GridCacheUtils.java | 209 +-
.../cache/IgniteCacheOffheapManager.java | 3 -
.../cache/IgniteCacheOffheapManagerImpl.java | 5 -
.../processors/cache/IgniteCacheProxy.java | 28 +-
.../processors/cache/IgniteInternalCache.java | 18 -
.../IgniteCacheDatabaseSharedManager.java | 146 +-
.../CacheDataStructuresManager.java | 34 +
.../distributed/GridDistributedLockRequest.java | 14 +-
.../distributed/GridDistributedTxMapping.java | 68 +-
.../GridDistributedTxRemoteAdapter.java | 2 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 37 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 1 -
.../cache/distributed/dht/GridDhtTxLocal.java | 2 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 28 +-
.../dht/GridPartitionedSingleGetFuture.java | 3 -
.../GridDhtAtomicAbstractUpdateFuture.java | 9 +-
.../dht/atomic/GridDhtAtomicCache.java | 92 +-
.../atomic/GridDhtAtomicSingleUpdateFuture.java | 3 -
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 3 -
.../GridNearAtomicAbstractUpdateFuture.java | 79 +-
.../GridNearAtomicSingleUpdateFuture.java | 134 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 159 +-
.../dht/preloader/GridDhtPartitionDemander.java | 12 -
.../GridDhtPartitionsExchangeFuture.java | 5 -
.../dht/preloader/GridDhtPreloader.java | 18 +-
.../distributed/near/GridNearAtomicCache.java | 5 -
.../distributed/near/GridNearCacheAdapter.java | 5 -
.../distributed/near/GridNearCacheEntry.java | 4 +-
...arOptimisticSerializableTxPrepareFuture.java | 218 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 95 +-
.../GridNearPessimisticTxPrepareFuture.java | 186 +-
.../near/GridNearSingleGetRequest.java | 4 +-
.../near/GridNearTxFinishFuture.java | 6 +-
.../cache/distributed/near/GridNearTxLocal.java | 30 +-
.../near/GridNearTxPrepareFutureAdapter.java | 30 +-
.../cache/local/GridLocalLockFuture.java | 3 -
.../local/atomic/GridLocalAtomicCache.java | 35 +-
.../cache/query/GridCacheQueryManager.java | 66 +-
.../cache/query/IgniteQueryErrorCode.java | 27 +-
.../cache/store/CacheOsStoreManager.java | 3 +
.../store/GridCacheStoreManagerAdapter.java | 11 +-
.../cache/store/GridCacheWriteBehindStore.java | 614 +++++-
.../cache/transactions/IgniteTxAdapter.java | 16 +-
.../cache/transactions/IgniteTxEntry.java | 39 +-
.../cache/transactions/IgniteTxHandler.java | 49 +-
.../IgniteTxImplicitSingleStateImpl.java | 6 +
.../transactions/IgniteTxLocalAdapter.java | 7 +-
.../cache/transactions/IgniteTxLocalState.java | 10 +
.../cache/transactions/IgniteTxManager.java | 7 +-
.../cache/transactions/IgniteTxState.java | 2 +-
.../cache/transactions/IgniteTxStateImpl.java | 52 +-
.../closure/GridClosureProcessor.java | 154 +-
.../datastructures/DataStructuresProcessor.java | 64 +-
.../datastructures/GridCacheAtomicLongImpl.java | 626 +++---
.../GridCacheAtomicReferenceImpl.java | 356 +++-
.../GridCacheAtomicSequenceImpl.java | 88 +-
.../GridCacheAtomicStampedImpl.java | 341 +--
.../GridCacheCountDownLatchImpl.java | 58 +-
.../datastructures/GridCacheLockImpl.java | 103 +-
.../datastructures/GridCacheQueueProxy.java | 292 +--
.../datastructures/GridCacheSemaphoreImpl.java | 292 ++-
.../datastructures/GridCacheSetProxy.java | 152 +-
.../GridTransactionalCacheQueueImpl.java | 8 +-
.../internal/processors/igfs/IgfsAsyncImpl.java | 6 +-
.../processors/igfs/IgfsDataManager.java | 36 +-
.../internal/processors/igfs/IgfsImpl.java | 30 +-
.../processors/igfs/IgfsIpcHandler.java | 2 +-
.../processors/igfs/IgfsMetaManager.java | 6 +-
.../processors/igfs/IgfsNoopProcessor.java | 4 +-
.../internal/processors/igfs/IgfsProcessor.java | 30 +-
.../processors/igfs/IgfsProcessorAdapter.java | 4 +-
.../igfs/IgfsSecondaryFileSystemImpl.java | 4 +-
.../internal/processors/igfs/IgfsUtils.java | 3 +
.../igfs/client/IgfsClientSetTimesCallable.java | 2 +-
.../IgfsMetaDirectoryListingAddProcessor.java | 5 +-
.../processors/job/GridJobProcessor.java | 41 +-
.../internal/processors/job/GridJobWorker.java | 15 +-
.../platform/PlatformContextImpl.java | 11 -
.../platform/cache/PlatformCache.java | 33 +-
.../platform/cluster/PlatformClusterGroup.java | 17 +
.../utils/PlatformConfigurationUtils.java | 202 +-
.../internal/processors/pool/PoolProcessor.java | 30 +
.../query/GridQueryIndexDescriptor.java | 5 +
.../processors/query/GridQueryIndexing.java | 62 +-
.../processors/query/GridQueryProcessor.java | 1765 ++++++++++++++--
.../query/GridQueryTypeDescriptor.java | 7 +
.../processors/query/IgniteSQLException.java | 7 +
.../query/QueryIndexDescriptorImpl.java | 42 +-
.../processors/query/QueryIndexKey.java | 85 +
.../internal/processors/query/QuerySchema.java | 166 ++
.../query/QueryTypeDescriptorImpl.java | 150 +-
.../internal/processors/query/QueryUtils.java | 298 ++-
.../query/schema/SchemaExchangeWorkerTask.java | 53 +
.../query/schema/SchemaIndexCacheVisitor.java | 33 +
.../schema/SchemaIndexCacheVisitorClosure.java | 42 +
.../schema/SchemaIndexCacheVisitorImpl.java | 197 ++
.../SchemaIndexOperationCancellationToken.java | 53 +
.../processors/query/schema/SchemaKey.java | 59 +
.../SchemaNodeLeaveExchangeWorkerTask.java | 53 +
.../schema/SchemaOperationClientFuture.java | 52 +
.../query/schema/SchemaOperationException.java | 138 ++
.../query/schema/SchemaOperationManager.java | 292 +++
.../query/schema/SchemaOperationWorker.java | 205 ++
.../message/SchemaAbstractDiscoveryMessage.java | 70 +
.../message/SchemaFinishDiscoveryMessage.java | 98 +
.../message/SchemaOperationStatusMessage.java | 168 ++
.../message/SchemaProposeDiscoveryMessage.java | 133 ++
.../operation/SchemaAbstractOperation.java | 67 +
.../operation/SchemaIndexAbstractOperation.java | 40 +
.../operation/SchemaIndexCreateOperation.java | 91 +
.../operation/SchemaIndexDropOperation.java | 68 +
.../handlers/cache/GridCacheCommandHandler.java | 4 +-
.../session/GridTaskSessionProcessor.java | 10 +-
.../processors/task/GridTaskProcessor.java | 69 +-
.../processors/task/GridTaskWorker.java | 3 +-
.../ignite/internal/util/GridIntIterator.java | 33 +
.../ignite/internal/util/GridIntList.java | 26 +-
.../ignite/internal/util/IgniteUtils.java | 21 +-
.../lang/gridfunc/PredicateCollectionView.java | 7 +-
.../util/lang/gridfunc/PredicateMapView.java | 6 -
.../util/lang/gridfunc/PredicateSetView.java | 6 -
.../lang/gridfunc/ReadOnlyCollectionView.java | 6 -
.../lang/gridfunc/ReadOnlyCollectionView2X.java | 6 -
.../lang/gridfunc/TransformCollectionView.java | 7 +-
.../util/lang/gridfunc/TransformMapView.java | 6 -
.../internal/visor/VisorDataTransferObject.java | 15 +-
.../visor/binary/VisorBinaryMetadata.java | 3 +-
.../visor/cache/VisorCacheConfiguration.java | 3 +-
.../visor/cache/VisorCachePartition.java | 87 -
.../visor/cache/VisorCachePartitions.java | 28 +-
.../visor/cache/VisorCachePartitionsTask.java | 20 +-
.../cache/VisorCachePartitionsTaskArg.java | 72 +
.../visor/compute/VisorGatewayTask.java | 91 +-
.../internal/visor/igfs/VisorIgfsMetrics.java | 3 +-
.../visor/node/VisorIgfsConfiguration.java | 78 -
.../visor/node/VisorNodeDataCollectorTask.java | 4 +-
.../node/VisorNodeDataCollectorTaskResult.java | 4 +-
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 32 +
.../spi/IgniteSpiOperationTimeoutHelper.java | 8 +-
.../jobstealing/JobStealingCollisionSpi.java | 2 +-
.../communication/tcp/TcpCommunicationSpi.java | 6 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 31 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 142 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 143 +-
.../spi/discovery/tcp/TcpDiscoverySpiMBean.java | 26 +-
.../tcp/internal/TcpDiscoveryNode.java | 33 +-
.../TcpDiscoveryClientHeartbeatMessage.java | 72 -
.../TcpDiscoveryClientMetricsUpdateMessage.java | 72 +
.../messages/TcpDiscoveryHeartbeatMessage.java | 338 ---
.../TcpDiscoveryMetricsUpdateMessage.java | 338 +++
.../apache/ignite/spi/indexing/IndexingSpi.java | 19 -
.../spi/indexing/noop/NoopIndexingSpi.java | 10 -
.../adaptive/AdaptiveLoadBalancingSpi.java | 12 +-
.../resources/META-INF/classnames.properties | 58 +-
.../core/src/test/config/load/dsi-load-base.xml | 3 +-
.../src/test/config/load/merge-sort-base.xml | 7 +-
.../test/config/loaders/grid-cfg-2-grids.xml | 6 +-
.../config/streamer/spring-streamer-base.xml | 5 +-
.../java/org/apache/ignite/GridTestJob.java | 19 +
.../java/org/apache/ignite/GridTestTask.java | 18 +-
.../CacheJdbcPojoStoreAbstractSelfTest.java | 19 +-
...BinaryMarshallerStoreKeepBinarySelfTest.java | 28 +
...lerStoreKeepBinaryWithSqlEscapeSelfTest.java | 28 +
.../store/jdbc/CacheJdbcPojoStoreTest.java | 147 +-
.../internal/ClusterNodeMetricsSelfTest.java | 10 +-
.../ignite/internal/GridAffinityMappedTest.java | 5 +-
.../internal/GridAffinityP2PSelfTest.java | 3 +-
.../ignite/internal/GridAffinitySelfTest.java | 3 +-
.../internal/GridCacheRecreateLockTest.java | 78 -
.../GridCancelledJobsMetricsSelfTest.java | 4 +-
...ridFailFastNodeFailureDetectionSelfTest.java | 4 +-
.../GridJobCollisionCancelSelfTest.java | 2 +-
.../IgniteClientReconnectAtomicsTest.java | 15 +-
.../internal/TestRecordingCommunicationSpi.java | 38 +-
.../GridDiscoveryManagerAliveCacheSelfTest.java | 4 +-
.../pagemem/impl/PageMemoryNoLoadSelfTest.java | 2 +-
...CacheExchangeMessageDuplicatedStateTest.java | 8 +-
.../CacheMemoryPolicyConfigurationTest.java | 6 +-
...sCacheTxNearEnabledRandomOperationsTest.java | 28 +
.../cache/CrossCacheTxRandomOperationsTest.java | 23 +-
.../GridCacheAbstractFailoverSelfTest.java | 4 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 45 -
.../cache/GridCacheAbstractSelfTest.java | 4 +-
.../cache/GridCacheMvccManagerSelfTest.java | 3 +-
.../processors/cache/GridCacheTestEntryEx.java | 22 +-
.../cache/IgniteCacheAbstractTest.java | 10 +-
.../IgniteCacheBinaryObjectsScanSelfTest.java | 11 +-
.../IgniteCacheConfigVariationsFullApiTest.java | 45 -
.../IgniteCacheEntryListenerAbstractTest.java | 2 +-
.../IgniteCacheStoreValueAbstractTest.java | 4 -
.../cache/IgniteOnePhaseCommitInvokeTest.java | 211 ++
.../IgniteTxExceptionAbstractSelfTest.java | 10 -
.../cache/MemoryPolicyConfigValidationTest.java | 6 +-
.../binary/BinaryMetadataUpdatesFlowTest.java | 4 +-
.../MemoryPolicyInitializationTest.java | 307 +++
...eAbstractDataStructuresFailoverSelfTest.java | 64 +-
...CacheAtomicReferenceApiSelfAbstractTest.java | 4 +-
...IgniteDataStructuresNoClassOnServerTest.java | 30 +
.../CacheLateAffinityAssignmentTest.java | 37 +-
.../CacheNoValueClassOnServerNodeTest.java | 112 +-
...tractDistributedByteArrayValuesSelfTest.java | 43 -
.../GridCacheNodeFailureAbstractTest.java | 3 +-
.../distributed/IgniteCache150ClientsTest.java | 2 +-
...heClientMultiNodeUpdateTopologyLockTest.java | 201 ++
.../distributed/IgniteCacheGetRestartTest.java | 2 +-
.../IgniteCacheNearRestartRollbackSelfTest.java | 2 +-
.../IgniteCacheReadFromBackupTest.java | 15 +-
.../IgniteNoClassOnServerAbstractTest.java | 135 ++
.../IgniteTxCachePrimarySyncTest.java | 17 +-
...dCacheColocatedTxSingleThreadedSelfTest.java | 2 +-
.../dht/GridCacheDhtPreloadDelayedSelfTest.java | 2 +-
.../GridCacheDhtPreloadMessageCountTest.java | 2 +-
.../dht/GridNearCacheTxNodeFailureSelfTest.java | 31 -
.../IgniteCachePutRetryAbstractSelfTest.java | 25 +-
...gniteCachePutRetryTransactionalSelfTest.java | 2 +-
.../dht/IgniteCacheTxRecoveryRollbackTest.java | 17 +-
.../dht/IgniteCrossCacheTxSelfTest.java | 8 +
.../atomic/IgniteCacheAtomicProtocolTest.java | 76 +-
...tomicClientOnlyMultiNodeFullApiSelfTest.java | 51 +-
.../near/GridCacheNearMultiGetSelfTest.java | 2 +-
.../near/GridCacheNearMultiNodeSelfTest.java | 2 +-
...achePartitionedMultiNodeFullApiSelfTest.java | 59 -
.../GridCachePartitionedTxSalvageSelfTest.java | 2 +-
...achePartitionedTxSingleThreadedSelfTest.java | 2 +-
...idCacheReplicatedUnswapAdvancedSelfTest.java | 151 --
.../cache/query/IndexingSpiQuerySelfTest.java | 26 +-
.../cache/query/IndexingSpiQueryTxSelfTest.java | 10 -
...idCacheWriteBehindStoreAbstractSelfTest.java | 24 +-
.../GridCacheWriteBehindStoreAbstractTest.java | 4 +
...heWriteBehindStoreMultithreadedSelfTest.java | 88 +-
.../GridCacheWriteBehindStoreSelfTest.java | 159 +-
...ClientWriteBehindStoreNonCoalescingTest.java | 168 ++
...puteCustomExecutorConfigurationSelfTest.java | 85 +
.../IgniteComputeCustomExecutorSelfTest.java | 245 +++
.../processors/database/BPlusTreeSelfTest.java | 7 +-
.../database/FreeListImplSelfTest.java | 8 +-
.../database/MetadataStorageSelfTest.java | 2 +-
...faultIgfsSecondaryFileSystemTestAdapter.java | 2 +-
.../igfs/IgfsAbstractBaseSelfTest.java | 9 -
.../processors/igfs/IgfsAbstractSelfTest.java | 17 +-
...lockMessageSystemPoolStarvationSelfTest.java | 8 +-
.../igfs/IgfsDualAbstractSelfTest.java | 39 +-
.../processors/igfs/IgfsIgniteMock.java | 2 +-
...IgfsLocalSecondaryFileSystemTestAdapter.java | 2 +-
.../processors/igfs/IgfsMaxSizeSelfTest.java | 121 --
.../internal/processors/igfs/IgfsMock.java | 2 +-
.../processors/igfs/IgfsModesSelfTest.java | 130 --
.../igfs/IgfsProcessorValidationSelfTest.java | 19 +-
...gfsSecondaryFileSystemInjectionSelfTest.java | 2 +-
.../IgfsSecondaryFileSystemTestAdapter.java | 2 +-
.../processors/igfs/IgfsSizeSelfTest.java | 55 +-
.../service/GridServiceClientNodeTest.java | 7 +-
...ServiceProcessorMultiNodeConfigSelfTest.java | 23 +-
.../GridServiceProcessorMultiNodeSelfTest.java | 31 +-
.../loadtests/cache/GridCacheSwapLoadTest.java | 320 ---
...ridSingleSplitsNewNodesAbstractLoadTest.java | 11 +-
...idSingleSplitsNewNodesMulticastLoadTest.java | 9 +-
.../p2p/GridP2PSameClassLoaderSelfTest.java | 2 +-
.../discovery/AbstractDiscoverySelfTest.java | 19 +-
...lientDiscoverySpiFailureTimeoutSelfTest.java | 245 ++-
.../tcp/TcpClientDiscoverySpiSelfTest.java | 79 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 18 +-
.../tcp/TcpDiscoverySpiConfigSelfTest.java | 4 +-
.../TcpDiscoverySpiFailureTimeoutSelfTest.java | 51 +-
.../ignite/testframework/GridTestNode.java | 7 +
.../testframework/junits/GridAbstractTest.java | 19 +-
.../junits/GridTestKernalContext.java | 6 +-
.../ignite/testframework/junits/IgniteMock.java | 4 +
.../junits/common/GridCommonAbstractTest.java | 189 +-
.../multijvm/IgniteCacheProcessProxy.java | 5 -
.../junits/multijvm/IgniteProcessProxy.java | 2 +-
...ObjectsCacheDataStructuresSelfTestSuite.java | 7 +-
.../IgniteCacheFailoverTestSuite.java | 2 -
.../ignite/testsuites/IgniteCacheTestSuite.java | 4 +
.../testsuites/IgniteCacheTestSuite2.java | 7 +
.../testsuites/IgniteCacheTestSuite3.java | 2 -
.../IgniteCacheWriteBehindTestSuite.java | 2 +
.../testsuites/IgniteComputeGridTestSuite.java | 7 +-
.../ignite/testsuites/IgniteIgfsTestSuite.java | 3 -
.../testsuites/IgniteUtilSelfTestSuite.java | 2 +
.../apache/ignite/util/GridIntListSelfTest.java | 153 ++
.../webapp/META-INF/ignite-webapp-config.xml | 1 -
modules/extdata/p2p/pom.xml | 6 +
.../p2p/NoValueClassOnServerAbstractClient.java | 90 +
.../CacheNoValueClassOnServerTestClient.java | 79 +-
...DataStructuresNoClassOnServerTestClient.java | 181 ++
.../query/h2/opt/GridH2SpatialIndex.java | 32 +-
.../h2/GridBinaryH2IndexingGeoSelfTest.java | 35 -
.../query/h2/GridH2IndexingGeoSelfTest.java | 470 -----
.../h2/GridH2IndexingSegmentedGeoSelfTest.java | 37 -
.../query/h2/H2IndexingAbstractGeoSelfTest.java | 673 ++++++
.../query/h2/H2IndexingBinaryGeoSelfTest.java | 30 +
.../H2IndexingBinarySegmentedGeoSelfTest.java | 30 +
.../query/h2/H2IndexingGeoSelfTest.java | 30 +
.../h2/H2IndexingSegmentedGeoSelfTest.java | 30 +
.../testsuites/GeoSpatialIndexingTestSuite.java | 16 +-
.../fs/IgniteHadoopIgfsSecondaryFileSystem.java | 4 +-
.../org/apache/ignite/hadoop/package-info.java | 22 -
.../hadoop/igfs/HadoopIgfsEndpoint.java | 6 +-
...doopIgfsSecondaryFileSystemDelegateImpl.java | 2 +-
.../hadoop/impl/igfs/HadoopIgfsInProc.java | 2 +-
.../resources/META-INF/classnames.properties | 1 +
.../hadoop/impl/HadoopAbstractSelfTest.java | 4 +-
.../impl/HadoopTaskExecutionSelfTest.java | 16 +-
...opClientProtocolMultipleServersSelfTest.java | 8 +-
.../client/HadoopClientProtocolSelfTest.java | 7 +-
.../igfs/HadoopFIleSystemFactorySelfTest.java | 12 +-
.../HadoopIgfs20FileSystemAbstractSelfTest.java | 1 -
...adoopIgfsSecondaryFileSystemTestAdapter.java | 2 +-
...IgniteHadoopFileSystemHandshakeSelfTest.java | 119 +-
modules/hibernate-4.2/README.txt | 48 +
modules/hibernate-4.2/licenses/apache-2.0.txt | 202 ++
modules/hibernate-4.2/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 102 +
.../hibernate/HibernateCollectionRegion.java | 100 +
.../cache/hibernate/HibernateEntityRegion.java | 112 +
.../hibernate/HibernateGeneralDataRegion.java | 76 +
.../cache/hibernate/HibernateKeyWrapper.java | 73 +
.../hibernate/HibernateNaturalIdRegion.java | 103 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 179 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 542 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 222 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 409 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 440 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1954 +++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 113 +
.../CacheHibernateStoreFactorySelfTest.java | 288 +++
...heHibernateStoreSessionListenerSelfTest.java | 238 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernateTestSuite.java | 37 +
.../testsuites/IgniteHibernateTestSuite.java | 57 +
modules/hibernate-5.1/README.txt | 48 +
modules/hibernate-5.1/licenses/apache-2.0.txt | 202 ++
modules/hibernate-5.1/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 103 +
.../hibernate/HibernateCollectionRegion.java | 114 +
.../cache/hibernate/HibernateEntityRegion.java | 128 ++
.../hibernate/HibernateGeneralDataRegion.java | 79 +
.../cache/hibernate/HibernateKeyWrapper.java | 109 +
.../hibernate/HibernateNaturalIdRegion.java | 113 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 168 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 543 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 224 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 407 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 429 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1960 ++++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 114 +
.../CacheHibernateStoreFactorySelfTest.java | 256 +++
...heHibernateStoreSessionListenerSelfTest.java | 242 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernate5TestSuite.java | 37 +
.../testsuites/IgniteHibernate5TestSuite.java | 57 +
modules/hibernate-core/pom.xml | 76 +
.../HibernateAccessStrategyAdapter.java | 340 +++
.../HibernateAccessStrategyFactory.java | 235 +++
.../cache/hibernate/HibernateCacheProxy.java | 801 +++++++
.../hibernate/HibernateExceptionConverter.java | 29 +
.../hibernate/HibernateKeyTransformer.java | 29 +
.../HibernateNonStrictAccessStrategy.java | 230 ++
.../HibernateReadOnlyAccessStrategy.java | 105 +
.../HibernateReadWriteAccessStrategy.java | 326 +++
.../HibernateTransactionalAccessStrategy.java | 141 ++
.../ignite/cache/hibernate/package-info.java | 24 +
modules/hibernate/README.txt | 48 -
modules/hibernate/licenses/apache-2.0.txt | 202 --
modules/hibernate/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 98 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 811 --------
.../hibernate/HibernateCollectionRegion.java | 100 -
.../cache/hibernate/HibernateEntityRegion.java | 112 -
.../hibernate/HibernateGeneralDataRegion.java | 71 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 72 -
.../hibernate/HibernateNaturalIdRegion.java | 100 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 266 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 222 --
.../cache/store/hibernate/package-info.java | 22 -
.../hibernate/src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 408 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1949 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 285 ---
...heHibernateStoreSessionListenerSelfTest.java | 238 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernateTestSuite.java | 37 -
.../testsuites/IgniteHibernateTestSuite.java | 57 -
modules/hibernate5/README.txt | 48 -
modules/hibernate5/licenses/apache-2.0.txt | 202 --
modules/hibernate5/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 99 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 811 --------
.../hibernate/HibernateCollectionRegion.java | 114 -
.../cache/hibernate/HibernateEntityRegion.java | 129 --
.../hibernate/HibernateGeneralDataRegion.java | 72 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 108 -
.../hibernate/HibernateNaturalIdRegion.java | 113 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 255 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 223 --
.../cache/store/hibernate/package-info.java | 22 -
.../src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 409 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1948 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 326 ---
...heHibernateStoreSessionListenerSelfTest.java | 241 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernate5TestSuite.java | 37 -
.../testsuites/IgniteHibernate5TestSuite.java | 57 -
.../query/h2/DmlStatementsProcessor.java | 49 +-
.../processors/query/h2/IgniteH2Indexing.java | 774 ++++---
.../query/h2/database/H2PkHashIndex.java | 6 +-
.../query/h2/database/H2TreeIndex.java | 6 +-
.../query/h2/database/InlineIndexHelper.java | 14 -
.../query/h2/ddl/DdlStatementsProcessor.java | 211 ++
.../query/h2/opt/GridH2AbstractKeyValueRow.java | 89 +-
.../query/h2/opt/GridH2IndexBase.java | 40 +-
.../query/h2/opt/GridH2KeyValueRowOffheap.java | 70 -
.../query/h2/opt/GridH2MetaTable.java | 8 +-
.../query/h2/opt/GridH2PrimaryScanIndex.java | 90 +
.../processors/query/h2/opt/GridH2Row.java | 2 +-
.../query/h2/opt/GridH2RowDescriptor.java | 11 -
.../query/h2/opt/GridH2ScanIndex.java | 4 +-
.../query/h2/opt/GridH2SystemIndexFactory.java | 38 +
.../processors/query/h2/opt/GridH2Table.java | 472 ++---
.../query/h2/opt/GridH2TreeIndex.java | 7 +-
.../query/h2/opt/GridLuceneIndex.java | 10 +-
.../processors/query/h2/sql/DmlAstUtils.java | 3 -
.../processors/query/h2/sql/GridSqlAlias.java | 20 +-
.../query/h2/sql/GridSqlCreateIndex.java | 121 ++
.../query/h2/sql/GridSqlDropIndex.java | 82 +
.../query/h2/sql/GridSqlQueryParser.java | 127 ++
.../processors/query/h2/sql/GridSqlTable.java | 46 +
.../query/h2/twostep/GridMapQueryExecutor.java | 5 +-
.../query/h2/twostep/GridMergeIndex.java | 1 +
.../query/h2/twostep/GridMergeIndexSorted.java | 6 +-
.../h2/twostep/GridMergeIndexUnsorted.java | 6 +-
.../query/h2/twostep/GridMergeTable.java | 12 +-
.../h2/twostep/GridReduceQueryExecutor.java | 251 ++-
.../query/h2/twostep/GridThreadLocalTable.java | 14 +-
.../h2/twostep/msg/GridH2QueryRequest.java | 64 +-
...ryDuplicateIndexObjectsAbstractSelfTest.java | 159 --
.../cache/GridCacheOffHeapSelfTest.java | 476 -----
.../cache/GridCacheQueryTestValue.java | 2 +-
.../IgniteCacheAbstractFieldsQuerySelfTest.java | 39 +-
.../cache/IgniteCacheDistributedJoinTest.java | 6 +-
...IgniteCacheJoinQueryWithAffinityKeyTest.java | 20 +-
.../IgniteCacheQueryMultiThreadedSelfTest.java | 25 -
.../cache/IgniteCrossCachesJoinsQueryTest.java | 77 +-
...ateIndexObjectPartitionedAtomicSelfTest.java | 38 -
...xObjectPartitionedTransactionalSelfTest.java | 41 -
...stributedPartitionQueryAbstractSelfTest.java | 655 ++++++
...utedPartitionQueryConfigurationSelfTest.java | 92 +
...butedPartitionQueryNodeRestartsSelfTest.java | 114 +
...eCacheDistributedPartitionQuerySelfTest.java | 90 +
.../IgniteCacheQueryNodeRestartSelfTest2.java | 8 +
.../cache/index/AbstractSchemaSelfTest.java | 534 +++++
.../index/DuplicateKeyValueClassesSelfTest.java | 94 +
.../DynamicIndexAbstractBasicSelfTest.java | 1078 ++++++++++
.../DynamicIndexAbstractConcurrentSelfTest.java | 1043 ++++++++++
.../index/DynamicIndexAbstractSelfTest.java | 452 ++++
.../index/DynamicIndexClientBasicSelfTest.java | 28 +
...ndexPartitionedAtomicConcurrentSelfTest.java | 33 +
...titionedTransactionalConcurrentSelfTest.java | 33 +
...IndexReplicatedAtomicConcurrentSelfTest.java | 33 +
...plicatedTransactionalConcurrentSelfTest.java | 33 +
.../index/DynamicIndexServerBasicSelfTest.java | 28 +
...amicIndexServerCoordinatorBasicSelfTest.java | 28 +
...namicIndexServerNodeFIlterBasicSelfTest.java | 28 +
...erverNodeFilterCoordinatorBasicSelfTest.java | 30 +
.../index/H2DynamicIndexAbstractSelfTest.java | 400 ++++
...namicIndexAtomicPartitionedNearSelfTest.java | 26 +
...H2DynamicIndexAtomicPartitionedSelfTest.java | 39 +
.../H2DynamicIndexAtomicReplicatedSelfTest.java | 39 +
...dexTransactionalPartitionedNearSelfTest.java | 26 +
...icIndexTransactionalPartitionedSelfTest.java | 39 +
...micIndexTransactionalReplicatedSelfTest.java | 39 +
.../index/QueryEntityValidationSelfTest.java | 162 ++
.../cache/index/SchemaExchangeSelfTest.java | 632 ++++++
.../local/IgniteCacheLocalQuerySelfTest.java | 2 +-
.../query/IgniteQueryDedicatedPoolTest.java | 11 -
.../query/IgniteSqlSegmentedIndexSelfTest.java | 2 +-
.../query/IgniteSqlSplitterSelfTest.java | 82 +-
.../h2/GridIndexingSpiAbstractSelfTest.java | 109 +-
.../query/h2/IgniteSqlQueryMinMaxTest.java | 16 +-
.../h2/database/InlineIndexHelperTest.java | 11 +-
.../query/h2/opt/GridH2TableSelfTest.java | 171 +-
.../query/h2/sql/GridQueryParsingTest.java | 239 ++-
.../IgniteBinaryCacheQueryTestSuite.java | 5 -
.../IgniteCacheQuerySelfTestSuite.java | 50 +-
.../IgniteCacheQuerySelfTestSuite2.java | 11 +
.../stream/kafka/connect/IgniteSourceTask.java | 4 -
.../java/org/apache/ignite/ml/math/Algebra.java | 107 +-
.../org/apache/ignite/ml/math/Constants.java | 35 +-
.../ignite/ml/math/IdentityValueMapper.java | 3 +-
.../java/org/apache/ignite/ml/math/Matrix.java | 40 +-
.../org/apache/ignite/ml/math/MurmurHash.java | 47 +-
.../java/org/apache/ignite/ml/math/Tracer.java | 4 +-
.../org/apache/ignite/ml/math/ValueMapper.java | 6 +-
.../java/org/apache/ignite/ml/math/Vector.java | 3 +-
.../decompositions/CholeskyDecomposition.java | 10 +-
.../math/decompositions/EigenDecomposition.java | 19 +-
.../ml/math/decompositions/LUDecomposition.java | 18 +-
.../ignite/ml/math/functions/Functions.java | 28 +-
.../functions/IntIntDoubleToVoidFunction.java | 6 +-
.../ml/math/impls/matrix/CacheMatrix.java | 19 +-
.../ml/math/impls/matrix/PivotedMatrixView.java | 38 +-
.../impls/matrix/SparseDistributedMatrix.java | 29 +-
.../storage/matrix/CacheMatrixStorage.java | 25 +-
.../matrix/DenseOffHeapMatrixStorage.java | 23 +-
.../storage/matrix/FunctionMatrixStorage.java | 16 +-
.../matrix/SparseLocalOnHeapMatrixStorage.java | 18 +-
.../storage/vector/CacheVectorStorage.java | 20 +-
.../storage/vector/ConstantVectorStorage.java | 9 +-
.../storage/vector/DelegateVectorStorage.java | 12 +-
.../storage/vector/FunctionVectorStorage.java | 16 +-
.../storage/vector/MatrixVectorStorage.java | 45 +-
.../storage/vector/PivotedVectorStorage.java | 15 +-
.../SingleElementVectorDelegateStorage.java | 12 +-
.../vector/SingleElementVectorStorage.java | 10 +-
.../vector/SparseLocalOffHeapVectorStorage.java | 6 +-
.../vector/SparseLocalOnHeapVectorStorage.java | 9 +-
.../ml/math/impls/vector/AbstractVector.java | 16 +-
.../ml/math/impls/vector/CacheVector.java | 10 +-
.../ml/math/impls/vector/ConstantVector.java | 4 +-
.../ml/math/impls/vector/DelegatingVector.java | 2 +-
.../ml/math/impls/vector/MatrixVectorView.java | 27 +-
.../ml/math/impls/vector/PivotedVectorView.java | 32 +-
.../ml/math/impls/vector/RandomVector.java | 15 +-
.../math/impls/vector/SingleElementVector.java | 10 +-
.../impls/vector/SingleElementVectorView.java | 4 +-
.../ml/math/impls/vector/SparseLocalVector.java | 4 +-
.../org/apache/ignite/ml/math/TracerTest.java | 11 +-
.../ml/math/impls/matrix/CacheMatrixTest.java | 14 +-
.../impls/matrix/MatrixKeyMapperForTests.java | 19 +-
.../storage/matrix/MatrixStorageFixtures.java | 18 +-
.../SparseLocalOffHeapVectorStorageTest.java | 3 +-
.../math/impls/vector/AbstractVectorTest.java | 47 +-
.../ml/math/impls/vector/CacheVectorTest.java | 4 +-
.../osgi-karaf/src/main/resources/features.xml | 2 +-
modules/platforms/cpp/odbc/README.txt | 17 +-
.../ExpiryCacheHolderTest.cs | 10 +
.../Apache.Ignite.Core.Tests.csproj | 9 +
.../Binary/BinaryBuilderSelfTest.cs | 3 +-
.../BinaryBuilderSelfTestDynamicRegistration.cs | 2 +
.../Binary/BinaryBuilderSelfTestSimpleName.cs | 2 +
.../Binary/BinaryCompactFooterInteropTest.cs | 4 +-
.../BinaryConfigurationTest.cs | 4 +-
.../Cache/AddArgCacheEntryProcessor.cs | 91 +
.../Cache/Affinity/AffinityFunctionTest.cs | 3 +-
.../Cache/Affinity/AffinityTest.cs | 10 +-
.../BinarizableAddArgCacheEntryProcessor.cs | 53 +
.../Cache/BinarizableTestException.cs | 51 +
.../Cache/CacheAbstractTest.cs | 476 +----
.../Cache/CacheConfigurationTest.cs | 21 +-
.../Cache/CacheDynamicStartTest.cs | 164 +-
.../Cache/CacheForkedTest.cs | 6 +-
.../Cache/CacheMetricsTest.cs | 3 +-
.../Cache/CacheTestAsyncWrapper.cs | 22 +-
.../Cache/CacheTestKey.cs | 68 +
.../Cache/NonSerializableCacheEntryProcessor.cs | 40 +
.../Cache/NonSerializableException.cs | 40 +
.../Cache/PartitionLossTest.cs | 260 +++
.../Cache/Query/CacheQueriesTest.cs | 35 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 45 +-
.../Continuous/ContinuousQueryJavaFilterTest.cs | 21 +-
.../Query/Continuous/ContinuousQueryTest.cs | 115 +
.../Cache/Store/CacheParallelLoadStoreTest.cs | 9 +-
.../Cache/Store/CacheStoreSessionTest.cs | 15 +-
.../Cache/Store/CacheStoreTest.cs | 17 +-
.../Cache/TestReferenceObject.cs | 40 +
.../Compute/AbstractTaskTest.cs | 29 +-
.../Compute/BinarizableClosureTaskTest.cs | 14 +-
.../Compute/BinarizableTaskTest.cs | 15 -
.../Compute/ComputeApiTest.cs | 9 +-
.../Compute/ComputeApiTestFullFooter.cs | 4 +-
.../Compute/FailoverTaskSelfTest.cs | 6 -
.../Compute/ResourceTaskTest.cs | 60 +-
.../Compute/SerializableClosureTaskTest.cs | 1 +
.../Compute/TaskAdapterTest.cs | 6 -
.../Compute/TaskResultTest.cs | 12 -
.../DataStructures/AtomicReferenceTest.cs | 2 -
.../Dataload/DataStreamerTest.cs | 55 +-
.../Apache.Ignite.Core.Tests/DeploymentTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/EventsTest.cs | 65 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 13 +-
.../Apache.Ignite.Core.Tests/ExecutableTest.cs | 57 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 18 +-
.../IgniteConfigurationSerializerTest.cs | 58 +-
.../IgniteConfigurationTest.cs | 57 +-
.../IgniteStartStopTest.cs | 55 +-
.../Apache.Ignite.Core.Tests/IgniteTestBase.cs | 51 +-
.../Apache.Ignite.Core.Tests/LifecycleTest.cs | 45 +-
.../Apache.Ignite.Core.Tests/LoadDllTest.cs | 11 +-
.../Apache.Ignite.Core.Tests/MessagingTest.cs | 30 +-
.../Apache.Ignite.Core.Tests/TestUtils.cs | 5 +-
.../Apache.Ignite.Core.csproj | 4 +
.../Cache/Configuration/CacheConfiguration.cs | 35 +
.../Cache/Configuration/DataPageEvictionMode.cs | 59 +
.../Cache/Configuration/MemoryConfiguration.cs | 158 ++
.../Configuration/MemoryPolicyConfiguration.cs | 122 ++
.../Cache/Configuration/PartitionLossPolicy.cs | 68 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 21 +-
.../Discovery/Tcp/TcpDiscoverySpi.cs | 15 -
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 12 +
.../Apache.Ignite.Core/IgniteConfiguration.cs | 21 +
.../IgniteConfigurationSection.xsd | 112 +-
.../Impl/Binary/BinaryUtils.cs | 207 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 56 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 6 +-
.../Impl/Cluster/ClusterGroupImpl.cs | 27 +
.../Impl/Common/DelegateConverter.cs | 1 +
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 16 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 10 +-
.../Apache.Ignite.Core/Impl/NativeMethods.cs | 6 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 8 +-
modules/platforms/dotnet/build.ps1 | 12 +-
.../Datagrid/MultiTieredCacheExample.cs | 2 +-
modules/rocketmq/README.txt | 25 +
modules/rocketmq/pom.xml | 81 +
.../stream/rocketmq/RocketMQStreamer.java | 151 ++
.../ignite/stream/rocketmq/package-info.java | 21 +
.../stream/rocketmq/RocketMQStreamerTest.java | 214 ++
.../rocketmq/RocketMQStreamerTestSuite.java | 37 +
.../stream/rocketmq/TestRocketMQServer.java | 148 ++
.../ignite/stream/rocketmq/package-info.java | 21 +
modules/spring-data/pom.xml | 2 +-
.../support/IgniteRepositoryFactoryBean.java | 7 +
.../apache/ignite/cache/spring/SpringCache.java | 6 +
.../GridSpringResourceInjectionSelfTest.java | 20 +-
.../org/apache/ignite/spring/sprint-exclude.xml | 2 -
.../ignite/p2p/GridP2PDisabledSelfTest.java | 4 +-
modules/web-console/backend/app/mongo.js | 4 -
modules/web-console/backend/index.js | 5 +-
.../list-of-registered-users.column-defs.js | 26 +-
.../list-of-registered-users.controller.js | 163 +-
.../list-of-registered-users.tpl.pug | 25 +-
.../frontend/app/data/event-groups.json | 14 -
.../frontend/app/modules/cluster/Cache.js | 4 -
.../app/modules/cluster/CacheMetrics.js | 4 -
.../generator/AbstractTransformer.js | 5 -
.../generator/ConfigurationGenerator.js | 11 -
.../generator/defaults/IGFS.service.js | 3 -
.../modules/states/configuration/igfs/dual.pug | 42 -
.../modules/states/configuration/igfs/misc.pug | 2 -
.../frontend/app/primitives/badge/index.scss | 1 +
.../frontend/app/primitives/btn/index.scss | 24 +-
.../frontend/app/primitives/dropdown/index.pug | 2 +-
.../frontend/app/primitives/dropdown/index.scss | 26 +-
.../frontend/app/primitives/panel/index.scss | 2 +-
.../app/primitives/ui-grid-header/index.scss | 10 +-
.../app/primitives/ui-grid-header/index.tpl.pug | 10 +-
.../app/primitives/ui-grid-settings/index.scss | 58 +-
.../frontend/app/primitives/ui-grid/index.scss | 149 +-
.../frontend/gulpfile.babel.js/paths.js | 1 +
.../frontend/gulpfile.babel.js/tasks/bundle.js | 2 +-
.../webpack/environments/development.js | 4 +-
.../frontend/public/images/icons/cross.svg | 1 +
.../frontend/public/images/icons/export.svg | 1 +
.../frontend/public/images/icons/gear.svg | 1 +
.../stylesheets/_bootstrap-variables.scss | 4 +-
.../frontend/views/configuration/igfs.tpl.pug | 1 -
.../views/templates/agent-download.tpl.pug | 6 +-
modules/web-console/licenses/cc-by-3.0.txt | 319 +++
modules/web-console/web-agent/pom.xml | 2 +-
.../ignite/console/agent/AgentLauncher.java | 10 +-
.../webapp2/META-INF/ignite-webapp-config.xml | 1 -
.../tcp/ipfinder/zk/ZookeeperIpFinderTest.java | 5 +-
parent/pom.xml | 11 +-
pom.xml | 20 +-
852 files changed, 42002 insertions(+), 29237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/examples/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/extdata/p2p/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/hibernate-4.2/pom.xml
----------------------------------------------------------------------
diff --cc modules/hibernate-4.2/pom.xml
index 0000000,c597b21..adcf1b1
mode 000000,100644..100644
--- a/modules/hibernate-4.2/pom.xml
+++ b/modules/hibernate-4.2/pom.xml
@@@ -1,0 -1,159 +1,159 @@@
+ <?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ 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.
+ -->
+
+ <!--
+ POM file.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate_4.2</artifactId>
- <version>2.0.0-SNAPSHOT</version>
++ <version>2.1.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>4.2.21.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.jotm</groupId>
+ <artifactId>jotm-core</artifactId>
+ <version>2.1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/hibernate-5.1/pom.xml
----------------------------------------------------------------------
diff --cc modules/hibernate-5.1/pom.xml
index 0000000,80299bc..8424806
mode 000000,100644..100644
--- a/modules/hibernate-5.1/pom.xml
+++ b/modules/hibernate-5.1/pom.xml
@@@ -1,0 -1,159 +1,159 @@@
+ <?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ 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.
+ -->
+
+ <!--
+ POM file.
+ -->
+ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate_5.1</artifactId>
- <version>2.0.0-SNAPSHOT</version>
++ <version>2.1.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>5.1.5.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.jotm</groupId>
+ <artifactId>jotm-core</artifactId>
+ <version>2.1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
----------------------------------------------------------------------
diff --cc modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
index cae5ca3,3ec14a2..a5dc64b
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/impls/vector/SingleElementVector.java
@@@ -1,102 -1,1 +1,102 @@@
-/*
* 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.ml.math.impls.vector;
import java.util.Map;
import org.apache.ignite.ml.math.Matrix;
import org.apache.ignite.ml.math.Vector;
import org.apache.ignite.ml.math.except
ions.UnsupportedOperationException;
import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
/**
* Read-write vector holding a single non-zero value at some index.
*/
public class SingleElementVector extends AbstractVector {
/**
*
*/
public SingleElementVector() {
// No-op
}
/**
* @param size Parent vector size.
* @param idx Index of the parent vector element.
* @param val Value of the vector element.
*/
public SingleElementVector(int size, int idx, double val) {
super(new SingleElementVectorStorage(size, idx, val));
}
/**
* @param args Parameters to create new vector instance.
*/
public SingleElementVector(Map<String, Object> args) {
assert args != null;
if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
int size = (int)args.get("size");
int idx = (int)args.get("index");
doub
le val = (double)args.get("value");
setStorage(new SingleElementVectorStorage(size, idx, val));
}
else
throw new UnsupportedOperationException("Invalid constructor argument(s).");
}
/**
*
*
*/
private SingleElementVectorStorage storage() {
return (SingleElementVectorStorage)getStorage();
}
/** {@inheritDoc} */
@Override public Element minElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public Element maxElement() {
return makeElement(storage().index());
}
/** {@inheritDoc} */
@Override public double sum() {
return getX(storage().index());
}
/** {@inheritDoc} */
@Override public int nonZeroElements() {
return isZero(get(storage().index())) ? 0 : 1;
}
/** {@inheritDoc} */
@Override public Vector like(int crd) {
int idx = storage().index();
return new SingleElemen
tVector(crd, idx, getX(idx));
}
/** {@inheritDoc} */
@Override public Matrix likeMatrix(int rows, int cols) {
throw new UnsupportedOperationException();
}
}
+/*
+ * 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.ml.math.impls.vector;
+
+import java.util.Map;
+import org.apache.ignite.ml.math.Matrix;
+import org.apache.ignite.ml.math.Vector;
+import org.apache.ignite.ml.math.exceptions.UnsupportedOperationException;
+import org.apache.ignite.ml.math.impls.storage.vector.SingleElementVectorStorage;
+
+/**
+ * Read-write vector holding a single non-zero value at some index.
+ */
+public class SingleElementVector extends AbstractVector {
+ /**
+ *
+ */
+ public SingleElementVector() {
+ // No-op
+ }
+
+ /**
- * @param size
- * @param idx
- * @param val
++ * @param size Parent vector size.
++ * @param idx Index of the parent vector element.
++ * @param val Value of the vector element.
+ */
+ public SingleElementVector(int size, int idx, double val) {
+ super(new SingleElementVectorStorage(size, idx, val));
+ }
+
+ /**
- * @param args
++ * @param args Parameters to create new vector instance.
+ */
+ public SingleElementVector(Map<String, Object> args) {
+ assert args != null;
+
+ if (args.containsKey("size") && args.containsKey("index") && args.containsKey("value")) {
+ int size = (int)args.get("size");
+ int idx = (int)args.get("index");
+ double val = (double)args.get("value");
+
+ setStorage(new SingleElementVectorStorage(size, idx, val));
+ }
+ else
+ throw new UnsupportedOperationException("Invalid constructor argument(s).");
+ }
+
+ /**
+ *
+ *
+ */
+ private SingleElementVectorStorage storage() {
+ return (SingleElementVectorStorage)getStorage();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Element minElement() {
+ return makeElement(storage().index());
+ }
+
+ /** {@inheritDoc} */
+ @Override public Element maxElement() {
+ return makeElement(storage().index());
+ }
+
+ /** {@inheritDoc} */
+ @Override public double sum() {
+ return getX(storage().index());
+ }
+
+ /** {@inheritDoc} */
+ @Override public int nonZeroElements() {
+ return isZero(get(storage().index())) ? 0 : 1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Vector like(int crd) {
+ int idx = storage().index();
+
+ return new SingleElementVector(crd, idx, getX(idx));
+ }
+
+ /** {@inheritDoc} */
+ @Override public Matrix likeMatrix(int rows, int cols) {
+ throw new UnsupportedOperationException();
+ }
- }
++}
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/spring-data/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/modules/web-console/web-agent/pom.xml
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/402154c6/pom.xml
----------------------------------------------------------------------
[35/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
deleted file mode 100644
index c87f08f..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
+++ /dev/null
@@ -1,542 +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 java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicBoolean;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
-import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
-import org.apache.ignite.transactions.Transaction;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.SharedSessionContract;
-import org.hibernate.cfg.Configuration;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * {@link CacheStore} implementation backed by Hibernate. This implementation
- * stores objects in underlying database in {@code BLOB} format.
- * <h2 class="header">Configuration</h2>
- * Either {@link #setSessionFactory(SessionFactory)} or
- * {@link #setHibernateConfigurationPath(String)} or
- * {@link #setHibernateProperties(Properties)} should be set.
- * <p>
- * If session factory is provided it should contain
- * {@link CacheHibernateBlobStoreEntry} persistent class (via provided
- * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
- * adding {@link CacheHibernateBlobStoreEntry} to annotated classes
- * of session factory.
- * <p>
- * Path to hibernate configuration may be either an URL or a file path or
- * a classpath resource. This configuration file should include provided
- * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
- * class {@link CacheHibernateBlobStoreEntry}.
- * <p>
- * If hibernate properties are provided, mapping
- * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
- * <p>
- * Use {@link CacheHibernateBlobStoreFactory} factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
- */
-public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
- /**
- * Default connection URL
- * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
- */
- public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
- "DEFAULT_LOCK_TIMEOUT=5000";
-
- /** Default show SQL property value (value is <tt>true</tt>). */
- public static final String DFLT_SHOW_SQL = "true";
-
- /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
- public static final String DFLT_HBM2DDL_AUTO = "update";
-
- /** Session attribute name. */
- private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
-
- /** Name of Hibarname mapping resource. */
- private static final String MAPPING_RESOURCE =
- "org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml";
-
- /** Marshaller. */
- private static final Marshaller marsh = new JdkMarshaller();
-
- /** Init guard. */
- @GridToStringExclude
- private final AtomicBoolean initGuard = new AtomicBoolean();
-
- /** Init latch. */
- @GridToStringExclude
- private final CountDownLatch initLatch = new CountDownLatch(1);
-
- /** Hibernate properties. */
- @GridToStringExclude
- private Properties hibernateProps;
-
- /** Session factory. */
- @GridToStringExclude
- private SessionFactory sesFactory;
-
- /** Path to hibernate configuration file. */
- private String hibernateCfgPath;
-
- /** Log. */
- @LoggerResource
- private IgniteLogger log;
-
- /** Auto-injected store session. */
- @CacheStoreSessionResource
- private CacheStoreSession ses;
-
- /** Ignite instance. */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** {@inheritDoc} */
- @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
- @Override public V load(K key) {
- init();
-
- Transaction tx = transaction();
-
- if (log.isDebugEnabled())
- log.debug("Store load [key=" + key + ", tx=" + tx + ']');
-
- Session ses = session(tx);
-
- try {
- CacheHibernateBlobStoreEntry entry = (CacheHibernateBlobStoreEntry)
- ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
-
- if (entry == null)
- return null;
-
- return fromBytes(entry.getValue());
- }
- catch (IgniteCheckedException | HibernateException e) {
- rollback(ses, tx);
-
- throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
- }
- finally {
- end(ses, tx);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
- init();
-
- Transaction tx = transaction();
-
- K key = entry.getKey();
- V val = entry.getValue();
-
- if (log.isDebugEnabled())
- log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
-
- if (val == null) {
- delete(key);
-
- return;
- }
-
- Session ses = session(tx);
-
- try {
- CacheHibernateBlobStoreEntry entry0 = new CacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
-
- ses.saveOrUpdate(entry0);
- }
- catch (IgniteCheckedException | 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", "JpaQlInspection"})
- @Override public void delete(Object key) {
- init();
-
- Transaction tx = transaction();
-
- if (log.isDebugEnabled())
- log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
-
- Session ses = session(tx);
-
- try {
- Object obj = ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
-
- if (obj != null)
- ses.delete(obj);
- }
- catch (IgniteCheckedException | HibernateException e) {
- rollback(ses, tx);
-
- throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
- }
- finally {
- end(ses, tx);
- }
- }
-
- /**
- * Rolls back hibernate session.
- *
- * @param ses Hibernate session.
- * @param tx Cache ongoing transaction.
- */
- private void rollback(SharedSessionContract 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, 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) {
- init();
-
- Transaction tx = transaction();
-
- Map<String, Session> props = session().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();
-
- if (log.isDebugEnabled())
- log.debug("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.
- */
- Session session(@Nullable Transaction tx) {
- Session ses;
-
- if (tx != null) {
- Map<String, Session> props = session().properties();
-
- ses = props.get(ATTR_SES);
-
- if (ses == null) {
- ses = sesFactory.openSession();
-
- ses.beginTransaction();
-
- // Store session in transaction metadata, so it can be accessed
- // for other operations on the same transaction.
- props.put(ATTR_SES, ses);
-
- if (log.isDebugEnabled())
- log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
- }
- }
- else {
- ses = sesFactory.openSession();
-
- ses.beginTransaction();
- }
-
- return ses;
- }
-
- /**
- * Sets session factory.
- *
- * @param sesFactory Session factory.
- */
- public void setSessionFactory(SessionFactory sesFactory) {
- this.sesFactory = sesFactory;
- }
-
- /**
- * Sets hibernate configuration path.
- * <p>
- * This may be either URL or file path or classpath resource.
- *
- * @param hibernateCfgPath URL or file path or classpath resource
- * pointing to hibernate configuration XML file.
- */
- public void setHibernateConfigurationPath(String hibernateCfgPath) {
- this.hibernateCfgPath = hibernateCfgPath;
- }
-
- /**
- * Sets Hibernate properties.
- *
- * @param hibernateProps Hibernate properties.
- */
- public void setHibernateProperties(Properties hibernateProps) {
- this.hibernateProps = hibernateProps;
- }
-
- /**
- * Initializes store.
- *
- * @throws IgniteException If failed to initialize.
- */
- private void init() throws IgniteException {
- if (initGuard.compareAndSet(false, true)) {
- if (log.isDebugEnabled())
- log.debug("Initializing cache store.");
-
- try {
- if (sesFactory != null)
- // Session factory has been provided - nothing to do.
- return;
-
- if (!F.isEmpty(hibernateCfgPath)) {
- try {
- URL url = new URL(hibernateCfgPath);
-
- sesFactory = new Configuration().configure(url).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using URL: " + url);
-
- // Session factory has been successfully initialized.
- return;
- }
- catch (MalformedURLException e) {
- if (log.isDebugEnabled())
- log.debug("Caught malformed URL exception: " + e.getMessage());
- }
-
- // Provided path is not a valid URL. File?
- File cfgFile = new File(hibernateCfgPath);
-
- if (cfgFile.exists()) {
- sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using file: " + hibernateCfgPath);
-
- // Session factory has been successfully initialized.
- return;
- }
-
- // Provided path is not a file. Classpath resource?
- sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
- }
- else {
- if (hibernateProps == null) {
- U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
-
- hibernateProps = new Properties();
-
- hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
- hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
- hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
- }
-
- Configuration cfg = new Configuration();
-
- cfg.setProperties(hibernateProps);
-
- assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
-
- cfg.addResource(MAPPING_RESOURCE);
-
- sesFactory = cfg.buildSessionFactory();
-
- if (log.isDebugEnabled())
- log.debug("Configured session factory using properties: " + hibernateProps);
- }
- }
- catch (HibernateException e) {
- throw new IgniteException("Failed to initialize store.", e);
- }
- finally {
- initLatch.countDown();
- }
- }
- else if (initLatch.getCount() > 0) {
- try {
- U.await(initLatch);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new IgniteException(e);
- }
- }
-
- if (sesFactory == null)
- throw new IgniteException("Cache store was not properly initialized.");
- }
-
- /**
- * Checks availability of a classpath resource.
- *
- * @param name Resource name.
- * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
- */
- private boolean resourceAvailable(String name) {
- InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
-
- if (cfgStream == null) {
- log.error("Classpath resource not found: " + name);
-
- return false;
- }
-
- try {
- // Read a single byte to force actual content access by JVM.
- cfgStream.read();
-
- return true;
- }
- catch (IOException e) {
- log.error("Failed to read classpath resource: " + name, e);
-
- return false;
- }
- finally {
- U.close(cfgStream, log);
- }
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(CacheHibernateBlobStore.class, this);
- }
-
- /**
- * Serialize object to byte array using marshaller.
- *
- * @param obj Object to convert to byte array.
- * @return Byte array.
- * @throws IgniteCheckedException If failed to convert.
- */
- protected byte[] toBytes(Object obj) throws IgniteCheckedException {
- return U.marshal(marsh, obj);
- }
-
- /**
- * Deserialize object from byte array using marshaller.
- *
- * @param bytes Bytes to deserialize.
- * @param <X> Result object type.
- * @return Deserialized object.
- * @throws IgniteCheckedException If failed.
- */
- protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
- if (bytes == null || bytes.length == 0)
- return null;
-
- return U.unmarshal(marsh, bytes, getClass().getClassLoader());
- }
-
- /**
- * @return Current transaction.
- */
- @Nullable private Transaction transaction() {
- CacheStoreSession ses = session();
-
- return ses != null ? ses.transaction() : null;
- }
-
- /**
- * @return Store session.
- */
- private CacheStoreSession session() {
- return ses;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
deleted file mode 100644
index 5b0be43..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.apache.ignite.examples.datagrid.store" default-access="field">
- <class name="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry" table="ENTRIES">
- <id name="key"/>
-
- <property name="val"/>
- </class>
-</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
deleted file mode 100644
index d40c5ef..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
+++ /dev/null
@@ -1,89 +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 javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-
-/**
- * Entry that is used by {@link CacheHibernateBlobStore} implementation.
- * <p>
- * Note that this is a reference implementation for tests only.
- * When running on production systems use concrete key-value types to
- * get better performance.
- */
-@Entity
-@Table(name = "ENTRIES")
-public class CacheHibernateBlobStoreEntry {
- /** Key (use concrete key type in production). */
- @Id
- @Column(length = 65535)
- private byte[] key;
-
- /** Value (use concrete value type in production). */
- @Column(length = 65535)
- private byte[] val;
-
- /**
- * Constructor.
- */
- CacheHibernateBlobStoreEntry() {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param key Key.
- * @param val Value.
- */
- CacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
- this.key = key;
- this.val = val;
- }
-
- /**
- * @return Key.
- */
- public byte[] getKey() {
- return key;
- }
-
- /**
- * @param key Key.
- */
- public void setKey(byte[] key) {
- this.key = key;
- }
-
- /**
- * @return Value.
- */
- public byte[] getValue() {
- return val;
- }
-
- /**
- * @param val Value.
- */
- public void setValue(byte[] val) {
- this.val = val;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
deleted file mode 100644
index ea4df8a..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.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 java.util.Properties;
-import javax.cache.configuration.Factory;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteComponentType;
-import org.apache.ignite.internal.util.spring.IgniteSpringHelper;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.resources.SpringApplicationContextResource;
-import org.hibernate.SessionFactory;
-
-/**
- * {@link Factory} implementation for {@link CacheHibernateBlobStore}.
- *
- * Use this factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
- *
- * <h2 class="header">Java Example</h2>
- * In this example existing session factory is provided.
- * <pre name="code" class="java">
- * ...
- * CacheHibernateBlobStoreFactory<String, String> factory = new CacheHibernateBlobStoreFactory<String, String>();
- *
- * factory.setSessionFactory(sesFactory);
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM)</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="sessionFactory">
- * <bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- * <property name="hibernateProperties">
- * <value>
- * connection.url=jdbc:h2:mem:
- * show_sql=true
- * hbm2ddl.auto=true
- * hibernate.dialect=org.hibernate.dialect.H2Dialect
- * </value>
- * </property>
- * <property name="mappingResources">
- * <list>
- * <value>
- * org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
- * </value>
- * </list>
- * </property>
- * </bean>
- * </property>
- * </bean>
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory1"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="sessionFactory">
- * <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
- * <property name="hibernateProperties">
- * <value>
- * connection.url=jdbc:h2:mem:
- * show_sql=true
- * hbm2ddl.auto=true
- * hibernate.dialect=org.hibernate.dialect.H2Dialect
- * </value>
- * </property>
- * <property name="annotatedClasses">
- * <list>
- * <value>
- * org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry
- * </value>
- * </list>
- * </property>
- * </bean>
- * </property>
- * </bean>
- * ...
- * </pre>
- *
- * <h2 class="header">Spring Example</h2>
- * <pre name="code" class="xml">
- * ...
- * <bean id="cache.hibernate.store.factory2"
- * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- * <property name="hibernateProperties">
- * <props>
- * <prop key="connection.url">jdbc:h2:mem:</prop>
- * <prop key="hbm2ddl.auto">update</prop>
- * <prop key="show_sql">true</prop>
- * </props>
- * </property>
- * </bean>
- * ...
- * </pre>
- * <p>
- * <img src="http://ignite.apache.org/images/spring-small.png">
- * <br>
- * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- */
-public class CacheHibernateBlobStoreFactory<K, V> implements Factory<CacheHibernateBlobStore<K, V>> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Session factory. */
- @GridToStringExclude
- private transient SessionFactory sesFactory;
-
- /** Session factory bean name. */
- private String sesFactoryBean;
-
- /** Path to hibernate configuration file. */
- private String hibernateCfgPath;
-
- /** Hibernate properties. */
- @GridToStringExclude
- private Properties hibernateProps;
-
- /** Application context. */
- @SpringApplicationContextResource
- private Object appContext;
-
- /** {@inheritDoc} */
- @Override public CacheHibernateBlobStore<K, V> create() {
- CacheHibernateBlobStore<K, V> store = new CacheHibernateBlobStore<>();
-
- store.setHibernateConfigurationPath(hibernateCfgPath);
- store.setHibernateProperties(hibernateProps);
-
- if (sesFactory != null)
- store.setSessionFactory(sesFactory);
- else if (sesFactoryBean != null) {
- if (appContext == null)
- throw new IgniteException("Spring application context resource is not injected.");
-
- IgniteSpringHelper spring;
-
- try {
- spring = IgniteComponentType.SPRING.create(false);
-
- SessionFactory sesFac = spring.loadBeanFromAppContext(appContext, sesFactoryBean);
-
- store.setSessionFactory(sesFac);
- }
- catch (IgniteCheckedException e) {
- throw new IgniteException("Failed to load bean in application context [beanName=" + sesFactoryBean +
- ", igniteConfig=" + appContext + ']');
- }
- }
-
- return store;
- }
-
- /**
- * Sets session factory.
- *
- * @param sesFactory Session factory.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
- */
- public CacheHibernateBlobStoreFactory<K, V> setSessionFactory(SessionFactory sesFactory) {
- this.sesFactory = sesFactory;
-
- return this;
- }
-
- /**
- * Sets name of the data source bean.
- *
- * @param sesFactory Session factory bean name.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
- */
- public CacheHibernateBlobStoreFactory<K, V> setSessionFactoryBean(String sesFactory) {
- this.sesFactoryBean = sesFactory;
-
- return this;
- }
-
- /**
- * Sets hibernate configuration path.
- * <p>
- * This may be either URL or file path or classpath resource.
- *
- * @param hibernateCfgPath URL or file path or classpath resource
- * pointing to hibernate configuration XML file.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setHibernateConfigurationPath(String)
- */
- public CacheHibernateBlobStoreFactory<K, V> setHibernateConfigurationPath(String hibernateCfgPath) {
- this.hibernateCfgPath = hibernateCfgPath;
-
- return this;
- }
-
- /**
- * Sets Hibernate properties.
- *
- * @param hibernateProps Hibernate properties.
- * @return {@code This} for chaining.
- * @see CacheHibernateBlobStore#setHibernateProperties(Properties)
- */
- public CacheHibernateBlobStoreFactory<K, V> setHibernateProperties(Properties hibernateProps) {
- this.hibernateProps = hibernateProps;
-
- return this;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(CacheHibernateBlobStoreFactory.class, this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/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
deleted file mode 100644
index 917641c..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
+++ /dev/null
@@ -1,222 +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 java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import javax.cache.integration.CacheWriterException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lifecycle.LifecycleAware;
-import org.apache.ignite.resources.LoggerResource;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-
-/**
- * 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<Integer, Integer> {
- * @CacheStoreSessionResource
- * private CacheStoreSession ses;
- *
- * @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> 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.attach(null);
-
- 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();
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
deleted file mode 100644
index 891d99a..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +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 description. -->
- * Contains reference Hibernate-based cache store implementation.
- */
-package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/config/factory-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/config/factory-cache.xml b/modules/hibernate/src/test/config/factory-cache.xml
deleted file mode 100644
index a251846..0000000
--- a/modules/hibernate/src/test/config/factory-cache.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="simpleSessionFactory"
- class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactoryExt"/>
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/config/factory-cache1.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/config/factory-cache1.xml b/modules/hibernate/src/test/config/factory-cache1.xml
deleted file mode 100644
index 7a53b1f..0000000
--- a/modules/hibernate/src/test/config/factory-cache1.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="simpleSessionFactory1"
- class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactory"/>
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="igniteInstanceName" value="ignite1"/>
-
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/config/factory-incorrect-store-cache.xml b/modules/hibernate/src/test/config/factory-incorrect-store-cache.xml
deleted file mode 100644
index 459930c..0000000
--- a/modules/hibernate/src/test/config/factory-incorrect-store-cache.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd">
-
- <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
- <property name="cacheConfiguration">
- <list>
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="name" value="test"/>
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- <property name="cacheStoreFactory">
- <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
- <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
- </bean>
- </property>
- </bean>
- </list>
- </property>
-
- <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
- <property name="discoverySpi">
- <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
- <property name="ipFinder">
- <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
- <property name="addresses">
- <list>
- <value>127.0.0.1:47500..47509</value>
- </list>
- </property>
- </bean>
- </property>
- </bean>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
deleted file mode 100644
index b018d0b..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
+++ /dev/null
@@ -1,408 +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.hibernate;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import javax.cache.Cache;
-import javax.persistence.Cacheable;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.annotations.CacheConcurrencyStrategy;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_ACCESS_TYPE_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.DFLT_CACHE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.IGNITE_INSTANCE_NAME_PROPERTY;
-import static org.apache.ignite.cache.hibernate.HibernateRegionFactory.REGION_CACHE_PROPERTY;
-import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
-import static org.hibernate.cfg.AvailableSettings.GENERATE_STATISTICS;
-import static org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO;
-import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
-import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
-import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
-
-/**
- * Tests Hibernate L2 cache configuration.
- */
-public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest {
- /** */
- public static final String ENTITY1_NAME = Entity1.class.getName();
-
- /** */
- public static final String ENTITY2_NAME = Entity2.class.getName();
-
- /** */
- public static final String ENTITY3_NAME = Entity3.class.getName();
-
- /** */
- public static final String ENTITY4_NAME = Entity4.class.getName();
-
- /** */
- public static final String TIMESTAMP_CACHE = "org.hibernate.cache.spi.UpdateTimestampsCache";
-
- /** */
- public static final String QUERY_CACHE = "org.hibernate.cache.internal.StandardQueryCache";
-
- /** */
- public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
-
- /** If {@code true} then sets default cache in configuration. */
- private boolean dfltCache;
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrid(0);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
- cache.clear();
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
- cfg.setDiscoverySpi(discoSpi);
-
- cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME), cacheConfiguration(ENTITY4_NAME),
- cacheConfiguration("cache1"), cacheConfiguration("cache2"), cacheConfiguration("cache3"),
- cacheConfiguration(TIMESTAMP_CACHE), cacheConfiguration(QUERY_CACHE));
-
- return cfg;
- }
-
- /**
- * @param cacheName Cache name.
- * @return Cache configuration.
- */
- private CacheConfiguration cacheConfiguration(String cacheName) {
- CacheConfiguration cfg = new CacheConfiguration();
-
- cfg.setName(cacheName);
-
- cfg.setCacheMode(PARTITIONED);
-
- cfg.setAtomicityMode(ATOMIC);
-
- return cfg;
- }
- /**
- * @param igniteInstanceName Ignite instance name.
- * @return Hibernate configuration.
- */
- protected Configuration hibernateConfiguration(String igniteInstanceName) {
- Configuration cfg = new Configuration();
-
- cfg.addAnnotatedClass(Entity1.class);
- cfg.addAnnotatedClass(Entity2.class);
- cfg.addAnnotatedClass(Entity3.class);
- cfg.addAnnotatedClass(Entity4.class);
-
- cfg.setProperty(DFLT_ACCESS_TYPE_PROPERTY, AccessType.NONSTRICT_READ_WRITE.name());
-
- cfg.setProperty(HBM2DDL_AUTO, "create");
-
- cfg.setProperty(GENERATE_STATISTICS, "true");
-
- cfg.setProperty(USE_SECOND_LEVEL_CACHE, "true");
-
- cfg.setProperty(USE_QUERY_CACHE, "true");
-
- cfg.setProperty(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
-
- cfg.setProperty(RELEASE_CONNECTIONS, "on_close");
-
- cfg.setProperty(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
-
- cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
- cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
- cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
- cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
-
- if (dfltCache)
- cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
-
- return cfg;
- }
-
- /**
- * Tests property {@link HibernateRegionFactory#REGION_CACHE_PROPERTY}.
- */
- public void testPerRegionCacheProperty() {
- testCacheUsage(1, 1, 0, 1, 1);
- }
-
- /**
- * Tests property {@link HibernateRegionFactory#DFLT_CACHE_NAME_PROPERTY}.
- */
- public void testDefaultCache() {
- dfltCache = true;
-
- testCacheUsage(1, 1, 2, 0, 0);
- }
-
- /**
- * @param expCache1 Expected size of cache with name 'cache1'.
- * @param expCache2 Expected size of cache with name 'cache2'.
- * @param expCache3 Expected size of cache with name 'cache3'.
- * @param expCacheE3 Expected size of cache with name {@link #ENTITY3_NAME}.
- * @param expCacheE4 Expected size of cache with name {@link #ENTITY4_NAME}.
- */
- @SuppressWarnings("unchecked")
- private void testCacheUsage(int expCache1, int expCache2, int expCache3, int expCacheE3, int expCacheE4) {
- SessionFactory sesFactory = startHibernate(getTestIgniteInstanceName(0));
-
- try {
- Session ses = sesFactory.openSession();
-
- try {
- Transaction tx = ses.beginTransaction();
-
- ses.save(new Entity1());
- ses.save(new Entity2());
- ses.save(new Entity3());
- ses.save(new Entity4());
-
- tx.commit();
- }
- finally {
- ses.close();
- }
-
- ses = sesFactory.openSession();
-
- try {
- List<Entity1> list1 = ses.createCriteria(ENTITY1_NAME).list();
-
- assertEquals(1, list1.size());
-
- for (Entity1 e : list1) {
- ses.load(ENTITY1_NAME, e.getId());
- assertNotNull(e.getId());
- }
-
- List<Entity2> list2 = ses.createCriteria(ENTITY2_NAME).list();
-
- assertEquals(1, list2.size());
-
- for (Entity2 e : list2)
- assertNotNull(e.getId());
-
- List<Entity3> list3 = ses.createCriteria(ENTITY3_NAME).list();
-
- assertEquals(1, list3.size());
-
- for (Entity3 e : list3)
- assertNotNull(e.getId());
-
- List<Entity4> list4 = ses.createCriteria(ENTITY4_NAME).list();
-
- assertEquals(1, list4.size());
-
- for (Entity4 e : list4)
- assertNotNull(e.getId());
- }
- finally {
- ses.close();
- }
-
- IgniteCache<Object, Object> cache1 = grid(0).cache("cache1");
- IgniteCache<Object, Object> cache2 = grid(0).cache("cache2");
- IgniteCache<Object, Object> cache3 = grid(0).cache("cache3");
- IgniteCache<Object, Object> cacheE3 = grid(0).cache(ENTITY3_NAME);
- IgniteCache<Object, Object> cacheE4 = grid(0).cache(ENTITY4_NAME);
-
- assertEquals("Unexpected entries: " + toSet(cache1.iterator()), expCache1, cache1.size());
- assertEquals("Unexpected entries: " + toSet(cache2.iterator()), expCache2, cache2.size());
- assertEquals("Unexpected entries: " + toSet(cache3.iterator()), expCache3, cache3.size());
- assertEquals("Unexpected entries: " + toSet(cacheE3.iterator()), expCacheE3, cacheE3.size());
- assertEquals("Unexpected entries: " + toSet(cacheE4.iterator()), expCacheE4, cacheE4.size());
- }
- finally {
- sesFactory.close();
- }
- }
-
- /**
- *
- */
- private <K, V> Set<Cache.Entry<K, V>> toSet(Iterator<Cache.Entry<K, V>> iter){
- Set<Cache.Entry<K, V>> set = new HashSet<>();
-
- while (iter.hasNext())
- set.add(iter.next());
-
- return set;
- }
-
- /**
- * @param igniteInstanceName Name of the grid providing caches.
- * @return Session factory.
- */
- private SessionFactory startHibernate(String igniteInstanceName) {
- Configuration cfg = hibernateConfiguration(igniteInstanceName);
-
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
-
- builder.applySetting("hibernate.connection.url", CONNECTION_URL);
- builder.applySetting("hibernate.show_sql", false);
-
- return cfg.buildSessionFactory(builder.buildServiceRegistry());
- }
-
- /**
- * Test Hibernate entity1.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity1 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity2.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity2 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity3.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity3 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-
- /**
- * Test Hibernate entity4.
- */
- @javax.persistence.Entity
- @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
- @Cacheable
- @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- public static class Entity4 {
- /** */
- private int id;
-
- /**
- * @return ID.
- */
- @Id
- @GeneratedValue
- public int getId() {
- return id;
- }
-
- /**
- * @param id ID.
- */
- public void setId(int id) {
- this.id = id;
- }
- }
-}
\ No newline at end of file
[44/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
ignite-1794 Refactored hibernate modules, switched to hibernate 5.1
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee1b19d3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee1b19d3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee1b19d3
Branch: refs/heads/master
Commit: ee1b19d3f6eb8c07405ee6783379d4c2c20ad8c8
Parents: c9cd761
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 26 14:18:01 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 26 14:18:14 2017 +0300
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 5 +-
examples/pom-standalone-lgpl.xml | 2 +-
examples/pom-standalone.xml | 2 +-
examples/pom.xml | 38 +-
.../hibernate/HibernateL2CacheExample.java | 12 +-
modules/hibernate-4.2/README.txt | 48 +
modules/hibernate-4.2/licenses/apache-2.0.txt | 202 ++
modules/hibernate-4.2/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 102 +
.../hibernate/HibernateCollectionRegion.java | 100 +
.../cache/hibernate/HibernateEntityRegion.java | 112 +
.../hibernate/HibernateGeneralDataRegion.java | 76 +
.../cache/hibernate/HibernateKeyWrapper.java | 73 +
.../hibernate/HibernateNaturalIdRegion.java | 103 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 179 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 542 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 222 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 409 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 440 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1954 +++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 113 +
.../CacheHibernateStoreFactorySelfTest.java | 288 +++
...heHibernateStoreSessionListenerSelfTest.java | 238 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernateTestSuite.java | 37 +
.../testsuites/IgniteHibernateTestSuite.java | 57 +
modules/hibernate-5.1/README.txt | 48 +
modules/hibernate-5.1/licenses/apache-2.0.txt | 202 ++
modules/hibernate-5.1/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 103 +
.../hibernate/HibernateCollectionRegion.java | 114 +
.../cache/hibernate/HibernateEntityRegion.java | 128 ++
.../hibernate/HibernateGeneralDataRegion.java | 79 +
.../cache/hibernate/HibernateKeyWrapper.java | 109 +
.../hibernate/HibernateNaturalIdRegion.java | 113 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 168 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 543 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 224 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 407 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 429 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1960 ++++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 114 +
.../CacheHibernateStoreFactorySelfTest.java | 256 +++
...heHibernateStoreSessionListenerSelfTest.java | 242 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernate5TestSuite.java | 37 +
.../testsuites/IgniteHibernate5TestSuite.java | 57 +
modules/hibernate-core/pom.xml | 76 +
.../HibernateAccessStrategyAdapter.java | 340 +++
.../HibernateAccessStrategyFactory.java | 235 +++
.../cache/hibernate/HibernateCacheProxy.java | 801 +++++++
.../hibernate/HibernateExceptionConverter.java | 29 +
.../hibernate/HibernateKeyTransformer.java | 29 +
.../HibernateNonStrictAccessStrategy.java | 230 ++
.../HibernateReadOnlyAccessStrategy.java | 105 +
.../HibernateReadWriteAccessStrategy.java | 326 +++
.../HibernateTransactionalAccessStrategy.java | 141 ++
.../ignite/cache/hibernate/package-info.java | 24 +
modules/hibernate/README.txt | 48 -
modules/hibernate/licenses/apache-2.0.txt | 202 --
modules/hibernate/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 98 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 801 -------
.../hibernate/HibernateCollectionRegion.java | 100 -
.../cache/hibernate/HibernateEntityRegion.java | 112 -
.../hibernate/HibernateGeneralDataRegion.java | 71 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 72 -
.../hibernate/HibernateNaturalIdRegion.java | 100 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 266 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 222 --
.../cache/store/hibernate/package-info.java | 22 -
.../hibernate/src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 408 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1949 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 285 ---
...heHibernateStoreSessionListenerSelfTest.java | 238 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernateTestSuite.java | 37 -
.../testsuites/IgniteHibernateTestSuite.java | 57 -
modules/hibernate5/README.txt | 48 -
modules/hibernate5/licenses/apache-2.0.txt | 202 --
modules/hibernate5/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 99 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 801 -------
.../hibernate/HibernateCollectionRegion.java | 114 -
.../cache/hibernate/HibernateEntityRegion.java | 129 --
.../hibernate/HibernateGeneralDataRegion.java | 72 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 108 -
.../hibernate/HibernateNaturalIdRegion.java | 113 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 255 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 223 --
.../cache/store/hibernate/package-info.java | 22 -
.../src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 409 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1948 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 326 ---
...heHibernateStoreSessionListenerSelfTest.java | 241 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernate5TestSuite.java | 37 -
.../testsuites/IgniteHibernate5TestSuite.java | 57 -
.../osgi-karaf/src/main/resources/features.xml | 2 +-
pom.xml | 9 +-
178 files changed, 15647 insertions(+), 16667 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/assembly/dependencies-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml
index 23a1731..be68d0a 100644
--- a/assembly/dependencies-fabric.xml
+++ b/assembly/dependencies-fabric.xml
@@ -127,8 +127,9 @@
<exclude>org.apache.ignite:ignite-hadoop</exclude>
<exclude>org.apache.ignite:ignite-codegen</exclude>
<exclude>org.apache.ignite:ignite-apache-license-gen</exclude>
- <exclude>org.apache.ignite:ignite-hibernate</exclude>
- <exclude>org.apache.ignite:ignite-hibernate5</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate-core</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate_4.2</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate_5.1</exclude>
<exclude>org.apache.ignite:ignite-schedule</exclude>
<exclude>org.apache.ignite:ignite-geospatial</exclude>
<exclude>org.apache.ignite:ignite-appserver-test</exclude>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom-standalone-lgpl.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone-lgpl.xml b/examples/pom-standalone-lgpl.xml
index 5fbb4ea..4798d03 100644
--- a/examples/pom-standalone-lgpl.xml
+++ b/examples/pom-standalone-lgpl.xml
@@ -191,7 +191,7 @@
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
<version>to_be_replaced_by_ignite_version</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 0183563..e74082c 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -192,7 +192,7 @@
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
<version>to_be_replaced_by_ignite_version</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 895519b..26f653d 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -64,24 +64,6 @@
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-schedule</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-geospatial</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring-data</artifactId>
<version>${project.version}</version>
</dependency>
@@ -288,6 +270,26 @@
<lgpl.folder>src/main/java-lgpl</lgpl.folder>
<lgpl.test.folder>src/test/java-lgpl</lgpl.test.folder>
</properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schedule</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
index a31d394..28aa6ca 100644
--- a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -31,9 +31,9 @@ import org.apache.ignite.examples.ExamplesUtils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.stat.SecondLevelCacheStatistics;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -226,14 +226,14 @@ public class HibernateL2CacheExample {
* @return New Hibernate {@link SessionFactory}.
*/
private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting("hibernate.connection.url", JDBC_URL);
builder.applySetting("hibernate.show_sql", true);
- return new Configuration()
- .configure(hibernateCfg)
- .buildSessionFactory(builder.buildServiceRegistry());
+ builder.configure(hibernateCfg);
+
+ return new MetadataSources(builder.build()).buildMetadata().buildSessionFactory();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/README.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/README.txt b/modules/hibernate-4.2/README.txt
new file mode 100644
index 0000000..096b9d7
--- /dev/null
+++ b/modules/hibernate-4.2/README.txt
@@ -0,0 +1,48 @@
+Apache Ignite Hibernate Module
+------------------------------
+
+Apache Ignite Hibernate module provides Hibernate second-level cache (L2 cache) implementation based
+on Apache Ignite In-Memory Data Grid.
+
+To enable Hibernate module when starting a standalone node, move 'optional/ignite-hibernate' folder to
+'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will
+be added to classpath in this case.
+
+Importing Hibernate Module In Maven Project
+-------------------------------------------
+
+If you are using Maven to manage dependencies of your project, you can add Hibernate module
+dependency like this (replace '${ignite.version}' with actual Ignite version you are
+interested in):
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ ...
+ <dependencies>
+ ...
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate_4.2</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+
+
+LGPL dependencies
+-----------------
+
+Ignite includes the following optional LGPL dependencies:
+ - Hibernate L2 Cache Integration, http://hibernate.org/orm/
+ - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
+ - cron4j for cron-based task scheduling, http://www.sauronsoftware.it/projects/cron4j
+
+Apache binary releases cannot include LGPL dependencies. If you would like include
+optional LGPL dependencies into your release, you should download the source release
+from Ignite website and do the build with the following maven command:
+
+mvn clean package -DskipTests -Prelease,lgpl
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/licenses/apache-2.0.txt b/modules/hibernate-4.2/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/hibernate-4.2/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/pom.xml b/modules/hibernate-4.2/pom.xml
new file mode 100644
index 0000000..c597b21
--- /dev/null
+++ b/modules/hibernate-4.2/pom.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate_4.2</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>4.2.21.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.jotm</groupId>
+ <artifactId>jotm-core</artifactId>
+ <version>2.1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
new file mode 100644
index 0000000..8bf4e9b
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
@@ -0,0 +1,102 @@
+/*
+ * 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.hibernate;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.access.RegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of L2 cache access strategy delegating to {@link HibernateAccessStrategyAdapter}.
+ */
+public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
+ /** */
+ final HibernateAccessStrategyAdapter stgy;
+
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ this.stgy = stgy;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key, long txTs) throws CacheException {
+ return stgy.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver) throws CacheException {
+ stgy.putFromLoad(key, val);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver, boolean minimalPutOverride)
+ throws CacheException {
+ stgy.putFromLoad(key, val, minimalPutOverride);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockItem(Object key, Object ver) throws CacheException {
+ stgy.lock(key);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockRegion() throws CacheException {
+ stgy.lockRegion();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockRegion(SoftLock lock) throws CacheException {
+ stgy.unlockRegion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ stgy.unlock(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) throws CacheException {
+ stgy.remove(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll() throws CacheException {
+ stgy.removeAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ stgy.evict(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ stgy.evictAll();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
new file mode 100644
index 0000000..dae476c
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
@@ -0,0 +1,100 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
+
+/**
+ * Implementation of {@link CollectionRegion}. This region is used to store collection data.
+ * <p>
+ * L2 cache for collection can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entities. -->
+ * <mapping class="com.example.Entity"/>
+ * <mapping class="com.example.ChildEntity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entities and collection. -->
+ * <collection-cache collection="com.example.Entity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.ChildEntity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.Entity.children" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for collection can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * public class Entity {
+ * ...
+ *
+ * @javax.persistence.OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ * @javax.persistence.JoinColumn(name="PARENT_ID")
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public List<ChildEntity> getChildren() {...}
+ * }
+ * </pre>
+ * Note: the collection cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * values. For this reason, the collection cache should always be used in conjunction with
+ * the second-level cache for those entities expected to be cached as part of a collection cache.
+ */
+public class HibernateCollectionRegion extends HibernateTransactionalDataRegion implements CollectionRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ HibernateCollectionRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Collection region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements CollectionRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion getRegion() {
+ return HibernateCollectionRegion.this;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
new file mode 100644
index 0000000..db921dc
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
@@ -0,0 +1,112 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+
+/**
+ * Implementation of {@link EntityRegion}. This region is used to store entity data.
+ * <p>
+ * L2 cache for entity can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for entity can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateEntityRegion extends HibernateTransactionalDataRegion implements EntityRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
+ HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Entity region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements EntityRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion getRegion() {
+ return HibernateEntityRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val, Object ver) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val, Object ver) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val, Object currVer, Object previousVer)
+ throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
+ throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
new file mode 100644
index 0000000..578d88b
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
@@ -0,0 +1,76 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.GeneralDataRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link GeneralDataRegion}. This interface defines common contract for {@link QueryResultsRegion}
+ * and {@link TimestampsRegion}.
+ */
+public class HibernateGeneralDataRegion extends HibernateRegion implements GeneralDataRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key) throws CacheException {
+ try {
+ return cache.get(key);
+ } catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void put(Object key, Object val) throws CacheException {
+ try {
+ cache.put(key, val);
+ } catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ HibernateAccessStrategyAdapter.evict(ignite, cache, key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ try {
+ HibernateAccessStrategyAdapter.evictAll(cache);
+ }
+ catch (IgniteCheckedException e) {
+ throw HibernateRegionFactory.EXCEPTION_CONVERTER.convert(e);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
new file mode 100644
index 0000000..64de395
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
@@ -0,0 +1,73 @@
+/*
+ * 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.hibernate;
+
+import java.io.Serializable;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Hibernate cache key wrapper.
+ */
+public class HibernateKeyWrapper implements Serializable {
+ /** Key. */
+ private final Object key;
+
+ /** Entry. */
+ private final String entry;
+
+ /** */
+ private final String tenantId;
+
+ /**
+ * @param key Key.
+ * @param entry Entry.
+ * @param tenantId Tenant ID.
+ */
+ HibernateKeyWrapper(Object key, String entry, String tenantId) {
+ this.key = key;
+ this.entry = entry;
+ this.tenantId = tenantId;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ HibernateKeyWrapper that = (HibernateKeyWrapper) o;
+
+ return (key != null ? key.equals(that.key) : that.key == null) &&
+ (entry != null ? entry.equals(that.entry) : that.entry == null) &&
+ (tenantId != null ? tenantId.equals(that.tenantId) : that.tenantId == null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = key != null ? key.hashCode() : 0;
+ res = 31 * res + (entry != null ? entry.hashCode() : 0);
+ res = 31 * res + (tenantId != null ? tenantId.hashCode() : 0);
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HibernateKeyWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
new file mode 100644
index 0000000..ae1099d
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
@@ -0,0 +1,103 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+
+/**
+ * Implementation of {@link NaturalIdRegion}. This region is used to store naturalId data.
+ * <p>
+ * L2 cache for entity naturalId and target cache region can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * @org.hibernate.annotations.NaturalIdCache
+ * public class Entity {
+ * @org.hibernate.annotations.NaturalId
+ * private String entityCode;
+ *
+ * ...
+ * }
+ * </pre>
+ */
+public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion implements NaturalIdRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ HibernateNaturalIdRegion(HibernateRegionFactory factory,
+ String name,
+ Ignite ignite,
+ HibernateCacheProxy cache,
+ CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * NaturalId region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy implements
+ NaturalIdRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion getRegion() {
+ return HibernateNaturalIdRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
new file mode 100644
index 0000000..fccbb5e
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
@@ -0,0 +1,70 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.Query;
+import org.hibernate.cache.spi.QueryResultsRegion;
+
+/**
+ * Implementation of {@link QueryResultsRegion}. This region is used to store query results.
+ * <p>
+ * Query results caching can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Enable query cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * By default queries are not cached even after enabling query caching, to enable results caching for a particular
+ * query, call {@link Query#setCacheable(boolean)}:
+ * <pre name="code" class="java">
+ * Session ses = getSession();
+ *
+ * Query qry = ses.createQuery("...");
+ *
+ * qry.setCacheable(true); // Enable L2 cache for query.
+ * </pre>
+ * Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * values. For this reason, the query cache should always be used in conjunction with
+ * the second-level cache for those entities expected to be cached as part of a query result cache
+ */
+class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
new file mode 100644
index 0000000..3666732
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
@@ -0,0 +1,99 @@
+/*
+ * 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.hibernate;
+
+import java.util.Collections;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.Region;
+
+/**
+ * Implementation of {@link Region}. This interface defines base contract for all L2 cache regions.
+ */
+public class HibernateRegion implements Region {
+ /** */
+ protected final HibernateRegionFactory factory;
+
+ /** */
+ private final String name;
+
+ /** Cache instance. */
+ protected final HibernateCacheProxy cache;
+
+ /** Grid instance. */
+ protected Ignite ignite;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateRegion(HibernateRegionFactory factory, String name, Ignite ignite, HibernateCacheProxy cache) {
+ this.factory = factory;
+ this.name = name;
+ this.ignite = ignite;
+ this.cache = cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy() throws CacheException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object key) {
+ return cache.containsKey(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getSizeInMemory() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountInMemory() {
+ return cache.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountOnDisk() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map toMap() {
+ return Collections.emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getTimeout() {
+ return 0;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
new file mode 100644
index 0000000..5667eb2
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
@@ -0,0 +1,179 @@
+/*
+ * 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.hibernate;
+
+import java.util.Properties;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CacheKey;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Settings;
+
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+
+/**
+ * Hibernate L2 cache region factory.
+ * <p>
+ * Following Hibernate settings should be specified to enable second level cache and to use this
+ * region factory for caching:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * hibernate.cache.use_second_level_cache=true
+ * hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
+ * </pre>
+ * Note that before region factory is started you need to start properly configured Ignite node in the same JVM.
+ * For example to start Ignite node one of loader provided in {@code org.apache.ignite.grid.startup} package can be used.
+ * <p>
+ * Name of Ignite instance to be used for region factory must be specified as following Hibernate property:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance name>
+ * </pre>
+ * Each Hibernate cache region must be associated with some {@link IgniteInternalCache}, by default it is assumed that
+ * for each cache region there is a {@link IgniteInternalCache} with the same name. Also it is possible to define
+ * region to cache mapping using properties with prefix {@code org.apache.ignite.hibernate.region_cache}.
+ * For example if for region with name "region1" cache with name "cache1" should be used then following
+ * Hibernate property should be specified:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.region_cache.region1=cache1
+ * </pre>
+ */
+public class HibernateRegionFactory implements RegionFactory {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ static final HibernateExceptionConverter EXCEPTION_CONVERTER = new HibernateExceptionConverter() {
+ @Override public RuntimeException convert(Exception e) {
+ return new CacheException(e);
+ }
+ };
+
+ /** Default region access type. */
+ private AccessType dfltAccessType;
+
+ /** Key transformer. */
+ private final HibernateKeyTransformer hibernate4transformer = new HibernateKeyTransformer() {
+ @Override public Object transform(Object key) {
+ if (key instanceof CacheKey) {
+ CacheKey cacheKey = (CacheKey)key;
+
+ return new HibernateKeyWrapper(
+ cacheKey.getKey(),
+ cacheKey.getEntityOrRoleName(),
+ cacheKey.getTenantId()
+ );
+ }
+
+ return key;
+ }
+ };
+
+ /** */
+ private final HibernateAccessStrategyFactory accessStgyFactory =
+ new HibernateAccessStrategyFactory(hibernate4transformer, EXCEPTION_CONVERTER);
+
+ /** {@inheritDoc} */
+ @Override public void start(Settings settings, Properties props) throws CacheException {
+ String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());
+
+ dfltAccessType = AccessType.valueOf(accessType);
+
+ accessStgyFactory.start(props);
+ }
+
+ /**
+ * @return Access strategy factory.
+ */
+ HibernateAccessStrategyFactory accessStrategyFactory() {
+ return accessStgyFactory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public AccessType getDefaultAccessType() {
+ return dfltAccessType;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion buildEntityRegion(String regionName, Properties props, CacheDataDescription metadata)
+ throws CacheException {
+ return new HibernateEntityRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateNaturalIdRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion buildCollectionRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateCollectionRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
+ throws CacheException {
+ return new HibernateQueryResultsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+
+ /** {@inheritDoc} */
+ @Override public TimestampsRegion buildTimestampsRegion(String regionName, Properties props) throws CacheException {
+ return new HibernateTimestampsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
new file mode 100644
index 0000000..8b4c243
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
@@ -0,0 +1,39 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.spi.TimestampsRegion;
+
+/**
+ * Implementation of {@link TimestampsRegion}. This region is automatically created when query
+ * caching is enabled and it holds most recent updates timestamps to queryable tables.
+ * Name of timestamps region is {@code "org.hibernate.cache.spi.UpdateTimestampsCache"}.
+ */
+public class HibernateTimestampsRegion extends HibernateGeneralDataRegion implements TimestampsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ public HibernateTimestampsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
new file mode 100644
index 0000000..275ea9e
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
@@ -0,0 +1,84 @@
+/*
+ * 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.hibernate;
+
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.TransactionalDataRegion;
+import org.hibernate.cache.spi.access.AccessType;
+
+/**
+ * Implementation of {@link TransactionalDataRegion} (transactional means that
+ * data in the region is updated in connection with database transaction).
+ * This interface defines base contract for {@link EntityRegion}, {@link CollectionRegion}
+ * and {@link NaturalIdRegion}.
+ */
+public class HibernateTransactionalDataRegion extends HibernateRegion implements TransactionalDataRegion {
+ /** */
+ private final CacheDataDescription dataDesc;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ HibernateTransactionalDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache);
+
+ this.dataDesc = dataDesc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isTransactionAware() {
+ return false; // This method is not used by Hibernate.
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheDataDescription getCacheDataDescription() {
+ return dataDesc;
+ }
+
+ /**
+ * @param accessType Hibernate L2 cache access type.
+ * @return Access strategy for given access type.
+ */
+ HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
+ switch (accessType) {
+ case READ_ONLY:
+ return factory.accessStrategyFactory().createReadOnlyStrategy(cache);
+
+ case NONSTRICT_READ_WRITE:
+ return factory.accessStrategyFactory().createNonStrictReadWriteStrategy(cache);
+
+ case READ_WRITE:
+ return factory.accessStrategyFactory().createReadWriteStrategy(cache);
+
+ case TRANSACTIONAL:
+ return factory.accessStrategyFactory().createTransactionalStrategy(cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
new file mode 100644
index 0000000..1179aec
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 description. -->
+ * Contains implementation of Hibernate L2 cache. Refer to
+ * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
+ * configure and use Ignite with Hibernate.
+ */
+package org.apache.ignite.cache.hibernate;
\ No newline at end of file
[04/50] [abbrv] ignite git commit:
IgniteCacheClientMultiNodeUpdateTopologyLockTest minor.
Posted by vo...@apache.org.
IgniteCacheClientMultiNodeUpdateTopologyLockTest minor.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/31928067
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/31928067
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/31928067
Branch: refs/heads/master
Commit: 319280678515e4e12c10c0362883f207919e87c2
Parents: 1968e4f
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 13:20:59 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 13:20:59 2017 +0300
----------------------------------------------------------------------
...heClientMultiNodeUpdateTopologyLockTest.java | 28 +++++++++++++-------
1 file changed, 18 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/31928067/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
index 4adf5f4..7711bbb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientMultiNodeUpdateTopologyLockTest.java
@@ -100,7 +100,7 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon
TestRecordingCommunicationSpi spi2 = TestRecordingCommunicationSpi.spi(ignite(2));
- TestRecordingCommunicationSpi clientSpi = TestRecordingCommunicationSpi.spi(clientNode);
+ final TestRecordingCommunicationSpi clientSpi = TestRecordingCommunicationSpi.spi(clientNode);
final UUID node0Id = ignite(0).cluster().localNode().id();
final UUID node2Id = ignite(2).cluster().localNode().id();
@@ -115,22 +115,30 @@ public class IgniteCacheClientMultiNodeUpdateTopologyLockTest extends GridCommon
}
});
- clientSpi.record(new IgniteBiPredicate<ClusterNode, Message>() {
- @Override public boolean apply(ClusterNode node, Message msg) {
+ clientSpi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
+ @Override public boolean apply(final ClusterNode node, final Message msg) {
if (!node2Id.equals(node.id()))
return false;
if (msg instanceof GridNearTxFinishRequest) {
log.info("Delay message [msg=" + msg + ']');
- try {
- Thread.sleep(5000);
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
+ GridTestUtils.runAsync(new Runnable() {
+ @Override public void run() {
+ try {
+ Thread.sleep(5000);
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ log.info("Send delayed message [msg=" + msg + ']');
+
+ clientSpi.stopBlock(true);
+ }
+ });
- log.info("Send delayed message [msg=" + msg + ']');
+ return true;
}
return false;
[08/50] [abbrv] ignite git commit: IGNITE-5057 .NET: Fix build.ps1 to
handle Any CPU config on PowerShell 4.0 and lower
Posted by vo...@apache.org.
IGNITE-5057 .NET: Fix build.ps1 to handle Any CPU config on PowerShell 4.0 and lower
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/de421ffc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/de421ffc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/de421ffc
Branch: refs/heads/master
Commit: de421ffc492e3536b885f2d90c21bcfa71e435a5
Parents: 7c249d7
Author: Pavel Tupitsyn <pt...@apache.org>
Authored: Mon Apr 24 15:37:42 2017 +0300
Committer: Pavel Tupitsyn <pt...@apache.org>
Committed: Mon Apr 24 15:37:42 2017 +0300
----------------------------------------------------------------------
modules/platforms/dotnet/build.ps1 | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/de421ffc/modules/platforms/dotnet/build.ps1
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/build.ps1 b/modules/platforms/dotnet/build.ps1
index 4b5d937..b8e6a37 100644
--- a/modules/platforms/dotnet/build.ps1
+++ b/modules/platforms/dotnet/build.ps1
@@ -143,9 +143,12 @@ echo "MSBuild detected at '$msbuildExe'."
# Detect NuGet
$ng = "nuget"
if ((Get-Command $ng -ErrorAction SilentlyContinue) -eq $null) {
- echo "Downloading NuGet..."
- (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe", "nuget.exe");
$ng = ".\nuget.exe"
+
+ if (-not (Test-Path $ng)) {
+ echo "Downloading NuGet..."
+ (New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v3.3.0/nuget.exe", "nuget.exe");
+ }
}
# Restore NuGet packages
@@ -153,10 +156,11 @@ echo "Restoring NuGet..."
& $ng restore
# Build
-echo "Starting MsBuild..."
$targets = if ($clean) {"Clean;Rebuild"} else {"Build"}
$codeAnalysis = if ($skipCodeAnalysis) {"/p:RunCodeAnalysis=false"} else {""}
-& $msbuildExe Apache.Ignite.sln /target:$targets /p:Configuration=$configuration /p:Platform=`"$platform`" $codeAnalysis /p:UseSharedCompilation=false
+$msBuildCommand = "`"$msBuildExe`" Apache.Ignite.sln /target:$targets /p:Configuration=$configuration /p:Platform=`"$platform`" $codeAnalysis /p:UseSharedCompilation=false"
+echo "Starting MsBuild: '$msBuildCommand'"
+cmd /c $msBuildCommand
# Check result
if ($LastExitCode -ne 0) {
[09/50] [abbrv] ignite git commit: ignite-2.0 - SQL: Geo tests fixed
+ distributed join on replicated cache
Posted by vo...@apache.org.
ignite-2.0 - SQL: Geo tests fixed + distributed join on replicated cache
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b58d5842
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b58d5842
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b58d5842
Branch: refs/heads/master
Commit: b58d584290fc4ca5f18031fac582130ffab59a24
Parents: de421ff
Author: Sergi Vladykin <se...@gmail.com>
Authored: Mon Apr 24 16:31:25 2017 +0300
Committer: Sergi Vladykin <se...@gmail.com>
Committed: Mon Apr 24 16:31:25 2017 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheProxy.java | 8 ----
.../query/h2/H2IndexingAbstractGeoSelfTest.java | 2 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../query/IgniteSqlSplitterSelfTest.java | 46 ++++++++++++++++----
4 files changed, 40 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 186212d..b38520d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -774,10 +774,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
opCtxCall != null && opCtxCall.isKeepBinary());
if (qry instanceof SqlQuery) {
- if (isReplicatedDataNode() && ((SqlQuery)qry).isDistributedJoins())
- throw new CacheException("Queries using distributed JOINs have to be run on partitioned cache, " +
- "not on replicated.");
-
final SqlQuery p = (SqlQuery)qry;
if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
@@ -788,10 +784,6 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
if (qry instanceof SqlFieldsQuery) {
- if (isReplicatedDataNode() && ((SqlFieldsQuery)qry).isDistributedJoins())
- throw new CacheException("Queries using distributed JOINs have to be run on partitioned cache, " +
- "not on replicated.");
-
SqlFieldsQuery p = (SqlFieldsQuery)qry;
if ((p.isReplicatedOnly() && isReplicatedDataNode()) || ctx.isLocal() || qry.isLocal())
http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
index f57d573..2a83941 100644
--- a/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
+++ b/modules/geospatial/src/test/java/org/apache/ignite/internal/processors/query/h2/H2IndexingAbstractGeoSelfTest.java
@@ -632,7 +632,7 @@ public abstract class H2IndexingAbstractGeoSelfTest extends GridCacheAbstractSel
*/
private static class Enemy {
/** */
- @QuerySqlField
+ @QuerySqlField(index = true)
int campId;
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index bf0276a..798ca9b 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1569,7 +1569,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
Connection c = connectionForSpace(space);
final boolean enforceJoinOrder = qry.isEnforceJoinOrder();
- final boolean distributedJoins = qry.isDistributedJoins() && cctx.isPartitioned();
+ final boolean distributedJoins = qry.isDistributedJoins();
final boolean grpByCollocated = qry.isCollocated();
final DistributedJoinMode distributedJoinMode = distributedJoinMode(qry.isLocal(), distributedJoins);
http://git-wip-us.apache.org/repos/asf/ignite/blob/b58d5842/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
index 4578171..fa4eded 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/IgniteSqlSplitterSelfTest.java
@@ -290,6 +290,35 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
}
}
+ /**
+ * @throws InterruptedException If failed.
+ */
+ public void testDistributedJoinFromReplicatedCache() throws InterruptedException {
+ CacheConfiguration ccfg1 = cacheConfig("pers", true,
+ Integer.class, Person2.class);
+
+ CacheConfiguration ccfg2 = cacheConfig("org", true,
+ Integer.class, Organization.class);
+
+ CacheConfiguration ccfg3 = cacheConfig("orgRepl", false,
+ Integer.class, Organization.class);
+
+ IgniteCache<Integer, Person2> c1 = ignite(0).getOrCreateCache(ccfg1);
+ IgniteCache<Integer, Organization> c2 = ignite(0).getOrCreateCache(ccfg2);
+ IgniteCache<Integer, Organization> c3 = ignite(0).getOrCreateCache(ccfg3);
+
+ try {
+ awaitPartitionMapExchange();
+
+ doTestDistributedJoins(c3, c1, c2, 300, 2000, 5, false);
+ doTestDistributedJoins(c3, c1, c2, 300, 2000, 5, true);
+ }
+ finally {
+ c1.destroy();
+ c2.destroy();
+ }
+ }
+
@SuppressWarnings("SuspiciousMethodCalls")
public void testExists() {
IgniteCache<Integer,Person2> x = ignite(0).getOrCreateCache(cacheConfig("x", true,
@@ -523,14 +552,14 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
try {
awaitPartitionMapExchange();
- doTestDistributedJoins(c1, c2, 30, 100, 1000, false);
- doTestDistributedJoins(c1, c2, 30, 100, 1000, true);
+ doTestDistributedJoins(c2, c1, c2, 30, 100, 1000, false);
+ doTestDistributedJoins(c2, c1, c2, 30, 100, 1000, true);
- doTestDistributedJoins(c1, c2, 3, 10, 3, false);
- doTestDistributedJoins(c1, c2, 3, 10, 3, true);
+ doTestDistributedJoins(c2, c1, c2, 3, 10, 3, false);
+ doTestDistributedJoins(c2, c1, c2, 3, 10, 3, true);
- doTestDistributedJoins(c1, c2, 300, 2000, 5, false);
- doTestDistributedJoins(c1, c2, 300, 2000, 5, true);
+ doTestDistributedJoins(c2, c1, c2, 300, 2000, 5, false);
+ doTestDistributedJoins(c2, c1, c2, 300, 2000, 5, true);
}
finally {
c1.destroy();
@@ -1409,6 +1438,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
* @param enforceJoinOrder Enforce join order.
*/
private void doTestDistributedJoins(
+ IgniteCache<?,?> qryCache,
IgniteCache<Integer, Person2> c1,
IgniteCache<Integer, Organization> c2,
int orgs,
@@ -1442,7 +1472,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
String select = "select count(*) from \"org\".Organization o, \"pers\".Person2 p where p.orgId = o._key";
- String plan = (String)c2.query(new SqlFieldsQuery("explain " + select)
+ String plan = (String)qryCache.query(new SqlFieldsQuery("explain " + select)
.setDistributedJoins(true).setEnforceJoinOrder(enforceJoinOrder).setPageSize(pageSize))
.getAll().get(0).get(0);
@@ -1453,7 +1483,7 @@ public class IgniteSqlSplitterSelfTest extends GridCommonAbstractTest {
else
assertTrue(plan, plan.contains("batched:unicast"));
- assertEquals(Long.valueOf(persons), c2.query(new SqlFieldsQuery(select).setDistributedJoins(true)
+ assertEquals((long)persons, qryCache.query(new SqlFieldsQuery(select).setDistributedJoins(true)
.setEnforceJoinOrder(enforceJoinOrder).setPageSize(pageSize)).getAll().get(0).get(0));
c1.clear();
[13/50] [abbrv] ignite git commit: GG-12132 Added magic header to
protect from unexpected input.
Posted by vo...@apache.org.
GG-12132 Added magic header to protect from unexpected input.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e4a926b2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e4a926b2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e4a926b2
Branch: refs/heads/master
Commit: e4a926b2825eee507e1f58a3c1b19fdc2ac80cb4
Parents: 26c222b
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Tue Apr 25 14:02:26 2017 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Tue Apr 25 14:02:26 2017 +0700
----------------------------------------------------------------------
.../marshaller/optimized/OptimizedMarshaller.java | 3 ++-
.../internal/visor/VisorDataTransferObject.java | 15 +++++++++++++--
.../internal/visor/binary/VisorBinaryMetadata.java | 3 +--
.../visor/cache/VisorCacheConfiguration.java | 3 +--
4 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
index 3f40d63..575c9a4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/marshaller/optimized/OptimizedMarshaller.java
@@ -232,7 +232,8 @@ public class OptimizedMarshaller extends AbstractNodeNameAwareMarshaller {
"[clsLdr=" + clsLdr + ", cls=" + e.getMessage() + "]", e);
}
catch (Exception e) {
- throw new IgniteCheckedException("Failed to deserialize object with given class loader: " + clsLdr, e);
+ throw new IgniteCheckedException("Failed to deserialize object with given class loader: " +
+ "[clsLdr=" + clsLdr + ", err=" + e.getMessage() + "]", e);
}
finally {
OptimizedObjectStreamRegistry.closeIn(objIn);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
index d8dcf4e..bdf01e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/VisorDataTransferObject.java
@@ -30,6 +30,9 @@ import org.jetbrains.annotations.Nullable;
* Base class for data transfer objects.
*/
public abstract class VisorDataTransferObject implements Externalizable {
+ /** Magic number to detect correct transfer objects. */
+ private static final int MAGIC = 0x42BEEF00;
+
/**
* @param col Source collection.
* @param <T> Collection type.
@@ -59,7 +62,9 @@ public abstract class VisorDataTransferObject implements Externalizable {
/** {@inheritDoc} */
@Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeByte(getProtocolVersion());
+ int hdr = MAGIC + getProtocolVersion();
+
+ out.writeInt(hdr);
try (VisorDataTransferObjectOutput dtout = new VisorDataTransferObjectOutput(out)) {
writeExternalData(dtout);
@@ -78,7 +83,13 @@ public abstract class VisorDataTransferObject implements Externalizable {
/** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- byte ver = in.readByte();
+ int hdr = in.readInt();
+
+ if ((hdr & MAGIC) != MAGIC)
+ throw new IOException("Unexpected VisorDataTransferObject header " +
+ "[actual=" + Integer.toHexString(hdr) + ", expected=" + Integer.toHexString(MAGIC) + "]");
+
+ byte ver = (byte)(hdr & 0xFF);
try (VisorDataTransferObjectInput dtin = new VisorDataTransferObjectInput(in)) {
readExternalData(ver, dtin);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
index 5e948c6..285bff9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/binary/VisorBinaryMetadata.java
@@ -124,8 +124,7 @@ public class VisorBinaryMetadata extends VisorDataTransferObject {
}
/** {@inheritDoc} */
- @Override protected void readExternalData(byte protoVer,
- ObjectInput in) throws IOException, ClassNotFoundException {
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
typeName = U.readString(in);
typeId = (Integer)in.readObject();
affinityKeyFieldName = U.readString(in);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e4a926b2/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
index 391b120..5b5d3a8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCacheConfiguration.java
@@ -418,8 +418,7 @@ public class VisorCacheConfiguration extends VisorDataTransferObject {
}
/** {@inheritDoc} */
- @Override protected void readExternalData(byte protoVer,
- ObjectInput in) throws IOException, ClassNotFoundException {
+ @Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
name = U.readString(in);
mode = CacheMode.fromOrdinal(in.readByte());
atomicityMode = CacheAtomicityMode.fromOrdinal(in.readByte());
[19/50] [abbrv] ignite git commit: CacheConfiguration code style
fixes.
Posted by vo...@apache.org.
CacheConfiguration code style fixes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8a5266e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8a5266e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8a5266e7
Branch: refs/heads/master
Commit: 8a5266e787d181dd98aeb3c597ea64e9c39af6ae
Parents: 1dc9e69
Author: sboikov <sb...@gridgain.com>
Authored: Tue Apr 25 11:42:56 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Apr 25 11:42:56 2017 +0300
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 57 +++++++++-----------
1 file changed, 25 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8a5266e7/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index d378343..219e0b1 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -143,15 +143,6 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Default rebalance batch size in bytes. */
public static final int DFLT_REBALANCE_BATCH_SIZE = 512 * 1024; // 512K
- /** Default maximum eviction queue ratio. */
- public static final float DFLT_MAX_EVICTION_OVERFLOW_RATIO = 10;
-
- /** Default synchronous eviction timeout in milliseconds. */
- public static final long DFLT_EVICT_SYNCHRONIZED_TIMEOUT = 10000;
-
- /** Default synchronous eviction concurrency level. */
- public static final int DFLT_EVICT_SYNCHRONIZED_CONCURRENCY_LEVEL = 4;
-
/** Default value for eager ttl flag. */
public static final boolean DFLT_EAGER_TTL = true;
@@ -290,13 +281,13 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private int rebalanceBatchSize = DFLT_REBALANCE_BATCH_SIZE;
/** Rebalance batches prefetch count. */
- private long rebalanceBatchesPrefetchCount = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;
+ private long rebalanceBatchesPrefetchCnt = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;
/** Maximum number of concurrent asynchronous operations. */
private int maxConcurrentAsyncOps = DFLT_MAX_CONCURRENT_ASYNC_OPS;
/** Maximum inline size for sql indexes. */
- private int sqlIndexMaxInlineSize = DFLT_SQL_INDEX_MAX_INLINE_SIZE;
+ private int sqlIdxMaxInlineSize = DFLT_SQL_INDEX_MAX_INLINE_SIZE;
/** Write-behind feature. */
private boolean writeBehindEnabled = DFLT_WRITE_BEHIND_ENABLED;
@@ -374,7 +365,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private Collection<QueryEntity> qryEntities;
/** Partition loss policy. */
- private PartitionLossPolicy partitionLossPolicy = DFLT_PARTITION_LOSS_POLICY;
+ private PartitionLossPolicy partLossPlc = DFLT_PARTITION_LOSS_POLICY;
/** */
private int qryParallelism = DFLT_QUERY_PARALLELISM;
@@ -433,18 +424,18 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
longQryWarnTimeout = cc.getLongQueryWarningTimeout();
maxConcurrentAsyncOps = cc.getMaxConcurrentAsyncOperations();
memPlcName = cc.getMemoryPolicyName();
- sqlIndexMaxInlineSize = cc.getSqlIndexMaxInlineSize();
+ sqlIdxMaxInlineSize = cc.getSqlIndexMaxInlineSize();
name = cc.getName();
nearCfg = cc.getNearConfiguration();
nodeFilter = cc.getNodeFilter();
onheapCache = cc.isOnheapCacheEnabled();
- partitionLossPolicy = cc.getPartitionLossPolicy();
+ partLossPlc = cc.getPartitionLossPolicy();
pluginCfgs = cc.getPluginConfigurations();
qryEntities = cc.getQueryEntities() == Collections.<QueryEntity>emptyList() ? null : cc.getQueryEntities();
qryDetailMetricsSz = cc.getQueryDetailMetricsSize();
readFromBackup = cc.isReadFromBackup();
rebalanceBatchSize = cc.getRebalanceBatchSize();
- rebalanceBatchesPrefetchCount = cc.getRebalanceBatchesPrefetchCount();
+ rebalanceBatchesPrefetchCnt = cc.getRebalanceBatchesPrefetchCount();
rebalanceDelay = cc.getRebalanceDelay();
rebalanceMode = cc.getRebalanceMode();
rebalanceOrder = cc.getRebalanceOrder();
@@ -1088,7 +1079,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return batches count
*/
public long getRebalanceBatchesPrefetchCount() {
- return rebalanceBatchesPrefetchCount;
+ return rebalanceBatchesPrefetchCnt;
}
/**
@@ -1102,7 +1093,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return {@code this} for chaining.
*/
public CacheConfiguration<K, V> setRebalanceBatchesPrefetchCount(long rebalanceBatchesCnt) {
- this.rebalanceBatchesPrefetchCount = rebalanceBatchesCnt;
+ this.rebalanceBatchesPrefetchCnt = rebalanceBatchesCnt;
return this;
}
@@ -1145,16 +1136,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @return Maximum payload size for offheap indexes.
*/
public int getSqlIndexMaxInlineSize() {
- return sqlIndexMaxInlineSize;
+ return sqlIdxMaxInlineSize;
}
/**
* Sets maximum inline size for sql indexes.
*
- * @param sqlIndexMaxInlineSize Maximum inline size for sql indexes.
+ * @param sqlIdxMaxInlineSize Maximum inline size for sql indexes.
+ * @return {@code this} for chaining.
*/
- public CacheConfiguration<K, V> setSqlIndexMaxInlineSize(int sqlIndexMaxInlineSize) {
- this.sqlIndexMaxInlineSize = sqlIndexMaxInlineSize;
+ public CacheConfiguration<K, V> setSqlIndexMaxInlineSize(int sqlIdxMaxInlineSize) {
+ this.sqlIdxMaxInlineSize = sqlIdxMaxInlineSize;
return this;
}
@@ -1809,18 +1801,19 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* @see PartitionLossPolicy
*/
public PartitionLossPolicy getPartitionLossPolicy() {
- return partitionLossPolicy == null ? DFLT_PARTITION_LOSS_POLICY : partitionLossPolicy;
+ return partLossPlc == null ? DFLT_PARTITION_LOSS_POLICY : partLossPlc;
}
/**
* Sets partition loss policy. This policy defines how Ignite will react to a situation when all nodes for
* some partition leave the cluster.
*
- * @param partitionLossPolicy Partition loss policy.
+ * @param partLossPlc Partition loss policy.
+ * @return {@code this} for chaining.
* @see PartitionLossPolicy
*/
- public CacheConfiguration<K, V> setPartitionLossPolicy(PartitionLossPolicy partitionLossPolicy) {
- this.partitionLossPolicy = partitionLossPolicy;
+ public CacheConfiguration<K, V> setPartitionLossPolicy(PartitionLossPolicy partLossPlc) {
+ this.partLossPlc = partLossPlc;
return this;
}
@@ -1991,7 +1984,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
for (ClassProperty prop : desc.props.values())
entity.addQueryField(prop.fullName(), U.box(prop.type()).getName(), prop.alias());
- entity.setKeyFields(desc.keyProperties);
+ entity.setKeyFields(desc.keyProps);
QueryIndex txtIdx = null;
@@ -2261,8 +2254,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/** {@inheritDoc} */
- @Override public CacheConfiguration<K, V> setTypes(Class<K> keyType, Class<V> valueType) {
- super.setTypes(keyType, valueType);
+ @Override public CacheConfiguration<K, V> setTypes(Class<K> keyType, Class<V> valType) {
+ super.setTypes(keyType, valType);
return this;
}
@@ -2282,8 +2275,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/** {@inheritDoc} */
- @Override public CacheConfiguration<K, V> setStoreByValue(boolean isStoreByValue) {
- super.setStoreByValue(isStoreByValue);
+ @Override public CacheConfiguration<K, V> setStoreByValue(boolean isStoreByVal) {
+ super.setStoreByValue(isStoreByVal);
return this;
}
@@ -2330,7 +2323,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** */
@GridToStringInclude
- private final Set<String> keyProperties = new HashSet<>();
+ private final Set<String> keyProps = new HashSet<>();
/** */
@GridToStringInclude
@@ -2464,7 +2457,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
fields.put(name, prop.type());
if (key)
- keyProperties.add(name);
+ keyProps.add(name);
}
/**
[12/50] [abbrv] ignite git commit: Fixed AtomicSequence test
Posted by vo...@apache.org.
Fixed AtomicSequence test
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/26c222bd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/26c222bd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/26c222bd
Branch: refs/heads/master
Commit: 26c222bd46e5fc725c2ad20815078792298d7869
Parents: b41ecd1
Author: Dmitriy Govorukhin <dm...@gmail.com>
Authored: Mon Apr 24 20:20:41 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Apr 24 20:20:41 2017 +0300
----------------------------------------------------------------------
.../datastructures/GridCacheAtomicReferenceImpl.java | 2 ++
.../internal/IgniteClientReconnectAtomicsTest.java | 15 +++++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/26c222bd/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index 0b0c202..d6fa2ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -166,6 +166,8 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
/** {@inheritDoc} */
@Override public boolean compareAndSet(final T expVal, final T newVal) {
+ checkRemoved();
+
try {
if (ctx.dataStructures().knownType(expVal) && ctx.dataStructures().knownType(newVal)) {
EntryProcessorResult<Boolean> res =
http://git-wip-us.apache.org/repos/asf/ignite/blob/26c222bd/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
index 4622fff..00daf5f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectAtomicsTest.java
@@ -31,6 +31,7 @@ import org.apache.ignite.IgniteCountDownLatch;
import org.apache.ignite.IgniteLock;
import org.apache.ignite.IgniteSemaphore;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
import org.apache.ignite.testframework.GridTestUtils;
/**
@@ -363,7 +364,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
- servCommSpi.blockMessage(GridNearLockResponse.class);
+ servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -396,8 +397,6 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
- assertEquals("3st value", clientAtomicRef.get());
- assertTrue(clientAtomicRef.compareAndSet("3st value", "4st value"));
assertEquals("4st value", clientAtomicRef.get());
assertEquals("4st value", srvAtomicRef.get());
@@ -523,7 +522,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
BlockTcpCommunicationSpi servCommSpi = commSpi(srv);
- servCommSpi.blockMessage(GridNearLockResponse.class);
+ servCommSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -556,7 +555,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
- assertEquals(true, clientAtomicStamped.compareAndSet(2, 3, 2, 3));
+ assertEquals(false, clientAtomicStamped.compareAndSet(2, 3, 2, 3));
assertEquals(3, clientAtomicStamped.value());
assertEquals(3, clientAtomicStamped.stamp());
@@ -655,7 +654,7 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
final IgniteAtomicLong srvAtomicLong = srv.atomicLong("atomicLongInProggress", 0, false);
- commSpi.blockMessage(GridNearLockResponse.class);
+ commSpi.blockMessage(GridNearTxPrepareResponse.class);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override public Object call() throws Exception {
@@ -688,8 +687,8 @@ public class IgniteClientReconnectAtomicsTest extends IgniteClientReconnectAbstr
assertTrue((Boolean)fut.get(2, TimeUnit.SECONDS));
// Check that after reconnect working.
- assertEquals(1, clientAtomicLong.addAndGet(1));
- assertEquals(2, srvAtomicLong.addAndGet(1));
+ assertEquals(2, clientAtomicLong.addAndGet(1));
+ assertEquals(3, srvAtomicLong.addAndGet(1));
clientAtomicLong.close();
}
[33/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/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
deleted file mode 100644
index 880d12a..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java
+++ /dev/null
@@ -1,238 +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 java.io.Serializable;
-import java.util.Map;
-import javax.cache.Cache;
-import javax.cache.configuration.Factory;
-import javax.cache.integration.CacheLoaderException;
-import javax.cache.integration.CacheWriterException;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import org.apache.ignite.cache.store.CacheStore;
-import org.apache.ignite.cache.store.CacheStoreAdapter;
-import org.apache.ignite.cache.store.CacheStoreSession;
-import org.apache.ignite.cache.store.CacheStoreSessionListener;
-import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest;
-import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
-import org.apache.ignite.lang.IgniteBiInClosure;
-import org.apache.ignite.resources.CacheStoreSessionResource;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-
-/**
- * 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;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
deleted file mode 100644
index 3822b31..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
- <session-factory>
- <!-- Show SQL. -->
- <property name="show_sql">true</property>
-
- <!-- Database connection settings (private in-memory database). -->
- <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property>
-
- <!-- Only validate the database schema on startup in production mode. -->
- <property name="hbm2ddl.auto">update</property>
-
- <!-- H2 dialect. -->
- <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
-
- <!-- Mappings. -->
- <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/>
- </session-factory>
-</hibernate-configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
deleted file mode 100644
index 8af9886..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java
+++ /dev/null
@@ -1,22 +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 description. -->
- * Contains internal tests or test related classes and interfaces.
- */
-package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java b/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
deleted file mode 100644
index 3791bae..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java
+++ /dev/null
@@ -1,37 +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.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
-import org.apache.ignite.testframework.config.GridTestProperties;
-
-/**
- *
- */
-public class IgniteBinaryHibernateTestSuite extends TestSuite {
- /**
- * @return Test suite.
- * @throws Exception If failed.
- */
- public static TestSuite suite() throws Exception {
- GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
-
- return IgniteHibernateTestSuite.suite();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/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
deleted file mode 100644
index 99fea56..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
+++ /dev/null
@@ -1,57 +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.testsuites;
-
-import junit.framework.TestSuite;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest;
-import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest;
-import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest;
-
-/**
- * Hibernate integration tests.
- */
-public class IgniteHibernateTestSuite extends TestSuite {
- /**
- * @return Test suite.
- * @throws Exception Thrown in case of the failure.
- */
- public static TestSuite suite() throws Exception {
- TestSuite suite = new TestSuite("Hibernate Integration Test Suite");
-
- // Hibernate L2 cache.
- suite.addTestSuite(HibernateL2CacheSelfTest.class);
- suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class);
- suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class);
- suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class);
-
- suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class);
-
- suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class);
-
- suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class);
-
- suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class);
-
- return suite;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/README.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate5/README.txt b/modules/hibernate5/README.txt
deleted file mode 100644
index 370258b..0000000
--- a/modules/hibernate5/README.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-Apache Ignite Hibernate Module
-------------------------------
-
-Apache Ignite Hibernate module provides Hibernate second-level cache (L2 cache) implementation based
-on Apache Ignite In-Memory Data Grid.
-
-To enable Hibernate module when starting a standalone node, move 'optional/ignite-hibernate5' folder to
-'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will
-be added to classpath in this case.
-
-Importing Hibernate Module In Maven Project
--------------------------------------------
-
-If you are using Maven to manage dependencies of your project, you can add Hibernate module
-dependency like this (replace '${ignite.version}' with actual Ignite version you are
-interested in):
-
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
- http://maven.apache.org/xsd/maven-4.0.0.xsd">
- ...
- <dependencies>
- ...
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate5</artifactId>
- <version>${ignite.version}</version>
- </dependency>
- ...
- </dependencies>
- ...
-</project>
-
-
-LGPL dependencies
------------------
-
-Ignite includes the following optional LGPL dependencies:
- - Hibernate L2 Cache Integration, http://hibernate.org/orm/
- - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
- - cron4j for cron-based task scheduling, http://www.sauronsoftware.it/projects/cron4j
-
-Apache binary releases cannot include LGPL dependencies. If you would like include
-optional LGPL dependencies into your release, you should download the source release
-from Ignite website and do the build with the following maven command:
-
-mvn clean package -DskipTests -Prelease,lgpl
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate5/licenses/apache-2.0.txt b/modules/hibernate5/licenses/apache-2.0.txt
deleted file mode 100644
index d645695..0000000
--- a/modules/hibernate5/licenses/apache-2.0.txt
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate5/pom.xml b/modules/hibernate5/pom.xml
deleted file mode 100644
index 13a0c40..0000000
--- a/modules/hibernate5/pom.xml
+++ /dev/null
@@ -1,146 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<!--
- POM file.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-parent</artifactId>
- <version>1</version>
- <relativePath>../../parent</relativePath>
- </parent>
-
- <artifactId>ignite-hibernate5</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <url>http://ignite.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>5.2.9.Final</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-jta</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.ow2.jotm</groupId>
- <artifactId>jotm-core</artifactId>
- <version>2.1.9</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-dbcp</groupId>
- <artifactId>commons-dbcp</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>${h2.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <version>1.5</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-spring</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-log4j</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <testResources>
- <testResource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- <testResource>
- <directory>src/test/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </testResource>
- </testResources>
-
- <plugins>
- <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
deleted file mode 100644
index efb9056..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
+++ /dev/null
@@ -1,99 +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.hibernate;
-
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.RegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.hibernate.engine.spi.SharedSessionContractImplementor;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of L2 cache access strategy delegating to {@link HibernateAccessStrategyAdapter}.
- */
-public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
- /** */
- protected final HibernateAccessStrategyAdapter stgy;
-
- /**
- * @param stgy Access strategy implementation.
- */
- protected HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
- this.stgy = stgy;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(SharedSessionContractImplementor ses, Object key, long txTs) throws CacheException {
- return stgy.get(key);
- }
-
- /** {@inheritDoc} */
- @Override public boolean putFromLoad(SharedSessionContractImplementor ses, Object key, Object val, long txTs, Object ver) throws CacheException {
- stgy.putFromLoad(key, val);
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean putFromLoad(SharedSessionContractImplementor ses, Object key, Object val, long txTs, Object ver, boolean minimalPutOverride)
- throws CacheException {
- stgy.putFromLoad(key, val, minimalPutOverride);
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public SoftLock lockItem(SharedSessionContractImplementor ses, Object key, Object ver) throws CacheException {
- return stgy.lock(key);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public SoftLock lockRegion() throws CacheException {
- return stgy.lockRegion();
- }
-
- /** {@inheritDoc} */
- @Override public void unlockRegion(SoftLock lock) throws CacheException {
- stgy.unlockRegion(lock);
- }
-
- /** {@inheritDoc} */
- @Override public void unlockItem(SharedSessionContractImplementor ses, Object key, SoftLock lock) throws CacheException {
- stgy.unlock(key, lock);
- }
-
- /** {@inheritDoc} */
- @Override public void remove(SharedSessionContractImplementor ses, Object key) throws CacheException {
- stgy.remove(key);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll() throws CacheException {
- stgy.removeAll();
- }
-
- /** {@inheritDoc} */
- @Override public void evict(Object key) throws CacheException {
- stgy.evict(key);
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll() throws CacheException {
- stgy.evictAll();
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
deleted file mode 100644
index f6c1d0e..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
+++ /dev/null
@@ -1,379 +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.hibernate;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
-import org.hibernate.cache.spi.access.RegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Common interface used to implement Hibernate L2 cache access strategies ({@link RegionAccessStrategy},
- * {@link EntityRegionAccessStrategy} and {@link CollectionRegionAccessStrategy}).
- * <p>
- * The expected sequences of steps related to various CRUD operations executed by Hibernate are:
- * <p>
- * Insert:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Execute database insert.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#insert}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#afterInsert}.</li>
- * </ul>
- * In case if some step fails and DB transaction is rolled back then
- * {@link HibernateAccessStrategyAdapter#afterInsert} is not called.
- * <p>
- * Update:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lock}.</li>
- * <li>Execute database update.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#update}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#afterUpdate}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * Delete:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lock} for removing key.</li>
- * <li>Execute database delete.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#remove}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#unlock}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * In case if custom SQL update query is executed Hibernate clears entire cache region,
- * for this case operations sequence is:
- * <ul>
- * <li>Start DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#lockRegion}.</li>
- * <li>Execute database query.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#removeAll}.</li>
- * <li>Commit DB transaction.</li>
- * <li>Call {@link HibernateAccessStrategyAdapter#unlockRegion}.</li>
- * </ul>
- */
-public abstract class HibernateAccessStrategyAdapter {
- /** */
- protected final HibernateCacheProxy cache;
-
- /** Grid. */
- protected final Ignite ignite;
-
- /** */
- protected final IgniteLogger log;
-
- /**
- * @param ignite Grid.
- * @param cache Cache.
- */
- protected HibernateAccessStrategyAdapter(Ignite ignite, HibernateCacheProxy cache) {
- this.cache = cache;
- this.ignite = ignite;
-
- log = ignite.log();
- }
-
- /**
- * Gets value from cache. Used by {@link RegionAccessStrategy#get}.
- *
- * @param key Key.
- * @return Cached value.
- * @throws CacheException If failed.
- */
- @Nullable protected Object get(Object key) throws CacheException {
- try {
- return cache.get(key);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
- *
- * @param key Key.
- * @param val Value.
- * @param minimalPutOverride MinimalPut flag
- * @throws CacheException If failed.
- */
- protected void putFromLoad(Object key, Object val, boolean minimalPutOverride) throws CacheException {
- putFromLoad(key, val);
- }
-
- /**
- * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
- *
- * @param key Key.
- * @param val Value.
- * @throws CacheException If failed.
- */
- protected void putFromLoad(Object key, Object val) throws CacheException {
- try {
- cache.put(key, val);
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Called during database transaction execution before Hibernate attempts to update or remove given key.
- * Used by {@link RegionAccessStrategy#lockItem}.
- *
- * @param key Key.
- * @return Lock representation or {@code null}.
- * @throws CacheException If failed.
- */
- @Nullable protected abstract SoftLock lock(Object key) throws CacheException;
-
- /**
- * Called after Hibernate failed to update or successfully removed given key.
- * Used by {@link RegionAccessStrategy#unlockItem}.
- *
- * @param key Key.
- * @param lock The lock previously obtained from {@link #lock}
- * @throws CacheException If failed.
- */
- protected abstract void unlock(Object key, SoftLock lock) throws CacheException;
-
- /**
- * Called after Hibernate updated object in the database but before transaction completed.
- * Used by {@link EntityRegionAccessStrategy#update} and {@link NaturalIdRegionAccessStrategy#update}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean update(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate updated object in the database and transaction successfully completed.
- * Used by {@link EntityRegionAccessStrategy#afterUpdate} and {@link NaturalIdRegionAccessStrategy#afterUpdate}.
- *
- * @param key Key.
- * @param val Value.
- * @param lock The lock previously obtained from {@link #lock}
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException;
-
- /**
- * Called after Hibernate inserted object in the database but before transaction completed.
- * Used by {@link EntityRegionAccessStrategy#insert} and {@link NaturalIdRegionAccessStrategy#insert}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean insert(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate inserted object in the database and transaction successfully completed.
- * Used by {@link EntityRegionAccessStrategy#afterInsert} and {@link NaturalIdRegionAccessStrategy#afterInsert}.
- *
- * @param key Key.
- * @param val Value.
- * @return {@code True} if operation updated cache.
- * @throws CacheException If failed.
- */
- protected abstract boolean afterInsert(Object key, Object val) throws CacheException;
-
- /**
- * Called after Hibernate removed object from database but before transaction completed.
- * Used by {@link RegionAccessStrategy#remove}.
- *
- * @param key Key,
- * @throws CacheException If failed.
- */
- protected abstract void remove(Object key) throws CacheException;
-
- /**
- * Called to remove object from cache without regard to transaction.
- * Used by {@link RegionAccessStrategy#evict}.
- *
- * @param key Key.
- * @throws CacheException If failed.
- */
- protected void evict(Object key) throws CacheException {
- evict(ignite, cache, key);
- }
-
- /**
- * Called to remove all data from cache without regard to transaction.
- * Used by {@link RegionAccessStrategy#evictAll}.
- *
- * @throws CacheException If failed.
- */
- protected void evictAll() throws CacheException {
- evictAll(cache);
- }
-
- /**
- * Called during database transaction execution before Hibernate executed
- * update operation which should invalidate entire cache region.
- * Used by {@link RegionAccessStrategy#lockRegion}.
- *
- * @throws CacheException If failed.
- * @return Lock representation or {@code null}.
- */
- @Nullable protected SoftLock lockRegion() throws CacheException {
- return null;
- }
-
- /**
- * Called after transaction clearing entire cache region completed.
- * Used by {@link RegionAccessStrategy#unlockRegion}.
- *
- * @param lock The lock previously obtained from {@link #lockRegion}
- * @throws CacheException If failed.
- */
- protected void unlockRegion(SoftLock lock) throws CacheException {
- // No-op.
- }
-
- /**
- * Called during database transaction execution to clear entire cache region after
- * Hibernate executed database update, but before transaction completed.
- * Used by {@link RegionAccessStrategy#removeAll}.
- *
- * @throws CacheException If failed.
- */
- protected final void removeAll() throws CacheException {
- evictAll();
- }
-
- /**
- * Called to remove object from cache without regard to transaction.
- *
- * @param ignite Grid.
- * @param cache Cache.
- * @param key Key.
- * @throws CacheException If failed.
- */
- static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) throws CacheException {
- try {
- key = cache.keyTransformer().transform(key);
-
- ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name()));
- }
- catch (IgniteException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Called to remove all data from cache without regard to transaction.
- *
- * @param cache Cache.
- * @throws CacheException If failed.
- */
- static void evictAll(IgniteInternalCache<Object,Object> cache) throws CacheException {
- try {
- cache.clear();
- }
- catch (IgniteCheckedException e) {
- throw new CacheException(e);
- }
- }
-
- /**
- * Callable invalidates given key.
- */
- private static class ClearKeyCallable implements IgniteCallable<Void>, Externalizable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** */
- @IgniteInstanceResource
- private Ignite ignite;
-
- /** */
- private Object key;
-
- /** */
- private String cacheName;
-
- /**
- * Empty constructor required by {@link Externalizable}.
- */
- public ClearKeyCallable() {
- // No-op.
- }
-
- /**
- * @param key Key to clear.
- * @param cacheName Cache name.
- */
- private ClearKeyCallable(Object key, String cacheName) {
- this.key = key;
- this.cacheName = cacheName;
- }
-
- /** {@inheritDoc} */
- @Override public Void call() throws IgniteCheckedException {
- IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
- assert cache != null;
-
- cache.clearLocally(key);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(key);
-
- U.writeString(out, cacheName);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- key = in.readObject();
-
- cacheName = U.readString(in);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
deleted file mode 100644
index 7204083..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCacheProxy.java
+++ /dev/null
@@ -1,801 +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.hibernate;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import javax.cache.Cache;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorResult;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CacheMetrics;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.mxbean.CacheMetricsMXBean;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Hibernate cache proxy used to substitute hibernate keys with ignite keys.
- */
-public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> {
- /** Delegate. */
- private final IgniteInternalCache<Object, Object> delegate;
-
- /** Transformer. */
- private final HibernateKeyTransformer keyTransformer;
-
- /**
- * @param delegate Delegate.
- * @param keyTransformer Key keyTransformer.
- */
- HibernateCacheProxy(
- IgniteInternalCache<Object, Object> delegate,
- HibernateKeyTransformer keyTransformer
- ) {
- assert delegate != null;
- assert keyTransformer != null;
-
- this.delegate = delegate;
- this.keyTransformer = keyTransformer;
- }
-
- /**
- * @return HibernateKeyTransformer
- */
- HibernateKeyTransformer keyTransformer(){
- return keyTransformer;
- }
-
- /** {@inheritDoc} */
- @Override public String name() {
- return delegate.name();
- }
-
- /** {@inheritDoc} */
- @Override public boolean skipStore() {
- return delegate.skipStore();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache setSkipStore(boolean skipStore) {
- return delegate.setSkipStore(skipStore);
- }
-
- /** {@inheritDoc} */
- @Override public boolean isEmpty() {
- return delegate.isEmpty();
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsKey(Object key) {
- return delegate.containsKey(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> containsKeyAsync(Object key) {
- return delegate.containsKeyAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean containsKeys(Collection keys) {
- return delegate.containsKey(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection keys) {
- return delegate.containsKeysAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object localPeek(
- Object key,
- CachePeekMode[] peekModes,
- @Nullable IgniteCacheExpiryPolicy plc
- ) throws IgniteCheckedException {
- return delegate.localPeek(keyTransformer.transform(key), peekModes, plc);
- }
-
- /** {@inheritDoc} */
- @Override public Iterable<Cache.Entry<Object, Object>> localEntries(
- CachePeekMode[] peekModes
- ) throws IgniteCheckedException {
- return delegate.localEntries(peekModes);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object get(Object key) throws IgniteCheckedException {
- return delegate.get(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public CacheEntry getEntry(Object key) throws IgniteCheckedException {
- return delegate.getEntry(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAsync(Object key) {
- return delegate.getAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<CacheEntry<Object, Object>> getEntryAsync(Object key) {
- return delegate.getEntryAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Map getAll(@Nullable Collection keys) throws IgniteCheckedException {
- return delegate.getAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<CacheEntry<Object, Object>> getEntries(
- @Nullable Collection keys) throws IgniteCheckedException {
- return delegate.getEntries(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map<Object, Object>> getAllAsync(@Nullable Collection keys) {
- return delegate.getAllAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Collection<CacheEntry<Object,Object>>> getEntriesAsync(
- @Nullable Collection keys
- ) {
- return delegate.getEntriesAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndPut(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndPutAsync(Object key, Object val) {
- return delegate.getAndPutAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean put(Object key, Object val) throws IgniteCheckedException {
- return delegate.put(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> putAsync(Object key, Object val) {
- return delegate.putAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndPutIfAbsent(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndPutIfAbsentAsync(Object key, Object val) {
- return delegate.getAndPutIfAbsentAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean putIfAbsent(Object key, Object val) throws IgniteCheckedException {
- return delegate.putIfAbsent(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(Object key, Object val) {
- return delegate.putIfAbsentAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndReplace(Object key, Object val) throws IgniteCheckedException {
- return delegate.getAndReplace(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndReplaceAsync(Object key, Object val) {
- return delegate.getAndReplaceAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(Object key, Object val) throws IgniteCheckedException {
- return delegate.replace(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object val) {
- return delegate.replaceAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public boolean replace(Object key, Object oldVal, Object newVal) throws IgniteCheckedException {
- return delegate.replace(keyTransformer.transform(key), oldVal, newVal);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object oldVal, Object newVal) {
- return delegate.replaceAsync(keyTransformer.transform(key), oldVal, newVal);
- }
-
- /** {@inheritDoc} */
- @Override public void putAll(@Nullable Map m) throws IgniteCheckedException {
- delegate.putAll(transform(m));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> putAllAsync(@Nullable Map m) {
- return delegate.putAllAsync(transform(m));
- }
-
- /** {@inheritDoc} */
- @Override public Set keySet() {
- return delegate.keySet();
- }
-
- /** {@inheritDoc} */
- @Override public Set keySetx() {
- return delegate.keySetx();
- }
-
- /** {@inheritDoc} */
- @Override public Set primaryKeySet() {
- return delegate.primaryKeySet();
- }
-
- /** {@inheritDoc} */
- @Override public Iterable values() {
- return delegate.values();
- }
-
- /** {@inheritDoc} */
- @Override public Set<Cache.Entry<Object, Object>> entrySet() {
- return delegate.entrySet();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Set<Cache.Entry<Object,Object>> entrySet(int part) {
- return delegate.entrySet(part);
- }
-
- /** {@inheritDoc} */
- @Override public Set<Cache.Entry<Object, Object>> entrySetx(CacheEntryPredicate... filter) {
- return delegate.entrySetx(filter);
- }
-
- /** {@inheritDoc} */
- @Override public Transaction txStart(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation
- ) {
- return delegate.txStart(concurrency, isolation);
- }
-
- /** {@inheritDoc} */
- @Override public GridNearTxLocal txStartEx(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation
- ) {
- return delegate.txStartEx(concurrency, isolation);
- }
-
- /** {@inheritDoc} */
- @Override public Transaction txStart(
- TransactionConcurrency concurrency,
- TransactionIsolation isolation,
- long timeout,
- int txSize
- ) {
- return delegate.txStart(concurrency, isolation, timeout, txSize);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public GridNearTxLocal tx() {
- return delegate.tx();
- }
-
- /** {@inheritDoc} */
- @Override public boolean evict(Object key) {
- return delegate.evict(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void evictAll(@Nullable Collection keys) {
- delegate.evictAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
- delegate.clearLocally(srv, near, readers);
- }
-
- /** {@inheritDoc} */
- @Override public boolean clearLocally(Object key) {
- return delegate.clearLocally(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void clearLocallyAll(Set keys, boolean srv, boolean near, boolean readers) {
- delegate.clearLocallyAll((Set<?>)transform(keys), srv, near, readers);
- }
-
- /** {@inheritDoc} */
- @Override public void clear(Object key) throws IgniteCheckedException {
- delegate.clear(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void clearAll(Set keys) throws IgniteCheckedException {
- delegate.clearAll((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void clear() throws IgniteCheckedException {
- delegate.clear();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync() {
- return delegate.clearAsync();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAsync(Object key) {
- return delegate.clearAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> clearAllAsync(Set keys) {
- return delegate.clearAllAsync((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getAndRemove(Object key) throws IgniteCheckedException {
- return delegate.getAndRemove(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getAndRemoveAsync(Object key) {
- return delegate.getAndRemoveAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean remove(Object key) throws IgniteCheckedException {
- return delegate.remove(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> removeAsync(Object key) {
- return delegate.removeAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean remove(Object key, Object val) throws IgniteCheckedException {
- return delegate.remove(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> removeAsync(Object key, Object val) {
- return delegate.removeAsync(keyTransformer.transform(key), val);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll(@Nullable Collection keys) throws IgniteCheckedException {
- delegate.removeAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection keys) {
- return delegate.removeAllAsync(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public void removeAll() throws IgniteCheckedException {
- delegate.removeAll();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllAsync() {
- return delegate.removeAllAsync();
- }
-
- /** {@inheritDoc} */
- @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException {
- return delegate.lock(keyTransformer.transform(key), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> lockAsync(Object key, long timeout) {
- return delegate.lockAsync(keyTransformer.transform(key), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public boolean lockAll(@Nullable Collection keys, long timeout) throws IgniteCheckedException {
- return delegate.lockAll(transform(keys), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection keys, long timeout) {
- return delegate.lockAllAsync(transform(keys), timeout);
- }
-
- /** {@inheritDoc} */
- @Override public void unlock(Object key) throws IgniteCheckedException {
- delegate.unlock(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public void unlockAll(@Nullable Collection keys) throws IgniteCheckedException {
- delegate.unlockAll(transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isLocked(Object key) {
- return delegate.isLocked(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isLockedByThread(Object key) {
- return delegate.isLockedByThread(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public int size() {
- return delegate.size();
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong() {
- return delegate.sizeLong();
- }
-
- /** {@inheritDoc} */
- @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSize(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSizeLong(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.localSizeLong(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.size(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.sizeLong(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
- return delegate.sizeLong(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) {
- return delegate.sizeAsync(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes) {
- return delegate.sizeLongAsync(peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Long> sizeLongAsync(int partition, CachePeekMode[] peekModes) {
- return delegate.sizeLongAsync(partition, peekModes);
- }
-
- /** {@inheritDoc} */
- @Override public int nearSize() {
- return delegate.nearSize();
- }
-
- /** {@inheritDoc} */
- @Override public int primarySize() {
- return delegate.primarySize();
- }
-
- /** {@inheritDoc} */
- @Override public long primarySizeLong() {
- return delegate.primarySizeLong();
- }
-
- /** {@inheritDoc} */
- @Override public CacheConfiguration configuration() {
- return delegate.configuration();
- }
-
- /** {@inheritDoc} */
- @Override public Affinity affinity() {
- return delegate.affinity();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics clusterMetrics() {
- return delegate.clusterMetrics();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics clusterMetrics(ClusterGroup grp) {
- return delegate.clusterMetrics(grp);
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetrics localMetrics() {
- return delegate.localMetrics();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetricsMXBean clusterMxBean() {
- return delegate.clusterMxBean();
- }
-
- /** {@inheritDoc} */
- @Override public CacheMetricsMXBean localMxBean() {
- return delegate.localMxBean();
- }
-
- /** {@inheritDoc} */
- @Override public long offHeapEntriesCount() {
- return delegate.offHeapEntriesCount();
- }
-
- /** {@inheritDoc} */
- @Override public long offHeapAllocatedSize() {
- return delegate.offHeapAllocatedSize();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> rebalance() {
- return delegate.rebalance();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache forSubjectId(UUID subjId) {
- return delegate.forSubjectId(subjId);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public Object getForcePrimary(Object key) throws IgniteCheckedException {
- return delegate.getForcePrimary(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture getForcePrimaryAsync(Object key) {
- return delegate.getForcePrimaryAsync(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Map getAllOutTx(Set keys) throws IgniteCheckedException {
- return delegate.getAllOutTx((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map<Object, Object>> getAllOutTxAsync(Set keys) {
- return delegate.getAllOutTxAsync((Set<?>)transform(keys));
- }
-
- /** {@inheritDoc} */
- @Override public boolean isIgfsDataCache() {
- return delegate.isIgfsDataCache();
- }
-
- /** {@inheritDoc} */
- @Override public long igfsDataSpaceUsed() {
- return delegate.igfsDataSpaceUsed();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMongoDataCache() {
- return delegate.isMongoDataCache();
- }
-
- /** {@inheritDoc} */
- @Override public boolean isMongoMetaCache() {
- return delegate.isMongoMetaCache();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public ExpiryPolicy expiry() {
- return delegate.expiry();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache withExpiryPolicy(ExpiryPolicy plc) {
- return delegate.withExpiryPolicy(plc);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache withNoRetries() {
- return delegate.withNoRetries();
- }
-
- /** {@inheritDoc} */
- @Override public GridCacheContext context() {
- return delegate.context();
- }
-
- /** {@inheritDoc} */
- @Override public void localLoadCache(
- @Nullable IgniteBiPredicate p,
- @Nullable Object... args
- ) throws IgniteCheckedException {
- delegate.localLoadCache(p, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> localLoadCacheAsync(
- @Nullable IgniteBiPredicate p,
- @Nullable Object... args
- ) {
- return delegate.localLoadCacheAsync(p, args);
- }
-
- /** {@inheritDoc} */
- @Override public Object getTopologySafe(Object key) throws IgniteCheckedException {
- return delegate.getTopologySafe(keyTransformer.transform(key));
- }
-
- /** {@inheritDoc} */
- @Override public Collection<Integer> lostPartitions() {
- return delegate.lostPartitions();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public EntryProcessorResult invoke(
- @Nullable AffinityTopologyVersion topVer,
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) throws IgniteCheckedException {
- return delegate.invoke(topVer, key, entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map> invokeAllAsync(Map map, Object... args) {
- return delegate.invokeAllAsync(map, args);
- }
-
- /** {@inheritDoc} */
- @Override public Map invokeAll(Map map, Object... args) throws IgniteCheckedException {
- return delegate.invokeAll(map, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<Map> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) {
- return delegate.invokeAllAsync((Set<?>)transform(keys), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public Map invokeAll(Set keys, EntryProcessor entryProcessor, Object... args) throws IgniteCheckedException {
- return delegate.invokeAll((Set<?>)transform(keys), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<EntryProcessorResult> invokeAsync(
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) {
- return delegate.invokeAsync(keyTransformer.transform(key), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public EntryProcessorResult invoke(
- Object key,
- EntryProcessor entryProcessor,
- Object... args
- ) throws IgniteCheckedException {
- return delegate.invoke(keyTransformer.transform(key), entryProcessor, args);
- }
-
- /** {@inheritDoc} */
- @Override public Iterator<Cache.Entry<Object,Object>> scanIterator(
- boolean keepBinary,
- @Nullable IgniteBiPredicate p
- ) throws IgniteCheckedException {
- return delegate.scanIterator(keepBinary, p);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map drMap) throws IgniteCheckedException {
- return delegate.removeAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public void removeAllConflict(Map drMap) throws IgniteCheckedException {
- delegate.removeAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalFuture<?> putAllConflictAsync(Map drMap) throws IgniteCheckedException {
- return delegate.putAllConflictAsync(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public void putAllConflict(Map drMap) throws IgniteCheckedException {
- delegate.putAllConflict(drMap);
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache keepBinary() {
- return delegate.keepBinary();
- }
-
- /** {@inheritDoc} */
- @Override public IgniteInternalCache cache() {
- return delegate.cache();
- }
-
- /** {@inheritDoc} */
- @Override public Iterator iterator() {
- return delegate.iterator();
- }
-
- /**
- * @param keys Keys.
- */
- private Collection<Object> transform(Collection<Object> keys) {
- Collection<Object> res = new LinkedList<>();
-
- for (Object o : keys)
- res.add(keyTransformer.transform(o));
-
- return res;
- }
-
- /**
- * @param map Map.
- */
- private Map<Object, Object> transform(Map<Object, Object> map) {
- Map<Object, Object> res = new HashMap<>();
-
- Set<Map.Entry<Object, Object>> ents = map.entrySet();
-
- for (Map.Entry<Object, Object> e : ents)
- res.put(keyTransformer.transform(e.getKey()), e.getValue());
-
- return res;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
deleted file mode 100644
index be99e98..0000000
--- a/modules/hibernate5/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
+++ /dev/null
@@ -1,114 +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.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.CacheDataDescription;
-import org.hibernate.cache.spi.CollectionRegion;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
-
-/**
- * Implementation of {@link CollectionRegion}. This region is used to store collection data.
- * <p>
- * L2 cache for collection can be enabled in the Hibernate configuration file:
- * <pre name="code" class="xml">
- * <hibernate-configuration>
- * <!-- Enable L2 cache. -->
- * <property name="cache.use_second_level_cache">true</property>
- *
- * <!-- Use Ignite as L2 cache provider. -->
- * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
- *
- * <!-- Specify entities. -->
- * <mapping class="com.example.Entity"/>
- * <mapping class="com.example.ChildEntity"/>
- *
- * <!-- Enable L2 cache with nonstrict-read-write access strategy for entities and collection. -->
- * <collection-cache collection="com.example.Entity" usage="nonstrict-read-write"/>
- * <collection-cache collection="com.example.ChildEntity" usage="nonstrict-read-write"/>
- * <collection-cache collection="com.example.Entity.children" usage="nonstrict-read-write"/>
- * </hibernate-configuration>
- * </pre>
- * Also cache for collection can be enabled using annotations:
- * <pre name="code" class="java">
- * @javax.persistence.Entity
- * public class Entity {
- * ...
- *
- * @javax.persistence.OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
- * @javax.persistence.JoinColumn(name="PARENT_ID")
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public List<ChildEntity> getChildren() {...}
- * }
- * </pre>
- * Note: the collection cache does not cache the state of the actual entities in the cache, it caches only identifier
- * values. For this reason, the collection cache should always be used in conjunction with
- * the second-level cache for those entities expected to be cached as part of a collection cache.
- */
-public class HibernateCollectionRegion extends HibernateTransactionalDataRegion implements CollectionRegion {
- /**
- * @param factory Region factory.
- * @param name Region name.
- * @param ignite Grid.
- * @param cache Region cache.
- * @param dataDesc Region data description.
- */
- public HibernateCollectionRegion(HibernateRegionFactory factory, String name,
- Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
- super(factory, name, ignite, cache, dataDesc);
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
- return new AccessStrategy(createAccessStrategy(accessType));
- }
-
- /**
- * Collection region access strategy.
- */
- private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
- implements CollectionRegionAccessStrategy {
- /**
- * @param stgy Access strategy implementation.
- */
- private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
- super(stgy);
- }
-
- /** {@inheritDoc} */
- @Override public Object generateCacheKey(Object id,
- CollectionPersister persister,
- SessionFactoryImplementor factory, String tenantIdentifier) {
- return HibernateKeyWrapper.staticCreateCollectionKey(id, persister, tenantIdentifier);
- }
-
- /** {@inheritDoc} */
- @Override public Object getCacheKeyId(Object cacheKey) {
- return ((HibernateKeyWrapper)cacheKey).id();
- }
-
- /** {@inheritDoc} */
- @Override public CollectionRegion getRegion() {
- return HibernateCollectionRegion.this;
- }
- }
-}
\ No newline at end of file
[11/50] [abbrv] ignite git commit: Try avoid timeout in
IgniteCacheGetRestartTest.
Posted by vo...@apache.org.
Try avoid timeout in IgniteCacheGetRestartTest.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b41ecd1e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b41ecd1e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b41ecd1e
Branch: refs/heads/master
Commit: b41ecd1e0b9dc6199a618e8d4df740c96372eba1
Parents: 3402043
Author: sboikov <sb...@gridgain.com>
Authored: Mon Apr 24 16:59:30 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Apr 24 16:59:30 2017 +0300
----------------------------------------------------------------------
.../processors/cache/distributed/IgniteCacheGetRestartTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b41ecd1e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
index aaa83cc..69d9123 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheGetRestartTest.java
@@ -219,7 +219,7 @@ public class IgniteCacheGetRestartTest extends GridCommonAbstractTest {
IgniteInternalFuture<?> syncFut = ((IgniteCacheProxy)cache).context().preloader().syncFuture();
- while (!syncFut.isDone())
+ while (!syncFut.isDone() && U.currentTimeMillis() < stopTime)
checkGet(cache);
checkGet(cache);
[47/50] [abbrv] ignite git commit: ignite-4799 TcpDiscoverySpi:
removed missedHeartbeats properties,
heartbeatFrequency (instead use IgiteConfiguration.metricsUpdateFrequency).
Added IgiteConfiguration.clientFailureDetectionTimeout.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
index 524fdcf..4b61199 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java
@@ -73,7 +73,6 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
-
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.ignite.events.EventType.EVT_CLIENT_NODE_DISCONNECTED;
@@ -142,7 +141,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
private boolean longSockTimeouts;
/** */
- private int maxMissedClientHbs = TcpDiscoverySpi.DFLT_MAX_MISSED_CLIENT_HEARTBEATS;
+ private long clientFailureDetectionTimeout = 1000;
/** */
private IgniteInClosure2X<TcpDiscoveryAbstractMessage, Socket> afterWrite;
@@ -154,9 +153,9 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
- TcpDiscoverySpi disco = getDiscoverySpi();
+ cfg.setClientFailureDetectionTimeout(clientFailureDetectionTimeout());
- disco.setMaxMissedClientHeartbeats(maxMissedClientHbs);
+ TcpDiscoverySpi disco = getDiscoverySpi();
if (igniteInstanceName.startsWith("server"))
disco.setIpFinder(IP_FINDER);
@@ -269,12 +268,21 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
}
/**
+ * Gets client failure detection timeout to use.
+ *
+ * @return Client failure detection timeout.
+ */
+ protected long clientFailureDetectionTimeout() {
+ return clientFailureDetectionTimeout;
+ }
+
+ /**
* Gets failure detection timeout to use.
*
* @return Failure detection timeout.
*/
protected long failureDetectionTimeout() {
- return 0;
+ return 500;
}
/**
@@ -301,6 +309,21 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testClientToClientPing() throws Exception {
+ startGrid("server-p1");
+ Ignite c1 = startGrid("client-p1");
+
+ startGrid("server-p2");
+ Ignite c2 = startGrid("client-p2");
+
+ boolean res = ((IgniteEx)c1).context().discovery().pingNode(c2.cluster().localNode().id());
+
+ assertTrue(res);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testClientNodeJoin() throws Exception {
startServerNodes(3);
startClientNodes(3);
@@ -358,8 +381,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
failClient(2);
- await(srvFailedLatch);
- await(clientFailedLatch);
+ awaitClient(srvFailedLatch);
+ awaitClient(clientFailedLatch);
checkNodes(3, 2);
}
@@ -588,7 +611,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClientReconnectTopologyChange1() throws Exception {
- maxMissedClientHbs = 100;
+ clientFailureDetectionTimeout = 100000;
clientsPerSrv = 1;
@@ -632,7 +655,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testClientReconnectTopologyChange2() throws Exception {
- maxMissedClientHbs = 100;
+ clientFailureDetectionTimeout = 100000;
clientsPerSrv = 1;
@@ -744,8 +767,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
failServer(2);
- await(srvFailedLatch);
- await(clientFailedLatch);
+ awaitClient(srvFailedLatch);
+ awaitClient(clientFailedLatch);
await(client2StoppedLatch);
@@ -796,6 +819,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
}
/**
+ * Test that server not fire client failure event after failure detection timeout.
+ *
* @throws Exception If failed.
*/
public void testClientNodeFailOneServer() throws Exception {
@@ -843,8 +868,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
failClient(1);
failServer(1);
- await(srvFailedLatch);
- await(clientFailedLatch);
+ awaitClient(srvFailedLatch);
+ awaitClient(clientFailedLatch);
checkNodes(1, 1);
}
@@ -1631,7 +1656,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
assertFalse(err.get());
if (!failSrv) {
- await(srvFailedLatch);
+ awaitClient(srvFailedLatch);
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
@@ -1721,7 +1746,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
public void testDisconnectAfterNetworkTimeout() throws Exception {
netTimeout = 5000;
joinTimeout = 60_000;
- maxMissedClientHbs = 2;
+ clientFailureDetectionTimeout = 2000;
startServerNodes(1);
@@ -1774,7 +1799,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
clientSpi.brakeConnection();
- assertTrue(disconnectLatch.await(awaitTime(), MILLISECONDS));
+ assertTrue(disconnectLatch.await(awaitClientTime(), MILLISECONDS));
log.info("Fail client connection2.");
@@ -1793,7 +1818,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
@Override public boolean apply() {
return srv.cluster().nodes().size() == 2;
}
- }, awaitTime());
+ }, awaitClientTime());
checkNodes(1, 1);
@@ -2076,6 +2101,15 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
}
/**
+ * @param latch Latch.
+ * @throws InterruptedException If interrupted.
+ */
+ private void awaitClient(CountDownLatch latch) throws InterruptedException {
+ assertTrue("Failed to wait for latch, latch count: " + latch.getCount(),
+ latch.await(awaitClientTime(), MILLISECONDS));
+ }
+
+ /**
* Time to wait for operation completion.
*
* @return Time in milliseconds.
@@ -2085,6 +2119,15 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
}
/**
+ * Time to wait for client operation completion.
+ *
+ * @return Time in milliseconds.
+ */
+ protected long awaitClientTime() {
+ return 20_000;
+ }
+
+ /**
*/
private static class MessageListener implements IgniteBiPredicate<UUID, Object> {
/** */
@@ -2267,7 +2310,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
IgniteSpiOperationTimeoutHelper timeoutHelper) throws IOException, IgniteSpiOperationTimeoutException {
waitFor(openSockLock);
- return super.openSocket(sockAddr, new IgniteSpiOperationTimeoutHelper(this));
+ return super.openSocket(sockAddr, timeoutHelper);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index c6d1147..f8f9baf 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -78,7 +78,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMultic
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage;
-import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryHeartbeatMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryMetricsUpdateMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddFinishedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeAddedMessage;
import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeFailedMessage;
@@ -154,16 +154,14 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
spi.setNetworkTimeout(2500);
- spi.setHeartbeatFrequency(1000);
-
- spi.setMaxMissedHeartbeats(3);
-
spi.setIpFinderCleanFrequency(5000);
spi.setJoinTimeout(5000);
cfg.setDiscoverySpi(spi);
+ cfg.setFailureDetectionTimeout(7500);
+
if (ccfgs != null)
cfg.setCacheConfiguration(ccfgs);
else
@@ -173,12 +171,16 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
cfg.setIncludeProperties();
+ cfg.setMetricsUpdateFrequency(1000);
+
if (!igniteInstanceName.contains("LoopbackProblemTest"))
cfg.setLocalHost("127.0.0.1");
if (igniteInstanceName.contains("testFailureDetectionOnNodePing")) {
spi.setReconnectCount(1); // To make test faster: on Windows 1 connect takes 1 second.
- spi.setHeartbeatFrequency(40000);
+
+ cfg.setMetricsUpdateFrequency(40000);
+ cfg.setClientFailureDetectionTimeout(41000);
}
cfg.setConnectorConfiguration(null);
@@ -433,7 +435,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
assertFalse("Ping is ok for node " + failedNodeId + ", but had to fail.", res);
- // Heartbeat interval is 40 seconds, but we should detect node failure faster.
+ // Metrics update interval is 40 seconds, but we should detect node failure faster.
assert cnt.await(7, SECONDS);
}
@@ -2252,7 +2254,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
long timeout) throws IOException, IgniteCheckedException {
boolean add = msgIds.add(msg.id());
- if (checkDuplicates && !add && !(msg instanceof TcpDiscoveryHeartbeatMessage)) {
+ if (checkDuplicates && !add && !(msg instanceof TcpDiscoveryMetricsUpdateMessage)) {
log.error("Send duplicated message: " + msg);
failed = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
index c349e5f..ea1bb27 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiConfigSelfTest.java
@@ -40,9 +40,7 @@ public class TcpDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTest<Tcp
checkNegativeSpiProperty(new TcpDiscoverySpi(), "ackTimeout", 0);
checkNegativeSpiProperty(new TcpDiscoverySpi(), "maxAckTimeout", 0);
checkNegativeSpiProperty(new TcpDiscoverySpi(), "reconnectCount", 0);
- checkNegativeSpiProperty(new TcpDiscoverySpi(), "heartbeatFrequency", 0);
checkNegativeSpiProperty(new TcpDiscoverySpi(), "threadPriority", -1);
- checkNegativeSpiProperty(new TcpDiscoverySpi(), "maxMissedHeartbeats", 0);
checkNegativeSpiProperty(new TcpDiscoverySpi(), "statisticsPrintFrequency", 0);
}
@@ -65,4 +63,4 @@ public class TcpDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTest<Tcp
stopAllGrids();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
index a218bcb..cb5e84b 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java
@@ -24,7 +24,6 @@ import java.net.Socket;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.spi.IgniteSpiOperationTimeoutException;
import org.apache.ignite.spi.IgniteSpiOperationTimeoutHelper;
import org.apache.ignite.spi.discovery.AbstractDiscoverySelfTest;
@@ -93,6 +92,11 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
firstSpi().failureDetectionTimeout());
assertEquals(IgniteConfiguration.DFLT_FAILURE_DETECTION_TIMEOUT.longValue(),
secondSpi().failureDetectionTimeout());
+
+ assertEquals(IgniteConfiguration.DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT.longValue(),
+ firstSpi().clientFailureDetectionTimeout());
+ assertEquals(IgniteConfiguration.DFLT_CLIENT_FAILURE_DETECTION_TIMEOUT.longValue(),
+ secondSpi().clientFailureDetectionTimeout());
}
/**
@@ -102,6 +106,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
for (int i = 2; i < spis.size(); i++) {
assertFalse(((TcpDiscoverySpi)spis.get(i)).failureDetectionTimeoutEnabled());
assertEquals(0, ((TcpDiscoverySpi)spis.get(i)).failureDetectionTimeout());
+ assertFalse(0 == ((TcpDiscoverySpi)spis.get(i)).clientFailureDetectionTimeout());
}
}
@@ -112,14 +117,14 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
try {
ClusterNode node = secondSpi().getLocalNode();
- firstSpi().openSocketTimeout = true;
+ firstSpi().openSockTimeout = true;
assertFalse(firstSpi().pingNode(node.id()));
assertTrue(firstSpi().validTimeout);
assertTrue(firstSpi().err.getMessage().equals("Timeout: openSocketTimeout"));
- firstSpi().openSocketTimeout = false;
- firstSpi().openSocketTimeoutWait = true;
+ firstSpi().openSockTimeout = false;
+ firstSpi().openSockTimeoutWait = true;
assertFalse(firstSpi().pingNode(node.id()));
assertTrue(firstSpi().validTimeout);
@@ -138,12 +143,12 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
try {
ClusterNode node = secondSpi().getLocalNode();
- firstSpi().writeToSocketTimeoutWait = true;
+ firstSpi().writeToSockTimeoutWait = true;
assertFalse(firstSpi().pingNode(node.id()));
assertTrue(firstSpi().validTimeout);
- firstSpi().writeToSocketTimeoutWait = false;
+ firstSpi().writeToSockTimeoutWait = false;
assertTrue(firstSpi().pingNode(node.id()));
assertTrue(firstSpi().validTimeout);
@@ -178,13 +183,13 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
assert nextSpi.connCheckStatusMsgCntReceived == 0;
- firstSpi().countConnCheckMsg = true;
- nextSpi.countConnCheckMsg = true;
+ firstSpi().cntConnCheckMsg = true;
+ nextSpi.cntConnCheckMsg = true;
Thread.sleep(firstSpi().failureDetectionTimeout());
- firstSpi().countConnCheckMsg = false;
- nextSpi.countConnCheckMsg = false;
+ firstSpi().cntConnCheckMsg = false;
+ nextSpi.cntConnCheckMsg = false;
int sent = firstSpi().connCheckStatusMsgCntSent;
int received = nextSpi.connCheckStatusMsgCntReceived;
@@ -224,16 +229,16 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
*/
private static class TestTcpDiscoverySpi extends TcpDiscoverySpi {
/** */
- private volatile boolean openSocketTimeout;
+ private volatile boolean openSockTimeout;
/** */
- private volatile boolean openSocketTimeoutWait;
+ private volatile boolean openSockTimeoutWait;
/** */
- private volatile boolean writeToSocketTimeoutWait;
+ private volatile boolean writeToSockTimeoutWait;
/** */
- private volatile boolean countConnCheckMsg;
+ private volatile boolean cntConnCheckMsg;
/** */
private volatile int connCheckStatusMsgCntSent;
@@ -253,11 +258,11 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
IgniteSpiOperationTimeoutHelper timeoutHelper)
throws IOException, IgniteSpiOperationTimeoutException {
- if (openSocketTimeout) {
+ if (openSockTimeout) {
err = new IgniteSpiOperationTimeoutException("Timeout: openSocketTimeout");
throw err;
}
- else if (openSocketTimeoutWait) {
+ else if (openSockTimeoutWait) {
long timeout = timeoutHelper.nextTimeoutChunk(0);
try {
@@ -291,7 +296,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
@Override protected void writeToSocket(Socket sock, OutputStream out, TcpDiscoveryAbstractMessage msg, long timeout)
throws IOException, IgniteCheckedException {
if (!(msg instanceof TcpDiscoveryPingRequest)) {
- if (countConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
+ if (cntConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
connCheckStatusMsgCntSent++;
super.writeToSocket(sock, out, msg, timeout);
@@ -305,7 +310,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
throw new IgniteCheckedException("Invalid timeout: " + timeout);
}
- if (writeToSocketTimeoutWait) {
+ if (writeToSockTimeoutWait) {
try {
Thread.sleep(timeout);
}
@@ -320,7 +325,7 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
/** {@inheritDoc} */
protected void writeToSocket(TcpDiscoveryAbstractMessage msg, Socket sock, int res, long timeout)
throws IOException {
- if (countConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
+ if (cntConnCheckMsg && msg instanceof TcpDiscoveryConnectionCheckMessage)
connCheckStatusMsgCntReceived++;
super.writeToSocket(msg, sock, res, timeout);
@@ -330,14 +335,14 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf
*
*/
private void resetState() {
- openSocketTimeout = false;
- openSocketTimeoutWait = false;
- writeToSocketTimeoutWait = false;
+ openSockTimeout = false;
+ openSockTimeoutWait = false;
+ writeToSockTimeoutWait = false;
err = null;
validTimeout = true;
connCheckStatusMsgCntSent = 0;
connCheckStatusMsgCntReceived = 0;
- countConnCheckMsg = false;
+ cntConnCheckMsg = false;
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 8a7150d..d080b54 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -1467,19 +1467,19 @@ public abstract class GridAbstractTest extends TestCase {
TcpDiscoverySpi discoSpi = new TestTcpDiscoverySpi();
if (isDebug()) {
- discoSpi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
+ cfg.setFailureDetectionTimeout(Integer.MAX_VALUE);
cfg.setNetworkTimeout(Long.MAX_VALUE / 3);
}
else {
// Set network timeout to 10 sec to avoid unexpected p2p class loading errors.
cfg.setNetworkTimeout(10000);
- // Increase max missed heartbeats to avoid unexpected node fails.
- discoSpi.setMaxMissedHeartbeats(30);
+ // Increase failure detection timeoute to avoid unexpected node fails.
+ cfg.setFailureDetectionTimeout(300000);
}
- // Set heartbeat interval to 1 second to speed up tests.
- discoSpi.setHeartbeatFrequency(1000);
+ // Set metrics update interval to 1 second to speed up tests.
+ cfg.setMetricsUpdateFrequency(1000);
String mcastAddr = GridTestUtils.getNextMulticastGroup(getClass());
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml
----------------------------------------------------------------------
diff --git a/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml b/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml
index cb781e0..429ff15 100644
--- a/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml
+++ b/modules/core/src/test/webapp/META-INF/ignite-webapp-config.xml
@@ -208,7 +208,6 @@
<property name="bucketName" value="YOUR_BUCKET_NAME_IP_FINDER"/>
</bean>
</property>
- <property name="heartbeatFrequency" value="2000"/>
</bean>
</property>
-->
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs
index fd5822a..b409a5a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheMetricsTest.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Tests.Cache
using System.Threading;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Configuration;
- using Apache.Ignite.Core.Discovery.Tcp;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Cache;
using NUnit.Framework;
@@ -228,7 +227,7 @@ namespace Apache.Ignite.Core.Tests.Cache
localCache.Put(localKey, 1);
localCache.Get(localKey);
// Wait for metrics to propagate.
- Thread.Sleep(TcpDiscoverySpi.DefaultHeartbeatFrequency);
+ Thread.Sleep(IgniteConfiguration.DefaultMetricsUpdateFrequency);
var localMetrics = func(localCache);
Assert.IsTrue(localMetrics.IsStatisticsEnabled);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
index 31dd887..0524c05 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -726,7 +726,6 @@ namespace Apache.Ignite.Core.Tests
},
ClientReconnectDisabled = true,
ForceServerMode = true,
- HeartbeatFrequency = TimeSpan.FromSeconds(3),
IpFinderCleanFrequency = TimeSpan.FromMinutes(7),
LocalAddress = "127.0.0.1",
LocalPort = 49900,
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
index 8da2616..b0ed0d2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -480,7 +480,6 @@ namespace Apache.Ignite.Core.Tests
},
ClientReconnectDisabled = true,
ForceServerMode = true,
- HeartbeatFrequency = TimeSpan.FromSeconds(3),
IpFinderCleanFrequency = TimeSpan.FromMinutes(7),
LocalAddress = "127.0.0.1",
LocalPort = 49900,
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
index a99f7b0..bdf5780 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
@@ -88,11 +88,6 @@ namespace Apache.Ignite.Core.Discovery.Tcp
public const int DefaultThreadPriority = 10;
/// <summary>
- /// Default value for the <see cref="HeartbeatFrequency"/> property.
- /// </summary>
- public static readonly TimeSpan DefaultHeartbeatFrequency = TimeSpan.FromSeconds(2);
-
- /// <summary>
/// Default value for the <see cref="TopologyHistorySize"/> property.
/// </summary>
public const int DefaultTopologyHistorySize = 1000;
@@ -114,7 +109,6 @@ namespace Apache.Ignite.Core.Discovery.Tcp
MaxMissedClientHeartbeats = DefaultMaxMissedClientHeartbeats;
IpFinderCleanFrequency = DefaultIpFinderCleanFrequency;
ThreadPriority = DefaultThreadPriority;
- HeartbeatFrequency = DefaultHeartbeatFrequency;
TopologyHistorySize = DefaultTopologyHistorySize;
}
@@ -143,7 +137,6 @@ namespace Apache.Ignite.Core.Discovery.Tcp
StatisticsPrintFrequency = reader.ReadLongAsTimespan();
IpFinderCleanFrequency = reader.ReadLongAsTimespan();
ThreadPriority = reader.ReadInt();
- HeartbeatFrequency = reader.ReadLongAsTimespan();
TopologyHistorySize = reader.ReadInt();
}
@@ -248,13 +241,6 @@ namespace Apache.Ignite.Core.Discovery.Tcp
public int ThreadPriority { get; set; }
/// <summary>
- /// Gets or sets delay between issuing of heartbeat messages. SPI sends heartbeat messages
- /// in configurable time interval to other nodes to notify them about its state.
- /// </summary>
- [DefaultValue(typeof(TimeSpan), "0:0:2")]
- public TimeSpan HeartbeatFrequency { get; set; }
-
- /// <summary>
/// Gets or sets the size of topology snapshots history.
/// </summary>
[DefaultValue(DefaultTopologyHistorySize)]
@@ -298,7 +284,6 @@ namespace Apache.Ignite.Core.Discovery.Tcp
writer.WriteLong((long) StatisticsPrintFrequency.TotalMilliseconds);
writer.WriteLong((long) IpFinderCleanFrequency.TotalMilliseconds);
writer.WriteInt(ThreadPriority);
- writer.WriteLong((long) HeartbeatFrequency.TotalMilliseconds);
writer.WriteInt(TopologyHistorySize);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
index 67f2715..728e62b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -873,11 +873,6 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="heartbeatFrequency" type="xs:string">
- <xs:annotation>
- <xs:documentation>Delay between issuing of heartbeat messages. SPI sends heartbeat messages in configurable time interval to other nodes to notify them about its state.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
<xs:attribute name="ipFinderCleanFrequency" type="xs:string">
<xs:annotation>
<xs:documentation>IP finder clean frequency.</xs:documentation>
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
index c40814c..f7caa78 100644
--- a/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
+++ b/modules/platforms/dotnet/examples/Apache.Ignite.Examples/Datagrid/MultiTieredCacheExample.cs
@@ -93,7 +93,7 @@ namespace Apache.Ignite.Examples.Datagrid
Console.WriteLine(">>> Waiting for metrics final update...");
- Thread.Sleep(TcpDiscoverySpi.DefaultHeartbeatFrequency);
+ Thread.Sleep(IgniteConfiguration.DefaultMetricsUpdateFrequency);
PrintCacheMetrics(cache);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java b/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java
index da51d68..2cfaa46 100644
--- a/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java
+++ b/modules/urideploy/src/test/java/org/apache/ignite/p2p/GridP2PDisabledSelfTest.java
@@ -83,7 +83,7 @@ public class GridP2PDisabledSelfTest extends GridCommonAbstractTest {
cfg.setDeploymentSpi(depSpi);
}
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setHeartbeatFrequency(500);
+ cfg.setMetricsUpdateFrequency(500);
return cfg;
}
@@ -212,4 +212,4 @@ public class GridP2PDisabledSelfTest extends GridCommonAbstractTest {
checkGar();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6998785a/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
----------------------------------------------------------------------
diff --git a/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml b/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
index e504fe7..9cb2761 100644
--- a/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
+++ b/modules/web/src/test/webapp2/META-INF/ignite-webapp-config.xml
@@ -199,7 +199,6 @@
<property name="bucketName" value="YOUR_BUCKET_NAME_IP_FINDER"/>
</bean>
</property>
- <property name="heartbeatFrequency" value="2000"/>
</bean>
</property>
-->
[16/50] [abbrv] ignite git commit: Fixed failures in
IgniteCrosscacheJoinsQueryTest.
Posted by vo...@apache.org.
Fixed failures in IgniteCrosscacheJoinsQueryTest.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/645581ee
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/645581ee
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/645581ee
Branch: refs/heads/master
Commit: 645581ee7b76ed40800b47049fa4aea7e4d5605e
Parents: 8d0da14
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 25 11:06:09 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 25 11:06:09 2017 +0300
----------------------------------------------------------------------
.../cache/IgniteCrossCachesJoinsQueryTest.java | 77 +-------------------
1 file changed, 3 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/645581ee/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
index cd35788..3ad316f 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCrossCachesJoinsQueryTest.java
@@ -31,8 +31,6 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
-import java.util.concurrent.Callable;
-import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheMode;
@@ -53,7 +51,6 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -428,6 +425,7 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
* @param cacheList Caches.
* @throws Exception If failed.
*/
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
private void checkAllCacheCombinations(
boolean idx,
List<List<TestCache>> cacheList) throws Exception {
@@ -552,8 +550,8 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
boolean distributeJoins0 = distributedJoins;
if (replicated(cache)) {
- if (!testNode.configuration().isClientMode())
- assertProperException(cache);
+// if (!testNode.configuration().isClientMode())
+// assertProperException(cache);
boolean all3CachesAreReplicated =
replicated(ignite(0).cache(ACC_CACHE_NAME)) &&
@@ -603,36 +601,6 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
}
/**
- * @param cache Cache.
- */
- private void assertProperException(final IgniteCache cache) {
- qry = "assertProperException";
-
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
- cache.query(new SqlFieldsQuery("select p.name from " +
- "\"" + PERSON_CACHE_NAME + "\".Person p, " +
- "\"" + ACC_CACHE_NAME + "\".Account a " +
- "where p._key = a.personId").setDistributedJoins(true));
-
- return null;
- }
- }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
-
- GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override public Object call() throws Exception {
- cache.query(new SqlQuery(Person.class,
- "from \"" + PERSON_CACHE_NAME + "\".Person , " +
- "\"" + ACC_CACHE_NAME + "\".Account " +
- "where Person._key = Account.personId")
- .setDistributedJoins(true));
-
- return null;
- }
- }, CacheException.class, "Queries using distributed JOINs have to be run on partitioned cache");
- }
-
- /**
* Organization ids: [0, 9]. Person ids: randoms at [10, 9999]. Accounts ids: randoms at [10000, 999_999]
*
* @return Data.
@@ -1195,45 +1163,6 @@ public class IgniteCrossCachesJoinsQueryTest extends AbstractH2CompareQueryTest
}
/**
- * @param cache Cache.
- */
- private void checkPersonAccountOrganizationGroupBy(IgniteCache cache) {
- qry = "checkPersonAccountOrganizationGroupBy";
-
- // Max count of accounts at org.
- SqlFieldsQuery q = new SqlFieldsQuery("select max(count(a.id)) " +
- "from " +
- "\"" + PERSON_CACHE_NAME + "\".Person p " +
- "\"" + ORG_CACHE_NAME + "\".Organization o " +
- "\"" + ACC_CACHE_NAME + "\".Account a " +
- "where p.id = a.personId and p.orgStrId = o.strId " +
- "group by org.id " +
- "having o.id = ?");
-
- q.setDistributedJoins(distributedJoins());
-
- for (Map.Entry<Integer, Integer> e : data.accountsPerPerson.entrySet()) {
- Integer personId = e.getKey();
- Integer cnt = e.getValue();
-
- q.setArgs(personId);
-
- List<List<?>> res = cache.query(q).getAll();
-
- String errMsg = "Expected data [personId=" + personId + ", cnt=" + cnt + ", data=" + data + "]";
-
- // Cnt == 0 means that there are no accounts for the person.
- if (cnt > 0) {
- assertEquals(errMsg, 1, res.size());
- assertEquals(errMsg, 1, res.get(0).size());
- assertEquals(errMsg, (long)cnt, res.get(0).get(0));
- }
- else
- assertEquals(errMsg, 0, res.size());
- }
- }
-
- /**
* @throws Exception If failed.
*/
private void checkGroupBy() throws Exception {
[45/50] [abbrv] ignite git commit: IGNITE-4539 - Added RocketMQ
integration
Posted by vo...@apache.org.
IGNITE-4539 - Added RocketMQ integration
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/335f2431
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/335f2431
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/335f2431
Branch: refs/heads/master
Commit: 335f24317da9f0083834bb9e34622b85d282f42b
Parents: ee1b19d
Author: Roman Shtykh <rs...@yahoo.com>
Authored: Wed Apr 26 14:24:20 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Apr 26 14:25:12 2017 +0300
----------------------------------------------------------------------
modules/rocketmq/README.txt | 25 +++
modules/rocketmq/pom.xml | 81 +++++++
.../stream/rocketmq/RocketMQStreamer.java | 151 +++++++++++++
.../ignite/stream/rocketmq/package-info.java | 21 ++
.../stream/rocketmq/RocketMQStreamerTest.java | 214 +++++++++++++++++++
.../rocketmq/RocketMQStreamerTestSuite.java | 37 ++++
.../stream/rocketmq/TestRocketMQServer.java | 148 +++++++++++++
.../ignite/stream/rocketmq/package-info.java | 21 ++
parent/pom.xml | 5 +
pom.xml | 1 +
10 files changed, 704 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/README.txt
----------------------------------------------------------------------
diff --git a/modules/rocketmq/README.txt b/modules/rocketmq/README.txt
new file mode 100644
index 0000000..55a117b
--- /dev/null
+++ b/modules/rocketmq/README.txt
@@ -0,0 +1,25 @@
+Apache Ignite RocketMQ Streamer Module
+--------------------------------------
+
+Apache Ignite RocketMQ Streamer module provides streaming from RocketMQ to Ignite cache.
+
+To use Ignite RocketMQ Streamer module, first import it to your Maven project.
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ ...
+ <dependencies>
+ ...
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-rocketmq</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+
+Then, initialize and start it as, for instance, done in RocketMQStreamerTest.java.
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rocketmq/pom.xml b/modules/rocketmq/pom.xml
new file mode 100644
index 0000000..3b317fa
--- /dev/null
+++ b/modules/rocketmq/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-rocketmq</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.rocketmq</groupId>
+ <artifactId>rocketmq-namesrv</artifactId>
+ <version>${rocketmq.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.rocketmq</groupId>
+ <artifactId>rocketmq-broker</artifactId>
+ <version>${rocketmq.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/RocketMQStreamer.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/RocketMQStreamer.java b/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/RocketMQStreamer.java
new file mode 100644
index 0000000..67f1ce5
--- /dev/null
+++ b/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/RocketMQStreamer.java
@@ -0,0 +1,151 @@
+/*
+ * 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.stream.rocketmq;
+
+import java.util.List;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.stream.StreamAdapter;
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.MessageExt;
+
+/**
+ * Streamer that subscribes to a RocketMQ topic amd feeds messages into {@link IgniteDataStreamer} instance.
+ */
+public class RocketMQStreamer<K, V> extends StreamAdapter<List<MessageExt>, K, V> implements MessageListenerConcurrently {
+ /** Logger. */
+ private IgniteLogger log;
+
+ /** RocketMQ consumer. */
+ private DefaultMQPushConsumer consumer;
+
+ /** State. */
+ private volatile boolean stopped = true;
+
+ /** Topic to subscribe to. */
+ private String topic;
+
+ /** Consumer group. */
+ private String consumerGrp;
+
+ /** Name server address. */
+ private String nameSrvAddr;
+
+ /**
+ * Starts streamer.
+ *
+ * @throws IgniteException If failed.
+ */
+ public void start() {
+ if (!stopped)
+ throw new IgniteException("Attempted to start an already started RocketMQ streamer");
+
+ // validate parameters.
+ A.notNull(getStreamer(), "streamer");
+ A.notNull(getIgnite(), "ignite");
+ A.notNull(topic, "topic");
+ A.notNull(consumerGrp, "consumer group");
+ A.notNullOrEmpty(nameSrvAddr, "nameserver address");
+ A.ensure(null != getMultipleTupleExtractor(), "Multiple tuple extractor must be configured");
+
+ log = getIgnite().log();
+
+ consumer = new DefaultMQPushConsumer(consumerGrp);
+
+ consumer.setNamesrvAddr(nameSrvAddr);
+ consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_LAST_OFFSET);
+
+ try {
+ consumer.subscribe(topic, "*");
+ }
+ catch (MQClientException e) {
+ throw new IgniteException("Failed to subscribe to " + topic, e);
+ }
+
+ consumer.registerMessageListener(this);
+
+ try {
+ consumer.start();
+ }
+ catch (MQClientException e) {
+ throw new IgniteException("Failed to start the streamer", e);
+ }
+
+ stopped = false;
+ }
+
+ /**
+ * Stops streamer.
+ */
+ public void stop() {
+ if (consumer != null)
+ consumer.shutdown();
+
+ stopped = true;
+ }
+
+ /**
+ * Implements {@link MessageListenerConcurrently#consumeMessage(List, ConsumeConcurrentlyContext)} to receive
+ * messages.
+ *
+ * {@inheritDoc}
+ */
+ @Override public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs,
+ ConsumeConcurrentlyContext context) {
+ if (log.isDebugEnabled())
+ log.debug("Received " + msgs.size() + " messages");
+
+ addMessage(msgs);
+
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+
+ /**
+ * Sets the topic to subscribe to.
+ *
+ * @param topic The topic to subscribe to.
+ */
+ public void setTopic(String topic) {
+ this.topic = topic;
+ }
+
+ /**
+ * Sets the name of the consumer group.
+ *
+ * @param consumerGrp Consumer group name.
+ */
+ public void setConsumerGrp(String consumerGrp) {
+ this.consumerGrp = consumerGrp;
+ }
+
+ /**
+ * Sets the name server address.
+ *
+ * @param nameSrvAddr Name server address
+ */
+ public void setNameSrvAddr(String nameSrvAddr) {
+ this.nameSrvAddr = nameSrvAddr;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/package-info.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/package-info.java b/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/package-info.java
new file mode 100644
index 0000000..f743696
--- /dev/null
+++ b/modules/rocketmq/src/main/java/org/apache/ignite/stream/rocketmq/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 implementation of RocketMQStreamer tests.
+ */
+package org.apache.ignite.stream.rocketmq;
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java
new file mode 100644
index 0000000..59451e9
--- /dev/null
+++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTest.java
@@ -0,0 +1,214 @@
+/*
+ * 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.stream.rocketmq;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.events.CacheEvent;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.apache.ignite.stream.StreamMultipleTupleExtractor;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.common.TopicConfig;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.tools.admin.DefaultMQAdminExt;
+
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
+import static org.apache.ignite.stream.rocketmq.TestRocketMQServer.NAME_SERVER_PORT;
+import static org.apache.ignite.stream.rocketmq.TestRocketMQServer.TEST_IP;
+
+/**
+ * Test for {@link RocketMQStreamer}.
+ */
+public class RocketMQStreamerTest extends GridCommonAbstractTest {
+ /** Test topic. */
+ private static final String TOPIC_NAME = "testTopic";
+
+ /** Test consumer group. */
+ private static final String CONSUMER_GRP = "testConsumerGrp";
+
+ /** Test server. */
+ private static TestRocketMQServer testRocketMQServer;
+
+ /** Number of events to handle. */
+ private static final int EVT_NUM = 1000;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected void beforeTest() throws Exception {
+ grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ grid().cache(null).clear();
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override protected void beforeTestsStarted() throws Exception {
+ testRocketMQServer = new TestRocketMQServer(log);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ if (testRocketMQServer != null)
+ testRocketMQServer.shutdown();
+ }
+
+ /** Constructor. */
+ public RocketMQStreamerTest() {
+ super(true);
+ }
+
+ /**
+ * Tests data is properly injected into the grid.
+ *
+ * @throws Exception If fails.
+ */
+ public void testStreamer() throws Exception {
+ RocketMQStreamer<String, byte[]> streamer = null;
+
+ Ignite ignite = grid();
+
+ try (IgniteDataStreamer<String, byte[]> dataStreamer = ignite.dataStreamer(null)) {
+ dataStreamer.allowOverwrite(true);
+ dataStreamer.autoFlushFrequency(10);
+
+ streamer = new RocketMQStreamer<>();
+
+ //configure.
+ streamer.setIgnite(ignite);
+ streamer.setStreamer(dataStreamer);
+ streamer.setNameSrvAddr(TEST_IP + ":" + NAME_SERVER_PORT);
+ streamer.setConsumerGrp(CONSUMER_GRP);
+ streamer.setTopic(TOPIC_NAME);
+ streamer.setMultipleTupleExtractor(new TestTupleExtractor());
+
+ streamer.start();
+
+ IgniteCache<String, String> cache = ignite.cache(null);
+
+ assertEquals(0, cache.size(CachePeekMode.PRIMARY));
+
+ final CountDownLatch latch = new CountDownLatch(EVT_NUM);
+
+ IgniteBiPredicate<UUID, CacheEvent> putLsnr = new IgniteBiPredicate<UUID, CacheEvent>() {
+ @Override public boolean apply(UUID uuid, CacheEvent evt) {
+ assert evt != null;
+
+ latch.countDown();
+
+ return true;
+ }
+ };
+
+ ignite.events(ignite.cluster().forCacheNodes(null)).remoteListen(putLsnr, null, EVT_CACHE_OBJECT_PUT);
+
+ produceData();
+
+ assertTrue(latch.await(30, TimeUnit.SECONDS));
+
+ assertEquals(EVT_NUM, cache.size(CachePeekMode.PRIMARY));
+ }
+ finally {
+ if (streamer != null)
+ streamer.stop();
+ }
+ }
+
+ /**
+ * Test tuple extractor.
+ */
+ public static class TestTupleExtractor implements StreamMultipleTupleExtractor<List<MessageExt>, String, byte[]> {
+
+ /** {@inheritDoc} */
+ @Override public Map<String, byte[]> extract(List<MessageExt> msgs) {
+ final Map<String, byte[]> map = new HashMap<>();
+
+ for (MessageExt msg : msgs)
+ map.put(msg.getMsgId(), msg.getBody());
+
+ return map;
+ }
+ }
+
+ /**
+ * Adds data to RocketMQ.
+ *
+ * @throws Exception If fails.
+ */
+ private void produceData() throws Exception {
+ initTopic(TOPIC_NAME, TEST_IP + ":" + NAME_SERVER_PORT);
+
+ DefaultMQProducer producer = new DefaultMQProducer("testProducerGrp");
+
+ producer.setNamesrvAddr(TEST_IP + ":" + NAME_SERVER_PORT);
+
+ try {
+ producer.start();
+
+ for (int i = 0; i < EVT_NUM; i++)
+ producer.send(new Message(TOPIC_NAME, "", String.valueOf(i).getBytes("UTF-8")));
+ }
+ catch (Exception e) {
+ throw new Exception(e);
+ }
+ finally {
+ producer.shutdown();
+ }
+ }
+
+ /**
+ * Initializes RocketMQ topic.
+ *
+ * @param topic Topic.
+ * @param nsAddr Nameserver address.
+ * @throws IgniteInterruptedCheckedException If fails.
+ */
+ private void initTopic(String topic, String nsAddr) throws Exception {
+ DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt();
+ defaultMQAdminExt.setNamesrvAddr(nsAddr);
+ try {
+ defaultMQAdminExt.start();
+
+ TopicConfig topicConfig = new TopicConfig();
+ topicConfig.setTopicName(topic);
+ topicConfig.setReadQueueNums(4);
+ topicConfig.setWriteQueueNums(4);
+
+ defaultMQAdminExt.createAndUpdateTopicConfig(testRocketMQServer.getBrokerAddr(), topicConfig);
+
+ U.sleep(100);
+ }
+ finally {
+ defaultMQAdminExt.shutdown();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java
new file mode 100644
index 0000000..e761f1b
--- /dev/null
+++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/RocketMQStreamerTestSuite.java
@@ -0,0 +1,37 @@
+/*
+ * 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.stream.rocketmq;
+
+import junit.framework.TestSuite;
+
+/**
+ * Apache RocketMQ streamers tests.
+ */
+public class RocketMQStreamerTestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Apache Kafka streamer Test Suite");
+
+ suite.addTest(new TestSuite(RocketMQStreamerTest.class));
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/TestRocketMQServer.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/TestRocketMQServer.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/TestRocketMQServer.java
new file mode 100644
index 0000000..beece8e
--- /dev/null
+++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/TestRocketMQServer.java
@@ -0,0 +1,148 @@
+/*
+ * 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.stream.rocketmq;
+
+import java.util.UUID;
+import org.apache.ignite.IgniteLogger;
+import org.apache.rocketmq.broker.BrokerController;
+import org.apache.rocketmq.common.BrokerConfig;
+import org.apache.rocketmq.common.namesrv.NamesrvConfig;
+import org.apache.rocketmq.namesrv.NamesrvController;
+import org.apache.rocketmq.remoting.netty.NettyClientConfig;
+import org.apache.rocketmq.remoting.netty.NettyServerConfig;
+import org.apache.rocketmq.store.config.MessageStoreConfig;
+
+import static java.io.File.separator;
+
+/**
+ * Test RocketMQ server handling a broker and a nameserver.
+ */
+class TestRocketMQServer {
+ /** Nameserver port. */
+ protected static final int NAME_SERVER_PORT = 9000;
+
+ /** Broker port. */
+ private static final int BROKER_PORT = 8000;
+
+ /** Broker HA port. */
+ private static final int HA_PORT = 8001;
+
+ /** Test ip address. */
+ protected static final String TEST_IP = "127.0.0.1";
+
+ /** Test broker name. */
+ private static final String TEST_BROKER = "testBroker";
+
+ /** Test cluster name. */
+ private static final String TEST_CLUSTER = "testCluster";
+
+ /** Nameserver. */
+ private static NamesrvController nameSrv;
+
+ /** Broker. */
+ private static BrokerController broker;
+
+ /** Logger. */
+ private final IgniteLogger log;
+
+ /**
+ * Test server constructor.
+ *
+ * @param log Logger.
+ */
+ TestRocketMQServer(IgniteLogger log) {
+ this.log = log;
+
+ try {
+ startNameServer();
+ startBroker();
+ }
+ catch (Exception e) {
+ throw new RuntimeException("Failed to start RocketMQ: " + e);
+ }
+ }
+
+ /**
+ * Starts a test nameserver.
+ *
+ * @throws Exception If fails.
+ */
+ private void startNameServer() throws Exception {
+ NamesrvConfig namesrvConfig = new NamesrvConfig();
+ NettyServerConfig nameServerNettyServerConfig = new NettyServerConfig();
+
+ namesrvConfig.setKvConfigPath(System.getProperty("java.io.tmpdir") + separator + "namesrv" + separator + "kvConfig.json");
+ nameServerNettyServerConfig.setListenPort(NAME_SERVER_PORT);
+
+ nameSrv = new NamesrvController(namesrvConfig, nameServerNettyServerConfig);
+
+ nameSrv.initialize();
+ nameSrv.start();
+
+ log.info("Started nameserver at " + NAME_SERVER_PORT);
+ }
+
+ /**
+ * Starts a test broker.
+ *
+ * @throws Exception If fails.
+ */
+ private void startBroker() throws Exception {
+ BrokerConfig brokerCfg = new BrokerConfig();
+ NettyServerConfig nettySrvCfg = new NettyServerConfig();
+ MessageStoreConfig storeCfg = new MessageStoreConfig();
+
+ brokerCfg.setBrokerName(TEST_BROKER);
+ brokerCfg.setBrokerClusterName(TEST_CLUSTER);
+ brokerCfg.setBrokerIP1(TEST_IP);
+ brokerCfg.setNamesrvAddr(TEST_IP + ":" + NAME_SERVER_PORT);
+
+ storeCfg.setStorePathRootDir(System.getProperty("java.io.tmpdir") + separator + "store-" + UUID.randomUUID());
+ storeCfg.setStorePathCommitLog(System.getProperty("java.io.tmpdir") + separator + "commitlog");
+ storeCfg.setHaListenPort(HA_PORT);
+
+ nettySrvCfg.setListenPort(BROKER_PORT);
+
+ broker = new BrokerController(brokerCfg, nettySrvCfg, new NettyClientConfig(), storeCfg);
+
+ broker.initialize();
+ broker.start();
+
+ log.info("Started broker [" + TEST_BROKER + "] at " + BROKER_PORT);
+ }
+
+ /**
+ * Obtains the broker address.
+ *
+ * @return Broker address.
+ */
+ String getBrokerAddr() {
+ return broker.getBrokerAddr();
+ }
+
+ /**
+ * Shuts test server down.
+ */
+ void shutdown() {
+ if (broker != null)
+ broker.shutdown();
+
+ if (nameSrv != null)
+ nameSrv.shutdown();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/package-info.java
----------------------------------------------------------------------
diff --git a/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/package-info.java b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/package-info.java
new file mode 100644
index 0000000..eebf084
--- /dev/null
+++ b/modules/rocketmq/src/test/java/org/apache/ignite/stream/rocketmq/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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 implementation of RocketMQStreamer.
+ */
+package org.apache.ignite.stream.rocketmq;
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 3d0f413..a59d8c9 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -94,6 +94,7 @@
<osgi.core.version>5.0.0</osgi.core.version>
<osgi.enterprise.version>5.0.0</osgi.enterprise.version>
<paho.version>1.0.2</paho.version>
+ <rocketmq.version>4.0.0-incubating</rocketmq.version>
<scala210.jline.version>2.10.4</scala210.jline.version>
<scala210.library.version>2.10.4</scala210.library.version>
<scala211.library.version>2.11.7</scala211.library.version>
@@ -449,6 +450,10 @@
<title>SpringData integration</title>
<packages>org.apache.ignite.springdata.repository*</packages>
</group>
+ <group>
+ <title>RocketMQ integration</title>
+ <packages>org.apache.ignite.rocketmq*</packages>
+ </group>
</groups>
<header>
<![CDATA[
http://git-wip-us.apache.org/repos/asf/ignite/blob/335f2431/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8a05342..9c6a0d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,6 +92,7 @@
<module>modules/kubernetes</module>
<module>modules/zeromq</module>
<module>modules/hibernate-core</module>
+ <module>modules/rocketmq</module>
</modules>
<profiles>
[40/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
new file mode 100644
index 0000000..6e546b0
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -0,0 +1,543 @@
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.Marshaller;
+import org.apache.ignite.marshaller.jdk.JdkMarshaller;
+import org.apache.ignite.resources.CacheStoreSessionResource;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.transactions.Transaction;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.SharedSessionContract;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.resource.transaction.spi.TransactionStatus;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * {@link CacheStore} implementation backed by Hibernate. This implementation
+ * stores objects in underlying database in {@code BLOB} format.
+ * <h2 class="header">Configuration</h2>
+ * Either {@link #setSessionFactory(SessionFactory)} or
+ * {@link #setHibernateConfigurationPath(String)} or
+ * {@link #setHibernateProperties(Properties)} should be set.
+ * <p>
+ * If session factory is provided it should contain
+ * {@link CacheHibernateBlobStoreEntry} persistent class (via provided
+ * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
+ * adding {@link CacheHibernateBlobStoreEntry} to annotated classes
+ * of session factory.
+ * <p>
+ * Path to hibernate configuration may be either an URL or a file path or
+ * a classpath resource. This configuration file should include provided
+ * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
+ * class {@link CacheHibernateBlobStoreEntry}.
+ * <p>
+ * If hibernate properties are provided, mapping
+ * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
+ * <p>
+ * Use {@link CacheHibernateBlobStoreFactory} factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
+ */
+public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
+ /**
+ * Default connection URL
+ * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
+ */
+ public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
+ "DEFAULT_LOCK_TIMEOUT=5000";
+
+ /** Default show SQL property value (value is <tt>true</tt>). */
+ public static final String DFLT_SHOW_SQL = "true";
+
+ /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
+ public static final String DFLT_HBM2DDL_AUTO = "update";
+
+ /** Session attribute name. */
+ private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
+
+ /** Name of Hibarname mapping resource. */
+ private static final String MAPPING_RESOURCE =
+ "org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml";
+
+ /** Marshaller. */
+ private static final Marshaller marsh = new JdkMarshaller();
+
+ /** Init guard. */
+ @GridToStringExclude
+ private final AtomicBoolean initGuard = new AtomicBoolean();
+
+ /** Init latch. */
+ @GridToStringExclude
+ private final CountDownLatch initLatch = new CountDownLatch(1);
+
+ /** Hibernate properties. */
+ @GridToStringExclude
+ private Properties hibernateProps;
+
+ /** Session factory. */
+ @GridToStringExclude
+ private SessionFactory sesFactory;
+
+ /** Path to hibernate configuration file. */
+ private String hibernateCfgPath;
+
+ /** Log. */
+ @LoggerResource
+ private IgniteLogger log;
+
+ /** Auto-injected store session. */
+ @CacheStoreSessionResource
+ private CacheStoreSession ses;
+
+ /** Ignite instance. */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
+ @Override public V load(K key) {
+ init();
+
+ Transaction tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store load [key=" + key + ", tx=" + tx + ']');
+
+ Session ses = session(tx);
+
+ try {
+ CacheHibernateBlobStoreEntry entry = (CacheHibernateBlobStoreEntry)
+ ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+ if (entry == null)
+ return null;
+
+ return fromBytes(entry.getValue());
+ }
+ catch (IgniteCheckedException | HibernateException e) {
+ rollback(ses, tx);
+
+ throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
+ }
+ finally {
+ end(ses, tx);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
+ init();
+
+ Transaction tx = transaction();
+
+ K key = entry.getKey();
+ V val = entry.getValue();
+
+ if (log.isDebugEnabled())
+ log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
+
+ if (val == null) {
+ delete(key);
+
+ return;
+ }
+
+ Session ses = session(tx);
+
+ try {
+ CacheHibernateBlobStoreEntry entry0 = new CacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
+
+ ses.saveOrUpdate(entry0);
+ }
+ catch (IgniteCheckedException | 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", "JpaQlInspection"})
+ @Override public void delete(Object key) {
+ init();
+
+ Transaction tx = transaction();
+
+ if (log.isDebugEnabled())
+ log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
+
+ Session ses = session(tx);
+
+ try {
+ Object obj = ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+ if (obj != null)
+ ses.delete(obj);
+ }
+ catch (IgniteCheckedException | HibernateException e) {
+ rollback(ses, tx);
+
+ throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
+ }
+ finally {
+ end(ses, tx);
+ }
+ }
+
+ /**
+ * Rolls back hibernate session.
+ *
+ * @param ses Hibernate session.
+ * @param tx Cache ongoing transaction.
+ */
+ private void rollback(SharedSessionContract 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.getStatus().canRollback())
+ hTx.rollback();
+ }
+ }
+
+ /**
+ * Ends hibernate session.
+ *
+ * @param ses Hibernate session.
+ * @param tx Cache ongoing transaction.
+ */
+ private void end(Session ses, 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.getStatus() == TransactionStatus.ACTIVE)
+ hTx.commit();
+
+ ses.close();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sessionEnd(boolean commit) {
+ init();
+
+ Transaction tx = transaction();
+
+ Map<String, Session> props = session().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();
+
+ if (log.isDebugEnabled())
+ log.debug("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.
+ */
+ Session session(@Nullable Transaction tx) {
+ Session ses;
+
+ if (tx != null) {
+ Map<String, Session> props = session().properties();
+
+ ses = props.get(ATTR_SES);
+
+ if (ses == null) {
+ ses = sesFactory.openSession();
+
+ ses.beginTransaction();
+
+ // Store session in transaction metadata, so it can be accessed
+ // for other operations on the same transaction.
+ props.put(ATTR_SES, ses);
+
+ if (log.isDebugEnabled())
+ log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
+ }
+ }
+ else {
+ ses = sesFactory.openSession();
+
+ ses.beginTransaction();
+ }
+
+ return ses;
+ }
+
+ /**
+ * Sets session factory.
+ *
+ * @param sesFactory Session factory.
+ */
+ public void setSessionFactory(SessionFactory sesFactory) {
+ this.sesFactory = sesFactory;
+ }
+
+ /**
+ * Sets hibernate configuration path.
+ * <p>
+ * This may be either URL or file path or classpath resource.
+ *
+ * @param hibernateCfgPath URL or file path or classpath resource
+ * pointing to hibernate configuration XML file.
+ */
+ public void setHibernateConfigurationPath(String hibernateCfgPath) {
+ this.hibernateCfgPath = hibernateCfgPath;
+ }
+
+ /**
+ * Sets Hibernate properties.
+ *
+ * @param hibernateProps Hibernate properties.
+ */
+ public void setHibernateProperties(Properties hibernateProps) {
+ this.hibernateProps = hibernateProps;
+ }
+
+ /**
+ * Initializes store.
+ *
+ * @throws IgniteException If failed to initialize.
+ */
+ private void init() throws IgniteException {
+ if (initGuard.compareAndSet(false, true)) {
+ if (log.isDebugEnabled())
+ log.debug("Initializing cache store.");
+
+ try {
+ if (sesFactory != null)
+ // Session factory has been provided - nothing to do.
+ return;
+
+ if (!F.isEmpty(hibernateCfgPath)) {
+ try {
+ URL url = new URL(hibernateCfgPath);
+
+ sesFactory = new Configuration().configure(url).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using URL: " + url);
+
+ // Session factory has been successfully initialized.
+ return;
+ }
+ catch (MalformedURLException e) {
+ if (log.isDebugEnabled())
+ log.debug("Caught malformed URL exception: " + e.getMessage());
+ }
+
+ // Provided path is not a valid URL. File?
+ File cfgFile = new File(hibernateCfgPath);
+
+ if (cfgFile.exists()) {
+ sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using file: " + hibernateCfgPath);
+
+ // Session factory has been successfully initialized.
+ return;
+ }
+
+ // Provided path is not a file. Classpath resource?
+ sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
+ }
+ else {
+ if (hibernateProps == null) {
+ U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
+
+ hibernateProps = new Properties();
+
+ hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
+ hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
+ hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
+ }
+
+ Configuration cfg = new Configuration();
+
+ cfg.setProperties(hibernateProps);
+
+ assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
+
+ cfg.addResource(MAPPING_RESOURCE);
+
+ sesFactory = cfg.buildSessionFactory();
+
+ if (log.isDebugEnabled())
+ log.debug("Configured session factory using properties: " + hibernateProps);
+ }
+ }
+ catch (HibernateException e) {
+ throw new IgniteException("Failed to initialize store.", e);
+ }
+ finally {
+ initLatch.countDown();
+ }
+ }
+ else if (initLatch.getCount() > 0) {
+ try {
+ U.await(initLatch);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new IgniteException(e);
+ }
+ }
+
+ if (sesFactory == null)
+ throw new IgniteException("Cache store was not properly initialized.");
+ }
+
+ /**
+ * Checks availability of a classpath resource.
+ *
+ * @param name Resource name.
+ * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
+ */
+ private boolean resourceAvailable(String name) {
+ InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+
+ if (cfgStream == null) {
+ log.error("Classpath resource not found: " + name);
+
+ return false;
+ }
+
+ try {
+ // Read a single byte to force actual content access by JVM.
+ cfgStream.read();
+
+ return true;
+ }
+ catch (IOException e) {
+ log.error("Failed to read classpath resource: " + name, e);
+
+ return false;
+ }
+ finally {
+ U.close(cfgStream, log);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheHibernateBlobStore.class, this);
+ }
+
+ /**
+ * Serialize object to byte array using marshaller.
+ *
+ * @param obj Object to convert to byte array.
+ * @return Byte array.
+ * @throws IgniteCheckedException If failed to convert.
+ */
+ protected byte[] toBytes(Object obj) throws IgniteCheckedException {
+ return U.marshal(marsh, obj);
+ }
+
+ /**
+ * Deserialize object from byte array using marshaller.
+ *
+ * @param bytes Bytes to deserialize.
+ * @param <X> Result object type.
+ * @return Deserialized object.
+ * @throws IgniteCheckedException If failed.
+ */
+ protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
+ if (bytes == null || bytes.length == 0)
+ return null;
+
+ return U.unmarshal(marsh, bytes, getClass().getClassLoader());
+ }
+
+ /**
+ * @return Current transaction.
+ */
+ @Nullable private Transaction transaction() {
+ CacheStoreSession ses = session();
+
+ return ses != null ? ses.transaction() : null;
+ }
+
+ /**
+ * @return Store session.
+ */
+ private CacheStoreSession session() {
+ return ses;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
new file mode 100644
index 0000000..5b0be43
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.apache.ignite.examples.datagrid.store" default-access="field">
+ <class name="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry" table="ENTRIES">
+ <id name="key"/>
+
+ <property name="val"/>
+ </class>
+</hibernate-mapping>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
new file mode 100644
index 0000000..d40c5ef
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
@@ -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.
+ */
+
+package org.apache.ignite.cache.store.hibernate;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Entry that is used by {@link CacheHibernateBlobStore} implementation.
+ * <p>
+ * Note that this is a reference implementation for tests only.
+ * When running on production systems use concrete key-value types to
+ * get better performance.
+ */
+@Entity
+@Table(name = "ENTRIES")
+public class CacheHibernateBlobStoreEntry {
+ /** Key (use concrete key type in production). */
+ @Id
+ @Column(length = 65535)
+ private byte[] key;
+
+ /** Value (use concrete value type in production). */
+ @Column(length = 65535)
+ private byte[] val;
+
+ /**
+ * Constructor.
+ */
+ CacheHibernateBlobStoreEntry() {
+ // No-op.
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param key Key.
+ * @param val Value.
+ */
+ CacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
+ this.key = key;
+ this.val = val;
+ }
+
+ /**
+ * @return Key.
+ */
+ public byte[] getKey() {
+ return key;
+ }
+
+ /**
+ * @param key Key.
+ */
+ public void setKey(byte[] key) {
+ this.key = key;
+ }
+
+ /**
+ * @return Value.
+ */
+ public byte[] getValue() {
+ return val;
+ }
+
+ /**
+ * @param val Value.
+ */
+ public void setValue(byte[] val) {
+ this.val = val;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
new file mode 100644
index 0000000..ea4df8a
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreFactory.java
@@ -0,0 +1,235 @@
+/*
+ * 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 java.util.Properties;
+import javax.cache.configuration.Factory;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteComponentType;
+import org.apache.ignite.internal.util.spring.IgniteSpringHelper;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.resources.SpringApplicationContextResource;
+import org.hibernate.SessionFactory;
+
+/**
+ * {@link Factory} implementation for {@link CacheHibernateBlobStore}.
+ *
+ * Use this factory to pass {@link CacheHibernateBlobStore} to {@link CacheConfiguration}.
+ *
+ * <h2 class="header">Java Example</h2>
+ * In this example existing session factory is provided.
+ * <pre name="code" class="java">
+ * ...
+ * CacheHibernateBlobStoreFactory<String, String> factory = new CacheHibernateBlobStoreFactory<String, String>();
+ *
+ * factory.setSessionFactory(sesFactory);
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM)</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="sessionFactory">
+ * <bean class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ * <property name="hibernateProperties">
+ * <value>
+ * connection.url=jdbc:h2:mem:
+ * show_sql=true
+ * hbm2ddl.auto=true
+ * hibernate.dialect=org.hibernate.dialect.H2Dialect
+ * </value>
+ * </property>
+ * <property name="mappingResources">
+ * <list>
+ * <value>
+ * org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
+ * </value>
+ * </list>
+ * </property>
+ * </bean>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory1"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="sessionFactory">
+ * <bean class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
+ * <property name="hibernateProperties">
+ * <value>
+ * connection.url=jdbc:h2:mem:
+ * show_sql=true
+ * hbm2ddl.auto=true
+ * hibernate.dialect=org.hibernate.dialect.H2Dialect
+ * </value>
+ * </property>
+ * <property name="annotatedClasses">
+ * <list>
+ * <value>
+ * org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry
+ * </value>
+ * </list>
+ * </property>
+ * </bean>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example</h2>
+ * <pre name="code" class="xml">
+ * ...
+ * <bean id="cache.hibernate.store.factory2"
+ * class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ * <property name="hibernateProperties">
+ * <props>
+ * <prop key="connection.url">jdbc:h2:mem:</prop>
+ * <prop key="hbm2ddl.auto">update</prop>
+ * <prop key="show_sql">true</prop>
+ * </props>
+ * </property>
+ * </bean>
+ * ...
+ * </pre>
+ * <p>
+ * <img src="http://ignite.apache.org/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ */
+public class CacheHibernateBlobStoreFactory<K, V> implements Factory<CacheHibernateBlobStore<K, V>> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Session factory. */
+ @GridToStringExclude
+ private transient SessionFactory sesFactory;
+
+ /** Session factory bean name. */
+ private String sesFactoryBean;
+
+ /** Path to hibernate configuration file. */
+ private String hibernateCfgPath;
+
+ /** Hibernate properties. */
+ @GridToStringExclude
+ private Properties hibernateProps;
+
+ /** Application context. */
+ @SpringApplicationContextResource
+ private Object appContext;
+
+ /** {@inheritDoc} */
+ @Override public CacheHibernateBlobStore<K, V> create() {
+ CacheHibernateBlobStore<K, V> store = new CacheHibernateBlobStore<>();
+
+ store.setHibernateConfigurationPath(hibernateCfgPath);
+ store.setHibernateProperties(hibernateProps);
+
+ if (sesFactory != null)
+ store.setSessionFactory(sesFactory);
+ else if (sesFactoryBean != null) {
+ if (appContext == null)
+ throw new IgniteException("Spring application context resource is not injected.");
+
+ IgniteSpringHelper spring;
+
+ try {
+ spring = IgniteComponentType.SPRING.create(false);
+
+ SessionFactory sesFac = spring.loadBeanFromAppContext(appContext, sesFactoryBean);
+
+ store.setSessionFactory(sesFac);
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteException("Failed to load bean in application context [beanName=" + sesFactoryBean +
+ ", igniteConfig=" + appContext + ']');
+ }
+ }
+
+ return store;
+ }
+
+ /**
+ * Sets session factory.
+ *
+ * @param sesFactory Session factory.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setSessionFactory(SessionFactory sesFactory) {
+ this.sesFactory = sesFactory;
+
+ return this;
+ }
+
+ /**
+ * Sets name of the data source bean.
+ *
+ * @param sesFactory Session factory bean name.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setSessionFactory(SessionFactory)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setSessionFactoryBean(String sesFactory) {
+ this.sesFactoryBean = sesFactory;
+
+ return this;
+ }
+
+ /**
+ * Sets hibernate configuration path.
+ * <p>
+ * This may be either URL or file path or classpath resource.
+ *
+ * @param hibernateCfgPath URL or file path or classpath resource
+ * pointing to hibernate configuration XML file.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setHibernateConfigurationPath(String)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setHibernateConfigurationPath(String hibernateCfgPath) {
+ this.hibernateCfgPath = hibernateCfgPath;
+
+ return this;
+ }
+
+ /**
+ * Sets Hibernate properties.
+ *
+ * @param hibernateProps Hibernate properties.
+ * @return {@code This} for chaining.
+ * @see CacheHibernateBlobStore#setHibernateProperties(Properties)
+ */
+ public CacheHibernateBlobStoreFactory<K, V> setHibernateProperties(Properties hibernateProps) {
+ this.hibernateProps = hibernateProps;
+
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(CacheHibernateBlobStoreFactory.class, this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
new file mode 100644
index 0000000..8db9568
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListener.java
@@ -0,0 +1,224 @@
+/*
+ * 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 java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.LoggerResource;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.resource.transaction.spi.TransactionStatus;
+
+/**
+ * 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<Integer, Integer> {
+ * @CacheStoreSessionResource
+ * private CacheStoreSession ses;
+ *
+ * @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> 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.attach(null);
+
+ if (hibSes != null) {
+ try {
+ Transaction tx = hibSes.getTransaction();
+
+ if (commit) {
+ if (hibSes.isDirty())
+ hibSes.flush();
+
+ if (tx.getStatus() == TransactionStatus.ACTIVE)
+ tx.commit();
+ }
+ else if (tx.getStatus().canRollback())
+ tx.rollback();
+ }
+ catch (HibernateException e) {
+ throw new CacheWriterException("Failed to end store session [tx=" + ses.transaction() + ']', e);
+ }
+ finally {
+ hibSes.close();
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
new file mode 100644
index 0000000..891d99a
--- /dev/null
+++ b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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 description. -->
+ * Contains reference Hibernate-based cache store implementation.
+ */
+package org.apache.ignite.cache.store.hibernate;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/config/factory-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/config/factory-cache.xml b/modules/hibernate-5.1/src/test/config/factory-cache.xml
new file mode 100644
index 0000000..a251846
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/config/factory-cache.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="simpleSessionFactory"
+ class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactoryExt"/>
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/config/factory-cache1.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/config/factory-cache1.xml b/modules/hibernate-5.1/src/test/config/factory-cache1.xml
new file mode 100644
index 0000000..7a53b1f
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/config/factory-cache1.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="simpleSessionFactory1"
+ class="org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest$DummySessionFactory"/>
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="igniteInstanceName" value="ignite1"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml b/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
new file mode 100644
index 0000000..459930c
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="test"/>
+ <property name="atomicityMode" value="ATOMIC"/>
+ <property name="backups" value="1"/>
+ <property name="cacheStoreFactory">
+ <bean class="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreFactory">
+ <property name="sessionFactoryBean" value = "simpleSessionFactory1"/>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+
+ <!-- Explicitly configure TCP discovery SPI to provide list of initial nodes. -->
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500..47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
new file mode 100644
index 0000000..0363c41
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
@@ -0,0 +1,407 @@
+/*
+ * 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.hibernate;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import javax.cache.Cache;
+import javax.persistence.Cacheable;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Configuration;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
+import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
+import static org.hibernate.cfg.AvailableSettings.GENERATE_STATISTICS;
+import static org.hibernate.cfg.AvailableSettings.HBM2DDL_AUTO;
+import static org.hibernate.cfg.AvailableSettings.RELEASE_CONNECTIONS;
+import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
+import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
+
+/**
+ * Tests Hibernate L2 cache configuration.
+ */
+public class HibernateL2CacheConfigurationSelfTest extends GridCommonAbstractTest {
+ /** */
+ public static final String ENTITY1_NAME = Entity1.class.getName();
+
+ /** */
+ public static final String ENTITY2_NAME = Entity2.class.getName();
+
+ /** */
+ public static final String ENTITY3_NAME = Entity3.class.getName();
+
+ /** */
+ public static final String ENTITY4_NAME = Entity4.class.getName();
+
+ /** */
+ public static final String TIMESTAMP_CACHE = "org.hibernate.cache.spi.UpdateTimestampsCache";
+
+ /** */
+ public static final String QUERY_CACHE = "org.hibernate.cache.internal.StandardQueryCache";
+
+ /** */
+ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+ /** If {@code true} then sets default cache in configuration. */
+ private boolean dfltCache;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
+ cache.clear();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ cfg.setCacheConfiguration(cacheConfiguration(ENTITY3_NAME), cacheConfiguration(ENTITY4_NAME),
+ cacheConfiguration("cache1"), cacheConfiguration("cache2"), cacheConfiguration("cache3"),
+ cacheConfiguration(TIMESTAMP_CACHE), cacheConfiguration(QUERY_CACHE));
+
+ return cfg;
+ }
+
+ /**
+ * @param cacheName Cache name.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration cacheConfiguration(String cacheName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(cacheName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(ATOMIC);
+
+ return cfg;
+ }
+ /**
+ * @param igniteInstanceName Ignite instance name.
+ * @return Hibernate configuration.
+ */
+ protected Configuration hibernateConfiguration(String igniteInstanceName) {
+ Configuration cfg = new Configuration();
+
+ cfg.addAnnotatedClass(Entity1.class);
+ cfg.addAnnotatedClass(Entity2.class);
+ cfg.addAnnotatedClass(Entity3.class);
+ cfg.addAnnotatedClass(Entity4.class);
+
+ cfg.setProperty(HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY, AccessType.NONSTRICT_READ_WRITE.name());
+
+ cfg.setProperty(HBM2DDL_AUTO, "create");
+
+ cfg.setProperty(GENERATE_STATISTICS, "true");
+
+ cfg.setProperty(USE_SECOND_LEVEL_CACHE, "true");
+
+ cfg.setProperty(USE_QUERY_CACHE, "true");
+
+ cfg.setProperty(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
+
+ cfg.setProperty(RELEASE_CONNECTIONS, "on_close");
+
+ cfg.setProperty(HibernateAccessStrategyFactory.IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
+
+ cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY1_NAME, "cache1");
+ cfg.setProperty(REGION_CACHE_PROPERTY + ENTITY2_NAME, "cache2");
+ cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE, TIMESTAMP_CACHE);
+ cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
+
+ if (dfltCache)
+ cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
+
+ return cfg;
+ }
+
+ /**
+ * Tests property {@link HibernateAccessStrategyFactory#REGION_CACHE_PROPERTY}.
+ */
+ public void testPerRegionCacheProperty() {
+ testCacheUsage(1, 1, 0, 1, 1);
+ }
+
+ /**
+ * Tests property {@link HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}.
+ */
+ public void testDefaultCache() {
+ dfltCache = true;
+
+ testCacheUsage(1, 1, 2, 0, 0);
+ }
+
+ /**
+ * @param expCache1 Expected size of cache with name 'cache1'.
+ * @param expCache2 Expected size of cache with name 'cache2'.
+ * @param expCache3 Expected size of cache with name 'cache3'.
+ * @param expCacheE3 Expected size of cache with name {@link #ENTITY3_NAME}.
+ * @param expCacheE4 Expected size of cache with name {@link #ENTITY4_NAME}.
+ */
+ @SuppressWarnings("unchecked")
+ private void testCacheUsage(int expCache1, int expCache2, int expCache3, int expCacheE3, int expCacheE4) {
+ SessionFactory sesFactory = startHibernate(getTestIgniteInstanceName(0));
+
+ try {
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity1());
+ ses.save(new Entity2());
+ ses.save(new Entity3());
+ ses.save(new Entity4());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory.openSession();
+
+ try {
+ List<Entity1> list1 = ses.createCriteria(ENTITY1_NAME).list();
+
+ assertEquals(1, list1.size());
+
+ for (Entity1 e : list1) {
+ ses.load(ENTITY1_NAME, e.getId());
+ assertNotNull(e.getId());
+ }
+
+ List<Entity2> list2 = ses.createCriteria(ENTITY2_NAME).list();
+
+ assertEquals(1, list2.size());
+
+ for (Entity2 e : list2)
+ assertNotNull(e.getId());
+
+ List<Entity3> list3 = ses.createCriteria(ENTITY3_NAME).list();
+
+ assertEquals(1, list3.size());
+
+ for (Entity3 e : list3)
+ assertNotNull(e.getId());
+
+ List<Entity4> list4 = ses.createCriteria(ENTITY4_NAME).list();
+
+ assertEquals(1, list4.size());
+
+ for (Entity4 e : list4)
+ assertNotNull(e.getId());
+ }
+ finally {
+ ses.close();
+ }
+
+ IgniteCache<Object, Object> cache1 = grid(0).cache("cache1");
+ IgniteCache<Object, Object> cache2 = grid(0).cache("cache2");
+ IgniteCache<Object, Object> cache3 = grid(0).cache("cache3");
+ IgniteCache<Object, Object> cacheE3 = grid(0).cache(ENTITY3_NAME);
+ IgniteCache<Object, Object> cacheE4 = grid(0).cache(ENTITY4_NAME);
+
+ assertEquals("Unexpected entries: " + toSet(cache1.iterator()), expCache1, cache1.size());
+ assertEquals("Unexpected entries: " + toSet(cache2.iterator()), expCache2, cache2.size());
+ assertEquals("Unexpected entries: " + toSet(cache3.iterator()), expCache3, cache3.size());
+ assertEquals("Unexpected entries: " + toSet(cacheE3.iterator()), expCacheE3, cacheE3.size());
+ assertEquals("Unexpected entries: " + toSet(cacheE4.iterator()), expCacheE4, cacheE4.size());
+ }
+ finally {
+ sesFactory.close();
+ }
+ }
+
+ /**
+ *
+ */
+ private <K, V> Set<Cache.Entry<K, V>> toSet(Iterator<Cache.Entry<K, V>> iter){
+ Set<Cache.Entry<K, V>> set = new HashSet<>();
+
+ while (iter.hasNext())
+ set.add(iter.next());
+
+ return set;
+ }
+
+ /**
+ * @param igniteInstanceName Name of the grid providing caches.
+ * @return Session factory.
+ */
+ private SessionFactory startHibernate(String igniteInstanceName) {
+ Configuration cfg = hibernateConfiguration(igniteInstanceName);
+
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+ builder.applySetting("hibernate.show_sql", false);
+ builder.applySettings(cfg.getProperties());
+
+ return cfg.buildSessionFactory(builder.build());
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity1 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity2.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity2 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity3.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity3 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity4.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity4 {
+ /** */
+ private int id;
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
new file mode 100644
index 0000000..57a3f71
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
@@ -0,0 +1,429 @@
+/*
+ * 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.hibernate;
+
+import java.util.Map;
+import javax.persistence.Cacheable;
+import javax.persistence.Id;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.CONNECTION_URL;
+import static org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.hibernateProperties;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+
+/**
+ *
+ */
+public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest {
+ /** */
+ private static final String CACHE_NAME = "hibernateCache";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ if (!getTestIgniteInstanceName(0).equals(igniteInstanceName))
+ cfg.setClientMode(true);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName(CACHE_NAME);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected boolean isMultiJvm() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+
+ startGrid(1);
+ startGrid(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testL2Cache() throws Exception {
+ Ignite srv = ignite(0);
+
+ {
+ IgniteCompute client1Compute =
+ srv.compute(srv.cluster().forNodeId(ignite(1).cluster().localNode().id()));
+
+ client1Compute.run(new HibernateInsertRunnable());
+ }
+
+ {
+ IgniteCompute client2Compute =
+ srv.compute(srv.cluster().forNodeId(ignite(2).cluster().localNode().id()));
+
+ client2Compute.run(new HibernateLoadRunnable());
+ }
+
+ {
+ IgniteCompute srvCompute = srv.compute(srv.cluster().forLocal());
+
+ srvCompute.run(new HibernateLoadRunnable());
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HibernateInsertRunnable extends HibernateBaseRunnable {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ SessionFactory sesFactory = startHibernate(ignite.name());
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 1; i++) {
+ {
+ Entity1 e = new Entity1();
+ e.setId(i);
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+
+ {
+ Entity2 e = new Entity2();
+ e.setId(String.valueOf(i));
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+
+ {
+ Entity3 e = new Entity3();
+ e.setId(i);
+ e.setName("name-" + i);
+
+ ses.save(e);
+ }
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private static class HibernateLoadRunnable extends HibernateBaseRunnable {
+ /** {@inheritDoc} */
+ @Override public void run() {
+ SessionFactory sesFactory = startHibernate(ignite.name());
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 1; i++) {
+ {
+ Entity1 e = (Entity1)ses.load(Entity1.class, i);
+
+ log.info("Found: " + e.getName());
+ }
+ {
+ Entity2 e = (Entity2)ses.load(Entity2.class, String.valueOf(i));
+
+ log.info("Found: " + e.getName());
+ }
+ {
+ Entity3 e = (Entity3)ses.load(Entity3.class, (double)i);
+
+ log.info("Found: " + e.getName());
+ }
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private abstract static class HibernateBaseRunnable implements IgniteRunnable {
+ /** */
+ @IgniteInstanceResource
+ protected Ignite ignite;
+
+ /** */
+ @LoggerResource
+ IgniteLogger log;
+
+ /**
+ * @param nodeName Name of the grid providing caches.
+ * @return Session factory.
+ */
+ SessionFactory startHibernate(String nodeName) {
+ log.info("Start hibernate on node: " + nodeName);
+
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
+
+ for (Map.Entry<String, String> e : hibernateProperties(nodeName, NONSTRICT_READ_WRITE.name()).entrySet())
+ builder.applySetting(e.getKey(), e.getValue());
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+ builder.applySetting(DFLT_CACHE_NAME_PROPERTY, CACHE_NAME);
+
+ MetadataSources metadataSources = new MetadataSources(builder.build());
+
+ metadataSources.addAnnotatedClass(Entity1.class);
+ metadataSources.addAnnotatedClass(Entity2.class);
+ metadataSources.addAnnotatedClass(Entity3.class);
+
+ return metadataSources.buildMetadata().buildSessionFactory();
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity1 {
+ /** */
+ @Id
+ private int id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity1 entity1 = (Entity1)o;
+
+ return id == entity1.id;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id;
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity2 {
+ /** */
+ @Id
+ private String id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity2 entity2 = (Entity2)o;
+
+ return id.equals(entity2.id);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return id.hashCode();
+ }
+ }
+
+ /**
+ * Test Hibernate entity1.
+ */
+ @javax.persistence.Entity
+ @Cacheable
+ @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ public static class Entity3 {
+ /** */
+ @Id
+ private double id;
+
+ /** */
+ private String name;
+
+ /**
+ * @return ID.
+ */
+ public double getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(double id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Entity3 entity3 = (Entity3)o;
+
+ return Double.compare(entity3.id, id) == 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ long temp = Double.doubleToLongBits(id);
+ return (int)(temp ^ (temp >>> 32));
+ }
+ }
+}
[39/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
new file mode 100644
index 0000000..f227af1
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheSelfTest.java
@@ -0,0 +1,1960 @@
+/*
+ * 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.hibernate;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.ObjectNotFoundException;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.StaleStateException;
+import org.hibernate.Transaction;
+import org.hibernate.annotations.NaturalId;
+import org.hibernate.annotations.NaturalIdCache;
+import org.hibernate.boot.Metadata;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cache.spi.GeneralDataRegion;
+import org.hibernate.cache.spi.TransactionalDataRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Environment;
+import org.hibernate.exception.ConstraintViolationException;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.stat.NaturalIdCacheStatistics;
+import org.hibernate.stat.SecondLevelCacheStatistics;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.IGNITE_INSTANCE_NAME_PROPERTY;
+import static org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+import static org.hibernate.cfg.Environment.CACHE_REGION_FACTORY;
+import static org.hibernate.cfg.Environment.GENERATE_STATISTICS;
+import static org.hibernate.cfg.Environment.HBM2DDL_AUTO;
+import static org.hibernate.cfg.Environment.RELEASE_CONNECTIONS;
+import static org.hibernate.cfg.Environment.USE_QUERY_CACHE;
+import static org.hibernate.cfg.Environment.USE_SECOND_LEVEL_CACHE;
+
+/**
+ *
+ * Tests Hibernate L2 cache.
+ */
+public class HibernateL2CacheSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ public static final String CONNECTION_URL = "jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
+
+ /** */
+ public static final String ENTITY_NAME = Entity.class.getName();
+
+ /** */
+ public static final String ENTITY2_NAME = Entity2.class.getName();
+
+ /** */
+ public static final String VERSIONED_ENTITY_NAME = VersionedEntity.class.getName();
+
+ /** */
+ public static final String CHILD_ENTITY_NAME = ChildEntity.class.getName();
+
+ /** */
+ public static final String PARENT_ENTITY_NAME = ParentEntity.class.getName();
+
+ /** */
+ public static final String CHILD_COLLECTION_REGION = ENTITY_NAME + ".children";
+
+ /** */
+ public static final String NATURAL_ID_REGION =
+ "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity##NaturalId";
+
+ /** */
+ public static final String NATURAL_ID_REGION2 =
+ "org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest$Entity2##NaturalId";
+
+ /** */
+ private SessionFactory sesFactory1;
+
+ /** */
+ private SessionFactory sesFactory2;
+
+ /**
+ * First Hibernate test entity.
+ */
+ @javax.persistence.Entity
+ @NaturalIdCache
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class Entity {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /** */
+ private Collection<ChildEntity> children;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public Entity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ public Entity(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ @NaturalId(mutable = true)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return Children.
+ */
+ @OneToMany(cascade=javax.persistence.CascadeType.ALL, fetch=FetchType.LAZY)
+ @JoinColumn(name="ENTITY_ID")
+ public Collection<ChildEntity> getChildren() {
+ return children;
+ }
+
+ /**
+ * @param children Children.
+ */
+ public void setChildren(Collection<ChildEntity> children) {
+ this.children = children;
+ }
+ }
+
+ /**
+ * Second Hibernate test entity.
+ */
+ @javax.persistence.Entity
+ @NaturalIdCache
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class Entity2 {
+ /** */
+ private int id;
+
+ /** */
+ private String name;
+
+ /** */
+ private Collection<ChildEntity> children;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public Entity2() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param name Name.
+ */
+ public Entity2(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Name.
+ */
+ @NaturalId(mutable = true)
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name Name.
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ /**
+ * Hibernate child entity referenced by {@link Entity}.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings("PublicInnerClass")
+ public static class ChildEntity {
+ /** */
+ private int id;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public ChildEntity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ */
+ public ChildEntity(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ @GeneratedValue
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ /**
+ * Hibernate entity referencing {@link Entity}.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings("PublicInnerClass")
+ public static class ParentEntity {
+ /** */
+ private int id;
+
+ /** */
+ private Entity entity;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public ParentEntity() {
+ // No-op.
+ }
+
+ /**
+ * @param id ID.
+ * @param entity Referenced entity.
+ */
+ public ParentEntity(int id, Entity entity) {
+ this.id = id;
+ this.entity = entity;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Referenced entity.
+ */
+ @OneToOne
+ public Entity getEntity() {
+ return entity;
+ }
+
+ /**
+ * @param entity Referenced entity.
+ */
+ public void setEntity(Entity entity) {
+ this.entity = entity;
+ }
+ }
+
+ /**
+ * Hibernate entity.
+ */
+ @javax.persistence.Entity
+ @SuppressWarnings({"PublicInnerClass", "UnnecessaryFullyQualifiedName"})
+ public static class VersionedEntity {
+ /** */
+ private int id;
+
+ /** */
+ private long ver;
+
+ /**
+ * Default constructor required by Hibernate.
+ */
+ public VersionedEntity() {
+ }
+
+ /**
+ * @param id ID.
+ */
+ public VersionedEntity(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return ID.
+ */
+ @Id
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id ID.
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return Version.
+ */
+ @javax.persistence.Version
+ public long getVersion() {
+ return ver;
+ }
+
+ /**
+ * @param ver Version.
+ */
+ public void setVersion(long ver) {
+ this.ver = ver;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ cfg.setCacheConfiguration(generalRegionConfiguration("org.hibernate.cache.spi.UpdateTimestampsCache"),
+ generalRegionConfiguration("org.hibernate.cache.internal.StandardQueryCache"),
+ transactionalRegionConfiguration(ENTITY_NAME),
+ transactionalRegionConfiguration(ENTITY2_NAME),
+ transactionalRegionConfiguration(VERSIONED_ENTITY_NAME),
+ transactionalRegionConfiguration(PARENT_ENTITY_NAME),
+ transactionalRegionConfiguration(CHILD_ENTITY_NAME),
+ transactionalRegionConfiguration(CHILD_COLLECTION_REGION),
+ transactionalRegionConfiguration(NATURAL_ID_REGION),
+ transactionalRegionConfiguration(NATURAL_ID_REGION2));
+
+ return cfg;
+ }
+
+ /**
+ * @param regionName Region name.
+ * @return Cache configuration for {@link GeneralDataRegion}.
+ */
+ private CacheConfiguration generalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(regionName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(ATOMIC);
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setBackups(1);
+
+ cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+ return cfg;
+ }
+
+ /**
+ * @param regionName Region name.
+ * @return Cache configuration for {@link TransactionalDataRegion}.
+ */
+ protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setName(regionName);
+
+ cfg.setCacheMode(PARTITIONED);
+
+ cfg.setAtomicityMode(TRANSACTIONAL);
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setBackups(1);
+
+ cfg.setAffinity(new RendezvousAffinityFunction(false, 10));
+
+ return cfg;
+ }
+
+ /**
+ * @return Hibernate registry builder.
+ */
+ protected StandardServiceRegistryBuilder registryBuilder() {
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
+
+ builder.applySetting("hibernate.connection.url", CONNECTION_URL);
+
+ return builder;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(2);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ cleanup();
+ }
+
+ /**
+ * @return Hibernate L2 cache access types to test.
+ */
+ protected AccessType[] accessTypes() {
+ return new AccessType[]{AccessType.READ_ONLY, AccessType.NONSTRICT_READ_WRITE, AccessType.READ_WRITE};
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollectionCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testCollectionCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("unchecked")
+ private void testCollectionCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, Integer> idToChildCnt = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ Entity e = new Entity(i, "name-" + i);
+
+ Collection<ChildEntity> children = new ArrayList<>();
+
+ for (int j = 0; j < 3; j++)
+ children.add(new ChildEntity());
+
+ e.setChildren(children);
+
+ idToChildCnt.put(e.getId(), e.getChildren().size());
+
+ ses.save(e);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Load children, this should populate cache.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ List<Entity> list = ses.createCriteria(ENTITY_NAME).list();
+
+ assertEquals(idToChildCnt.size(), list.size());
+
+ for (Entity e : list)
+ assertEquals((int)idToChildCnt.get(e.getId()), e.getChildren().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 3, 0);
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ // Update children for one entity.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.getChildren().remove(e1.getChildren().iterator().next());
+
+ ses.update(e1);
+
+ idToChildCnt.put(e1.getId(), e1.getChildren().size());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
+
+ // Update children for the same entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.getChildren().remove(e1.getChildren().iterator().next());
+
+ ses.update(e1);
+
+ idToChildCnt.put(e1.getId(), e1.getChildren().size());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertCollectionCache(sesFactory2, idToChildCnt, 2, 1); // After update collection cache entry is removed.
+ assertCollectionCache(sesFactory1, idToChildCnt, 3, 0); // 'assertCollectionCache' loads children in cache.
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEntityCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testEntityCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testEntityCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, String> idToName = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 2; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ idToName.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates and inserts in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed1");
+
+ ses.update(e0);
+
+ idToName.put(0, e0.getName());
+
+ ses.save(new Entity(2, "name-2"));
+
+ idToName.put(2, "name-2");
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-1-changed1");
+
+ ses.update(e1);
+
+ idToName.put(1, e1.getName());
+
+ ses.save(new Entity(3, "name-3"));
+
+ idToName.put(3, "name-3");
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates, inserts and deletes in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity(4, "name-4"));
+
+ idToName.put(4, "name-4");
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed2");
+
+ ses.update(e0);
+
+ idToName.put(e0.getId(), e0.getName());
+
+ ses.delete(ses.load(Entity.class, 1));
+
+ idToName.remove(1);
+
+ Entity e2 = (Entity)ses.load(Entity.class, 2);
+
+ e2.setName("name-2-changed1");
+
+ ses.update(e2);
+
+ idToName.put(e2.getId(), e2.getName());
+
+ ses.delete(ses.load(Entity.class, 3));
+
+ idToName.remove(3);
+
+ ses.save(new Entity(5, "name-5"));
+
+ idToName.put(5, "name-5");
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 1, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 1, 3);
+
+ // Try to update the same entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+
+ e0.setName("name-0-changed3");
+
+ ses.update(e0);
+
+ idToName.put(e0.getId(), e0.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTwoEntitiesSameCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testTwoEntitiesSameCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testTwoEntitiesSameCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ Map<Integer, String> idToName1 = new HashMap<>();
+ Map<Integer, String> idToName2 = new HashMap<>();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 2; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+ ses.save(new Entity2(i, name));
+
+ idToName1.put(i, name);
+ idToName2.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Updates both entities in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 0);
+
+ e.setName("name-0-changed1");
+
+ ses.update(e);
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 0);
+
+ e2.setName("name-e2-0-changed1");
+
+ ses.update(e2);
+
+ idToName1.put(0, e.getName());
+ idToName2.put(0, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Remove entity1 and insert entity2 in single transaction.
+
+ Transaction tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 0);
+
+ ses.delete(e);
+
+ Entity2 e2 = new Entity2(2, "name-2");
+
+ ses.save(e2);
+
+ idToName1.remove(0);
+ idToName2.put(2, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ // Update, remove, insert in single transaction, transaction fails.
+
+ Entity e = (Entity)ses.load(Entity.class, 1);
+
+ e.setName("name-1-changed1");
+
+ ses.update(e); // Valid update.
+
+ ses.save(new Entity(2, "name-2")); // Valid insert.
+
+ ses.delete(ses.load(Entity2.class, 0)); // Valid delete.
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
+
+ e2.setName("name-2"); // Invalid update, not-unique name.
+
+ ses.update(e2);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 2, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 2, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 100);
+
+ ses = sesFactory2.openSession();
+
+ try {
+ // Update, remove, insert in single transaction.
+
+ tx = ses.beginTransaction();
+
+ Entity e = (Entity)ses.load(Entity.class, 1);
+
+ e.setName("name-1-changed1");
+
+ ses.update(e);
+
+ idToName1.put(1, e.getName());
+
+ ses.save(new Entity(2, "name-2"));
+
+ idToName1.put(2, "name-2");
+
+ ses.delete(ses.load(Entity2.class, 0));
+
+ idToName2.remove(0);
+
+ Entity2 e2 = (Entity2)ses.load(Entity2.class, 1);
+
+ e2.setName("name-e2-2-changed");
+
+ ses.update(e2);
+
+ idToName2.put(1, e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName1, 0, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName1, 0, 100);
+
+ assertEntityCache(ENTITY2_NAME, sesFactory2, idToName2, 0, 100);
+ assertEntityCache(ENTITY2_NAME, sesFactory1, idToName2, 0, 100);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testVersionedEntity() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testVersionedEntity(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testVersionedEntity(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ VersionedEntity e0 = new VersionedEntity(0);
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(e0);
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ long ver;
+
+ try {
+ ver = ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion();
+ }
+ finally {
+ ses.close();
+ }
+
+ SecondLevelCacheStatistics stats1 =
+ sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+ SecondLevelCacheStatistics stats2 =
+ sesFactory2.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+
+ assertEquals(1, stats1.getElementCountInMemory());
+ assertEquals(1, stats2.getElementCountInMemory());
+
+ ses = sesFactory2.openSession();
+
+ try {
+ assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(1, stats2.getElementCountInMemory());
+ assertEquals(1, stats2.getHitCount());
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ e0.setVersion(ver - 1);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ ses.update(e0);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (StaleStateException e) {
+ log.info("Expected exception: " + e);
+ }
+ finally {
+ tx.rollback();
+
+ ses.close();
+ }
+
+ sesFactory1.getStatistics().clear();
+
+ stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(VERSIONED_ENTITY_NAME);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ assertEquals(ver, ((VersionedEntity)ses.load(VersionedEntity.class, 0)).getVersion());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(1, stats1.getElementCountInMemory());
+ assertEquals(1, stats1.getHitCount());
+ assertEquals(1, stats2.getElementCountInMemory());
+ assertEquals(1, stats2.getHitCount());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNaturalIdCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testNaturalIdCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testNaturalIdCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<String, Integer> nameToId = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ nameToId.put(name, i);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ try {
+ for (Map.Entry<String, Integer> e : nameToId.entrySet())
+ ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-100");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-100");
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ // Update naturalId.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ nameToId.remove(e1.getName());
+
+ e1.setName("name-1-changed1");
+
+ nameToId.put(e1.getName(), e1.getId());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-1");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-1");
+
+ // Update entity using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ nameToId.remove(e1.getName());
+
+ e1.setName("name-1-changed2");
+
+ nameToId.put(e1.getName(), e1.getId());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-1-changed1");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-1-changed1");
+
+ // Try invalid NaturalId update.
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-0"); // Invalid update (duplicated name).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId);
+ assertNaturalIdCache(sesFactory1, nameToId);
+
+ // Delete entity.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ tx = ses.beginTransaction();
+
+ Entity e2 = (Entity)ses.load(Entity.class, 2);
+
+ ses.delete(e2);
+
+ nameToId.remove(e2.getName());
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertNaturalIdCache(sesFactory2, nameToId, "name-2");
+ assertNaturalIdCache(sesFactory1, nameToId, "name-2");
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEntityCacheTransactionFails() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testEntityCacheTransactionFails(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testEntityCacheTransactionFails(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ Map<Integer, String> idToName = new HashMap<>();
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 3; i++) {
+ String name = "name-" + i;
+
+ ses.save(new Entity(i, name));
+
+ idToName.put(i, name);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 100);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 100);
+
+ ses = sesFactory1.openSession();
+
+ Transaction tx = ses.beginTransaction();
+
+ try {
+ ses.save(new Entity(3, "name-3")); // Valid insert.
+
+ ses.save(new Entity(0, "name-0")); // Invalid insert (duplicated ID).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
+
+ if (accessType == AccessType.READ_ONLY)
+ return;
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ Entity e0 = (Entity)ses.load(Entity.class, 0);
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e0.setName("name-10"); // Valid update.
+ e1.setName("name-2"); // Invalid update (violates unique constraint).
+
+ ses.update(e0);
+ ses.update(e1);
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+
+ ses = sesFactory1.openSession();
+
+ try {
+ // Create parent entity referencing Entity with ID = 0.
+
+ tx = ses.beginTransaction();
+
+ ses.save(new ParentEntity(0, (Entity) ses.load(Entity.class, 0)));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ ses.save(new Entity(3, "name-3")); // Valid insert.
+
+ Entity e1 = (Entity)ses.load(Entity.class, 1);
+
+ e1.setName("name-10"); // Valid update.
+
+ ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName, 3);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName, 3);
+
+ ses = sesFactory1.openSession();
+
+ tx = ses.beginTransaction();
+
+ try {
+ ses.delete(ses.load(Entity.class, 1)); // Valid delete.
+
+ idToName.remove(1);
+
+ ses.delete(ses.load(Entity.class, 0)); // Invalid delete (there is a parent entity referencing it).
+
+ tx.commit();
+
+ fail("Commit must fail.");
+ }
+ catch (ConstraintViolationException e) {
+ log.info("Expected exception: " + e);
+
+ tx.rollback();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEntityCache(ENTITY_NAME, sesFactory2, idToName);
+ assertEntityCache(ENTITY_NAME, sesFactory1, idToName);
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testQueryCache() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testQueryCache(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testQueryCache(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < 5; i++)
+ ses.save(new Entity(i, "name-" + i));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Run some queries.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(2, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+
+ // Run queries using another SessionFactory.
+
+ ses = sesFactory2.openSession();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(2, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+
+ Query qry3 = ses.createQuery("from " + ENTITY_NAME + " where id > 1");
+
+ qry3.setCacheable(true);
+
+ assertEquals(3, qry3.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(2, sesFactory2.getStatistics().getQueryCacheHitCount());
+ assertEquals(1, sesFactory2.getStatistics().getQueryCacheMissCount());
+ assertEquals(1, sesFactory2.getStatistics().getQueryCachePutCount());
+
+ // Update entity, it should invalidate query cache.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.save(new Entity(5, "name-5"));
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ // Run queries.
+
+ ses = sesFactory1.openSession();
+
+ sesFactory1.getStatistics().clear();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(3, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+
+ // Clear query cache using another SessionFactory.
+
+ sesFactory2.getCache().evictDefaultQueryRegion();
+
+ ses = sesFactory1.openSession();
+
+ // Run queries again.
+
+ sesFactory1.getStatistics().clear();
+
+ try {
+ Query qry1 = ses.createQuery("from " + ENTITY_NAME + " where id > 2");
+
+ qry1.setCacheable(true);
+
+ assertEquals(3, qry1.list().size());
+
+ Query qry2 = ses.createQuery("from " + ENTITY_NAME + " where name = 'name-0'");
+
+ qry2.setCacheable(true);
+
+ assertEquals(1, qry2.list().size());
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, sesFactory1.getStatistics().getQueryCacheHitCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCacheMissCount());
+ assertEquals(2, sesFactory1.getStatistics().getQueryCachePutCount());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testRegionClear() throws Exception {
+ for (AccessType accessType : accessTypes())
+ testRegionClear(accessType);
+ }
+
+ /**
+ * @param accessType Cache access type.
+ * @throws Exception If failed.
+ */
+ private void testRegionClear(AccessType accessType) throws Exception {
+ createSessionFactories(accessType);
+
+ try {
+ final int ENTITY_CNT = 100;
+
+ Session ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ for (int i = 0; i < ENTITY_CNT; i++) {
+ Entity e = new Entity(i, "name-" + i);
+
+ Collection<ChildEntity> children = new ArrayList<>();
+
+ for (int j = 0; j < 3; j++)
+ children.add(new ChildEntity());
+
+ e.setChildren(children);
+
+ ses.save(e);
+ }
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ loadEntities(sesFactory2, ENTITY_CNT);
+
+ SecondLevelCacheStatistics stats1 = sesFactory1.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
+ SecondLevelCacheStatistics stats2 = sesFactory2.getStatistics().getSecondLevelCacheStatistics(ENTITY_NAME);
+
+ NaturalIdCacheStatistics idStats1 =
+ sesFactory1.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+ NaturalIdCacheStatistics idStats2 =
+ sesFactory2.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+
+ SecondLevelCacheStatistics colStats1 =
+ sesFactory1.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+ SecondLevelCacheStatistics colStats2 =
+ sesFactory2.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+
+ assertEquals(ENTITY_CNT, stats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, stats2.getElementCountInMemory());
+
+ assertEquals(ENTITY_CNT, idStats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, idStats2.getElementCountInMemory());
+
+ assertEquals(ENTITY_CNT, colStats1.getElementCountInMemory());
+ assertEquals(ENTITY_CNT, colStats2.getElementCountInMemory());
+
+ // Test cache is cleared after update query.
+
+ ses = sesFactory1.openSession();
+
+ try {
+ Transaction tx = ses.beginTransaction();
+
+ ses.createQuery("delete from " + ENTITY_NAME + " where name='no such name'").executeUpdate();
+
+ ses.createQuery("delete from " + ChildEntity.class.getName() + " where id=-1").executeUpdate();
+
+ tx.commit();
+ }
+ finally {
+ ses.close();
+ }
+
+ assertEquals(0, stats1.getElementCountInMemory());
+ assertEquals(0, stats2.getElementCountInMemory());
+
+ assertEquals(0, idStats1.getElementCountInMemory());
+ assertEquals(0, idStats2.getElementCountInMemory());
+
+ assertEquals(0, colStats1.getElementCountInMemory());
+ assertEquals(0, colStats2.getElementCountInMemory());
+
+ // Load some data in cache.
+
+ loadEntities(sesFactory1, 10);
+
+ assertEquals(10, stats1.getElementCountInMemory());
+ assertEquals(10, stats2.getElementCountInMemory());
+ assertEquals(10, idStats1.getElementCountInMemory());
+ assertEquals(10, idStats2.getElementCountInMemory());
+
+ // Test evictAll method.
+
+ sesFactory2.getCache().evictEntityRegion(ENTITY_NAME);
+
+ assertEquals(0, stats1.getElementCountInMemory());
+ assertEquals(0, stats2.getElementCountInMemory());
+
+ sesFactory2.getCache().evictNaturalIdRegion(ENTITY_NAME);
+
+ assertEquals(0, idStats1.getElementCountInMemory());
+ assertEquals(0, idStats2.getElementCountInMemory());
+
+ sesFactory2.getCache().evictCollectionRegion(CHILD_COLLECTION_REGION);
+
+ assertEquals(0, colStats1.getElementCountInMemory());
+ assertEquals(0, colStats2.getElementCountInMemory());
+ }
+ finally {
+ cleanup();
+ }
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param nameToId Name-ID mapping.
+ * @param absentNames Absent entities' names.
+ */
+ private void assertNaturalIdCache(SessionFactory sesFactory, Map<String, Integer> nameToId, String... absentNames) {
+ sesFactory.getStatistics().clear();
+
+ NaturalIdCacheStatistics stats =
+ sesFactory.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION);
+
+ long hitBefore = stats.getHitCount();
+
+ long missBefore = stats.getMissCount();
+
+ final Session ses = sesFactory.openSession();
+
+ try {
+ for (Map.Entry<String, Integer> e : nameToId.entrySet())
+ assertEquals((int)e.getValue(), ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId());
+
+ for (String name : absentNames)
+ assertNull((ses.bySimpleNaturalId(Entity.class).load(name)));
+
+ assertEquals(nameToId.size() + hitBefore, stats.getHitCount());
+
+ assertEquals(absentNames.length + missBefore, stats.getMissCount());
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param idToChildCnt Number of children per entity.
+ * @param expHit Expected cache hits.
+ * @param expMiss Expected cache misses.
+ */
+ @SuppressWarnings("unchecked")
+ private void assertCollectionCache(SessionFactory sesFactory, Map<Integer, Integer> idToChildCnt, int expHit,
+ int expMiss) {
+ sesFactory.getStatistics().clear();
+
+ Session ses = sesFactory.openSession();
+
+ try {
+ for(Map.Entry<Integer, Integer> e : idToChildCnt.entrySet()) {
+ Entity entity = (Entity)ses.load(Entity.class, e.getKey());
+
+ assertEquals((int)e.getValue(), entity.getChildren().size());
+ }
+ }
+ finally {
+ ses.close();
+ }
+
+ SecondLevelCacheStatistics stats =
+ sesFactory.getStatistics().getSecondLevelCacheStatistics(CHILD_COLLECTION_REGION);
+
+ assertEquals(expHit, stats.getHitCount());
+
+ assertEquals(expMiss, stats.getMissCount());
+ }
+
+ /**
+ * @param sesFactory Session factory.
+ * @param cnt Number of entities to load.
+ */
+ private void loadEntities(SessionFactory sesFactory, int cnt) {
+ Session ses = sesFactory.openSession();
+
+ try {
+ for (int i = 0; i < cnt; i++) {
+ Entity e = (Entity)ses.load(Entity.class, i);
+
+ assertEquals("name-" + i, e.getName());
+
+ assertFalse(e.getChildren().isEmpty());
+
+ ses.bySimpleNaturalId(Entity.class).load(e.getName());
+ }
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * @param entityName Entity name.
+ * @param sesFactory Session factory.
+ * @param idToName ID to name mapping.
+ * @param absentIds Absent entities' IDs.
+ */
+ private void assertEntityCache(String entityName, SessionFactory sesFactory, Map<Integer, String> idToName,
+ Integer... absentIds) {
+ assert entityName.equals(ENTITY_NAME) || entityName.equals(ENTITY2_NAME) : entityName;
+
+ sesFactory.getStatistics().clear();
+
+ final Session ses = sesFactory.openSession();
+
+ final boolean entity1 = entityName.equals(ENTITY_NAME);
+
+ try {
+ if (entity1) {
+ for (Map.Entry<Integer, String> e : idToName.entrySet())
+ assertEquals(e.getValue(), ((Entity)ses.load(Entity.class, e.getKey())).getName());
+ }
+ else {
+ for (Map.Entry<Integer, String> e : idToName.entrySet())
+ assertEquals(e.getValue(), ((Entity2)ses.load(Entity2.class, e.getKey())).getName());
+ }
+
+ for (final int id : absentIds) {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ if (entity1)
+ ((Entity)ses.load(Entity.class, id)).getName();
+ else
+ ((Entity2)ses.load(Entity2.class, id)).getName();
+
+ return null;
+ }
+ }, ObjectNotFoundException.class, null);
+ }
+
+ SecondLevelCacheStatistics stats = sesFactory.getStatistics().getSecondLevelCacheStatistics(entityName);
+
+ assertEquals(idToName.size(), stats.getHitCount());
+
+ assertEquals(absentIds.length, stats.getMissCount());
+ }
+ finally {
+ ses.close();
+ }
+ }
+
+ /**
+ * Creates session factories.
+ *
+ * @param accessType Cache access type.
+ */
+ private void createSessionFactories(AccessType accessType) {
+ sesFactory1 = startHibernate(accessType, getTestIgniteInstanceName(0));
+
+ sesFactory2 = startHibernate(accessType, getTestIgniteInstanceName(1));
+ }
+
+ /**
+ * Starts Hibernate.
+ *
+ * @param accessType Cache access type.
+ * @param igniteInstanceName Ignite instance name.
+ * @return Session factory.
+ */
+ private SessionFactory startHibernate(org.hibernate.cache.spi.access.AccessType accessType, String igniteInstanceName) {
+ StandardServiceRegistryBuilder builder = registryBuilder();
+
+ for (Map.Entry<String, String> e : hibernateProperties(igniteInstanceName, accessType.name()).entrySet())
+ builder.applySetting(e.getKey(), e.getValue());
+
+ // Use the same cache for Entity and Entity2.
+ builder.applySetting(REGION_CACHE_PROPERTY + ENTITY2_NAME, ENTITY_NAME);
+
+ StandardServiceRegistry srvcRegistry = builder.build();
+
+ MetadataSources metadataSources = new MetadataSources(srvcRegistry);
+
+ for (Class entityClass : getAnnotatedClasses())
+ metadataSources.addAnnotatedClass(entityClass);
+
+ Metadata metadata = metadataSources.buildMetadata();
+
+ for (PersistentClass entityBinding : metadata.getEntityBindings()) {
+ if (!entityBinding.isInherited())
+ ((RootClass)entityBinding).setCacheConcurrencyStrategy(accessType.getExternalName());
+ }
+
+ for (org.hibernate.mapping.Collection collectionBinding : metadata.getCollectionBindings())
+ collectionBinding.setCacheConcurrencyStrategy( accessType.getExternalName() );
+
+ return metadata.buildSessionFactory();
+ }
+
+ /**
+ * @return Entities classes.
+ */
+ private Class[] getAnnotatedClasses() {
+ return new Class[]{Entity.class, Entity2.class, VersionedEntity.class, ChildEntity.class, ParentEntity.class};
+ }
+
+ /**
+ * Closes session factories and clears data from caches.
+ *
+ * @throws Exception If failed.
+ */
+ private void cleanup() throws Exception {
+ if (sesFactory1 != null)
+ sesFactory1.close();
+
+ sesFactory1 = null;
+
+ if (sesFactory2 != null)
+ sesFactory2.close();
+
+ sesFactory2 = null;
+
+ for (IgniteCacheProxy<?, ?> cache : ((IgniteKernal)grid(0)).caches())
+ cache.clear();
+ }
+
+ /**
+ * @param igniteInstanceName Node name.
+ * @param dfltAccessType Default cache access type.
+ * @return Properties map.
+ */
+ static Map<String, String> hibernateProperties(String igniteInstanceName, String dfltAccessType) {
+ Map<String, String> map = new HashMap<>();
+
+ map.put(HBM2DDL_AUTO, "create");
+ map.put(GENERATE_STATISTICS, "true");
+ map.put(USE_SECOND_LEVEL_CACHE, "true");
+ map.put(USE_QUERY_CACHE, "true");
+ map.put(CACHE_REGION_FACTORY, HibernateRegionFactory.class.getName());
+ map.put(RELEASE_CONNECTIONS, "on_close");
+ map.put(IGNITE_INSTANCE_NAME_PROPERTY, igniteInstanceName);
+ map.put(DFLT_ACCESS_TYPE_PROPERTY, dfltAccessType);
+
+ return map;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
new file mode 100644
index 0000000..5175292
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.hibernate;
+
+import java.util.Collections;
+import javax.cache.configuration.Factory;
+import javax.transaction.Synchronization;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import org.apache.commons.dbcp.managed.BasicManagedDataSource;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.h2.jdbcx.JdbcDataSource;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cfg.Environment;
+import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
+import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
+import org.hibernate.engine.transaction.jta.platform.internal.AbstractJtaPlatform;
+import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
+import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
+import org.jetbrains.annotations.Nullable;
+import org.objectweb.jotm.Jotm;
+
+/**
+ *
+ * Tests Hibernate L2 cache with TRANSACTIONAL access mode (Hibernate and Cache are configured
+ * to used the same TransactionManager).
+ */
+public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfTest {
+ /** */
+ private static Jotm jotm;
+
+ /**
+ */
+ private static class TestJtaPlatform extends AbstractJtaPlatform {
+ /** {@inheritDoc} */
+ @Override protected TransactionManager locateTransactionManager() {
+ return jotm.getTransactionManager();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected UserTransaction locateUserTransaction() {
+ return jotm.getUserTransaction();
+ }
+ }
+
+ /**
+ */
+ @SuppressWarnings("PublicInnerClass")
+ public static class TestTmFactory implements Factory<TransactionManager> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public TransactionManager create() {
+ return jotm.getTransactionManager();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ jotm = new Jotm(true, false);
+
+ super.beforeTestsStarted();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ if (jotm != null)
+ jotm.stop();
+
+ jotm = null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ cfg.getTransactionConfiguration().setTxManagerFactory(new TestTmFactory());
+ cfg.getTransactionConfiguration().setUseJtaSynchronization(useJtaSynchronization());
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
+ CacheConfiguration cfg = super.transactionalRegionConfiguration(regionName);
+
+ cfg.setNearConfiguration(null);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override protected StandardServiceRegistryBuilder registryBuilder() {
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
+
+ DatasourceConnectionProviderImpl connProvider = new DatasourceConnectionProviderImpl();
+
+ BasicManagedDataSource dataSrc = new BasicManagedDataSource(); // JTA-aware data source.
+
+ dataSrc.setTransactionManager(jotm.getTransactionManager());
+
+ dataSrc.setDefaultAutoCommit(false);
+
+ JdbcDataSource h2DataSrc = new JdbcDataSource();
+
+ h2DataSrc.setURL(CONNECTION_URL);
+
+ dataSrc.setXaDataSourceInstance(h2DataSrc);
+
+ connProvider.setDataSource(dataSrc);
+
+ connProvider.configure(Collections.emptyMap());
+
+ builder.addService(ConnectionProvider.class, connProvider);
+
+ builder.addService(JtaPlatform.class, new TestJtaPlatform());
+
+ builder.applySetting(Environment.TRANSACTION_COORDINATOR_STRATEGY, JtaTransactionCoordinatorBuilderImpl.class.getName());
+
+ return builder;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected AccessType[] accessTypes() {
+ return new AccessType[]{AccessType.TRANSACTIONAL};
+ }
+
+ /**
+ * @return Whether to use {@link Synchronization}.
+ */
+ protected boolean useJtaSynchronization() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
new file mode 100644
index 0000000..44899f9
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalUseSyncSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.hibernate;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Tests Hibernate L2 cache with TRANSACTIONAL access mode and {@link Synchronization}
+ * instead of XA resource.
+ */
+public class HibernateL2CacheTransactionalUseSyncSelfTest extends HibernateL2CacheTransactionalSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean useJtaSynchronization() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
new file mode 100644
index 0000000..d5496af
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreNodeRestartTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.processors.cache.integration.IgniteCacheStoreNodeRestartAbstractTest;
+
+public class CacheHibernateBlobStoreNodeRestartTest extends IgniteCacheStoreNodeRestartAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected CacheStore getStore() {
+ return new CacheHibernateBlobStore();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.PARTITIONED;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicityMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected NearCacheConfiguration nearConfiguration() {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
new file mode 100644
index 0000000..c62db4a
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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 java.io.File;
+import java.net.URL;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.cache.GridAbstractCacheStoreSelfTest;
+import org.hibernate.FlushMode;
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.resource.transaction.spi.TransactionStatus;
+
+/**
+ * Cache store test.
+ */
+public class CacheHibernateBlobStoreSelfTest extends
+ GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> {
+ /**
+ * @throws Exception If failed.
+ */
+ public CacheHibernateBlobStoreSelfTest() throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ Session s = store.session(null);
+
+ if (s == null)
+ return;
+
+ try {
+ s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
+ .setFlushMode(FlushMode.ALWAYS).executeUpdate();
+
+ Transaction hTx = s.getTransaction();
+
+ if (hTx != null && hTx.getStatus() == TransactionStatus.ACTIVE)
+ hTx.commit();
+ }
+ finally {
+ s.close();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheHibernateBlobStore<Object, Object> store() {
+ return new CacheHibernateBlobStore<>();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByUrl() throws Exception {
+ URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH +
+ "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ assert url != null;
+
+ store.setHibernateConfigurationPath(url.toString());
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByFile() throws Exception {
+ URL url = U.resolveIgniteUrl(CacheHibernateStoreFactorySelfTest.MODULE_PATH +
+ "/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ assert url != null;
+
+ File file = new File(url.toURI());
+
+ store.setHibernateConfigurationPath(file.getAbsolutePath());
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testConfigurationByResource() throws Exception {
+ store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ // Store will be implicitly initialized.
+ store.load("key");
+ }
+
+ @Override public void testSimpleMultithreading() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1757");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
new file mode 100644
index 0000000..7d4f280
--- /dev/null
+++ b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
@@ -0,0 +1,256 @@
+/*
+ * 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 java.sql.Connection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.hibernate.Cache;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.SessionBuilder;
+import org.hibernate.SessionFactory;
+import org.hibernate.StatelessSession;
+import org.hibernate.StatelessSessionBuilder;
+import org.hibernate.TypeHelper;
+import org.hibernate.boot.spi.SessionFactoryOptions;
+import org.hibernate.engine.spi.FilterDefinition;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.metadata.CollectionMetadata;
+import org.hibernate.stat.Statistics;
+
+/**
+ * Test for Cache jdbc blob store factory.
+ */
+public class CacheHibernateStoreFactorySelfTest extends GridCommonAbstractTest {
+ /** Cache name. */
+ private static final String CACHE_NAME = "test";
+
+ /** */
+ static final String MODULE_PATH = "modules/hibernate-5.1/";
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheConfiguration() throws Exception {
+ try (Ignite ignite1 = startGrid(0)) {
+ IgniteCache<Integer, String> cache1 = ignite1.getOrCreateCache(cacheConfiguration());
+
+ checkStore(cache1);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testXmlConfiguration() throws Exception {
+ try (Ignite ignite = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache.xml")) {
+ try(Ignite ignite1 = Ignition.start(MODULE_PATH + "/src/test/config/factory-cache1.xml")) {
+ checkStore(ignite.<Integer, String>cache(CACHE_NAME), DummySessionFactoryExt.class);
+
+ checkStore(ignite1.<Integer, String>cache(CACHE_NAME), DummySessionFactory.class);
+ }
+ }
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncorrectBeanConfiguration() throws Exception {
+ GridTestUtils.assertThrows(log, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try(Ignite ignite =
+ Ignition.start(MODULE_PATH + "/src/test/config/factory-incorrect-store-cache.xml")) {
+ ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
+ getCacheStoreFactory().create();
+ }
+ return null;
+ }
+ }, IgniteException.class, "Failed to load bean in application context");
+ }
+
+ /**
+ * @return Cache configuration with store.
+ */
+ private CacheConfiguration<Integer, String> cacheConfiguration() {
+ CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>();
+
+ CacheHibernateBlobStoreFactory<Integer, String> factory = new CacheHibernateBlobStoreFactory();
+
+ factory.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+ cfg.setCacheStoreFactory(factory);
+
+ return cfg;
+ }
+
+ /**
+ * @param cache Ignite cache.
+ * @param dataSrcClass Data source class.
+ * @throws Exception If store parameters is not the same as in configuration xml.
+ */
+ private void checkStore(IgniteCache<Integer, String> cache, Class<?> dataSrcClass) throws Exception {
+ CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache
+ .getConfiguration(CacheConfiguration.class).getCacheStoreFactory().create();
+
+ assertEquals(dataSrcClass,
+ GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "sesFactory").getClass());
+ }
+
+ /**
+ * @param cache Ignite cache.
+ * @throws Exception If store parameters is not the same as in configuration xml.
+ */
+ private void checkStore(IgniteCache<Integer, String> cache) throws Exception {
+ CacheHibernateBlobStore store = (CacheHibernateBlobStore)cache.getConfiguration(CacheConfiguration.class)
+ .getCacheStoreFactory().create();
+
+ assertEquals("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml",
+ GridTestUtils.getFieldValue(store, CacheHibernateBlobStore.class, "hibernateCfgPath"));
+ }
+
+ /**
+ *
+ */
+ public static class DummySessionFactoryExt extends DummySessionFactory {
+ /** */
+ public DummySessionFactoryExt() {
+ // No-op.
+ }
+ }
+
+ /**
+ *
+ */
+ public static class DummySessionFactory implements SessionFactory {
+ /** {@inheritDoc} */
+ @Override public SessionFactoryOptions getSessionFactoryOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public SessionBuilder withOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Session openSession() throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Session getCurrentSession() throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSessionBuilder withStatelessOptions() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSession openStatelessSession() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public StatelessSession openStatelessSession(Connection conn) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassMetadata getClassMetadata(Class entityCls) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ClassMetadata getClassMetadata(String entityName) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionMetadata getCollectionMetadata(String roleName) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<String, ClassMetadata> getAllClassMetadata() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map getAllCollectionMetadata() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Statistics getStatistics() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void close() throws HibernateException {
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isClosed() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Cache getCache() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Set getDefinedFilterNames() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public FilterDefinition getFilterDefinition(String filterName) throws HibernateException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean containsFetchProfileDefinition(String name) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public TypeHelper getTypeHelper() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Reference getReference() throws NamingException {
+ return null;
+ }
+ }
+}
\ No newline at end of file