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 2016/02/12 14:17:23 UTC
[01/10] ignite git commit: Fix R# analysis warnings
Repository: ignite
Updated Branches:
refs/heads/ignite-1786 344a38e8d -> 1eacb979a
Fix R# analysis warnings
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/877be93e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/877be93e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/877be93e
Branch: refs/heads/ignite-1786
Commit: 877be93ee35afddcc126a147cfd3cd1dda4a46ce
Parents: 0491a5f
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Thu Feb 11 16:31:28 2016 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Thu Feb 11 16:31:28 2016 +0300
----------------------------------------------------------------------
.../Impl/Common/IgniteConfigurationXmlSerializer.cs | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/877be93e/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
index af25bfa..c27012a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Impl.Common
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
- using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Xml;
@@ -99,14 +98,13 @@ namespace Apache.Ignite.Core.Impl.Common
/// <summary>
/// Writes the property of a basic type (primitives, strings, types).
/// </summary>
- [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
private static void WriteBasicProperty(object obj, XmlWriter writer, Type valueType, PropertyInfo property)
{
var converter = GetConverter(property, valueType);
var stringValue = converter.ConvertToInvariantString(obj);
- writer.WriteString(stringValue);
+ writer.WriteString(stringValue ?? "");
}
/// <summary>
@@ -125,7 +123,6 @@ namespace Apache.Ignite.Core.Impl.Common
/// <summary>
/// Writes the complex property (nested object).
/// </summary>
- [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")]
private static void WriteComplexProperty(object obj, XmlWriter writer, Type valueType)
{
var props = GetNonDefaultProperties(obj).ToList();
@@ -139,7 +136,7 @@ namespace Apache.Ignite.Core.Impl.Common
{
var converter = GetConverter(prop, prop.PropertyType);
var stringValue = converter.ConvertToInvariantString(prop.GetValue(obj, null));
- writer.WriteAttributeString(PropertyNameToXmlName(prop.Name), stringValue);
+ writer.WriteAttributeString(PropertyNameToXmlName(prop.Name), stringValue ?? "");
}
// Write elements
[08/10] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6c4bad17
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6c4bad17
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6c4bad17
Branch: refs/heads/ignite-1786
Commit: 6c4bad1758d7ff963a3bc1830d910732edd7db0b
Parents: 159b6cb 57236c6
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 12 16:03:06 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 12 16:03:06 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/cache/CacheMemoryMode.java | 2 +
.../internal/GridMessageListenHandler.java | 16 ++
.../processors/cache/GridCacheAdapter.java | 7 +
.../processors/cache/GridCacheProcessor.java | 8 +-
.../processors/cache/GridCacheSwapManager.java | 3 +-
.../continuous/GridContinuousProcessor.java | 50 +++--
.../internal/GridAffinityNoCacheSelfTest.java | 4 +-
...eClientReconnectContinuousProcessorTest.java | 32 +++-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 17 +-
.../GridCacheReplicatedPreloadSelfTest.java | 121 +++++++++---
...IgniteCacheContinuousQueryReconnectTest.java | 192 +++++++++++++++++++
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +-
.../p2p/CacheDeploymentAffinityKeyMapper.java | 35 ++++
.../CacheDeploymentAlwaysTruePredicate2.java | 30 +++
...oymentCacheEntryEventSerializableFilter.java | 32 ++++
.../p2p/CacheDeploymentCacheEntryListener.java | 31 +++
...CacheDeploymentCachePluginConfiguration.java | 74 +++++++
...heDeploymentStoreSessionListenerFactory.java | 83 ++++++++
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../yardstick/cache/IgniteInvokeBenchmark.java | 65 +++++++
.../cache/IgniteInvokeTxBenchmark.java | 30 +++
21 files changed, 786 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
[09/10] ignite git commit: IGNITE-2625 .NET: Fixed field offset
calculation in BinaryReader.
Posted by vo...@apache.org.
IGNITE-2625 .NET: Fixed field offset calculation in BinaryReader.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3dce33f5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3dce33f5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3dce33f5
Branch: refs/heads/ignite-1786
Commit: 3dce33f5a007aa15adfc1e79b1ac96e86683e9fb
Parents: 6c4bad1
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Feb 12 16:09:00 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 12 16:09:00 2016 +0300
----------------------------------------------------------------------
.../Binary/BinaryStructureTest.cs | 38 ++++++++++++++------
.../Impl/Binary/BinaryReader.cs | 2 +-
2 files changed, 28 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3dce33f5/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
index 78ee8c0..1ab81c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinaryStructureTest.cs
@@ -20,9 +20,11 @@ namespace Apache.Ignite.Core.Tests.Binary
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.IO;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Impl;
using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Binary.IO;
using NUnit.Framework;
/// <summary>
@@ -66,15 +68,29 @@ namespace Apache.Ignite.Core.Tests.Binary
Marshaller marsh = new Marshaller(cfg);
// 3. Marshal all data and ensure deserialized object is fine.
- foreach (BranchedType obj in objs)
+ // Use single stream to test object offsets
+ using (var stream = new BinaryHeapStream(128))
{
- Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
+ var writer = marsh.StartMarshal(stream);
- byte[] data = marsh.Marshal(obj);
+ foreach (var obj in objs)
+ {
+ Console.WriteLine(">>> Write object [mode=" + obj.mode + ']');
- BranchedType other = marsh.Unmarshal<BranchedType>(data);
+ writer.WriteObject(obj);
- Assert.IsTrue(obj.Equals(other));
+ }
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ var reader = marsh.StartUnmarshal(stream);
+
+ foreach (var obj in objs)
+ {
+ var other = reader.ReadObject<BranchedType>();
+
+ Assert.IsTrue(obj.Equals(other));
+ }
}
Console.WriteLine();
@@ -206,30 +222,30 @@ namespace Apache.Ignite.Core.Tests.Binary
break;
case 2:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
f4 = reader.ReadInt("f4");
+ f3 = reader.ReadInt("f3");
+ f2 = reader.ReadInt("f2");
break;
case 3:
+ f5 = reader.ReadInt("f5");
f2 = reader.ReadInt("f2");
f3 = reader.ReadInt("f3");
- f5 = reader.ReadInt("f5");
break;
case 4:
- f2 = reader.ReadInt("f2");
- f3 = reader.ReadInt("f3");
f5 = reader.ReadInt("f5");
f6 = reader.ReadInt("f6");
+ f2 = reader.ReadInt("f2");
+ f3 = reader.ReadInt("f3");
break;
case 5:
- f2 = reader.ReadInt("f2");
f3 = reader.ReadInt("f3");
+ f2 = reader.ReadInt("f2");
f7 = reader.ReadInt("f7");
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/3dce33f5/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
index 1c5c719..16aae93 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReader.cs
@@ -938,7 +938,7 @@ namespace Apache.Ignite.Core.Impl.Binary
if (!_curSchemaMap.TryGetValue(fieldId, out pos))
return false;
- Stream.Seek(pos, SeekOrigin.Begin);
+ Stream.Seek(pos + _curPos, SeekOrigin.Begin);
}
return true;
[04/10] ignite git commit: IGNITE-2468
Posted by vo...@apache.org.
IGNITE-2468
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/725d6cb5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/725d6cb5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/725d6cb5
Branch: refs/heads/ignite-1786
Commit: 725d6cb557684ac8f31dfde8f5fcb4ddb95a18dd
Parents: 763bf57
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Feb 12 14:08:25 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Feb 12 14:08:25 2016 +0300
----------------------------------------------------------------------
.../internal/GridMessageListenHandler.java | 16 ++
.../continuous/GridContinuousProcessor.java | 50 +++--
...eClientReconnectContinuousProcessorTest.java | 32 +++-
...IgniteCacheContinuousQueryReconnectTest.java | 192 +++++++++++++++++++
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +-
.../IgniteCacheQuerySelfTestSuite.java | 2 +
6 files changed, 279 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
index 13aeb54..bf81944 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/GridMessageListenHandler.java
@@ -83,6 +83,22 @@ public class GridMessageListenHandler implements GridContinuousHandler {
this.pred = pred;
}
+ /**
+ *
+ * @param orig Handler to be copied.
+ */
+ public GridMessageListenHandler(GridMessageListenHandler orig) {
+ assert orig != null;
+
+ this.clsName = orig.clsName;
+ this.depInfo = orig.depInfo;
+ this.pred = orig.pred;
+ this.predBytes = orig.predBytes;
+ this.topic = orig.topic;
+ this.topicBytes = orig.topicBytes;
+ this.depEnabled = false;
+ }
+
/** {@inheritDoc} */
@Override public boolean isEvents() {
return false;
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
index 0218897..496f820 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/continuous/GridContinuousProcessor.java
@@ -40,6 +40,7 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.GridKernalContext;
+import org.apache.ignite.internal.GridMessageListenHandler;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteDeploymentCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -428,11 +429,17 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
ctx.resource().injectGeneric(item.prjPred);
// Register handler only if local node passes projection predicate.
- if (item.prjPred == null || item.prjPred.apply(ctx.discovery().localNode())) {
+ if ((item.prjPred == null || item.prjPred.apply(ctx.discovery().localNode())) &&
+ !locInfos.containsKey(item.routineId)) {
if (registerHandler(data.nodeId, item.routineId, item.hnd, item.bufSize, item.interval,
item.autoUnsubscribe, false))
item.hnd.onListenerRegistered(item.routineId, ctx);
}
+
+ if (!item.autoUnsubscribe)
+ // Register routine locally.
+ locInfos.putIfAbsent(item.routineId, new LocalRoutineInfo(
+ item.prjPred, item.hnd, item.bufSize, item.interval, item.autoUnsubscribe));
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to register continuous handler.", e);
@@ -854,6 +861,10 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
U.error(log, "Failed to register handler [nodeId=" + node.id() + ", routineId=" + routineId + ']', e);
}
+ GridContinuousHandler hnd0 = hnd instanceof GridMessageListenHandler ?
+ new GridMessageListenHandler((GridMessageListenHandler)hnd) :
+ hnd;
+
if (node.isClient()) {
Map<UUID, LocalRoutineInfo> clientRoutineMap = clientInfos.get(node.id());
@@ -866,7 +877,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
}
clientRoutineMap.put(routineId, new LocalRoutineInfo(data.projectionPredicate(),
- hnd,
+ hnd0,
data.bufferSize(),
data.interval(),
data.autoUnsubscribe()));
@@ -881,10 +892,16 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
if (prjPred != null)
ctx.resource().injectGeneric(prjPred);
- if (prjPred == null || prjPred.apply(ctx.discovery().node(ctx.localNodeId()))) {
- registered = registerHandler(node.id(), routineId, hnd, data.bufferSize(), data.interval(),
+ if ((prjPred == null || prjPred.apply(ctx.discovery().node(ctx.localNodeId()))) &&
+ !locInfos.containsKey(routineId)) {
+ registered = registerHandler(node.id(), routineId, hnd0, data.bufferSize(), data.interval(),
data.autoUnsubscribe(), false);
}
+
+ if (!data.autoUnsubscribe())
+ // Register routine locally.
+ locInfos.putIfAbsent(routineId, new LocalRoutineInfo(
+ prjPred, hnd0, data.bufferSize(), data.interval(), data.autoUnsubscribe()));
}
catch (IgniteCheckedException e) {
err = e;
@@ -894,11 +911,11 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
}
// Load partition counters.
- if (hnd.isQuery()) {
+ if (hnd0.isQuery()) {
GridCacheProcessor proc = ctx.cache();
if (proc != null) {
- GridCacheAdapter cache = ctx.cache().internalCache(hnd.cacheName());
+ GridCacheAdapter cache = ctx.cache().internalCache(hnd0.cacheName());
if (cache != null && !cache.isLocal()) {
Map<Integer, Long> cntrs = cache.context().topology().updateCounters();
@@ -912,7 +929,7 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
req.addError(ctx.localNodeId(), err);
if (registered)
- hnd.onListenerRegistered(routineId, ctx);
+ hnd0.onListenerRegistered(routineId, ctx);
}
/**
@@ -1095,22 +1112,31 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
*/
@SuppressWarnings("TooBroadScope")
private void unregisterRemote(UUID routineId) {
- RemoteRoutineInfo info;
+ RemoteRoutineInfo remote;
+ LocalRoutineInfo loc;
stopLock.lock();
try {
- info = rmtInfos.remove(routineId);
+ remote = rmtInfos.remove(routineId);
- if (info == null)
+ loc = locInfos.remove(routineId);
+
+ if (remote == null)
stopped.add(routineId);
}
finally {
stopLock.unlock();
}
- if (info != null)
- unregisterHandler(routineId, info.hnd, false);
+ if (remote != null)
+ unregisterHandler(routineId, remote.hnd, false);
+ else {
+ assert loc != null;
+
+ // Removes routine at node started it when stopRoutine called from another node.
+ unregisterHandler(routineId, loc.hnd, false);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectContinuousProcessorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectContinuousProcessorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectContinuousProcessorTest.java
index dc94c96..4c44adc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectContinuousProcessorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectContinuousProcessorTest.java
@@ -113,7 +113,21 @@ public class IgniteClientReconnectContinuousProcessorTest extends IgniteClientRe
/**
* @throws Exception If failed.
*/
- public void testMessageListenerReconnect() throws Exception {
+ public void testMessageListenerReconnectAndStopFromServer() throws Exception {
+ testMessageListenerReconnect(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMessageListenerReconnectAndStopFromClient() throws Exception {
+ testMessageListenerReconnect(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testMessageListenerReconnect(boolean stopFromClient) throws Exception {
Ignite client = grid(serverCount());
assertTrue(client.cluster().localNode().isClient());
@@ -166,7 +180,7 @@ public class IgniteClientReconnectContinuousProcessorTest extends IgniteClientRe
log.info("Stop listen, should not get remote messages anymore.");
- client.message().stopRemoteListen(opId);
+ (stopFromClient ? client : srv).message().stopRemoteListen(opId);
srv.message().send(topic, "msg3");
@@ -175,6 +189,20 @@ public class IgniteClientReconnectContinuousProcessorTest extends IgniteClientRe
assertTrue(locLsnr.latch.await(5000, MILLISECONDS));
assertFalse(latch.await(3000, MILLISECONDS));
+
+ log.info("New nodes should not register stopped listeners.");
+
+ startGrid(serverCount() + 1);
+
+ srv.message().send(topic, "msg4");
+
+ locLsnr.latch = new CountDownLatch(1);
+ latch = new CountDownLatch(1);
+
+ assertTrue(locLsnr.latch.await(5000, MILLISECONDS));
+ assertFalse(latch.await(3000, MILLISECONDS));
+
+ stopGrid(serverCount() + 1);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryReconnectTest.java
new file mode 100644
index 0000000..b1d8a49
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/IgniteCacheContinuousQueryReconnectTest.java
@@ -0,0 +1,192 @@
+/*
+ * 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.query.continuous;
+
+import java.io.Serializable;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.Cache;
+import javax.cache.CacheException;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheContinuousQueryReconnectTest extends GridCommonAbstractTest implements Serializable {
+ /** */
+ final private static AtomicInteger cnt = new AtomicInteger();
+
+ /** */
+ private volatile boolean isClient = false;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setCacheMode(PARTITIONED);
+ ccfg.setAtomicityMode(atomicMode());
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setBackups(1);
+
+ cfg.setCacheConfiguration(ccfg);
+
+ if (isClient)
+ cfg.setClientMode(true);
+
+ return cfg;
+ }
+
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @return Atomic mode.
+ */
+ protected CacheAtomicityMode atomicMode() {
+ return ATOMIC;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReconnectServer() throws Exception {
+ testReconnect(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReconnectClient() throws Exception {
+ testReconnect(true);
+ }
+
+ /**
+ *
+ */
+ private void putAndCheck(IgniteCache<Object, Object> cache, int diff) {
+ cnt.set(0);
+
+ cache.put(1, "1");
+
+ assertEquals(diff, cnt.get());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testReconnect(boolean clientQuery) throws Exception {
+ Ignite srv1 = startGrid(0);
+
+ ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() {
+ @Override public void onUpdated(Iterable iterable) throws CacheEntryListenerException {
+ // No-op.
+ }
+ });
+
+ qry.setAutoUnsubscribe(false);
+
+ qry.setRemoteFilter(new CacheEntryEventSerializableFilter<Object, Object>() {
+ @Override public boolean evaluate(CacheEntryEvent<?, ?> event) throws CacheEntryListenerException {
+ cnt.incrementAndGet();
+
+ return true;
+ }
+ });
+
+ isClient = true;
+
+ Ignite client = startGrid(1);
+
+ isClient = false;
+
+ IgniteCache<Object, Object> cache1 = srv1.cache(null);
+ IgniteCache<Object, Object> clCache = client.cache(null);
+
+ putAndCheck(clCache, 0); // 0 remote listeners.
+
+ QueryCursor<Cache.Entry<Object, Object>> cur = (clientQuery ? clCache : cache1).query(qry);
+
+ putAndCheck(clCache, 1); // 1 remote listener.
+
+ final Ignite srv2 = startGrid(2);
+
+ putAndCheck(clCache, 2); // 2 remote listeners.
+
+ stopGrid(0);
+
+ while (true) {
+ try {
+ clCache.get(1);
+
+ break;
+ }
+ catch (IgniteClientDisconnectedException e) {
+ e.reconnectFuture().get(); // Wait for reconnect.
+
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof IgniteClientDisconnectedException)
+ ((IgniteClientDisconnectedException)e.getCause()).reconnectFuture().get(); // Wait for reconnect.
+ }
+ }
+
+ putAndCheck(clCache, 1); // 1 remote listener.
+
+ Ignite srv3 = startGrid(3);
+
+ putAndCheck(clCache, 2); // 2 remote listeners.
+
+ stopGrid(1); // Client node.
+
+ isClient = true;
+
+ client = startGrid(4);
+
+ isClient = false;
+
+ clCache = client.cache(null);
+
+ putAndCheck(clCache, 2); // 2 remote listeners.
+
+ Ignite srv4 = startGrid(5);
+
+ putAndCheck(clCache, 3); // 3 remote listeners.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/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 030c653..7debb41 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
@@ -2050,7 +2050,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override public boolean apply(UUID uuid, Object msg) {
- X.println(">>> Received [locNodeId=" + ignite.configuration().getNodeId() + ", msg=" + msg + ']');
+ X.println(">>> Received [node=" + ignite.name() + ", msg=" + msg + ']');
msgLatch.countDown();
http://git-wip-us.apache.org/repos/asf/ignite/blob/725d6cb5/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 3cd4579..cecb8ad 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
@@ -100,6 +100,7 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest;
import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest;
import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryReconnectTest;
import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest;
import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryPartitionedSelfTest;
@@ -200,6 +201,7 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(GridCacheContinuousQueryPartitionTxOneNodeTest.class);
suite.addTestSuite(GridCacheContinuousQueryPartitionAtomicOneNodeTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
+ suite.addTestSuite(IgniteCacheContinuousQueryReconnectTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class);
suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest.class);
[10/10] ignite git commit: Merge branch 'master' into ignite-1786
Posted by vo...@apache.org.
Merge branch 'master' into ignite-1786
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1eacb979
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1eacb979
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1eacb979
Branch: refs/heads/ignite-1786
Commit: 1eacb979a24c7eb04ea79ace4e0a214877c62e13
Parents: 344a38e 3dce33f
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 12 16:17:17 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 12 16:17:17 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/cache/CacheMemoryMode.java | 2 +
.../internal/GridMessageListenHandler.java | 16 ++
.../apache/ignite/internal/IgniteKernal.java | 14 +-
.../ignite/internal/binary/BinaryUtils.java | 4 +-
.../binary/builder/BinaryBuilderSerializer.java | 16 +-
.../binary/builder/BinaryObjectBuilderImpl.java | 12 +-
.../binary/builder/BinaryValueWithType.java | 3 +-
.../processors/cache/GridCacheAdapter.java | 7 +
.../processors/cache/GridCacheProcessor.java | 8 +-
.../processors/cache/GridCacheSwapManager.java | 3 +-
.../continuous/GridContinuousProcessor.java | 50 +++--
.../internal/GridAffinityNoCacheSelfTest.java | 4 +-
.../internal/GridNodeMetricsLogSelfTest.java | 98 ++++++++++
...eClientReconnectContinuousProcessorTest.java | 32 +++-
.../BinaryObjectBuilderAdditionalSelfTest.java | 91 ++++++++-
...naryObjectBuilderDefaultMappersSelfTest.java | 30 ++-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 17 +-
.../GridCacheReplicatedPreloadSelfTest.java | 121 +++++++++---
...IgniteCacheContinuousQueryReconnectTest.java | 192 +++++++++++++++++++
.../tcp/TcpClientDiscoverySpiSelfTest.java | 2 +-
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
.../p2p/CacheDeploymentAffinityKeyMapper.java | 35 ++++
.../CacheDeploymentAlwaysTruePredicate2.java | 30 +++
...oymentCacheEntryEventSerializableFilter.java | 32 ++++
.../p2p/CacheDeploymentCacheEntryListener.java | 31 +++
...CacheDeploymentCachePluginConfiguration.java | 74 +++++++
...heDeploymentStoreSessionListenerFactory.java | 83 ++++++++
.../IgniteCacheQuerySelfTestSuite.java | 2 +
.../Binary/BinaryStructureTest.cs | 38 ++--
.../Impl/Binary/BinaryReader.cs | 2 +-
.../Common/IgniteConfigurationXmlSerializer.cs | 7 +-
.../yardstick/cache/IgniteInvokeBenchmark.java | 65 +++++++
.../cache/IgniteInvokeTxBenchmark.java | 30 +++
33 files changed, 1070 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1eacb979/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
[02/10] ignite git commit: IGNITE-2555
Posted by vo...@apache.org.
IGNITE-2555
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/35b0e6bf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/35b0e6bf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/35b0e6bf
Branch: refs/heads/ignite-1786
Commit: 35b0e6bf149bb86a3eefefcbc657c822e25681f3
Parents: 877be93
Author: ruskim <ru...@gmail.com>
Authored: Thu Feb 11 18:53:50 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Feb 11 18:53:50 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 14 ++-
.../internal/GridNodeMetricsLogSelfTest.java | 98 ++++++++++++++++++++
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +
3 files changed, 113 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index e3017ff..5d8daf6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -989,6 +989,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
double avgCpuLoadPct = m.getAverageCpuLoad() * 100;
double gcPct = m.getCurrentGcCpuLoad() * 100;
+ //Heap params
long heapUsed = m.getHeapMemoryUsed();
long heapMax = m.getHeapMemoryMaximum();
@@ -997,6 +998,15 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
double freeHeapPct = heapMax > 0 ? ((double)((heapMax - heapUsed) * 100)) / heapMax : -1;
+ //Non heap params
+ long nonHeapUsed = m.getNonHeapMemoryUsed();
+ long nonHeapMax = m.getNonHeapMemoryMaximum();
+
+ long nonHeapUsedInMBytes = nonHeapUsed / 1024 / 1024;
+ long nonHeapCommInMBytes = m.getNonHeapMemoryCommitted() / 1024 / 1024;
+
+ double freeNonHeapPct = nonHeapMax > 0 ? ((double)((nonHeapMax - nonHeapUsed) * 100)) / nonHeapMax : -1;
+
int hosts = 0;
int nodes = 0;
int cpus = 0;
@@ -1046,12 +1056,14 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
String msg = NL +
"Metrics for local node (to disable set 'metricsLogFrequency' to 0)" + NL +
- " ^-- Node [id=" + id + ", name=" + name() + "]" + NL +
+ " ^-- Node [id=" + id + ", name=" + name() + ", uptime=" + getUpTimeFormatted() + "]" + NL +
" ^-- H/N/C [hosts=" + hosts + ", nodes=" + nodes + ", CPUs=" + cpus + "]" + NL +
" ^-- CPU [cur=" + dblFmt.format(cpuLoadPct) + "%, avg=" +
dblFmt.format(avgCpuLoadPct) + "%, GC=" + dblFmt.format(gcPct) + "%]" + NL +
" ^-- Heap [used=" + dblFmt.format(heapUsedInMBytes) + "MB, free=" +
dblFmt.format(freeHeapPct) + "%, comm=" + dblFmt.format(heapCommInMBytes) + "MB]" + NL +
+ " ^-- Non heap [used=" + dblFmt.format(nonHeapUsedInMBytes) + "MB, free=" +
+ dblFmt.format(freeNonHeapPct) + "%, comm=" + dblFmt.format(nonHeapCommInMBytes) + "MB]" + NL +
" ^-- Public thread pool [active=" + pubPoolActiveThreads + ", idle=" +
pubPoolIdleThreads + ", qSize=" + pubPoolQSize + "]" + NL +
" ^-- System thread pool [active=" + sysPoolActiveThreads + ", idle=" +
http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
new file mode 100644
index 0000000..fe5922e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridNodeMetricsLogSelfTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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;
+
+
+import java.io.StringWriter;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.testframework.junits.common.GridCommonTest;
+import org.apache.log4j.Layout;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.apache.log4j.WriterAppender;
+
+/**
+ * Check logging local node metrics
+ */
+@SuppressWarnings({"ProhibitedExceptionDeclared"})
+@GridCommonTest(group = "Kernal")
+public class GridNodeMetricsLogSelfTest extends GridCommonAbstractTest {
+ /** */
+
+ public GridNodeMetricsLogSelfTest() {
+ super(false);
+ }
+
+ /** {@inheritDoc} */
+ @SuppressWarnings({"unchecked"})
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMetricsLogFrequency(1000);
+
+ return cfg;
+ }
+
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNodeMetricsLog() throws Exception {
+ // Log to string, to check log content
+ Layout layout = new SimpleLayout();
+
+ StringWriter strWr = new StringWriter();
+
+ WriterAppender app = new WriterAppender(layout, strWr);
+
+ Logger.getRootLogger().addAppender(app);
+
+ Ignite g1 = startGrid(1);
+
+ IgniteCache<Integer, String> cache1 = g1.createCache("TestCache1");
+
+ cache1.put(1, "one");
+
+ Ignite g2 = startGrid(2);
+
+ IgniteCache<Integer, String> cache2 = g2.createCache("TestCache2");
+
+ cache2.put(2, "two");
+
+ Thread.sleep(10000);
+
+ //Check that nodes are alie
+ assert cache1.get(1).equals("one");
+ assert cache2.get(2).equals("two");
+
+ String fullLog = strWr.toString();
+
+ Logger.getRootLogger().removeAppender(app);
+
+ assert fullLog.contains("Metrics for local node");
+ assert fullLog.contains("uptime=");
+ assert fullLog.contains("Non heap");
+ assert fullLog.contains("Outbound messages queue");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/35b0e6bf/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index c904ef4..3903910 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.ClusterGroupSelfTest;
import org.apache.ignite.internal.GridFailFastNodeFailureDetectionSelfTest;
import org.apache.ignite.internal.GridLifecycleAwareSelfTest;
import org.apache.ignite.internal.GridLifecycleBeanSelfTest;
+import org.apache.ignite.internal.GridNodeMetricsLogSelfTest;
import org.apache.ignite.internal.GridProjectionForCachesSelfTest;
import org.apache.ignite.internal.GridReduceSelfTest;
import org.apache.ignite.internal.GridReleaseTypeSelfTest;
@@ -114,6 +115,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class);
GridTestUtils.addTestIfNeeded(suite, IgniteDaemonNodeMarshallerCacheTest.class, ignoredTests);
suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class);
+ suite.addTestSuite(GridNodeMetricsLogSelfTest.class);
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
[03/10] ignite git commit: IGNITE-2509 - Fixed offheap metrics -
Fixes #470.
Posted by vo...@apache.org.
IGNITE-2509 - Fixed offheap metrics - Fixes #470.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/763bf578
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/763bf578
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/763bf578
Branch: refs/heads/ignite-1786
Commit: 763bf578e9f510e50bdfa6b9e51ea25348bfd2e9
Parents: 35b0e6b
Author: vershov <ve...@gridgain.com>
Authored: Fri Feb 12 12:51:50 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Feb 12 12:51:50 2016 +0300
----------------------------------------------------------------------
.../org/apache/ignite/cache/CacheMemoryMode.java | 2 ++
.../processors/cache/GridCacheAdapter.java | 7 +++++++
.../processors/cache/GridCacheSwapManager.java | 3 ++-
.../internal/GridAffinityNoCacheSelfTest.java | 4 +++-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 17 +++++++++++++++--
5 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/763bf578/modules/core/src/main/java/org/apache/ignite/cache/CacheMemoryMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheMemoryMode.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheMemoryMode.java
index a596824..0133327 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheMemoryMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheMemoryMode.java
@@ -56,6 +56,8 @@ public enum CacheMemoryMode {
* Entry keys will be stored on heap memory, and values will be stored in offheap memory. Note
* that in this mode entries can be evicted only to swap. The evictions will happen according
* to configured {@link EvictionPolicy}.
+ * <p/>
+ * Size returned by {@link CachePeekMode#OFFHEAP} is always zero, for this mode.
*/
OFFHEAP_VALUES,
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/763bf578/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 84eb0b8..3fac207 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
@@ -54,6 +54,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheInterceptor;
+import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.affinity.Affinity;
@@ -4121,6 +4122,12 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** {@inheritDoc} */
@Override public long offHeapAllocatedSize() {
+ if (ctx.config().getMemoryMode() == CacheMemoryMode.OFFHEAP_VALUES) {
+ assert ctx.unsafeMemory() != null;
+
+ return ctx.unsafeMemory().allocatedSize();
+ }
+
GridCacheSwapManager swapMgr = ctx.swap();
return swapMgr != null ? swapMgr.offHeapAllocatedSize() : -1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/763bf578/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 37b5e15..cbf09bc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentMap;
import javax.cache.Cache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
@@ -85,7 +86,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
/** Flag to indicate if swap is enabled. */
private boolean swapEnabled;
- /** Flag to indicate if offheap is enabled. */
+ /** Flag to indicate if offheap is enabled. {@link CacheMemoryMode#OFFHEAP_VALUES} treated as offheap disabled. */
private boolean offheapEnabled;
/** Swap listeners. */
http://git-wip-us.apache.org/repos/asf/ignite/blob/763bf578/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
index 6fb1280..5561f35 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityNoCacheSelfTest.java
@@ -101,13 +101,15 @@ public class GridAffinityNoCacheSelfTest extends GridCommonAbstractTest {
/**
* @param key Key.
*/
- private void checkAffinityImplCacheDeleted(Object key) {
+ private void checkAffinityImplCacheDeleted(Object key) throws InterruptedException{
IgniteEx grid = grid(0);
final String cacheName = "cacheToBeDeleted";
grid(1).getOrCreateCache(cacheName);
+ awaitPartitionMapExchange();
+
Affinity<Object> affinity = grid.affinity(cacheName);
assertTrue(affinity instanceof GridCacheAffinityImpl);
http://git-wip-us.apache.org/repos/asf/ignite/blob/763bf578/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java
index 9baab33..0efd89b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java
@@ -33,12 +33,18 @@ import org.apache.ignite.testframework.GridTestUtils;
*/
public class GridCacheOffHeapValuesEvictionSelfTest extends GridCacheAbstractSelfTest {
+ /** */
private static final int VAL_SIZE = 512 * 1024; // bytes
+ /** */
private static final int MAX_VALS_AMOUNT = 100;
+ /** */
private static final int MAX_MEMORY_SIZE = MAX_VALS_AMOUNT * VAL_SIZE;
+ /** */
private static final int VALS_AMOUNT = MAX_VALS_AMOUNT * 2;
+ /** */
private static final int THREAD_COUNT = 4;
+ /** {@inheritDoc} */
@Override protected int gridCount() {
return 1;
}
@@ -46,7 +52,7 @@ public class GridCacheOffHeapValuesEvictionSelfTest extends GridCacheAbstractSel
/**
* @throws Exception If failed.
*/
- public void testPutOnHeap() throws Exception {
+ public void testPutValuesOffHeap() throws Exception {
CacheConfiguration<Integer, Object> ccfg = cacheConfiguration(grid(0).name());
ccfg.setName("testPutOffHeapValues");
ccfg.setStatisticsEnabled(true);
@@ -70,6 +76,10 @@ public class GridCacheOffHeapValuesEvictionSelfTest extends GridCacheAbstractSel
assertTrue(MAX_VALS_AMOUNT >= cache.size(CachePeekMode.ONHEAP));
assertTrue(MAX_VALS_AMOUNT - 5 <= cache.size(CachePeekMode.ONHEAP));
assertEquals(cache.size(CachePeekMode.ALL) - cache.size(CachePeekMode.ONHEAP), cache.size(CachePeekMode.SWAP));
+
+ assertTrue((MAX_VALS_AMOUNT + 5) * VAL_SIZE > cache.metrics().getOffHeapAllocatedSize());
+ assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE < cache.metrics().getOffHeapAllocatedSize());
+ assertTrue(cache.metrics().getOffHeapAllocatedSize() >= cache.size(CachePeekMode.ONHEAP) * VAL_SIZE);
}
/**
@@ -109,6 +119,7 @@ public class GridCacheOffHeapValuesEvictionSelfTest extends GridCacheAbstractSel
assertTrue((MAX_VALS_AMOUNT + 5) * VAL_SIZE > cache.metrics().getOffHeapAllocatedSize());
assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE < cache.metrics().getOffHeapAllocatedSize());
+ assertTrue(cache.metrics().getOffHeapAllocatedSize() >= cache.size(CachePeekMode.OFFHEAP) * VAL_SIZE);
}
/**
@@ -146,12 +157,14 @@ public class GridCacheOffHeapValuesEvictionSelfTest extends GridCacheAbstractSel
assertTrue((MAX_VALS_AMOUNT + 5) * VAL_SIZE > cache.metrics().getOffHeapAllocatedSize());
assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE < cache.metrics().getOffHeapAllocatedSize());
+ assertTrue(cache.metrics().getOffHeapAllocatedSize() >= cache.size(CachePeekMode.OFFHEAP) * VAL_SIZE);
}
+ /** Fill cache with values. */
private static void fillCache(final IgniteCache<Integer, Object> cache, long timeout) throws Exception{
final byte[] val = new byte[VAL_SIZE];
final AtomicInteger keyStart = new AtomicInteger(0);
- final CountDownLatch latch = new CountDownLatch(4);
+ final CountDownLatch latch = new CountDownLatch(THREAD_COUNT);
GridTestUtils.runMultiThreaded(new Callable<Void>() {
@Override public Void call() throws Exception {
[07/10] ignite git commit: IGNITE-2430: Fixed binary builder
serialization logic for non-standard collections.
Posted by vo...@apache.org.
IGNITE-2430: Fixed binary builder serialization logic for non-standard collections.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/159b6cb4
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/159b6cb4
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/159b6cb4
Branch: refs/heads/ignite-1786
Commit: 159b6cb4e17da75b77c958f5ad2b7b3fb7596c63
Parents: 35b0e6b
Author: dkarachentsev <dk...@gridgain.com>
Authored: Fri Feb 12 16:02:32 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 12 16:02:32 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/binary/BinaryUtils.java | 4 +-
.../binary/builder/BinaryBuilderSerializer.java | 16 +++-
.../binary/builder/BinaryObjectBuilderImpl.java | 12 ++-
.../binary/builder/BinaryValueWithType.java | 3 +-
.../BinaryObjectBuilderAdditionalSelfTest.java | 91 +++++++++++++++++++-
...naryObjectBuilderDefaultMappersSelfTest.java | 30 +++++--
6 files changed, 141 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index c3343d4..8b5d780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -1055,7 +1055,7 @@ public class BinaryUtils {
* @param cls Class.
* @return {@code True} if this is a special collection class.
*/
- private static boolean isSpecialCollection(Class cls) {
+ public static boolean isSpecialCollection(Class cls) {
return ArrayList.class.equals(cls) || LinkedList.class.equals(cls) ||
HashSet.class.equals(cls) || LinkedHashSet.class.equals(cls);
}
@@ -1066,7 +1066,7 @@ public class BinaryUtils {
* @param cls Class.
* @return {@code True} if this is a special map class.
*/
- private static boolean isSpecialMap(Class cls) {
+ public static boolean isSpecialMap(Class cls) {
return HashMap.class.equals(cls) || LinkedHashMap.class.equals(cls);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
index 6e5a621..b296437 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
@@ -50,6 +50,18 @@ class BinaryBuilderSerializer {
* @param val Value.
*/
public void writeValue(BinaryWriterExImpl writer, Object val) {
+ writeValue(writer, val, false, false);
+ }
+
+ /** *
+ * @param writer Writer.
+ * @param val Value.
+ * @param forceCol Whether to force collection type.
+ * @param forceMap Whether to force map type.
+ */
+ public void writeValue(BinaryWriterExImpl writer, Object val, boolean forceCol, boolean forceMap) {
+ assert !(forceCol && forceMap);
+
if (val == null) {
writer.writeByte(GridBinaryMarshaller.NULL);
@@ -113,7 +125,7 @@ class BinaryBuilderSerializer {
return;
}
- if (val instanceof Collection) {
+ if (forceCol || BinaryUtils.isSpecialCollection(val.getClass())) {
Collection<?> c = (Collection<?>)val;
writer.writeByte(GridBinaryMarshaller.COL);
@@ -129,7 +141,7 @@ class BinaryBuilderSerializer {
return;
}
- if (val instanceof Map) {
+ if (forceMap || BinaryUtils.isSpecialMap(val.getClass())) {
Map<?, ?> map = (Map<?, ?>)val;
writer.writeByte(GridBinaryMarshaller.MAP);
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index e2290d6..9043a8b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.jetbrains.annotations.Nullable;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -508,10 +509,19 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
/** {@inheritDoc} */
@Override public <T> BinaryObjectBuilder setField(String name, @Nullable T val, Class<? super T> type) {
+ byte typeId;
+
+ if (Collection.class.equals(type))
+ typeId = GridBinaryMarshaller.COL;
+ else if (Map.class.equals(type))
+ typeId = GridBinaryMarshaller.MAP;
+ else
+ typeId = BinaryUtils.typeByClass(type);
+
if (assignedVals == null)
assignedVals = new LinkedHashMap<>();
- assignedVals.put(name, new BinaryValueWithType(BinaryUtils.typeByClass(type), val));
+ assignedVals.put(name, new BinaryValueWithType(typeId, val));
return this;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryValueWithType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryValueWithType.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryValueWithType.java
index 9f43bdb..c5a3e0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryValueWithType.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryValueWithType.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.binary.builder;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.util.typedef.internal.S;
/**
@@ -44,7 +45,7 @@ class BinaryValueWithType implements BinaryLazyValue {
if (val instanceof BinaryBuilderSerializationAware)
((BinaryBuilderSerializationAware)val).writeTo(writer, ctx);
else
- ctx.writeValue(writer, val);
+ ctx.writeValue(writer, val, type == GridBinaryMarshaller.COL, type == GridBinaryMarshaller.MAP);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 06e1e93..804c060 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -30,10 +30,10 @@ import org.apache.ignite.binary.BinaryType;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
-import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.builder.BinaryBuilderEnum;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.mutabletest.GridBinaryMarshalerAwareTestClass;
+import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.binary.IgniteBinaryImpl;
import org.apache.ignite.internal.util.lang.GridMapEntry;
@@ -43,12 +43,18 @@ import org.junit.Assert;
import java.lang.reflect.Field;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.sql.Timestamp;
+import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -1261,4 +1267,85 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
processor.binaryContext().userTypeName(aCls.getName()));
}
+
+ /**
+ * Check that correct type is stored in binary object.
+ */
+ public void testCollectionsSerialization() {
+ final BinaryObjectBuilder root = newWrapper(BigInteger.class);
+
+ final List<Integer> arrList = new ArrayList<>();
+
+ arrList.add(Integer.MAX_VALUE);
+
+ final List<Integer> linkedList = new LinkedList<>();
+
+ linkedList.add(Integer.MAX_VALUE);
+
+ final Set<Integer> hashSet = new HashSet<>();
+
+ hashSet.add(Integer.MAX_VALUE);
+
+ final Set<Integer> linkedHashSet = new LinkedHashSet<>();
+
+ linkedHashSet.add(Integer.MAX_VALUE);
+
+ final Map<String, String> hashMap = new HashMap<>();
+
+ hashMap.put("key", "val");
+
+ final Map<String, String> linkedHashMap = new LinkedHashMap<>();
+
+ linkedHashMap.put("key", "val");
+
+ // collections
+ root.setField("arrayList", arrList);
+ root.setField("linkedList", linkedList);
+ root.setField("hashSet", hashSet);
+ root.setField("linkedHashSet", linkedHashSet);
+
+ root.setField("singletonList", Collections.singletonList(Integer.MAX_VALUE), Collection.class);
+ root.setField("singletonSet", Collections.singleton(Integer.MAX_VALUE), Collection.class);
+
+ // maps
+ root.setField("hashMap", hashMap);
+ root.setField("linkedHashMap", linkedHashMap);
+
+ root.setField("singletonMap", Collections.singletonMap("key", "val"), Map.class);
+
+ // objects
+ root.setField("asList", Collections.singletonList(Integer.MAX_VALUE));
+ root.setField("asSet", Collections.singleton(Integer.MAX_VALUE));
+ root.setField("asMap", Collections.singletonMap("key", "val"));
+ root.setField("asListHint", Collections.singletonList(Integer.MAX_VALUE), List.class);
+ root.setField("asSetHint", Collections.singleton(Integer.MAX_VALUE), Set.class);
+ root.setField("asMapHint", (AbstractMap) Collections.singletonMap("key", "val"), AbstractMap.class);
+
+ BinaryObject binaryObj = root.build();
+
+ final String COL = "Collection";
+ final String MAP = "Map";
+ final String OBJ = "Object";
+
+ assert COL.equals(binaryObj.type().fieldTypeName("arrayList"));
+ assert COL.equals(binaryObj.type().fieldTypeName("linkedList"));
+ assert COL.equals(binaryObj.type().fieldTypeName("hashSet"));
+ assert COL.equals(binaryObj.type().fieldTypeName("linkedHashSet"));
+ assert COL.equals(binaryObj.type().fieldTypeName("linkedHashSet"));
+ assert COL.equals(binaryObj.type().fieldTypeName("linkedHashSet"));
+
+ assert COL.equals(binaryObj.type().fieldTypeName("singletonList"));
+ assert COL.equals(binaryObj.type().fieldTypeName("singletonSet"));
+
+ assert MAP.equals(binaryObj.type().fieldTypeName("singletonMap"));
+
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asList"));
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asSet"));
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asMap"));
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asListHint"));
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asSetHint"));
+ assert OBJ.equals(binaryObj.type().fieldTypeName("asMapHint"));
+
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/159b6cb4/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index 990c928..9659c39 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -674,18 +674,24 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder.hashCode(100);
builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
+ builder.setField("collectionField2", Arrays.asList(new Value(1), new Value(2)), Collection.class);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(100, po.hashCode());
- List<BinaryObject> list = po.field("collectionField");
+ List<Value> list = po.field("collectionField");
assertEquals(2, list.size());
+ assertEquals(1, list.get(0).i);
+ assertEquals(2, list.get(1).i);
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
+ List<BinaryObject> list2 = po.field("collectionField2");
+
+ assertEquals(2, list2.size());
+ assertEquals(1, list2.get(0).<Value>deserialize().i);
+ assertEquals(2, list2.get(1).<Value>deserialize().i);
}
/**
@@ -697,17 +703,27 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder.hashCode(100);
builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
+ builder.setField("mapField2", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)), Map.class);
BinaryObject po = builder.build();
assertEquals(expectedHashCode("Class"), po.type().typeId());
assertEquals(100, po.hashCode());
- Map<BinaryObject, BinaryObject> map = po.field("mapField");
+ // Test non-standard map.
+ Map<Key, Value> map = po.field("mapField");
assertEquals(2, map.size());
- for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
+ for (Map.Entry<Key, Value> e : map.entrySet())
+ assertEquals(e.getKey().i, e.getValue().i);
+
+ // Test binary map
+ Map<BinaryObject, BinaryObject> map2 = po.field("mapField2");
+
+ assertEquals(2, map2.size());
+
+ for (Map.Entry<BinaryObject, BinaryObject> e : map2.entrySet())
assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
}
@@ -723,7 +739,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder.setField("f", 111.111f);
builder.setField("iArr", new int[] {1, 2, 3});
builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)), Collection.class);
BinaryObject po = builder.build();
@@ -755,7 +771,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
builder.setField("f", 111.111f);
builder.setField("iArr", new int[] {1, 2, 3});
builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)), Collection.class);
BinaryObject po = builder.build();
[05/10] ignite git commit: IGNITE-2603
Posted by vo...@apache.org.
IGNITE-2603
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a32dfc41
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a32dfc41
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a32dfc41
Branch: refs/heads/ignite-1786
Commit: a32dfc41ea9301f8b98c6a666e4b72c65c892659
Parents: 725d6cb
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Feb 12 14:30:08 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Feb 12 14:30:08 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheProcessor.java | 8 +-
.../GridCacheReplicatedPreloadSelfTest.java | 121 ++++++++++++++-----
.../p2p/CacheDeploymentAffinityKeyMapper.java | 35 ++++++
.../CacheDeploymentAlwaysTruePredicate2.java | 30 +++++
...oymentCacheEntryEventSerializableFilter.java | 32 +++++
.../p2p/CacheDeploymentCacheEntryListener.java | 31 +++++
...CacheDeploymentCachePluginConfiguration.java | 74 ++++++++++++
...heDeploymentStoreSessionListenerFactory.java | 83 +++++++++++++
8 files changed, 383 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/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 5acad6c..7a36e73 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
@@ -3425,8 +3425,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
try {
if (val.getCacheStoreFactory() != null) {
try {
- marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
- val.getCacheStoreFactory().getClass().getClassLoader());
+ ClassLoader ldr = ctx.config().getClassLoader();
+
+ if (ldr == null)
+ ldr = val.getCacheStoreFactory().getClass().getClassLoader();
+
+ marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()), ldr);
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration. " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 887fea4..1fae875 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -26,13 +26,18 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryListener;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.CacheRebalanceMode;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cache.affinity.AffinityFunctionContext;
+import org.apache.ignite.cache.affinity.AffinityKeyMapper;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
@@ -43,6 +48,8 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.plugin.CachePluginConfiguration;
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;
@@ -71,7 +78,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
private int poolSize = 2;
/** */
- private volatile boolean needStore = false;
+ private volatile boolean extClassloadingAtCfg = false;
/** */
private volatile boolean isClient = false;
@@ -136,21 +143,47 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
cacheCfg.setRebalanceBatchSize(batchSize);
cacheCfg.setRebalanceThreadPoolSize(poolSize);
- if (needStore) {
- Object sf = null;
+ if (extClassloadingAtCfg) {
+ loadExternalClassesToCfg(cacheCfg);
+ }
- try {
- sf = getExternalClassLoader().
- loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
- }
- catch (Exception e) {
- throw new RuntimeException(e);
- }
+ return cacheCfg;
+ }
+
+ /**
+ *
+ * @param cacheCfg Configuration.
+ */
+ private void loadExternalClassesToCfg(CacheConfiguration cacheCfg) {
+ try {
+ Object sf = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
cacheCfg.setCacheStoreFactory((Factory)sf);
- }
- return cacheCfg;
+ Object sslf = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentStoreSessionListenerFactory").newInstance();
+
+ cacheCfg.setCacheStoreSessionListenerFactories((Factory)sslf);
+
+ Object cpc = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCachePluginConfiguration").newInstance();
+
+ cacheCfg.setPluginConfigurations((CachePluginConfiguration)cpc);
+
+ Object akm = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAffinityKeyMapper").newInstance();
+
+ cacheCfg.setAffinityMapper((AffinityKeyMapper)akm);
+
+ Object pred = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentAlwaysTruePredicate2").newInstance();
+
+ cacheCfg.setNodeFilter((IgnitePredicate)pred);
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -299,9 +332,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If test failed.
*/
- public void testStore() throws Exception {
+ public void testExternalClassesAtConfiguration() throws Exception {
try {
- needStore = true;
+ extClassloadingAtCfg = true;
useExtClassLoader = true;
Ignite g1 = startGrid(1);
@@ -316,13 +349,47 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
IgniteCache<Integer, Object> cache2 = g2.cache(null);
IgniteCache<Integer, Object> cache3 = g3.cache(null);
+ final Class<CacheEntryListener> cls1 = (Class<CacheEntryListener>) getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCacheEntryListener");
+ final Class<CacheEntryEventSerializableFilter> cls2 = (Class<CacheEntryEventSerializableFilter>) getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentCacheEntryEventSerializableFilter");
+
+ CacheEntryListenerConfiguration<Integer, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ new Factory<CacheEntryListener<Integer, Object>>() {
+ @Override public CacheEntryListener<Integer, Object> create() {
+ try {
+ return cls1.newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ },
+ new Factory<CacheEntryEventSerializableFilter<Integer, Object>>() {
+ /** {@inheritDoc} */
+ @Override public CacheEntryEventSerializableFilter<Integer, Object> create() {
+ try {
+
+ return cls2.newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ },
+ true,
+ true
+ );
+
+ cache1.registerCacheEntryListener(lsnrCfg);
+
cache1.put(1, 1);
assertEquals(1, cache2.get(1));
assertEquals(1, cache3.get(1));
}
finally {
- needStore = false;
+ extClassloadingAtCfg = false;
isClient = false;
useExtClassLoader = false;
}
@@ -331,9 +398,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If test failed.
*/
- public void testStoreDynamicStart() throws Exception {
+ public void testExternalClassesAtConfigurationDynamicStart() throws Exception {
try {
- needStore = false;
+ extClassloadingAtCfg = false;
useExtClassLoader = true;
Ignite g1 = startGrid(1);
@@ -343,12 +410,10 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
Ignite g3 = startGrid(3);
- Object sf = getExternalClassLoader().loadClass(
- "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
-
CacheConfiguration cfg = defaultCacheConfiguration();
- cfg.setCacheStoreFactory((Factory)sf);
+ loadExternalClassesToCfg(cfg);
+
cfg.setName("customStore");
IgniteCache<Integer, Object> cache1 = g1.createCache(cfg);
@@ -362,7 +427,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
assertEquals(1, cache3.get(1));
}
finally {
- needStore = false;
+ extClassloadingAtCfg = false;
isClient = false;
useExtClassLoader = false;
}
@@ -371,9 +436,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If test failed.
*/
- public void testStoreDynamicStart2() throws Exception {
+ public void testExternalClassesAtConfigurationDynamicStart2() throws Exception {
try {
- needStore = false;
+ extClassloadingAtCfg = false;
useExtClassLoader = true;
Ignite g1 = startGrid(1);
@@ -383,12 +448,10 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
Ignite g3 = startGrid(3);
- Object sf = getExternalClassLoader().loadClass(
- "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
-
CacheConfiguration cfg = defaultCacheConfiguration();
- cfg.setCacheStoreFactory((Factory)sf);
+ loadExternalClassesToCfg(cfg);
+
cfg.setName("customStore");
IgniteCache<Integer, Object> cache1 = g1.getOrCreateCache(cfg);
@@ -402,7 +465,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
assertEquals(1, cache3.get(1));
}
finally {
- needStore = false;
+ extClassloadingAtCfg = false;
isClient = false;
useExtClassLoader = false;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAffinityKeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAffinityKeyMapper.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAffinityKeyMapper.java
new file mode 100644
index 0000000..fbb74d2
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAffinityKeyMapper.java
@@ -0,0 +1,35 @@
+/*
+ * 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.tests.p2p;
+
+import org.apache.ignite.cache.affinity.AffinityKeyMapper;
+
+/**
+ * Test affinity ley mapper for cache deployment tests.
+ */
+public class CacheDeploymentAffinityKeyMapper implements AffinityKeyMapper {
+ /** {@inheritDoc} */
+ @Override public Object affinityKey(Object key) {
+ return key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void reset() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate2.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate2.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate2.java
new file mode 100644
index 0000000..d88c7bf
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentAlwaysTruePredicate2.java
@@ -0,0 +1,30 @@
+/*
+ * 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.tests.p2p;
+
+import org.apache.ignite.lang.IgnitePredicate;
+
+/**
+ *
+ */
+public class CacheDeploymentAlwaysTruePredicate2 implements IgnitePredicate<Object> {
+ /** */
+ @Override public boolean apply(Object o) {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryEventSerializableFilter.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryEventSerializableFilter.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryEventSerializableFilter.java
new file mode 100644
index 0000000..c29c1a4
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryEventSerializableFilter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.tests.p2p;
+
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+
+/**
+ *
+ */
+public class CacheDeploymentCacheEntryEventSerializableFilter implements CacheEntryEventSerializableFilter {
+ /** {@inheritDoc} */
+ @Override public boolean evaluate(CacheEntryEvent event) throws CacheEntryListenerException {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryListener.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryListener.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryListener.java
new file mode 100644
index 0000000..64c13fb
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCacheEntryListener.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.tests.p2p;
+
+import javax.cache.event.CacheEntryCreatedListener;
+import javax.cache.event.CacheEntryListenerException;
+
+/**
+ *
+ */
+public class CacheDeploymentCacheEntryListener implements CacheEntryCreatedListener {
+ /** {@inheritDoc} */
+ @Override public void onCreated(Iterable iterable) throws CacheEntryListenerException {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
new file mode 100644
index 0000000..bb37c25
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentCachePluginConfiguration.java
@@ -0,0 +1,74 @@
+/*
+ * 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.tests.p2p;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.plugin.CachePluginConfiguration;
+import org.apache.ignite.plugin.CachePluginContext;
+import org.apache.ignite.plugin.CachePluginProvider;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Test cache plugin configuration for cache deployment tests.
+ */
+public class CacheDeploymentCachePluginConfiguration<K, V> implements CachePluginConfiguration<K, V> {
+ /** {@inheritDoc} */
+ @Override public CachePluginProvider createProvider(CachePluginContext ctx) {
+ return new CacheDeploymentCachePluginProvider();
+ }
+
+ private static class CacheDeploymentCachePluginProvider implements CachePluginProvider {
+ /** {@inheritDoc} */
+ @Nullable @Override public Object createComponent(Class cls) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteCheckedException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop(boolean cancel) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onIgniteStart() throws IgniteCheckedException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onIgniteStop(boolean cancel) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void validate() throws IgniteCheckedException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void validateRemote(CacheConfiguration locCfg, CachePluginConfiguration locPluginCcfg,
+ CacheConfiguration rmtCfg, ClusterNode rmtNode) throws IgniteCheckedException {
+
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a32dfc41/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentStoreSessionListenerFactory.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentStoreSessionListenerFactory.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentStoreSessionListenerFactory.java
new file mode 100644
index 0000000..74d9d21
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentStoreSessionListenerFactory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.tests.p2p;
+
+import javax.cache.configuration.Factory;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.store.CacheStoreSession;
+import org.apache.ignite.cache.store.CacheStoreSessionListener;
+import org.apache.ignite.lifecycle.LifecycleAware;
+
+/**
+ * Test store session listener factory for cache deployment tests.
+ */
+public class CacheDeploymentStoreSessionListenerFactory implements Factory<CacheStoreSessionListener> {
+ /** */
+ private String name;
+
+ /**
+ *
+ */
+ public CacheDeploymentStoreSessionListenerFactory() {
+ }
+
+ /**
+ * @param name Name.
+ */
+ public CacheDeploymentStoreSessionListenerFactory(String name) {
+ this.name = name;
+ }
+
+ @Override public CacheStoreSessionListener create() {
+ return new CacheDeploymentSessionListener(name);
+ }
+
+ /**
+ */
+ private static class CacheDeploymentSessionListener implements CacheStoreSessionListener, LifecycleAware {
+ /** */
+ private final String name;
+
+ /**
+ * @param name Name.
+ */
+ private CacheDeploymentSessionListener(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws IgniteException {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onSessionStart(CacheStoreSession ses) {
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onSessionEnd(CacheStoreSession ses, boolean commit) {
+
+ }
+ }
+}
\ No newline at end of file
[06/10] ignite git commit: Added benchmarks for cache.invoke.
Posted by vo...@apache.org.
Added benchmarks for cache.invoke.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/57236c62
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/57236c62
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/57236c62
Branch: refs/heads/ignite-1786
Commit: 57236c62e3050f602e05647dc71586615f27ec73
Parents: a32dfc4
Author: sboikov <sb...@gridgain.com>
Authored: Fri Feb 12 15:37:32 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Feb 12 15:37:32 2016 +0300
----------------------------------------------------------------------
.../yardstick/cache/IgniteInvokeBenchmark.java | 65 ++++++++++++++++++++
.../cache/IgniteInvokeTxBenchmark.java | 30 +++++++++
2 files changed, 95 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/57236c62/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java
new file mode 100644
index 0000000..a1e80f0
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+import java.util.Map;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Ignite benchmark that performs invoke operations.
+ */
+public class IgniteInvokeBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = nextRandom(args.range());
+
+ cache.invoke(key, new SetValueEntryProcessor(new SampleValue(key)));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic");
+ }
+
+ /**
+ *
+ */
+ public static class SetValueEntryProcessor implements CacheEntryProcessor<Integer, Object, Object> {
+ /** */
+ private Object val;
+
+ /**
+ * @param val Value.
+ */
+ public SetValueEntryProcessor(Object val) {
+ this.val = val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<Integer, Object> entry, Object... args) {
+ entry.setValue(val);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/57236c62/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java
new file mode 100644
index 0000000..8f05598
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * 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.yardstick.cache;
+
+import org.apache.ignite.IgniteCache;
+
+/**
+ * Ignite benchmark that performs invoke operations.
+ */
+public class IgniteInvokeTxBenchmark extends IgniteInvokeBenchmark {
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("tx");
+ }
+}