You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/02/11 06:11:42 UTC
[01/21] ignite git commit: IGNITE-2509 - Fixed evictions for
OFFHEAP_VALUES memory mode - Fixes #452.
Repository: ignite
Updated Branches:
refs/heads/ignite-2542 52e7d9de6 -> b2b11e878
IGNITE-2509 - Fixed evictions for OFFHEAP_VALUES memory mode - Fixes #452.
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/e2e216d7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e2e216d7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e2e216d7
Branch: refs/heads/ignite-2542
Commit: e2e216d7f1295dd350cc2e98a5b704e27aa92a41
Parents: fa246cd
Author: vershov <ve...@gridgain.com>
Authored: Mon Feb 8 21:54:48 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Feb 8 21:54:48 2016 +0300
----------------------------------------------------------------------
.../cache/CacheEvictableEntryImpl.java | 4 +-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 171 +++++++++++++++++++
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
3 files changed, 175 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2e216d7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
index 7cea4f6..9f4d9d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
@@ -103,7 +103,7 @@ public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> {
byte[] valBytes = null;
- if (cctx.useOffheapEntry())
+ if (cctx.offheapTiered())
valBytes = cctx.offheap().get(cctx.swap().spaceName(), cached.partition(), key, keyBytes);
else {
CacheObject cacheObj = cached.valueBytes();
@@ -231,4 +231,4 @@ public class CacheEvictableEntryImpl<K, V> implements EvictableEntry<K, V> {
@Override public String toString() {
return S.toString(CacheEvictableEntryImpl.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2e216d7/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
new file mode 100644
index 0000000..9baab33
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapValuesEvictionSelfTest.java
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Test for eviction with offHeap.
+ */
+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;
+
+ @Override protected int gridCount() {
+ return 1;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPutOnHeap() throws Exception {
+ CacheConfiguration<Integer, Object> ccfg = cacheConfiguration(grid(0).name());
+ ccfg.setName("testPutOffHeapValues");
+ ccfg.setStatisticsEnabled(true);
+ ccfg.setOffHeapMaxMemory(MAX_MEMORY_SIZE);
+
+ FifoEvictionPolicy plc = new FifoEvictionPolicy();
+ plc.setMaxMemorySize(MAX_MEMORY_SIZE);
+
+ ccfg.setSwapEnabled(true);
+ ccfg.setMemoryMode(CacheMemoryMode.OFFHEAP_VALUES);
+
+ ccfg.setEvictionPolicy(plc);
+
+ final IgniteCache<Integer, Object> cache = grid(0).getOrCreateCache(ccfg);
+
+ fillCache(cache, getTestTimeout());
+
+ assertEquals(VALS_AMOUNT * THREAD_COUNT, cache.size(CachePeekMode.ALL));
+ assertEquals(0, cache.size(CachePeekMode.NEAR));
+ assertEquals(0, cache.size(CachePeekMode.OFFHEAP));
+ 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));
+ }
+
+ /**
+ * swap disabled -> entries discarded
+ * @throws Exception If failed.
+ */
+ public void testPutOnHeapWithOffHeap() throws Exception {
+ final int PLC_MAX_SIZE = 50;
+
+ CacheConfiguration<Integer, Object> ccfg = cacheConfiguration(grid(0).name());
+ ccfg.setName("testPutOnHeapWithOffHeap");
+ ccfg.setStatisticsEnabled(true);
+ ccfg.setOffHeapMaxMemory(MAX_MEMORY_SIZE);
+
+ FifoEvictionPolicy plc = new FifoEvictionPolicy();
+ plc.setMaxMemorySize(MAX_MEMORY_SIZE);
+ plc.setMaxSize(PLC_MAX_SIZE);
+
+ ccfg.setSwapEnabled(false);
+ ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
+
+ ccfg.setEvictionPolicy(plc);
+
+ final IgniteCache<Integer, Object> cache = grid(0).getOrCreateCache(ccfg);
+
+ fillCache(cache, getTestTimeout());
+
+ assertEquals(cache.size(CachePeekMode.ONHEAP) + cache.size(CachePeekMode.OFFHEAP), cache.size(CachePeekMode.ALL));
+ assertEquals(0, cache.size(CachePeekMode.NEAR));
+ assertEquals(0, cache.size(CachePeekMode.SWAP));
+ assertTrue(PLC_MAX_SIZE >= cache.size(CachePeekMode.ONHEAP));
+ assertTrue(PLC_MAX_SIZE - 5 <= cache.size(CachePeekMode.ONHEAP));
+ assertTrue(MAX_VALS_AMOUNT >= cache.size(CachePeekMode.OFFHEAP));
+ assertTrue(MAX_VALS_AMOUNT - 5 <= cache.size(CachePeekMode.OFFHEAP));
+ assertEquals(cache.size(CachePeekMode.ALL) - cache.size(CachePeekMode.ONHEAP) - cache.size(CachePeekMode.OFFHEAP),
+ cache.size(CachePeekMode.SWAP));
+
+ assertTrue((MAX_VALS_AMOUNT + 5) * VAL_SIZE > cache.metrics().getOffHeapAllocatedSize());
+ assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE < cache.metrics().getOffHeapAllocatedSize());
+ }
+
+ /**
+ * swap enabled -> entries are not discarded
+ * @throws Exception
+ */
+ public void testOnHeapWithOffHeapSwap() throws Exception{
+ final int PLC_MAX_SIZE = 50;
+
+ CacheConfiguration<Integer, Object> ccfg = cacheConfiguration(grid(0).name());
+ ccfg.setName("testOnHeapWithOffHeapSwap");
+ ccfg.setStatisticsEnabled(true);
+ ccfg.setOffHeapMaxMemory(MAX_MEMORY_SIZE);
+
+ FifoEvictionPolicy plc = new FifoEvictionPolicy();
+ plc.setMaxMemorySize(MAX_MEMORY_SIZE);
+ plc.setMaxSize(PLC_MAX_SIZE);
+
+ ccfg.setSwapEnabled(true);
+ ccfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
+
+ ccfg.setEvictionPolicy(plc);
+
+ final IgniteCache<Integer, Object> cache = grid(0).getOrCreateCache(ccfg);
+
+ fillCache(cache, getTestTimeout());
+
+ assertEquals(cache.size(CachePeekMode.SWAP) + cache.size(CachePeekMode.ONHEAP) +
+ cache.size(CachePeekMode.OFFHEAP), cache.size(CachePeekMode.ALL));
+
+ assertTrue(PLC_MAX_SIZE >= cache.size(CachePeekMode.ONHEAP));
+ assertTrue(PLC_MAX_SIZE - 5 <= cache.size(CachePeekMode.ONHEAP));
+ assertTrue(MAX_VALS_AMOUNT >= cache.size(CachePeekMode.OFFHEAP));
+ assertTrue(MAX_VALS_AMOUNT - 5 <= cache.size(CachePeekMode.OFFHEAP));
+
+ assertTrue((MAX_VALS_AMOUNT + 5) * VAL_SIZE > cache.metrics().getOffHeapAllocatedSize());
+ assertTrue((MAX_VALS_AMOUNT - 5) * VAL_SIZE < cache.metrics().getOffHeapAllocatedSize());
+ }
+
+ 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);
+
+ GridTestUtils.runMultiThreaded(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ final int start = keyStart.addAndGet(VALS_AMOUNT);
+
+ for (int i = start; i < start + VALS_AMOUNT; i++)
+ cache.put(i, val);
+
+ latch.countDown();
+
+ return null;
+ }
+ }, THREAD_COUNT, "test");
+
+ latch.await(timeout, TimeUnit.MILLISECONDS);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2e216d7/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 88d0834..90125b1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -65,6 +65,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredAtomicS
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredEvictionSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheOffHeapTieredSelfTest;
+import org.apache.ignite.internal.processors.cache.GridCacheOffHeapValuesEvictionSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheP2PUndeploySelfTest;
import org.apache.ignite.internal.processors.cache.GridCachePartitionedLocalStoreSelfTest;
import org.apache.ignite.internal.processors.cache.GridCachePartitionedOffHeapLocalStoreSelfTest;
@@ -247,6 +248,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheStorePutxSelfTest.class);
suite.addTestSuite(GridCacheOffHeapMultiThreadedUpdateSelfTest.class);
suite.addTestSuite(GridCacheOffHeapAtomicMultiThreadedUpdateSelfTest.class);
+ suite.addTestSuite(GridCacheOffHeapValuesEvictionSelfTest.class);
suite.addTestSuite(GridCacheColocatedTxStoreExceptionSelfTest.class);
suite.addTestSuite(GridCacheReplicatedTxStoreExceptionSelfTest.class);
suite.addTestSuite(GridCacheLocalTxStoreExceptionSelfTest.class);
[18/21] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@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/d08a7790
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d08a7790
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d08a7790
Branch: refs/heads/ignite-2542
Commit: d08a779083634b2d332961c8ae098e2e2cf041ed
Parents: 008c8cd 14824a1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 10 15:46:36 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 15:46:36 2016 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 4 +-
...niteCacheEntryListenerExpiredEventsTest.java | 202 +++++++++++++++++++
.../cache/CacheQueryBuildValueTest.java | 144 +++++++++++++
3 files changed, 348 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
[09/21] ignite git commit: ignite-2587 Fixed continuous query
notifications in offheap mode and BinaryObjectOffheapImpl usage.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapValuesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapValuesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapValuesTest.java
new file mode 100644
index 0000000..2994af6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapValuesTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryTxOffheapValuesTest extends GridCacheContinuousQueryTxSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_VALUES;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 949290e..4fcc1ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -941,7 +941,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
* @param cacheName Cache name.
* @return Near cache for key.
*/
- protected IgniteCache<Integer, Integer> primaryCache(Integer key, String cacheName) {
+ protected <K, V> IgniteCache<K, V> primaryCache(Object key, String cacheName) {
return primaryNode(key, cacheName).cache(cacheName);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 90125b1..5af37a6 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -86,10 +86,14 @@ import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPrimaryWrite
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheAtomicStopBusySelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicLocalTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicOffheapTieredTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicOffheapValuesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicReplicatedTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerAtomicTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerEagerTtlDisabledTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerTxLocalTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerTxOffheapTieredTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerTxOffheapValuesTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerTxReplicatedTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryListenerTxTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheEntryProcessorCallTest;
@@ -156,9 +160,13 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheEntryListenerAtomicReplicatedTest.class);
suite.addTestSuite(IgniteCacheEntryListenerAtomicLocalTest.class);
suite.addTestSuite(IgniteCacheEntryListenerTxTest.class);
+ suite.addTestSuite(IgniteCacheEntryListenerTxOffheapTieredTest.class);
+ suite.addTestSuite(IgniteCacheEntryListenerTxOffheapValuesTest.class);
suite.addTestSuite(IgniteCacheEntryListenerTxReplicatedTest.class);
suite.addTestSuite(IgniteCacheEntryListenerTxLocalTest.class);
suite.addTestSuite(IgniteCacheEntryListenerEagerTtlDisabledTest.class);
+ suite.addTestSuite(IgniteCacheEntryListenerAtomicOffheapTieredTest.class);
+ suite.addTestSuite(IgniteCacheEntryListenerAtomicOffheapValuesTest.class);
suite.addTestSuite(IgniteClientAffinityAssignmentSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/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 359cdf3..3cd4579 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
@@ -70,11 +70,16 @@ import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQ
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.GridCacheSwapScanQuerySelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicReplicatedSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxOffheapTieredTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxReplicatedSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryRandomOperationsTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapTieredTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicOffheapValuesTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
@@ -89,6 +94,8 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedTxOneNodeTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedP2PDisabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxOffheapTieredTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxOffheapValuesTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryTxSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest;
import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest;
@@ -181,9 +188,13 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(GridCacheContinuousQueryPartitionedOnlySelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryPartitionedP2PDisabledSelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryTxSelfTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryTxOffheapTieredTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryTxOffheapValuesTest.class);
suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryAtomicOffheapTieredTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryAtomicOffheapValuesTest.class);
suite.addTestSuite(GridCacheContinuousQueryReplicatedTxOneNodeTest.class);
suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicOneNodeTest.class);
suite.addTestSuite(GridCacheContinuousQueryPartitionTxOneNodeTest.class);
@@ -195,6 +206,9 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(CacheContinuousQueryFailoverAtomicReplicatedSelfTest.class);
suite.addTestSuite(CacheContinuousQueryFailoverTxSelfTest.class);
suite.addTestSuite(CacheContinuousQueryFailoverTxReplicatedSelfTest.class);
+ suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.class);
+ suite.addTestSuite(CacheContinuousQueryFailoverTxOffheapTieredTest.class);
+ suite.addTestSuite(CacheContinuousQueryRandomOperationsTest.class);
// Reduce fields queries.
suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class);
[06/21] ignite git commit: IGNITE-2575: Added validation of IGFS
endpoint port value. This closes #469.
Posted by sb...@apache.org.
IGNITE-2575: Added validation of IGFS endpoint port value. This closes #469.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b7475f09
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b7475f09
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b7475f09
Branch: refs/heads/ignite-2542
Commit: b7475f09b1727e5cc93681ee229b60ad8e188732
Parents: a4d8a04
Author: dkarachentsev <dk...@gridgain.com>
Authored: Wed Feb 10 12:38:43 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 12:38:43 2016 +0300
----------------------------------------------------------------------
.../internal/processors/igfs/IgfsProcessor.java | 14 ++++++++++
.../igfs/IgfsProcessorValidationSelfTest.java | 27 ++++++++++++++++++++
2 files changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b7475f09/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
index 21446e1..1b60252 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsProcessor.java
@@ -67,6 +67,12 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
/** Null IGFS name. */
private static final String NULL_NAME = UUID.randomUUID().toString();
+ /** Min available TCP port. */
+ private static final int MIN_TCP_PORT = 1;
+
+ /** Max available TCP port. */
+ private static final int MAX_TCP_PORT = 0xFFFF;
+
/** Converts context to IGFS. */
private static final IgniteClosure<IgfsContext,IgniteFileSystem> CTX_TO_IGFS = new C1<IgfsContext, IgniteFileSystem>() {
@Override public IgniteFileSystem apply(IgfsContext igfsCtx) {
@@ -307,6 +313,14 @@ public class IgfsProcessor extends IgfsProcessorAdapter {
throw new IgniteCheckedException("Invalid IGFS data cache configuration (key affinity mapper class should be " +
IgfsGroupDataBlocksKeyMapper.class.getSimpleName() + "): " + cfg);
+ if (cfg.getIpcEndpointConfiguration() != null) {
+ final int tcpPort = cfg.getIpcEndpointConfiguration().getPort();
+
+ if (!(tcpPort >= MIN_TCP_PORT && tcpPort <= MAX_TCP_PORT))
+ throw new IgniteCheckedException("IGFS endpoint TCP port is out of range [" + MIN_TCP_PORT +
+ ".." + MAX_TCP_PORT + "]: " + tcpPort);
+ }
+
long maxSpaceSize = cfg.getMaxSpaceSize();
if (maxSpaceSize > 0) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/b7475f09/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
index 11a80af..27f47e8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsProcessorValidationSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper;
+import org.apache.ignite.igfs.IgfsIpcEndpointConfiguration;
import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMapper;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -442,6 +443,32 @@ public class IgfsProcessorValidationSelfTest extends IgfsCommonAbstractTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testInvalidEndpointTcpPort() throws Exception {
+ final String failMsg = "IGFS endpoint TCP port is out of range";
+ g1Cfg.setCacheConfiguration(concat(dataCaches(1024), metaCaches(), CacheConfiguration.class));
+
+ final String igfsCfgName = "igfs-cfg";
+ final IgfsIpcEndpointConfiguration igfsEndpointCfg = new IgfsIpcEndpointConfiguration();
+ igfsEndpointCfg.setPort(0);
+ g1IgfsCfg1.setName(igfsCfgName);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+
+ igfsEndpointCfg.setPort(-1);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+
+ igfsEndpointCfg.setPort(65536);
+ g1IgfsCfg1.setIpcEndpointConfiguration(igfsEndpointCfg);
+
+ checkGridStartFails(g1Cfg, failMsg, true);
+ }
+
+ /**
* Checks that the given grid configuration will lead to {@link IgniteCheckedException} upon grid startup.
*
* @param cfg Grid configuration to check.
[20/21] ignite git commit: added missing file header to
org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactorySelfTest
Posted by sb...@apache.org.
added missing file header to org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactorySelfTest
Signed-off-by: Anton Vinogradov <av...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0491a5f8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0491a5f8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0491a5f8
Branch: refs/heads/ignite-2542
Commit: 0491a5f814365723b53ff1820aad76f646307f13
Parents: a9937a6
Author: iveselovskiy <iv...@gridgain.com>
Authored: Wed Feb 10 18:54:36 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Feb 10 19:31:41 2016 +0300
----------------------------------------------------------------------
.../KerberosHadoopFileSystemFactorySelfTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0491a5f8/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
index 8fb1612..ea7fa99 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
@@ -1,3 +1,20 @@
+/*
+ * 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.hadoop.fs;
import java.io.ByteArrayInputStream;
[05/21] ignite git commit: IGNITE-2380: Added ability to start Ignite
using configuration from app.config. This closes #417.
Posted by sb...@apache.org.
IGNITE-2380: Added ability to start Ignite using configuration from app.config. This closes #417.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a4d8a049
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a4d8a049
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a4d8a049
Branch: refs/heads/ignite-2542
Commit: a4d8a049138a4d4bc86a59ccb273f7e214baf694
Parents: f7c1296
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Feb 9 14:54:20 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Feb 9 14:54:20 2016 +0300
----------------------------------------------------------------------
.../Apache.Ignite.Core.Tests.csproj | 4 +
.../Apache.Ignite.Core.Tests/FutureTest.cs | 1 +
.../IgniteConfigurationSectionTest.cs | 69 +++
.../IgniteConfigurationSerializerTest.cs | 554 +++++++++++++++++++
.../dotnet/Apache.Ignite.Core.Tests/app.config | 54 ++
.../Apache.Ignite.Core.csproj | 11 +
.../Binary/IBinarySerializer.cs | 6 +-
.../IgniteConfigurationSection.cs | 80 +++
.../IgniteConfigurationSection.xsd | 281 ++++++++++
.../dotnet/Apache.Ignite.Core/Ignition.cs | 39 ++
.../Impl/Common/BooleanLowerCaseConverter.cs | 60 ++
.../Common/IgniteConfigurationXmlSerializer.cs | 410 ++++++++++++++
.../Impl/Common/TypeStringConverter.cs | 115 ++++
.../Impl/Events/EventTypeConverter.cs | 133 +++++
14 files changed, 1814 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index f5e98c5..fb14ed5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -55,6 +55,7 @@
<HintPath>..\libs\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
+ <Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.XML" />
@@ -117,6 +118,8 @@
<Compile Include="ExceptionsTest.cs" />
<Compile Include="ExecutableTest.cs" />
<Compile Include="FutureTest.cs" />
+ <Compile Include="IgniteConfigurationSectionTest.cs" />
+ <Compile Include="IgniteConfigurationSerializerTest.cs" />
<Compile Include="IgniteConfigurationTest.cs" />
<Compile Include="IgniteTestBase.cs" />
<Compile Include="LifecycleTest.cs" />
@@ -251,6 +254,7 @@
<ItemGroup>
<None Include="Apache.Ignite.Core.Tests.nunit" />
<None Include="Apache.Ignite.Core.Tests.snk" />
+ <None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
index f18be8c..bc1f08f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/FutureTest.cs
@@ -67,6 +67,7 @@ namespace Apache.Ignite.Core.Tests
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
+ Ignition.StopAll(true);
TestUtils.KillProcesses();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
new file mode 100644
index 0000000..29aea90
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSectionTest.cs
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.Configuration;
+ using System.Linq;
+ using Apache.Ignite.Core.Impl.Common;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests <see cref="IgniteConfigurationSection"/>.
+ /// </summary>
+ public class IgniteConfigurationSectionTest
+ {
+ /// <summary>
+ /// Tests the read.
+ /// </summary>
+ [Test]
+ public void TestRead()
+ {
+ var section = (IgniteConfigurationSection) ConfigurationManager.GetSection("igniteConfiguration");
+
+ Assert.AreEqual("myGrid1", section.IgniteConfiguration.GridName);
+ Assert.AreEqual("cacheName", section.IgniteConfiguration.CacheConfiguration.Single().Name);
+ }
+
+ /// <summary>
+ /// Tests the ignite start.
+ /// </summary>
+ [Test]
+ public void TestIgniteStart()
+ {
+ Environment.SetEnvironmentVariable(Classpath.EnvIgniteNativeTestClasspath, "true");
+
+ using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration"))
+ {
+ Assert.AreEqual("myGrid1", ignite.Name);
+ Assert.IsNotNull(ignite.GetCache<int, int>("cacheName"));
+ }
+
+ using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration2"))
+ {
+ Assert.AreEqual("myGrid2", ignite.Name);
+ Assert.IsNotNull(ignite.GetCache<int, int>("cacheName2"));
+ }
+
+ using (var ignite = Ignition.StartFromApplicationConfiguration())
+ {
+ Assert.IsTrue(ignite.Name.StartsWith("myGrid"));
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
new file mode 100644
index 0000000..d8c52ee
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationSerializerTest.cs
@@ -0,0 +1,554 @@
+/*
+ * 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.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using System.Threading;
+ using System.Xml;
+ using System.Xml.Schema;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Impl.Common;
+ using Apache.Ignite.Core.Lifecycle;
+ using Apache.Ignite.Core.Tests.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests <see cref="IgniteConfiguration"/> serialization.
+ /// </summary>
+ public class IgniteConfigurationSerializerTest
+ {
+ /// <summary>
+ /// Tests the predefined XML.
+ /// </summary>
+ [Test]
+ public void TestPredefinedXml()
+ {
+ var xml = @"<igniteConfig workDirectory='c:' JvmMaxMemoryMb='1024' MetricsLogFrequency='0:0:10'>
+ <localhost>127.1.1.1</localhost>
+ <binaryConfiguration>
+ <defaultNameMapper type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+NameMapper, Apache.Ignite.Core.Tests' bar='testBar' />
+ <types>
+ <string>Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+FooClass, Apache.Ignite.Core.Tests</string>
+ </types>
+ </binaryConfiguration>
+ <discoverySpi type='TcpDiscoverySpi' joinTimeout='0:1:0'>
+ <ipFinder type='TcpDiscoveryMulticastIpFinder' addressRequestAttempts='7' />
+ </discoverySpi>
+ <jvmOptions><string>-Xms1g</string><string>-Xmx4g</string></jvmOptions>
+ <lifecycleBeans>
+ <iLifecycleBean type='Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+LifecycleBean, Apache.Ignite.Core.Tests' foo='15' />
+ </lifecycleBeans>
+ <cacheConfiguration>
+ <cacheConfiguration cacheMode='Replicated'>
+ <queryEntities>
+ <queryEntity keyType='System.Int32' valueType='System.String'>
+ <fields>
+ <queryField name='length' fieldType='System.Int32' />
+ </fields>
+ <aliases>
+ <queryAlias fullName='somefield.field' alias='shortField' />
+ </aliases>
+ <indexes>
+ <queryIndex name='idx' indexType='Geospatial'>
+ <fields>
+ <queryIndexField name='indexFld' isDescending='true' />
+ </fields>
+ </queryIndex>
+ </indexes>
+ </queryEntity>
+ </queryEntities>
+ </cacheConfiguration>
+ <cacheConfiguration name='secondCache' />
+ </cacheConfiguration>
+ <includedEventTypes>
+ <int>42</int>
+ <int>TaskFailed</int>
+ <int>JobFinished</int>
+ </includedEventTypes>
+ </igniteConfig>";
+ var reader = XmlReader.Create(new StringReader(xml));
+
+ var cfg = IgniteConfigurationXmlSerializer.Deserialize(reader);
+
+ Assert.AreEqual("c:", cfg.WorkDirectory);
+ Assert.AreEqual("127.1.1.1", cfg.Localhost);
+ Assert.AreEqual(1024, cfg.JvmMaxMemoryMb);
+ Assert.AreEqual(TimeSpan.FromSeconds(10), cfg.MetricsLogFrequency);
+ Assert.AreEqual(TimeSpan.FromMinutes(1), ((TcpDiscoverySpi)cfg.DiscoverySpi).JoinTimeout);
+ Assert.AreEqual(7,
+ ((TcpDiscoveryMulticastIpFinder) ((TcpDiscoverySpi) cfg.DiscoverySpi).IpFinder).AddressRequestAttempts);
+ Assert.AreEqual(new[] { "-Xms1g", "-Xmx4g" }, cfg.JvmOptions);
+ Assert.AreEqual(15, ((LifecycleBean) cfg.LifecycleBeans.Single()).Foo);
+ Assert.AreEqual("testBar", ((NameMapper) cfg.BinaryConfiguration.DefaultNameMapper).Bar);
+ Assert.AreEqual(
+ "Apache.Ignite.Core.Tests.IgniteConfigurationSerializerTest+FooClass, Apache.Ignite.Core.Tests",
+ cfg.BinaryConfiguration.Types.Single());
+ Assert.AreEqual(new[] {42, EventType.TaskFailed, EventType.JobFinished}, cfg.IncludedEventTypes);
+
+ Assert.AreEqual("secondCache", cfg.CacheConfiguration.Last().Name);
+
+ var cacheCfg = cfg.CacheConfiguration.First();
+
+ Assert.AreEqual(CacheMode.Replicated, cacheCfg.CacheMode);
+
+ var queryEntity = cacheCfg.QueryEntities.Single();
+ Assert.AreEqual(typeof(int), queryEntity.KeyType);
+ Assert.AreEqual(typeof(string), queryEntity.ValueType);
+ Assert.AreEqual("length", queryEntity.Fields.Single().Name);
+ Assert.AreEqual(typeof(int), queryEntity.Fields.Single().FieldType);
+ Assert.AreEqual("somefield.field", queryEntity.Aliases.Single().FullName);
+ Assert.AreEqual("shortField", queryEntity.Aliases.Single().Alias);
+ Assert.AreEqual(QueryIndexType.Geospatial, queryEntity.Indexes.Single().IndexType);
+ Assert.AreEqual("indexFld", queryEntity.Indexes.Single().Fields.Single().Name);
+ Assert.AreEqual(true, queryEntity.Indexes.Single().Fields.Single().IsDescending);
+ }
+
+ /// <summary>
+ /// Tests the serialize deserialize.
+ /// </summary>
+ [Test]
+ public void TestSerializeDeserialize()
+ {
+ // Test custom
+ CheckSerializeDeserialize(GetTestConfig());
+
+ // Test custom with different culture to make sure numbers are serialized properly
+ RunWithCustomCulture(() => CheckSerializeDeserialize(GetTestConfig()));
+
+ // Test default
+ CheckSerializeDeserialize(new IgniteConfiguration());
+ }
+
+ /// <summary>
+ /// Tests the schema validation.
+ /// </summary>
+ [Test]
+ public void TestSchemaValidation()
+ {
+ CheckSchemaValidation();
+
+ RunWithCustomCulture(CheckSchemaValidation);
+
+ // Check invalid xml
+ const string invalidXml =
+ @"<igniteConfiguration xmlns='http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection'>
+ <binaryConfiguration /><binaryConfiguration />
+ </igniteConfiguration>";
+
+ Assert.Throws<XmlSchemaValidationException>(() => CheckSchemaValidation(invalidXml));
+ }
+
+ /// <summary>
+ /// Checks the schema validation.
+ /// </summary>
+ private static void CheckSchemaValidation()
+ {
+ var sb = new StringBuilder();
+
+ using (var xmlWriter = XmlWriter.Create(sb))
+ {
+ IgniteConfigurationXmlSerializer.Serialize(GetTestConfig(), xmlWriter, "igniteConfiguration");
+ }
+
+ CheckSchemaValidation(sb.ToString());
+ }
+
+ /// <summary>
+ /// Checks the schema validation.
+ /// </summary>
+ /// <param name="xml">The XML.</param>
+ private static void CheckSchemaValidation(string xml)
+ {
+ var document = new XmlDocument();
+
+ document.Schemas.Add("http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection",
+ XmlReader.Create("IgniteConfigurationSection.xsd"));
+
+ document.Load(new StringReader(xml));
+
+ document.Validate(null);
+ }
+
+ /// <summary>
+ /// Checks the serialize deserialize.
+ /// </summary>
+ /// <param name="cfg">The config.</param>
+ private static void CheckSerializeDeserialize(IgniteConfiguration cfg)
+ {
+ var resCfg = SerializeDeserialize(cfg);
+
+ AssertReflectionEqual(cfg, resCfg);
+ }
+
+ /// <summary>
+ /// Serializes and deserializes a config.
+ /// </summary>
+ private static IgniteConfiguration SerializeDeserialize(IgniteConfiguration cfg)
+ {
+ var sb = new StringBuilder();
+
+ using (var xmlWriter = XmlWriter.Create(sb))
+ {
+ IgniteConfigurationXmlSerializer.Serialize(cfg, xmlWriter, "igniteConfig");
+ }
+
+ var xml = sb.ToString();
+
+ using (var xmlReader = XmlReader.Create(new StringReader(xml)))
+ {
+ xmlReader.MoveToContent();
+ return IgniteConfigurationXmlSerializer.Deserialize(xmlReader);
+ }
+ }
+
+ /// <summary>
+ /// Asserts equality with reflection.
+ /// </summary>
+ private static void AssertReflectionEqual(object x, object y)
+ {
+ var type = x.GetType();
+
+ Assert.AreEqual(type, y.GetType());
+
+ if (type.IsValueType || type == typeof (string) || type.IsSubclassOf(typeof (Type)))
+ {
+ Assert.AreEqual(x, y);
+ return;
+ }
+
+ var props = type.GetProperties();
+
+ foreach (var propInfo in props)
+ {
+ var propType = propInfo.PropertyType;
+
+ var xVal = propInfo.GetValue(x, null);
+ var yVal = propInfo.GetValue(y, null);
+
+ if (xVal == null || yVal == null)
+ {
+ Assert.IsNull(xVal);
+ Assert.IsNull(yVal);
+ }
+ else if (propType != typeof(string) && propType.IsGenericType
+ && propType.GetGenericTypeDefinition() == typeof (ICollection<>))
+ {
+ var xCol = ((IEnumerable) xVal).OfType<object>().ToList();
+ var yCol = ((IEnumerable) yVal).OfType<object>().ToList();
+
+ Assert.AreEqual(xCol.Count, yCol.Count);
+
+ for (int i = 0; i < xCol.Count; i++)
+ AssertReflectionEqual(xCol[i], yCol[i]);
+ }
+ else
+ {
+ AssertReflectionEqual(xVal, yVal);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the test configuration.
+ /// </summary>
+ private static IgniteConfiguration GetTestConfig()
+ {
+ return new IgniteConfiguration
+ {
+ GridName = "gridName",
+ JvmOptions = new[] {"1", "2"},
+ Localhost = "localhost11",
+ JvmClasspath = "classpath",
+ Assemblies = new[] {"asm1", "asm2", "asm3"},
+ BinaryConfiguration = new BinaryConfiguration
+ {
+ TypeConfigurations = new[]
+ {
+ new BinaryTypeConfiguration
+ {
+ IsEnum = true,
+ KeepDeserialized = true,
+ AffinityKeyFieldName = "affKeyFieldName",
+ TypeName = "typeName",
+ IdMapper = new IdMapper(),
+ NameMapper = new NameMapper(),
+ Serializer = new TestSerializer()
+ }
+ },
+ DefaultIdMapper = new IdMapper(),
+ DefaultKeepDeserialized = true,
+ DefaultNameMapper = new NameMapper(),
+ DefaultSerializer = new TestSerializer()
+ },
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration("cacheName")
+ {
+ AtomicWriteOrderMode = CacheAtomicWriteOrderMode.Primary,
+ AtomicityMode = CacheAtomicityMode.Transactional,
+ Backups = 15,
+ CacheMode = CacheMode.Partitioned,
+ CacheStoreFactory = new TestCacheStoreFactory(),
+ CopyOnRead = true,
+ EagerTtl = true,
+ EnableSwap = true,
+ EvictSynchronized = true,
+ EvictSynchronizedConcurrencyLevel = 13,
+ EvictSynchronizedKeyBufferSize = 14,
+ EvictSynchronizedTimeout = TimeSpan.FromMinutes(3),
+ Invalidate = true,
+ KeepBinaryInStore = true,
+ LoadPreviousValue = true,
+ LockTimeout = TimeSpan.FromSeconds(56),
+ LongQueryWarningTimeout = TimeSpan.FromSeconds(99),
+ MaxConcurrentAsyncOperations = 24,
+ MaxEvictionOverflowRatio = 5.6F,
+ MemoryMode = CacheMemoryMode.OffheapValues,
+ OffHeapMaxMemory = 567,
+ QueryEntities = new[]
+ {
+ new QueryEntity
+ {
+ Fields = new[]
+ {
+ new QueryField("field", typeof (int))
+ },
+ Indexes = new[]
+ {
+ new QueryIndex("field") { IndexType = QueryIndexType.FullText }
+ },
+ Aliases = new[]
+ {
+ new QueryAlias("field.field", "fld")
+ },
+ KeyType = typeof (string),
+ ValueType = typeof (long)
+ },
+ },
+ ReadFromBackup = true,
+ RebalanceBatchSize = 33,
+ RebalanceDelay = TimeSpan.MaxValue,
+ RebalanceMode = CacheRebalanceMode.Sync,
+ RebalanceThrottle = TimeSpan.FromHours(44),
+ RebalanceTimeout = TimeSpan.FromMinutes(8),
+ SqlEscapeAll = true,
+ SqlOnheapRowCacheSize = 679,
+ StartSize = 1023,
+ WriteBehindBatchSize = 45,
+ WriteBehindEnabled = true,
+ WriteBehindFlushFrequency = TimeSpan.FromSeconds(5),
+ WriteBehindFlushSize = 66,
+ WriteBehindFlushThreadCount = 2,
+ WriteSynchronizationMode = CacheWriteSynchronizationMode.FullAsync
+ }
+ },
+ ClientMode = true,
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ NetworkTimeout = TimeSpan.FromSeconds(1),
+ SocketTimeout = TimeSpan.FromSeconds(2),
+ AckTimeout = TimeSpan.FromSeconds(3),
+ JoinTimeout = TimeSpan.FromSeconds(4),
+ MaxAckTimeout = TimeSpan.FromSeconds(5),
+ IpFinder = new TcpDiscoveryMulticastIpFinder
+ {
+ TimeToLive = 110,
+ MulticastGroup = "multicastGroup",
+ AddressRequestAttempts = 10,
+ MulticastPort = 987,
+ ResponseTimeout = TimeSpan.FromDays(1),
+ LocalAddress = "127.0.0.2",
+ Endpoints = new[] {"", "abc"}
+ }
+ },
+ IgniteHome = "igniteHome",
+ IncludedEventTypes = EventType.CacheQueryAll,
+ JvmDllPath = @"c:\jvm",
+ JvmInitialMemoryMb = 1024,
+ JvmMaxMemoryMb = 2048,
+ LifecycleBeans = new[] {new LifecycleBean(), new LifecycleBean() },
+ MetricsExpireTime = TimeSpan.FromSeconds(15),
+ MetricsHistorySize = 45,
+ MetricsLogFrequency = TimeSpan.FromDays(2),
+ MetricsUpdateFrequency = TimeSpan.MinValue,
+ NetworkSendRetryCount = 7,
+ NetworkSendRetryDelay = TimeSpan.FromSeconds(98),
+ NetworkTimeout = TimeSpan.FromMinutes(4),
+ SuppressWarnings = true,
+ WorkDirectory = @"c:\work"
+ };
+ }
+
+ /// <summary>
+ /// Runs the with custom culture.
+ /// </summary>
+ /// <param name="action">The action.</param>
+ private static void RunWithCustomCulture(Action action)
+ {
+ RunWithCulture(action, CultureInfo.InvariantCulture);
+ RunWithCulture(action, CultureInfo.GetCultureInfo("ru-RU"));
+ }
+
+ /// <summary>
+ /// Runs the with culture.
+ /// </summary>
+ /// <param name="action">The action.</param>
+ /// <param name="cultureInfo">The culture information.</param>
+ private static void RunWithCulture(Action action, CultureInfo cultureInfo)
+ {
+ var oldCulture = Thread.CurrentThread.CurrentCulture;
+
+ try
+ {
+ Thread.CurrentThread.CurrentCulture = cultureInfo;
+
+ action();
+ }
+ finally
+ {
+ Thread.CurrentThread.CurrentCulture = oldCulture;
+ }
+ }
+
+ /// <summary>
+ /// Test bean.
+ /// </summary>
+ public class LifecycleBean : ILifecycleBean
+ {
+ /// <summary>
+ /// Gets or sets the foo.
+ /// </summary>
+ /// <value>
+ /// The foo.
+ /// </value>
+ public int Foo { get; set; }
+
+ /// <summary>
+ /// This method is called when lifecycle event occurs.
+ /// </summary>
+ /// <param name="evt">Lifecycle event.</param>
+ public void OnLifecycleEvent(LifecycleEventType evt)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test mapper.
+ /// </summary>
+ public class NameMapper : IBinaryNameMapper
+ {
+ /// <summary>
+ /// Gets or sets the bar.
+ /// </summary>
+ /// <value>
+ /// The bar.
+ /// </value>
+ public string Bar { get; set; }
+
+ /// <summary>
+ /// Gets the type name.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <returns>
+ /// Type name.
+ /// </returns>
+ public string GetTypeName(string name)
+ {
+ return name;
+ }
+
+ /// <summary>
+ /// Gets the field name.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <returns>
+ /// Field name.
+ /// </returns>
+ public string GetFieldName(string name)
+ {
+ return name;
+ }
+ }
+
+ /// <summary>
+ /// Serializer.
+ /// </summary>
+ public class TestSerializer : IBinarySerializer
+ {
+ /// <summary>
+ /// Write portalbe object.
+ /// </summary>
+ /// <param name="obj">Object.</param>
+ /// <param name="writer">Poratble writer.</param>
+ public void WriteBinary(object obj, IBinaryWriter writer)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Read binary object.
+ /// </summary>
+ /// <param name="obj">Instantiated empty object.</param>
+ /// <param name="reader">Poratble reader.</param>
+ public void ReadBinary(object obj, IBinaryReader reader)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test class.
+ /// </summary>
+ public class FooClass
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Test factory.
+ /// </summary>
+ public class TestCacheStoreFactory : IFactory<ICacheStore>
+ {
+ /// <summary>
+ /// Creates an instance of the cache store.
+ /// </summary>
+ /// <returns>
+ /// New instance of the cache store.
+ /// </returns>
+ public ICacheStore CreateInstance()
+ {
+ return null;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
new file mode 100644
index 0000000..c290c83
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<configuration>
+ <configSections>
+ <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
+ <section name="igniteConfiguration2" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
+ </configSections>
+
+ <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" gridName="myGrid1">
+ <discoverySpi type="TcpDiscoverySpi">
+ <ipFinder type="TcpDiscoveryStaticIpFinder">
+ <endpoints>
+ <string>127.0.0.1:47500..47501</string>
+ </endpoints>
+ </ipFinder>
+ </discoverySpi>
+
+ <cacheConfiguration>
+ <cacheConfiguration name="cacheName" />
+ </cacheConfiguration>
+ </igniteConfiguration>
+
+ <igniteConfiguration2 gridName="myGrid2">
+ <discoverySpi type="TcpDiscoverySpi">
+ <ipFinder type="TcpDiscoveryStaticIpFinder">
+ <endpoints>
+ <string>127.0.0.1:47500..47501</string>
+ </endpoints>
+ </ipFinder>
+ </discoverySpi>
+
+ <cacheConfiguration>
+ <cacheConfiguration name="cacheName2" />
+ </cacheConfiguration>
+ </igniteConfiguration2>
+
+</configuration>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index e2efd0a..d0ef352 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -60,7 +60,9 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
+ <Reference Include="System.configuration" />
<Reference Include="System.Core" />
+ <Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Binary\Package-Info.cs" />
@@ -183,6 +185,7 @@
<Compile Include="Events\TaskEvent.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="IgniteConfiguration.cs" />
+ <Compile Include="IgniteConfigurationSection.cs" />
<Compile Include="Ignition.cs" />
<Compile Include="IIgnite.cs" />
<Compile Include="Impl\Binary\BinaryEnum.cs" />
@@ -222,11 +225,13 @@
<Compile Include="Impl\Collections\MultiValueDictionary.cs" />
<Compile Include="Impl\Collections\ReadOnlyCollection.cs" />
<Compile Include="Impl\Collections\ReadOnlyDictionary.cs" />
+ <Compile Include="Impl\Common\BooleanLowerCaseConverter.cs" />
<Compile Include="Impl\Common\CancelledTask.cs" />
<Compile Include="Impl\Common\Classpath.cs" />
<Compile Include="Impl\Common\CopyOnWriteConcurrentDictionary.cs" />
<Compile Include="Impl\Common\DelegateConverter.cs" />
<Compile Include="Impl\Common\DelegateTypeDescriptor.cs" />
+ <Compile Include="Impl\Events\EventTypeConverter.cs" />
<Compile Include="Impl\Common\Fnv1Hash.cs" />
<Compile Include="Impl\Common\Future.cs" />
<Compile Include="Impl\Common\FutureConverter.cs" />
@@ -234,10 +239,12 @@
<Compile Include="Impl\Common\IgniteArgumentCheck.cs" />
<Compile Include="Impl\Common\IFutureConverter.cs" />
<Compile Include="Impl\Common\IFutureInternal.cs" />
+ <Compile Include="Impl\Common\IgniteConfigurationXmlSerializer.cs" />
<Compile Include="Impl\Common\IgniteHome.cs" />
<Compile Include="Impl\Common\LoadedAssembliesResolver.cs" />
<Compile Include="Impl\Common\ResizeableArray.cs" />
<Compile Include="Impl\Common\TypeCaster.cs" />
+ <Compile Include="Impl\Common\TypeStringConverter.cs" />
<Compile Include="Impl\Compute\Closure\ComputeAbstractClosureTask.cs" />
<Compile Include="Impl\Compute\Closure\ComputeActionJob.cs" />
<Compile Include="Impl\Compute\Closure\ComputeFuncJob.cs" />
@@ -434,6 +441,10 @@
<ItemGroup>
<None Include="Apache.Ignite.Core.ruleset" />
<None Include="Apache.Ignite.Core.snk" />
+ <None Include="IgniteConfigurationSection.xsd">
+ <SubType>Designer</SubType>
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
index 23dc811..3f924eb 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/IBinarySerializer.cs
@@ -23,17 +23,17 @@ namespace Apache.Ignite.Core.Binary
public interface IBinarySerializer
{
/// <summary>
- /// Write portalbe object.
+ /// Write binary object.
/// </summary>
/// <param name="obj">Object.</param>
- /// <param name="writer">Poratble writer.</param>
+ /// <param name="writer">Binary writer.</param>
void WriteBinary(object obj, IBinaryWriter writer);
/// <summary>
/// Read binary object.
/// </summary>
/// <param name="obj">Instantiated empty object.</param>
- /// <param name="reader">Poratble reader.</param>
+ /// <param name="reader">Binary reader.</param>
void ReadBinary(object obj, IBinaryReader reader);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.cs
new file mode 100644
index 0000000..51b963e
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.cs
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core
+{
+ using System.Configuration;
+ using System.Text;
+ using System.Xml;
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Ignite configuration section for app.config and web.config files.
+ /// </summary>
+ public class IgniteConfigurationSection : ConfigurationSection
+ {
+ /// <summary>
+ /// Gets or sets the ignite configuration.
+ /// </summary>
+ /// <value>
+ /// The ignite configuration.
+ /// </value>
+ public IgniteConfiguration IgniteConfiguration { get; private set; }
+
+ /// <summary>
+ /// Reads XML from the configuration file.
+ /// </summary>
+ /// <param name="reader">The reader object, which reads from the configuration file.</param>
+ protected override void DeserializeSection(XmlReader reader)
+ {
+ IgniteArgumentCheck.NotNull(reader, "reader");
+
+ IgniteConfiguration = IgniteConfigurationXmlSerializer.Deserialize(reader);
+ }
+
+ /// <summary>
+ /// Creates an XML string containing an unmerged view of the <see cref="ConfigurationSection" />
+ /// object as a single section to write to a file.
+ /// </summary>
+ /// <param name="parentElement">The <see cref="ConfigurationElement" />
+ /// instance to use as the parent when performing the un-merge.</param>
+ /// <param name="name">The name of the section to create.</param>
+ /// <param name="saveMode">The <see cref="ConfigurationSaveMode" /> instance
+ /// to use when writing to a string.</param>
+ /// <returns>
+ /// An XML string containing an unmerged view of the <see cref="ConfigurationSection" /> object.
+ /// </returns>
+ protected override string SerializeSection(ConfigurationElement parentElement, string name,
+ ConfigurationSaveMode saveMode)
+ {
+ IgniteArgumentCheck.NotNull(parentElement, "parentElement");
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ if (IgniteConfiguration == null)
+ return string.Format("<{0} />", name);
+
+ var sb = new StringBuilder();
+
+ using (var xmlWriter = XmlWriter.Create(sb))
+ {
+ IgniteConfigurationXmlSerializer.Serialize(IgniteConfiguration, xmlWriter, name);
+
+ return sb.ToString();
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
new file mode 100644
index 0000000..5181217
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd
@@ -0,0 +1,281 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<xs:schema id="IgniteConfigurationSection"
+ targetNamespace="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
+ elementFormDefault="qualified"
+ xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
+ xmlns:mstns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="igniteConfiguration">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="binaryConfiguration" minOccurs="0">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="typeConfigurations" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="binaryTypeConfiguration">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="nameMapper" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="idMapper" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="serializer" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="typeName" type="xs:string" />
+ <xs:attribute name="affinityKeyFieldName" type="xs:string" />
+ <xs:attribute name="keepDeserialized" type="xs:string" />
+ <xs:attribute name="isEnum" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="defaultNameMapper" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="defaultIdMapper" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="defaultSerializer" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="defaultKeepDeserialized" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="cacheConfiguration" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="cacheConfiguration" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="cacheStoreFactory" minOccurs="0">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="queryEntities" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="queryEntity" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:all>
+ <xs:element name="fields" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="queryField" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="fieldType" type="xs:string" />
+ <xs:attribute name="fieldTypeName" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="aliases" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="queryAlias" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="fullName" type="xs:string" use="required" />
+ <xs:attribute name="alias" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="indexes" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="queryIndex" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="fields" minOccurs="1">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="queryIndexField" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="isDescending" type="xs:boolean" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="indexType" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="keyTypeName" type="xs:string"/>
+ <xs:attribute name="keyType" type="xs:string" />
+ <xs:attribute name="valueTypeName" type="xs:string" />
+ <xs:attribute name="valueType" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="name" type="xs:string" />
+ <xs:attribute name="writeSynchronizationMode" type="xs:string" />
+ <xs:attribute name="evictSynchronized" type="xs:boolean" />
+ <xs:attribute name="evictSynchronizedKeyBufferSize" type="xs:int" />
+ <xs:attribute name="evictSynchronizedConcurrencyLevel" type="xs:int" />
+ <xs:attribute name="evictSynchronizedTimeout" type="xs:string" />
+ <xs:attribute name="maxEvictionOverflowRatio" type="xs:decimal" />
+ <xs:attribute name="startSize" type="xs:int" />
+ <xs:attribute name="loadPreviousValue" type="xs:string" />
+ <xs:attribute name="atomicityMode" type="xs:string" />
+ <xs:attribute name="atomicWriteOrderMode" type="xs:string" />
+ <xs:attribute name="backups" type="xs:int" />
+ <xs:attribute name="lockTimeout" type="xs:string" />
+ <xs:attribute name="invalidate" type="xs:boolean" />
+ <xs:attribute name="rebalanceMode" type="xs:string" />
+ <xs:attribute name="rebalanceBatchSize" type="xs:int" />
+ <xs:attribute name="enableSwap" type="xs:boolean" />
+ <xs:attribute name="maxConcurrentAsyncOperations" type="xs:int" />
+ <xs:attribute name="writeBehindEnabled" type="xs:boolean" />
+ <xs:attribute name="writeBehindFlushSize" type="xs:int" />
+ <xs:attribute name="writeBehindFlushThreadCount" type="xs:int" />
+ <xs:attribute name="writeBehindBatchSize" type="xs:int" />
+ <xs:attribute name="rebalanceTimeout" type="xs:string" />
+ <xs:attribute name="rebalanceDelay" type="xs:string" />
+ <xs:attribute name="rebalanceThrottle" type="xs:string" />
+ <xs:attribute name="offHeapMaxMemory" type="xs:int" />
+ <xs:attribute name="memoryMode" type="xs:string" />
+ <xs:attribute name="longQueryWarningTimeout" type="xs:string" />
+ <xs:attribute name="sqlEscapeAll" type="xs:boolean" />
+ <xs:attribute name="sqlOnheapRowCacheSize" type="xs:int" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="jvmOptions" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="string" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="assemblies" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="string" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="lifecycleBeans" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="iLifecycleBean">
+ <xs:complexType>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="discoverySpi" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="ipFinder" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="endpoints" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="string" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="type" type="xs:string" use="required" />
+ <xs:attribute name="localAddress" type="xs:string" />
+ <xs:attribute name="multicastGroup" type="xs:string" />
+ <xs:attribute name="multicastPort" type="xs:int" />
+ <xs:attribute name="addressRequestAttempts" type="xs:int" />
+ <xs:attribute name="responseTimeout" type="xs:string" />
+ <xs:attribute name="timeToLive" type="xs:byte" />
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="socketTimeout" type="xs:string" />
+ <xs:attribute name="ackTimeout" type="xs:string" />
+ <xs:attribute name="maxAckTimeout" type="xs:string" />
+ <xs:attribute name="networkTimeout" type="xs:string" />
+ <xs:attribute name="joinTimeout" type="xs:string" />
+ <xs:attribute name="type" type="xs:string" use="required" />
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="includedEventTypes" minOccurs="0">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" name="int" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:all>
+ <xs:attribute name="gridName" type="xs:string" />
+ <xs:attribute name="jvmDllPath" type="xs:string" />
+ <xs:attribute name="igniteHome" type="xs:string" />
+ <xs:attribute name="jvmClasspath" type="xs:string" />
+ <xs:attribute name="suppressWarnings" type="xs:boolean" />
+ <xs:attribute name="jvmInitialMemoryMb" type="xs:int" />
+ <xs:attribute name="jvmMaxMemoryMb" type="xs:int" />
+ <xs:attribute name="clientMode" type="xs:boolean" />
+ <xs:attribute name="metricsExpireTime" type="xs:string" />
+ <xs:attribute name="metricsHistorySize" type="xs:int" />
+ <xs:attribute name="metricsLogFrequency" type="xs:string" />
+ <xs:attribute name="metricsUpdateFrequency" type="xs:string" />
+ <xs:attribute name="networkSendRetryCount" type="xs:int" />
+ <xs:attribute name="networkSendRetryDelay" type="xs:string" />
+ <xs:attribute name="networkTimeout" type="xs:string" />
+ <xs:attribute name="workDirectory" type="xs:string" />
+ <xs:attribute name="localhost" type="xs:string" />
+ </xs:complexType>
+ </xs:element>
+</xs:schema>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
index 0549010..70d7422 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core
{
using System;
using System.Collections.Generic;
+ using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
@@ -116,6 +117,44 @@ namespace Apache.Ignite.Core
}
/// <summary>
+ /// Reads <see cref="IgniteConfiguration"/> from first <see cref="IgniteConfigurationSection"/> in the
+ /// application configuration and starts Ignite.
+ /// </summary>
+ /// <returns>Started Ignite.</returns>
+ public static IIgnite StartFromApplicationConfiguration()
+ {
+ var cfg = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
+
+ var section = cfg.Sections.OfType<IgniteConfigurationSection>().FirstOrDefault();
+
+ if (section == null)
+ throw new ConfigurationErrorsException(
+ string.Format("Could not find {0} in current application configuration",
+ typeof(IgniteConfigurationSection).Name));
+
+ return Start(section.IgniteConfiguration);
+ }
+
+ /// <summary>
+ /// Reads <see cref="IgniteConfiguration"/> from application configuration
+ /// <see cref="IgniteConfigurationSection"/> with specified name and starts Ignite.
+ /// </summary>
+ /// <param name="sectionName">Name of the section.</param>
+ /// <returns>Started Ignite.</returns>
+ public static IIgnite StartFromApplicationConfiguration(string sectionName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(sectionName, "sectionName");
+
+ var section = ConfigurationManager.GetSection(sectionName) as IgniteConfigurationSection;
+
+ if (section == null)
+ throw new ConfigurationErrorsException(string.Format("Could not find {0} with name '{1}'",
+ typeof(IgniteConfigurationSection).Name, sectionName));
+
+ return Start(section.IgniteConfiguration);
+ }
+
+ /// <summary>
/// Starts Ignite with given configuration.
/// </summary>
/// <returns>Started Ignite.</returns>
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/BooleanLowerCaseConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/BooleanLowerCaseConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/BooleanLowerCaseConverter.cs
new file mode 100644
index 0000000..e8cced2
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/BooleanLowerCaseConverter.cs
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
+
+ /// <summary>
+ /// Bollean converter that returns lower-case strings, for XML serialization.
+ /// </summary>
+ internal class BooleanLowerCaseConverter : BooleanConverter
+ {
+ /// <summary>
+ /// Default instance.
+ /// </summary>
+ public static readonly BooleanLowerCaseConverter Instance = new BooleanLowerCaseConverter();
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="culture">
+ /// A <see cref="CultureInfo" />. If null is passed, the current culture is assumed.
+ /// </param>
+ /// <param name="value">The <see cref="object" /> to convert.</param>
+ /// <param name="destinationType">
+ /// The <see cref="Type" /> to convert the <paramref name="value" /> parameter to.
+ /// </param>
+ /// <returns>
+ /// An <see cref="object" /> that represents the converted value.
+ /// </returns>
+ [SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")]
+ [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "2")]
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
+ Type destinationType)
+ {
+ if (destinationType == typeof (string))
+ return value.ToString().ToLowerInvariant();
+
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/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
new file mode 100644
index 0000000..af25bfa
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/IgniteConfigurationXmlSerializer.cs
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Configuration;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Reflection;
+ using System.Xml;
+ using Apache.Ignite.Core.Impl.Events;
+
+ /// <summary>
+ /// Serializes <see cref="IgniteConfiguration"/> to XML.
+ /// </summary>
+ internal static class IgniteConfigurationXmlSerializer
+ {
+ /** Attribute that specifies a type for abstract properties, such as IpFinder. */
+ private const string TypNameAttribute = "type";
+
+ /** Xmlns. */
+ private const string XmlnsAttribute = "xmlns";
+
+ /** Schema. */
+ private const string Schema = "http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection";
+
+ /// <summary>
+ /// Deserializes <see cref="IgniteConfiguration"/> from specified <see cref="XmlReader"/>.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ /// <returns>Resulting <see cref="IgniteConfiguration"/>.</returns>
+ public static IgniteConfiguration Deserialize(XmlReader reader)
+ {
+ IgniteArgumentCheck.NotNull(reader, "reader");
+
+ var cfg = new IgniteConfiguration();
+
+ if (reader.NodeType == XmlNodeType.Element || reader.Read())
+ ReadElement(reader, cfg);
+
+ return cfg;
+ }
+
+ /// <summary>
+ /// Serializes specified <see cref="IgniteConfiguration" /> to <see cref="XmlWriter" />.
+ /// </summary>
+ /// <param name="configuration">The configuration.</param>
+ /// <param name="writer">The writer.</param>
+ /// <param name="rootElementName">Name of the root element.</param>
+ public static void Serialize(IgniteConfiguration configuration, XmlWriter writer, string rootElementName)
+ {
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+ IgniteArgumentCheck.NotNull(writer, "writer");
+ IgniteArgumentCheck.NotNullOrEmpty(rootElementName, "rootElementName");
+
+ WriteElement(configuration, writer, rootElementName, typeof(IgniteConfiguration));
+ }
+
+ /// <summary>
+ /// Writes new element.
+ /// </summary>
+ private static void WriteElement(object obj, XmlWriter writer, string rootElementName, Type valueType,
+ PropertyInfo property = null)
+ {
+ if (valueType == typeof(IgniteConfiguration))
+ writer.WriteStartElement(rootElementName, Schema); // write xmlns for the root element
+ else
+ writer.WriteStartElement(rootElementName);
+
+ if (IsBasicType(valueType))
+ WriteBasicProperty(obj, writer, valueType, property);
+ else if (valueType.IsGenericType && valueType.GetGenericTypeDefinition() == typeof (ICollection<>))
+ WriteCollectionProperty(obj, writer, valueType, property);
+ else
+ WriteComplexProperty(obj, writer, valueType);
+
+ writer.WriteEndElement();
+ }
+
+ /// <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);
+ }
+
+ /// <summary>
+ /// Writes the collection property.
+ /// </summary>
+ private static void WriteCollectionProperty(object obj, XmlWriter writer, Type valueType, PropertyInfo property)
+ {
+ var elementType = valueType.GetGenericArguments().Single();
+
+ var elementTypeName = PropertyNameToXmlName(elementType.Name);
+
+ foreach (var element in (IEnumerable)obj)
+ WriteElement(element, writer, elementTypeName, elementType, property);
+ }
+
+ /// <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();
+
+ // Specify type for interfaces and abstract classes
+ if (valueType.IsAbstract)
+ writer.WriteAttributeString(TypNameAttribute, TypeStringConverter.Convert(obj.GetType()));
+
+ // Write attributes
+ foreach (var prop in props.Where(p => IsBasicType(p.PropertyType)))
+ {
+ var converter = GetConverter(prop, prop.PropertyType);
+ var stringValue = converter.ConvertToInvariantString(prop.GetValue(obj, null));
+ writer.WriteAttributeString(PropertyNameToXmlName(prop.Name), stringValue);
+ }
+
+ // Write elements
+ foreach (var prop in props.Where(p => !IsBasicType(p.PropertyType)))
+ WriteElement(prop.GetValue(obj, null), writer, PropertyNameToXmlName(prop.Name),
+ prop.PropertyType, prop);
+ }
+
+ /// <summary>
+ /// Reads the element.
+ /// </summary>
+ private static void ReadElement(XmlReader reader, object target)
+ {
+ var targetType = target.GetType();
+
+ // Read attributes
+ while (reader.MoveToNextAttribute())
+ {
+ var name = reader.Name;
+ var val = reader.Value;
+
+ SetProperty(target, name, val);
+ }
+
+ // Read content
+ reader.MoveToElement();
+
+ while (reader.Read())
+ {
+ if (reader.NodeType != XmlNodeType.Element)
+ continue;
+
+ var name = reader.Name;
+ var prop = GetPropertyOrThrow(name, reader.Value, targetType);
+ var propType = prop.PropertyType;
+
+ if (IsBasicType(propType))
+ {
+ // Regular property in xmlElement form
+ SetProperty(target, name, reader.ReadString());
+ }
+ else if (propType.IsGenericType && propType.GetGenericTypeDefinition() == typeof (ICollection<>))
+ {
+ // Collection
+ ReadCollectionProperty(reader, prop, target);
+ }
+ else
+ {
+ // Nested object (complex property)
+ prop.SetValue(target, ReadComplexProperty(reader, propType, prop.Name, targetType), null);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Reads the complex property (nested object).
+ /// </summary>
+ private static object ReadComplexProperty(XmlReader reader, Type propType, string propName, Type targetType)
+ {
+ if (propType.IsAbstract)
+ {
+ var typeName = reader.GetAttribute(TypNameAttribute);
+
+ var derivedTypes = GetConcreteDerivedTypes(propType);
+
+ propType = typeName == null
+ ? null
+ : Type.GetType(typeName, false) ?? derivedTypes.FirstOrDefault(x => x.Name == typeName);
+
+ if (propType == null)
+ {
+ var message = string.Format("'type' attribute is required for '{0}.{1}' property", targetType.Name,
+ propName);
+
+ if (typeName != null)
+ {
+ message += ", specified type cannot be resolved: " + typeName;
+ }
+ else if (derivedTypes.Any())
+ message += ", possible values are: " + string.Join(", ", derivedTypes.Select(x => x.Name));
+
+ throw new ConfigurationErrorsException(message);
+ }
+ }
+
+ var nestedVal = Activator.CreateInstance(propType);
+
+ using (var subReader = reader.ReadSubtree())
+ {
+ subReader.Read(); // read first element
+
+ ReadElement(subReader, nestedVal);
+ }
+
+ return nestedVal;
+ }
+
+ /// <summary>
+ /// Reads the collection.
+ /// </summary>
+ private static void ReadCollectionProperty(XmlReader reader, PropertyInfo prop, object target)
+ {
+ var elementType = prop.PropertyType.GetGenericArguments().Single();
+
+ var listType = typeof (List<>).MakeGenericType(elementType);
+
+ var list = (IList) Activator.CreateInstance(listType);
+
+ var converter = IsBasicType(elementType) ? GetConverter(prop, elementType) : null;
+
+ using (var subReader = reader.ReadSubtree())
+ {
+ subReader.Read(); // skip list head
+ while (subReader.Read())
+ {
+ if (subReader.NodeType != XmlNodeType.Element)
+ continue;
+
+ if (subReader.Name != PropertyNameToXmlName(elementType.Name))
+ throw new ConfigurationErrorsException(
+ string.Format("Invalid list element in IgniteConfiguration: expected '{0}', but was '{1}'",
+ PropertyNameToXmlName(elementType.Name), subReader.Name));
+
+ list.Add(converter != null
+ ? converter.ConvertFromInvariantString(subReader.ReadString())
+ : ReadComplexProperty(subReader, elementType, prop.Name, target.GetType()));
+ }
+ }
+
+ prop.SetValue(target, list, null);
+ }
+
+ /// <summary>
+ /// Sets the property.
+ /// </summary>
+ private static void SetProperty(object target, string propName, string propVal)
+ {
+ if (propName == TypNameAttribute || propName == XmlnsAttribute)
+ return;
+
+ var type = target.GetType();
+ var property = GetPropertyOrThrow(propName, propVal, type);
+
+ var converter = GetConverter(property, property.PropertyType);
+
+ var convertedVal = converter.ConvertFromInvariantString(propVal);
+
+ property.SetValue(target, convertedVal, null);
+ }
+
+ /// <summary>
+ /// Gets concrete derived types.
+ /// </summary>
+ private static List<Type> GetConcreteDerivedTypes(Type type)
+ {
+ return type.Assembly.GetTypes().Where(t => t.IsClass && !t.IsAbstract && type.IsAssignableFrom(t)).ToList();
+ }
+
+ /// <summary>
+ /// Gets specified property from a type or throws an exception.
+ /// </summary>
+ private static PropertyInfo GetPropertyOrThrow(string propName, string propVal, Type type)
+ {
+ var property = type.GetProperty(XmlNameToPropertyName(propName));
+
+ if (property == null)
+ throw new ConfigurationErrorsException(
+ string.Format(
+ "Invalid IgniteConfiguration attribute '{0}={1}', there is no such property on '{2}'",
+ propName, propVal, type));
+
+ return property;
+ }
+
+ /// <summary>
+ /// Converts an XML name to CLR name.
+ /// </summary>
+ private static string XmlNameToPropertyName(string name)
+ {
+ Debug.Assert(name.Length > 0);
+
+ if (name == "int")
+ return "Int32"; // allow aliases
+
+ return char.ToUpperInvariant(name[0]) + name.Substring(1);
+ }
+
+ /// <summary>
+ /// Converts a CLR name to XML name.
+ /// </summary>
+ private static string PropertyNameToXmlName(string name)
+ {
+ Debug.Assert(name.Length > 0);
+
+ if (name == "Int32")
+ return "int"; // allow aliases
+
+ return char.ToLowerInvariant(name[0]) + name.Substring(1);
+ }
+
+ /// <summary>
+ /// Determines whether specified type is a basic built-in type.
+ /// </summary>
+ private static bool IsBasicType(Type propertyType)
+ {
+ Debug.Assert(propertyType != null);
+
+ return propertyType.IsValueType || propertyType == typeof(string) || propertyType == typeof(Type);
+ }
+
+ /// <summary>
+ /// Gets converter for a property.
+ /// </summary>
+ private static TypeConverter GetConverter(PropertyInfo property, Type propertyType)
+ {
+ Debug.Assert(property != null);
+ Debug.Assert(propertyType != null);
+
+ if (propertyType.IsEnum)
+ return new GenericEnumConverter(propertyType);
+
+ if (propertyType == typeof (Type))
+ return TypeStringConverter.Instance;
+
+ if (propertyType == typeof(bool))
+ return BooleanLowerCaseConverter.Instance;
+
+ if (property.DeclaringType == typeof (IgniteConfiguration) && property.Name == "IncludedEventTypes")
+ return EventTypeConverter.Instance;
+
+ var converter = TypeDescriptor.GetConverter(propertyType);
+
+ if (converter == null || !converter.CanConvertFrom(typeof(string)) ||
+ !converter.CanConvertTo(typeof(string)))
+ throw new ConfigurationErrorsException("No converter for type " + propertyType);
+
+ return converter;
+ }
+
+ /// <summary>
+ /// Gets properties with non-default value.
+ /// </summary>
+ private static IEnumerable<PropertyInfo> GetNonDefaultProperties(object obj)
+ {
+ Debug.Assert(obj != null);
+
+ return obj.GetType().GetProperties().Where(p => !Equals(p.GetValue(obj, null), GetDefaultValue(p)));
+ }
+
+ /// <summary>
+ /// Gets the default value for a property.
+ /// </summary>
+ private static object GetDefaultValue(PropertyInfo property)
+ {
+ var attr = property.GetCustomAttributes(true).OfType<DefaultValueAttribute>().FirstOrDefault();
+
+ if (attr != null)
+ return attr.Value;
+
+ var propertyType = property.PropertyType;
+
+ if (propertyType.IsValueType)
+ return Activator.CreateInstance(propertyType);
+
+ return null;
+ }
+ }
+}
[15/21] ignite git commit: Added test.
Posted by sb...@apache.org.
Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5539cbad
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5539cbad
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5539cbad
Branch: refs/heads/ignite-2542
Commit: 5539cbadb81195c35889b71486b1e449b637d8c0
Parents: 16927ab
Author: sboikov <sb...@gridgain.com>
Authored: Wed Feb 10 15:32:03 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Feb 10 15:32:03 2016 +0300
----------------------------------------------------------------------
...niteCacheEntryListenerExpiredEventsTest.java | 202 +++++++++++++++++++
1 file changed, 202 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5539cbad/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java
new file mode 100644
index 0000000..d9fdfac
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerExpiredEventsTest.java
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.configuration.CacheEntryListenerConfiguration;
+import javax.cache.configuration.Factory;
+import javax.cache.configuration.MutableCacheEntryListenerConfiguration;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryExpiredListener;
+import javax.cache.event.CacheEntryListener;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.ModifiedExpiryPolicy;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class IgniteCacheEntryListenerExpiredEventsTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static AtomicInteger evtCntr;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExpiredEventAtomic() throws Exception {
+ checkExpiredEvents(cacheConfiguration(PARTITIONED, ATOMIC, ONHEAP_TIERED));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExpiredEventAtomicOffheap() throws Exception {
+ checkExpiredEvents(cacheConfiguration(PARTITIONED, ATOMIC, OFFHEAP_TIERED));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExpiredEventTx() throws Exception {
+ checkExpiredEvents(cacheConfiguration(PARTITIONED, TRANSACTIONAL, ONHEAP_TIERED));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testExpiredEventTxOffheap() throws Exception {
+ checkExpiredEvents(cacheConfiguration(PARTITIONED, TRANSACTIONAL, OFFHEAP_TIERED));
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void checkExpiredEvents(CacheConfiguration<Object, Object> ccfg) throws Exception {
+ IgniteCache<Object, Object> cache = ignite(0).createCache(ccfg);
+
+ try {
+ evtCntr = new AtomicInteger();
+
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ new ExpiredListenerFactory(),
+ null,
+ true,
+ false
+ );
+
+ cache.registerCacheEntryListener(lsnrCfg);
+
+ IgniteCache<Object, Object> expiryCache =
+ cache.withExpiryPolicy(new ModifiedExpiryPolicy(new Duration(MILLISECONDS, 500)));
+
+ expiryCache.put(1, 1);
+
+ for (int i = 0; i < 10; i++)
+ cache.get(i);
+
+ boolean wait = GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return evtCntr.get() > 0;
+ }
+ }, 5000);
+
+ assertTrue(wait);
+
+ U.sleep(100);
+
+ assertEquals(1, evtCntr.get());
+ }
+ finally {
+ ignite(0).destroyCache(cache.getName());
+ }
+ }
+
+ /**
+ *
+ * @param cacheMode Cache mode.
+ * @param atomicityMode Cache atomicity mode.
+ * @param memoryMode Cache memory mode.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Object, Object> cacheConfiguration(
+ CacheMode cacheMode,
+ CacheAtomicityMode atomicityMode,
+ CacheMemoryMode memoryMode) {
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setMemoryMode(memoryMode);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setAtomicWriteOrderMode(PRIMARY);
+
+ if (cacheMode == PARTITIONED)
+ ccfg.setBackups(1);
+
+ return ccfg;
+ }
+
+ /**
+ *
+ */
+ private static class ExpiredListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
+ /** {@inheritDoc} */
+ @Override public CacheEntryListener<Object, Object> create() {
+ return new ExpiredListener();
+ }
+ }
+
+ /**
+ *
+ */
+ private static class ExpiredListener implements CacheEntryExpiredListener<Object, Object> {
+ /** {@inheritDoc} */
+ @Override public void onExpired(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
+ evtCntr.incrementAndGet();
+ }
+ }
+}
[04/21] ignite git commit: IGNITE-2380: Added ability to start Ignite
using configuration from app.config. This closes #417.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeStringConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeStringConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeStringConverter.cs
new file mode 100644
index 0000000..e7e8b8f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/TypeStringConverter.cs
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Common
+{
+ using System;
+ using System.ComponentModel;
+ using System.Globalization;
+
+ /// <summary>
+ /// Converts string to <see cref="Type"/>.
+ /// </summary>
+ internal class TypeStringConverter : TypeConverter
+ {
+ /// <summary>
+ /// Default instance.
+ /// </summary>
+ public static readonly TypeStringConverter Instance = new TypeStringConverter();
+
+ /// <summary>
+ /// Returns whether this converter can convert an object of the given type to the type of this converter,
+ /// using the specified context.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="sourceType">A <see cref="Type" /> that represents the type you want to convert from.</param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise, false.
+ /// </returns>
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ return sourceType == typeof (string);
+ }
+
+ /// <summary>
+ /// Returns whether this converter can convert the object to the specified type, using the specified context.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="destinationType">
+ /// A <see cref="Type" /> that represents the type you want to convert to.
+ /// </param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise, false.
+ /// </returns>
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ return destinationType == typeof(string);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter,
+ /// using the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="culture">The <see cref="CultureInfo" /> to use as the current culture.</param>
+ /// <param name="value">The <see cref="Object" /> to convert.</param>
+ /// <returns>
+ /// An <see cref="Object" /> that represents the converted value.
+ /// </returns>
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ return value == null ? null : Type.GetType(value.ToString(), false);
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="culture">
+ /// A <see cref="CultureInfo" />. If null is passed, the current culture is assumed.
+ /// </param>
+ /// <param name="value">The <see cref="Object" /> to convert.</param>
+ /// <param name="destinationType">
+ /// The <see cref="Type" /> to convert the <paramref name="value" /> parameter to.
+ /// </param>
+ /// <returns>
+ /// An <see cref="Object" /> that represents the converted value.
+ /// </returns>
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
+ Type destinationType)
+ {
+ return Convert(value);
+ }
+
+ /// <summary>
+ /// Converts Type to string.
+ /// </summary>
+ /// <param name="value">The value to convert.</param>
+ /// <returns>Resulting string.</returns>
+ public static string Convert(object value)
+ {
+ var type = value as Type;
+ if (type == null)
+ return null;
+
+ if (type.Assembly == typeof (int).Assembly)
+ return type.FullName;
+
+ return type.AssemblyQualifiedName;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a4d8a049/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
new file mode 100644
index 0000000..6b8f935
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Events/EventTypeConverter.cs
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.Events
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Globalization;
+ using System.Linq;
+ using Apache.Ignite.Core.Events;
+
+ /// <summary>
+ /// Converts string to <see cref="EventType"/> member value.
+ /// </summary>
+ internal class EventTypeConverter : TypeConverter
+ {
+ /// <summary>
+ /// Default instance.
+ /// </summary>
+ public static readonly EventTypeConverter Instance = new EventTypeConverter();
+
+ /// <summary>
+ /// The event type map.
+ /// </summary>
+ private static readonly Dictionary<int, string> EvtIdToNameMap =
+ typeof (EventType).GetFields()
+ .Where(p => p.FieldType == typeof (int))
+ .ToDictionary(f => (int) f.GetValue(null), f => f.Name);
+
+ /// <summary>
+ /// The event type map.
+ /// </summary>
+ private static readonly Dictionary<string, int> EvtNameToIdMap =
+ EvtIdToNameMap.ToDictionary(p => p.Value, p => p.Key, StringComparer.OrdinalIgnoreCase);
+
+ /// <summary>
+ /// Returns whether this converter can convert an object of the given type to the type of this converter,
+ /// using the specified context.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="sourceType">A <see cref="Type" /> that represents the type you want to convert from.</param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise, false.
+ /// </returns>
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ return sourceType == typeof(string);
+ }
+
+ /// <summary>
+ /// Returns whether this converter can convert the object to the specified type, using the specified context.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="destinationType">
+ /// A <see cref="Type" /> that represents the type you want to convert to.
+ /// </param>
+ /// <returns>
+ /// true if this converter can perform the conversion; otherwise, false.
+ /// </returns>
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ return destinationType == typeof(string);
+ }
+
+ /// <summary>
+ /// Converts the given object to the type of this converter,
+ /// using the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="culture">The <see cref="CultureInfo" /> to use as the current culture.</param>
+ /// <param name="value">The <see cref="Object" /> to convert.</param>
+ /// <returns>
+ /// An <see cref="object" /> that represents the converted value.
+ /// </returns>
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ if (value == null)
+ return null;
+
+ var s = value.ToString();
+ int intResult;
+
+ if (int.TryParse(s, out intResult) || EvtNameToIdMap.TryGetValue(s, out intResult))
+ return intResult;
+
+ throw new InvalidOperationException(string.Format("Cannot convert value to {0}: {1}",
+ typeof (EventType).Name, s));
+ }
+
+ /// <summary>
+ /// Converts the given value object to the specified type, using the specified context and culture information.
+ /// </summary>
+ /// <param name="context">An <see cref="ITypeDescriptorContext" /> that provides a format context.</param>
+ /// <param name="culture">
+ /// A <see cref="CultureInfo" />. If null is passed, the current culture is assumed.
+ /// </param>
+ /// <param name="value">The <see cref="Object" /> to convert.</param>
+ /// <param name="destinationType">
+ /// The <see cref="Type" /> to convert the <paramref name="value" /> parameter to.
+ /// </param>
+ /// <returns>
+ /// An <see cref="object" /> that represents the converted value.
+ /// </returns>
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
+ Type destinationType)
+ {
+ if (!(value is int))
+ return null;
+
+ string eventName;
+
+ if (EvtIdToNameMap.TryGetValue((int)value, out eventName))
+ return eventName;
+
+ return value.ToString();
+ }
+ }
+}
\ No newline at end of file
[14/21] ignite git commit: Added test.
Posted by sb...@apache.org.
Added test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/16927abb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/16927abb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/16927abb
Branch: refs/heads/ignite-2542
Commit: 16927abbb1ed1a6c3b47831562d263dd38f495d1
Parents: fa3706f
Author: sboikov <sb...@gridgain.com>
Authored: Wed Feb 10 15:05:56 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Feb 10 15:06:31 2016 +0300
----------------------------------------------------------------------
.../cache/CacheQueryBuildValueTest.java | 144 +++++++++++++++++++
1 file changed, 144 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/16927abb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java
new file mode 100644
index 0000000..cb574bb
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheQueryBuildValueTest.java
@@ -0,0 +1,144 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.query.SqlQuery;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheQueryBuildValueTest extends GridCommonAbstractTest {
+ /** */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMarshaller(null);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+ QueryEntity entity = new QueryEntity();
+ entity.setKeyType(Integer.class.getName());
+ entity.setValueType(TestBuilderValue.class.getName());
+
+ ArrayList<QueryIndex> idxs = new ArrayList<>();
+
+ QueryIndex idx = new QueryIndex("iVal");
+ idxs.add(idx);
+
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>();
+
+ fields.put("iVal", Integer.class.getName());
+
+ entity.setFields(fields);
+
+ entity.setIndexes(idxs);
+
+ ccfg.setQueryEntities(Collections.singleton(entity));
+
+ cfg.setCacheConfiguration(ccfg);
+
+ BinaryConfiguration binaryCfg = new BinaryConfiguration();
+
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
+ typeCfg.setTypeName(TestBuilderValue.class.getName());
+
+ binaryCfg.setTypeConfigurations(Collections.singletonList(typeCfg));
+
+ cfg.setBinaryConfiguration(binaryCfg);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGrid(0);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBuilderAndQuery() throws Exception {
+ Ignite node = ignite(0);
+
+ final IgniteCache<Object, Object> cache = node.cache(null);
+
+ IgniteBinary binary = node.binary();
+
+ BinaryObjectBuilder builder = binary.builder(TestBuilderValue.class.getName());
+
+ cache.put(0, builder.build());
+
+ builder.setField("iVal", 1);
+
+ cache.put(1, builder.build());
+
+ List<Cache.Entry<Object, Object>> entries =
+ cache.query(new SqlQuery<>(TestBuilderValue.class, "true")).getAll();
+
+ assertEquals(2, entries.size());
+ }
+
+ /**
+ *
+ */
+ static class TestBuilderValue implements Serializable {
+ /** */
+ private int iVal;
+
+ /**
+ * @param iVal Integer value.
+ */
+ public TestBuilderValue(int iVal) {
+ this.iVal = iVal;
+ }
+ }
+}
[02/21] ignite git commit: IGNITE-1563 .NET: Implemented "atomics":
AtomicReference and AtomicSequence. This closes #455.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index ad62f38..cdcddf0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -281,6 +281,40 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static IUnmanagedTarget ProcessorAtomicSequence(IUnmanagedTarget target, string name, long initialValue,
+ bool create)
+ {
+ var name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+ try
+ {
+ var res = JNI.ProcessorAtomicSequence(target.Context, target.Target, name0, initialValue, create);
+
+ return res == null ? null : target.ChangeTarget(res);
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(new IntPtr(name0));
+ }
+ }
+
+ internal static IUnmanagedTarget ProcessorAtomicReference(IUnmanagedTarget target, string name, long memPtr,
+ bool create)
+ {
+ var name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+ try
+ {
+ var res = JNI.ProcessorAtomicReference(target.Context, target.Target, name0, memPtr, create);
+
+ return res == null ? null : target.ChangeTarget(res);
+ }
+ finally
+ {
+ Marshal.FreeHGlobal(new IntPtr(name0));
+ }
+ }
+
internal static void ProcessorGetIgniteConfiguration(IUnmanagedTarget target, long memPtr)
{
JNI.ProcessorGetIgniteConfiguration(target.Context, target.Target, memPtr);
@@ -867,6 +901,51 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
JNI.AtomicLongClose(target.Context, target.Target);
}
+ internal static long AtomicSequenceGet(IUnmanagedTarget target)
+ {
+ return JNI.AtomicSequenceGet(target.Context, target.Target);
+ }
+
+ internal static long AtomicSequenceIncrementAndGet(IUnmanagedTarget target)
+ {
+ return JNI.AtomicSequenceIncrementAndGet(target.Context, target.Target);
+ }
+
+ internal static long AtomicSequenceAddAndGet(IUnmanagedTarget target, long value)
+ {
+ return JNI.AtomicSequenceAddAndGet(target.Context, target.Target, value);
+ }
+
+ internal static int AtomicSequenceGetBatchSize(IUnmanagedTarget target)
+ {
+ return JNI.AtomicSequenceGetBatchSize(target.Context, target.Target);
+ }
+
+ internal static void AtomicSequenceSetBatchSize(IUnmanagedTarget target, int size)
+ {
+ JNI.AtomicSequenceSetBatchSize(target.Context, target.Target, size);
+ }
+
+ internal static bool AtomicSequenceIsClosed(IUnmanagedTarget target)
+ {
+ return JNI.AtomicSequenceIsClosed(target.Context, target.Target);
+ }
+
+ internal static void AtomicSequenceClose(IUnmanagedTarget target)
+ {
+ JNI.AtomicSequenceClose(target.Context, target.Target);
+ }
+
+ internal static bool AtomicReferenceIsClosed(IUnmanagedTarget target)
+ {
+ return JNI.AtomicReferenceIsClosed(target.Context, target.Target);
+ }
+
+ internal static void AtomicReferenceClose(IUnmanagedTarget target)
+ {
+ JNI.AtomicReferenceClose(target.Context, target.Target);
+ }
+
internal static bool ListenableCancel(IUnmanagedTarget target)
{
return JNI.ListenableCancel(target.Context, target.Target);
[16/21] ignite git commit: IGNITE-2195: Implemented Hadoop FileSystem
factory capable of working with kerberized file systems. This closes #464.
Posted by sb...@apache.org.
IGNITE-2195: Implemented Hadoop FileSystem factory capable of working with kerberized file systems. This closes #464.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/008c8cd3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/008c8cd3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/008c8cd3
Branch: refs/heads/ignite-2542
Commit: 008c8cd3f33b9c2cace43a9d1f2b4e4542fb58fe
Parents: fa3706f
Author: iveselovskiy <iv...@gridgain.com>
Authored: Wed Feb 10 15:45:58 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 15:45:58 2016 +0300
----------------------------------------------------------------------
.../hadoop/fs/BasicHadoopFileSystemFactory.java | 22 +-
.../fs/CachingHadoopFileSystemFactory.java | 2 +-
.../fs/KerberosHadoopFileSystemFactory.java | 214 +++++++++++++++++++
...KerberosHadoopFileSystemFactorySelfTest.java | 104 +++++++++
.../testsuites/IgniteHadoopTestSuite.java | 3 +
5 files changed, 339 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/008c8cd3/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
index c791e9a..01fe6c9 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/BasicHadoopFileSystemFactory.java
@@ -66,7 +66,7 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
/** {@inheritDoc} */
@Override public FileSystem get(String usrName) throws IOException {
- return create0(IgfsUtils.fixUserName(usrName));
+ return get0(IgfsUtils.fixUserName(usrName));
}
/**
@@ -76,7 +76,7 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
* @return File system.
* @throws IOException If failed.
*/
- protected FileSystem create0(String usrName) throws IOException {
+ protected FileSystem get0(String usrName) throws IOException {
assert cfg != null;
try {
@@ -87,12 +87,12 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
ClassLoader clsLdr = getClass().getClassLoader();
if (ctxClsLdr == clsLdr)
- return FileSystem.get(fullUri, cfg, usrName);
+ return create(usrName);
else {
Thread.currentThread().setContextClassLoader(clsLdr);
try {
- return FileSystem.get(fullUri, cfg, usrName);
+ return create(usrName);
}
finally {
Thread.currentThread().setContextClassLoader(ctxClsLdr);
@@ -107,6 +107,18 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
}
/**
+ * Internal file system creation routine, invoked in correct class loader context.
+ *
+ * @param usrName User name.
+ * @return File system.
+ * @throws IOException If failed.
+ * @throws InterruptedException if the current thread is interrupted.
+ */
+ protected FileSystem create(String usrName) throws IOException, InterruptedException {
+ return FileSystem.get(fullUri, cfg, usrName);
+ }
+
+ /**
* Gets file system URI.
* <p>
* This URI will be used as a first argument when calling {@link FileSystem#get(URI, Configuration, String)}.
@@ -152,7 +164,7 @@ public class BasicHadoopFileSystemFactory implements HadoopFileSystemFactory, Ex
*
* @param cfgPaths Paths to file system configuration files.
*/
- public void setConfigPaths(String... cfgPaths) {
+ public void setConfigPaths(@Nullable String... cfgPaths) {
this.cfgPaths = cfgPaths;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/008c8cd3/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
index 91f7777..e1b30c4 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/CachingHadoopFileSystemFactory.java
@@ -47,7 +47,7 @@ public class CachingHadoopFileSystemFactory extends BasicHadoopFileSystemFactory
private final transient HadoopLazyConcurrentMap<String, FileSystem> cache = new HadoopLazyConcurrentMap<>(
new HadoopLazyConcurrentMap.ValueFactory<String, FileSystem>() {
@Override public FileSystem createValue(String key) throws IOException {
- return create0(key);
+ return get0(key);
}
}
);
http://git-wip-us.apache.org/repos/asf/ignite/blob/008c8cd3/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
new file mode 100644
index 0000000..fc768d6
--- /dev/null
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.hadoop.fs;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.security.UserGroupInformation;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.hadoop.fs.v1.IgniteHadoopFileSystem;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.jetbrains.annotations.Nullable;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Secure Hadoop file system factory that can work with underlying file system protected with Kerberos.
+ * It uses "impersonation" mechanism, to be able to work on behalf of arbitrary client user.
+ * Please see https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Superusers.html for details.
+ * The principal and the key tab name to be used for Kerberos authentication are set explicitly
+ * in the factory configuration.
+ *
+ * <p>This factory does not cache any file system instances. If {@code "fs.[prefix].impl.disable.cache"} is set
+ * to {@code true}, file system instances will be cached by Hadoop.
+ */
+public class KerberosHadoopFileSystemFactory extends BasicHadoopFileSystemFactory {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** The default interval used to re-login from the key tab, in milliseconds. */
+ public static final long DFLT_RELOGIN_INTERVAL = 10 * 60 * 1000L;
+
+ /** Keytab full file name. */
+ private String keyTab;
+
+ /** Keytab principal. */
+ private String keyTabPrincipal;
+
+ /** The re-login interval. See {@link #getReloginInterval()} for more information. */
+ private long reloginInterval = DFLT_RELOGIN_INTERVAL;
+
+ /** Time of last re-login attempt, in system milliseconds. */
+ private transient volatile long lastReloginTime;
+
+ /**
+ * Constructor.
+ */
+ public KerberosHadoopFileSystemFactory() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public FileSystem get(String userName) throws IOException {
+ reloginIfNeeded();
+
+ return super.get(userName);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected FileSystem create(String usrName) throws IOException, InterruptedException {
+ UserGroupInformation proxyUgi = UserGroupInformation.createProxyUser(usrName,
+ UserGroupInformation.getLoginUser());
+
+ return proxyUgi.doAs(new PrivilegedExceptionAction<FileSystem>() {
+ @Override public FileSystem run() throws Exception {
+ return FileSystem.get(fullUri, cfg);
+ }
+ });
+ }
+
+ /**
+ * Gets the key tab principal short name (e.g. "hdfs").
+ *
+ * @return The key tab principal.
+ */
+ @Nullable public String getKeyTabPrincipal() {
+ return keyTabPrincipal;
+ }
+
+ /**
+ * Set the key tab principal name. See {@link #getKeyTabPrincipal()} for more information.
+ *
+ * @param keyTabPrincipal The key tab principal name.
+ */
+ public void setKeyTabPrincipal(@Nullable String keyTabPrincipal) {
+ this.keyTabPrincipal = keyTabPrincipal;
+ }
+
+ /**
+ * Gets the key tab full file name (e.g. "/etc/security/keytabs/hdfs.headless.keytab" or "/etc/krb5.keytab").
+ *
+ * @return The key tab file name.
+ */
+ @Nullable public String getKeyTab() {
+ return keyTab;
+ }
+
+ /**
+ * Sets the key tab file name. See {@link #getKeyTab()} for more information.
+ *
+ * @param keyTab The key tab file name.
+ */
+ public void setKeyTab(@Nullable String keyTab) {
+ this.keyTab = keyTab;
+ }
+
+ /**
+ * The interval used to re-login from the key tab, in milliseconds.
+ * Important that the value should not be larger than the Kerberos ticket life time multiplied by 0.2. This is
+ * because the ticket renew window starts from {@code 0.8 * ticket life time}.
+ * Default ticket life time is 1 day (24 hours), so the default re-login interval (10 min)
+ * is obeys this rule well.
+ *
+ * <p>Zero value means that re-login should be attempted on each file system operation.
+ * Negative values are not allowed.
+ *
+ * <p>Note, however, that it does not make sense to make this value small, because Hadoop does not allow to
+ * login if less than {@link org.apache.hadoop.security.UserGroupInformation#MIN_TIME_BEFORE_RELOGIN} milliseconds
+ * have passed since the time of the previous login.
+ * See {@link org.apache.hadoop.security.UserGroupInformation#hasSufficientTimeElapsed(long)} and its usages for
+ * more detail.
+ *
+ * @return The re-login interval, in milliseconds.
+ */
+ public long getReloginInterval() {
+ return reloginInterval;
+ }
+
+ /**
+ * Sets the relogin interval in milliseconds. See {@link #getReloginInterval()} for more information.
+ *
+ * @param reloginInterval The re-login interval, in milliseconds.
+ */
+ public void setReloginInterval(long reloginInterval) {
+ this.reloginInterval = reloginInterval;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start() throws IgniteException {
+ A.ensure(!F.isEmpty(keyTab), "keyTab cannot not be empty.");
+ A.ensure(!F.isEmpty(keyTabPrincipal), "keyTabPrincipal cannot not be empty.");
+ A.ensure(reloginInterval >= 0, "reloginInterval cannot not be negative.");
+
+ super.start();
+
+ try {
+ UserGroupInformation.setConfiguration(cfg);
+ UserGroupInformation.loginUserFromKeytab(keyTabPrincipal, keyTab);
+ }
+ catch (IOException ioe) {
+ throw new IgniteException("Failed login from keytab [keyTab=" + keyTab +
+ ", keyTabPrincipal=" + keyTabPrincipal + ']', ioe);
+ }
+ }
+
+ /**
+ * Re-logins the user if needed.
+ * First, the re-login interval defined in factory is checked. The re-login attempts will be not more
+ * frequent than one attempt per {@code reloginInterval}.
+ * Second, {@link UserGroupInformation#checkTGTAndReloginFromKeytab()} method invoked that gets existing
+ * TGT and checks its validity. If the TGT is expired or is close to expiry, it performs re-login.
+ *
+ * <p>This operation expected to be called upon each operation with the file system created with the factory.
+ * As long as {@link #get(String)} operation is invoked upon each file {@link IgniteHadoopFileSystem}, there
+ * is no need to invoke it otherwise specially.
+ *
+ * @throws IOException If login fails.
+ */
+ private void reloginIfNeeded() throws IOException {
+ long now = System.currentTimeMillis();
+
+ if (now >= lastReloginTime + reloginInterval) {
+ UserGroupInformation.getLoginUser().checkTGTAndReloginFromKeytab();
+
+ lastReloginTime = now;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+
+ U.writeString(out, keyTab);
+ U.writeString(out, keyTabPrincipal);
+ out.writeLong(reloginInterval);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ super.readExternal(in);
+
+ keyTab = U.readString(in);
+ keyTabPrincipal = U.readString(in);
+ reloginInterval = in.readLong();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/008c8cd3/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
new file mode 100644
index 0000000..8fb1612
--- /dev/null
+++ b/modules/hadoop/src/test/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactorySelfTest.java
@@ -0,0 +1,104 @@
+package org.apache.ignite.hadoop.fs;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.util.concurrent.Callable;
+
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
+/**
+ * Tests KerberosHadoopFileSystemFactory.
+ */
+public class KerberosHadoopFileSystemFactorySelfTest extends GridCommonAbstractTest {
+ /**
+ * Test parameters validation.
+ *
+ * @throws Exception If failed.
+ */
+ public void testParameters() throws Exception {
+ checkParameters(null, null, -1);
+
+ checkParameters(null, null, 100);
+ checkParameters(null, "b", -1);
+ checkParameters("a", null, -1);
+
+ checkParameters(null, "b", 100);
+ checkParameters("a", null, 100);
+ checkParameters("a", "b", -1);
+ }
+
+ /**
+ * Check parameters.
+ *
+ * @param keyTab Key tab.
+ * @param keyTabPrincipal Key tab principal.
+ * @param reloginInterval Re-login interval.
+ */
+ @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
+ private void checkParameters(String keyTab, String keyTabPrincipal, long reloginInterval) {
+ final KerberosHadoopFileSystemFactory fac = new KerberosHadoopFileSystemFactory();
+
+ fac.setKeyTab(keyTab);
+ fac.setKeyTabPrincipal(keyTabPrincipal);
+ fac.setReloginInterval(reloginInterval);
+
+ GridTestUtils.assertThrows(null, new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ fac.start();
+
+ return null;
+ }
+ }, IllegalArgumentException.class, null);
+ }
+
+ /**
+ * Checks serializatuion and deserialization of the secure factory.
+ *
+ * @throws Exception If failed.
+ */
+ public void testSerialization() throws Exception {
+ KerberosHadoopFileSystemFactory fac = new KerberosHadoopFileSystemFactory();
+
+ checkSerialization(fac);
+
+ fac = new KerberosHadoopFileSystemFactory();
+
+ fac.setUri("igfs://igfs@localhost:10500/");
+ fac.setConfigPaths("/a/core-sute.xml", "/b/mapred-site.xml");
+ fac.setKeyTabPrincipal("foo");
+ fac.setKeyTab("/etc/krb5.keytab");
+ fac.setReloginInterval(30 * 60 * 1000L);
+
+ checkSerialization(fac);
+ }
+
+ /**
+ * Serializes the factory,
+ *
+ * @param fac The facory to check.
+ * @throws Exception If failed.
+ */
+ private void checkSerialization(KerberosHadoopFileSystemFactory fac) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ ObjectOutput oo = new ObjectOutputStream(baos);
+
+ oo.writeObject(fac);
+
+ ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+
+ KerberosHadoopFileSystemFactory fac2 = (KerberosHadoopFileSystemFactory)in.readObject();
+
+ assertEquals(fac.getUri(), fac2.getUri());
+ Assert.assertArrayEquals(fac.getConfigPaths(), fac2.getConfigPaths());
+ assertEquals(fac.getKeyTab(), fac2.getKeyTab());
+ assertEquals(fac.getKeyTabPrincipal(), fac2.getKeyTabPrincipal());
+ assertEquals(fac.getReloginInterval(), fac2.getReloginInterval());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/008c8cd3/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
index 9092f32..acd255c 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/testsuites/IgniteHadoopTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.client.hadoop.HadoopClientProtocolEmbeddedSelfTest;
import org.apache.ignite.client.hadoop.HadoopClientProtocolSelfTest;
+import org.apache.ignite.hadoop.fs.KerberosHadoopFileSystemFactorySelfTest;
import org.apache.ignite.igfs.Hadoop1OverIgfsDualAsyncTest;
import org.apache.ignite.igfs.Hadoop1OverIgfsDualSyncTest;
import org.apache.ignite.igfs.HadoopFIleSystemFactorySelfTest;
@@ -101,6 +102,8 @@ public class IgniteHadoopTestSuite extends TestSuite {
TestSuite suite = new TestSuite("Ignite Hadoop MR Test Suite");
+ suite.addTest(new TestSuite(ldr.loadClass(KerberosHadoopFileSystemFactorySelfTest.class.getName())));
+
suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyTest.class.getName())));
suite.addTest(new TestSuite(ldr.loadClass(HadoopSnappyFullMapReduceTest.class.getName())));
[11/21] ignite git commit: ignite-2587 Fixed continuous query
notifications in offheap mode and BinaryObjectOffheapImpl usage.
Posted by sb...@apache.org.
ignite-2587 Fixed continuous query notifications in offheap mode and BinaryObjectOffheapImpl usage.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4c05fc02
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4c05fc02
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4c05fc02
Branch: refs/heads/ignite-2542
Commit: 4c05fc0254f446ef040f5d22a066a0d4916a589e
Parents: 0b47d5c
Author: sboikov <sb...@gridgain.com>
Authored: Wed Feb 10 14:07:40 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Feb 10 14:07:40 2016 +0300
----------------------------------------------------------------------
.../processors/cache/CacheLazyEntry.java | 3 +
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheMapEntry.java | 118 +++-
.../binary/CacheObjectBinaryProcessorImpl.java | 6 +-
.../dht/atomic/GridDhtAtomicCache.java | 79 ++-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 85 ++-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 38 +-
.../cache/query/GridCacheQueryManager.java | 30 +-
.../continuous/CacheContinuousQueryHandler.java | 3 +-
.../CacheContinuousQueryListener.java | 2 +-
.../continuous/CacheContinuousQueryManager.java | 120 +++-
.../continuous/GridContinuousProcessor.java | 16 +-
.../IgniteCacheEntryListenerAbstractTest.java | 454 ++++++++----
...cheEntryListenerAtomicOffheapTieredTest.java | 32 +
...cheEntryListenerAtomicOffheapValuesTest.java | 32 +
...teCacheEntryListenerTxOffheapTieredTest.java | 32 +
...teCacheEntryListenerTxOffheapValuesTest.java | 32 +
.../cache/IgniteCacheEntryListenerTxTest.java | 1 +
...ContinuousQueryFailoverAbstractSelfTest.java | 10 +
...tomicPrimaryWriteOrderOffheapTieredTest.java | 33 +
...tinuousQueryFailoverTxOffheapTieredTest.java | 32 +
...acheContinuousQueryRandomOperationsTest.java | 684 +++++++++++++++++++
...ridCacheContinuousQueryAbstractSelfTest.java | 19 +-
...eContinuousQueryAtomicOffheapTieredTest.java | 32 +
...eContinuousQueryAtomicOffheapValuesTest.java | 32 +
...CacheContinuousQueryTxOffheapTieredTest.java | 32 +
...CacheContinuousQueryTxOffheapValuesTest.java | 32 +
.../junits/common/GridCommonAbstractTest.java | 2 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 8 +
.../IgniteCacheQuerySelfTestSuite.java | 14 +
30 files changed, 1743 insertions(+), 274 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
index 05a6fef..30933e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLazyEntry.java
@@ -50,6 +50,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
* @param cctx Cache context.
* @param keyObj Key cache object.
* @param valObj Cache object value.
+ * @param keepBinary Keep binary flag.
*/
public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, CacheObject valObj, boolean keepBinary) {
this.cctx = cctx;
@@ -61,6 +62,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
/**
* @param keyObj Key cache object.
* @param val Value.
+ * @param keepBinary Keep binary flag.
* @param cctx Cache context.
*/
public CacheLazyEntry(GridCacheContext cctx, KeyCacheObject keyObj, V val, boolean keepBinary) {
@@ -75,6 +77,7 @@ public class CacheLazyEntry<K, V> implements Cache.Entry<K, V> {
* @param keyObj Key cache object.
* @param key Key value.
* @param valObj Cache object
+ * @param keepBinary Keep binary flag.
* @param val Cache value.
*/
public CacheLazyEntry(GridCacheContext<K, V> ctx,
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index e875df0..5729959 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1729,10 +1729,10 @@ public class GridCacheContext<K, V> implements Externalizable {
* @return Heap-based object.
*/
@Nullable public <T> T unwrapTemporary(@Nullable Object obj) {
- if (!offheapTiered())
+ if (!useOffheapEntry())
return (T)obj;
- return (T) cacheObjects().unwrapTemporary(this, obj);
+ return (T)cacheObjects().unwrapTemporary(this, obj);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index ae40295..9336e0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Collections;
+import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import javax.cache.Cache;
@@ -44,6 +45,7 @@ import org.apache.ignite.internal.processors.cache.extras.GridCacheMvccEntryExtr
import org.apache.ignite.internal.processors.cache.extras.GridCacheObsoleteEntryExtras;
import org.apache.ignite.internal.processors.cache.extras.GridCacheTtlEntryExtras;
import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryListener;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
@@ -1122,7 +1124,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
assert newVer != null : "Failed to get write version for tx: " + tx;
- old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : this.val;
+ boolean internal = isInternal() || !context().userCache();
+
+ Map<UUID, CacheContinuousQueryListener> lsnrCol =
+ notifyContinuousQueries(tx) ? cctx.continuousQueries().updateListeners(internal, false) : null;
+
+ old = (retval || intercept || lsnrCol != null) ?
+ rawGetOrUnmarshalUnlocked(!retval && !isOffHeapValuesOnly()) : this.val;
if (intercept) {
val0 = CU.value(val, cctx, false);
@@ -1206,10 +1214,19 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
keepBinary);
}
- if (cctx.isLocal() || cctx.isReplicated() ||
- (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())))
- cctx.continuousQueries().onEntryUpdated(key, val, old, isInternal() || !context().userCache(),
- partition(), tx.local(), false, updateCntr0, topVer);
+ if (lsnrCol != null) {
+ cctx.continuousQueries().onEntryUpdated(
+ lsnrCol,
+ key,
+ val,
+ old,
+ internal,
+ partition(),
+ tx.local(),
+ false,
+ updateCntr0,
+ topVer);
+ }
cctx.dataStructures().onEntryUpdated(key, false, keepBinary);
}
@@ -1304,7 +1321,13 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
newVer = explicitVer != null ? explicitVer : tx == null ? nextVersion() : tx.writeVersion();
- old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ boolean internal = isInternal() || !context().userCache();
+
+ Map<UUID, CacheContinuousQueryListener> lsnrCol =
+ notifyContinuousQueries(tx) ? cctx.continuousQueries().updateListeners(internal, false) : null;
+
+ old = (retval || intercept || lsnrCol != null) ?
+ rawGetOrUnmarshalUnlocked(!retval && !isOffHeapValuesOnly()) : val;
if (intercept) {
entry0 = new CacheLazyEntry(cctx, key, old, keepBinary);
@@ -1388,10 +1411,19 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
keepBinary);
}
- if (cctx.isLocal() || cctx.isReplicated() ||
- (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local())))
- cctx.continuousQueries().onEntryUpdated(key, null, old, isInternal()
- || !context().userCache(),partition(), tx.local(), false, updateCntr0, topVer);
+ if (lsnrCol != null) {
+ cctx.continuousQueries().onEntryUpdated(
+ lsnrCol,
+ key,
+ null,
+ old,
+ internal,
+ partition(),
+ tx.local(),
+ false,
+ updateCntr0,
+ topVer);
+ }
cctx.dataStructures().onEntryUpdated(key, true, keepBinary);
@@ -1440,6 +1472,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return new GridCacheUpdateTxResult(false, null);
}
+ /**
+ * @param tx Transaction.
+ * @return {@code True} if should notify continuous query manager.
+ */
+ private boolean notifyContinuousQueries(@Nullable IgniteInternalTx tx) {
+ return cctx.isLocal() ||
+ cctx.isReplicated() ||
+ (!isNear() && !(tx != null && tx.onePhaseCommit() && !tx.local()));
+ }
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public GridTuple3<Boolean, Object, EntryProcessorResult<Object>> innerUpdateLocal(
@@ -1470,7 +1512,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
EntryProcessorResult<Object> invokeRes = null;
synchronized (this) {
- boolean needVal = retval || intercept || op == GridCacheOperation.TRANSFORM || !F.isEmpty(filter);
+ boolean internal = isInternal() || !context().userCache();
+
+ Map<UUID, CacheContinuousQueryListener> lsnrCol =
+ cctx.continuousQueries().updateListeners(internal, false);
+
+ boolean needVal = retval ||
+ intercept ||
+ op == GridCacheOperation.TRANSFORM ||
+ !F.isEmpty(filter) ||
+ lsnrCol != null;
checkObsolete();
@@ -1479,7 +1530,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
unswap(retval);
// Possibly get old value form store.
- old = needVal ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ old = needVal ? rawGetOrUnmarshalUnlocked(!retval && !isOffHeapValuesOnly()) : val;
boolean readFromStore = false;
@@ -1731,11 +1782,20 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (res)
updateMetrics(op, metrics);
- if (!isNear()) {
+ if (lsnrCol != null) {
long updateCntr = nextPartCounter(AffinityTopologyVersion.NONE);
- cctx.continuousQueries().onEntryUpdated(key, val, old, isInternal() || !context().userCache(),
- partition(), true, false, updateCntr, AffinityTopologyVersion.NONE);
+ cctx.continuousQueries().onEntryUpdated(
+ lsnrCol,
+ key,
+ val,
+ old,
+ internal,
+ partition(),
+ true,
+ false,
+ updateCntr,
+ AffinityTopologyVersion.NONE);
}
cctx.dataStructures().onEntryUpdated(key, op == GridCacheOperation.DELETE, keepBinary);
@@ -1997,8 +2057,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (updateCntr != null)
updateCntr0 = updateCntr;
- cctx.continuousQueries().onEntryUpdated(key, evtVal, prevVal, isInternal()
- || !context().userCache(), partition(), primary, false, updateCntr0, topVer);
+ cctx.continuousQueries().onEntryUpdated(
+ key,
+ evtVal,
+ prevVal,
+ isInternal() || !context().userCache(),
+ partition(),
+ primary,
+ false,
+ updateCntr0,
+ topVer);
}
return new GridCacheUpdateAtomicResult(false,
@@ -2019,7 +2087,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
// Prepare old value and value bytes.
- oldVal = needVal ? rawGetOrUnmarshalUnlocked(!retval) : val;
+ oldVal = needVal ? rawGetOrUnmarshalUnlocked(!retval && !isOffHeapValuesOnly()) : val;
// Possibly read value from store.
boolean readFromStore = false;
@@ -2937,7 +3005,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/**
* @return {@code True} if values should be stored off-heap.
*/
- protected boolean isOffHeapValuesOnly() {
+ protected final boolean isOffHeapValuesOnly() {
return cctx.config().getMemoryMode() == CacheMemoryMode.OFFHEAP_VALUES;
}
@@ -3236,8 +3304,16 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
drReplicate(drType, val, ver);
if (!skipQryNtf) {
- cctx.continuousQueries().onEntryUpdated(key, val, null, this.isInternal()
- || !this.context().userCache(), this.partition(), true, preload, updateCntr, topVer);
+ cctx.continuousQueries().onEntryUpdated(
+ key,
+ val,
+ null,
+ this.isInternal() || !this.context().userCache(),
+ this.partition(),
+ true,
+ preload,
+ updateCntr,
+ topVer);
cctx.dataStructures().onEntryUpdated(key, false, true);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 0fef6f8..f091fc7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -822,10 +822,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
Object val = unmarshal(valPtr, !tmp);
- if (val instanceof BinaryObjectOffheapImpl)
- return (BinaryObjectOffheapImpl)val;
+ if (val instanceof CacheObject)
+ return (CacheObject)val;
- return new CacheObjectImpl(val, null);
+ return toCacheObject(ctx.cacheObjectContext(), val, false);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index 6c7bac5..fec61df 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -76,6 +76,7 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSing
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrExpirationInfo;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryListener;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext;
@@ -1992,6 +1993,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
boolean intercept = ctx.config().getInterceptor() != null;
+ boolean initLsnrs = false;
+ Map<UUID, CacheContinuousQueryListener> lsnrs = null;
+ boolean internal = false;
+
// Avoid iterator creation.
for (int i = 0; i < keys.size(); i++) {
KeyCacheObject k = keys.get(i);
@@ -2006,6 +2011,14 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (entry == null)
continue;
+ if (!initLsnrs) {
+ internal = entry.isInternal() || !context().userCache();
+
+ lsnrs = ctx.continuousQueries().updateListeners(internal, false);
+
+ initLsnrs = true;
+ }
+
GridCacheVersion newConflictVer = req.conflictVersion(i);
long newConflictTtl = req.conflictTtl(i);
long newConflictExpireTime = req.conflictExpireTime(i);
@@ -2034,7 +2047,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
req.invokeArguments(),
primary && writeThrough() && !req.skipStore(),
!req.skipStore(),
- sndPrevVal || req.returnValue(),
+ lsnrs != null || sndPrevVal || req.returnValue(),
req.keepBinary(),
expiry,
true,
@@ -2061,6 +2074,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
if (dhtFut != null) {
+ dhtFut.listeners(lsnrs);
+
if (updRes.sendToDht()) { // Send to backups even in case of remove-remove scenarios.
GridCacheVersionConflictContext<?, ?> conflictCtx = updRes.conflictResolveResult();
@@ -2097,10 +2112,18 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
"[entry=" + entry + ", filter=" + Arrays.toString(req.filter()) + ']');
}
}
- else if (!entry.isNear() && updRes.success()) {
- ctx.continuousQueries().onEntryUpdated(entry.key(), updRes.newValue(), updRes.oldValue(),
- entry.isInternal() || !context().userCache(), entry.partition(), primary, false,
- updRes.updateCounter(), topVer);
+ else if (lsnrs != null && updRes.success()) {
+ ctx.continuousQueries().onEntryUpdated(
+ lsnrs,
+ entry.key(),
+ updRes.newValue(),
+ updRes.oldValue(),
+ internal,
+ entry.partition(),
+ primary,
+ false,
+ updRes.updateCounter(),
+ topVer);
}
if (hasNear) {
@@ -2275,6 +2298,9 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
boolean intercept = ctx.config().getInterceptor() != null;
+ boolean initLsnrs = false;
+ Map<UUID, CacheContinuousQueryListener> lsnrs = null;
+
// Avoid iterator creation.
for (int i = 0; i < entries.size(); i++) {
GridDhtCacheEntry entry = entries.get(i);
@@ -2308,6 +2334,14 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
filteredReaders = F.view(entry.readers(), F.notEqualTo(node.id()));
}
+ if (!initLsnrs) {
+ lsnrs = ctx.continuousQueries().updateListeners(
+ entry.isInternal() || !context().userCache(),
+ false);
+
+ initLsnrs = true;
+ }
+
GridCacheUpdateAtomicResult updRes = entry.innerUpdate(
ver,
node.id(),
@@ -2317,7 +2351,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
null,
/*write-through*/false,
/*read-through*/false,
- /*retval*/sndPrevVal,
+ /*retval*/sndPrevVal || lsnrs != null,
req.keepBinary(),
expiry,
/*event*/true,
@@ -2366,6 +2400,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
if (dhtFut != null) {
+ dhtFut.listeners(lsnrs);
+
EntryProcessor<Object, Object, Object> entryProcessor =
entryProcessorMap == null ? null : entryProcessorMap.get(entry.key());
@@ -2763,6 +2799,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
String taskName = ctx.kernalContext().task().resolveTaskName(req.taskNameHash());
+ boolean initLsnrs = false;
+ Map<UUID, CacheContinuousQueryListener> lsnrs = null;
+ boolean internal = false;
+
for (int i = 0; i < req.size(); i++) {
KeyCacheObject key = req.key(i);
@@ -2785,6 +2825,14 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
long ttl = req.ttl(i);
long expireTime = req.conflictExpireTime(i);
+ if (!initLsnrs) {
+ internal = entry.isInternal() || !context().userCache();
+
+ lsnrs = ctx.continuousQueries().updateListeners(internal, false);
+
+ initLsnrs = true;
+ }
+
GridCacheUpdateAtomicResult updRes = entry.innerUpdate(
ver,
nodeId,
@@ -2794,7 +2842,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
op == TRANSFORM ? req.invokeArguments() : null,
/*write-through*/false,
/*read-through*/false,
- /*retval*/false,
+ /*retval*/lsnrs != null,
req.keepBinary(),
/*expiry policy*/null,
/*event*/true,
@@ -2817,10 +2865,19 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (updRes.removeVersion() != null)
ctx.onDeferredDelete(entry, updRes.removeVersion());
- if (updRes.success() && !entry.isNear())
- ctx.continuousQueries().onEntryUpdated(entry.key(), updRes.newValue(),
- updRes.oldValue(), entry.isInternal() || !context().userCache(), entry.partition(),
- false, false, updRes.updateCounter(), req.topologyVersion());
+ if (lsnrs != null && updRes.success()) {
+ ctx.continuousQueries().onEntryUpdated(
+ lsnrs,
+ entry.key(),
+ updRes.newValue(),
+ updRes.oldValue(),
+ internal,
+ entry.partition(),
+ false,
+ false,
+ updRes.updateCounter(),
+ req.topologyVersion());
+ }
entry.onUnlock();
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
index 06c8441..58d704d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
+import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryListener;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -102,6 +103,9 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
/** Response count. */
private volatile int resCnt;
+ /** */
+ private Map<UUID, CacheContinuousQueryListener> lsnrs;
+
/**
* @param cctx Cache context.
* @param completionCb Callback to invoke when future is completed.
@@ -136,6 +140,13 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
waitForExchange = !topLocked;
}
+ /**
+ * @param lsnrs Continuous query listeners.
+ */
+ void listeners(@Nullable Map<UUID, CacheContinuousQueryListener> lsnrs) {
+ this.lsnrs = lsnrs;
+ }
+
/** {@inheritDoc} */
@Override public IgniteUuid futureId() {
return futVer.asGridUuid();
@@ -215,6 +226,8 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
* @param ttl TTL (optional).
* @param conflictExpireTime Conflict expire time (optional).
* @param conflictVer Conflict version (optional).
+ * @param addPrevVal If {@code true} sends previous value to backups.
+ * @param prevVal Previous value.
* @param updateCntr Partition update counter.
*/
public void addWriteEntry(GridDhtCacheEntry entry,
@@ -270,13 +283,22 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
addPrevVal,
entry.partition(),
prevVal,
- updateCntr);
+ updateCntr,
+ lsnrs != null);
}
- else if (dhtNodes.size() == 1) {
+ else if (lsnrs != null && dhtNodes.size() == 1) {
try {
- cctx.continuousQueries().onEntryUpdated(entry.key(), val, prevVal,
- entry.key().internal() || !cctx.userCache(), entry.partition(), true, false,
- updateCntr, updateReq.topologyVersion());
+ cctx.continuousQueries().onEntryUpdated(
+ lsnrs,
+ entry.key(),
+ val,
+ prevVal,
+ entry.key().internal() || !cctx.userCache(),
+ entry.partition(),
+ true,
+ false,
+ updateCntr,
+ updateReq.topologyVersion());
}
catch (IgniteCheckedException e) {
U.warn(log, "Failed to send continuous query message. [key=" + entry.key() + ", newVal="
@@ -352,7 +374,7 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
cctx.mvcc().removeAtomicFuture(version());
if (err != null) {
- if (!mappings.isEmpty()) {
+ if (!mappings.isEmpty() && lsnrs != null) {
Collection<KeyCacheObject> hndKeys = new ArrayList<>(keys.size());
exit: for (GridDhtAtomicUpdateRequest req : mappings.values()) {
@@ -362,7 +384,11 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
if (!hndKeys.contains(key)) {
updateRes.addFailedKey(key, err);
- cctx.continuousQueries().skipUpdateEvent(key, req.partitionId(i), req.updateCounter(i),
+ cctx.continuousQueries().skipUpdateEvent(
+ lsnrs,
+ key,
+ req.partitionId(i),
+ req.updateCounter(i),
updateReq.topologyVersion());
hndKeys.add(key);
@@ -378,27 +404,38 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
updateRes.addFailedKey(key, err);
}
else {
- Collection<KeyCacheObject> hndKeys = new ArrayList<>(keys.size());
+ if (lsnrs != null) {
+ Collection<KeyCacheObject> hndKeys = new ArrayList<>(keys.size());
- exit: for (GridDhtAtomicUpdateRequest req : mappings.values()) {
- for (int i = 0; i < req.size(); i++) {
- KeyCacheObject key = req.key(i);
+ exit: for (GridDhtAtomicUpdateRequest req : mappings.values()) {
+ for (int i = 0; i < req.size(); i++) {
+ KeyCacheObject key = req.key(i);
- if (!hndKeys.contains(key)) {
- try {
- cctx.continuousQueries().onEntryUpdated(key, req.value(i), req.localPreviousValue(i),
- key.internal() || !cctx.userCache(), req.partitionId(i), true, false,
- req.updateCounter(i), updateReq.topologyVersion());
- }
- catch (IgniteCheckedException e) {
- U.warn(log, "Failed to send continuous query message. [key=" + key + ", newVal="
- + req.value(i) + ", err=" + e + "]");
- }
+ if (!hndKeys.contains(key)) {
+ try {
+ cctx.continuousQueries().onEntryUpdated(
+ lsnrs,
+ key,
+ req.value(i),
+ req.localPreviousValue(i),
+ key.internal() || !cctx.userCache(),
+ req.partitionId(i),
+ true,
+ false,
+ req.updateCounter(i),
+ updateReq.topologyVersion());
+ }
+ catch (IgniteCheckedException e) {
+ U.warn(log, "Failed to send continuous query message. [key=" + key +
+ ", newVal=" + req.value(i) +
+ ", err=" + e + "]");
+ }
- hndKeys.add(key);
+ hndKeys.add(key);
- if (hndKeys.size() == keys.size())
- break exit;
+ if (hndKeys.size() == keys.size())
+ break exit;
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
index 7cc276f..e417cdb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.internal.GridDirectCollection;
import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.IgniteCodeGeneratingFail;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -49,6 +50,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Lite dht cache backup update request.
*/
+@IgniteCodeGeneratingFail // Need add 'cleanup' call in 'writeTo' method.
public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements GridCacheDeployable {
/** */
private static final long serialVersionUID = 0L;
@@ -215,7 +217,6 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
keys = new ArrayList<>();
partIds = new ArrayList<>();
- locPrevVals = new ArrayList<>();
if (forceTransformBackups) {
entryProcessors = new ArrayList<>();
@@ -240,7 +241,10 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
* @param conflictExpireTime Conflict expire time (optional).
* @param conflictVer Conflict version (optional).
* @param addPrevVal If {@code true} adds previous value.
+ * @param partId Partition.
* @param prevVal Previous value.
+ * @param updateCntr Update counter.
+ * @param storeLocPrevVal If {@code true} stores previous value.
*/
public void addWriteValue(KeyCacheObject key,
@Nullable CacheObject val,
@@ -251,12 +255,18 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
boolean addPrevVal,
int partId,
@Nullable CacheObject prevVal,
- @Nullable Long updateIdx) {
+ @Nullable Long updateCntr,
+ boolean storeLocPrevVal) {
keys.add(key);
partIds.add(partId);
- locPrevVals.add(prevVal);
+ if (storeLocPrevVal) {
+ if (locPrevVals == null)
+ locPrevVals = new ArrayList<>();
+
+ locPrevVals.add(prevVal);
+ }
if (forceTransformBackups) {
assert entryProcessor != null;
@@ -273,11 +283,11 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
prevVals.add(prevVal);
}
- if (updateIdx != null) {
+ if (updateCntr != null) {
if (updateCntrs == null)
updateCntrs = new GridLongList();
- updateCntrs.add(updateIdx);
+ updateCntrs.add(updateCntr);
}
// In case there is no conflict, do not create the list.
@@ -521,6 +531,8 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
* @return Value.
*/
@Nullable public CacheObject localPreviousValue(int idx) {
+ assert locPrevVals != null;
+
return locPrevVals.get(idx);
}
@@ -849,6 +861,8 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
}
+ cleanup();
+
return true;
}
@@ -1048,6 +1062,20 @@ public class GridDhtAtomicUpdateRequest extends GridCacheMessage implements Grid
return reader.afterMessageRead(GridDhtAtomicUpdateRequest.class);
}
+ /**
+ * Cleanup values not needed after message was sent.
+ */
+ private void cleanup() {
+ nearVals = null;
+ prevVals = null;
+
+ // Do not keep values if they are not needed for continuous query notification.
+ if (locPrevVals == null) {
+ vals = null;
+ locPrevVals = null;
+ }
+ }
+
/** {@inheritDoc} */
@Override public byte directType() {
return 38;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 8f0cab7..0d8f795 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -1107,7 +1107,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
next = null;
while (it.hasNext()) {
- final LazySwapEntry e = new LazySwapEntry(it.next(), keepBinary);
+ final LazySwapEntry e = new LazySwapEntry(it.next());
if (filter != null) {
K key = (K)cctx.unwrapBinaryIfNeeded(e.key(), keepBinary);
@@ -2524,15 +2524,11 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
/** */
private final Map.Entry<byte[], byte[]> e;
- /** */
- private boolean keepBinary;
-
/**
* @param e Entry with
*/
- LazySwapEntry(Map.Entry<byte[], byte[]> e, boolean keepBinary) {
+ LazySwapEntry(Map.Entry<byte[], byte[]> e) {
this.e = e;
- this.keepBinary = keepBinary;
}
/** {@inheritDoc} */
@@ -2545,9 +2541,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
@Override protected V unmarshalValue() throws IgniteCheckedException {
IgniteBiTuple<byte[], Byte> t = GridCacheSwapEntryImpl.getValue(e.getValue());
- CacheObject obj = cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1());
-
- return (V)cctx.cacheObjectContext().unwrapBinaryIfNeeded(obj, keepBinary);
+ return (V)cctx.cacheObjects().toCacheObject(cctx.cacheObjectContext(), t.get2(), t.get1());
}
/** {@inheritDoc} */
@@ -2597,13 +2591,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
@Override protected V unmarshalValue() throws IgniteCheckedException {
long ptr = GridCacheOffheapSwapEntry.valueAddress(valPtr.get1(), valPtr.get2());
- CacheObject obj = cctx.fromOffheap(ptr, false);
-
- V val = CU.value(obj, cctx, false);
-
- assert val != null;
-
- return val;
+ return (V)cctx.fromOffheap(ptr, false);
}
/** {@inheritDoc} */
@@ -2661,7 +2649,15 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
if (!filter.apply(key, val))
return null;
- return new IgniteBiTuple<>(e.key(), (V)cctx.unwrapTemporary(e.value()));
+ if (key instanceof CacheObject)
+ ((CacheObject)key).prepareMarshal(cctx.cacheObjectContext());
+
+ val = (V)cctx.unwrapTemporary(e.value());
+
+ if (val instanceof CacheObject)
+ ((CacheObject)val).prepareMarshal(cctx.cacheObjectContext());
+
+ return new IgniteBiTuple<>(e.key(), val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
index 7e66ad3..cf9b439 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryHandler.java
@@ -882,8 +882,7 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
* @return Continuous query entry.
*/
private CacheContinuousQueryEntry skipEntry(CacheContinuousQueryEntry e) {
- if (lastFiredCntr.get() > e.updateCounter() || e.updateCounter() == 1) {
-
+ if (lastFiredCntr.get() > e.updateCounter() || e.updateCounter() == 1L) {
e.markFiltered();
return e;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
index 86abbef..dce04de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryListener.java
@@ -24,7 +24,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
/**
* Continuous query listener.
*/
-interface CacheContinuousQueryListener<K, V> {
+public interface CacheContinuousQueryListener<K, V> {
/**
* Query execution callback.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 0e4cb40..cc59989 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -60,6 +60,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.resources.LoggerResource;
+import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import static javax.cache.event.EventType.CREATED;
@@ -155,37 +156,102 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
}
/**
+ * @param lsnrs Listeners to notify.
+ * @param key Entry key.
* @param partId Partition id.
* @param updCntr Updated counter.
* @param topVer Topology version.
*/
- public void skipUpdateEvent(KeyCacheObject key, int partId, long updCntr, AffinityTopologyVersion topVer) {
- if (lsnrCnt.get() > 0) {
- for (CacheContinuousQueryListener lsnr : lsnrs.values()) {
- CacheContinuousQueryEntry e0 = new CacheContinuousQueryEntry(
- cctx.cacheId(),
- UPDATED,
- key,
- null,
- null,
- lsnr.keepBinary(),
- partId,
- updCntr,
- topVer);
+ public void skipUpdateEvent(Map<UUID, CacheContinuousQueryListener> lsnrs,
+ KeyCacheObject key, int partId, long updCntr, AffinityTopologyVersion topVer) {
+ assert lsnrs != null;
- CacheContinuousQueryEvent evt = new CacheContinuousQueryEvent<>(
- cctx.kernalContext().cache().jcache(cctx.name()), cctx, e0);
+ for (CacheContinuousQueryListener lsnr : lsnrs.values()) {
+ CacheContinuousQueryEntry e0 = new CacheContinuousQueryEntry(
+ cctx.cacheId(),
+ UPDATED,
+ key,
+ null,
+ null,
+ lsnr.keepBinary(),
+ partId,
+ updCntr,
+ topVer);
- lsnr.skipUpdateEvent(evt, topVer);
- }
+ CacheContinuousQueryEvent evt = new CacheContinuousQueryEvent<>(
+ cctx.kernalContext().cache().jcache(cctx.name()), cctx, e0);
+
+ lsnr.skipUpdateEvent(evt, topVer);
}
}
/**
+ * @param internal Internal entry flag (internal key or not user cache).
+ * @param preload Whether update happened during preloading.
+ * @return Registered listeners.
+ */
+ @Nullable public Map<UUID, CacheContinuousQueryListener> updateListeners(
+ boolean internal,
+ boolean preload) {
+ if (preload && !internal)
+ return null;
+
+ ConcurrentMap<UUID, CacheContinuousQueryListener> lsnrCol;
+
+ if (internal)
+ lsnrCol = intLsnrCnt.get() > 0 ? intLsnrs : null;
+ else
+ lsnrCol = lsnrCnt.get() > 0 ? lsnrs : null;
+
+ return F.isEmpty(lsnrCol) ? null : lsnrCol;
+ }
+
+ /**
+ * @param key Key.
+ * @param newVal New value.
+ * @param oldVal Old value.
+ * @param internal Internal entry (internal key or not user cache).
+ * @param partId Partition.
+ * @param primary {@code True} if called on primary node.
+ * @param preload Whether update happened during preloading.
+ * @param updateCntr Update counter.
+ * @param topVer Topology version.
+ * @throws IgniteCheckedException In case of error.
+ */
+ public void onEntryUpdated(
+ KeyCacheObject key,
+ CacheObject newVal,
+ CacheObject oldVal,
+ boolean internal,
+ int partId,
+ boolean primary,
+ boolean preload,
+ long updateCntr,
+ AffinityTopologyVersion topVer) throws IgniteCheckedException {
+ Map<UUID, CacheContinuousQueryListener> lsnrCol = updateListeners(internal, preload);
+
+ if (lsnrCol != null) {
+ onEntryUpdated(
+ lsnrCol,
+ key,
+ newVal,
+ oldVal,
+ internal,
+ partId,
+ primary,
+ preload,
+ updateCntr,
+ topVer);
+ }
+ }
+
+ /**
+ * @param lsnrCol Listeners to notify.
* @param key Key.
* @param newVal New value.
* @param oldVal Old value.
* @param internal Internal entry (internal key or not user cache),
+ * @param partId Partition.
* @param primary {@code True} if called on primary node.
* @param preload Whether update happened during preloading.
* @param updateCntr Update counter.
@@ -193,6 +259,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
* @throws IgniteCheckedException In case of error.
*/
public void onEntryUpdated(
+ Map<UUID, CacheContinuousQueryListener> lsnrCol,
KeyCacheObject key,
CacheObject newVal,
CacheObject oldVal,
@@ -205,25 +272,16 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
throws IgniteCheckedException
{
assert key != null;
-
- if (preload && !internal)
- return;
-
- ConcurrentMap<UUID, CacheContinuousQueryListener> lsnrCol;
-
- if (internal)
- lsnrCol = intLsnrCnt.get() > 0 ? intLsnrs : null;
- else
- lsnrCol = lsnrCnt.get() > 0 ? lsnrs : null;
-
- if (F.isEmpty(lsnrCol))
- return;
+ assert lsnrCol != null;
boolean hasNewVal = newVal != null;
boolean hasOldVal = oldVal != null;
- if (!hasNewVal && !hasOldVal)
+ if (!hasNewVal && !hasOldVal) {
+ skipUpdateEvent(lsnrCol, key, partId, updateCntr, topVer);
+
return;
+ }
EventType evtType = !hasNewVal ? REMOVED : !hasOldVal ? CREATED : UPDATED;
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/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 7c7e3e3..0218897 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
@@ -55,6 +55,7 @@ import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryHandler;
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -893,11 +894,18 @@ public class GridContinuousProcessor extends GridProcessorAdapter {
}
// Load partition counters.
- if (hnd.isQuery() && ctx.cache() != null && ctx.cache().internalCache(hnd.cacheName()) != null) {
- Map<Integer, Long> cntrs = ctx.cache().internalCache(hnd.cacheName())
- .context().topology().updateCounters();
+ if (hnd.isQuery()) {
+ GridCacheProcessor proc = ctx.cache();
- req.addUpdateCounters(cntrs);
+ if (proc != null) {
+ GridCacheAdapter cache = ctx.cache().internalCache(hnd.cacheName());
+
+ if (cache != null && !cache.isLocal()) {
+ Map<Integer, Long> cntrs = cache.context().topology().updateCounters();
+
+ req.addUpdateCounters(cntrs);
+ }
+ }
}
if (err != null)
[10/21] ignite git commit: ignite-2587 Fixed continuous query
notifications in offheap mode and BinaryObjectOffheapImpl usage.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
index 27edb0c..e6bfd87 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAbstractTest.java
@@ -21,6 +21,7 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -56,6 +57,7 @@ import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.continuous.GridContinuousProcessor;
@@ -70,6 +72,7 @@ import static javax.cache.event.EventType.CREATED;
import static javax.cache.event.EventType.EXPIRED;
import static javax.cache.event.EventType.REMOVED;
import static javax.cache.event.EventType.UPDATED;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
import static org.apache.ignite.cache.CacheMode.LOCAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -79,7 +82,7 @@ import static org.apache.ignite.cache.CacheMode.REPLICATED;
*/
public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAbstractTest {
/** */
- private static volatile List<CacheEntryEvent<? extends Integer, ? extends Integer>> evts;
+ private static volatile List<CacheEntryEvent<?, ?>> evts;
/** */
private static volatile CountDownLatch evtsLatch;
@@ -91,7 +94,10 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
private Integer lastKey = 0;
/** */
- private CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg;
+ private CacheEntryListenerConfiguration<Object, Object> lsnrCfg;
+
+ /** */
+ private boolean useObjects;
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@@ -103,9 +109,18 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
cfg.setEagerTtl(eagerTtl());
+ cfg.setMemoryMode(memoryMode());
+
return cfg;
}
+ /**
+ * @return Cache memory mode.
+ */
+ protected CacheMemoryMode memoryMode() {
+ return ONHEAP_TIERED;
+ }
+
/** {@inheritDoc} */
@Override protected void afterTest() throws Exception {
super.afterTest();
@@ -129,9 +144,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @throws Exception If failed.
*/
public void testExceptionIgnored() throws Exception {
- CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
- new Factory<CacheEntryListener<Integer, Integer>>() {
- @Override public CacheEntryListener<Integer, Integer> create() {
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ new Factory<CacheEntryListener<Object, Object>>() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new ExceptionListener();
}
},
@@ -140,7 +155,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
false
);
- IgniteCache<Integer, Integer> cache = jcache();
+ IgniteCache<Object, Object> cache = jcache();
cache.registerCacheEntryListener(lsnrCfg);
@@ -158,13 +173,13 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
}
lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
- new Factory<CacheEntryListener<Integer, Integer>>() {
- @Override public CacheEntryListener<Integer, Integer> create() {
+ new Factory<CacheEntryListener<Object, Object>>() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateUpdateRemoveExpireListener();
}
},
- new Factory<CacheEntryEventSerializableFilter<? super Integer, ? super Integer>>() {
- @Override public CacheEntryEventSerializableFilter<? super Integer, ? super Integer> create() {
+ new Factory<CacheEntryEventSerializableFilter<Object, Object>>() {
+ @Override public CacheEntryEventSerializableFilter<Object, Object> create() {
return new ExceptionFilter();
}
},
@@ -192,9 +207,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @throws Exception If failed.
*/
public void testNoOldValue() throws Exception {
- CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
- new Factory<CacheEntryListener<Integer, Integer>>() {
- @Override public CacheEntryListener<Integer, Integer> create() {
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ new Factory<CacheEntryListener<Object, Object>>() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateUpdateRemoveExpireListener();
}
},
@@ -203,7 +218,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
true
);
- IgniteCache<Integer, Integer> cache = jcache();
+ IgniteCache<Object, Object> cache = jcache();
try {
for (Integer key : keys()) {
@@ -222,21 +237,30 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
* @throws Exception If failed.
*/
+ public void testSynchronousEventsObjectKeyValue() throws Exception {
+ useObjects = true;
+
+ testSynchronousEvents();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testSynchronousEvents() throws Exception {
- final CacheEntryCreatedListener<Integer, Integer> lsnr = new CreateUpdateRemoveExpireListener() {
- @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ final CacheEntryCreatedListener<Object, Object> lsnr = new CreateUpdateRemoveExpireListener() {
+ @Override public void onRemoved(Iterable<CacheEntryEvent<?, ?>> evts) {
super.onRemoved(evts);
awaitLatch();
}
- @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onCreated(Iterable<CacheEntryEvent<?, ?>> evts) {
super.onCreated(evts);
awaitLatch();
}
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
super.onUpdated(evts);
awaitLatch();
@@ -252,9 +276,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
}
};
- CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
- new Factory<CacheEntryListener<Integer, Integer>>() {
- @Override public CacheEntryListener<Integer, Integer> create() {
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ new Factory<CacheEntryListener<Object, Object>>() {
+ @Override public CacheEntryListener<Object, Object> create() {
return lsnr;
}
},
@@ -263,7 +287,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
true
);
- IgniteCache<Integer, Integer> cache = jcache();
+ IgniteCache<Object, Object> cache = jcache();
cache.registerCacheEntryListener(lsnrCfg);
@@ -299,7 +323,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
if (!eagerTtl()) {
U.sleep(1100);
- assertNull(primaryCache(key, cache.getName()).get(key));
+ assertNull(primaryCache(key, cache.getName()).get(key(key)));
evtsLatch.await(5000, MILLISECONDS);
@@ -378,13 +402,13 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
final CyclicBarrier barrier = new CyclicBarrier(THREADS);
- final IgniteCache<Integer, Integer> cache = jcache(0);
+ final IgniteCache<Object, Object> cache = jcache(0);
GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
- CacheEntryListenerConfiguration<Integer, Integer> cfg = new MutableCacheEntryListenerConfiguration<>(
- new Factory<CacheEntryListener<Integer, Integer>>() {
- @Override public CacheEntryListener<Integer, Integer> create() {
+ CacheEntryListenerConfiguration<Object, Object> cfg = new MutableCacheEntryListenerConfiguration<>(
+ new Factory<CacheEntryListener<Object, Object>>() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateUpdateRemoveExpireListener();
}
},
@@ -441,9 +465,13 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @param expEvts Expected events number.
* @throws Exception If failed.
*/
- private void syncEvent(Integer key, Integer val, IgniteCache<Integer, Integer> cache, int expEvts)
+ private void syncEvent(
+ Integer key,
+ Integer val,
+ IgniteCache<Object, Object> cache,
+ int expEvts)
throws Exception {
- evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<? extends Integer, ? extends Integer>>());
+ evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<?, ?>>());
evtsLatch = new CountDownLatch(expEvts);
@@ -466,9 +494,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
});
if (val != null)
- cache.put(key, val);
+ cache.put(key(key), value(val));
else
- cache.remove(key);
+ cache.remove(key(key));
done.set(true);
@@ -480,15 +508,45 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
}
/**
+ * @param key Integer key.
+ * @return Key instance.
+ */
+ private Object key(Integer key) {
+ assert key != null;
+
+ return useObjects ? new ListenerTestKey(key) : key;
+ }
+
+ /**
+ * @param val Integer value.
+ * @return Value instance.
+ */
+ private Object value(Integer val) {
+ if (val == null)
+ return null;
+
+ return useObjects ? new ListenerTestValue(val) : val;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testEventsObjectKeyValue() throws Exception {
+ useObjects = true;
+
+ testEvents();
+ }
+
+ /**
* @throws Exception If failed.
*/
public void testEvents() throws Exception {
- IgniteCache<Integer, Integer> cache = jcache();
+ IgniteCache<Object, Object> cache = jcache();
- Map<Integer, Integer> vals = new HashMap<>();
+ Map<Object, Object> vals = new HashMap<>();
for (int i = 0; i < 100; i++)
- vals.put(i + 2_000_000, i);
+ vals.put(key(i + 2_000_000), value(i));
cache.putAll(vals); // Put some data in cache to make sure events are not generated for existing entries.
@@ -518,7 +576,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
checkEvents(cache, new CreateUpdateRemoveExpireListenerFactory(), key, true, true, true, true);
}
- CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
new CreateUpdateRemoveExpireListenerFactory(),
new TestFilterFactory(),
true,
@@ -551,7 +609,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @throws Exception If failed.
*/
@SuppressWarnings("unchecked")
- private void checkListenerOnStart(Map<Integer, Integer> vals) throws Exception {
+ private void checkListenerOnStart(Map<Object, Object> vals) throws Exception {
lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
new CreateUpdateRemoveExpireListenerFactory(),
null,
@@ -564,7 +622,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
try {
awaitPartitionMapExchange();
- IgniteCache<Integer, Integer> cache = grid.cache(null);
+ IgniteCache<Object, Object> cache = grid.cache(null);
Integer key = Integer.MAX_VALUE;
@@ -588,7 +646,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
try {
awaitPartitionMapExchange();
- IgniteCache<Integer, Integer> cache = grid.cache(null);
+ IgniteCache<Object, Object> cache = grid.cache(null);
log.info("Check filter for listener in configuration.");
@@ -613,14 +671,14 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @throws Exception If failed.
*/
private void checkEvents(
- final IgniteCache<Integer, Integer> cache,
- final Factory<CacheEntryListener<Integer, Integer>> lsnrFactory,
+ final IgniteCache<Object, Object> cache,
+ final Factory<CacheEntryListener<Object, Object>> lsnrFactory,
Integer key,
boolean create,
boolean update,
boolean rmv,
boolean expire) throws Exception {
- CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
+ CacheEntryListenerConfiguration<Object, Object> lsnrCfg = new MutableCacheEntryListenerConfiguration<>(
lsnrFactory,
null,
true,
@@ -642,8 +700,8 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @param vals Values in cache.
* @throws Exception If failed.
*/
- private void checkFilter(final IgniteCache<Integer, Integer> cache, Map<Integer, Integer> vals) throws Exception {
- evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<? extends Integer, ? extends Integer>>());
+ private void checkFilter(final IgniteCache<Object, Object> cache, Map<Object, Object> vals) throws Exception {
+ evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<?, ?>>());
final int expEvts = (vals.size() / 2) * 4; // Remove, create, update and expire for half of modified entries.
@@ -653,16 +711,18 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
cache.putAll(vals);
- final Map<Integer, Integer> newVals = new HashMap<>();
+ final Map<Object, Object> newVals = new HashMap<>();
- for (Integer key : vals.keySet())
- newVals.put(key, -1);
+ for (Object key : vals.keySet())
+ newVals.put(key, value(-1));
cache.withExpiryPolicy(new ModifiedExpiryPolicy(new Duration(MILLISECONDS, 500))).putAll(newVals);
+ U.sleep(1000);
+
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override public boolean apply() {
- for (Integer key : newVals.keySet()) {
+ for (Object key : newVals.keySet()) {
if (primaryCache(key, cache.getName()).get(key) != null)
return false;
}
@@ -675,13 +735,20 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
assertEquals(expEvts, evts.size());
- Set<Integer> rmvd = new HashSet<>();
- Set<Integer> created = new HashSet<>();
- Set<Integer> updated = new HashSet<>();
- Set<Integer> expired = new HashSet<>();
+ Set<Object> rmvd = new HashSet<>();
+ Set<Object> created = new HashSet<>();
+ Set<Object> updated = new HashSet<>();
+ Set<Object> expired = new HashSet<>();
+
+ for (CacheEntryEvent<?, ?> evt : evts) {
+ Integer key;
+
+ if (useObjects)
+ key = ((ListenerTestKey)evt.getKey()).key;
+ else
+ key = (Integer)evt.getKey();
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
- assertTrue(evt.getKey() % 2 == 0);
+ assertTrue(key % 2 == 0);
assertTrue(vals.keySet().contains(evt.getKey()));
@@ -707,7 +774,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
break;
case UPDATED:
- assertEquals(-1, (int)evt.getValue());
+ assertEquals(value(-1), evt.getValue());
assertEquals(vals.get(evt.getKey()), evt.getOldValue());
@@ -722,7 +789,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
case EXPIRED:
assertNull(evt.getValue());
- assertEquals(-1, (int)evt.getOldValue());
+ assertEquals(value(-1), evt.getOldValue());
assertTrue(rmvd.contains(evt.getKey()));
@@ -757,8 +824,8 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @throws Exception If failed.
*/
private void checkEvents(
- final IgniteCache<Integer, Integer> cache,
- final CacheEntryListenerConfiguration<Integer, Integer> lsnrCfg,
+ final IgniteCache<Object, Object> cache,
+ final CacheEntryListenerConfiguration<Object, Object> lsnrCfg,
Integer key,
boolean create,
boolean update,
@@ -789,64 +856,64 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
if (expire)
expEvts += 2;
- evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<? extends Integer, ? extends Integer>>());
+ evts = Collections.synchronizedList(new ArrayList<CacheEntryEvent<?, ?>>());
evtsLatch = new CountDownLatch(expEvts);
- cache.put(key, 0);
+ cache.put(key(key), value(0));
for (int i = 0; i < UPDATES; i++) {
if (i % 2 == 0)
- cache.put(key, i + 1);
+ cache.put(key(key), value(i + 1));
else
- cache.invoke(key, new EntrySetValueProcessor(i + 1));
+ cache.invoke(key(key), new EntrySetValueProcessor(value(i + 1)));
}
// Invoke processor does not update value, should not trigger event.
- assertEquals(String.valueOf(UPDATES), cache.invoke(key, new EntryToStringProcessor()));
+ assertEquals(String.valueOf(UPDATES), cache.invoke(key(key), new EntryToStringProcessor()));
- assertFalse(cache.putIfAbsent(key, -1));
+ assertFalse(cache.putIfAbsent(key(key), value(-1)));
- assertFalse(cache.remove(key, -1));
+ assertFalse(cache.remove(key(key), value(-1)));
- assertTrue(cache.remove(key));
+ assertTrue(cache.remove(key(key)));
- IgniteCache<Integer, Integer> expirePlcCache =
+ IgniteCache<Object, Object> expirePlcCache =
cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, 100)));
- expirePlcCache.put(key, 10);
+ expirePlcCache.put(key(key), value(10));
U.sleep(700);
if (!eagerTtl())
- assertNull(primaryCache(key, cache.getName()).get(key)); // Provoke expire event if eager ttl is disabled.
+ assertNull(primaryCache(key, cache.getName()).get(key(key))); // Provoke expire event if eager ttl is disabled.
- IgniteCache<Integer, Integer> cache1 = cache;
+ IgniteCache<Object, Object> cache1 = cache;
if (gridCount() > 1)
cache1 = jcache(1); // Do updates from another node.
- cache1.put(key, 1);
+ cache1.put(key(key), value(1));
- cache1.put(key, 2);
+ cache1.put(key(key), value(2));
- assertTrue(cache1.remove(key));
+ assertTrue(cache1.remove(key(key)));
- IgniteCache<Integer, Integer> expirePlcCache1 =
+ IgniteCache<Object, Object> expirePlcCache1 =
cache1.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, 100)));
- expirePlcCache1.put(key, 20);
+ expirePlcCache1.put(key(key), value(20));
U.sleep(200);
if (!eagerTtl())
- assertNull(primaryCache(key, cache.getName()).get(key)); // Provoke expire event if eager ttl is disabled.
+ assertNull(primaryCache(key, cache.getName()).get(key(key))); // Provoke expire event if eager ttl is disabled.
evtsLatch.await(5000, MILLISECONDS);
assertEquals(expEvts, evts.size());
- Iterator<CacheEntryEvent<? extends Integer, ? extends Integer>> iter = evts.iterator();
+ Iterator<CacheEntryEvent<?, ?>> iter = evts.iterator();
if (create)
checkEvent(iter, key, CREATED, 0, null);
@@ -886,11 +953,11 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
cache.deregisterCacheEntryListener(lsnrCfg);
- cache.put(key, 1);
+ cache.put(key(key), value(1));
- cache.put(key, 2);
+ cache.put(key(key), value(2));
- assertTrue(cache.remove(key));
+ assertTrue(cache.remove(key(key)));
U.sleep(500); // Sleep some time to ensure listener was really removed.
@@ -908,26 +975,26 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
* @param expVal Expected value.
* @param expOld Expected old value.
*/
- private void checkEvent(Iterator<CacheEntryEvent<? extends Integer, ? extends Integer>> iter,
+ private void checkEvent(Iterator<CacheEntryEvent<?, ?>> iter,
Integer expKey,
EventType expType,
@Nullable Integer expVal,
@Nullable Integer expOld) {
assertTrue(iter.hasNext());
- CacheEntryEvent<? extends Integer, ? extends Integer> evt = iter.next();
+ CacheEntryEvent<?, ?> evt = iter.next();
iter.remove();
assertTrue(evt.getSource() instanceof IgniteCacheProxy);
- assertEquals(expKey, evt.getKey());
+ assertEquals(key(expKey), evt.getKey());
assertEquals(expType, evt.getEventType());
- assertEquals(expVal, evt.getValue());
+ assertEquals(value(expVal), evt.getValue());
- assertEquals(expOld, evt.getOldValue());
+ assertEquals(value(expOld), evt.getOldValue());
if (expOld == null)
assertFalse(evt.isOldValueAvailable());
@@ -977,7 +1044,7 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
* @param evt Event.
*/
- private static void onEvent(CacheEntryEvent<? extends Integer, ? extends Integer> evt) {
+ private static void onEvent(CacheEntryEvent<?, ?> evt) {
// System.out.println("Received event [evt=" + evt + ", thread=" + Thread.currentThread().getName() + ']');
assertNotNull(evt);
@@ -993,9 +1060,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class CreateUpdateRemoveExpireListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class CreateUpdateRemoveExpireListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateUpdateRemoveExpireListener();
}
}
@@ -1003,9 +1070,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class NoOpCreateUpdateListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class NoOpCreateUpdateListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new NoOpCreateUpdateListener();
}
}
@@ -1013,9 +1080,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class CreateUpdateListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class CreateUpdateListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateUpdateListener();
}
}
@@ -1023,9 +1090,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class CreateListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class CreateListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new CreateListener();
}
}
@@ -1033,9 +1100,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class RemoveListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class RemoveListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new RemoveListener();
}
}
@@ -1043,9 +1110,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class UpdateListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class UpdateListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new UpdateListener();
}
}
@@ -1053,9 +1120,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class ExpireListenerFactory implements Factory<CacheEntryListener<Integer, Integer>> {
+ private static class ExpireListenerFactory implements Factory<CacheEntryListener<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryListener<Integer, Integer> create() {
+ @Override public CacheEntryListener<Object, Object> create() {
return new ExpireListener();
}
}
@@ -1063,9 +1130,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class TestFilterFactory implements Factory<CacheEntryEventSerializableFilter<Integer, Integer>> {
+ private static class TestFilterFactory implements Factory<CacheEntryEventSerializableFilter<Object, Object>> {
/** {@inheritDoc} */
- @Override public CacheEntryEventSerializableFilter<Integer, Integer> create() {
+ @Override public CacheEntryEventSerializableFilter<Object, Object> create() {
return new TestFilter();
}
}
@@ -1073,10 +1140,10 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class CreateListener implements CacheEntryCreatedListener<Integer, Integer> {
+ private static class CreateListener implements CacheEntryCreatedListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onCreated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1084,10 +1151,10 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class UpdateListener implements CacheEntryUpdatedListener<Integer, Integer> {
+ private static class UpdateListener implements CacheEntryUpdatedListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1095,10 +1162,10 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class RemoveListener implements CacheEntryRemovedListener<Integer, Integer> {
+ private static class RemoveListener implements CacheEntryRemovedListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onRemoved(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1106,10 +1173,10 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class ExpireListener implements CacheEntryExpiredListener<Integer, Integer> {
+ private static class ExpireListener implements CacheEntryExpiredListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onExpired(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onExpired(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1117,32 +1184,39 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class TestFilter implements CacheEntryEventSerializableFilter<Integer, Integer> {
+ private static class TestFilter implements CacheEntryEventSerializableFilter<Object, Object> {
/** {@inheritDoc} */
- @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) {
+ @Override public boolean evaluate(CacheEntryEvent<?, ?> evt) {
assert evt != null;
assert evt.getSource() != null : evt;
assert evt.getEventType() != null : evt;
assert evt.getKey() != null : evt;
- return evt.getKey() % 2 == 0;
+ Integer key;
+
+ if (evt.getKey() instanceof ListenerTestKey)
+ key = ((ListenerTestKey)evt.getKey()).key;
+ else
+ key = (Integer)evt.getKey();
+
+ return key % 2 == 0;
}
}
/**
*
*/
- private static class CreateUpdateListener implements CacheEntryCreatedListener<Integer, Integer>,
- CacheEntryUpdatedListener<Integer, Integer> {
+ private static class CreateUpdateListener implements CacheEntryCreatedListener<Object, Object>,
+ CacheEntryUpdatedListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onCreated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
/** {@inheritDoc} */
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1150,11 +1224,11 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class NoOpCreateUpdateListener implements CacheEntryCreatedListener<Integer, Integer>,
- CacheEntryUpdatedListener<Integer, Integer> {
+ private static class NoOpCreateUpdateListener implements CacheEntryCreatedListener<Object, Object>,
+ CacheEntryUpdatedListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
+ @Override public void onCreated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts) {
assertNotNull(evt);
assertNotNull(evt.getSource());
assertNotNull(evt.getEventType());
@@ -1163,8 +1237,8 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
}
/** {@inheritDoc} */
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts) {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts) {
assertNotNull(evt);
assertNotNull(evt.getSource());
assertNotNull(evt.getEventType());
@@ -1177,16 +1251,16 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
*
*/
private static class CreateUpdateRemoveExpireListener extends CreateUpdateListener
- implements CacheEntryRemovedListener<Integer, Integer>, CacheEntryExpiredListener<Integer, Integer> {
+ implements CacheEntryRemovedListener<Object, Object>, CacheEntryExpiredListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onRemoved(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
/** {@inheritDoc} */
- @Override public void onExpired(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
- for (CacheEntryEvent<? extends Integer, ? extends Integer> evt : evts)
+ @Override public void onExpired(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts)
onEvent(evt);
}
}
@@ -1194,9 +1268,9 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- private static class ExceptionFilter implements CacheEntryEventSerializableFilter<Integer, Integer> {
+ private static class ExceptionFilter implements CacheEntryEventSerializableFilter<Object, Object> {
/** {@inheritDoc} */
- @Override public boolean evaluate(CacheEntryEvent<? extends Integer, ? extends Integer> evt) {
+ @Override public boolean evaluate(CacheEntryEvent<?, ?> evt) {
throw new RuntimeException("Test filter error.");
}
}
@@ -1205,24 +1279,24 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
*
*/
private static class ExceptionListener extends CreateUpdateListener
- implements CacheEntryRemovedListener<Integer, Integer>, CacheEntryExpiredListener<Integer, Integer> {
+ implements CacheEntryRemovedListener<Object, Object>, CacheEntryExpiredListener<Object, Object> {
/** {@inheritDoc} */
- @Override public void onCreated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onCreated(Iterable<CacheEntryEvent<?, ?>> evts) {
error();
}
/** {@inheritDoc} */
- @Override public void onUpdated(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
error();
}
/** {@inheritDoc} */
- @Override public void onExpired(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onExpired(Iterable<CacheEntryEvent<?, ?>> evts) {
error();
}
/** {@inheritDoc} */
- @Override public void onRemoved(Iterable<CacheEntryEvent<? extends Integer, ? extends Integer>> evts) {
+ @Override public void onRemoved(Iterable<CacheEntryEvent<?, ?>> evts) {
error();
}
@@ -1237,10 +1311,12 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- protected static class EntryToStringProcessor implements EntryProcessor<Integer, Integer, String> {
+ protected static class EntryToStringProcessor implements EntryProcessor<Object, Object, String> {
/** {@inheritDoc} */
- @Override public String process(MutableEntry<Integer, Integer> e, Object... arguments)
- throws EntryProcessorException {
+ @Override public String process(MutableEntry<Object, Object> e, Object... args) {
+ if (e.getValue() instanceof ListenerTestValue)
+ return String.valueOf(((ListenerTestValue)e.getValue()).val1);
+
return String.valueOf(e.getValue());
}
@@ -1253,19 +1329,19 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
/**
*
*/
- protected static class EntrySetValueProcessor implements EntryProcessor<Integer, Integer, String> {
+ protected static class EntrySetValueProcessor implements EntryProcessor<Object, Object, String> {
/** */
- private Integer val;
+ private Object val;
/**
* @param val Value to set.
*/
- public EntrySetValueProcessor(Integer val) {
+ public EntrySetValueProcessor(Object val) {
this.val = val;
}
/** {@inheritDoc} */
- @Override public String process(MutableEntry<Integer, Integer> e, Object... arguments)
+ @Override public String process(MutableEntry<Object, Object> e, Object... args)
throws EntryProcessorException {
e.setValue(val);
@@ -1307,4 +1383,88 @@ public abstract class IgniteCacheEntryListenerAbstractTest extends IgniteCacheAb
// No-op.
}
}
+
+ /**
+ *
+ */
+ static class ListenerTestKey implements Serializable {
+ /** */
+ private final Integer key;
+
+ /**
+ * @param key Key.
+ */
+ public ListenerTestKey(Integer key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ ListenerTestKey that = (ListenerTestKey)o;
+
+ return key.equals(that.key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return key.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ListenerTestKey.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ static class ListenerTestValue implements Serializable {
+ /** */
+ private final Integer val1;
+
+ /** */
+ private final String val2;
+
+ /**
+ * @param val Value.
+ */
+ public ListenerTestValue(Integer val) {
+ this.val1 = val;
+ this.val2 = String.valueOf(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ ListenerTestValue that = (ListenerTestValue) o;
+
+ return val1.equals(that.val1) && val2.equals(that.val2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = val1.hashCode();
+
+ res = 31 * res + val2.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(ListenerTestValue.class, this);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapTieredTest.java
new file mode 100644
index 0000000..69efb84
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapTieredTest.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.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class IgniteCacheEntryListenerAtomicOffheapTieredTest extends IgniteCacheEntryListenerAtomicTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapValuesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapValuesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapValuesTest.java
new file mode 100644
index 0000000..23b1bc0
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerAtomicOffheapValuesTest.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.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.*;
+
+/**
+ *
+ */
+public class IgniteCacheEntryListenerAtomicOffheapValuesTest extends IgniteCacheEntryListenerAtomicTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_VALUES;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapTieredTest.java
new file mode 100644
index 0000000..d552195
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapTieredTest.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.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class IgniteCacheEntryListenerTxOffheapTieredTest extends IgniteCacheEntryListenerTxTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapValuesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapValuesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapValuesTest.java
new file mode 100644
index 0000000..32555c8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxOffheapValuesTest.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.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+
+/**
+ *
+ */
+public class IgniteCacheEntryListenerTxOffheapValuesTest extends IgniteCacheEntryListenerTxTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_VALUES;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxTest.java
index a9e43d4..41725e7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheEntryListenerTxTest.java
@@ -48,6 +48,7 @@ public class IgniteCacheEntryListenerTxTest extends IgniteCacheEntryListenerAbst
return null;
}
+ /** {@inheritDoc} */
@Override public void testEvents(){
fail("https://issues.apache.org/jira/browse/IGNITE-1600");
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
index 1c65f9b..a42f056 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAbstractSelfTest.java
@@ -55,6 +55,7 @@ import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
import org.apache.ignite.cache.query.ContinuousQuery;
@@ -97,6 +98,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheMemoryMode.*;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;
@@ -142,6 +144,7 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
ccfg.setBackups(backups);
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setNearConfiguration(nearCacheConfiguration());
+ ccfg.setMemoryMode(memoryMode());
cfg.setCacheConfiguration(ccfg);
@@ -151,6 +154,13 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
}
/**
+ * @return Cache memory mode.
+ */
+ protected CacheMemoryMode memoryMode() {
+ return ONHEAP_TIERED;
+ }
+
+ /**
* @return Near cache configuration.
*/
protected NearCacheConfiguration nearCacheConfiguration() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.java
new file mode 100644
index 0000000..cc8590d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class CacheContinuousQueryFailoverAtomicPrimaryWriteOrderOffheapTieredTest
+ extends CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxOffheapTieredTest.java
new file mode 100644
index 0000000..cae06c3
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryFailoverTxOffheapTieredTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class CacheContinuousQueryFailoverTxOffheapTieredTest extends CacheContinuousQueryFailoverTxSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
new file mode 100644
index 0000000..d9b2091
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryRandomOperationsTest.java
@@ -0,0 +1,684 @@
+/*
+ * 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.Random;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryUpdatedListener;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import javax.cache.processor.EntryProcessor;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.cache.store.CacheStoreAdapter;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class CacheContinuousQueryRandomOperationsTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final int NODES = 5;
+
+ /** */
+ private static final int KEYS = 10;
+
+ /** */
+ private static final int VALS = 10;
+
+ /** */
+ private boolean client;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ cfg.setClientMode(client);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ super.beforeTestsStarted();
+
+ startGridsMultiThreaded(NODES - 1);
+
+ client = true;
+
+ startGrid(NODES - 1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+
+ super.afterTestsStopped();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomic() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicOffheapValues() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ OFFHEAP_VALUES,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicOffheapTiered() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ ATOMIC,
+ OFFHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testAtomicNoBackups() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ ATOMIC,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTx() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxReplicated() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(REPLICATED,
+ 0,
+ TRANSACTIONAL,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxOffheapValues() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ OFFHEAP_VALUES,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxOffheapTiered() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 1,
+ TRANSACTIONAL,
+ OFFHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxNoBackups() throws Exception {
+ CacheConfiguration<Object, Object> ccfg = cacheConfiguration(PARTITIONED,
+ 0,
+ TRANSACTIONAL,
+ ONHEAP_TIERED,
+ false);
+
+ testContinuousQuery(ccfg);
+ }
+
+ /**
+ * @param ccfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void testContinuousQuery(CacheConfiguration<Object, Object> ccfg) throws Exception {
+ ignite(0).createCache(ccfg);
+
+ try {
+ IgniteCache<Object, Object> cache = ignite(NODES - 1).cache(ccfg.getName());
+
+ long seed = System.currentTimeMillis();
+
+ Random rnd = new Random(seed);
+
+ log.info("Random seed: " + seed);
+
+ ContinuousQuery<Object, Object> qry = new ContinuousQuery<>();
+
+ final BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue =
+ new ArrayBlockingQueue<>(10_000);
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<Object, Object>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<?, ?>> evts) {
+ for (CacheEntryEvent<?, ?> evt : evts) {
+ // System.out.println("Event: " + evt);
+
+ evtsQueue.add(evt);
+ }
+ }
+ });
+
+ QueryCursor<?> cur = cache.query(qry);
+
+ ConcurrentMap<Object, Object> expData = new ConcurrentHashMap<>();
+
+ try {
+ for (int i = 0; i < 1000; i++) {
+ if (i % 100 == 0)
+ log.info("Iteration: " + i);
+
+ randomUpdate(rnd, evtsQueue, expData, cache);
+ }
+ }
+ finally {
+ cur.close();
+ }
+ }
+ finally {
+ ignite(0).destroyCache(ccfg.getName());
+ }
+ }
+
+ /**
+ * @param rnd Random generator.
+ * @param evtsQueue Events queue.
+ * @param expData Expected cache data.
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void randomUpdate(
+ Random rnd,
+ BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue,
+ ConcurrentMap<Object, Object> expData,
+ IgniteCache<Object, Object> cache)
+ throws Exception {
+ Object key = new QueryTestKey(rnd.nextInt(KEYS));
+ Object newVal = value(rnd);
+ Object oldVal = expData.get(key);
+
+ int op = rnd.nextInt(11);
+
+ // log.info("Random operation [key=" + key + ", op=" + op + ']');
+
+ switch (op) {
+ case 0: {
+ cache.put(key, newVal);
+
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+
+ break;
+ }
+
+ case 1: {
+ cache.getAndPut(key, newVal);
+
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+
+ break;
+ }
+
+ case 2: {
+ cache.remove(key);
+
+ waitEvent(evtsQueue, key, null, oldVal);
+
+ expData.remove(key);
+
+ break;
+ }
+
+ case 3: {
+ cache.getAndRemove(key);
+
+ waitEvent(evtsQueue, key, null, oldVal);
+
+ expData.remove(key);
+
+ break;
+ }
+
+ case 4: {
+ cache.invoke(key, new EntrySetValueProcessor(newVal, rnd.nextBoolean()));
+
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+
+ break;
+ }
+
+ case 5: {
+ cache.invoke(key, new EntrySetValueProcessor(null, rnd.nextBoolean()));
+
+ waitEvent(evtsQueue, key, null, oldVal);
+
+ expData.remove(key);
+
+ break;
+ }
+
+ case 6: {
+ cache.putIfAbsent(key, newVal);
+
+ if (oldVal == null) {
+ waitEvent(evtsQueue, key, newVal, null);
+
+ expData.put(key, newVal);
+ }
+ else
+ checkNoEvent(evtsQueue);
+
+ break;
+ }
+
+ case 7: {
+ cache.getAndPutIfAbsent(key, newVal);
+
+ if (oldVal == null) {
+ waitEvent(evtsQueue, key, newVal, null);
+
+ expData.put(key, newVal);
+ }
+ else
+ checkNoEvent(evtsQueue);
+
+ break;
+ }
+
+ case 8: {
+ cache.replace(key, newVal);
+
+ if (oldVal != null) {
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+ }
+ else
+ checkNoEvent(evtsQueue);
+
+ break;
+ }
+
+ case 9: {
+ cache.getAndReplace(key, newVal);
+
+ if (oldVal != null) {
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+ }
+ else
+ checkNoEvent(evtsQueue);
+
+ break;
+ }
+
+ case 10: {
+ if (oldVal != null) {
+ Object replaceVal = value(rnd);
+
+ boolean success = replaceVal.equals(oldVal);
+
+ if (success) {
+ cache.replace(key, replaceVal, newVal);
+
+ waitEvent(evtsQueue, key, newVal, oldVal);
+
+ expData.put(key, newVal);
+ }
+ else {
+ cache.replace(key, replaceVal, newVal);
+
+ checkNoEvent(evtsQueue);
+ }
+ }
+ else {
+ cache.replace(key, value(rnd), newVal);
+
+ checkNoEvent(evtsQueue);
+ }
+
+ break;
+ }
+
+ default:
+ fail();
+ }
+ }
+
+ /**
+ * @param rnd Random generator.
+ * @return Cache value.
+ */
+ private static Object value(Random rnd) {
+ return new QueryTestValue(rnd.nextInt(VALS));
+ }
+
+ /**
+ * @param evtsQueue Event queue.
+ * @param key Key.
+ * @param val Value.
+ * @param oldVal Old value.
+ * @throws Exception If failed.
+ */
+ private void waitEvent(BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue,
+ Object key, Object val, Object oldVal) throws Exception {
+ if (val == null && oldVal == null) {
+ checkNoEvent(evtsQueue);
+
+ return;
+ }
+
+ CacheEntryEvent<?, ?> evt = evtsQueue.poll(5, SECONDS);
+
+ assertNotNull("Failed to wait for event [key=" + key +
+ ", val=" + val +
+ ", oldVal=" + oldVal + ']', evt);
+ assertEquals(key, evt.getKey());
+ assertEquals(val, evt.getValue());
+ assertEquals(oldVal, evt.getOldValue());
+ }
+
+ /**
+ * @param evtsQueue Event queue.
+ * @throws Exception If failed.
+ */
+ private void checkNoEvent(BlockingQueue<CacheEntryEvent<?, ?>> evtsQueue) throws Exception {
+ CacheEntryEvent<?, ?> evt = evtsQueue.poll(50, MILLISECONDS);
+
+ assertNull(evt);
+ }
+
+ /**
+ *
+ * @param cacheMode Cache mode.
+ * @param backups Number of backups.
+ * @param atomicityMode Cache atomicity mode.
+ * @param memoryMode Cache memory mode.
+ * @param store If {@code true} configures dummy cache store.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration<Object, Object> cacheConfiguration(
+ CacheMode cacheMode,
+ int backups,
+ CacheAtomicityMode atomicityMode,
+ CacheMemoryMode memoryMode,
+ boolean store) {
+ CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>();
+
+ ccfg.setAtomicityMode(atomicityMode);
+ ccfg.setCacheMode(cacheMode);
+ ccfg.setMemoryMode(memoryMode);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setAtomicWriteOrderMode(PRIMARY);
+
+ if (cacheMode == PARTITIONED)
+ ccfg.setBackups(backups);
+
+ if (store) {
+ ccfg.setCacheStoreFactory(new TestStoreFactory());
+ ccfg.setReadThrough(true);
+ ccfg.setWriteThrough(true);
+ }
+
+ return ccfg;
+ }
+
+ /**
+ *
+ */
+ private static class TestStoreFactory implements Factory<CacheStore<Object, Object>> {
+ /** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
+ @Override public CacheStore<Object, Object> create() {
+ return new CacheStoreAdapter() {
+ @Override public Object load(Object key) throws CacheLoaderException {
+ return null;
+ }
+
+ @Override public void write(Cache.Entry entry) throws CacheWriterException {
+ // No-op.
+ }
+
+ @Override public void delete(Object key) throws CacheWriterException {
+ // No-op.
+ }
+ };
+ }
+ }
+
+ /**
+ *
+ */
+ static class QueryTestKey implements Serializable {
+ /** */
+ private final Integer key;
+
+ /**
+ * @param key Key.
+ */
+ public QueryTestKey(Integer key) {
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ QueryTestKey that = (QueryTestKey)o;
+
+ return key.equals(that.key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return key.hashCode();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(QueryTestKey.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ static class QueryTestValue implements Serializable {
+ /** */
+ private final Integer val1;
+
+ /** */
+ private final String val2;
+
+ /**
+ * @param val Value.
+ */
+ public QueryTestValue(Integer val) {
+ this.val1 = val;
+ this.val2 = String.valueOf(val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ QueryTestValue that = (QueryTestValue) o;
+
+ return val1.equals(that.val1) && val2.equals(that.val2);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = val1.hashCode();
+
+ res = 31 * res + val2.hashCode();
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(QueryTestValue.class, this);
+ }
+ }
+ /**
+ *
+ */
+ protected static class EntrySetValueProcessor implements EntryProcessor<Object, Object, Object> {
+ /** */
+ private Object val;
+
+ /** */
+ private boolean retOld;
+
+ /**
+ * @param val Value to set.
+ * @param retOld Return old value flag.
+ */
+ public EntrySetValueProcessor(Object val, boolean retOld) {
+ this.val = val;
+ this.retOld = retOld;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<Object, Object> e, Object... args) {
+ Object old = retOld ? e.getValue() : null;
+
+ if (val != null)
+ e.setValue(val);
+ else
+ e.remove();
+
+ return old;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(EntrySetValueProcessor.class, this);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
index 5abb98d..dbe282e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAbstractSelfTest.java
@@ -40,6 +40,7 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
+import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.query.ContinuousQuery;
@@ -73,9 +74,9 @@ import org.jsr166.ConcurrentHashMap8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
-
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.ONHEAP_TIERED;
import static org.apache.ignite.cache.CacheMode.LOCAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -117,6 +118,7 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
cacheCfg.setReadThrough(true);
cacheCfg.setWriteThrough(true);
cacheCfg.setLoadPreviousValue(true);
+ cacheCfg.setMemoryMode(memoryMode());
cfg.setCacheConfiguration(cacheCfg);
}
@@ -135,6 +137,13 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
}
/**
+ * @return Cache memory mode.
+ */
+ protected CacheMemoryMode memoryMode() {
+ return ONHEAP_TIERED;
+ }
+
+ /**
* @return Peer class loading enabled flag.
*/
protected boolean peerClassLoadingEnabled() {
@@ -393,8 +402,8 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
}
});
- try (QueryCursor<Cache.Entry<Integer, Integer>> query2 = cache1.query(qry2);
- QueryCursor<Cache.Entry<Integer, Integer>> query1 = cache.query(qry1)) {
+ try (QueryCursor<Cache.Entry<Integer, Integer>> qryCur2 = cache1.query(qry2);
+ QueryCursor<Cache.Entry<Integer, Integer>> qryCur1 = cache.query(qry1)) {
for (int i = 0; i < gridCount(); i++) {
IgniteCache<Object, Object> cache0 = grid(i).cache(null);
@@ -448,7 +457,7 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
}
});
- QueryCursor<Cache.Entry<Integer, Integer>> query = cache.query(qry);
+ QueryCursor<Cache.Entry<Integer, Integer>> qryCur = cache.query(qry);
for (int key = 0; key < keyCnt; key++)
cache.put(key, key);
@@ -461,7 +470,7 @@ public abstract class GridCacheContinuousQueryAbstractSelfTest extends GridCommo
}, 2000L);
}
finally {
- query.close();
+ qryCur.close();
}
}
else {
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapTieredTest.java
new file mode 100644
index 0000000..d6948e2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapTieredTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryAtomicOffheapTieredTest extends GridCacheContinuousQueryAtomicSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapValuesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapValuesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapValuesTest.java
new file mode 100644
index 0000000..4002435
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryAtomicOffheapValuesTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryAtomicOffheapValuesTest extends GridCacheContinuousQueryAtomicSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_VALUES;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c05fc02/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapTieredTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapTieredTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapTieredTest.java
new file mode 100644
index 0000000..bcba7b6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryTxOffheapTieredTest.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.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheMemoryMode;
+
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryTxOffheapTieredTest extends GridCacheContinuousQueryTxSelfTest {
+ /** {@inheritDoc} */
+ @Override protected CacheMemoryMode memoryMode() {
+ return OFFHEAP_TIERED;
+ }
+}
[21/21] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-2542
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-2542
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b2b11e87
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b2b11e87
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b2b11e87
Branch: refs/heads/ignite-2542
Commit: b2b11e87897118bea6ec693d3a00bff88aa8ada6
Parents: 52e7d9d 0491a5f
Author: sboikov <sb...@gridgain.com>
Authored: Thu Feb 11 08:10:32 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Feb 11 08:10:32 2016 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 4 +-
.../cache/CacheEvictableEntryImpl.java | 4 +-
.../processors/cache/CacheLazyEntry.java | 3 +
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheMapEntry.java | 118 +++-
.../binary/CacheObjectBinaryProcessorImpl.java | 6 +-
.../dht/atomic/GridDhtAtomicCache.java | 79 ++-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 85 ++-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 38 +-
.../cache/query/GridCacheQueryManager.java | 30 +-
.../continuous/CacheContinuousQueryHandler.java | 3 +-
.../CacheContinuousQueryListener.java | 2 +-
.../continuous/CacheContinuousQueryManager.java | 120 +++-
.../continuous/GridContinuousProcessor.java | 16 +-
.../GridCacheAtomicReferenceImpl.java | 68 +-
.../internal/processors/igfs/IgfsProcessor.java | 14 +
.../platform/PlatformNoopProcessor.java | 10 +
.../processors/platform/PlatformProcessor.java | 20 +
.../platform/PlatformProcessorImpl.java | 18 +
.../callback/PlatformCallbackUtils.java | 1 -
.../datastructures/PlatformAtomicReference.java | 141 ++++
.../datastructures/PlatformAtomicSequence.java | 122 ++++
.../GridCacheOffHeapValuesEvictionSelfTest.java | 171 +++++
.../IgniteCacheEntryListenerAbstractTest.java | 454 ++++++++----
...cheEntryListenerAtomicOffheapTieredTest.java | 32 +
...cheEntryListenerAtomicOffheapValuesTest.java | 32 +
...niteCacheEntryListenerExpiredEventsTest.java | 202 ++++++
...teCacheEntryListenerTxOffheapTieredTest.java | 32 +
...teCacheEntryListenerTxOffheapValuesTest.java | 32 +
.../cache/IgniteCacheEntryListenerTxTest.java | 1 +
...ContinuousQueryFailoverAbstractSelfTest.java | 10 +
...tomicPrimaryWriteOrderOffheapTieredTest.java | 33 +
...tinuousQueryFailoverTxOffheapTieredTest.java | 32 +
...acheContinuousQueryRandomOperationsTest.java | 684 +++++++++++++++++++
...ridCacheContinuousQueryAbstractSelfTest.java | 19 +-
...eContinuousQueryAtomicOffheapTieredTest.java | 32 +
...eContinuousQueryAtomicOffheapValuesTest.java | 32 +
...CacheContinuousQueryTxOffheapTieredTest.java | 32 +
...CacheContinuousQueryTxOffheapValuesTest.java | 32 +
.../igfs/IgfsProcessorValidationSelfTest.java | 27 +
.../junits/common/GridCommonAbstractTest.java | 2 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 10 +
.../hadoop/fs/BasicHadoopFileSystemFactory.java | 22 +-
.../fs/CachingHadoopFileSystemFactory.java | 2 +-
.../fs/KerberosHadoopFileSystemFactory.java | 217 ++++++
...KerberosHadoopFileSystemFactorySelfTest.java | 121 ++++
.../testsuites/IgniteHadoopTestSuite.java | 3 +
.../cache/CacheQueryBuildValueTest.java | 144 ++++
.../IgniteCacheQuerySelfTestSuite.java | 14 +
.../cpp/common/include/ignite/common/exports.h | 15 +
.../cpp/common/include/ignite/common/java.h | 32 +
.../platforms/cpp/common/project/vs/module.def | 15 +-
modules/platforms/cpp/common/src/exports.cpp | 52 ++
modules/platforms/cpp/common/src/java.cpp | 181 +++++
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../cpp/core-test/project/vs/core-test.vcxproj | 1 +
.../project/vs/core-test.vcxproj.filters | 3 +
.../platforms/cpp/core-test/src/cache_test.cpp | 12 +
.../cpp/core-test/src/interop_memory_test.cpp | 95 +++
.../include/ignite/impl/ignite_environment.h | 19 +-
.../cpp/core/src/impl/cache/cache_impl.cpp | 2 +-
.../cpp/core/src/impl/ignite_environment.cpp | 30 +-
.../Apache.Ignite.Core.Tests.csproj | 6 +
.../DataStructures/AtomicReferenceTest.cs | 239 +++++++
.../DataStructures/AtomicSequenceTest.cs | 131 ++++
.../Apache.Ignite.Core.Tests/FutureTest.cs | 1 +
.../IgniteConfigurationSectionTest.cs | 69 ++
.../IgniteConfigurationSerializerTest.cs | 554 +++++++++++++++
.../dotnet/Apache.Ignite.Core.Tests/app.config | 54 ++
.../Apache.Ignite.Core.csproj | 15 +
.../Binary/IBinarySerializer.cs | 6 +-
.../DataStructures/IAtomicReference.cs | 64 ++
.../DataStructures/IAtomicSequence.cs | 69 ++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 28 +
.../IgniteConfigurationSection.cs | 80 +++
.../IgniteConfigurationSection.xsd | 281 ++++++++
.../dotnet/Apache.Ignite.Core/Ignition.cs | 39 ++
.../Impl/Common/BooleanLowerCaseConverter.cs | 60 ++
.../Common/IgniteConfigurationXmlSerializer.cs | 410 +++++++++++
.../Impl/Common/TypeStringConverter.cs | 115 ++++
.../Impl/DataStructures/AtomicReference.cs | 92 +++
.../Impl/DataStructures/AtomicSequence.cs | 90 +++
.../Impl/Events/EventTypeConverter.cs | 133 ++++
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 50 ++
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 12 +
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 37 +
.../Impl/Unmanaged/UnmanagedUtils.cs | 79 +++
.../commands/tasks/VisorTasksCommand.scala | 4 +-
.../scala/org/apache/ignite/visor/visor.scala | 4 +
89 files changed, 6161 insertions(+), 349 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b2b11e87/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteCacheQuerySelfTestSuite.java
----------------------------------------------------------------------
[03/21] ignite git commit: IGNITE-1563 .NET: Implemented "atomics":
AtomicReference and AtomicSequence. This closes #455.
Posted by sb...@apache.org.
IGNITE-1563 .NET: Implemented "atomics": AtomicReference and AtomicSequence. This closes #455.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f7c1296c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f7c1296c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f7c1296c
Branch: refs/heads/ignite-2542
Commit: f7c1296cceba73ce1b61af605e476a905a0c8ab4
Parents: e2e216d
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Feb 9 14:43:00 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Feb 9 14:43:00 2016 +0300
----------------------------------------------------------------------
.../GridCacheAtomicReferenceImpl.java | 68 ++----
.../platform/PlatformNoopProcessor.java | 10 +
.../processors/platform/PlatformProcessor.java | 20 ++
.../platform/PlatformProcessorImpl.java | 18 ++
.../callback/PlatformCallbackUtils.java | 1 -
.../datastructures/PlatformAtomicReference.java | 141 +++++++++++
.../datastructures/PlatformAtomicSequence.java | 122 ++++++++++
.../cpp/common/include/ignite/common/exports.h | 15 ++
.../cpp/common/include/ignite/common/java.h | 32 +++
.../platforms/cpp/common/project/vs/module.def | 15 +-
modules/platforms/cpp/common/src/exports.cpp | 52 ++++
modules/platforms/cpp/common/src/java.cpp | 181 ++++++++++++++
.../Apache.Ignite.Core.Tests.csproj | 2 +
.../DataStructures/AtomicReferenceTest.cs | 239 +++++++++++++++++++
.../DataStructures/AtomicSequenceTest.cs | 131 ++++++++++
.../Apache.Ignite.Core.csproj | 4 +
.../DataStructures/IAtomicReference.cs | 64 +++++
.../DataStructures/IAtomicSequence.cs | 69 ++++++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 28 +++
.../Impl/DataStructures/AtomicReference.cs | 92 +++++++
.../Impl/DataStructures/AtomicSequence.cs | 90 +++++++
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 50 ++++
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 12 +
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 37 +++
.../Impl/Unmanaged/UnmanagedUtils.cs | 79 ++++++
25 files changed, 1526 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
index 37cdaea..e044138 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheAtomicReferenceImpl.java
@@ -35,8 +35,6 @@ import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.lang.IgnitePredicate;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -153,10 +151,20 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
/** {@inheritDoc} */
@Override public boolean compareAndSet(T expVal, T newVal) {
+ return compareAndSetAndGet(newVal, expVal) == expVal;
+ }
+
+ /**
+ * Compares current value with specified value for equality and, if they are equal, replaces current value.
+ *
+ * @param newVal New value to set.
+ * @return Original value.
+ */
+ public T compareAndSetAndGet(T newVal, T expVal) {
checkRemoved();
try {
- return CU.outTx(internalCompareAndSet(wrapperPredicate(expVal), wrapperClosure(newVal)), ctx);
+ return CU.outTx(internalCompareAndSetAndGet(expVal, newVal), ctx);
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -197,34 +205,6 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
}
/**
- * Method make wrapper predicate for existing value.
- *
- * @param val Value.
- * @return Predicate.
- */
- private IgnitePredicate<T> wrapperPredicate(final T val) {
- return new IgnitePredicate<T>() {
- @Override public boolean apply(T e) {
- return F.eq(val, e);
- }
- };
- }
-
- /**
- * Method make wrapper closure for existing value.
- *
- * @param val Value.
- * @return Closure.
- */
- private IgniteClosure<T, T> wrapperClosure(final T val) {
- return new IgniteClosure<T, T>() {
- @Override public T apply(T e) {
- return val;
- }
- };
- }
-
- /**
* Method returns callable for execution {@link #set(Object)} operation in async and sync mode.
*
* @param val Value will be set in reference .
@@ -260,39 +240,39 @@ public final class GridCacheAtomicReferenceImpl<T> implements GridCacheAtomicRef
* Conditionally sets the new value. It will be set if {@code expValPred} is
* evaluate to {@code true}.
*
- * @param expValPred Predicate which should evaluate to {@code true} for value to be set.
- * @param newValClos Closure which generates new value.
+ * @param expVal Expected value.
+ * @param newVal New value.
* @return Callable for execution in async and sync mode.
*/
- private Callable<Boolean> internalCompareAndSet(final IgnitePredicate<T> expValPred,
- final IgniteClosure<T, T> newValClos) {
-
- return retryTopologySafe(new Callable<Boolean>() {
- @Override public Boolean call() throws Exception {
+ private Callable<T> internalCompareAndSetAndGet(final T expVal, final T newVal) {
+ return retryTopologySafe(new Callable<T>() {
+ @Override public T call() throws Exception {
try (IgniteInternalTx tx = CU.txStartInternal(ctx, atomicView, PESSIMISTIC, REPEATABLE_READ)) {
GridCacheAtomicReferenceValue<T> ref = atomicView.get(key);
if (ref == null)
throw new IgniteCheckedException("Failed to find atomic reference with given name: " + name);
- if (!expValPred.apply(ref.get())) {
+ T origVal = ref.get();
+
+ if (!F.eq(expVal, origVal)) {
tx.setRollbackOnly();
- return false;
+ return origVal;
}
else {
- ref.set(newValClos.apply(ref.get()));
+ ref.set(newVal);
atomicView.getAndPut(key, ref);
tx.commit();
- return true;
+ return expVal;
}
}
catch (Error | Exception e) {
- U.error(log, "Failed to compare and value [expValPred=" + expValPred + ", newValClos" +
- newValClos + ", atomicReference" + this + ']', e);
+ U.error(log, "Failed to compare and value [expVal=" + expVal + ", newVal" +
+ newVal + ", atomicReference" + this + ']', e);
throw e;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index b25e32e..8fe17e1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -148,4 +148,14 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
@Override public void getIgniteConfiguration(long memPtr) {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget atomicReference(String name, long memPtr, boolean create) throws IgniteException {
+ return null;
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index b59d93d..2d51c69 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -208,6 +208,26 @@ public interface PlatformProcessor extends GridProcessor {
public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException;
/**
+ * Get or create AtomicSequence.
+ * @param name Name.
+ * @param initVal Initial value.
+ * @param create Create flag.
+ * @return Platform atomic long.
+ * @throws IgniteException
+ */
+ public PlatformTarget atomicSequence(String name, long initVal, boolean create) throws IgniteException;
+
+ /**
+ * Get or create AtomicReference.
+ * @param name Name.
+ * @param memPtr Pointer to a stream with initial value. 0 for null initial value.
+ * @param create Create flag.
+ * @return Platform atomic long.
+ * @throws IgniteException
+ */
+ public PlatformTarget atomicReference(String name, long memPtr, boolean create) throws IgniteException;
+
+ /**
* Gets the configuration of the current Ignite instance.
*
* @param memPtr Stream to write data to.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index 4ed8c25..d0e0a63 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.platform;
import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteAtomicSequence;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
@@ -39,6 +40,8 @@ import org.apache.ignite.internal.processors.platform.cluster.PlatformClusterGro
import org.apache.ignite.internal.processors.platform.compute.PlatformCompute;
import org.apache.ignite.internal.processors.platform.datastreamer.PlatformDataStreamer;
import org.apache.ignite.internal.processors.platform.datastructures.PlatformAtomicLong;
+import org.apache.ignite.internal.processors.platform.datastructures.PlatformAtomicReference;
+import org.apache.ignite.internal.processors.platform.datastructures.PlatformAtomicSequence;
import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore;
import org.apache.ignite.internal.processors.platform.events.PlatformEvents;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
@@ -361,6 +364,21 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
}
/** {@inheritDoc} */
+ @Override public PlatformTarget atomicSequence(String name, long initVal, boolean create) throws IgniteException {
+ IgniteAtomicSequence atomicSeq = ignite().atomicSequence(name, initVal, create);
+
+ if (atomicSeq == null)
+ return null;
+
+ return new PlatformAtomicSequence(platformCtx, atomicSeq);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget atomicReference(String name, long memPtr, boolean create) throws IgniteException {
+ return PlatformAtomicReference.createInstance(platformCtx, name, memPtr, create);
+ }
+
+ /** {@inheritDoc} */
@Override public void getIgniteConfiguration(long memPtr) {
PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
BinaryRawWriterEx writer = platformCtx.writer(stream);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
index 7f3ba6f..3112e0f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/callback/PlatformCallbackUtils.java
@@ -442,7 +442,6 @@ public class PlatformCallbackUtils {
static native void serviceCancel(long envPtr, long svcPtr, long memPtr);
/**
- /**
* Invokes service method.
*
* @param envPtr Environment pointer.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
new file mode 100644
index 0000000..81b7570
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.platform.datastructures;
+
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.internal.binary.BinaryRawReaderEx;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.processors.datastructures.GridCacheAtomicReferenceImpl;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
+
+/**
+ * Platform atomic reference wrapper.
+ */
+@SuppressWarnings("unchecked")
+public class PlatformAtomicReference extends PlatformAbstractTarget {
+ /** */
+ private static final int OP_GET = 1;
+
+ /** */
+ private static final int OP_SET = 2;
+
+ /** */
+ private static final int OP_COMPARE_AND_SET_AND_GET = 3;
+
+ /** */
+ private final GridCacheAtomicReferenceImpl atomicRef;
+
+ /**
+ * Creates an instance or returns null.
+ *
+ * @param ctx Context.
+ * @param name Name.
+ * @param memPtr Pointer to a stream with initial value. 0 for default value.
+ * @param create Create flag.
+ * @return Instance of a PlatformAtomicReference, or null when Ignite reference with specific name is null.
+ */
+ public static PlatformAtomicReference createInstance(PlatformContext ctx, String name, long memPtr,
+ boolean create) {
+ assert ctx != null;
+ assert name != null;
+
+ Object initVal = null;
+
+ if (memPtr != 0) {
+ try (PlatformMemory mem = ctx.memory().get(memPtr)) {
+ initVal = ctx.reader(mem).readObjectDetached();
+ }
+ }
+
+ GridCacheAtomicReferenceImpl atomicRef =
+ (GridCacheAtomicReferenceImpl)ctx.kernalContext().grid().atomicReference(name, initVal, create);
+
+ if (atomicRef == null)
+ return null;
+
+ return new PlatformAtomicReference(ctx, atomicRef);
+ }
+
+ /**
+ * Ctor.
+ *
+ * @param ctx Context.
+ * @param ref Atomic reference to wrap.
+ */
+ private PlatformAtomicReference(PlatformContext ctx, GridCacheAtomicReferenceImpl ref) {
+ super(ctx);
+
+ assert ref != null;
+
+ atomicRef = ref;
+ }
+
+ /**
+ * Returns a value indicating whether this instance has been closed.
+ *
+ * @return Value indicating whether this instance has been closed.
+ */
+ public boolean isClosed() {
+ return atomicRef.removed();
+ }
+
+ /**
+ * Closes this instance.
+ */
+ public void close() {
+ atomicRef.close();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processOutStream(int type, BinaryRawWriterEx writer) throws IgniteCheckedException {
+ if (type == OP_GET)
+ writer.writeObject(atomicRef.get());
+ else
+ super.processOutStream(type, writer);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long processInStreamOutLong(int type, BinaryRawReaderEx reader)
+ throws IgniteCheckedException {
+ if (type == OP_SET) {
+ atomicRef.set(reader.readObjectDetached());
+
+ return 0;
+ }
+
+ return super.processInStreamOutLong(type, reader);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void processInStreamOutStream(int type, BinaryRawReaderEx reader,
+ BinaryRawWriterEx writer) throws IgniteCheckedException {
+ if (type == OP_COMPARE_AND_SET_AND_GET) {
+ Object val = reader.readObjectDetached();
+ final Object cmp = reader.readObjectDetached();
+
+ Object res = atomicRef.compareAndSetAndGet(val, cmp);
+
+ writer.writeObject(res);
+ }
+ else
+ super.processInStreamOutStream(type, reader, writer);
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
new file mode 100644
index 0000000..ce7e364
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence.java
@@ -0,0 +1,122 @@
+/*
+ * 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.platform.datastructures;
+
+import org.apache.ignite.IgniteAtomicSequence;
+import org.apache.ignite.internal.processors.platform.PlatformAbstractTarget;
+import org.apache.ignite.internal.processors.platform.PlatformContext;
+
+/**
+ * Platform atomic sequence wrapper.
+ */
+public class PlatformAtomicSequence extends PlatformAbstractTarget {
+ /** */
+ private final IgniteAtomicSequence atomicSeq;
+
+ /**
+ * Ctor.
+ * @param ctx Context.
+ * @param atomicSeq AtomicSequence to wrap.
+ */
+ public PlatformAtomicSequence(PlatformContext ctx, IgniteAtomicSequence atomicSeq) {
+ super(ctx);
+
+ assert atomicSeq != null;
+
+ this.atomicSeq = atomicSeq;
+ }
+
+ /**
+ * Reads the value.
+ *
+ * @return Current atomic sequence value.
+ */
+ public long get() {
+ return atomicSeq.get();
+ }
+
+ /**
+ * Increments and reads the value.
+ *
+ * @return Current atomic sequence value.
+ */
+ public long incrementAndGet() {
+ return atomicSeq.incrementAndGet();
+ }
+
+ /**
+ * Reads and increments the value.
+ *
+ * @return Original atomic sequence value.
+ */
+ public long getAndIncrement() {
+ return atomicSeq.getAndIncrement();
+ }
+
+ /**
+ * Adds a value.
+ *
+ * @return Current atomic sequence value.
+ */
+ public long addAndGet(long l) {
+ return atomicSeq.addAndGet(l);
+ }
+
+ /**
+ * Adds a value.
+ *
+ * @return Original atomic sequence value.
+ */
+ public long getAndAdd(long l) {
+ return atomicSeq.getAndAdd(l);
+ }
+
+ /**
+ * Gets the batch size.
+ *
+ * @return Batch size.
+ */
+ public int getBatchSize() {
+ return atomicSeq.batchSize();
+ }
+
+ /**
+ * Sets the batch size.
+ *
+ * @param size Batch size.
+ */
+ public void setBatchSize(int size) {
+ atomicSeq.batchSize(size);
+ }
+
+ /**
+ * Gets status of atomic.
+ *
+ * @return {@code true} if atomic was removed from cache, {@code false} in other case.
+ */
+ public boolean isClosed() {
+ return atomicSeq.removed();
+ }
+
+ /**
+ * Removes this atomic.
+ */
+ public void close() {
+ atomicSeq.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h
index 66f918f..15911a6 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -48,6 +48,8 @@ extern "C" {
void* IGNITE_CALL IgniteProcessorServices(gcj::JniContext* ctx, void* obj, void* prj);
void* IGNITE_CALL IgniteProcessorExtensions(gcj::JniContext* ctx, void* obj);
void* IGNITE_CALL IgniteProcessorAtomicLong(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create);
+ void* IGNITE_CALL IgniteProcessorAtomicSequence(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create);
+ void* IGNITE_CALL IgniteProcessorAtomicReference(gcj::JniContext* ctx, void* obj, char* name, long long memPtr, bool create);
void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr);
long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
@@ -160,6 +162,19 @@ extern "C" {
bool IGNITE_CALL IgniteAtomicLongIsClosed(gcj::JniContext* ctx, void* obj);
void IGNITE_CALL IgniteAtomicLongClose(gcj::JniContext* ctx, void* obj);
+ long long IGNITE_CALL IgniteAtomicSequenceGet(gcj::JniContext* ctx, void* obj);
+ long long IGNITE_CALL IgniteAtomicSequenceIncrementAndGet(gcj::JniContext* ctx, void* obj);
+ long long IGNITE_CALL IgniteAtomicSequenceGetAndIncrement(gcj::JniContext* ctx, void* obj);
+ long long IGNITE_CALL IgniteAtomicSequenceAddAndGet(gcj::JniContext* ctx, void* obj, long long l);
+ long long IGNITE_CALL IgniteAtomicSequenceGetAndAdd(gcj::JniContext* ctx, void* obj, long long l);
+ int IGNITE_CALL IgniteAtomicSequenceGetBatchSize(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteAtomicSequenceSetBatchSize(gcj::JniContext* ctx, void* obj, int size);
+ bool IGNITE_CALL IgniteAtomicSequenceIsClosed(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteAtomicSequenceClose(gcj::JniContext* ctx, void* obj);
+
+ bool IGNITE_CALL IgniteAtomicReferenceIsClosed(gcj::JniContext* ctx, void* obj);
+ void IGNITE_CALL IgniteAtomicReferenceClose(gcj::JniContext* ctx, void* obj);
+
bool IGNITE_CALL IgniteListenableCancel(gcj::JniContext* ctx, void* obj);
bool IGNITE_CALL IgniteListenableIsCancelled(gcj::JniContext* ctx, void* obj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index 072a8ef..8f5823e 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -311,6 +311,8 @@ namespace ignite
jmethodID m_PlatformProcessor_extensions;
jmethodID m_PlatformProcessor_atomicLong;
jmethodID m_PlatformProcessor_getIgniteConfiguration;
+ jmethodID m_PlatformProcessor_atomicSequence;
+ jmethodID m_PlatformProcessor_atomicReference;
jclass c_PlatformTarget;
jmethodID m_PlatformTarget_inStreamOutLong;
@@ -353,6 +355,21 @@ namespace ignite
jmethodID m_PlatformAtomicLong_isClosed;
jmethodID m_PlatformAtomicLong_close;
+ jclass c_PlatformAtomicSequence;
+ jmethodID m_PlatformAtomicSequence_get;
+ jmethodID m_PlatformAtomicSequence_incrementAndGet;
+ jmethodID m_PlatformAtomicSequence_getAndIncrement;
+ jmethodID m_PlatformAtomicSequence_addAndGet;
+ jmethodID m_PlatformAtomicSequence_getAndAdd;
+ jmethodID m_PlatformAtomicSequence_getBatchSize;
+ jmethodID m_PlatformAtomicSequence_setBatchSize;
+ jmethodID m_PlatformAtomicSequence_isClosed;
+ jmethodID m_PlatformAtomicSequence_close;
+
+ jclass c_PlatformAtomicReference;
+ jmethodID m_PlatformAtomicReference_isClosed;
+ jmethodID m_PlatformAtomicReference_close;
+
jclass c_PlatformListenable;
jmethodID m_PlatformListenable_cancel;
jmethodID m_PlatformListenable_isCancelled;
@@ -507,6 +524,8 @@ namespace ignite
jobject ProcessorServices(jobject obj, jobject prj);
jobject ProcessorExtensions(jobject obj);
jobject ProcessorAtomicLong(jobject obj, char* name, long long initVal, bool create);
+ jobject ProcessorAtomicSequence(jobject obj, char* name, long long initVal, bool create);
+ jobject ProcessorAtomicReference(jobject obj, char* name, long long memPtr, bool create);
void ProcessorGetIgniteConfiguration(jobject obj, long memPtr);
long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
@@ -608,6 +627,19 @@ namespace ignite
bool AtomicLongIsClosed(jobject obj);
void AtomicLongClose(jobject obj);
+ long long AtomicSequenceGet(jobject obj);
+ long long AtomicSequenceIncrementAndGet(jobject obj);
+ long long AtomicSequenceGetAndIncrement(jobject obj);
+ long long AtomicSequenceAddAndGet(jobject obj, long long l);
+ long long AtomicSequenceGetAndAdd(jobject obj, long long l);
+ int AtomicSequenceGetBatchSize(jobject obj);
+ void AtomicSequenceSetBatchSize(jobject obj, int size);
+ bool AtomicSequenceIsClosed(jobject obj);
+ void AtomicSequenceClose(jobject obj);
+
+ bool AtomicReferenceIsClosed(jobject obj);
+ void AtomicReferenceClose(jobject obj);
+
bool ListenableCancel(jobject obj);
bool ListenableIsCancelled(jobject obj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
index 81df027..21a4994 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -116,4 +116,17 @@ IgniteTargetListenFutureForOperationAndGet @113
IgniteProcessorCreateCacheFromConfig @114
IgniteProcessorGetOrCreateCacheFromConfig @115
IgniteProcessorGetIgniteConfiguration @116
-IgniteProcessorDestroyCache @117
\ No newline at end of file
+IgniteProcessorDestroyCache @117
+IgniteProcessorAtomicSequence @118
+IgniteAtomicSequenceGet @119
+IgniteAtomicSequenceIncrementAndGet @120
+IgniteAtomicSequenceGetAndIncrement @121
+IgniteAtomicSequenceAddAndGet @122
+IgniteAtomicSequenceGetAndAdd @123
+IgniteAtomicSequenceGetBatchSize @124
+IgniteAtomicSequenceSetBatchSize @125
+IgniteAtomicSequenceIsClosed @126
+IgniteAtomicSequenceClose @127
+IgniteProcessorAtomicReference @128
+IgniteAtomicReferenceIsClosed @129
+IgniteAtomicReferenceClose @130
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/exports.cpp b/modules/platforms/cpp/common/src/exports.cpp
index e9ec519..fff2a16 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -114,6 +114,14 @@ extern "C" {
return ctx->ProcessorAtomicLong(static_cast<jobject>(obj), name, initVal, create);
}
+ void* IGNITE_CALL IgniteProcessorAtomicSequence(gcj::JniContext* ctx, void* obj, char* name, long long initVal, bool create) {
+ return ctx->ProcessorAtomicSequence(static_cast<jobject>(obj), name, initVal, create);
+ }
+
+ void* IGNITE_CALL IgniteProcessorAtomicReference(gcj::JniContext* ctx, void* obj, char* name, long long memPtr, bool create) {
+ return ctx->ProcessorAtomicReference(static_cast<jobject>(obj), name, memPtr, create);
+ }
+
void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr) {
return ctx->ProcessorGetIgniteConfiguration(static_cast<jobject>(obj), memPtr);
}
@@ -482,6 +490,50 @@ extern "C" {
void IGNITE_CALL IgniteAtomicLongClose(gcj::JniContext* ctx, void* obj) {
return ctx->AtomicLongClose(static_cast<jobject>(obj));
}
+
+ long long IGNITE_CALL IgniteAtomicSequenceGet(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceGet(static_cast<jobject>(obj));
+ }
+
+ long long IGNITE_CALL IgniteAtomicSequenceIncrementAndGet(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceIncrementAndGet(static_cast<jobject>(obj));
+ }
+
+ long long IGNITE_CALL IgniteAtomicSequenceGetAndIncrement(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceGetAndIncrement(static_cast<jobject>(obj));
+ }
+
+ long long IGNITE_CALL IgniteAtomicSequenceAddAndGet(gcj::JniContext* ctx, void* obj, long long l) {
+ return ctx->AtomicSequenceAddAndGet(static_cast<jobject>(obj), l);
+ }
+
+ long long IGNITE_CALL IgniteAtomicSequenceGetAndAdd(gcj::JniContext* ctx, void* obj, long long l) {
+ return ctx->AtomicSequenceGetAndAdd(static_cast<jobject>(obj), l);
+ }
+
+ int IGNITE_CALL IgniteAtomicSequenceGetBatchSize(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceGetBatchSize(static_cast<jobject>(obj));
+ }
+
+ void IGNITE_CALL IgniteAtomicSequenceSetBatchSize(gcj::JniContext* ctx, void* obj, int size) {
+ return ctx->AtomicSequenceSetBatchSize(static_cast<jobject>(obj), size);
+ }
+
+ bool IGNITE_CALL IgniteAtomicSequenceIsClosed(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceIsClosed(static_cast<jobject>(obj));
+ }
+
+ void IGNITE_CALL IgniteAtomicSequenceClose(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicSequenceClose(static_cast<jobject>(obj));
+ }
+
+ bool IGNITE_CALL IgniteAtomicReferenceIsClosed(gcj::JniContext* ctx, void* obj) {
+ return ctx->AtomicReferenceIsClosed(static_cast<jobject>(obj));
+ }
+
+ void IGNITE_CALL IgniteAtomicReferenceClose(gcj::JniContext* ctx, void* obj) {
+ ctx->AtomicReferenceClose(static_cast<jobject>(obj));
+ }
bool IGNITE_CALL IgniteListenableCancel(gcj::JniContext* ctx, void* obj) {
return ctx->ListenableCancel(static_cast<jobject>(obj));
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index e36c1e0..d6f7ef0 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -203,6 +203,8 @@ namespace ignite
JniMethod M_PLATFORM_PROCESSOR_SERVICES = JniMethod("services", "(Lorg/apache/ignite/internal/processors/platform/PlatformTarget;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_EXTENSIONS = JniMethod("extensions", "()Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_ATOMIC_LONG = JniMethod("atomicLong", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_ATOMIC_SEQUENCE = JniMethod("atomicSequence", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_ATOMIC_REFERENCE = JniMethod("atomicReference", "(Ljava/lang/String;JZ)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION = JniMethod("getIgniteConfiguration", "(J)V", false);
const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
@@ -396,6 +398,21 @@ namespace ignite
JniMethod M_PLATFORM_ATOMIC_LONG_IS_CLOSED = JniMethod("isClosed", "()Z", false);
JniMethod M_PLATFORM_ATOMIC_LONG_CLOSE = JniMethod("close", "()V", false);
+ const char* C_PLATFORM_ATOMIC_SEQUENCE = "org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicSequence";
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET = JniMethod("get", "()J", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_INCREMENT_AND_GET = JniMethod("incrementAndGet", "()J", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_INCREMENT = JniMethod("getAndIncrement", "()J", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_ADD_AND_GET = JniMethod("addAndGet", "(J)J", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_ADD = JniMethod("getAndAdd", "(J)J", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_GET_BATCH_SIZE = JniMethod("getBatchSize", "()I", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_SET_BATCH_SIZE = JniMethod("setBatchSize", "(I)V", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_IS_CLOSED = JniMethod("isClosed", "()Z", false);
+ JniMethod M_PLATFORM_ATOMIC_SEQUENCE_CLOSE = JniMethod("close", "()V", false);
+
+ const char* C_PLATFORM_ATOMIC_REFERENCE = "org/apache/ignite/internal/processors/platform/datastructures/PlatformAtomicReference";
+ JniMethod M_PLATFORM_ATOMIC_REFERENCE_IS_CLOSED = JniMethod("isClosed", "()Z", false);
+ JniMethod M_PLATFORM_ATOMIC_REFERENCE_CLOSE = JniMethod("close", "()V", false);
+
const char* C_PLATFORM_LISTENABLE = "org/apache/ignite/internal/processors/platform/utils/PlatformListenable";
JniMethod M_PLATFORM_LISTENABLE_CANCEL = JniMethod("cancel", "()Z", false);
JniMethod M_PLATFORM_LISTENABLE_IS_CANCELED = JniMethod("isCancelled", "()Z", false);
@@ -652,6 +669,8 @@ namespace ignite
m_PlatformProcessor_services = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_SERVICES);
m_PlatformProcessor_extensions = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_EXTENSIONS);
m_PlatformProcessor_atomicLong = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_LONG);
+ m_PlatformProcessor_atomicSequence = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_SEQUENCE);
+ m_PlatformProcessor_atomicReference = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_ATOMIC_REFERENCE);
m_PlatformProcessor_getIgniteConfiguration = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION);
c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
@@ -695,6 +714,21 @@ namespace ignite
m_PlatformAtomicLong_isClosed = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_IS_CLOSED);
m_PlatformAtomicLong_close = FindMethod(env, c_PlatformAtomicLong, M_PLATFORM_ATOMIC_LONG_CLOSE);
+ jclass c_PlatformAtomicSequence = FindClass(env, C_PLATFORM_ATOMIC_SEQUENCE);
+ m_PlatformAtomicSequence_get = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET);
+ m_PlatformAtomicSequence_incrementAndGet = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_INCREMENT_AND_GET);
+ m_PlatformAtomicSequence_getAndIncrement = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_INCREMENT);
+ m_PlatformAtomicSequence_addAndGet = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_ADD_AND_GET);
+ m_PlatformAtomicSequence_getAndAdd = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_AND_ADD);
+ m_PlatformAtomicSequence_getBatchSize = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_GET_BATCH_SIZE);
+ m_PlatformAtomicSequence_setBatchSize = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_SET_BATCH_SIZE);
+ m_PlatformAtomicSequence_isClosed = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_IS_CLOSED);
+ m_PlatformAtomicSequence_close = FindMethod(env, c_PlatformAtomicSequence, M_PLATFORM_ATOMIC_SEQUENCE_CLOSE);
+
+ jclass c_PlatformAtomicReference = FindClass(env, C_PLATFORM_ATOMIC_REFERENCE);
+ m_PlatformAtomicReference_isClosed = FindMethod(env, c_PlatformAtomicReference, M_PLATFORM_ATOMIC_REFERENCE_IS_CLOSED);
+ m_PlatformAtomicReference_close = FindMethod(env, c_PlatformAtomicReference, M_PLATFORM_ATOMIC_REFERENCE_CLOSE);
+
c_PlatformListenable = FindClass(env, C_PLATFORM_LISTENABLE);
m_PlatformListenable_cancel = FindMethod(env, c_PlatformListenable, M_PLATFORM_LISTENABLE_CANCEL);
m_PlatformListenable_isCancelled = FindMethod(env, c_PlatformListenable, M_PLATFORM_LISTENABLE_IS_CANCELED);
@@ -1307,6 +1341,38 @@ namespace ignite
return LocalToGlobal(env, res);
}
+ jobject JniContext::ProcessorAtomicSequence(jobject obj, char* name, long long initVal, bool create)
+ {
+ JNIEnv* env = Attach();
+
+ jstring name0 = name != NULL ? env->NewStringUTF(name) : NULL;
+
+ jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformProcessor_atomicSequence, name0, initVal, create);
+
+ if (name0)
+ env->DeleteLocalRef(name0);
+
+ ExceptionCheck(env);
+
+ return LocalToGlobal(env, res);
+ }
+
+ jobject JniContext::ProcessorAtomicReference(jobject obj, char* name, long long memPtr, bool create)
+ {
+ JNIEnv* env = Attach();
+
+ jstring name0 = name != NULL ? env->NewStringUTF(name) : NULL;
+
+ jobject res = env->CallObjectMethod(obj, jvm->GetMembers().m_PlatformProcessor_atomicReference, name0, memPtr, create);
+
+ if (name0)
+ env->DeleteLocalRef(name0);
+
+ ExceptionCheck(env);
+
+ return LocalToGlobal(env, res);
+ }
+
void JniContext::ProcessorGetIgniteConfiguration(jobject obj, long memPtr)
{
JNIEnv* env = Attach();
@@ -2139,6 +2205,121 @@ namespace ignite
ExceptionCheck(env);
}
+ long long JniContext::AtomicSequenceGet(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_get);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ long long JniContext::AtomicSequenceIncrementAndGet(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_incrementAndGet);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ long long JniContext::AtomicSequenceGetAndIncrement(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getAndIncrement);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ long long JniContext::AtomicSequenceAddAndGet(jobject obj, long long l)
+ {
+ JNIEnv* env = Attach();
+
+ long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_addAndGet, l);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ long long JniContext::AtomicSequenceGetAndAdd(jobject obj, long long l)
+ {
+ JNIEnv* env = Attach();
+
+ long long res = env->CallLongMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getAndAdd, l);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ int JniContext::AtomicSequenceGetBatchSize(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ int res = env->CallIntMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_getBatchSize);
+
+ ExceptionCheck(env);
+
+ return res;
+ }
+
+ void JniContext::AtomicSequenceSetBatchSize(jobject obj, int size)
+ {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_setBatchSize, size);
+
+ ExceptionCheck(env);
+ }
+
+ bool JniContext::AtomicSequenceIsClosed(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_isClosed);
+
+ ExceptionCheck(env);
+
+ return res != 0;
+ }
+
+ void JniContext::AtomicSequenceClose(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicSequence_close);
+
+ ExceptionCheck(env);
+ }
+
+ bool JniContext::AtomicReferenceIsClosed(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ jboolean res = env->CallBooleanMethod(obj, jvm->GetMembers().m_PlatformAtomicReference_isClosed);
+
+ ExceptionCheck(env);
+
+ return res != 0;
+ }
+
+ void JniContext::AtomicReferenceClose(jobject obj)
+ {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformAtomicReference_close);
+
+ ExceptionCheck(env);
+ }
+
bool JniContext::ListenableCancel(jobject obj)
{
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index 481adfb..f5e98c5 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -107,6 +107,8 @@
<Compile Include="Compute\TaskResultTest.cs" />
<Compile Include="Dataload\DataStreamerTest.cs" />
<Compile Include="DataStructures\AtomicLongTest.cs" />
+ <Compile Include="DataStructures\AtomicReferenceTest.cs" />
+ <Compile Include="DataStructures\AtomicSequenceTest.cs" />
<Compile Include="EventsTest.cs" />
<Compile Include="Examples\Example.cs" />
<Compile Include="Examples\ExamplesTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
new file mode 100644
index 0000000..93375da
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicReferenceTest.cs
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.DataStructures
+{
+ using System;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Atomic reference test.
+ /// </summary>
+ public class AtomicReferenceTest : IgniteTestBase
+ {
+ /** */
+ private const string AtomicRefName = "testAtomicRef";
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AtomicReferenceTest"/> class.
+ /// </summary>
+ public AtomicReferenceTest() : base("config\\compute\\compute-grid1.xml")
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public override void TestSetUp()
+ {
+ base.TestSetUp();
+
+ // Close test atomic if there is any
+ Grid.GetAtomicReference(AtomicRefName, 0, true).Close();
+ }
+
+ /** <inheritdoc /> */
+ protected override IgniteConfiguration GetConfiguration(string springConfigUrl)
+ {
+ var cfg = base.GetConfiguration(springConfigUrl);
+
+ cfg.BinaryConfiguration = new BinaryConfiguration(typeof(BinaryObj));
+
+ return cfg;
+ }
+
+ /// <summary>
+ /// Tests lifecycle of the AtomicReference.
+ /// </summary>
+ [Test]
+ public void TestCreateClose()
+ {
+ Assert.IsNull(Grid.GetAtomicReference(AtomicRefName, 10, false));
+
+ // Nonexistent atomic returns null
+ Assert.IsNull(Grid.GetAtomicReference(AtomicRefName, 10, false));
+
+ // Create new
+ var al = Grid.GetAtomicReference(AtomicRefName, 10, true);
+ Assert.AreEqual(AtomicRefName, al.Name);
+ Assert.AreEqual(10, al.Read());
+ Assert.AreEqual(false, al.IsClosed);
+
+ // Get existing with create flag
+ var al2 = Grid.GetAtomicReference(AtomicRefName, 5, true);
+ Assert.AreEqual(AtomicRefName, al2.Name);
+ Assert.AreEqual(10, al2.Read());
+ Assert.AreEqual(false, al2.IsClosed);
+
+ // Get existing without create flag
+ var al3 = Grid.GetAtomicReference(AtomicRefName, 5, false);
+ Assert.AreEqual(AtomicRefName, al3.Name);
+ Assert.AreEqual(10, al3.Read());
+ Assert.AreEqual(false, al3.IsClosed);
+
+ al.Close();
+
+ Assert.AreEqual(true, al.IsClosed);
+ Assert.AreEqual(true, al2.IsClosed);
+ Assert.AreEqual(true, al3.IsClosed);
+
+ Assert.IsNull(Grid.GetAtomicReference(AtomicRefName, 10, false));
+ }
+
+ /// <summary>
+ /// Tests modification methods.
+ /// </summary>
+ [Test]
+ public void TestModify()
+ {
+ var atomics = Enumerable.Range(1, 10)
+ .Select(x => Grid.GetAtomicReference(AtomicRefName, 5, true)).ToList();
+
+ atomics.ForEach(x => Assert.AreEqual(5, x.Read()));
+
+ atomics[0].Write(15);
+ atomics.ForEach(x => Assert.AreEqual(15, x.Read()));
+
+ Assert.AreEqual(15, atomics[0].CompareExchange(42, 15));
+ atomics.ForEach(x => Assert.AreEqual(42, x.Read()));
+ }
+
+ /// <summary>
+ /// Tests primitives in the atomic.
+ /// </summary>
+ [Test]
+ public void TestPrimitives()
+ {
+ TestOperations(1, 2);
+ TestOperations("1", "2");
+ TestOperations(Guid.NewGuid(), Guid.NewGuid());
+ }
+
+ /// <summary>
+ /// Tests DateTime in the atomic.
+ /// </summary>
+ [Test]
+ [Ignore("IGNITE-2578")]
+ public void TestDateTime()
+ {
+ TestOperations(DateTime.Now, DateTime.Now.AddDays(-1));
+ }
+
+ /// <summary>
+ /// Tests serializable objects in the atomic.
+ /// </summary>
+ [Test]
+ [Ignore("IGNITE-2578")]
+ public void TestSerializable()
+ {
+ TestOperations(new SerializableObj {Foo = 16}, new SerializableObj {Foo = -5});
+ }
+
+ /// <summary>
+ /// Tests binarizable objects in the atomic.
+ /// </summary>
+ [Test]
+ public void TestBinarizable()
+ {
+ TestOperations(new BinaryObj {Foo = 16}, new BinaryObj {Foo = -5});
+ }
+
+ /// <summary>
+ /// Tests operations on specific object.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="x">The x.</param>
+ /// <param name="y">The y.</param>
+ private void TestOperations<T>(T x, T y)
+ {
+ Grid.GetAtomicReference(AtomicRefName, 0, true).Close();
+
+ var atomic = Grid.GetAtomicReference(AtomicRefName, x, true);
+
+ Assert.AreEqual(x, atomic.Read());
+
+ atomic.Write(y);
+ Assert.AreEqual(y, atomic.Read());
+
+ var old = atomic.CompareExchange(x, y);
+ Assert.AreEqual(y, old);
+ Assert.AreEqual(x, atomic.Read());
+
+ old = atomic.CompareExchange(x, y);
+ Assert.AreEqual(x, old);
+ Assert.AreEqual(x, atomic.Read());
+
+ // Check nulls
+ var nul = default(T);
+
+ old = atomic.CompareExchange(nul, x);
+ Assert.AreEqual(x, old);
+ Assert.AreEqual(nul, atomic.Read());
+
+ old = atomic.CompareExchange(y, nul);
+ Assert.AreEqual(nul, old);
+ Assert.AreEqual(y, atomic.Read());
+ }
+
+ /// <summary>
+ /// Serializable.
+ /// </summary>
+ [Serializable]
+ private class SerializableObj
+ {
+ /** */
+ public int Foo { get; set; }
+
+ /** <inheritdoc /> */
+ private bool Equals(SerializableObj other)
+ {
+ return Foo == other.Foo;
+ }
+
+ /** <inheritdoc /> */
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != GetType()) return false;
+ return Equals((SerializableObj) obj);
+ }
+
+ /** <inheritdoc /> */
+ public override int GetHashCode()
+ {
+ // ReSharper disable once NonReadonlyMemberInGetHashCode
+ return Foo;
+ }
+
+ /** <inheritdoc /> */
+ public override string ToString()
+ {
+ return base.ToString() + "[" + Foo + "]";
+ }
+ }
+
+ /// <summary>
+ /// Binary.
+ /// </summary>
+ private sealed class BinaryObj : SerializableObj
+ {
+ // No-op.
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs
new file mode 100644
index 0000000..472dee2
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/DataStructures/AtomicSequenceTest.cs
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.DataStructures
+{
+ using System.Linq;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Atomic sequence test.
+ /// </summary>
+ public class AtomicSequenceTest : IgniteTestBase
+ {
+ /** */
+ private const string AtomicSeqName = "testAtomicSeq";
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AtomicSequenceTest"/> class.
+ /// </summary>
+ public AtomicSequenceTest() : base("config\\compute\\compute-grid1.xml")
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public override void TestSetUp()
+ {
+ base.TestSetUp();
+
+ // Close test atomic if there is any
+ Grid.GetAtomicSequence(AtomicSeqName, 0, true).Close();
+ }
+
+ /// <summary>
+ /// Tests lifecycle of the AtomicSequence.
+ /// </summary>
+ [Test]
+ public void TestCreateClose()
+ {
+ Assert.IsNull(Grid.GetAtomicSequence(AtomicSeqName, 10, false));
+
+ // Nonexistent atomic returns null
+ Assert.IsNull(Grid.GetAtomicSequence(AtomicSeqName, 10, false));
+
+ // Create new
+ var al = Grid.GetAtomicSequence(AtomicSeqName, 10, true);
+ Assert.AreEqual(AtomicSeqName, al.Name);
+ Assert.AreEqual(10, al.Read());
+ Assert.AreEqual(false, al.IsClosed);
+
+ // Get existing with create flag
+ var al2 = Grid.GetAtomicSequence(AtomicSeqName, 5, true);
+ Assert.AreEqual(AtomicSeqName, al2.Name);
+ Assert.AreEqual(10, al2.Read());
+ Assert.AreEqual(false, al2.IsClosed);
+
+ // Get existing without create flag
+ var al3 = Grid.GetAtomicSequence(AtomicSeqName, 5, false);
+ Assert.AreEqual(AtomicSeqName, al3.Name);
+ Assert.AreEqual(10, al3.Read());
+ Assert.AreEqual(false, al3.IsClosed);
+
+ al.Close();
+
+ Assert.AreEqual(true, al.IsClosed);
+ Assert.AreEqual(true, al2.IsClosed);
+ Assert.AreEqual(true, al3.IsClosed);
+
+ Assert.IsNull(Grid.GetAtomicSequence(AtomicSeqName, 10, false));
+ }
+
+ /// <summary>
+ /// Tests modification methods.
+ /// </summary>
+ [Test]
+ public void TestModify()
+ {
+ var atomics = Enumerable.Range(1, 10)
+ .Select(x => Grid.GetAtomicSequence(AtomicSeqName, 5, true)).ToList();
+
+ atomics.ForEach(x => Assert.AreEqual(5, x.Read()));
+
+ Assert.AreEqual(10, atomics[0].Add(5));
+ atomics.ForEach(x => Assert.AreEqual(10, x.Read()));
+
+ Assert.AreEqual(11, atomics[0].Increment());
+ atomics.ForEach(x => Assert.AreEqual(11, x.Read()));
+
+ atomics.ForEach(x => x.BatchSize = 42);
+ atomics.ForEach(x => Assert.AreEqual(42, x.BatchSize));
+ }
+
+ /// <summary>
+ /// Tests multithreaded scenario.
+ /// </summary>
+ [Test]
+ public void TestMultithreaded()
+ {
+ const int atomicCnt = 10;
+ const int threadCnt = 5;
+ const int iterations = 3000;
+
+ // 10 atomics with same name
+ var atomics = Enumerable.Range(1, atomicCnt)
+ .Select(x => Grid.GetAtomicSequence(AtomicSeqName, 0, true)).ToList();
+
+ // 5 threads increment 30000 times
+ TestUtils.RunMultiThreaded(() =>
+ {
+ for (var i = 0; i < iterations; i++)
+ atomics.ForEach(x => x.Increment());
+ }, threadCnt);
+
+ atomics.ForEach(x => Assert.AreEqual(atomicCnt*threadCnt*iterations, x.Read()));
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 1c83168..e2efd0a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -161,6 +161,8 @@
<Compile Include="Datastream\StreamTransformer.cs" />
<Compile Include="Datastream\StreamVisitor.cs" />
<Compile Include="DataStructures\IAtomicLong.cs" />
+ <Compile Include="DataStructures\IAtomicReference.cs" />
+ <Compile Include="DataStructures\IAtomicSequence.cs" />
<Compile Include="DataStructures\Package-Info.cs" />
<Compile Include="Events\CacheEvent.cs" />
<Compile Include="Events\CacheQueryExecutedEvent.cs" />
@@ -259,6 +261,8 @@
<Compile Include="Impl\Datastream\DataStreamerRemoveEntry.cs" />
<Compile Include="Impl\Datastream\StreamReceiverHolder.cs" />
<Compile Include="Impl\DataStructures\AtomicLong.cs" />
+ <Compile Include="Impl\DataStructures\AtomicReference.cs" />
+ <Compile Include="Impl\DataStructures\AtomicSequence.cs" />
<Compile Include="Impl\Events\Events.cs" />
<Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
<Compile Include="Impl\ExceptionUtils.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicReference.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicReference.cs b/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicReference.cs
new file mode 100644
index 0000000..403c0ca
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicReference.cs
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.DataStructures
+{
+ /// <summary>
+ /// Represents a named value in the distributed cache.
+ /// </summary>
+ public interface IAtomicReference<T>
+ {
+ /// <summary>
+ /// Gets the name of this atomic reference.
+ /// </summary>
+ /// <value>
+ /// Name of this atomic reference.
+ /// </value>
+ string Name { get; }
+
+ /// <summary>
+ /// Reads current value of an atomic reference.
+ /// </summary>
+ /// <returns>Current value of an atomic reference.</returns>
+ T Read();
+
+ /// <summary>
+ /// Writes current value of an atomic reference.
+ /// </summary>
+ /// <param name="value">The value to set.</param>
+ void Write(T value);
+
+ /// <summary>
+ /// Compares current value with specified value for equality and, if they are equal, replaces current value.
+ /// </summary>
+ /// <param name="value">The value to set.</param>
+ /// <param name="comparand">The value that is compared to the current value.</param>
+ /// <returns>Original value of the atomic reference.</returns>
+ T CompareExchange(T value, T comparand);
+
+ /// <summary>
+ /// Determines whether this instance was removed from cache.
+ /// </summary>
+ /// <returns>True if this atomic was removed from cache; otherwise, false.</returns>
+ bool IsClosed { get; }
+
+ /// <summary>
+ /// Closes this instance.
+ /// </summary>
+ void Close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicSequence.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicSequence.cs b/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicSequence.cs
new file mode 100644
index 0000000..f5b1dad
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/DataStructures/IAtomicSequence.cs
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.DataStructures
+{
+ /// <summary>
+ /// Represents a distributed atomic sequence of numbers.
+ /// </summary>
+ public interface IAtomicSequence
+ {
+ /// <summary>
+ /// Gets the name of this atomic sequence.
+ /// </summary>
+ /// <value>
+ /// Name of this atomic sequence.
+ /// </value>
+ string Name { get; }
+
+ /// <summary>
+ /// Returns current value.
+ /// </summary>
+ /// <returns>Current value of the atomic sequence.</returns>
+ long Read();
+
+ /// <summary>
+ /// Increments current value and returns result.
+ /// </summary>
+ /// <returns>The new value of the atomic sequence.</returns>
+ long Increment();
+
+ /// <summary>
+ /// Adds specified value to the current value and returns result.
+ /// </summary>
+ /// <param name="value">The value to add.</param>
+ /// <returns>The new value of the atomic sequence.</returns>
+ long Add(long value);
+
+ /// <summary>
+ /// Gets local batch size for this atomic sequence.
+ /// </summary>
+ /// <returns>Sequence batch size.</returns>
+ int BatchSize { get; set; }
+
+ /// <summary>
+ /// Determines whether this instance was removed from cache.
+ /// </summary>
+ /// <returns>True if this atomic was removed from cache; otherwise, false.</returns>
+ bool IsClosed { get; }
+
+ /// <summary>
+ /// Closes this instance.
+ /// </summary>
+ void Close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index d18e790..12ea09e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -192,6 +192,34 @@ namespace Apache.Ignite.Core
IAtomicLong GetAtomicLong(string name, long initialValue, bool create);
/// <summary>
+ /// Gets an atomic sequence with specified name from cache.
+ /// Creates new atomic sequence in cache if it does not exist and <paramref name="create"/> is true.
+ /// </summary>
+ /// <param name="name">Name of the atomic sequence.</param>
+ /// <param name="initialValue">
+ /// Initial value for the atomic sequence. Ignored if <paramref name="create"/> is false.
+ /// </param>
+ /// <param name="create">Flag indicating whether atomic sequence should be created if it does not exist.</param>
+ /// <returns>Atomic sequence instance with specified name,
+ /// or null if it does not exist and <paramref name="create"/> flag is not set.</returns>
+ /// <exception cref="IgniteException">If atomic sequence could not be fetched or created.</exception>
+ IAtomicSequence GetAtomicSequence(string name, long initialValue, bool create);
+
+ /// <summary>
+ /// Gets an atomic reference with specified name from cache.
+ /// Creates new atomic reference in cache if it does not exist and <paramref name="create"/> is true.
+ /// </summary>
+ /// <param name="name">Name of the atomic reference.</param>
+ /// <param name="initialValue">
+ /// Initial value for the atomic reference. Ignored if <paramref name="create"/> is false.
+ /// </param>
+ /// <param name="create">Flag indicating whether atomic reference should be created if it does not exist.</param>
+ /// <returns>Atomic reference instance with specified name,
+ /// or null if it does not exist and <paramref name="create"/> flag is not set.</returns>
+ /// <exception cref="IgniteException">If atomic reference could not be fetched or created.</exception>
+ IAtomicReference<T> GetAtomicReference<T>(string name, T initialValue, bool create);
+
+ /// <summary>
/// Gets the configuration of this Ignite instance.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
new file mode 100644
index 0000000..e871412
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicReference.cs
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.DataStructures
+{
+ using System.Diagnostics;
+ using Apache.Ignite.Core.DataStructures;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Unmanaged;
+
+ /// <summary>
+ /// Atomic reference.
+ /// </summary>
+ internal class AtomicReference<T> : PlatformTarget, IAtomicReference<T>
+ {
+ /** Opcodes. */
+ private enum Op
+ {
+ Get = 1,
+ Set = 2,
+ CompareAndSetAndGet = 3
+ }
+
+ /** */
+ private readonly string _name;
+
+ /** <inheritDoc /> */
+ public AtomicReference(IUnmanagedTarget target, Marshaller marsh, string name)
+ : base(target, marsh)
+ {
+ Debug.Assert(!string.IsNullOrEmpty(name));
+
+ _name = name;
+ }
+
+ /** <inheritDoc /> */
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ /** <inheritDoc /> */
+ public T Read()
+ {
+ return DoInOp<T>((int) Op.Get);
+ }
+
+ /** <inheritDoc /> */
+ public void Write(T value)
+ {
+ DoOutOp((int) Op.Set, value);
+ }
+
+ /** <inheritDoc /> */
+ public T CompareExchange(T value, T comparand)
+ {
+ return DoOutInOp((int) Op.CompareAndSetAndGet,
+ writer =>
+ {
+ writer.WriteObject(value);
+ writer.WriteObject(comparand);
+ },
+ stream => Marshaller.StartUnmarshal(stream).Deserialize<T>());
+ }
+
+ /** <inheritDoc /> */
+ public bool IsClosed
+ {
+ get { return UnmanagedUtils.AtomicReferenceIsClosed(Target); }
+ }
+
+ /** <inheritDoc /> */
+ public void Close()
+ {
+ UnmanagedUtils.AtomicReferenceClose(Target);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
new file mode 100644
index 0000000..0835b9a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/DataStructures/AtomicSequence.cs
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Impl.DataStructures
+{
+ using System.Diagnostics;
+ using Apache.Ignite.Core.DataStructures;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Unmanaged;
+
+ /// <summary>
+ /// Atomic long wrapper.
+ /// </summary>
+ internal sealed class AtomicSequence: PlatformTarget, IAtomicSequence
+ {
+ /** */
+ private readonly string _name;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Apache.Ignite.Core.Impl.DataStructures.AtomicLong"/> class.
+ /// </summary>
+ /// <param name="target">The target.</param>
+ /// <param name="marsh">The marshaller.</param>
+ /// <param name="name">The name.</param>
+ public AtomicSequence(IUnmanagedTarget target, Marshaller marsh, string name)
+ : base(target, marsh)
+ {
+ Debug.Assert(!string.IsNullOrEmpty(name));
+
+ _name = name;
+ }
+
+ /** <inheritDoc /> */
+ public string Name
+ {
+ get { return _name; }
+ }
+
+ /** <inheritDoc /> */
+ public long Read()
+ {
+ return UnmanagedUtils.AtomicSequenceGet(Target);
+ }
+
+ /** <inheritDoc /> */
+ public long Increment()
+ {
+ return UnmanagedUtils.AtomicSequenceIncrementAndGet(Target);
+ }
+
+ /** <inheritDoc /> */
+ public long Add(long value)
+ {
+ return UnmanagedUtils.AtomicSequenceAddAndGet(Target, value);
+ }
+
+ /** <inheritDoc /> */
+ public int BatchSize
+ {
+ get { return UnmanagedUtils.AtomicSequenceGetBatchSize(Target); }
+ set { UnmanagedUtils.AtomicSequenceSetBatchSize(Target, value); }
+ }
+
+ /** <inheritDoc /> */
+ public bool IsClosed
+ {
+ get { return UnmanagedUtils.AtomicSequenceIsClosed(Target); }
+ }
+
+ /** <inheritDoc /> */
+ public void Close()
+ {
+ UnmanagedUtils.AtomicSequenceClose(Target);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 9d27117..be21d7f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -486,6 +486,56 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IAtomicSequence GetAtomicSequence(string name, long initialValue, bool create)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ var nativeSeq = UU.ProcessorAtomicSequence(_proc, name, initialValue, create);
+
+ if (nativeSeq == null)
+ return null;
+
+ return new AtomicSequence(nativeSeq, Marshaller, name);
+ }
+
+ /** <inheritdoc /> */
+ public IAtomicReference<T> GetAtomicReference<T>(string name, T initialValue, bool create)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ var refTarget = GetAtomicReferenceUnmanaged(name, initialValue, create);
+
+ return refTarget == null ? null : new AtomicReference<T>(refTarget, Marshaller, name);
+ }
+
+ /// <summary>
+ /// Gets the unmanaged atomic reference.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="initialValue">The initial value.</param>
+ /// <param name="create">Create flag.</param>
+ /// <returns>Unmanaged atomic reference, or null.</returns>
+ private IUnmanagedTarget GetAtomicReferenceUnmanaged<T>(string name, T initialValue, bool create)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ // Do not allocate memory when default is not used.
+ if (!create)
+ return UU.ProcessorAtomicReference(_proc, name, 0, false);
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var writer = Marshaller.StartMarshal(stream);
+
+ writer.Write(initialValue);
+
+ var memPtr = stream.SynchronizeOutput();
+
+ return UU.ProcessorAtomicReference(_proc, name, memPtr, true);
+ }
+ }
+
+ /** <inheritdoc /> */
public IgniteConfiguration GetConfiguration()
{
using (var stream = IgniteManager.Memory.Allocate(1024).GetStream())
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 46bc3ca..a303783 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -340,6 +340,18 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IAtomicSequence GetAtomicSequence(string name, long initialValue, bool create)
+ {
+ return _ignite.GetAtomicSequence(name, initialValue, create);
+ }
+
+ /** <inheritdoc /> */
+ public IAtomicReference<T> GetAtomicReference<T>(string name, T initialValue, bool create)
+ {
+ return _ignite.GetAtomicReference(name, initialValue, create);
+ }
+
+ /** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
{
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f7c1296c/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index 17df94a..28eb208 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -93,6 +93,14 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
public static extern void* ProcessorAtomicLong(void* ctx, void* obj, sbyte* name, long initVal,
[MarshalAs(UnmanagedType.U1)] bool create);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorAtomicSequence")]
+ public static extern void* ProcessorAtomicSequence(void* ctx, void* obj, sbyte* name, long initVal,
+ [MarshalAs(UnmanagedType.U1)] bool create);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorAtomicReference")]
+ public static extern void* ProcessorAtomicReference(void* ctx, void* obj, sbyte* name, long memPtr,
+ [MarshalAs(UnmanagedType.U1)] bool create);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetIgniteConfiguration")]
public static extern void ProcessorGetIgniteConfiguration(void* ctx, void* obj, long memPtr);
@@ -373,6 +381,35 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicLongClose")]
public static extern void AtomicLongClose(void* ctx, void* target);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceGet")]
+ public static extern long AtomicSequenceGet(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceIncrementAndGet")]
+ public static extern long AtomicSequenceIncrementAndGet(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceAddAndGet")]
+ public static extern long AtomicSequenceAddAndGet(void* ctx, void* target, long value);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceGetBatchSize")]
+ public static extern int AtomicSequenceGetBatchSize(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceSetBatchSize")]
+ public static extern void AtomicSequenceSetBatchSize(void* ctx, void* target, int size);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceIsClosed")]
+ [return: MarshalAs(UnmanagedType.U1)]
+ public static extern bool AtomicSequenceIsClosed(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicSequenceClose")]
+ public static extern void AtomicSequenceClose(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicReferenceIsClosed")]
+ [return: MarshalAs(UnmanagedType.U1)]
+ public static extern bool AtomicReferenceIsClosed(void* ctx, void* target);
+
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteAtomicReferenceClose")]
+ public static extern void AtomicReferenceClose(void* ctx, void* target);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteListenableCancel")]
[return: MarshalAs(UnmanagedType.U1)]
public static extern bool ListenableCancel(void* ctx, void* target);
[13/21] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by sb...@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/fa3706f8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fa3706f8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fa3706f8
Branch: refs/heads/ignite-2542
Commit: fa3706f866b42418abaa54c5f4e73f2dedb166b0
Parents: c3aa137 4c05fc0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 10 15:01:00 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 15:01:00 2016 +0300
----------------------------------------------------------------------
.../processors/cache/CacheLazyEntry.java | 3 +
.../processors/cache/GridCacheContext.java | 4 +-
.../processors/cache/GridCacheMapEntry.java | 118 +++-
.../binary/CacheObjectBinaryProcessorImpl.java | 6 +-
.../dht/atomic/GridDhtAtomicCache.java | 79 ++-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 85 ++-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 38 +-
.../cache/query/GridCacheQueryManager.java | 30 +-
.../continuous/CacheContinuousQueryHandler.java | 3 +-
.../CacheContinuousQueryListener.java | 2 +-
.../continuous/CacheContinuousQueryManager.java | 120 +++-
.../continuous/GridContinuousProcessor.java | 16 +-
.../IgniteCacheEntryListenerAbstractTest.java | 454 ++++++++----
...cheEntryListenerAtomicOffheapTieredTest.java | 32 +
...cheEntryListenerAtomicOffheapValuesTest.java | 32 +
...teCacheEntryListenerTxOffheapTieredTest.java | 32 +
...teCacheEntryListenerTxOffheapValuesTest.java | 32 +
.../cache/IgniteCacheEntryListenerTxTest.java | 1 +
...ContinuousQueryFailoverAbstractSelfTest.java | 10 +
...tomicPrimaryWriteOrderOffheapTieredTest.java | 33 +
...tinuousQueryFailoverTxOffheapTieredTest.java | 32 +
...acheContinuousQueryRandomOperationsTest.java | 684 +++++++++++++++++++
...ridCacheContinuousQueryAbstractSelfTest.java | 19 +-
...eContinuousQueryAtomicOffheapTieredTest.java | 32 +
...eContinuousQueryAtomicOffheapValuesTest.java | 32 +
...CacheContinuousQueryTxOffheapTieredTest.java | 32 +
...CacheContinuousQueryTxOffheapValuesTest.java | 32 +
.../junits/common/GridCommonAbstractTest.java | 2 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 8 +
.../IgniteCacheQuerySelfTestSuite.java | 14 +
.../commands/tasks/VisorTasksCommand.scala | 4 +-
.../scala/org/apache/ignite/visor/visor.scala | 4 +
32 files changed, 1749 insertions(+), 276 deletions(-)
----------------------------------------------------------------------
[19/21] ignite git commit: Improved KerberosHadoopFileSystemFactory
JavaDocs.
Posted by sb...@apache.org.
Improved KerberosHadoopFileSystemFactory JavaDocs.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a9937a6e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a9937a6e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a9937a6e
Branch: refs/heads/ignite-2542
Commit: a9937a6e20407189b8bd67b2cc30a30ddc8dd6ce
Parents: d08a779
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 10 16:57:16 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 16:57:16 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a9937a6e/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
index fc768d6..a78cabc 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/hadoop/fs/KerberosHadoopFileSystemFactory.java
@@ -106,6 +106,9 @@ public class KerberosHadoopFileSystemFactory extends BasicHadoopFileSystemFactor
/**
* Gets the key tab full file name (e.g. "/etc/security/keytabs/hdfs.headless.keytab" or "/etc/krb5.keytab").
+ * <p>
+ * <b>NOTE!</b> Factory can be serialized and transferred to other machines where instance of
+ * {@link IgniteHadoopFileSystem} resides. Corresponding path must exist on these machines as well.
*
* @return The key tab file name.
*/
[08/21] ignite git commit: IGNITE-1507 Correct help text for 'tasks'
command in visorcmd.
Posted by sb...@apache.org.
IGNITE-1507 Correct help text for 'tasks' command in visorcmd.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0b47d5cb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0b47d5cb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0b47d5cb
Branch: refs/heads/ignite-2542
Commit: 0b47d5cbc6a6bf87e2ab121a0e50d795e3f9ed17
Parents: c67e2ea
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Wed Feb 10 17:13:50 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed Feb 10 17:13:50 2016 +0700
----------------------------------------------------------------------
.../apache/ignite/visor/commands/tasks/VisorTasksCommand.scala | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0b47d5cb/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala
index e158506..660c5f1 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/tasks/VisorTasksCommand.scala
@@ -250,7 +250,7 @@ private case class VisorTask(
* | | of Event Storage SPI that is responsible for temporary storage of generated |
* | | events on each node can also affect the functionality of this command. |
* | | |
- * | | By default - all events are enabled and Ignite stores last 10,000 local |
+ * | | By default - all events are disabled and Ignite stores last 10,000 local |
* | | events on each node. Both of these defaults can be changed in configuration. |
* +---------------------------------------------------------------------------------------+
* }}}
@@ -1341,7 +1341,7 @@ object VisorTasksCommand {
"of Event Storage SPI that is responsible for temporary storage of generated",
"events on each node can also affect the functionality of this command.",
" ",
- "By default - all events are enabled and Ignite stores last 10,000 local",
+ "By default - all events are disabled and Ignite stores last 10,000 local",
"events on each node. Both of these defaults can be changed in configuration."
),
spec = List(
[12/21] ignite git commit: IGNITE-2564: CPP: Fixed a bug preventing
CPP memory reallocation from Java. This closes #460.
Posted by sb...@apache.org.
IGNITE-2564: CPP: Fixed a bug preventing CPP memory reallocation from Java. This closes #460.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c3aa1375
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c3aa1375
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c3aa1375
Branch: refs/heads/ignite-2542
Commit: c3aa1375171b5f3a97cd50fcd209256e46579b0d
Parents: b7475f0
Author: isapego <is...@gridgain.com>
Authored: Wed Feb 10 15:00:42 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 15:00:42 2016 +0300
----------------------------------------------------------------------
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../cpp/core-test/project/vs/core-test.vcxproj | 1 +
.../project/vs/core-test.vcxproj.filters | 3 +
.../platforms/cpp/core-test/src/cache_test.cpp | 12 +++
.../cpp/core-test/src/interop_memory_test.cpp | 95 ++++++++++++++++++++
.../include/ignite/impl/ignite_environment.h | 19 ++--
.../cpp/core/src/impl/cache/cache_impl.cpp | 2 +-
.../cpp/core/src/impl/ignite_environment.cpp | 30 +++++--
8 files changed, 149 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am
index aa81c65..531fee0 100644
--- a/modules/platforms/cpp/core-test/Makefile.am
+++ b/modules/platforms/cpp/core-test/Makefile.am
@@ -29,6 +29,7 @@ ignite_tests_SOURCES = src/cache_test.cpp \
src/cache_query_test.cpp \
src/concurrent_test.cpp \
src/ignition_test.cpp \
+ src/interop_memory_test.cpp \
src/handle_registry_test.cpp \
src/binary_test_defs.cpp \
src/binary_reader_writer_raw_test.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index 422199a..d98d202 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -40,6 +40,7 @@
<ClCompile Include="..\..\src\binary_session_test.cpp" />
<ClCompile Include="..\..\src\binary_test_defs.cpp" />
<ClCompile Include="..\..\src\cache_query_test.cpp" />
+ <ClCompile Include="..\..\src\interop_memory_test.cpp" />
<ClCompile Include="..\..\src\teamcity_boost.cpp" />
<ClCompile Include="..\..\src\teamcity_messages.cpp" />
</ItemGroup>
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index 32737be..15b9c40 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -34,6 +34,9 @@
<ClCompile Include="..\..\src\binary_reader_writer_raw_test.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\interop_memory_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\teamcity_messages.h">
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index 32c5bd6..a11865d 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -476,4 +476,16 @@ BOOST_AUTO_TEST_CASE(TestGetOrCreateCache)
BOOST_REQUIRE(7 == cache2.Get(5));
}
+BOOST_AUTO_TEST_CASE(TestGetBigString)
+{
+ // Get existing cache
+ cache::Cache<int, std::string> cache = grid0.GetOrCreateCache<int, std::string>("partitioned");
+
+ std::string longStr(impl::IgniteEnvironment::DEFAULT_ALLOCATION_SIZE * 10, 'a');
+
+ cache.Put(5, longStr);
+
+ BOOST_REQUIRE(longStr == cache.Get(5));
+}
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core-test/src/interop_memory_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/interop_memory_test.cpp b/modules/platforms/cpp/core-test/src/interop_memory_test.cpp
new file mode 100644
index 0000000..07e928c
--- /dev/null
+++ b/modules/platforms/cpp/core-test/src/interop_memory_test.cpp
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+#ifndef _MSC_VER
+ #define BOOST_TEST_DYN_LINK
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include "ignite/ignite.h"
+#include "ignite/ignition.h"
+
+using namespace ignite;
+using namespace impl;
+using namespace boost::unit_test;
+
+BOOST_AUTO_TEST_SUITE(MemoryTestSuite)
+
+BOOST_AUTO_TEST_CASE(MemoryReallocationTest)
+{
+ using impl::interop::InteropMemory;
+ using common::concurrent::SharedPointer;
+
+ IgniteEnvironment env;
+
+ SharedPointer<InteropMemory> mem = env.AllocateMemory();
+
+ BOOST_CHECK_EQUAL(mem.Get()->Capacity(), IgniteEnvironment::DEFAULT_ALLOCATION_SIZE);
+
+ BOOST_CHECK(mem.Get()->Data() != NULL);
+
+ // Checking memory for write access.
+ int32_t capBeforeReallocation = mem.Get()->Capacity();
+
+ for (int32_t i = 0; i <capBeforeReallocation; ++i)
+ {
+ int8_t *data = mem.Get()->Data();
+
+ data[i] = static_cast<int8_t>(i);
+ }
+
+ mem.Get()->Reallocate(mem.Get()->Capacity() * 3);
+
+ BOOST_CHECK(mem.Get()->Capacity() >= IgniteEnvironment::DEFAULT_ALLOCATION_SIZE * 3);
+
+ // Checking memory data.
+ for (int32_t i = 0; i <capBeforeReallocation; ++i)
+ {
+ int8_t *data = mem.Get()->Data();
+
+ BOOST_REQUIRE_EQUAL(data[i], static_cast<int8_t>(i));
+ }
+
+ // Checking memory for write access.
+ capBeforeReallocation = mem.Get()->Capacity();
+
+ for (int32_t i = 0; i <capBeforeReallocation; ++i)
+ {
+ int8_t *data = mem.Get()->Data();
+
+ data[i] = static_cast<int8_t>(i + 42);
+ }
+
+ // Trying reallocate memory once more.
+ mem.Get()->Reallocate(mem.Get()->Capacity() * 3);
+
+ // Checking memory data.
+ for (int32_t i = 0; i <capBeforeReallocation; ++i)
+ {
+ int8_t *data = mem.Get()->Data();
+
+ BOOST_REQUIRE_EQUAL(data[i], static_cast<int8_t>(i + 42));
+ }
+
+ BOOST_CHECK(mem.Get()->Capacity() >= IgniteEnvironment::DEFAULT_ALLOCATION_SIZE * 9);
+
+ // Checking memory for write access.
+ memset(mem.Get()->Data(), 0xF0F0F0F0, mem.Get()->Capacity());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
index 2fbdb44..02facfc 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_environment.h
@@ -25,16 +25,21 @@
#include "binary/binary_type_manager.h"
namespace ignite
-{
+{
namespace impl
{
/**
* Defines environment in which Ignite operates.
*/
class IGNITE_IMPORT_EXPORT IgniteEnvironment
- {
+ {
public:
/**
+ * Default memory block allocation size.
+ */
+ enum { DEFAULT_ALLOCATION_SIZE = 1024 };
+
+ /**
* Default constructor.
*/
IgniteEnvironment();
@@ -51,7 +56,7 @@ namespace ignite
* @return JNI handlers.
*/
ignite::common::java::JniHandlers GetJniHandlers(ignite::common::concurrent::SharedPointer<IgniteEnvironment>* target);
-
+
/**
* Perform initialization on successful start.
*
@@ -64,8 +69,8 @@ namespace ignite
*
* @param memPtr Memory pointer.
*/
- void OnStartCallback(long long memPtr);
-
+ void OnStartCallback(long long memPtr);
+
/**
* Get name of Ignite instance.
*
@@ -120,11 +125,11 @@ namespace ignite
char* name;
/** Type manager. */
- binary::BinaryTypeManager* metaMgr;
+ binary::BinaryTypeManager* metaMgr;
IGNITE_NO_COPY_ASSIGNMENT(IgniteEnvironment);
};
- }
+ }
}
#endif
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
index 08526b5..f66a228 100644
--- a/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/cache/cache_impl.cpp
@@ -379,7 +379,7 @@ namespace ignite
if (outPtr)
{
- env.Get()->Context()->TargetInStreamOutStream(javaRef, opType, WriteTo(outMem.Get(), inOp, err),
+ env.Get()->Context()->TargetInStreamOutStream(javaRef, opType, outPtr,
inMem.Get()->PointerLong(), &jniErr);
IgniteError::SetError(jniErr.code, jniErr.errCls, jniErr.errMsg, err);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c3aa1375/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/ignite_environment.cpp b/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
index 013a139..c9c57a0 100644
--- a/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
+++ b/modules/platforms/cpp/core/src/impl/ignite_environment.cpp
@@ -53,7 +53,23 @@ namespace ignite
SharedPointer<IgniteEnvironment>* ptr = static_cast<SharedPointer<IgniteEnvironment>*>(target);
delete ptr;
- }
+ }
+
+ /**
+ * Memory reallocate callback.
+ *
+ * @param target Target environment.
+ * @param memPtr Memory pointer.
+ * @param cap Required capasity.
+ */
+ void IGNITE_CALL MemoryReallocate(void* target, long long memPtr, int cap)
+ {
+ SharedPointer<IgniteEnvironment>* env = static_cast<SharedPointer<IgniteEnvironment>*>(target);
+
+ SharedPointer<InteropMemory> mem = env->Get()->GetMemory(memPtr);
+
+ mem.Get()->Reallocate(cap);
+ }
IgniteEnvironment::IgniteEnvironment() : ctx(SharedPointer<JniContext>()), latch(new SingleLatch), name(NULL),
metaMgr(new BinaryTypeManager())
@@ -80,18 +96,20 @@ namespace ignite
hnds.onStart = OnStart;
hnds.onStop = OnStop;
+ hnds.memRealloc = MemoryReallocate;
+
hnds.error = NULL;
return hnds;
}
-
+
void IgniteEnvironment::Initialize(SharedPointer<JniContext> ctx)
{
this->ctx = ctx;
-
+
latch->CountDown();
}
-
+
const char* IgniteEnvironment::InstanceName() const
{
return name;
@@ -104,7 +122,7 @@ namespace ignite
SharedPointer<InteropMemory> IgniteEnvironment::AllocateMemory()
{
- SharedPointer<InteropMemory> ptr(new InteropUnpooledMemory(1024));
+ SharedPointer<InteropMemory> ptr(new InteropUnpooledMemory(DEFAULT_ALLOCATION_SIZE));
return ptr;
}
@@ -147,7 +165,7 @@ namespace ignite
InteropInputStream stream(&mem);
BinaryReaderImpl reader(&stream);
-
+
int32_t nameLen = reader.ReadString(NULL, 0);
if (nameLen >= 0)
[17/21] ignite git commit: Fixed devnotes.txt for yarn and mesos
modules.
Posted by sb...@apache.org.
Fixed devnotes.txt for yarn and mesos modules.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/14824a19
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/14824a19
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/14824a19
Branch: refs/heads/ignite-2542
Commit: 14824a19847091d5599f41eeaf52aa2694b7da87
Parents: 5539cba
Author: nikolay_tikhonov <nt...@gridgain.com>
Authored: Wed Feb 10 15:46:27 2016 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Wed Feb 10 15:46:27 2016 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/14824a19/DEVNOTES.txt
----------------------------------------------------------------------
diff --git a/DEVNOTES.txt b/DEVNOTES.txt
index 3e19243..e920b79 100644
--- a/DEVNOTES.txt
+++ b/DEVNOTES.txt
@@ -110,7 +110,7 @@ cd to ./modules/mesos
mvn clean package
-Look for ignite-mesos-<version>-jar-with-dependencies.jar in ./target directory.
+Look for ignite-mesos-<version>.jar in ./target directory.
Ignite Yarn Maven Build Instructions
============================================
@@ -118,7 +118,7 @@ cd to ./modules/yarn
mvn clean package
-Look for ignite-yarn-<version>-jar-with-dependencies.jar in ./target directory.
+Look for ignite-yarn-<version>.jar in ./target directory.
Run tests
==========
[07/21] ignite git commit: IGNITE-864 Disabled version check for
visorcmd
Posted by sb...@apache.org.
IGNITE-864 Disabled version check for visorcmd
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c67e2ea5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c67e2ea5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c67e2ea5
Branch: refs/heads/ignite-2542
Commit: c67e2ea5bfb7b73d76744d54047eb1b692e0907a
Parents: b7475f0
Author: Andrey <an...@gridgain.com>
Authored: Wed Feb 10 16:56:23 2016 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Wed Feb 10 16:56:23 2016 +0700
----------------------------------------------------------------------
.../src/main/scala/org/apache/ignite/visor/visor.scala | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c67e2ea5/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index a4eed69..335eb9f 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -17,6 +17,7 @@
package org.apache.ignite.visor
+import org.apache.ignite.IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER
import org.apache.ignite._
import org.apache.ignite.cluster.{ClusterGroup, ClusterGroupEmptyException, ClusterMetrics, ClusterNode}
import org.apache.ignite.events.EventType._
@@ -303,6 +304,9 @@ object visor extends VisorTag {
}
})
+ // Make sure visor starts without version checker print.
+ System.setProperty(IGNITE_UPDATE_NOTIFIER, "false")
+
addHelp(
name = "mlist",
shortInfo = "Prints Visor console memory variables.",