You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/12/16 06:59:53 UTC
[1/7] ignite git commit: fixed
https://issues.apache.org/jira/browse/IGNITE-2168
Repository: ignite
Updated Branches:
refs/heads/ignite-1537 730efdafb -> dea42fd32
fixed https://issues.apache.org/jira/browse/IGNITE-2168
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ed5f2798
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ed5f2798
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ed5f2798
Branch: refs/heads/ignite-1537
Commit: ed5f2798fe18896db0d3d7c169f04c72ff056eee
Parents: 301d522
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Dec 15 18:20:24 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Dec 15 18:20:24 2015 +0300
----------------------------------------------------------------------
.../datagrid/store/auto/CacheBinaryAutoStoreExample.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ed5f2798/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
index aa228f1..aa5eea1 100644
--- a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
@@ -18,10 +18,8 @@
package org.apache.ignite.examples.binary.datagrid.store.auto;
import java.sql.Types;
-import java.util.UUID;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore;
import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory;
@@ -30,8 +28,8 @@ import org.apache.ignite.cache.store.jdbc.JdbcTypeField;
import org.apache.ignite.cache.store.jdbc.dialect.H2Dialect;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.ExampleNodeStartup;
-import org.apache.ignite.examples.util.DbH2ServerStartup;
import org.apache.ignite.examples.model.Person;
+import org.apache.ignite.examples.util.DbH2ServerStartup;
import org.apache.ignite.transactions.Transaction;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
@@ -163,6 +161,9 @@ public class CacheBinaryAutoStoreExample {
System.out.println(">>> Loaded cache entries: " + cache.size());
}
+ finally {
+ ignite.destroyCache(CACHE_NAME);
+ }
}
}
}
[5/7] ignite git commit: ignite-2146 Call service node filter outside
of system cache transaction.
Posted by sb...@apache.org.
ignite-2146 Call service node filter outside of system cache transaction.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ab8ba974
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ab8ba974
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ab8ba974
Branch: refs/heads/ignite-1537
Commit: ab8ba9746f7f8f3be88eba73cc9abfb84cd86ecc
Parents: df08d3d
Author: sboikov <sb...@gridgain.com>
Authored: Wed Dec 16 08:39:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Dec 16 08:39:20 2015 +0300
----------------------------------------------------------------------
.../service/GridServiceProcessor.java | 30 +++-
.../ServicePredicateAccessCacheTest.java | 155 +++++++++++++++++++
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
3 files changed, 180 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ab8ba974/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index ed54f00..6b05edd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -704,13 +704,33 @@ public class GridServiceProcessor extends GridProcessorAdapter {
Object affKey = cfg.getAffinityKey();
while (true) {
+ GridServiceAssignments assigns = new GridServiceAssignments(cfg, dep.nodeId(), topVer);
+
+ Collection<ClusterNode> nodes;
+
+ // Call node filter outside of transaction.
+ if (affKey == null) {
+ nodes = ctx.discovery().nodes(topVer);
+
+ if (assigns.nodeFilter() != null) {
+ Collection<ClusterNode> nodes0 = new ArrayList<>();
+
+ for (ClusterNode node : nodes) {
+ if (assigns.nodeFilter().apply(node))
+ nodes0.add(node);
+ }
+
+ nodes = nodes0;
+ }
+ }
+ else
+ nodes = null;
+
try (IgniteInternalTx tx = cache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) {
GridServiceAssignmentsKey key = new GridServiceAssignmentsKey(cfg.getName());
GridServiceAssignments oldAssigns = (GridServiceAssignments)cache.get(key);
- GridServiceAssignments assigns = new GridServiceAssignments(cfg, dep.nodeId(), topVer);
-
Map<UUID, Integer> cnts = new HashMap<>();
if (affKey != null) {
@@ -723,10 +743,6 @@ public class GridServiceProcessor extends GridProcessorAdapter {
}
}
else {
- Collection<ClusterNode> nodes = assigns.nodeFilter() == null ?
- ctx.discovery().nodes(topVer) :
- F.view(ctx.discovery().nodes(topVer), assigns.nodeFilter());
-
if (!nodes.isEmpty()) {
int size = nodes.size();
@@ -805,7 +821,7 @@ public class GridServiceProcessor extends GridProcessorAdapter {
assigns.assigns(cnts);
- cache.getAndPut(key, assigns);
+ cache.put(key, assigns);
tx.commit();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ab8ba974/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java
new file mode 100644
index 0000000..c91d9f1
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/ServicePredicateAccessCacheTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.service;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+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.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class ServicePredicateAccessCacheTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static CountDownLatch latch;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ cfg.setPeerClassLoadingEnabled(false);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 60_000;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPredicateAccessCache() throws Exception {
+ final Ignite ignite0 = startGrid(0);
+
+ ignite0.getOrCreateCache(new CacheConfiguration<String, Object>()
+ .setName("testCache")
+ .setAtomicityMode(ATOMIC)
+ .setCacheMode(REPLICATED)
+ .setWriteSynchronizationMode(FULL_SYNC)
+ .setAtomicWriteOrderMode(PRIMARY));
+
+ latch = new CountDownLatch(1);
+
+ final ClusterGroup grp = ignite0.cluster().forPredicate(new IgnitePredicate<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ System.out.println("Predicated started [thread=" + Thread.currentThread().getName() + ']');
+
+ latch.countDown();
+
+ try {
+ Thread.sleep(3000);
+ }
+ catch (InterruptedException ignore) {
+ // No-op.
+ }
+
+ System.out.println("Call contains key [thread=" + Thread.currentThread().getName() + ']');
+
+ boolean ret = ignite0.cache("testCache").containsKey(node.id().toString());
+
+ System.out.println("After contains key [ret=" + ret +
+ ", thread=" + Thread.currentThread().getName() + ']');
+
+ return ret;
+ }
+ });
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ info("Start deploy service.");
+
+ ignite0.services(grp).deployNodeSingleton("testService", new TestService());
+
+ info("Service deployed.");
+
+ return null;
+ }
+ }, "deploy-thread");
+
+ latch.await();
+
+ startGrid(1);
+
+ fut.get();
+ }
+
+ /**
+ *
+ */
+ public static class TestService implements Service {
+ /** {@inheritDoc} */
+ public void execute(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ public void init(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ab8ba974/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index a41859e..deb49b7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -52,6 +52,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessorProxySe
import org.apache.ignite.internal.processors.service.GridServiceProcessorSingleNodeSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorStopSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceReassignmentSelfTest;
+import org.apache.ignite.internal.processors.service.ServicePredicateAccessCacheTest;
import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
import org.apache.ignite.internal.util.GridStartupWithUndefinedIgniteHomeSelfTest;
import org.apache.ignite.spi.communication.GridCacheMessageSelfTest;
@@ -117,6 +118,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
suite.addTestSuite(GridServiceReassignmentSelfTest.class);
suite.addTestSuite(GridServiceClientNodeTest.class);
suite.addTestSuite(GridServiceProcessorStopSelfTest.class);
+ suite.addTestSuite(ServicePredicateAccessCacheTest.class);
return suite;
}
[2/7] ignite git commit: IGNITE-2155 Fixed
ScalarSnowflakeSchemaExample.
Posted by sb...@apache.org.
IGNITE-2155 Fixed ScalarSnowflakeSchemaExample.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/894992d6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/894992d6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/894992d6
Branch: refs/heads/ignite-1537
Commit: 894992d6846f8290362e43816524902a57955ee2
Parents: ed5f279
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Dec 15 23:59:30 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Dec 15 23:59:30 2015 +0700
----------------------------------------------------------------------
.../examples/ScalarSnowflakeSchemaExample.scala | 31 ++++++++++++--------
.../scala/org/apache/ignite/scalar/scalar.scala | 11 ++++++-
2 files changed, 29 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/894992d6/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarSnowflakeSchemaExample.scala
----------------------------------------------------------------------
diff --git a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarSnowflakeSchemaExample.scala b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarSnowflakeSchemaExample.scala
index 33b2fcc..eb8a538 100644
--- a/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarSnowflakeSchemaExample.scala
+++ b/examples/src/main/scala/org/apache/ignite/scalar/examples/ScalarSnowflakeSchemaExample.scala
@@ -52,14 +52,14 @@ object ScalarSnowflakeSchemaExample {
/** Configuration file name. */
private val CONFIG = "examples/config/example-ignite.xml"
- /** Name of replicated cache specified in spring configuration. */
- private val REPL_NAME = "ScalarSnowflakeSchemaExampleReplicated"
-
/** Name of partitioned cache specified in spring configuration. */
- private val PART_NAME = "ScalarSnowflakeSchemaExamplePartitioned"
+ private val PARTITIONED_CACHE_NAME = "ScalarSnowflakeSchemaExamplePartitioned"
+
+ /** Name of replicated cache specified in spring configuration. */
+ private val REPLICATED_CACHE_NAME = "ScalarSnowflakeSchemaExampleReplicated"
/** ID generator. */
- private[this] val idGen = Stream.from(System.currentTimeMillis.toInt).iterator
+ private[this] val idGen = Stream.from(0).iterator
/** DimStore data. */
private[this] val dataStore = scala.collection.mutable.Map[JavaInt, DimStore]()
@@ -72,11 +72,18 @@ object ScalarSnowflakeSchemaExample {
*/
def main(args: Array[String]) {
scalar(CONFIG) {
- val dimCache = createCache$[JavaInt, AnyRef](REPL_NAME, CacheMode.REPLICATED, Seq(classOf[JavaInt], classOf[DimStore],
+ println
+ println(">>> Cache star schema example started.")
+
+ // Destroy caches to clean up the data if any left from previous runs.
+ destroyCache$(PARTITIONED_CACHE_NAME)
+ destroyCache$(REPLICATED_CACHE_NAME)
+
+ val dimCache = createCache$[JavaInt, AnyRef](REPLICATED_CACHE_NAME, CacheMode.REPLICATED, Seq(classOf[JavaInt], classOf[DimStore],
classOf[JavaInt], classOf[DimProduct]))
try {
- val factCache = createCache$[JavaInt, FactPurchase](PART_NAME, indexedTypes = Seq(classOf[JavaInt], classOf[FactPurchase]))
+ val factCache = createCache$[JavaInt, FactPurchase](PARTITIONED_CACHE_NAME, indexedTypes = Seq(classOf[JavaInt], classOf[FactPurchase]))
try {
populateDimensions(dimCache)
@@ -138,10 +145,10 @@ object ScalarSnowflakeSchemaExample {
* `FactPurchase` objects stored in `partitioned` cache.
*/
def queryStorePurchases() {
- val factCache = ignite$.cache[JavaInt, FactPurchase](PART_NAME)
+ val factCache = ignite$.cache[JavaInt, FactPurchase](PARTITIONED_CACHE_NAME)
val storePurchases = factCache.sql(
- "from \"" + REPL_NAME + "\".DimStore, \"" + PART_NAME + "\".FactPurchase " +
+ "from \"" + REPLICATED_CACHE_NAME + "\".DimStore, \"" + PARTITIONED_CACHE_NAME + "\".FactPurchase " +
"where DimStore.id=FactPurchase.storeId and DimStore.name=?", "Store1")
printQueryResults("All purchases made at store1:", storePurchases.getAll)
@@ -154,7 +161,7 @@ object ScalarSnowflakeSchemaExample {
* stored in `partitioned` cache.
*/
private def queryProductPurchases() {
- val factCache = ignite$.cache[JavaInt, FactPurchase](PART_NAME)
+ val factCache = ignite$.cache[JavaInt, FactPurchase](PARTITIONED_CACHE_NAME)
// All purchases for certain product made at store2.
// =================================================
@@ -165,8 +172,8 @@ object ScalarSnowflakeSchemaExample {
println("IDs of products [p1=" + p1.id + ", p2=" + p2.id + ", p3=" + p3.id + ']')
val prodPurchases = factCache.sql(
- "from \"" + REPL_NAME + "\".DimStore, \"" + REPL_NAME + "\".DimProduct, \"" +
- PART_NAME + "\".FactPurchase " +
+ "from \"" + REPLICATED_CACHE_NAME + "\".DimStore, \"" + REPLICATED_CACHE_NAME + "\".DimProduct, \"" +
+ PARTITIONED_CACHE_NAME + "\".FactPurchase " +
"where DimStore.id=FactPurchase.storeId and " +
"DimProduct.id=FactPurchase.productId and " +
"DimStore.name=? and DimProduct.id in(?, ?, ?)",
http://git-wip-us.apache.org/repos/asf/ignite/blob/894992d6/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala
----------------------------------------------------------------------
diff --git a/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala b/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala
index c5bc085..998ec28 100644
--- a/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala
+++ b/modules/scalar/src/main/scala/org/apache/ignite/scalar/scalar.scala
@@ -275,7 +275,7 @@ object scalar extends ScalarConversions {
Option(Ignition.ignite.cache(cacheName))
/**
- * Creates cache cache with specified parameters in default grid.
+ * Creates cache with specified parameters in default grid.
*
* @param cacheName Name of the cache to get.
*/
@@ -291,6 +291,15 @@ object scalar extends ScalarConversions {
}
/**
+ * Destroy cache with specified name.
+ *
+ * @param cacheName Name of the cache to destroy.
+ */
+ @inline def destroyCache$(@Nullable cacheName: String) = {
+ Ignition.ignite.destroyCache(cacheName)
+ }
+
+ /**
* Gets named cache from specified grid.
*
* @param gridName Name of the grid.
[3/7] ignite git commit: #Ignite-1.5 - Javadoc
Posted by sb...@apache.org.
#Ignite-1.5 - Javadoc
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/046f3b84
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/046f3b84
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/046f3b84
Branch: refs/heads/ignite-1537
Commit: 046f3b84fd78e36d6dc3130c3200f3e97074515c
Parents: 894992d
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Dec 15 20:16:00 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Dec 15 20:16:00 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/Ignite.java | 19 +++++++++++++++++++
.../main/java/org/apache/ignite/IgniteCache.java | 8 +++++++-
2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/046f3b84/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index 7196959..5703744 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -214,6 +214,9 @@ public interface Ignite extends AutoCloseable {
* <p>
* If local node is an affinity node, this method will return the instance of started cache.
* Otherwise, it will create a client cache on local node.
+ * <p>
+ * If a cache with the same name already exists in the grid, an exception will be thrown regardless
+ * whether the given configuration matches the configuration of the existing cache or not.
*
* @param cacheCfg Cache configuration to use.
* @return Instance of started cache.
@@ -225,6 +228,8 @@ public interface Ignite extends AutoCloseable {
* <p>
* If local node is an affinity node, this method will return the instance of started cache.
* Otherwise, it will create a client cache on local node.
+ * <p>
+ * If a cache with the same name already exists in the grid, an exception will be thrown.
*
* @param cacheName Cache name.
* @return Instance of started cache.
@@ -233,6 +238,10 @@ public interface Ignite extends AutoCloseable {
/**
* Gets existing cache with the given name or creates new one with the given configuration.
+ * <p>
+ * If a cache with the same name already exist, this method will not check that the given
+ * configuration matches the configuration of existing cache and will return an instance
+ * of the existing cache.
*
* @param cacheCfg Cache configuration to use.
* @return Existing or newly created cache.
@@ -259,6 +268,9 @@ public interface Ignite extends AutoCloseable {
* <p>
* If local node is an affinity node, this method will return the instance of started cache.
* Otherwise, it will create a near cache with the given configuration on local node.
+ * <p>
+ * If a cache with the same name already exists in the grid, an exception will be thrown regardless
+ * whether the given configuration matches the configuration of the existing cache or not.
*
* @param cacheCfg Cache configuration to use.
* @param nearCfg Near cache configuration to use on local node in case it is not an
@@ -270,6 +282,13 @@ public interface Ignite extends AutoCloseable {
/**
* Gets existing cache with the given cache configuration or creates one if it does not exist.
+ * <p>
+ * If a cache with the same name already exist, this method will not check that the given
+ * configuration matches the configuration of existing cache and will return an instance
+ * of the existing cache.
+ * <p>
+ * If local node is not an affinity node and a client cache without near cache has been already started
+ * on this node, an exception will be thrown.
*
* @param cacheCfg Cache configuration.
* @param nearCfg Near cache configuration for client.
http://git-wip-us.apache.org/repos/asf/ignite/blob/046f3b84/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index f98d50a..886dca6 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -557,8 +557,10 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* the provided key. If an {@link javax.cache.Cache.Entry} does not exist for the specified key,
* an attempt is made to load it (if a loader is configured) or a surrogate
* {@link javax.cache.Cache.Entry}, consisting of the key with a null value is used instead.
- * This method different
* <p>
+ * An instance of entry processor must be stateless as it may be invoked multiple times on primary and
+ * backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always
+ * the same.
*
* @param key the key to the entry
* @param entryProcessor the {@link CacheEntryProcessor} to invoke
@@ -605,6 +607,10 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* {@link CacheEntryProcessor} or Caching implementation throw an exception, the
* exception is wrapped and re-thrown when a call to
* {@link javax.cache.processor.EntryProcessorResult#get()} is made.
+ * <p>
+ * An instance of entry processor must be stateless as it may be invoked multiple times on primary and
+ * backup nodes in the cache. It is guaranteed that the value passed to the entry processor will be always
+ * the same.
*
* @param keys the set of keys for entries to process
* @param entryProcessor the {@link CacheEntryProcessor} to invoke
[6/7] ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-1.5' into ignite-1537
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1.5' into ignite-1537
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4230ab0a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4230ab0a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4230ab0a
Branch: refs/heads/ignite-1537
Commit: 4230ab0a5f98832c656f054ebb391cb4fb8313cc
Parents: 730efda ab8ba97
Author: sboikov <sb...@gridgain.com>
Authored: Wed Dec 16 08:53:17 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Dec 16 08:53:17 2015 +0300
----------------------------------------------------------------------
.../store/auto/CacheBinaryAutoStoreExample.java | 9 +-
.../examples/ScalarSnowflakeSchemaExample.scala | 31 ++-
.../src/main/java/org/apache/ignite/Ignite.java | 19 ++
.../java/org/apache/ignite/IgniteCache.java | 8 +-
.../org/apache/ignite/binary/BinaryObject.java | 15 ++
.../store/jdbc/CacheAbstractJdbcStore.java | 2 +-
.../configuration/CacheConfiguration.java | 19 +-
.../internal/binary/BinaryEnumObjectImpl.java | 7 +
.../internal/binary/BinaryObjectExImpl.java | 7 +
.../binary/BinaryObjectOffheapImpl.java | 7 +
.../processors/cache/GridCacheProcessor.java | 4 +-
.../cache/store/CacheOsStoreManager.java | 2 +-
...IgniteCacheBinaryEntryProcessorSelfTest.java | 255 +++++++++++++++++++
.../GridCacheBinaryStoreAbstractSelfTest.java | 2 +-
.../BinaryTxCacheLocalEntriesSelfTest.java | 2 +-
.../native-client-test-cache-parallel-store.xml | 2 +-
.../Config/native-client-test-cache-store.xml | 6 +-
.../scala/org/apache/ignite/scalar/scalar.scala | 11 +-
18 files changed, 370 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
[4/7] ignite git commit: IGNITE-2138 Introduced toBuilder() method.
Posted by sb...@apache.org.
IGNITE-2138 Introduced toBuilder() method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/df08d3de
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/df08d3de
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/df08d3de
Branch: refs/heads/ignite-1537
Commit: df08d3de91d080bd26a1aa0debc656fa73a3f156
Parents: 046f3b8
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Tue Dec 15 20:31:52 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Dec 15 20:31:52 2015 +0300
----------------------------------------------------------------------
.../store/auto/CacheBinaryAutoStoreExample.java | 2 +-
.../org/apache/ignite/binary/BinaryObject.java | 15 ++
.../store/jdbc/CacheAbstractJdbcStore.java | 2 +-
.../configuration/CacheConfiguration.java | 19 +-
.../internal/binary/BinaryEnumObjectImpl.java | 7 +
.../internal/binary/BinaryObjectExImpl.java | 7 +
.../binary/BinaryObjectOffheapImpl.java | 7 +
.../processors/cache/GridCacheProcessor.java | 4 +-
.../cache/store/CacheOsStoreManager.java | 2 +-
...IgniteCacheBinaryEntryProcessorSelfTest.java | 255 +++++++++++++++++++
.../GridCacheBinaryStoreAbstractSelfTest.java | 2 +-
.../BinaryTxCacheLocalEntriesSelfTest.java | 2 +-
.../native-client-test-cache-parallel-store.xml | 2 +-
.../Config/native-client-test-cache-store.xml | 6 +-
14 files changed, 311 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
index aa5eea1..75773cb 100644
--- a/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
+++ b/examples/src/main/java/org/apache/ignite/examples/binary/datagrid/store/auto/CacheBinaryAutoStoreExample.java
@@ -94,7 +94,7 @@ public class CacheBinaryAutoStoreExample {
cfg.setAtomicityMode(TRANSACTIONAL);
// This option will allow to start remote nodes without having user classes in classpath.
- cfg.setKeepBinaryInStore(true);
+ cfg.setStoreKeepBinary(true);
cfg.setReadThrough(true);
cfg.setWriteThrough(true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
index f4afd8d..3d99757 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryObject.java
@@ -141,6 +141,21 @@ public interface BinaryObject extends Serializable, Cloneable {
public BinaryObject clone() throws CloneNotSupportedException;
/**
+ * Creates a new {@link BinaryObjectBuilder} based on this binary object. The following code
+ * <pre name=code class=java>
+ * BinaryObjectBuilder builder = binaryObject.toBuilder();
+ * </pre>
+ * is equivalent to
+ * <pre name=code class=java>
+ * BinaryObjectBuilder builder = ignite.binary().builder(binaryObject);
+ * </pre>
+ *
+ * @return Binary object builder.
+ * @throws BinaryObjectException If builder cannot be created.
+ */
+ public BinaryObjectBuilder toBuilder() throws BinaryObjectException;
+
+ /**
* Get ordinal for this enum object. Use {@link BinaryType#isEnum()} to check if object is of enum type.
*
* @return Ordinal.
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 07e9c9b..c5c55e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -1475,7 +1475,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
throws CacheWriterException {
TypeKind valKind = em.valueKind();
- // Object could be passed by cache in binary format in case of cache configured with setKeepBinaryInStore(true).
+ // Object could be passed by cache in binary format in case of cache configured with setStoreKeepBinary(true).
if (valKind == TypeKind.POJO && val instanceof BinaryObject)
valKind = TypeKind.BINARY;
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/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 d73ff58..be1240c 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
@@ -208,7 +208,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Default value for keep binary in store behavior .*/
@SuppressWarnings({"UnnecessaryBoxing", "BooleanConstructorCall"})
- public static final Boolean DFLT_KEEP_BINARY_IN_STORE = new Boolean(false);
+ public static final Boolean DFLT_STORE_KEEP_BINARY = new Boolean(false);
/** Default threshold for concurrent loading of keys from {@link CacheStore}. */
public static final int DFLT_CONCURRENT_LOAD_ALL_THRESHOLD = 5;
@@ -269,7 +269,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private Factory storeFactory;
/** */
- private Boolean keepBinaryInStore = DFLT_KEEP_BINARY_IN_STORE;
+ private Boolean storeKeepBinary = DFLT_STORE_KEEP_BINARY;
/** */
private boolean loadPrevVal = DFLT_LOAD_PREV_VAL;
@@ -444,8 +444,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
invalidate = cc.isInvalidate();
isReadThrough = cc.isReadThrough();
isWriteThrough = cc.isWriteThrough();
- keepBinaryInStore = cc.isKeepBinaryInStore() != null ? cc.isKeepBinaryInStore() :
- DFLT_KEEP_BINARY_IN_STORE;
+ storeKeepBinary = cc.isStoreKeepBinary() != null ? cc.isStoreKeepBinary() : DFLT_STORE_KEEP_BINARY;
listenerConfigurations = cc.listenerConfigurations;
loadPrevVal = cc.isLoadPreviousValue();
longQryWarnTimeout = cc.getLongQueryWarningTimeout();
@@ -891,7 +890,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/**
* Flag indicating that {@link CacheStore} implementation
* is working with binary objects instead of Java objects.
- * Default value of this flag is {@link #DFLT_KEEP_BINARY_IN_STORE}.
+ * Default value of this flag is {@link #DFLT_STORE_KEEP_BINARY}.
* <p>
* If set to {@code false}, Ignite will deserialize keys and
* values stored in binary format before they are passed
@@ -906,17 +905,17 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
*
* @return Keep binary in store flag.
*/
- public Boolean isKeepBinaryInStore() {
- return keepBinaryInStore;
+ public Boolean isStoreKeepBinary() {
+ return storeKeepBinary;
}
/**
* Sets keep binary in store flag.
*
- * @param keepBinaryInStore Keep binary in store flag.
+ * @param storeKeepBinary Keep binary in store flag.
*/
- public void setKeepBinaryInStore(boolean keepBinaryInStore) {
- this.keepBinaryInStore = keepBinaryInStore;
+ public void setStoreKeepBinary(boolean storeKeepBinary) {
+ this.storeKeepBinary = storeKeepBinary;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index b2ee16f..001d2d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -19,9 +19,11 @@ package org.apache.ignite.internal.binary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
@@ -121,6 +123,11 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
}
/** {@inheritDoc} */
+ @Override public BinaryObjectBuilder toBuilder() throws BinaryObjectException {
+ return BinaryObjectBuilderImpl.wrap(this);
+ }
+
+ /** {@inheritDoc} */
@Override public int enumOrdinal() throws BinaryObjectException {
return ord;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
index 404300d..ddf17f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectExImpl.java
@@ -21,6 +21,8 @@ import java.math.BigDecimal;
import java.util.Arrays;
import java.util.IdentityHashMap;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.binary.BinaryObjectException;
@@ -101,6 +103,11 @@ public abstract class BinaryObjectExImpl implements BinaryObjectEx {
protected abstract BinarySchema createSchema();
/** {@inheritDoc} */
+ @Override public BinaryObjectBuilder toBuilder() throws BinaryObjectException {
+ return BinaryObjectBuilderImpl.wrap(this);
+ }
+
+ /** {@inheritDoc} */
@Override public BinaryObject clone() throws CloneNotSupportedException {
return (BinaryObject)super.clone();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
index 0246a36..696a34b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
@@ -19,8 +19,10 @@ package org.apache.ignite.internal.binary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
@@ -326,6 +328,11 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
}
/** {@inheritDoc} */
+ @Override public BinaryObjectBuilder toBuilder() throws BinaryObjectException {
+ return BinaryObjectBuilderImpl.wrap(heapCopy());
+ }
+
+ /** {@inheritDoc} */
@Override public byte cacheObjectType() {
throw new UnsupportedOperationException();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/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 1bbef62..f0bed99 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
@@ -1041,9 +1041,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
CacheConfiguration cfg = cacheCtx.config();
// Intentionally compare Boolean references using '!=' below to check if the flag has been explicitly set.
- if (cfg.isKeepBinaryInStore() && cfg.isKeepBinaryInStore() != CacheConfiguration.DFLT_KEEP_BINARY_IN_STORE
+ if (cfg.isStoreKeepBinary() && cfg.isStoreKeepBinary() != CacheConfiguration.DFLT_STORE_KEEP_BINARY
&& !(ctx.config().getMarshaller() instanceof BinaryMarshaller))
- U.warn(log, "CacheConfiguration.isKeepBinaryInStore() configuration property will be ignored because " +
+ U.warn(log, "CacheConfiguration.isStoreKeepBinary() configuration property will be ignored because " +
"BinaryMarshaller is not used");
// Start managers.
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
index e89483a..27771ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/store/CacheOsStoreManager.java
@@ -82,6 +82,6 @@ public class CacheOsStoreManager extends GridCacheStoreManagerAdapter {
/** {@inheritDoc} */
@Override public boolean configuredConvertBinary() {
- return !(ctx.config().getMarshaller() instanceof BinaryMarshaller && cfg.isKeepBinaryInStore());
+ return !(ctx.config().getMarshaller() instanceof BinaryMarshaller && cfg.isStoreKeepBinary());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java
new file mode 100644
index 0000000..8e20c3e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheBinaryEntryProcessorSelfTest.java
@@ -0,0 +1,255 @@
+/*
+ * 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 javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
+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.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class IgniteCacheBinaryEntryProcessorSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int SRV_CNT = 4;
+
+ /** */
+ private static final int NODES = 5;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ if (getTestGridName(SRV_CNT).equals(gridName))
+ cfg.setClientMode(true);
+
+ cfg.setMarshaller(null);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES);
+ }
+
+ /**
+ * @param cacheMode Cache mode.
+ * @param atomicityMode Atomicity mode.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Integer, TestValue> cacheConfiguration(CacheMode cacheMode, CacheAtomicityMode atomicityMode) {
+ CacheConfiguration<Integer, TestValue> ccfg = new CacheConfiguration<>();
+
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setAtomicityMode(atomicityMode);
+
+ ccfg.setBackups(1);
+
+ return ccfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedTransactional() throws Exception {
+ checkInvokeBinaryObject(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedTransactional() throws Exception {
+ checkInvokeBinaryObject(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedAtomic() throws Exception {
+ checkInvokeBinaryObject(CacheMode.PARTITIONED, CacheAtomicityMode.TRANSACTIONAL);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedAtomic() throws Exception {
+ checkInvokeBinaryObject(CacheMode.REPLICATED, CacheAtomicityMode.TRANSACTIONAL);
+ }
+
+ /**
+ * @param cacheMode Cache mode to test.
+ * @param atomicityMode Atomicity mode to test.
+ * @throws Exception
+ */
+ private void checkInvokeBinaryObject(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws Exception {
+ Ignite client = ignite(SRV_CNT);
+
+ IgniteCache<Integer, TestValue> clientCache = client.createCache(cacheConfiguration(cacheMode, atomicityMode));
+
+ try {
+ IgniteBinary binary = client.binary();
+
+ for (int i = 0; i < 100; i++) {
+ clientCache.put(i, new TestValue(i, "value-" + i));
+
+ BinaryObjectBuilder bldr = binary.builder("NoClass");
+
+ bldr.setField("val", i);
+ bldr.setField("strVal", "value-" + i);
+
+ clientCache.withKeepBinary().put(-(i + 1), bldr.build());
+ }
+
+ IgniteCache<Integer, BinaryObject> binaryClientCache = clientCache.withKeepBinary();
+
+ for (int i = 0; i < 100; i++) {
+ binaryClientCache.invoke(i, new TestEntryProcessor());
+ binaryClientCache.invoke(-(i + 1), new TestEntryProcessor());
+ }
+
+ for (int g = 0; g < NODES; g++) {
+ IgniteCache<Integer, TestValue> nodeCache = ignite(g).cache(null);
+ IgniteCache<Integer, BinaryObject> nodeBinaryCache = nodeCache.withKeepBinary();
+
+ for (int i = 0; i < 100; i++) {
+ TestValue updated = nodeCache.get(i);
+
+ assertEquals((Integer)(i + 1), updated.value());
+ assertEquals("updated-" + i, updated.stringValue());
+
+ BinaryObject updatedBinary = nodeBinaryCache.get(i);
+ assertEquals(i + 1, updatedBinary.field("val"));
+ assertEquals("updated-" + i, updatedBinary.field("strVal"));
+
+ updatedBinary = nodeBinaryCache.get(-(i + 1));
+ assertEquals(i + 1, updatedBinary.field("val"));
+ assertEquals("updated-" + i, updatedBinary.field("strVal"));
+ }
+ }
+ }
+ finally {
+ client.destroyCache(null);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestEntryProcessor implements CacheEntryProcessor<Integer, BinaryObject, Void> {
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<Integer, BinaryObject> entry, Object... arguments)
+ throws EntryProcessorException {
+ BinaryObjectBuilder bldr = entry.getValue().toBuilder();
+
+ Integer val = bldr.<Integer>getField("val");
+
+ bldr.setField("val", val + 1);
+ bldr.setField("strVal", "updated-" + val);
+
+ entry.setValue(bldr.build());
+
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ static class TestValue {
+ /** */
+ private Integer val;
+
+ /** */
+ private String strVal;
+
+ /**
+ * @param val Value.
+ */
+ public TestValue(Integer val, String strVal) {
+ this.val = val;
+ this.strVal = strVal;
+ }
+
+ /**
+ * @return Value.
+ */
+ public Integer value() {
+ return val;
+ }
+
+ /**
+ * @return String value.
+ */
+ public String stringValue() {
+ return strVal;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TestValue testVal = (TestValue) o;
+
+ return val.equals(testVal.val);
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return val.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TestValue.class, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
index 4f478f7..0cfa88b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
@@ -62,7 +62,7 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
CacheConfiguration cacheCfg = new CacheConfiguration();
cacheCfg.setCacheStoreFactory(singletonFactory(STORE));
- cacheCfg.setKeepBinaryInStore(keepBinaryInStore());
+ cacheCfg.setStoreKeepBinary(keepBinaryInStore());
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java
index aa25caf..54fa5dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/portable/BinaryTxCacheLocalEntriesSelfTest.java
@@ -41,7 +41,7 @@ public class BinaryTxCacheLocalEntriesSelfTest extends GridCacheAbstractSelfTest
@Override protected CacheConfiguration cacheConfiguration(String gridName) throws Exception {
CacheConfiguration ccfg = super.cacheConfiguration(gridName);
- ccfg.setKeepBinaryInStore(true);
+ ccfg.setStoreKeepBinary(true);
return ccfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
index af03e69..8376d40 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-parallel-store.xml
@@ -39,7 +39,7 @@
<property name="name" value="object_store_parallel"/>
<property name="cacheMode" value="LOCAL"/>
<property name="atomicityMode" value="TRANSACTIONAL"/>
- <property name="keepBinaryInStore" value="false"/>
+ <property name="storeKeepBinary" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
http://git-wip-us.apache.org/repos/asf/ignite/blob/df08d3de/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
index 25a1d16..c2c4762 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/native-client-test-cache-store.xml
@@ -41,7 +41,7 @@
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true"/>
- <property name="keepBinaryInStore" value="true"/>
+ <property name="storeKeepBinary" value="true"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
@@ -56,7 +56,7 @@
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true"/>
- <property name="keepBinaryInStore" value="false"/>
+ <property name="storeKeepBinary" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
@@ -71,7 +71,7 @@
<property name="atomicityMode" value="TRANSACTIONAL"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true"/>
- <property name="keepBinaryInStore" value="false"/>
+ <property name="storeKeepBinary" value="false"/>
<property name="cacheStoreFactory">
<bean class="org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactory">
[7/7] ignite git commit: ignite-1.5 Fixed tx entry add to always
check for enlistWrite errors.
Posted by sb...@apache.org.
ignite-1.5 Fixed tx entry add to always check for enlistWrite errors.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dea42fd3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dea42fd3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dea42fd3
Branch: refs/heads/ignite-1537
Commit: dea42fd32cd9213499fed5b88a26a4ed76887511
Parents: 4230ab0
Author: sboikov <sb...@gridgain.com>
Authored: Wed Dec 16 08:59:33 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Dec 16 08:59:33 2015 +0300
----------------------------------------------------------------------
.../transactions/IgniteTxLocalAdapter.java | 23 +++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dea42fd3/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index a3aed34..720832e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -2952,6 +2952,9 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (pessimistic()) {
assert loadFut == null || loadFut.isDone() : loadFut;
+ if (loadFut != null)
+ loadFut.get();
+
final Collection<KeyCacheObject> enlisted = Collections.singleton(cacheKey);
if (log.isDebugEnabled())
@@ -3124,6 +3127,15 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
if (pessimistic()) {
assert loadFut == null || loadFut.isDone() : loadFut;
+ if (loadFut != null) {
+ try {
+ loadFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture(e);
+ }
+ }
+
if (log.isDebugEnabled())
log.debug("Before acquiring transaction lock for put on keys: " + enlisted);
@@ -3382,7 +3394,16 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
// Otherwise, during rollback we will not know whether locks need
// to be rolled back.
if (pessimistic()) {
- assert loadFut.isDone() : loadFut;
+ assert loadFut == null || loadFut.isDone() : loadFut;
+
+ if (loadFut != null) {
+ try {
+ loadFut.get();
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
if (log.isDebugEnabled())
log.debug("Before acquiring transaction lock for remove on keys: " + enlisted);