You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/02/10 12:55:48 UTC
[01/50] [abbrv] ignite git commit: 2224
Repository: ignite
Updated Branches:
refs/heads/ignite-1786 d55dc3690 -> 4c6e7fae6
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 93ff515..3bd87cf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -53,6 +53,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMemoryMode;
import org.apache.ignite.cache.CachePeekMode;
@@ -556,6 +557,30 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testGetEntry() throws Exception {
+ IgniteCache<String, Integer> cache = jcache();
+
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ CacheEntry<String, Integer> key1e = cache.getEntry("key1");
+ CacheEntry<String, Integer> key2e = cache.getEntry("key2");
+ CacheEntry<String, Integer> wrongKeye = cache.getEntry("wrongKey");
+
+ assert key1e.getValue() == 1;
+ assert key1e.getKey().equals("key1");
+ assert key1e.version() != null;
+
+ assert key2e.getValue() == 2;
+ assert key2e.getKey().equals("key2");
+ assert key2e.version() != null;
+
+ assert wrongKeye == null;
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAsync() throws Exception {
IgniteCache<String, Integer> cache = jcache();
@@ -664,6 +689,122 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
/**
* @throws Exception In case of error.
*/
+ public void testGetEntries() throws Exception {
+ Transaction tx = txShouldBeUsed() ? transactions().txStart() : null;
+
+ final IgniteCache<String, Integer> cache = jcache();
+
+ try {
+ cache.put("key1", 1);
+ cache.put("key2", 2);
+
+ if (tx != null)
+ tx.commit();
+ }
+ finally {
+ if (tx != null)
+ tx.close();
+ }
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ cache.getEntries(null).isEmpty();
+
+ return null;
+ }
+ }, NullPointerException.class, null);
+
+ assert cache.getEntries(Collections.<String>emptySet()).isEmpty();
+
+ Collection<CacheEntry<String, Integer>> c1 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+ info("Retrieved c1: " + c1);
+
+ assert 2 == c1.size() : "Invalid collection: " + c1;
+
+ boolean b1 = false;
+ boolean b2 = false;
+
+ for (CacheEntry<String, Integer> e: c1){
+ if (e.getKey().equals("key1") && e.getValue().equals(1))
+ b1 = true;
+
+ if (e.getKey().equals("key2") && e.getValue().equals(2))
+ b2 = true;
+ }
+
+ assertTrue(b1 && b2);
+
+ Collection<CacheEntry<String, Integer>> c2 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+ info("Retrieved c2: " + c2);
+
+ assert 2 == c2.size() : "Invalid collection: " + c2;
+
+ b1 = false;
+ b2 = false;
+
+ for (CacheEntry<String, Integer> e: c2){
+ if (e.getKey().equals("key1") && e.getValue().equals(1))
+ b1 = true;
+
+ if (e.getKey().equals("key2") && e.getValue().equals(2))
+ b2 = true;
+ }
+
+ assertTrue(b1 && b2);
+
+ // Now do the same checks but within transaction.
+ if (txShouldBeUsed()) {
+ try (Transaction tx0 = transactions().txStart()) {
+ assert cache.getEntries(Collections.<String>emptySet()).isEmpty();
+
+ c1 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+ info("Retrieved c1: " + c1);
+
+ assert 2 == c1.size() : "Invalid collection: " + c1;
+
+ b1 = false;
+ b2 = false;
+
+ for (CacheEntry<String, Integer> e : c1) {
+ if (e.getKey().equals("key1") && e.getValue().equals(1))
+ b1 = true;
+
+ if (e.getKey().equals("key2") && e.getValue().equals(2))
+ b2 = true;
+ }
+
+ assertTrue(b1 && b2);
+
+ c2 = cache.getEntries(ImmutableSet.of("key1", "key2", "key9999"));
+
+ info("Retrieved c2: " + c2);
+
+ assert 2 == c2.size() : "Invalid collection: " + c2;
+
+ b1 = false;
+ b2 = false;
+
+ for (CacheEntry<String, Integer> e : c2) {
+ if (e.getKey().equals("key1") && e.getValue().equals(1))
+ b1 = true;
+
+ if (e.getKey().equals("key2") && e.getValue().equals(2))
+ b2 = true;
+ }
+
+ assertTrue(b1 && b2);
+
+ tx0.commit();
+ }
+ }
+ }
+
+ /**
+ * @throws Exception In case of error.
+ */
public void testGetAllWithNulls() throws Exception {
final IgniteCache<String, Integer> cache = jcache();
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
index c57869f..f50a3e0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
@@ -29,6 +30,7 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheInterceptor;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.Affinity;
@@ -152,19 +154,32 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
* @throws Exception If failed.
*/
public void testGet() throws Exception {
- testGet(primaryKey(0));
+ testGet(primaryKey(0), false);
afterTest();
if (cacheMode() != LOCAL)
- testGet(backupKey(0));
+ testGet(backupKey(0), false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetEntry() throws Exception {
+ testGet(primaryKey(0), true);
+
+ afterTest();
+
+ if (cacheMode() != LOCAL)
+ testGet(backupKey(0), true);
}
/**
* @param key Key.
+ * @param needVer Need version.
* @throws Exception If failed.
*/
- private void testGet(String key) throws Exception {
+ private void testGet(String key, boolean needVer) throws Exception {
// Try when value is not in cache.
interceptor.retInterceptor = new NullGetInterceptor();
@@ -173,7 +188,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
IgniteCache<String, Integer> cache = jcache(0);
- assertEquals(null, cache.get(key));
+ assertEquals(null, needVer ? cache.getEntry(key) : cache.get(key));
assertEquals(1, interceptor.invokeCnt.get());
@@ -185,7 +200,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
log.info("Get 2.");
- assertEquals((Integer)1, cache.get(key));
+ assertEquals((Integer)1, needVer ? cache.getEntry(key).getValue() : cache.get(key));
assertEquals(1, interceptor.invokeCnt.get());
@@ -207,7 +222,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
log.info("Get 3.");
- assertEquals(null, cache.get(key));
+ assertEquals(null, needVer ? cache.getEntry(key) : cache.get(key));
assertEquals(1, interceptor.invokeCnt.get());
@@ -223,7 +238,7 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
log.info("Get 4.");
- assertEquals((Integer)101, cache.get(key));
+ assertEquals((Integer)101, needVer ? cache.getEntry(key).getValue() : cache.get(key));
assertEquals(1, interceptor.invokeCnt.get());
@@ -241,9 +256,16 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
- cacheAsync.get(key);
+ if (needVer) {
+ cacheAsync.getEntry(key);
- assertEquals((Integer)101, cacheAsync.<Integer>future().get());
+ assertEquals((Integer)101, cacheAsync.<CacheEntry<String, Integer>>future().get().getValue());
+ }
+ else {
+ cacheAsync.get(key);
+
+ assertEquals((Integer)101, cacheAsync.<Integer>future().get());
+ }
assertEquals(1, interceptor.invokeCnt.get());
@@ -258,6 +280,20 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
* @throws Exception If failed.
*/
public void testGetAll() throws Exception {
+ testGetAll(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetEntries() throws Exception {
+ testGetAll(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testGetAll(boolean needVer) throws Exception {
Set<String> keys = new LinkedHashSet<>();
for (int i = 0; i < 1000; i++)
@@ -269,10 +305,19 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
IgniteCache<String, Integer> cacheAsync = cache.withAsync();
- Map<String, Integer> map = cache.getAll(keys);
+ Collection<CacheEntry<String, Integer>> c;
+ Map<String, Integer> map;
+
+ if (needVer){
+ c = cache.getEntries(keys);
- for (String key : keys)
- assertEquals(null, map.get(key));
+ assertTrue(c.isEmpty());
+ }else {
+ map = cache.getAll(keys);
+
+ for (String key : keys)
+ assertEquals(null, map.get(key));
+ }
assertEquals(1000, interceptor.invokeCnt.get());
@@ -280,15 +325,28 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
interceptor.retInterceptor = new GetAllInterceptor1();
- map = cache.getAll(keys);
+ if (needVer) {
+ c = cache.getEntries(keys);
- for (String key : keys) {
- int k = Integer.valueOf(key);
+ assertEquals(500, c.size());
- if (k % 2 == 0)
- assertEquals(null, map.get(key));
- else
- assertEquals((Integer)(k * 2), map.get(key));
+ for (CacheEntry<String, Integer> e : c) {
+ int k = Integer.valueOf(e.getKey());
+
+ assertEquals((Integer)(k * 2), e.getValue());
+ }
+ }
+ else {
+ map = cache.getAll(keys);
+
+ for (String key : keys) {
+ int k = Integer.valueOf(key);
+
+ if (k % 2 == 0)
+ assertEquals(null, map.get(key));
+ else
+ assertEquals((Integer)(k * 2), map.get(key));
+ }
}
assertEquals(1000, interceptor.invokeCnt.get());
@@ -307,40 +365,72 @@ public abstract class GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
interceptor.retInterceptor = new GetAllInterceptor2();
- if (j == 0)
- map = cache.getAll(keys);
- else {
- cacheAsync.getAll(keys);
+ if (needVer) {
+ if (j == 0)
+ c = cache.getEntries(keys);
+ else {
+ cacheAsync.getEntries(keys);
+
+ c = cacheAsync.<Collection<CacheEntry<String, Integer>>>future().get();
+ }
+
+ for (CacheEntry<String, Integer> e : c) {
+ int k = Integer.valueOf(e.getKey());
+
+ switch (k % 3) {
+ case 1:
+ Integer exp = k < 500 ? k : null;
- map = cacheAsync.<Map<String, Integer>>future().get();
+ assertEquals(exp, e.getValue());
+
+ break;
+
+ case 2:
+ assertEquals((Integer)(k * 3), e.getValue());
+
+ break;
+
+ default:
+ fail();
+ }
+ }
}
+ else {
+ if (j == 0)
+ map = cache.getAll(keys);
+ else {
+ cacheAsync.getAll(keys);
- int i = 0;
+ map = cacheAsync.<Map<String, Integer>>future().get();
+ }
- for (String key : keys) {
- switch (i % 3) {
- case 0:
- assertEquals(null, map.get(key));
+ int i = 0;
- break;
+ for (String key : keys) {
+ switch (i % 3) {
+ case 0:
+ assertEquals(null, map.get(key));
- case 1:
- Integer exp = i < 500 ? i : null;
+ break;
- assertEquals(exp, map.get(key));
+ case 1:
+ Integer exp = i < 500 ? i : null;
- break;
+ assertEquals(exp, map.get(key));
- case 2:
- assertEquals((Integer)(i * 3), map.get(key));
+ break;
- break;
+ case 2:
+ assertEquals((Integer)(i * 3), map.get(key));
- default:
- fail();
- }
+ break;
- i++;
+ default:
+ fail();
+ }
+
+ i++;
+ }
}
assertEquals(1000, interceptor.invokeCnt.get());
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
index 6a7416e..293ba1e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
@@ -263,7 +263,7 @@ public class GridCacheDhtEvictionNearReadersSelfTest extends GridCommonAbstractT
waitForLocalEvent(grid(primary).events(), nodeEvent(primary.id()), EVT_CACHE_ENTRY_EVICTED);
// Get value on other node, it should be loaded to near cache.
- assertEquals(val, nearOther.get(key, true));
+ assertEquals(val, nearOther.get(key, true, false));
entryPrimary = (GridDhtCacheEntry)dhtPrimary.peekEx(key);
entryBackup = (GridDhtCacheEntry)dhtBackup.peekEx(key);
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
index 035f1b0..7286fb3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteCacheProcessProxy.java
@@ -34,6 +34,7 @@ import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
@@ -129,7 +130,7 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
- @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
+ @Override public void loadCache(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
throws CacheException {
throw new UnsupportedOperationException("Method should be supported.");
}
@@ -224,11 +225,21 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
}
/** {@inheritDoc} */
+ @Override public CacheEntry<K, V> getEntry(K key) {
+ return compute.call(new GetEntryTask<K, V>(cacheName, isAsync, key));
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAll(Set<? extends K> keys) {
return compute.call(new GetAllTask<K, V>(cacheName, isAsync, keys));
}
/** {@inheritDoc} */
+ @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
+ return compute.call(new GetEntriesTask<K, V>(cacheName, isAsync, keys));
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
return compute.call(new GetAllOutTxTask<K, V>(cacheName, isAsync, keys));
}
@@ -710,6 +721,29 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
*
*/
+ private static class GetEntryTask<K, V> extends CacheTaskAdapter<K, V, CacheEntry<K, V>> {
+ /** Key. */
+ private final K key;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param key Key.
+ */
+ public GetEntryTask(String cacheName, boolean async, K key) {
+ super(cacheName, async);
+ this.key = key;
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheEntry<K, V> call() throws Exception {
+ return cache().getEntry(key);
+ }
+ }
+
+ /**
+ *
+ */
private static class RemoveAllTask<K, V> extends CacheTaskAdapter<K, V, Void> {
/**
* @param cacheName Cache name.
@@ -973,6 +1007,29 @@ public class IgniteCacheProcessProxy<K, V> implements IgniteCache<K, V> {
/**
*
*/
+ private static class GetEntriesTask<K, V> extends CacheTaskAdapter<K, V, Collection<CacheEntry<K, V>> > {
+ /** Keys. */
+ private final Set<? extends K> keys;
+
+ /**
+ * @param cacheName Cache name.
+ * @param async Async.
+ * @param keys Keys.
+ */
+ public GetEntriesTask(String cacheName, boolean async, Set<? extends K> keys) {
+ super(cacheName, async);
+ this.keys = keys;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<CacheEntry<K, V>> call() throws Exception {
+ return cache().getEntries(keys);
+ }
+ }
+
+ /**
+ *
+ */
private static class GetAllOutTxTask<K, V> extends CacheTaskAdapter<K, V, Map<K, V>> {
/** Keys. */
private final Set<? extends K> keys;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 68e52df..45679dd 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -19,6 +19,12 @@ package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListenerSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryOptimisticSerializableSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticReadCommittedSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticRepeatableReadSeltTest;
+import org.apache.ignite.internal.processors.cache.CacheGetEntryPessimisticSerializableSeltTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheGetCustomCollectionsSelfTest;
import org.apache.ignite.internal.processors.GridCacheTxLoadFromStoreOnLockSelfTest;
import org.apache.ignite.internal.processors.cache.CacheClientStoreSelfTest;
@@ -241,6 +247,12 @@ public class IgniteCacheTestSuite4 extends TestSuite {
suite.addTestSuite(IgniteSystemCacheOnClientTest.class);
suite.addTestSuite(CacheRemoveAllSelfTest.class);
+ suite.addTestSuite(CacheGetEntryOptimisticReadCommittedSeltTest.class);
+ suite.addTestSuite(CacheGetEntryOptimisticRepeatableReadSeltTest.class);
+ suite.addTestSuite(CacheGetEntryOptimisticSerializableSeltTest.class);
+ suite.addTestSuite(CacheGetEntryPessimisticReadCommittedSeltTest.class);
+ suite.addTestSuite(CacheGetEntryPessimisticRepeatableReadSeltTest.class);
+ suite.addTestSuite(CacheGetEntryPessimisticSerializableSeltTest.class);
suite.addTestSuite(CacheStopAndDestroySelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/config/benchmark-multicast.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties
index c638d94..0428c73 100644
--- a/modules/yardstick/config/benchmark-multicast.properties
+++ b/modules/yardstick/config/benchmark-multicast.properties
@@ -89,10 +89,14 @@ j=10
CONFIGS="\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetEntryBenchmark -sn IgniteNode -ds ${ver}atomic-put-getEntry-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxImplicitBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-put-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-optim-repRead-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-optim-repRead-put-getEntry-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc PESSIMISTIC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-pessim-repRead-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc PESSIMISTIC -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-pessim-repRead-put-getEntry-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -txi SERIALIZABLE -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serial-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -txc OPTIMISTIC -txi SERIALIZABLE -dn IgnitePutGetEntryTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serial-put-getEntry-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
@@ -114,6 +118,9 @@ CONFIGS="\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-optimistic-getEntriesPutAll-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc PESSIMISTIC -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-pessimistic-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc PESSIMISTIC -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-pessimistic-getEntriesPutAll-1-backup,\
-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -txi SERIALIZABLE -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serializable-getAllPutAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -txi SERIALIZABLE -dn IgniteGetEntriesPutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-opt-serializable-getEntriesPutAll-1-backup,\
"
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
new file mode 100644
index 0000000..501e12d
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction;
+
+/**
+ * Ignite benchmark that performs transactional putAll operations.
+ */
+public class IgniteGetEntriesPutAllTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Integer> {
+ /** */
+ private IgniteTransactions txs;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ txs = ignite().transactions();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final ThreadRange r = threadRange();
+
+ doInTransaction(txs, args.txConcurrency(), args.txIsolation(), new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ SortedMap<Integer, Integer> vals = new TreeMap<>();
+
+ for (int i = 0; i < args.batch(); i++) {
+ int key = r.nextRandom();
+
+ vals.put(key, key);
+ }
+
+ cache.getEntries(vals.keySet());
+
+ cache.putAll(vals);
+
+ return null;
+ }
+ });
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Integer> cache() {
+ return ignite().cache("tx");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
new file mode 100644
index 0000000..1289fa1
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Ignite benchmark that performs put and get operations.
+ */
+public class IgnitePutGetEntryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ int key = nextRandom(args.range());
+
+ CacheEntry<Integer, Object> val = cache.getEntry(key);
+
+ if (val != null)
+ key = nextRandom(args.range());
+
+ cache.put(key, new SampleValue(key));
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("atomic");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
new file mode 100644
index 0000000..6e58b41
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction;
+
+/**
+ * Ignite benchmark that performs transactional put and get operations.
+ */
+public class IgnitePutGetEntryTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
+ /** */
+ private IgniteTransactions txs;
+
+ /** */
+ private Callable<Void> clo;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ txs = ignite().transactions();
+
+ clo = new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ int key = nextRandom(0, args.range() / 2);
+
+ CacheEntry<Integer, Object> val = cache.getEntry(key);
+
+ if (val != null)
+ key = nextRandom(args.range() / 2, args.range());
+
+ cache.put(key, new SampleValue(key));
+
+ return null;
+ }
+ };
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ doInTransaction(txs, args.txConcurrency(), args.txIsolation(), clo);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<Integer, Object> cache() {
+ return ignite().cache("tx");
+ }
+}
[38/50] [abbrv] ignite git commit: Improved CacheStore + external
class loader tests
Posted by vo...@apache.org.
Improved CacheStore + external class loader tests
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bf3a5ea6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bf3a5ea6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bf3a5ea6
Branch: refs/heads/ignite-1786
Commit: bf3a5ea652a9c36e5ce8dd87dba72b5fafc3ce86
Parents: bad0420
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Feb 8 13:41:38 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Feb 8 13:41:38 2016 +0300
----------------------------------------------------------------------
.../GridCacheReplicatedPreloadSelfTest.java | 120 +++++++++++++------
1 file changed, 82 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bf3a5ea6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 523f641..887fea4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -77,6 +77,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
private volatile boolean isClient = false;
/** */
+ private volatile boolean useExtClassLoader = false;
+
+ /** */
private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
/** {@inheritDoc} */
@@ -108,7 +111,8 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
cfg.setEventStorageSpi(spi);
- if (getTestGridName(1).equals(gridName) || cfg.getMarshaller() instanceof BinaryMarshaller)
+ if (getTestGridName(1).equals(gridName) || useExtClassLoader ||
+ cfg.getMarshaller() instanceof BinaryMarshaller)
cfg.setClassLoader(getExternalClassLoader());
if (isClient)
@@ -187,7 +191,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
for (int i = 0; i < 3; i++) {
evts = g2.events().localQuery(F.<Event>alwaysTrue(),
- EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED);
+ EVT_CACHE_REBALANCE_STARTED, EVT_CACHE_REBALANCE_STOPPED);
if (evts.size() != 2) {
info("Wrong events collection size (will retry in 1000 ms): " + evts.size());
@@ -284,7 +288,7 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
assert v3 != null;
assert v3.toString().equals(v1.toString());
assert !v3.getClass().getClassLoader().equals(getClass().getClassLoader());
- assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader")||
+ assert v3.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
grid(3).configuration().getMarshaller() instanceof BinaryMarshaller;
}
finally {
@@ -297,70 +301,110 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
*/
public void testStore() throws Exception {
try {
+ needStore = true;
+ useExtClassLoader = true;
+
Ignite g1 = startGrid(1);
- if (g1.configuration().getMarshaller() instanceof BinaryMarshaller) {
- stopAllGrids();
+ Ignite g2 = startGrid(2); // Checks deserialization at node join.
- needStore = true;
+ isClient = true;
- g1 = startGrid(1);
+ Ignite g3 = startGrid(3);
+
+ IgniteCache<Integer, Object> cache1 = g1.cache(null);
+ IgniteCache<Integer, Object> cache2 = g2.cache(null);
+ IgniteCache<Integer, Object> cache3 = g3.cache(null);
+
+ cache1.put(1, 1);
+
+ assertEquals(1, cache2.get(1));
+ assertEquals(1, cache3.get(1));
+ }
+ finally {
+ needStore = false;
+ isClient = false;
+ useExtClassLoader = false;
+ }
+ }
+
+ /**
+ * @throws Exception If test failed.
+ */
+ public void testStoreDynamicStart() throws Exception {
+ try {
+ needStore = false;
+ useExtClassLoader = true;
- ClassLoader ldr = grid(1).configuration().getClassLoader();
+ Ignite g1 = startGrid(1);
+ Ignite g2 = startGrid(2);
- CacheConfiguration cfg = defaultCacheConfiguration();
+ isClient = true;
- Ignite g2 = startGrid(2); // Checks deserialization at node join.
+ Ignite g3 = startGrid(3);
- isClient = true;
+ Object sf = getExternalClassLoader().loadClass(
+ "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
- Ignite g3 = startGrid(3);
+ CacheConfiguration cfg = defaultCacheConfiguration();
- isClient = false;
+ cfg.setCacheStoreFactory((Factory)sf);
+ cfg.setName("customStore");
- IgniteCache<Integer, Object> cache1 = g1.cache(null);
- IgniteCache<Integer, Object> cache2 = g2.cache(null);
- IgniteCache<Integer, Object> cache3 = g3.cache(null);
+ IgniteCache<Integer, Object> cache1 = g1.createCache(cfg);
- cache1.put(1, 1);
+ IgniteCache<Integer, Object> cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+ IgniteCache<Integer, Object> cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
- assertEquals(1, cache2.get(1));
- assertEquals(1, cache3.get(1));
+ cache1.put(1, 1);
- needStore = false;
+ assertEquals(1, cache2.get(1));
+ assertEquals(1, cache3.get(1));
+ }
+ finally {
+ needStore = false;
+ isClient = false;
+ useExtClassLoader = false;
+ }
+ }
- stopAllGrids();
+ /**
+ * @throws Exception If test failed.
+ */
+ public void testStoreDynamicStart2() throws Exception {
+ try {
+ needStore = false;
+ useExtClassLoader = true;
- g1 = startGrid(1);
- g2 = startGrid(2);
+ Ignite g1 = startGrid(1);
+ Ignite g2 = startGrid(2);
- isClient = true;
+ isClient = true;
- g3 = startGrid(3);
+ Ignite g3 = startGrid(3);
- isClient = false;
+ Object sf = getExternalClassLoader().loadClass(
+ "org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
- Object sf = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+ CacheConfiguration cfg = defaultCacheConfiguration();
- cfg.setCacheStoreFactory((Factory)sf);
- cfg.setName("customStore");
+ cfg.setCacheStoreFactory((Factory)sf);
+ cfg.setName("customStore");
- cache1 = g1.createCache(cfg);
+ IgniteCache<Integer, Object> cache1 = g1.getOrCreateCache(cfg);
- cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
- cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+ IgniteCache<Integer, Object> cache2 = g2.getOrCreateCache("customStore"); // Checks deserialization at cache creation.
+ IgniteCache<Integer, Object> cache3 = g3.getOrCreateCache("customStore"); // Checks deserialization at cache creation.
- cache1.put(1, 1);
+ cache1.put(1, 1);
- assertEquals(1, cache2.get(1));
- assertEquals(1, cache3.get(1));
- }
+ assertEquals(1, cache2.get(1));
+ assertEquals(1, cache3.get(1));
}
finally {
needStore = false;
isClient = false;
-
- stopAllGrids();
+ useExtClassLoader = false;
}
}
[50/50] [abbrv] ignite git commit: Merge branch 'master' into
ignite-1786
Posted by vo...@apache.org.
Merge branch 'master' into ignite-1786
# Conflicts:
# .gitignore
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4c6e7fae
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4c6e7fae
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4c6e7fae
Branch: refs/heads/ignite-1786
Commit: 4c6e7fae625689d8492e0dbbe4cfa779bf20f55f
Parents: d55dc36 b7475f0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Feb 10 12:51:51 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Feb 10 12:51:51 2016 +0300
----------------------------------------------------------------------
.gitignore | 5 +
.../examples/datagrid/CacheAffinityExample.java | 8 +-
.../java8/datagrid/CacheAffinityExample.java | 6 +-
modules/benchmarks/pom.xml | 32 +-
.../benchmarks/jmh/cache/PutBenchmark.java | 170 --
.../ignite/benchmarks/model/IntValue.java | 91 --
.../benchmarks/jmh/JmhAbstractBenchmark.java | 150 ++
.../jmh/cache/JmhCacheAbstractBenchmark.java | 184 +++
.../benchmarks/jmh/cache/JmhCacheBenchmark.java | 145 ++
.../jmh/runner/JmhIdeBenchmarkRunner.java | 236 +++
.../internal/benchmarks/model/IntValue.java | 91 ++
.../internal/client/ClientGetAffinityTask.java | 4 +-
.../java/org/apache/ignite/IgniteCache.java | 45 +-
.../java/org/apache/ignite/IgniteCluster.java | 7 +-
.../apache/ignite/IgniteSystemProperties.java | 12 +-
.../ignite/binary/BinaryBasicIdMapper.java | 167 ++
.../ignite/binary/BinaryBasicNameMapper.java | 141 ++
.../apache/ignite/binary/BinaryIdMapper.java | 19 +-
.../apache/ignite/binary/BinaryNameMapper.java | 47 +
.../ignite/binary/BinaryTypeConfiguration.java | 23 +-
.../org/apache/ignite/cache/CacheEntry.java | 9 +-
.../apache/ignite/cache/CacheInterceptor.java | 5 +
.../apache/ignite/cache/affinity/Affinity.java | 24 +-
.../configuration/BinaryConfiguration.java | 28 +
.../configuration/IgniteConfiguration.java | 8 +-
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../org/apache/ignite/internal/IgnitionEx.java | 7 +-
.../internal/binary/BinaryClassDescriptor.java | 51 +-
.../ignite/internal/binary/BinaryContext.java | 347 ++--
.../internal/binary/BinaryEnumObjectImpl.java | 13 +-
.../internal/binary/BinaryFieldAccessor.java | 45 +-
.../internal/binary/BinaryInternalIdMapper.java | 161 --
.../internal/binary/BinaryInternalMapper.java | 131 ++
.../internal/binary/BinaryMarshaller.java | 5 +-
.../binary/BinaryMetadataCollector.java | 22 +-
.../binary/BinaryObjectOffheapImpl.java | 34 +-
.../internal/binary/BinaryPrimitives.java | 117 +-
.../internal/binary/BinaryReaderExImpl.java | 22 +-
.../ignite/internal/binary/BinaryUtils.java | 48 +-
.../ignite/internal/binary/BinaryWriteMode.java | 3 +
.../internal/binary/BinaryWriterExImpl.java | 64 +-
.../internal/binary/GridBinaryMarshaller.java | 31 +-
.../binary/builder/BinaryBuilderSerializer.java | 16 +-
.../binary/builder/BinaryObjectBuilderImpl.java | 2 +-
.../streams/BinaryAbstractInputStream.java | 53 +-
.../streams/BinaryAbstractOutputStream.java | 90 +-
.../binary/streams/BinaryAbstractStream.java | 34 -
.../binary/streams/BinaryHeapInputStream.java | 43 +-
.../binary/streams/BinaryHeapOutputStream.java | 86 +-
.../streams/BinaryMemoryAllocatorChunk.java | 9 +-
.../streams/BinaryOffheapInputStream.java | 42 +-
.../streams/BinaryOffheapOutputStream.java | 94 +-
.../internal/direct/DirectMessageReader.java | 2 +-
.../internal/direct/DirectMessageWriter.java | 2 +-
.../stream/v1/DirectByteBufferStreamImplV1.java | 106 +-
.../stream/v2/DirectByteBufferStreamImplV2.java | 351 ++++-
.../ignite/internal/jdbc/JdbcConnection.java | 14 +-
.../affinity/GridAffinityAssignment.java | 36 +-
.../affinity/GridAffinityAssignmentCache.java | 2 +-
.../affinity/GridAffinityProcessor.java | 60 +-
.../processors/cache/CacheEntryImplEx.java | 14 +-
.../cache/CacheEvictableEntryImpl.java | 4 +-
.../processors/cache/CacheMetricsSnapshot.java | 4 +-
.../processors/cache/CacheOperationContext.java | 43 +-
.../processors/cache/GridCacheAdapter.java | 520 ++++--
.../cache/GridCacheAffinityManager.java | 77 +-
.../processors/cache/GridCacheContext.java | 33 +-
.../cache/GridCacheEvictionManager.java | 7 +-
.../processors/cache/GridCacheMapEntry.java | 12 +-
.../processors/cache/GridCacheMvccManager.java | 42 +-
.../cache/GridCacheOffheapSwapEntry.java | 24 +-
.../processors/cache/GridCachePreloader.java | 6 +
.../cache/GridCachePreloaderAdapter.java | 5 +
.../processors/cache/GridCacheProcessor.java | 43 +-
.../processors/cache/GridCacheProxyImpl.java | 62 +-
.../cache/GridCacheSwapEntryImpl.java | 61 +-
.../cache/GridCacheUpdateAtomicResult.java | 4 +-
.../processors/cache/GridCacheUtils.java | 57 +-
.../processors/cache/IgniteCacheProxy.java | 94 +-
.../processors/cache/IgniteInternalCache.java | 85 +
.../cache/affinity/GridCacheAffinityImpl.java | 48 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 127 +-
.../dht/CacheDistributedGetFutureAdapter.java | 15 -
.../dht/GridClientPartitionTopology.java | 5 +
.../distributed/dht/GridDhtCacheAdapter.java | 79 +-
.../distributed/dht/GridDhtEmbeddedFuture.java | 13 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 182 ++-
.../distributed/dht/GridDhtGetSingleFuture.java | 476 ++++++
.../distributed/dht/GridDhtLocalPartition.java | 76 +-
.../distributed/dht/GridDhtPartitionState.java | 2 +-
.../dht/GridDhtPartitionTopology.java | 5 +
.../dht/GridDhtPartitionTopologyImpl.java | 18 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 44 +-
.../dht/GridPartitionedGetFuture.java | 38 +-
.../dht/GridPartitionedSingleGetFuture.java | 17 +-
.../dht/atomic/GridDhtAtomicCache.java | 205 ++-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 2 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 10 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 22 +-
.../dht/colocated/GridDhtColocatedCache.java | 82 +-
.../dht/preloader/GridDhtPartitionDemander.java | 4 +-
.../dht/preloader/GridDhtPreloader.java | 16 +
.../distributed/near/GridNearAtomicCache.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 6 +-
.../distributed/near/GridNearCacheEntry.java | 3 +-
.../distributed/near/GridNearGetFuture.java | 45 +-
...arOptimisticSerializableTxPrepareFuture.java | 6 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 6 +-
.../GridNearPessimisticTxPrepareFuture.java | 4 +-
.../near/GridNearTransactionalCache.java | 9 +-
.../near/GridNearTxFinishFuture.java | 96 +-
.../cache/distributed/near/GridNearTxLocal.java | 67 +-
.../processors/cache/dr/GridCacheDrInfo.java | 49 +-
.../local/atomic/GridLocalAtomicCache.java | 106 +-
.../continuous/CacheContinuousQueryHandler.java | 9 +
.../cache/transactions/IgniteTxEntry.java | 32 +-
.../transactions/IgniteTxLocalAdapter.java | 277 +++-
.../cache/transactions/IgniteTxLocalEx.java | 3 +-
.../cache/transactions/IgniteTxManager.java | 4 +-
.../cache/version/GridCacheVersionManager.java | 23 +-
.../IgniteCacheObjectProcessorImpl.java | 9 +-
.../GridCacheAtomicReferenceImpl.java | 68 +-
.../internal/processors/igfs/IgfsProcessor.java | 14 +
.../processors/platform/PlatformIgnition.java | 6 +-
.../platform/PlatformNoopProcessor.java | 25 +
.../processors/platform/PlatformProcessor.java | 45 +
.../platform/PlatformProcessorImpl.java | 52 +-
.../platform/cache/PlatformCache.java | 16 +-
.../callback/PlatformCallbackUtils.java | 1 -
.../cpp/PlatformCppConfigurationClosure.java | 32 +
.../datastructures/PlatformAtomicReference.java | 141 ++
.../datastructures/PlatformAtomicSequence.java | 122 ++
.../dotnet/PlatformDotNetCacheStore.java | 39 +-
.../PlatformDotNetConfigurationClosure.java | 80 +-
.../platform/memory/PlatformAbstractMemory.java | 6 +-
.../PlatformBigEndianOutputStreamImpl.java | 14 +-
.../memory/PlatformInputStreamImpl.java | 53 +-
.../platform/memory/PlatformMemoryUtils.java | 108 +-
.../memory/PlatformOutputStreamImpl.java | 58 +-
.../utils/PlatformConfigurationUtils.java | 621 ++++++++
.../platform/utils/PlatformUtils.java | 52 +-
.../processors/service/ServiceContextImpl.java | 4 +-
.../processors/task/GridTaskProcessor.java | 2 +-
.../ignite/internal/util/GridHandleTable.java | 17 +-
.../ignite/internal/util/GridJavaProcess.java | 3 -
.../internal/util/GridSpinReadWriteLock.java | 10 +-
.../apache/ignite/internal/util/GridUnsafe.java | 1483 +++++++++++++++++-
.../ignite/internal/util/IgniteUtils.java | 106 +-
.../util/future/GridCompoundFuture.java | 2 +-
.../internal/util/io/GridUnsafeDataInput.java | 145 +-
.../internal/util/io/GridUnsafeDataOutput.java | 165 +-
.../ignite/internal/util/nio/GridNioServer.java | 171 +-
.../util/nio/GridSelectorNioSessionImpl.java | 2 +-
.../util/nio/SelectedSelectionKeySet.java | 132 ++
.../util/offheap/unsafe/GridUnsafeMap.java | 75 +-
.../util/offheap/unsafe/GridUnsafeMemory.java | 106 +-
.../org/apache/ignite/lang/IgniteBiTuple.java | 6 +-
.../optimized/OptimizedClassDescriptor.java | 59 +-
.../optimized/OptimizedMarshaller.java | 5 +-
.../optimized/OptimizedMarshallerUtils.java | 47 +-
.../optimized/OptimizedObjectInputStream.java | 25 +-
.../optimized/OptimizedObjectOutputStream.java | 4 +-
.../OptimizedObjectStreamRegistry.java | 4 +-
.../PlatformDotNetCacheStoreFactoryNative.java | 58 +
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 11 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 1 -
.../TcpDiscoveryMulticastIpFinder.java | 12 +-
.../TcpDiscoveryCustomEventMessage.java | 10 +-
.../java/org/apache/ignite/GridTestIoUtils.java | 117 +-
.../ignite/internal/GridAffinityMappedTest.java | 8 +-
.../internal/GridAffinityNoCacheSelfTest.java | 290 ++++
.../internal/GridAffinityP2PSelfTest.java | 8 +-
.../ignite/internal/GridAffinitySelfTest.java | 10 +-
.../binary/BinaryBasicIdMapperSelfTest.java | 51 +
.../binary/BinaryBasicNameMapperSelfTest.java | 50 +
.../BinaryConfigurationConsistencySelfTest.java | 231 +++
.../internal/binary/BinaryEnumsSelfTest.java | 12 +-
.../binary/BinaryFieldsOffheapSelfTest.java | 13 +-
.../BinaryFooterOffsetsOffheapSelfTest.java | 13 +-
.../binary/BinaryMarshallerSelfTest.java | 525 ++++++-
.../BinaryObjectBuilderAdditionalSelfTest.java | 4 +-
...naryObjectBuilderDefaultMappersSelfTest.java | 1149 ++++++++++++++
.../binary/BinaryObjectBuilderSelfTest.java | 1108 -------------
...ilderSimpleNameLowerCaseMappersSelfTest.java | 41 +
.../BinarySimpleNameTestPropertySelfTest.java | 94 ++
.../binary/GridBinaryMetaDataSelfTest.java | 371 -----
.../binary/GridBinaryWildcardsSelfTest.java | 338 +++-
...aultBinaryMappersBinaryMetaDataSelfTest.java | 389 +++++
...CaseBinaryMappersBinaryMetaDataSelfTest.java | 41 +
.../internal/binary/TestMappedObject.java | 25 +
.../mutabletest/GridBinaryTestClasses.java | 3 +-
...BuilderNonCompactDefaultMappersSelfTest.java | 30 +
.../BinaryObjectBuilderNonCompactSelfTest.java | 30 -
...mpactSimpleNameLowerCaseMappersSelfTest.java | 31 +
.../AbstractBinaryStreamByteOrderSelfTest.java | 464 ++++++
.../BinaryHeapStreamByteOrderSelfTest.java | 29 +
.../BinaryOffheapStreamByteOrderSelfTest.java | 31 +
...ByteBufferStreamImplV2ByteOrderSelfTest.java | 244 +++
.../cache/CacheGetEntryAbstractTest.java | 803 ++++++++++
...GetEntryOptimisticReadCommittedSeltTest.java | 36 +
...etEntryOptimisticRepeatableReadSeltTest.java | 36 +
...eGetEntryOptimisticSerializableSeltTest.java | 36 +
...etEntryPessimisticReadCommittedSeltTest.java | 36 +
...tEntryPessimisticRepeatableReadSeltTest.java | 36 +
...GetEntryPessimisticSerializableSeltTest.java | 36 +
.../cache/CacheReadThroughRestartSelfTest.java | 43 +-
.../CacheSerializableTransactionsTest.java | 142 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 145 +-
.../cache/GridCacheAffinityRoutingSelfTest.java | 10 +-
.../cache/GridCacheConcurrentMapSelfTest.java | 13 +-
.../GridCacheConcurrentTxMultiNodeTest.java | 4 +-
.../GridCacheConditionalDeploymentSelfTest.java | 4 +-
.../GridCacheDaemonNodeAbstractSelfTest.java | 17 +-
.../GridCacheDeploymentOffHeapSelfTest.java | 4 +-
...ridCacheDeploymentOffHeapValuesSelfTest.java | 41 +
.../cache/GridCacheDeploymentSelfTest.java | 8 +-
.../cache/GridCacheEntryMemorySizeSelfTest.java | 6 +-
.../GridCacheInterceptorAbstractSelfTest.java | 172 +-
.../GridCacheOffHeapValuesEvictionSelfTest.java | 171 ++
...hePartitionedProjectionAffinitySelfTest.java | 8 +-
.../cache/GridCachePutAllFailoverSelfTest.java | 4 +-
.../cache/GridCacheUtilsSelfTest.java | 136 +-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 17 +-
.../GridCacheBinaryStoreAbstractSelfTest.java | 10 +
...naryStoreBinariesDefaultMappersSelfTest.java | 81 +
.../GridCacheBinaryStoreBinariesSelfTest.java | 66 -
...yStoreBinariesSimpleNameMappersSelfTest.java | 40 +
.../IgniteTxPreloadAbstractTest.java | 2 +-
...GridCacheDhtEvictionNearReadersSelfTest.java | 2 +-
.../dht/GridCacheDhtMultiBackupTest.java | 4 +-
.../near/GridCacheNearOnlyTopologySelfTest.java | 4 +-
.../near/GridCacheNearReadersSelfTest.java | 19 +-
.../near/GridCacheNearTxMultiNodeSelfTest.java | 4 +-
...titionedExplicitLockNodeFailureSelfTest.java | 6 +-
.../GridCacheRebalancingSyncSelfTest.java | 8 +
.../GridCacheReplicatedPreloadSelfTest.java | 158 +-
.../RandomEvictionPolicyCacheSizeSelfTest.java | 79 -
.../random/RandomEvictionPolicySelfTest.java | 363 -----
...ContinuousQueryFailoverAbstractSelfTest.java | 6 +
...ridCacheContinuousQueryAbstractSelfTest.java | 10 +-
...ntinuousQueryPartitionAtomicOneNodeTest.java | 37 +
...heContinuousQueryPartitionTxOneNodeTest.java | 37 +
...tinuousQueryReplicatedAtomicOneNodeTest.java | 31 +
...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 --
...eContinuousQueryReplicatedTxOneNodeTest.java | 193 +++
.../igfs/IgfsProcessorValidationSelfTest.java | 27 +
.../processors/igfs/IgfsStreamsSelfTest.java | 4 +-
.../GridServicePackagePrivateSelfTest.java | 51 +
.../processors/service/inner/MyService.java | 30 +
.../service/inner/MyServiceFactory.java | 30 +
.../processors/service/inner/MyServiceImpl.java | 45 +
...dUnsafeDataInputOutputByteOrderSelfTest.java | 249 +++
.../ignite/lang/GridBasicPerformanceTest.java | 11 +-
.../apache/ignite/lang/GridTupleSelfTest.java | 42 +-
.../ignite/loadtests/dsi/GridDsiClient.java | 4 +-
...namicProxySerializationMultiJvmSelfTest.java | 131 ++
.../tcp/GridCacheDhtLockBackupSelfTest.java | 4 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 5 +-
.../config/GridTestProperties.java | 5 +-
.../testframework/junits/GridAbstractTest.java | 30 +-
.../multijvm/IgniteCacheProcessProxy.java | 59 +-
.../junits/multijvm/IgniteNodeRunner.java | 16 +-
.../junits/multijvm/IgniteProcessProxy.java | 19 +-
.../ignite/testsuites/IgniteBasicTestSuite.java | 5 +-
.../testsuites/IgniteBinaryBasicTestSuite.java | 97 ++
...ctsSimpleNameMapperComputeGridTestSuite.java | 38 +
.../IgniteBinaryObjectsTestSuite.java | 40 +-
...iteBinarySimpleNameMapperBasicTestSuite.java | 38 +
...rySimpleNameMapperCacheFullApiTestSuite.java | 39 +
.../IgniteCacheEvictionSelfTestSuite.java | 4 -
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../testsuites/IgniteCacheTestSuite3.java | 2 +
.../testsuites/IgniteCacheTestSuite4.java | 12 +
.../testsuites/IgniteComputeGridTestSuite.java | 4 +-
.../testsuites/IgniteKernalSelfTestSuite.java | 4 +-
.../IgniteMarshallerSelfTestSuite.java | 4 +
modules/docker/1.5.0.final/Dockerfile | 40 +
modules/docker/1.5.0.final/run.sh | 50 +
modules/docker/Dockerfile | 6 +-
.../tests/p2p/CacheDeploymentTestEnumValue.java | 47 +
.../p2p/CacheDeploymentTestStoreFactory.java | 113 ++
.../hadoop/shuffle/HadoopShuffleJob.java | 5 +-
.../hadoop/shuffle/HadoopShuffleMessage.java | 10 +-
.../shuffle/streams/HadoopDataOutStream.java | 6 +-
.../HadoopConcurrentHashMultimapSelftest.java | 6 +-
.../collections/HadoopSkipListSelfTest.java | 5 +-
.../query/h2/opt/GridH2IndexBase.java | 5 +-
.../query/h2/opt/GridH2TreeIndex.java | 2 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 10 +-
.../IgniteBinaryCacheQueryTestSuite.java | 186 +--
...narySimpleNameMapperCacheQueryTestSuite.java | 38 +
.../IgniteCacheQuerySelfTestSuite.java | 10 +-
modules/kafka/README.txt | 111 +-
modules/kafka/pom.xml | 69 +-
.../ignite/stream/kafka/KafkaStreamer.java | 2 +-
.../kafka/connect/IgniteSinkConnector.java | 91 ++
.../kafka/connect/IgniteSinkConstants.java | 38 +
.../stream/kafka/connect/IgniteSinkTask.java | 165 ++
.../kafka/IgniteKafkaStreamerSelfTestSuite.java | 9 +-
.../stream/kafka/KafkaEmbeddedBroker.java | 387 -----
.../kafka/KafkaIgniteStreamerSelfTest.java | 13 +-
.../ignite/stream/kafka/SimplePartitioner.java | 53 -
.../ignite/stream/kafka/TestKafkaBroker.java | 237 +++
.../kafka/connect/IgniteSinkConnectorTest.java | 250 +++
.../kafka/src/test/resources/example-ignite.xml | 71 +
.../osgi-karaf/src/main/resources/features.xml | 12 +-
.../cpp/common/include/ignite/common/exports.h | 18 +
.../cpp/common/include/ignite/common/java.h | 41 +
.../platforms/cpp/common/project/vs/module.def | 18 +-
modules/platforms/cpp/common/src/exports.cpp | 64 +
modules/platforms/cpp/common/src/java.cpp | 225 +++
.../Apache.Ignite.Benchmarks.csproj | 4 +-
.../Apache.Ignite.Core.Tests.TestDll.csproj | 4 +-
.../Apache.Ignite.Core.Tests.csproj | 11 +-
.../Binary/BinarySelfTest.cs | 41 +
.../Cache/CacheAbstractTest.cs | 2 +-
.../Cache/CacheAffinityTest.cs | 2 +-
.../Cache/CacheConfigurationTest.cs | 538 +++++++
.../Cache/CacheDynamicStartTest.cs | 4 +-
.../Cache/CacheTestAsyncWrapper.cs | 7 +
.../Query/CacheQueriesCodeConfigurationTest.cs | 295 ++++
.../Cache/Query/CacheQueriesTest.cs | 2 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 2 +-
.../Cache/Store/CacheStoreSessionTest.cs | 2 +-
.../Cache/Store/CacheStoreTest.cs | 23 +-
.../Config/Compute/compute-grid2.xml | 21 +
.../Config/Compute/compute-grid3.xml | 31 +-
.../DataStructures/AtomicReferenceTest.cs | 239 +++
.../DataStructures/AtomicSequenceTest.cs | 131 ++
.../Dataload/DataStreamerTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 2 +-
.../Apache.Ignite.Core.Tests/FutureTest.cs | 1 +
.../IgniteConfigurationSectionTest.cs | 69 +
.../IgniteConfigurationSerializerTest.cs | 554 +++++++
.../IgniteConfigurationTest.cs | 367 +++++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 4 +-
.../SerializationTest.cs | 2 +-
.../Apache.Ignite.Core.Tests/TestRunner.cs | 5 +-
.../dotnet/Apache.Ignite.Core.Tests/app.config | 54 +
.../Apache.Ignite.Core.csproj | 52 +-
.../Apache.Ignite.Core.ruleset | 26 +
.../Binary/BinaryConfiguration.cs | 30 +-
.../Binary/BinaryTypeConfiguration.cs | 5 +
.../Binary/BinaryTypeNames.cs | 64 +-
.../Binary/IBinarySerializer.cs | 6 +-
.../Cache/CachePartialUpdateException.cs | 2 +
.../Apache.Ignite.Core/Cache/CacheResult.cs | 41 +-
.../Configuration/CacheAtomicWriteOrderMode.cs | 43 +
.../Cache/Configuration/CacheAtomicityMode.cs | 54 +
.../Cache/Configuration/CacheConfiguration.cs | 601 +++++++
.../Cache/Configuration/CacheMemoryMode.cs | 60 +
.../Cache/Configuration/CacheMode.cs | 52 +
.../Cache/Configuration/CacheRebalanceMode.cs | 51 +
.../CacheWriteSynchronizationMode.cs | 45 +
.../Cache/Configuration/QueryAlias.cs | 59 +
.../Cache/Configuration/QueryEntity.cs | 401 +++++
.../Cache/Configuration/QueryField.cs | 109 ++
.../Cache/Configuration/QueryIndex.cs | 137 ++
.../Cache/Configuration/QueryIndexField.cs | 66 +
.../Cache/Configuration/QueryIndexType.cs | 40 +
.../Configuration/QuerySqlFieldAttribute.cs | 60 +
.../Configuration/QueryTextFieldAttribute.cs | 36 +
.../Cache/Event/ICacheEntryEventFilter.cs | 1 +
.../Cache/Event/ICacheEntryEventListener.cs | 1 +
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 6 +
.../Cache/Query/Continuous/ContinuousQuery.cs | 2 +-
.../Apache.Ignite.Core/Cache/Query/QueryBase.cs | 2 +-
.../Cache/Query/SqlFieldsQuery.cs | 2 +-
.../Apache.Ignite.Core/Cache/Query/SqlQuery.cs | 6 +-
.../Apache.Ignite.Core/Cache/Query/TextQuery.cs | 7 +-
.../Cache/Store/CacheStoreAdapter.cs | 3 +
.../Apache.Ignite.Core/Common/IFactory.cs | 34 +
.../Compute/ComputeJobAdapter.cs | 2 +-
.../Compute/ComputeJobResultPolicy.cs | 2 -
.../Compute/ComputeTaskAdapter.cs | 2 +
.../Compute/ComputeTaskSplitAdapter.cs | 17 +-
.../DataStructures/IAtomicReference.cs | 64 +
.../DataStructures/IAtomicSequence.cs | 69 +
.../Datastream/StreamTransformer.cs | 2 +
.../Datastream/StreamVisitor.cs | 2 +
.../Discovery/IDiscoverySpi.cs | 32 +
.../Discovery/Tcp/ITcpDiscoveryIpFinder.cs | 34 +
.../Multicast/TcpDiscoveryMulticastIpFinder.cs | 135 ++
.../Tcp/Static/TcpDiscoveryStaticIpFinder.cs | 86 +
.../Discovery/Tcp/TcpDiscoveryIpFinderBase.cs | 78 +
.../Discovery/Tcp/TcpDiscoverySpi.cs | 144 ++
.../Apache.Ignite.Core/Events/CacheEvent.cs | 8 +-
.../Events/CacheQueryExecutedEvent.cs | 4 +-
.../Events/CacheQueryReadEvent.cs | 6 +-
.../Events/CacheRebalancingEvent.cs | 4 +-
.../Events/CheckpointEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/DiscoveryEvent.cs | 4 +-
.../Apache.Ignite.Core/Events/EventBase.cs | 69 +-
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 57 +-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 347 +++-
.../IgniteConfigurationSection.cs | 80 +
.../IgniteConfigurationSection.xsd | 281 ++++
.../dotnet/Apache.Ignite.Core/Ignition.cs | 69 +-
.../Apache.Ignite.Core/Impl/Binary/Binary.cs | 50 +-
.../Impl/Binary/BinaryFullTypeDescriptor.cs | 2 +-
.../Impl/Binary/BinaryObject.cs | 44 +-
.../Impl/Binary/BinaryObjectBuilder.cs | 75 +-
.../Impl/Binary/BinaryReader.cs | 1 +
.../Impl/Binary/BinaryReaderExtensions.cs | 19 +
.../Impl/Binary/BinaryReflectiveSerializer.cs | 2 +-
.../Impl/Binary/BinarySystemHandlers.cs | 9 +-
.../Impl/Binary/BinaryUtils.cs | 173 +-
.../Impl/Binary/BinaryWriter.cs | 3 +
.../Impl/Binary/Io/BinaryHeapStream.cs | 9 +
.../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs | 92 ++
.../Impl/Binary/Marshaller.cs | 27 +-
.../Impl/Binary/Metadata/BinaryType.cs | 2 +
.../Impl/Binary/SerializableObjectHolder.cs | 13 +-
.../Impl/Binary/Structure/BinaryStructure.cs | 3 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 51 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 3 +-
.../Impl/Cache/Query/AbstractQueryCursor.cs | 4 +-
.../Continuous/ContinuousQueryFilterHolder.cs | 2 +-
.../Continuous/ContinuousQueryHandleImpl.cs | 4 +-
.../Impl/Cache/Query/FieldsQueryCursor.cs | 2 +
.../Impl/Cache/Query/QueryCursor.cs | 2 +
.../Impl/Cache/Store/CacheStore.cs | 20 +-
.../Impl/Common/BooleanLowerCaseConverter.cs | 60 +
.../Impl/Common/CancelledTask.cs | 3 +
.../Common/CopyOnWriteConcurrentDictionary.cs | 1 +
.../Impl/Common/DelegateConverter.cs | 11 +-
.../Apache.Ignite.Core/Impl/Common/Future.cs | 16 +-
.../Impl/Common/FutureType.cs | 18 +-
.../Common/IgniteConfigurationXmlSerializer.cs | 410 +++++
.../Impl/Common/LoadedAssembliesResolver.cs | 1 +
.../Impl/Common/TypeStringConverter.cs | 115 ++
.../Closure/ComputeAbstractClosureTask.cs | 2 +
.../Compute/Closure/ComputeMultiClosureTask.cs | 2 +
.../Closure/ComputeReducingClosureTask.cs | 2 +
.../Compute/Closure/ComputeSingleClosureTask.cs | 2 +
.../Impl/DataStructures/AtomicReference.cs | 92 ++
.../Impl/DataStructures/AtomicSequence.cs | 90 ++
.../Impl/Datastream/DataStreamerBatch.cs | 1 +
.../Impl/Datastream/DataStreamerImpl.cs | 5 +-
.../Impl/Events/EventTypeConverter.cs | 133 ++
.../Apache.Ignite.Core/Impl/ExceptionUtils.cs | 56 +-
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 8 +-
.../Impl/Handle/HandleRegistry.cs | 1 +
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 98 ++
.../Impl/IgniteConfigurationEx.cs | 57 -
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 5 +-
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 30 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 13 +-
.../Impl/InteropExceptionHolder.cs | 11 +-
.../Memory/PlatformBigEndianMemoryStream.cs | 8 +
.../Impl/Memory/PlatformMemory.cs | 2 +
.../Impl/Memory/PlatformMemoryManager.cs | 2 +
.../Impl/Memory/PlatformMemoryStream.cs | 322 +++-
.../Impl/Memory/PlatformRawMemory.cs | 4 +-
.../Apache.Ignite.Core/Impl/PlatformTarget.cs | 3 +-
.../Impl/Resource/ResourceProcessor.cs | 2 +-
.../Impl/Resource/ResourceTypeDescriptor.cs | 2 +-
.../Impl/Services/ServiceProxy.cs | 2 +
.../Impl/Services/ServiceProxyInvoker.cs | 1 +
.../Impl/Transactions/TransactionsImpl.cs | 4 +-
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 48 +-
.../Impl/Unmanaged/UnmanagedCallbacks.cs | 5 +-
.../Impl/Unmanaged/UnmanagedUtils.cs | 101 +-
.../Services/ServiceInvocationException.cs | 2 +
modules/platforms/dotnet/Apache.Ignite.FxCop | 354 +----
modules/platforms/dotnet/Apache.Ignite.sln | 4 +-
.../Apache.Ignite.sln.TeamCity.DotSettings | 30 +
.../dotnet/Apache.Ignite/Apache.Ignite.csproj | 5 +-
.../Apache.Ignite.Examples.csproj | 4 +-
.../Apache.Ignite.ExamplesDll.csproj | 4 +-
.../org/apache/ignite/spark/IgniteContext.scala | 11 +-
.../ignite/internal/GridFactorySelfTest.java | 2 +-
.../visor/commands/node/VisorNodeCommand.scala | 1 +
.../commands/top/VisorTopologyCommand.scala | 5 +-
.../scala/org/apache/ignite/visor/visor.scala | 3 +-
modules/yardstick/.gitignore | 2 +
.../config/benchmark-multicast.properties | 7 +
.../org/apache/ignite/yardstick/IgniteNode.java | 3 +
.../IgniteGetEntriesPutAllTxBenchmark.java | 73 +
.../cache/IgnitePutGetEntryBenchmark.java | 47 +
.../cache/IgnitePutGetEntryTxBenchmark.java | 73 +
.../apache/ignite/yarn/ApplicationMaster.java | 12 +-
.../apache/ignite/yarn/ClusterProperties.java | 144 +-
.../yarn/IgniteApplicationMasterSelfTest.java | 52 +
parent/pom.xml | 217 ++-
pom.xml | 16 -
487 files changed, 26403 insertions(+), 7084 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c6e7fae/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
[17/50] [abbrv] ignite git commit: IGNITE-2454 Fixed "Continuous
query notification missed if there is only one node".
Posted by vo...@apache.org.
IGNITE-2454 Fixed "Continuous query notification missed if there is only one node".
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/60c8b072
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/60c8b072
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/60c8b072
Branch: refs/heads/ignite-1786
Commit: 60c8b072dc08d92e45da2404be09031af165ae48
Parents: e6acce6
Author: Tikhonov Nikolay <ti...@gmail.com>
Authored: Wed Feb 3 13:06:14 2016 +0300
Committer: Tikhonov Nikolay <ti...@gmail.com>
Committed: Wed Feb 3 13:06:14 2016 +0300
----------------------------------------------------------------------
.../continuous/CacheContinuousQueryHandler.java | 9 +
...ntinuousQueryPartitionAtomicOneNodeTest.java | 37 ++++
...heContinuousQueryPartitionTxOneNodeTest.java | 37 ++++
...tinuousQueryReplicatedAtomicOneNodeTest.java | 31 +++
...ontinuousQueryReplicatedOneNodeSelfTest.java | 120 ------------
...eContinuousQueryReplicatedTxOneNodeTest.java | 193 +++++++++++++++++++
.../IgniteCacheQuerySelfTestSuite.java | 10 +-
7 files changed, 315 insertions(+), 122 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/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 fa54a6b..7e66ad3 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
@@ -754,6 +754,15 @@ public class CacheContinuousQueryHandler<K, V> implements GridContinuousHandler
List<CacheContinuousQueryEntry> entries;
synchronized (pendingEvts) {
+ // Received first event.
+ if (curTop == AffinityTopologyVersion.NONE) {
+ lastFiredEvt = entry.updateCounter();
+
+ curTop = entry.topologyVersion();
+
+ return F.asList(entry);
+ }
+
if (curTop.compareTo(entry.topologyVersion()) < 0) {
if (entry.updateCounter() == 1L && !entry.isBackup()) {
entries = new ArrayList<>(pendingEvts.size());
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java
new file mode 100644
index 0000000..797882b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionAtomicOneNodeTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryPartitionAtomicOneNodeTest
+ extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.PARTITIONED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java
new file mode 100644
index 0000000..7dd7bd7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryPartitionTxOneNodeTest.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryPartitionTxOneNodeTest
+ extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicMode() {
+ return CacheAtomicityMode.TRANSACTIONAL;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected CacheMode cacheMode() {
+ return CacheMode.PARTITIONED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java
new file mode 100644
index 0000000..066afa9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedAtomicOneNodeTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.query.continuous;
+
+import org.apache.ignite.cache.CacheAtomicityMode;
+
+/**
+ *
+ */
+public class GridCacheContinuousQueryReplicatedAtomicOneNodeTest
+ extends GridCacheContinuousQueryReplicatedTxOneNodeTest {
+ /** {@inheritDoc} */
+ @Override protected CacheAtomicityMode atomicMode() {
+ return CacheAtomicityMode.ATOMIC;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
deleted file mode 100644
index 8152b2a..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedOneNodeSelfTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.query.continuous;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.cache.event.CacheEntryEvent;
-import javax.cache.event.CacheEntryListenerException;
-import javax.cache.event.CacheEntryUpdatedListener;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.query.ContinuousQuery;
-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;
-
-/**
- * Test for replicated cache with one node.
- */
-public class GridCacheContinuousQueryReplicatedOneNodeSelfTest extends GridCommonAbstractTest {
- /** IP finder. */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration cacheCfg = defaultCacheConfiguration();
-
- cacheCfg.setCacheMode(CacheMode.REPLICATED);
- cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
- cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
-
- cfg.setCacheConfiguration(cacheCfg);
-
- TcpDiscoverySpi disco = new TcpDiscoverySpi();
-
- disco.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(disco);
-
- return cfg;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLocal() throws Exception {
- doTest(true);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDistributed() throws Exception {
- doTest(false);
- }
-
- /**
- * @throws Exception If failed.
- */
- private void doTest(boolean loc) throws Exception {
- try {
- IgniteCache<String, Integer> cache = startGrid(0).cache(null);
-
- ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
-
- final AtomicInteger cnt = new AtomicInteger();
- final CountDownLatch latch = new CountDownLatch(10);
-
- qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
- @Override
- public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
- throws CacheEntryListenerException {
- for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
- cnt.incrementAndGet();
- latch.countDown();
- }
- }
- });
-
- cache.query(qry.setLocal(loc));
-
- startGrid(1);
-
- awaitPartitionMapExchange();
-
- for (int i = 0; i < 10; i++)
- cache.put("key" + i, i);
-
- assert latch.await(5000, TimeUnit.MILLISECONDS);
-
- assertEquals(10, cnt.get());
- }
- finally {
- stopAllGrids();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
new file mode 100644
index 0000000..271a8d9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/continuous/GridCacheContinuousQueryReplicatedTxOneNodeTest.java
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.cache.event.CacheEntryEvent;
+import javax.cache.event.CacheEntryListenerException;
+import javax.cache.event.CacheEntryUpdatedListener;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.query.ContinuousQuery;
+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;
+
+/**
+ * Test for replicated cache with one node.
+ */
+@SuppressWarnings("Duplicates")
+public class GridCacheContinuousQueryReplicatedTxOneNodeTest extends GridCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+ cacheCfg.setAtomicityMode(atomicMode());
+ cacheCfg.setCacheMode(cacheMode());
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+ cfg.setCacheConfiguration(cacheCfg);
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ disco.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(disco);
+
+ return cfg;
+ }
+
+ /**
+ * @return Atomicity mode for a cache.
+ */
+ protected CacheAtomicityMode atomicMode() {
+ return CacheAtomicityMode.TRANSACTIONAL;
+ }
+
+ /**
+ * @return Cache mode.
+ */
+ protected CacheMode cacheMode() {
+ return CacheMode.REPLICATED;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocal() throws Exception {
+ if (cacheMode() == CacheMode.REPLICATED)
+ doTest(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDistributed() throws Exception {
+ doTest(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalOneNode() throws Exception {
+ doTestOneNode(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDistributedOneNode() throws Exception {
+ doTestOneNode(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTest(boolean loc) throws Exception {
+ try {
+ IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+ ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+ final AtomicInteger cnt = new AtomicInteger();
+ final CountDownLatch latch = new CountDownLatch(10);
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+ @Override
+ public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
+ throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
+ cnt.incrementAndGet();
+ latch.countDown();
+ }
+ }
+ });
+
+ cache.query(qry.setLocal(loc));
+
+ startGrid(1);
+
+ awaitPartitionMapExchange();
+
+ for (int i = 0; i < 10; i++)
+ cache.put("key" + i, i);
+
+ assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+ assertEquals(10, cnt.get());
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTestOneNode(boolean loc) throws Exception {
+ try {
+ IgniteCache<String, Integer> cache = startGrid(0).cache(null);
+
+ ContinuousQuery<String, Integer> qry = new ContinuousQuery<>();
+
+ final AtomicInteger cnt = new AtomicInteger();
+ final CountDownLatch latch = new CountDownLatch(10);
+
+ for (int i = 0; i < 10; i++)
+ cache.put("key" + i, i);
+
+ cache.clear();
+
+ qry.setLocalListener(new CacheEntryUpdatedListener<String, Integer>() {
+ @Override public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends Integer>> evts)
+ throws CacheEntryListenerException {
+ for (CacheEntryEvent<? extends String, ? extends Integer> evt : evts) {
+ cnt.incrementAndGet();
+ latch.countDown();
+ }
+ }
+ });
+
+ cache.query(qry.setLocal(loc));
+
+ for (int i = 0; i < 10; i++)
+ cache.put("key" + i, i);
+
+ assert latch.await(5000, TimeUnit.MILLISECONDS);
+
+ assertEquals(10, cnt.get());
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/60c8b072/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 4b1eafa..359cdf3 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
@@ -79,11 +79,14 @@ import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheCon
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionAtomicOneNodeTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionTxOneNodeTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedOnlySelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedP2PDisabledSelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryPartitionedSelfTest;
+import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicOneNodeTest;
import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedOneNodeSelfTest;
+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.GridCacheContinuousQueryTxSelfTest;
@@ -181,7 +184,10 @@ public class IgniteCacheQuerySelfTestSuite extends TestSuite {
suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryReplicatedOneNodeSelfTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryReplicatedTxOneNodeTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicOneNodeTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryPartitionTxOneNodeTest.class);
+ suite.addTestSuite(GridCacheContinuousQueryPartitionAtomicOneNodeTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class);
suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class);
[19/50] [abbrv] ignite git commit: IGNITE-2465 - Fixed race in load
cache closure - Fixes #431.
Posted by vo...@apache.org.
IGNITE-2465 - Fixed race in load cache closure - Fixes #431.
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/500bd3ab
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/500bd3ab
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/500bd3ab
Branch: refs/heads/ignite-1786
Commit: 500bd3ab576830f8160eb66274590b7684a39599
Parents: e7de923
Author: ashutak <as...@gridgain.com>
Authored: Wed Feb 3 14:56:42 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Wed Feb 3 14:56:42 2016 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAdapter.java | 100 ++++++++++++++++++-
1 file changed, 96 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/500bd3ab/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 69abc54..2c3a197 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -70,6 +70,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.FileSystemConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
+import org.apache.ignite.internal.ComputeTaskInternalFuture;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.IgniteKernal;
@@ -101,6 +102,7 @@ import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanMap;
+import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -128,6 +130,7 @@ import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgniteOutClosure;
+import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.mxbean.CacheMetricsMXBean;
@@ -166,6 +169,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/** Maximum number of retries when topology changes. */
public static final int MAX_RETRIES = IgniteSystemProperties.getInteger(IGNITE_CACHE_RETRIES_COUNT, 100);
+ /** */
+ public static final IgniteProductVersion LOAD_CACHE_JOB_SINCE = IgniteProductVersion.fromString("1.5.7");
+
/** Deserialization stash. */
private static final ThreadLocal<IgniteBiTuple<String, String>> stash = new ThreadLocal<IgniteBiTuple<String,
String>>() {
@@ -3737,7 +3743,19 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
*/
IgniteInternalFuture<?> globalLoadCacheAsync(@Nullable IgniteBiPredicate<K, V> p, @Nullable Object... args)
throws IgniteCheckedException {
- ClusterGroup nodes = ctx.kernalContext().grid().cluster().forCacheNodes(ctx.name());
+ ClusterGroup oldNodes = ctx.kernalContext().grid().cluster().forCacheNodes(ctx.name())
+ .forPredicate(new IgnitePredicate<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ return node.version().compareToIgnoreTimestamp(LOAD_CACHE_JOB_SINCE) < 0;
+ }
+ });
+
+ ClusterGroup newNodes = ctx.kernalContext().grid().cluster().forCacheNodes(ctx.name())
+ .forPredicate(new IgnitePredicate<ClusterNode>() {
+ @Override public boolean apply(ClusterNode node) {
+ return node.version().compareToIgnoreTimestamp(LOAD_CACHE_JOB_SINCE) >= 0;
+ }
+ });
ctx.kernalContext().task().setThreadContext(TC_NO_FAILOVER, true);
@@ -3745,9 +3763,27 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ExpiryPolicy plc = opCtx != null ? opCtx.expiry() : null;
- return ctx.kernalContext().closure().callAsync(BROADCAST,
- Arrays.asList(new LoadCacheClosure<>(ctx.name(), p, args, plc)),
- nodes.nodes());
+ GridCompoundFuture<Object, ?> fut = new GridCompoundFuture<>();
+
+ if (!F.isEmpty(oldNodes.nodes())) {
+ ComputeTaskInternalFuture oldNodesFut = ctx.kernalContext().closure().callAsync(BROADCAST,
+ Arrays.asList(new LoadCacheClosure<>(ctx.name(), p, args, plc)),
+ oldNodes.nodes());
+
+ fut.add(oldNodesFut);
+ }
+
+ if (!F.isEmpty(newNodes.nodes())) {
+ ComputeTaskInternalFuture newNodesFut = ctx.kernalContext().closure().callAsync(BROADCAST,
+ Arrays.asList(new LoadCacheJob<>(ctx.name(), ctx.affinity().affinityTopologyVersion(), p, args, plc)),
+ newNodes.nodes());
+
+ fut.add(newNodesFut);
+ }
+
+ fut.markInitialized();
+
+ return fut;
}
/**
@@ -5498,6 +5534,62 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/**
+ * Internal callable for global size calculation.
+ */
+ @GridInternal
+ private static class LoadCacheJob<K, V> extends TopologyVersionAwareJob {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final IgniteBiPredicate<K, V> p;
+
+ /** */
+ private final Object[] args;
+
+ /** */
+ private final ExpiryPolicy plc;
+
+ /**
+ * @param cacheName Cache name.
+ * @param topVer Affinity topology version.
+ * @param p Predicate.
+ * @param args Arguments.
+ * @param plc Policy.
+ */
+ private LoadCacheJob(String cacheName, AffinityTopologyVersion topVer, IgniteBiPredicate<K, V> p, Object[] args,
+ ExpiryPolicy plc) {
+ super(cacheName, topVer);
+
+ this.p = p;
+ this.args = args;
+ this.plc = plc;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object localExecute(@Nullable IgniteInternalCache cache) {
+ try {
+ assert cache != null : "Failed to get a cache [cacheName=" + cacheName + ", topVer=" + topVer + "]";
+
+ if (plc != null)
+ cache = cache.withExpiryPolicy(plc);
+
+ cache.localLoadCache(p, args);
+
+ return null;
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return S.toString(LoadCacheJob.class, this);
+ }
+ }
+
+ /**
* Holder for last async operation future.
*/
protected static class FutureHolder {
[12/50] [abbrv] ignite git commit: ignite-2080 Data alignment issues
with Unsafe
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
index 2867b0a..1f7a53c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridUnsafe.java
@@ -18,15 +18,67 @@
package org.apache.ignite.internal.util;
import java.lang.reflect.Field;
+import java.nio.ByteOrder;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import sun.misc.Unsafe;
/**
- * Provides handle on Unsafe class from SUN which cannot be instantiated directly.
+ * <p>Wrapper for {@link sun.misc.Unsafe} class.</p>
+ *
+ * <p>
+ * The following statements for memory access operations are true:
+ * <ul>
+ * <li>All {@code putXxx(long addr, xxx val)}, {@code getXxx(long addr)}, {@code putXxx(byte[] arr, long off, xxx val)},
+ * {@code getXxx(byte[] arr, long off)} and corresponding methods with {@code LE} suffix are alignment aware
+ * and can be safely used with unaligned pointers.</li>
+ * <li>All {@code putXxxField(Object obj, long fieldOff, xxx val)} and {@code getXxxField(Object obj, long fieldOff)}
+ * methods are not alignment aware and can't be safely used with unaligned pointers. This methods can be safely used
+ * for object field values access because all object fields addresses are aligned.</li>
+ * <li>All {@code putXxxLE(...)} and {@code getXxxLE(...)} methods assumes that byte order is fixed as little-endian
+ * while native byte order is big-endian. So it is client code responsibility to check native byte order before
+ * invoking of this methods.</li>
+ * </ul>
+ * </p>
*/
-public class GridUnsafe {
+public abstract class GridUnsafe {
+ /** Unsafe. */
+ private static final Unsafe UNSAFE = unsafe();
+
+ /** Unaligned flag. */
+ private static final boolean UNALIGNED = unaligned();
+
+ /** Big endian. */
+ public static final boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
+
+ /** Address size. */
+ public static final int ADDR_SIZE = UNSAFE.addressSize();
+
+ /** */
+ public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
+
+ /** */
+ public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
+
+ /** */
+ public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
+
+ /** */
+ public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
+
+ /** */
+ public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
+
+ /** */
+ public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
+
+ /** */
+ public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
+
+ /** */
+ public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
+
/**
* Ensure singleton.
*/
@@ -35,9 +87,1130 @@ public class GridUnsafe {
}
/**
+ * Gets boolean value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Boolean value from object field.
+ */
+ public static boolean getBooleanField(Object obj, long fieldOff) {
+ return UNSAFE.getBoolean(obj, fieldOff);
+ }
+
+ /**
+ * Stores boolean value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putBooleanField(Object obj, long fieldOff, boolean val) {
+ UNSAFE.putBoolean(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets byte value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Byte value from object field.
+ */
+ public static byte getByteField(Object obj, long fieldOff) {
+ return UNSAFE.getByte(obj, fieldOff);
+ }
+
+ /**
+ * Stores byte value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putByteField(Object obj, long fieldOff, byte val) {
+ UNSAFE.putByte(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets short value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Short value from object field.
+ */
+ public static short getShortField(Object obj, long fieldOff) {
+ return UNSAFE.getShort(obj, fieldOff);
+ }
+
+ /**
+ * Stores short value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putShortField(Object obj, long fieldOff, short val) {
+ UNSAFE.putShort(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets char value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Char value from object field.
+ */
+ public static char getCharField(Object obj, long fieldOff) {
+ return UNSAFE.getChar(obj, fieldOff);
+ }
+
+ /**
+ * Stores char value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putCharField(Object obj, long fieldOff, char val) {
+ UNSAFE.putChar(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets integer value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Integer value from object field.
+ */
+ public static int getIntField(Object obj, long fieldOff) {
+ return UNSAFE.getInt(obj, fieldOff);
+ }
+
+ /**
+ * Stores integer value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putIntField(Object obj, long fieldOff, int val) {
+ UNSAFE.putInt(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets long value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Long value from object field.
+ */
+ public static long getLongField(Object obj, long fieldOff) {
+ return UNSAFE.getLong(obj, fieldOff);
+ }
+
+ /**
+ * Stores long value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putLongField(Object obj, long fieldOff, long val) {
+ UNSAFE.putLong(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets float value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Float value from object field.
+ */
+ public static float getFloatField(Object obj, long fieldOff) {
+ return UNSAFE.getFloat(obj, fieldOff);
+ }
+
+ /**
+ * Stores float value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putFloatField(Object obj, long fieldOff, float val) {
+ UNSAFE.putFloat(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets double value from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Double value from object field.
+ */
+ public static double getDoubleField(Object obj, long fieldOff) {
+ return UNSAFE.getDouble(obj, fieldOff);
+ }
+
+ /**
+ * Stores double value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putDoubleField(Object obj, long fieldOff, double val) {
+ UNSAFE.putDouble(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets reference from object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @return Reference from object field.
+ */
+ public static Object getObjectField(Object obj, long fieldOff) {
+ return UNSAFE.getObject(obj, fieldOff);
+ }
+
+ /**
+ * Stores reference value into object field.
+ *
+ * @param obj Object.
+ * @param fieldOff Field offset.
+ * @param val Value.
+ */
+ public static void putObjectField(Object obj, long fieldOff, Object val) {
+ UNSAFE.putObject(obj, fieldOff, val);
+ }
+
+ /**
+ * Gets boolean value from byte array.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Boolean value from byte array.
+ */
+ public static boolean getBoolean(byte[] arr, long off) {
+ return UNSAFE.getBoolean(arr, off);
+ }
+
+ /**
+ * Stores boolean value into byte array.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putBoolean(byte[] arr, long off, boolean val) {
+ UNSAFE.putBoolean(arr, off, val);
+ }
+
+ /**
+ * Gets byte value from byte array.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Byte value from byte array.
+ */
+ public static byte getByte(byte[] arr, long off) {
+ return UNSAFE.getByte(arr, off);
+ }
+
+ /**
+ * Stores byte value into byte array.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putByte(byte[] arr, long off, byte val) {
+ UNSAFE.putByte(arr, off, val);
+ }
+
+ /**
+ * Gets short value from byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Short value from byte array.
+ */
+ public static short getShort(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getShort(arr, off) : getShortByByte(arr, off, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores short value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putShort(byte[] arr, long off, short val) {
+ if (UNALIGNED)
+ UNSAFE.putShort(arr, off, val);
+ else
+ putShortByByte(arr, off, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets char value from byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Char value from byte array.
+ */
+ public static char getChar(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getChar(arr, off) : getCharByByte(arr, off, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores char value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putChar(byte[] arr, long off, char val) {
+ if (UNALIGNED)
+ UNSAFE.putChar(arr, off, val);
+ else
+ putCharByByte(arr, off, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets integer value from byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Integer value from byte array.
+ */
+ public static int getInt(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getInt(arr, off) : getIntByByte(arr, off, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores integer value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putInt(byte[] arr, long off, int val) {
+ if (UNALIGNED)
+ UNSAFE.putInt(arr, off, val);
+ else
+ putIntByByte(arr, off, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets long value from byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Long value from byte array.
+ */
+ public static long getLong(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getLong(arr, off) : getLongByByte(arr, off, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores long value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putLong(byte[] arr, long off, long val) {
+ if (UNALIGNED)
+ UNSAFE.putLong(arr, off, val);
+ else
+ putLongByByte(arr, off, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets float value from byte array. Alignment aware.
+ *
+ * @param arr Object.
+ * @param off Offset.
+ * @return Float value from byte array.
+ */
+ public static float getFloat(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getFloat(arr, off) : Float.intBitsToFloat(getIntByByte(arr, off, BIG_ENDIAN));
+ }
+
+ /**
+ * Stores float value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putFloat(byte[] arr, long off, float val) {
+ if (UNALIGNED)
+ UNSAFE.putFloat(arr, off, val);
+ else
+ putIntByByte(arr, off, Float.floatToIntBits(val), BIG_ENDIAN);
+ }
+
+ /**
+ * Gets double value from byte array. Alignment aware.
+ *
+ * @param arr byte array.
+ * @param off Offset.
+ * @return Double value from byte array. Alignment aware.
+ */
+ public static double getDouble(byte[] arr, long off) {
+ return UNALIGNED ? UNSAFE.getDouble(arr, off) : Double.longBitsToDouble(getLongByByte(arr, off, BIG_ENDIAN));
+ }
+
+ /**
+ * Stores double value into byte array. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putDouble(byte[] arr, long off, double val) {
+ if (UNALIGNED)
+ UNSAFE.putDouble(arr, off, val);
+ else
+ putLongByByte(arr, off, Double.doubleToLongBits(val), BIG_ENDIAN);
+ }
+
+ /**
+ * Gets short value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Short value from byte array.
+ */
+ public static short getShortLE(byte[] arr, long off) {
+ return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(arr, off)) : getShortByByte(arr, off, false);
+ }
+
+ /**
+ * Stores short value into byte array assuming that value should be stored in little-endian byte order and native
+ * byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putShortLE(byte[] arr, long off, short val) {
+ if (UNALIGNED)
+ UNSAFE.putShort(arr, off, Short.reverseBytes(val));
+ else
+ putShortByByte(arr, off, val, false);
+ }
+
+ /**
+ * Gets char value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Char value from byte array.
+ */
+ public static char getCharLE(byte[] arr, long off) {
+ return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(arr, off)) : getCharByByte(arr, off, false);
+ }
+
+ /**
+ * Stores char value into byte array assuming that value should be stored in little-endian byte order and native
+ * byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putCharLE(byte[] arr, long off, char val) {
+ if (UNALIGNED)
+ UNSAFE.putChar(arr, off, Character.reverseBytes(val));
+ else
+ putCharByByte(arr, off, val, false);
+ }
+
+ /**
+ * Gets integer value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Integer value from byte array.
+ */
+ public static int getIntLE(byte[] arr, long off) {
+ return UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(arr, off)) : getIntByByte(arr, off, false);
+ }
+
+ /**
+ * Stores integer value into byte array assuming that value should be stored in little-endian byte order and
+ * native byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putIntLE(byte[] arr, long off, int val) {
+ if (UNALIGNED)
+ UNSAFE.putInt(arr, off, Integer.reverseBytes(val));
+ else
+ putIntByByte(arr, off, val, false);
+ }
+
+ /**
+ * Gets long value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Long value from byte array.
+ */
+ public static long getLongLE(byte[] arr, long off) {
+ return UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(arr, off)) : getLongByByte(arr, off, false);
+ }
+
+ /**
+ * Stores long value into byte array assuming that value should be stored in little-endian byte order and native
+ * byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putLongLE(byte[] arr, long off, long val) {
+ if (UNALIGNED)
+ UNSAFE.putLong(arr, off, Long.reverseBytes(val));
+ else
+ putLongByByte(arr, off, val, false);
+ }
+
+ /**
+ * Gets float value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Float value from byte array.
+ */
+ public static float getFloatLE(byte[] arr, long off) {
+ return Float.intBitsToFloat(
+ UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(arr, off)) : getIntByByte(arr, off, false)
+ );
+ }
+
+ /**
+ * Stores float value into byte array assuming that value should be stored in little-endian byte order and native
+ * byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putFloatLE(byte[] arr, long off, float val) {
+ int intVal = Float.floatToIntBits(val);
+
+ if (UNALIGNED)
+ UNSAFE.putInt(arr, off, Integer.reverseBytes(intVal));
+ else
+ putIntByByte(arr, off, intVal, false);
+ }
+
+ /**
+ * Gets double value from byte array assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @return Double value from byte array.
+ */
+ public static double getDoubleLE(byte[] arr, long off) {
+ return Double.longBitsToDouble(
+ UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(arr, off)) : getLongByByte(arr, off, false)
+ );
+ }
+
+ /**
+ * Stores double value into byte array assuming that value should be stored in little-endian byte order and
+ * native byte order is big-endian. Alignment aware.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putDoubleLE(byte[] arr, long off, double val) {
+ long longVal = Double.doubleToLongBits(val);
+
+ if (UNALIGNED)
+ UNSAFE.putLong(arr, off, Long.reverseBytes(longVal));
+ else
+ putLongByByte(arr, off, longVal, false);
+ }
+
+ /**
+ * Gets byte value from given address.
+ *
+ * @param addr Address.
+ * @return Byte value from given address.
+ */
+ public static byte getByte(long addr) {
+ return UNSAFE.getByte(addr);
+ }
+
+ /**
+ * Stores given byte value.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putByte(long addr, byte val) {
+ UNSAFE.putByte(addr, val);
+ }
+
+ /**
+ * Gets short value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Short value from given address.
+ */
+ public static short getShort(long addr) {
+ return UNALIGNED ? UNSAFE.getShort(addr) : getShortByByte(addr, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores given short value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putShort(long addr, short val) {
+ if (UNALIGNED)
+ UNSAFE.putShort(addr, val);
+ else
+ putShortByByte(addr, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets char value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Char value from given address.
+ */
+ public static char getChar(long addr) {
+ return UNALIGNED ? UNSAFE.getChar(addr) : getCharByByte(addr, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores given char value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putChar(long addr, char val) {
+ if (UNALIGNED)
+ UNSAFE.putChar(addr, val);
+ else
+ putCharByByte(addr, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets integer value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Integer value from given address.
+ */
+ public static int getInt(long addr) {
+ return UNALIGNED ? UNSAFE.getInt(addr) : getIntByByte(addr, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores given integer value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putInt(long addr, int val) {
+ if (UNALIGNED)
+ UNSAFE.putInt(addr, val);
+ else
+ putIntByByte(addr, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets long value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Long value from given address.
+ */
+ public static long getLong(long addr) {
+ return UNALIGNED ? UNSAFE.getLong(addr) : getLongByByte(addr, BIG_ENDIAN);
+ }
+
+ /**
+ * Stores given integer value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putLong(long addr, long val) {
+ if (UNALIGNED)
+ UNSAFE.putLong(addr, val);
+ else
+ putLongByByte(addr, val, BIG_ENDIAN);
+ }
+
+ /**
+ * Gets float value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Float value from given address.
+ */
+ public static float getFloat(long addr) {
+ return UNALIGNED ? UNSAFE.getFloat(addr) : Float.intBitsToFloat(getIntByByte(addr, BIG_ENDIAN));
+ }
+
+ /**
+ * Stores given float value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putFloat(long addr, float val) {
+ if (UNALIGNED)
+ UNSAFE.putFloat(addr, val);
+ else
+ putIntByByte(addr, Float.floatToIntBits(val), BIG_ENDIAN);
+ }
+
+ /**
+ * Gets double value from given address. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Double value from given address.
+ */
+ public static double getDouble(long addr) {
+ return UNALIGNED ? UNSAFE.getDouble(addr) : Double.longBitsToDouble(getLongByByte(addr, BIG_ENDIAN));
+ }
+
+ /**
+ * Stores given double value. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putDouble(long addr, double val) {
+ if (UNALIGNED)
+ UNSAFE.putDouble(addr, val);
+ else
+ putLongByByte(addr, Double.doubleToLongBits(val), BIG_ENDIAN);
+ }
+
+ /**
+ * Gets short value from given address assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Short value from given address.
+ */
+ public static short getShortLE(long addr) {
+ return UNALIGNED ? Short.reverseBytes(UNSAFE.getShort(addr)) : getShortByByte(addr, false);
+ }
+
+ /**
+ * Stores given short value assuming that value should be stored in little-endian byte order and native byte
+ * order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putShortLE(long addr, short val) {
+ if (UNALIGNED)
+ UNSAFE.putShort(addr, Short.reverseBytes(val));
+ else
+ putShortByByte(addr, val, false);
+ }
+
+ /**
+ * Gets char value from given address assuming that value stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Char value from given address.
+ */
+ public static char getCharLE(long addr) {
+ return UNALIGNED ? Character.reverseBytes(UNSAFE.getChar(addr)) : getCharByByte(addr, false);
+ }
+
+ /**
+ * Stores given char value assuming that value should be stored in little-endian byte order and native byte order
+ * is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putCharLE(long addr, char val) {
+ if (UNALIGNED)
+ UNSAFE.putChar(addr, Character.reverseBytes(val));
+ else
+ putCharByByte(addr, val, false);
+ }
+
+ /**
+ * Gets integer value from given address assuming that value stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Integer value from given address.
+ */
+ public static int getIntLE(long addr) {
+ return UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(addr)) : getIntByByte(addr, false);
+ }
+
+ /**
+ * Stores given integer value assuming that value should be stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putIntLE(long addr, int val) {
+ if (UNALIGNED)
+ UNSAFE.putInt(addr, Integer.reverseBytes(val));
+ else
+ putIntByByte(addr, val, false);
+ }
+
+ /**
+ * Gets long value from given address assuming that value stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Long value from given address.
+ */
+ public static long getLongLE(long addr) {
+ return UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(addr)) : getLongByByte(addr, false);
+ }
+
+ /**
+ * Stores given integer value assuming that value should be stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putLongLE(long addr, long val) {
+ if (UNALIGNED)
+ UNSAFE.putLong(addr, Long.reverseBytes(val));
+ else
+ putLongByByte(addr, val, false);
+ }
+
+ /**
+ * Gets float value from given address assuming that value stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Float value from given address.
+ */
+ public static float getFloatLE(long addr) {
+ return Float.intBitsToFloat(UNALIGNED ? Integer.reverseBytes(UNSAFE.getInt(addr)) : getIntByByte(addr, false));
+ }
+
+ /**
+ * Stores given float value assuming that value should be stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putFloatLE(long addr, float val) {
+ int intVal = Float.floatToIntBits(val);
+
+ if (UNALIGNED)
+ UNSAFE.putInt(addr, Integer.reverseBytes(intVal));
+ else
+ putIntByByte(addr, intVal, false);
+ }
+
+ /**
+ * Gets double value from given address assuming that value stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @return Double value from given address.
+ */
+ public static double getDoubleLE(long addr) {
+ return Double.longBitsToDouble(
+ UNALIGNED ? Long.reverseBytes(UNSAFE.getLong(addr)) : getLongByByte(addr, false)
+ );
+ }
+
+ /**
+ * Stores given double value assuming that value should be stored in little-endian byte order
+ * and native byte order is big-endian. Alignment aware.
+ *
+ * @param addr Address.
+ * @param val Value.
+ */
+ public static void putDoubleLE(long addr, double val) {
+ long longVal = Double.doubleToLongBits(val);
+
+ if (UNALIGNED)
+ UNSAFE.putLong(addr, Long.reverseBytes(longVal));
+ else
+ putLongByByte(addr, longVal, false);
+ }
+
+ /**
+ * Returns static field offset.
+ *
+ * @param field Field.
+ * @return Static field offset.
+ */
+ public static long staticFieldOffset(Field field) {
+ return UNSAFE.staticFieldOffset(field);
+ }
+
+ /**
+ * Returns object field offset.
+ *
+ * @param field Field.
+ * @return Object field offset.
+ */
+ public static long objectFieldOffset(Field field) {
+ return UNSAFE.objectFieldOffset(field);
+ }
+
+ /**
+ * Returns static field base.
+ *
+ * @param field Field.
+ * @return Static field base.
+ */
+ public static Object staticFieldBase(Field field) {
+ return UNSAFE.staticFieldBase(field);
+ }
+
+ /**
+ * Allocates memory.
+ *
+ * @param size Size.
+ * @return address.
+ */
+ public static long allocateMemory(long size) {
+ return UNSAFE.allocateMemory(size);
+ }
+
+ /**
+ * Reallocates memory.
+ *
+ * @param addr Address.
+ * @param len Length.
+ * @return address.
+ */
+ public static long reallocateMemory(long addr, long len) {
+ return UNSAFE.reallocateMemory(addr, len);
+ }
+
+ /**
+ * Fills memory with given value.
+ *
+ * @param addr Address.
+ * @param len Length.
+ * @param val Value.
+ */
+ public static void setMemory(long addr, long len, byte val) {
+ UNSAFE.setMemory(addr, len, val);
+ }
+
+ /**
+ * Copies memory.
+ *
+ * @param src Source.
+ * @param dst Dst.
+ * @param len Length.
+ */
+ public static void copyMemory(long src, long dst, long len) {
+ UNSAFE.copyMemory(src, dst, len);
+ }
+
+ /**
+ * Sets all bytes in a given block of memory to a copy of another block.
+ *
+ * @param srcBase Source base.
+ * @param srcOff Source offset.
+ * @param dstBase Dst base.
+ * @param dstOff Dst offset.
+ * @param len Length.
+ */
+ public static void copyMemory(Object srcBase, long srcOff, Object dstBase, long dstOff, long len) {
+ UNSAFE.copyMemory(srcBase, srcOff, dstBase, dstOff, len);
+ }
+
+ /**
+ * Frees memory.
+ *
+ * @param addr Address.
+ */
+ public static void freeMemory(long addr) {
+ UNSAFE.freeMemory(addr);
+ }
+
+ /**
+ * Returns the offset of the first element in the storage allocation of a given array class.
+ *
+ * @param cls Class.
+ * @return the offset of the first element in the storage allocation of a given array class.
+ */
+ public static int arrayBaseOffset(Class cls) {
+ return UNSAFE.arrayBaseOffset(cls);
+ }
+
+ /**
+ * Allocates instance of given class.
+ *
+ * @param cls Class.
+ * @return Allocated instance.
+ */
+ public static Object allocateInstance(Class cls) throws InstantiationException {
+ return UNSAFE.allocateInstance(cls);
+ }
+
+ /**
+ * Acquires monitor lock.
+ *
+ * @param obj Object.
+ */
+ public static void monitorEnter(Object obj) {
+ UNSAFE.monitorEnter(obj);
+ }
+
+ /**
+ * Releases monitor lock.
+ *
+ * @param obj Object.
+ */
+ public static void monitorExit(Object obj) {
+ UNSAFE.monitorExit(obj);
+ }
+
+ /**
+ * Integer CAS.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param exp Expected.
+ * @param upd Upd.
+ * @return {@code True} if operation completed successfully, {@code false} - otherwise.
+ */
+ public static boolean compareAndSwapInt(Object obj, long off, int exp, int upd) {
+ return UNSAFE.compareAndSwapInt(obj, off, exp, upd);
+ }
+
+ /**
+ * Long CAS.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param exp Expected.
+ * @param upd Upd.
+ * @return {@code True} if operation completed successfully, {@code false} - otherwise.
+ */
+ public static boolean compareAndSwapLong(Object obj, long off, long exp, long upd) {
+ return UNSAFE.compareAndSwapLong(obj, off, exp, upd);
+ }
+
+ /**
+ * Gets byte value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @return Byte value.
+ */
+ public static byte getByteVolatile(Object obj, long off) {
+ return UNSAFE.getByteVolatile(obj, off);
+ }
+
+ /**
+ * Stores byte value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putByteVolatile(Object obj, long off, byte val) {
+ UNSAFE.putByteVolatile(obj, off, val);
+ }
+
+ /**
+ * Gets integer value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @return Integer value.
+ */
+ public static int getIntVolatile(Object obj, long off) {
+ return UNSAFE.getIntVolatile(obj, off);
+ }
+
+ /**
+ * Stores integer value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putIntVolatile(Object obj, long off, int val) {
+ UNSAFE.putIntVolatile(obj, off, val);
+ }
+
+ /**
+ * Gets long value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @return Long value.
+ */
+ public static long getLongVolatile(Object obj, long off) {
+ return UNSAFE.getLongVolatile(obj, off);
+ }
+
+ /**
+ * Stores long value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putLongVolatile(Object obj, long off, long val) {
+ UNSAFE.putLongVolatile(obj, off, val);
+ }
+
+ /**
+ * Stores reference value with volatile semantic.
+ *
+ * @param obj Object.
+ * @param off Offset.
+ * @param val Value.
+ */
+ public static void putObjectVolatile(Object obj, long off, Object val) {
+ UNSAFE.putObjectVolatile(obj, off, val);
+ }
+
+ /**
+ * Returns unaligned flag.
+ */
+ private static boolean unaligned() {
+ String arch = System.getProperty("os.arch");
+
+ return arch.equals("i386") || arch.equals("x86") || arch.equals("amd64") || arch.equals("x86_64");
+ }
+
+ /**
* @return Instance of Unsafe class.
*/
- public static Unsafe unsafe() {
+ private static Unsafe unsafe() {
try {
return Unsafe.getUnsafe();
}
@@ -59,4 +1232,308 @@ public class GridUnsafe {
}
}
}
+
+ /**
+ * @param obj Object.
+ * @param off Offset.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static short getShortByByte(Object obj, long off, boolean bigEndian) {
+ if (bigEndian)
+ return (short)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff));
+ else
+ return (short)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff));
+ }
+
+ /**
+ * @param obj Object.
+ * @param off Offset.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putShortByByte(Object obj, long off, short val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(obj, off, (byte)(val >> 8));
+ UNSAFE.putByte(obj, off + 1, (byte)val);
+ }
+ else {
+ UNSAFE.putByte(obj, off + 1, (byte)(val >> 8));
+ UNSAFE.putByte(obj, off, (byte)val);
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param off Offset.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static char getCharByByte(Object obj, long off, boolean bigEndian) {
+ if (bigEndian)
+ return (char)(UNSAFE.getByte(obj, off) << 8 | (UNSAFE.getByte(obj, off + 1) & 0xff));
+ else
+ return (char)(UNSAFE.getByte(obj, off + 1) << 8 | (UNSAFE.getByte(obj, off) & 0xff));
+ }
+
+ /**
+ * @param obj Object.
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putCharByByte(Object obj, long addr, char val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(obj, addr, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr + 1, (byte)val);
+ }
+ else {
+ UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr, (byte)val);
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static int getIntByByte(Object obj, long addr, boolean bigEndian) {
+ if (bigEndian) {
+ return (((int)UNSAFE.getByte(obj, addr)) << 24) |
+ (((int)UNSAFE.getByte(obj, addr + 1) & 0xff) << 16) |
+ (((int)UNSAFE.getByte(obj, addr + 2) & 0xff) << 8) |
+ (((int)UNSAFE.getByte(obj, addr + 3) & 0xff));
+ }
+ else {
+ return (((int)UNSAFE.getByte(obj, addr + 3)) << 24) |
+ (((int)UNSAFE.getByte(obj, addr + 2) & 0xff) << 16) |
+ (((int)UNSAFE.getByte(obj, addr + 1) & 0xff) << 8) |
+ (((int)UNSAFE.getByte(obj, addr) & 0xff));
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putIntByByte(Object obj, long addr, int val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(obj, addr, (byte)(val >> 24));
+ UNSAFE.putByte(obj, addr + 1, (byte)(val >> 16));
+ UNSAFE.putByte(obj, addr + 2, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr + 3, (byte)(val));
+ }
+ else {
+ UNSAFE.putByte(obj, addr + 3, (byte)(val >> 24));
+ UNSAFE.putByte(obj, addr + 2, (byte)(val >> 16));
+ UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr, (byte)(val));
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static long getLongByByte(Object obj, long addr, boolean bigEndian) {
+ if (bigEndian) {
+ return (((long)UNSAFE.getByte(obj, addr)) << 56) |
+ (((long)UNSAFE.getByte(obj, addr + 1) & 0xff) << 48) |
+ (((long)UNSAFE.getByte(obj, addr + 2) & 0xff) << 40) |
+ (((long)UNSAFE.getByte(obj, addr + 3) & 0xff) << 32) |
+ (((long)UNSAFE.getByte(obj, addr + 4) & 0xff) << 24) |
+ (((long)UNSAFE.getByte(obj, addr + 5) & 0xff) << 16) |
+ (((long)UNSAFE.getByte(obj, addr + 6) & 0xff) << 8) |
+ (((long)UNSAFE.getByte(obj, addr + 7) & 0xff));
+ }
+ else {
+ return (((long)UNSAFE.getByte(obj, addr + 7)) << 56) |
+ (((long)UNSAFE.getByte(obj, addr + 6) & 0xff) << 48) |
+ (((long)UNSAFE.getByte(obj, addr + 5) & 0xff) << 40) |
+ (((long)UNSAFE.getByte(obj, addr + 4) & 0xff) << 32) |
+ (((long)UNSAFE.getByte(obj, addr + 3) & 0xff) << 24) |
+ (((long)UNSAFE.getByte(obj, addr + 2) & 0xff) << 16) |
+ (((long)UNSAFE.getByte(obj, addr + 1) & 0xff) << 8) |
+ (((long)UNSAFE.getByte(obj, addr) & 0xff));
+ }
+ }
+
+ /**
+ * @param obj Object.
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putLongByByte(Object obj, long addr, long val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(obj, addr, (byte)(val >> 56));
+ UNSAFE.putByte(obj, addr + 1, (byte)(val >> 48));
+ UNSAFE.putByte(obj, addr + 2, (byte)(val >> 40));
+ UNSAFE.putByte(obj, addr + 3, (byte)(val >> 32));
+ UNSAFE.putByte(obj, addr + 4, (byte)(val >> 24));
+ UNSAFE.putByte(obj, addr + 5, (byte)(val >> 16));
+ UNSAFE.putByte(obj, addr + 6, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr + 7, (byte)(val));
+ }
+ else {
+ UNSAFE.putByte(obj, addr + 7, (byte)(val >> 56));
+ UNSAFE.putByte(obj, addr + 6, (byte)(val >> 48));
+ UNSAFE.putByte(obj, addr + 5, (byte)(val >> 40));
+ UNSAFE.putByte(obj, addr + 4, (byte)(val >> 32));
+ UNSAFE.putByte(obj, addr + 3, (byte)(val >> 24));
+ UNSAFE.putByte(obj, addr + 2, (byte)(val >> 16));
+ UNSAFE.putByte(obj, addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(obj, addr, (byte)(val));
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static short getShortByByte(long addr, boolean bigEndian) {
+ if (bigEndian)
+ return (short)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff));
+ else
+ return (short)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff));
+ }
+
+ /**
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putShortByByte(long addr, short val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(addr, (byte)(val >> 8));
+ UNSAFE.putByte(addr + 1, (byte)val);
+ }
+ else {
+ UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(addr, (byte)val);
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static char getCharByByte(long addr, boolean bigEndian) {
+ if (bigEndian)
+ return (char)(UNSAFE.getByte(addr) << 8 | (UNSAFE.getByte(addr + 1) & 0xff));
+ else
+ return (char)(UNSAFE.getByte(addr + 1) << 8 | (UNSAFE.getByte(addr) & 0xff));
+ }
+
+ /**
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putCharByByte(long addr, char val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(addr, (byte)(val >> 8));
+ UNSAFE.putByte(addr + 1, (byte)val);
+ }
+ else {
+ UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(addr, (byte)val);
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static int getIntByByte(long addr, boolean bigEndian) {
+ if (bigEndian) {
+ return (((int)UNSAFE.getByte(addr)) << 24) |
+ (((int)UNSAFE.getByte(addr + 1) & 0xff) << 16) |
+ (((int)UNSAFE.getByte(addr + 2) & 0xff) << 8) |
+ (((int)UNSAFE.getByte(addr + 3) & 0xff));
+ }
+ else {
+ return (((int)UNSAFE.getByte(addr + 3)) << 24) |
+ (((int)UNSAFE.getByte(addr + 2) & 0xff) << 16) |
+ (((int)UNSAFE.getByte(addr + 1) & 0xff) << 8) |
+ (((int)UNSAFE.getByte(addr) & 0xff));
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putIntByByte(long addr, int val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(addr, (byte)(val >> 24));
+ UNSAFE.putByte(addr + 1, (byte)(val >> 16));
+ UNSAFE.putByte(addr + 2, (byte)(val >> 8));
+ UNSAFE.putByte(addr + 3, (byte)(val));
+ }
+ else {
+ UNSAFE.putByte(addr + 3, (byte)(val >> 24));
+ UNSAFE.putByte(addr + 2, (byte)(val >> 16));
+ UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(addr, (byte)(val));
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static long getLongByByte(long addr, boolean bigEndian) {
+ if (bigEndian) {
+ return (((long)UNSAFE.getByte(addr)) << 56) |
+ (((long)UNSAFE.getByte(addr + 1) & 0xff) << 48) |
+ (((long)UNSAFE.getByte(addr + 2) & 0xff) << 40) |
+ (((long)UNSAFE.getByte(addr + 3) & 0xff) << 32) |
+ (((long)UNSAFE.getByte(addr + 4) & 0xff) << 24) |
+ (((long)UNSAFE.getByte(addr + 5) & 0xff) << 16) |
+ (((long)UNSAFE.getByte(addr + 6) & 0xff) << 8) |
+ (((long)UNSAFE.getByte(addr + 7) & 0xff));
+ }
+ else {
+ return (((long)UNSAFE.getByte(addr + 7)) << 56) |
+ (((long)UNSAFE.getByte(addr + 6) & 0xff) << 48) |
+ (((long)UNSAFE.getByte(addr + 5) & 0xff) << 40) |
+ (((long)UNSAFE.getByte(addr + 4) & 0xff) << 32) |
+ (((long)UNSAFE.getByte(addr + 3) & 0xff) << 24) |
+ (((long)UNSAFE.getByte(addr + 2) & 0xff) << 16) |
+ (((long)UNSAFE.getByte(addr + 1) & 0xff) << 8) |
+ (((long)UNSAFE.getByte(addr) & 0xff));
+ }
+ }
+
+ /**
+ * @param addr Address.
+ * @param val Value.
+ * @param bigEndian Order of value bytes in memory. If {@code true} - big-endian, otherwise little-endian.
+ */
+ private static void putLongByByte(long addr, long val, boolean bigEndian) {
+ if (bigEndian) {
+ UNSAFE.putByte(addr, (byte)(val >> 56));
+ UNSAFE.putByte(addr + 1, (byte)(val >> 48));
+ UNSAFE.putByte(addr + 2, (byte)(val >> 40));
+ UNSAFE.putByte(addr + 3, (byte)(val >> 32));
+ UNSAFE.putByte(addr + 4, (byte)(val >> 24));
+ UNSAFE.putByte(addr + 5, (byte)(val >> 16));
+ UNSAFE.putByte(addr + 6, (byte)(val >> 8));
+ UNSAFE.putByte(addr + 7, (byte)(val));
+ }
+ else {
+ UNSAFE.putByte(addr + 7, (byte)(val >> 56));
+ UNSAFE.putByte(addr + 6, (byte)(val >> 48));
+ UNSAFE.putByte(addr + 5, (byte)(val >> 40));
+ UNSAFE.putByte(addr + 4, (byte)(val >> 32));
+ UNSAFE.putByte(addr + 3, (byte)(val >> 24));
+ UNSAFE.putByte(addr + 2, (byte)(val >> 16));
+ UNSAFE.putByte(addr + 1, (byte)(val >> 8));
+ UNSAFE.putByte(addr, (byte)(val));
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 6c0b8e6..a6b28fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -243,21 +243,19 @@ import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_CACHE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JVM_PID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
+import static org.apache.ignite.internal.util.GridUnsafe.objectFieldOffset;
+import static org.apache.ignite.internal.util.GridUnsafe.putObjectVolatile;
+import static org.apache.ignite.internal.util.GridUnsafe.staticFieldBase;
+import static org.apache.ignite.internal.util.GridUnsafe.staticFieldOffset;
/**
* Collection of utility methods used throughout the system.
*/
@SuppressWarnings({"UnusedReturnValue", "UnnecessaryFullyQualifiedName"})
public abstract class IgniteUtils {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** {@code True} if {@code unsafe} should be used for array copy. */
private static final boolean UNSAFE_BYTE_ARR_CP = unsafeByteArrayCopyAvailable();
- /** Offset. */
- private static final int BYTE_ARRAY_DATA_OFFSET = UNSAFE.arrayBaseOffset(byte[].class);
-
/** Sun-specific JDK constructor factory for objects that don't have empty constructor. */
private static final Method CTOR_FACTORY;
@@ -526,7 +524,7 @@ public abstract class IgniteUtils {
}
// UNIX name detection.
- if (osLow.contains("olaris"))
+ if (osLow.contains("olaris") || osLow.contains("sunos"))
solaris = true;
else if (osLow.contains("inux"))
linux = true;
@@ -669,9 +667,8 @@ public abstract class IgniteUtils {
// We use unsafe operations to update static fields on interface because
// they are treated as static final and cannot be updated via standard reflection.
- UNSAFE.putObjectVolatile(UNSAFE.staticFieldBase(f1), UNSAFE.staticFieldOffset(f1), gridEvents());
- UNSAFE.putObjectVolatile(UNSAFE.staticFieldBase(f2), UNSAFE.staticFieldOffset(f2),
- gridEvents(EVT_NODE_METRICS_UPDATED));
+ putObjectVolatile(staticFieldBase(f1), staticFieldOffset(f1), gridEvents());
+ putObjectVolatile(staticFieldBase(f2), staticFieldOffset(f2), gridEvents(EVT_NODE_METRICS_UPDATED));
assert EVTS_ALL != null;
assert EVTS_ALL.length == GRID_EVTS.length;
@@ -7692,7 +7689,7 @@ public abstract class IgniteUtils {
*/
public static long fieldOffset(Class<?> cls, String fieldName) {
try {
- return UNSAFE.objectFieldOffset(cls.getDeclaredField(fieldName));
+ return objectFieldOffset(cls.getDeclaredField(fieldName));
}
catch (NoSuchFieldException e) {
throw new IllegalStateException(e);
@@ -8304,7 +8301,7 @@ public abstract class IgniteUtils {
@SuppressWarnings("TypeParameterExtendsFinalClass")
private static boolean unsafeByteArrayCopyAvailable() {
try {
- Class<? extends Unsafe> unsafeCls = UNSAFE.getClass();
+ Class<? extends Unsafe> unsafeCls = Unsafe.class;
unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);
@@ -8327,7 +8324,7 @@ public abstract class IgniteUtils {
assert resBuf.length >= resOff + len;
if (UNSAFE_BYTE_ARR_CP)
- UNSAFE.copyMemory(src, BYTE_ARRAY_DATA_OFFSET + off, resBuf, BYTE_ARRAY_DATA_OFFSET + resOff, len);
+ GridUnsafe.copyMemory(src, GridUnsafe.BYTE_ARR_OFF + off, resBuf, GridUnsafe.BYTE_ARR_OFF + resOff, len);
else
System.arraycopy(src, off, resBuf, resOff, len);
@@ -8860,18 +8857,18 @@ public abstract class IgniteUtils {
* @return Offset.
*/
public static long writeGridUuid(byte[] arr, long off, @Nullable IgniteUuid uid) {
- UNSAFE.putBoolean(arr, off++, uid != null);
+ GridUnsafe.putBoolean(arr, off++, uid != null);
if (uid != null) {
- UNSAFE.putLong(arr, off, uid.globalId().getMostSignificantBits());
+ GridUnsafe.putLong(arr, off, uid.globalId().getMostSignificantBits());
off += 8;
- UNSAFE.putLong(arr, off, uid.globalId().getLeastSignificantBits());
+ GridUnsafe.putLong(arr, off, uid.globalId().getLeastSignificantBits());
off += 8;
- UNSAFE.putLong(arr, off, uid.localId());
+ GridUnsafe.putLong(arr, off, uid.localId());
off += 8;
}
@@ -8885,18 +8882,18 @@ public abstract class IgniteUtils {
* @return UUID.
*/
@Nullable public static IgniteUuid readGridUuid(byte[] arr, long off) {
- if (UNSAFE.getBoolean(arr, off++)) {
- long most = UNSAFE.getLong(arr, off);
+ if (GridUnsafe.getBoolean(arr, off++)) {
+ long most = GridUnsafe.getLong(arr, off);
off += 8;
- long least = UNSAFE.getLong(arr, off);
+ long least = GridUnsafe.getLong(arr, off);
off += 8;
UUID globalId = new UUID(most, least);
- long locId = UNSAFE.getLong(arr, off);
+ long locId = GridUnsafe.getLong(arr, off);
return new IgniteUuid(globalId, locId);
}
@@ -8909,18 +8906,18 @@ public abstract class IgniteUtils {
* @return UUID.
*/
@Nullable public static IgniteUuid readGridUuid(long ptr) {
- if (UNSAFE.getBoolean(null, ptr++)) {
- long most = UNSAFE.getLong(ptr);
+ if (GridUnsafe.getBoolean(null, ptr++)) {
+ long most = GridUnsafe.getLong(ptr);
ptr += 8;
- long least = UNSAFE.getLong(ptr);
+ long least = GridUnsafe.getLong(ptr);
ptr += 8;
UUID globalId = new UUID(most, least);
- long locId = UNSAFE.getLong(ptr);
+ long locId = GridUnsafe.getLong(ptr);
return new IgniteUuid(globalId, locId);
}
@@ -8937,43 +8934,43 @@ public abstract class IgniteUtils {
public static long writeVersion(byte[] arr, long off, GridCacheVersion ver) {
boolean verEx = ver instanceof GridCacheVersionEx;
- UNSAFE.putBoolean(arr, off++, verEx);
+ GridUnsafe.putBoolean(arr, off++, verEx);
if (verEx) {
GridCacheVersion drVer = ver.conflictVersion();
assert drVer != null;
- UNSAFE.putInt(arr, off, drVer.topologyVersion());
+ GridUnsafe.putInt(arr, off, drVer.topologyVersion());
off += 4;
- UNSAFE.putInt(arr, off, drVer.nodeOrderAndDrIdRaw());
+ GridUnsafe.putInt(arr, off, drVer.nodeOrderAndDrIdRaw());
off += 4;
- UNSAFE.putLong(arr, off, drVer.globalTime());
+ GridUnsafe.putLong(arr, off, drVer.globalTime());
off += 8;
- UNSAFE.putLong(arr, off, drVer.order());
+ GridUnsafe.putLong(arr, off, drVer.order());
off += 8;
}
- UNSAFE.putInt(arr, off, ver.topologyVersion());
+ GridUnsafe.putInt(arr, off, ver.topologyVersion());
off += 4;
- UNSAFE.putInt(arr, off, ver.nodeOrderAndDrIdRaw());
+ GridUnsafe.putInt(arr, off, ver.nodeOrderAndDrIdRaw());
off += 4;
- UNSAFE.putLong(arr, off, ver.globalTime());
+ GridUnsafe.putLong(arr, off, ver.globalTime());
off += 8;
- UNSAFE.putLong(arr, off, ver.order());
+ GridUnsafe.putLong(arr, off, ver.order());
off += 8;
@@ -8986,18 +8983,18 @@ public abstract class IgniteUtils {
* @return Version.
*/
public static GridCacheVersion readVersion(long ptr, boolean verEx) {
- GridCacheVersion ver = new GridCacheVersion(UNSAFE.getInt(ptr),
- UNSAFE.getInt(ptr + 4),
- UNSAFE.getLong(ptr + 8),
- UNSAFE.getLong(ptr + 16));
+ GridCacheVersion ver = new GridCacheVersion(GridUnsafe.getInt(ptr),
+ GridUnsafe.getInt(ptr + 4),
+ GridUnsafe.getLong(ptr + 8),
+ GridUnsafe.getLong(ptr + 16));
if (verEx) {
ptr += 24;
- ver = new GridCacheVersionEx(UNSAFE.getInt(ptr),
- UNSAFE.getInt(ptr + 4),
- UNSAFE.getLong(ptr + 8),
- UNSAFE.getLong(ptr + 16),
+ ver = new GridCacheVersionEx(GridUnsafe.getInt(ptr),
+ GridUnsafe.getInt(ptr + 4),
+ GridUnsafe.getLong(ptr + 8),
+ GridUnsafe.getLong(ptr + 16),
ver);
}
@@ -9011,38 +9008,38 @@ public abstract class IgniteUtils {
* @return Version.
*/
public static GridCacheVersion readVersion(byte[] arr, long off, boolean verEx) {
- int topVer = UNSAFE.getInt(arr, off);
+ int topVer = GridUnsafe.getInt(arr, off);
off += 4;
- int nodeOrderDrId = UNSAFE.getInt(arr, off);
+ int nodeOrderDrId = GridUnsafe.getInt(arr, off);
off += 4;
- long globalTime = UNSAFE.getLong(arr, off);
+ long globalTime = GridUnsafe.getLong(arr, off);
off += 8;
- long order = UNSAFE.getLong(arr, off);
+ long order = GridUnsafe.getLong(arr, off);
off += 8;
GridCacheVersion ver = new GridCacheVersion(topVer, nodeOrderDrId, globalTime, order);
if (verEx) {
- topVer = UNSAFE.getInt(arr, off);
+ topVer = GridUnsafe.getInt(arr, off);
off += 4;
- nodeOrderDrId = UNSAFE.getInt(arr, off);
+ nodeOrderDrId = GridUnsafe.getInt(arr, off);
off += 4;
- globalTime = UNSAFE.getLong(arr, off);
+ globalTime = GridUnsafe.getLong(arr, off);
off += 8;
- order = UNSAFE.getLong(arr, off);
+ order = GridUnsafe.getLong(arr, off);
ver = new GridCacheVersionEx(topVer, nodeOrderDrId, globalTime, order, ver);
}
@@ -9058,7 +9055,7 @@ public abstract class IgniteUtils {
public static byte[] copyMemory(long ptr, int size) {
byte[] res = new byte[size];
- UNSAFE.copyMemory(null, ptr, res, BYTE_ARRAY_DATA_OFFSET, size);
+ GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, size);
return res;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
index 00fa2c3..2f57e59 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataInput.java
@@ -26,41 +26,24 @@ import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
/**
* Data input based on {@code Unsafe} operations.
*/
public class GridUnsafeDataInput extends InputStream implements GridDataInput {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** */
private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
- /** */
- private static final long byteArrOff = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
- private static final long shortArrOff = UNSAFE.arrayBaseOffset(short[].class);
-
- /** */
- private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
- /** */
- private static final long longArrOff = UNSAFE.arrayBaseOffset(long[].class);
-
- /** */
- private static final long floatArrOff = UNSAFE.arrayBaseOffset(float[].class);
-
- /** */
- private static final long doubleArrOff = UNSAFE.arrayBaseOffset(double[].class);
-
- /** */
- private static final long charArrOff = UNSAFE.arrayBaseOffset(char[].class);
-
/** Maximum data block length. */
private static final int MAX_BLOCK_SIZE = 1024;
@@ -152,7 +135,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
if (maxOff < halfSize) {
byte[] newInBuf = new byte[halfSize]; // Shrink.
- UNSAFE.copyMemory(inBuf, byteArrOff, newInBuf, byteArrOff, off);
+ GridUnsafe.copyMemory(inBuf, BYTE_ARR_OFF, newInBuf, BYTE_ARR_OFF, off);
buf = inBuf = newInBuf;
}
@@ -208,7 +191,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
byte[] arr = new byte[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(arrSize), arr, byteArrOff, arrSize);
+ GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(arrSize), arr, BYTE_ARR_OFF, arrSize);
return arr;
}
@@ -223,7 +206,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
short[] arr = new short[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, shortArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getShortLE(buf, off);
+
+ off += 2;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, SHORT_ARR_OFF, bytesToCp);
return arr;
}
@@ -238,7 +231,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
int[] arr = new int[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, intArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getIntLE(buf, off);
+
+ off += 4;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, INT_ARR_OFF, bytesToCp);
return arr;
}
@@ -253,7 +256,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
double[] arr = new double[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, doubleArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getDoubleLE(buf, off);
+
+ off += 8;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, DOUBLE_ARR_OFF, bytesToCp);
return arr;
}
@@ -280,7 +293,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
char[] arr = new char[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, charArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getCharLE(buf, off);
+
+ off += 2;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, CHAR_ARR_OFF, bytesToCp);
return arr;
}
@@ -295,7 +318,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
long[] arr = new long[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, longArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getLongLE(buf, off);
+
+ off += 8;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, LONG_ARR_OFF, bytesToCp);
return arr;
}
@@ -310,7 +343,17 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
float[] arr = new float[arrSize];
- UNSAFE.copyMemory(buf, byteArrOff + offset(bytesToCp), arr, floatArrOff, bytesToCp);
+ long off = BYTE_ARR_OFF + offset(bytesToCp);
+
+ if (BIG_ENDIAN) {
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = GridUnsafe.getFloatLE(buf, off);
+
+ off += 4;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(buf, off, arr, FLOAT_ARR_OFF, bytesToCp);
return arr;
}
@@ -321,14 +364,14 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
fromStream(len);
- UNSAFE.copyMemory(buf, byteArrOff + offset(len), b, byteArrOff, len);
+ GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(len), b, BYTE_ARR_OFF, len);
}
/** {@inheritDoc} */
@Override public void readFully(byte[] b, int off, int len) throws IOException {
fromStream(len);
- UNSAFE.copyMemory(buf, byteArrOff + offset(len), b, byteArrOff + off, len);
+ GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(len), b, BYTE_ARR_OFF + off, len);
}
/** {@inheritDoc} */
@@ -345,14 +388,14 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
@Override public boolean readBoolean() throws IOException {
fromStream(1);
- return UNSAFE.getBoolean(buf, byteArrOff + offset(1));
+ return GridUnsafe.getBoolean(buf, BYTE_ARR_OFF + offset(1));
}
/** {@inheritDoc} */
@Override public byte readByte() throws IOException {
fromStream(1);
- return UNSAFE.getByte(buf, byteArrOff + offset(1));
+ return GridUnsafe.getByte(buf, BYTE_ARR_OFF + offset(1));
}
/** {@inheritDoc} */
@@ -364,7 +407,9 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
@Override public short readShort() throws IOException {
fromStream(2);
- return UNSAFE.getShort(buf, byteArrOff + offset(2));
+ long off = BYTE_ARR_OFF + offset(2);
+
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(buf, off) : GridUnsafe.getShort(buf, off);
}
/** {@inheritDoc} */
@@ -376,7 +421,9 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
@Override public char readChar() throws IOException {
fromStream(2);
- char v = UNSAFE.getChar(buf, byteArrOff + off);
+ long off = BYTE_ARR_OFF + this.off;
+
+ char v = BIG_ENDIAN ? GridUnsafe.getCharLE(buf, off) : GridUnsafe.getChar(buf, off);
offset(2);
@@ -387,28 +434,32 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
@Override public int readInt() throws IOException {
fromStream(4);
- return UNSAFE.getInt(buf, byteArrOff + offset(4));
+ long off = BYTE_ARR_OFF + offset(4);
+
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(buf, off) : GridUnsafe.getInt(buf, off);
}
/** {@inheritDoc} */
@Override public long readLong() throws IOException {
fromStream(8);
- return UNSAFE.getLong(buf, byteArrOff + offset(8));
+ long off = BYTE_ARR_OFF + offset(8);
+
+ return BIG_ENDIAN ? GridUnsafe.getLongLE(buf, off) : GridUnsafe.getLong(buf, off);
}
/** {@inheritDoc} */
@Override public float readFloat() throws IOException {
- fromStream(4);
+ int v = readInt();
- return UNSAFE.getFloat(buf, byteArrOff + offset(4));
+ return Float.intBitsToFloat(v);
}
/** {@inheritDoc} */
@Override public double readDouble() throws IOException {
- fromStream(8);
+ long v = readLong();
- return UNSAFE.getDouble(buf, byteArrOff + offset(8));
+ return Double.longBitsToDouble(v);
}
/** {@inheritDoc} */
@@ -437,7 +488,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
else {
int toRead = Math.min(len, max - this.off);
- UNSAFE.copyMemory(buf, byteArrOff + offset(toRead), b, byteArrOff + off, toRead);
+ GridUnsafe.copyMemory(buf, BYTE_ARR_OFF + offset(toRead), b, BYTE_ARR_OFF + off, toRead);
return toRead;
}
@@ -501,7 +552,7 @@ public class GridUnsafeDataInput extends InputStream implements GridDataInput {
else {
// shift and refill buffer manually
if (avail > 0)
- UNSAFE.copyMemory(utfBuf, byteArrOff + pos, utfBuf, byteArrOff, avail);
+ GridUnsafe.copyMemory(utfBuf, BYTE_ARR_OFF + pos, utfBuf, BYTE_ARR_OFF, avail);
pos = 0;
end = (int)Math.min(MAX_BLOCK_SIZE, utfLen);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
index b7c82a6..c0fe0d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/io/GridUnsafeDataOutput.java
@@ -22,41 +22,24 @@ import java.io.OutputStream;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
/**
* Data output based on {@code Unsafe} operations.
*/
public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** */
private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
- /** */
- private static final long byteArrOff = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
- private static final long shortArrOff = UNSAFE.arrayBaseOffset(short[].class);
-
- /** */
- private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
- /** */
- private static final long longArrOff = UNSAFE.arrayBaseOffset(long[].class);
-
- /** */
- private static final long floatArrOff = UNSAFE.arrayBaseOffset(float[].class);
-
- /** */
- private static final long doubleArrOff = UNSAFE.arrayBaseOffset(double[].class);
-
- /** */
- private static final long charArrOff = UNSAFE.arrayBaseOffset(char[].class);
-
/** Length of char buffer (for writing strings). */
private static final int CHAR_BUF_SIZE = 256;
@@ -114,7 +97,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public byte[] array() {
byte[] bytes0 = new byte[off];
- UNSAFE.copyMemory(bytes, byteArrOff, bytes0, byteArrOff, off);
+ GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, bytes0, BYTE_ARR_OFF, off);
return bytes0;
}
@@ -147,7 +130,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
if (size > bytes.length) {
byte[] newBytes = new byte[size << 1]; // Grow.
- UNSAFE.copyMemory(bytes, byteArrOff, newBytes, byteArrOff, off);
+ GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, newBytes, BYTE_ARR_OFF, off);
bytes = newBytes;
}
@@ -157,7 +140,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
if (maxOff < halfSize) {
byte[] newBytes = new byte[halfSize]; // Shrink.
- UNSAFE.copyMemory(bytes, byteArrOff, newBytes, byteArrOff, off);
+ GridUnsafe.copyMemory(bytes, BYTE_ARR_OFF, newBytes, BYTE_ARR_OFF, off);
bytes = newBytes;
}
@@ -182,7 +165,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void write(byte[] b) throws IOException {
requestFreeSize(b.length);
- UNSAFE.copyMemory(b, byteArrOff, bytes, byteArrOff + off, b.length);
+ GridUnsafe.copyMemory(b, BYTE_ARR_OFF, bytes, BYTE_ARR_OFF + off, b.length);
onWrite(b.length);
}
@@ -191,7 +174,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void write(byte[] b, int off, int len) throws IOException {
requestFreeSize(len);
- UNSAFE.copyMemory(b, byteArrOff + off, bytes, byteArrOff + this.off, len);
+ GridUnsafe.copyMemory(b, BYTE_ARR_OFF + off, bytes, BYTE_ARR_OFF + this.off, len);
onWrite(len);
}
@@ -204,7 +187,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, doubleArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (double val : arr) {
+ GridUnsafe.putDoubleLE(bytes, off, val);
+
+ off += 8;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, DOUBLE_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -226,7 +219,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, charArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (char val : arr) {
+ GridUnsafe.putCharLE(bytes, off, val);
+
+ off += 2;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, CHAR_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -239,7 +242,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, longArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (long val : arr) {
+ GridUnsafe.putLongLE(bytes, off, val);
+
+ off += 8;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, LONG_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -252,7 +265,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, floatArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (float val : arr) {
+ GridUnsafe.putFloatLE(bytes, off, val);
+
+ off += 4;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, FLOAT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -270,7 +293,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(arr.length);
- UNSAFE.copyMemory(arr, byteArrOff, bytes, byteArrOff + off, arr.length);
+ GridUnsafe.copyMemory(arr, BYTE_ARR_OFF, bytes, BYTE_ARR_OFF + off, arr.length);
onWrite(arr.length);
}
@@ -283,7 +306,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, shortArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (short val : arr) {
+ GridUnsafe.putShortLE(bytes, off, val);
+
+ off += 2;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, SHORT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -296,7 +329,17 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
requestFreeSize(bytesToCp);
- UNSAFE.copyMemory(arr, intArrOff, bytes, byteArrOff + off, bytesToCp);
+ if (BIG_ENDIAN) {
+ long off = BYTE_ARR_OFF + this.off;
+
+ for (int val : arr) {
+ GridUnsafe.putIntLE(bytes, off, val);
+
+ off += 4;
+ }
+ }
+ else
+ GridUnsafe.copyMemory(arr, INT_ARR_OFF, bytes, BYTE_ARR_OFF + off, bytesToCp);
onWrite(bytesToCp);
}
@@ -310,7 +353,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeBoolean(boolean v) throws IOException {
requestFreeSize(1);
- UNSAFE.putBoolean(bytes, byteArrOff + off, v);
+ GridUnsafe.putBoolean(bytes, BYTE_ARR_OFF + off, v);
onWrite(1);
}
@@ -319,7 +362,7 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeByte(int v) throws IOException {
requestFreeSize(1);
- UNSAFE.putByte(bytes, byteArrOff + off, (byte)v);
+ GridUnsafe.putByte(bytes, BYTE_ARR_OFF + off, (byte)v);
onWrite(1);
}
@@ -328,7 +371,14 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeShort(int v) throws IOException {
requestFreeSize(2);
- UNSAFE.putShort(bytes, byteArrOff + off, (short)v);
+ short val = (short)v;
+
+ long off = BYTE_ARR_OFF + this.off;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(bytes, off, val);
+ else
+ GridUnsafe.putShort(bytes, off, val);
onWrite(2);
}
@@ -337,7 +387,14 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeChar(int v) throws IOException {
requestFreeSize(2);
- UNSAFE.putChar(bytes, byteArrOff + off, (char)v);
+ char val = (char)v;
+
+ long off = BYTE_ARR_OFF + this.off;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(bytes, off, val);
+ else
+ GridUnsafe.putChar(bytes, off, val);
onWrite(2);
}
@@ -346,7 +403,12 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeInt(int v) throws IOException {
requestFreeSize(4);
- UNSAFE.putInt(bytes, byteArrOff + off, v);
+ long off = BYTE_ARR_OFF + this.off;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(bytes, off, v);
+ else
+ GridUnsafe.putInt(bytes, off, v);
onWrite(4);
}
@@ -355,27 +417,28 @@ public class GridUnsafeDataOutput extends OutputStream implements GridDataOutput
@Override public void writeLong(long v) throws IOException {
requestFreeSize(8);
- UNSAFE.putLong(bytes, byteArrOff + off, v);
+ long off = BYTE_ARR_OFF + this.off;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(bytes, off, v);
+ else
+ GridUnsafe.putLong(bytes, off, v);
onWrite(8);
}
/** {@inheritDoc} */
@Override public void writeFloat(float v) throws IOException {
- requestFreeSize(4);
+ int val = Float.floatToIntBits(v);
- UNSAFE.putFloat(bytes, byteArrOff + off, v);
-
- onWrite(4);
+ writeInt(val);
}
/** {@inheritDoc} */
@Override public void writeDouble(double v) throws IOException {
- requestFreeSize(8);
-
- UNSAFE.putDouble(bytes, byteArrOff + off, v);
+ long val = Double.doubleToLongBits(v);
- onWrite(8);
+ writeLong(val);
}
/** {@inheritDoc} */
[22/50] [abbrv] ignite git commit: IGNITE-2541: Fixed potential NPE
in GridCacheUpdateAtomicResult caused by unsafe [long -> Long -> long]
transitions.
Posted by vo...@apache.org.
IGNITE-2541: Fixed potential NPE in GridCacheUpdateAtomicResult caused by unsafe [long -> Long -> long] transitions.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/10a2b7a1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/10a2b7a1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/10a2b7a1
Branch: refs/heads/ignite-1786
Commit: 10a2b7a18de3d9e0cb3fdf147956c127fa4d4d2b
Parents: 74d9d05
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Feb 4 09:41:26 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 4 09:41:26 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/cache/GridCacheMapEntry.java | 4 ++--
.../internal/processors/cache/GridCacheUpdateAtomicResult.java | 4 ++--
.../cache/distributed/dht/atomic/GridDhtAtomicUpdateFuture.java | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/10a2b7a1/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 64cfd01..ae40295 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
@@ -2135,7 +2135,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
null,
null,
false,
- updateCntr0 == null ? 0 : updateCntr);
+ updateCntr0 == null ? 0 : updateCntr0);
}
}
else
@@ -2431,7 +2431,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
enqueueVer,
conflictCtx,
true,
- updateCntr0);
+ updateCntr0 == null ? 0 : updateCntr0);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/10a2b7a1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
index 9df476e..2355b7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
@@ -58,7 +58,7 @@ public class GridCacheUpdateAtomicResult {
private final boolean sndToDht;
/** */
- private final Long updateCntr;
+ private final long updateCntr;
/** Value computed by entry processor. */
private IgniteBiTuple<Object, Exception> res;
@@ -137,7 +137,7 @@ public class GridCacheUpdateAtomicResult {
/**
* @return Partition update index.
*/
- public Long updateCounter() {
+ public long updateCounter() {
return updateCntr;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/10a2b7a1/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 e31af19..06c8441 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
@@ -225,7 +225,7 @@ public class GridDhtAtomicUpdateFuture extends GridFutureAdapter<Void>
@Nullable GridCacheVersion conflictVer,
boolean addPrevVal,
@Nullable CacheObject prevVal,
- @Nullable Long updateCntr) {
+ long updateCntr) {
AffinityTopologyVersion topVer = updateReq.topologyVersion();
Collection<ClusterNode> dhtNodes = cctx.dht().topology().nodes(entry.partition(), topVer);
[16/50] [abbrv] ignite git commit: Updated CacheInterceptor JavaDoc
Posted by vo...@apache.org.
Updated CacheInterceptor JavaDoc
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e6acce66
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e6acce66
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e6acce66
Branch: refs/heads/ignite-1786
Commit: e6acce66d84b0148aa6c4a49541ce9907d064d47
Parents: 57194e2
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Feb 2 16:40:44 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Feb 2 16:40:44 2016 -0800
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/cache/CacheInterceptor.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e6acce66/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
index 103fe57..ffb3c2b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
@@ -63,6 +63,11 @@ public interface CacheInterceptor<K, V> extends Serializable {
* from sensitive synchronization blocks.
* <p>
* This method should not throw any exception.
+ * <p>
+ * <b>IMPORTANT:</b> for this method to take affect, {@code newVal} and
+ * the returned value have to be different instances. I.e., you should
+ * not mutate {@code newVal} directly, but instead create a copy, update
+ * it and then return from the interceptor.
*
* @param entry Old entry. If {@link CacheConfiguration#isCopyOnRead()} is {@code true}, then is copy.
* @param newVal New value.
[08/50] [abbrv] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by vo...@apache.org.
IGNITE-1906: .NET: Implemented programmatic configuration.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee20f1d9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee20f1d9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee20f1d9
Branch: refs/heads/ignite-1786
Commit: ee20f1d9fb94f792d0b62097499c7c3f976ff6f5
Parents: 28a5247
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Tue Feb 2 16:19:55 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Tue Feb 2 16:19:55 2016 +0300
----------------------------------------------------------------------
.gitignore | 1 +
.../internal/binary/GridBinaryMarshaller.java | 23 +-
.../processors/cache/GridCacheProcessor.java | 43 +-
.../processors/platform/PlatformIgnition.java | 6 +-
.../platform/PlatformNoopProcessor.java | 15 +
.../processors/platform/PlatformProcessor.java | 25 +
.../platform/PlatformProcessorImpl.java | 34 +-
.../platform/cache/PlatformCache.java | 16 +-
.../dotnet/PlatformDotNetCacheStore.java | 39 +-
.../PlatformDotNetConfigurationClosure.java | 50 +-
.../utils/PlatformConfigurationUtils.java | 621 +++++++++++++++++++
.../platform/utils/PlatformUtils.java | 52 +-
.../PlatformDotNetCacheStoreFactoryNative.java | 58 ++
.../cpp/common/include/ignite/common/exports.h | 3 +
.../cpp/common/include/ignite/common/java.h | 9 +
.../platforms/cpp/common/project/vs/module.def | 5 +-
modules/platforms/cpp/common/src/exports.cpp | 12 +
modules/platforms/cpp/common/src/java.cpp | 44 ++
.../Apache.Ignite.Core.Tests.csproj | 3 +
.../Binary/BinarySelfTest.cs | 9 +
.../Cache/CacheAbstractTest.cs | 2 +-
.../Cache/CacheAffinityTest.cs | 2 +-
.../Cache/CacheConfigurationTest.cs | 538 ++++++++++++++++
.../Cache/CacheDynamicStartTest.cs | 4 +-
.../Cache/CacheTestAsyncWrapper.cs | 7 +
.../Query/CacheQueriesCodeConfigurationTest.cs | 295 +++++++++
.../Cache/Query/CacheQueriesTest.cs | 2 +-
.../Continuous/ContinuousQueryAbstractTest.cs | 2 +-
.../Cache/Store/CacheStoreSessionTest.cs | 2 +-
.../Cache/Store/CacheStoreTest.cs | 23 +-
.../Dataload/DataStreamerTest.cs | 4 +-
.../Apache.Ignite.Core.Tests/ExceptionsTest.cs | 2 +-
.../IgniteConfigurationTest.cs | 367 +++++++++++
.../Apache.Ignite.Core.Tests/MarshallerTest.cs | 4 +-
.../SerializationTest.cs | 2 +-
.../Apache.Ignite.Core.Tests/TestRunner.cs | 5 +-
.../Apache.Ignite.Core.csproj | 29 +-
.../Binary/BinaryConfiguration.cs | 27 +-
.../Configuration/CacheAtomicWriteOrderMode.cs | 43 ++
.../Cache/Configuration/CacheAtomicityMode.cs | 54 ++
.../Cache/Configuration/CacheConfiguration.cs | 601 ++++++++++++++++++
.../Cache/Configuration/CacheMemoryMode.cs | 60 ++
.../Cache/Configuration/CacheMode.cs | 52 ++
.../Cache/Configuration/CacheRebalanceMode.cs | 51 ++
.../CacheWriteSynchronizationMode.cs | 45 ++
.../Cache/Configuration/QueryAlias.cs | 59 ++
.../Cache/Configuration/QueryEntity.cs | 401 ++++++++++++
.../Cache/Configuration/QueryField.cs | 109 ++++
.../Cache/Configuration/QueryIndex.cs | 137 ++++
.../Cache/Configuration/QueryIndexField.cs | 66 ++
.../Cache/Configuration/QueryIndexType.cs | 40 ++
.../Configuration/QuerySqlFieldAttribute.cs | 60 ++
.../Configuration/QueryTextFieldAttribute.cs | 36 ++
.../dotnet/Apache.Ignite.Core/Cache/ICache.cs | 6 +
.../Apache.Ignite.Core/Common/IFactory.cs | 34 +
.../Discovery/IDiscoverySpi.cs | 32 +
.../Discovery/Tcp/ITcpDiscoveryIpFinder.cs | 34 +
.../Multicast/TcpDiscoveryMulticastIpFinder.cs | 133 ++++
.../Tcp/Static/TcpDiscoveryStaticIpFinder.cs | 84 +++
.../Discovery/Tcp/TcpDiscoveryIpFinderBase.cs | 78 +++
.../Discovery/Tcp/TcpDiscoverySpi.cs | 144 +++++
.../dotnet/Apache.Ignite.Core/IIgnite.cs | 29 +-
.../Apache.Ignite.Core/IgniteConfiguration.cs | 347 ++++++++++-
.../dotnet/Apache.Ignite.Core/Ignition.cs | 29 +-
.../Apache.Ignite.Core/Impl/Binary/Binary.cs | 3 -
.../Impl/Binary/BinaryReaderExtensions.cs | 19 +
.../Apache.Ignite.Core/Impl/Binary/JavaTypes.cs | 92 +++
.../Impl/Binary/Marshaller.cs | 8 +-
.../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs | 9 +-
.../Apache.Ignite.Core/Impl/Cache/CacheOp.cs | 3 +-
.../Impl/Cache/Store/CacheStore.cs | 20 +-
.../dotnet/Apache.Ignite.Core/Impl/Ignite.cs | 48 ++
.../Impl/IgniteConfigurationEx.cs | 57 --
.../Apache.Ignite.Core/Impl/IgniteManager.cs | 5 +-
.../Apache.Ignite.Core/Impl/IgniteProxy.cs | 18 +-
.../Apache.Ignite.Core/Impl/IgniteUtils.cs | 2 +-
.../Impl/Memory/PlatformRawMemory.cs | 2 +-
.../Impl/Transactions/TransactionsImpl.cs | 2 +-
.../Impl/Unmanaged/IgniteJniNativeMethods.cs | 11 +-
.../Impl/Unmanaged/UnmanagedUtils.cs | 22 +-
parent/pom.xml | 1 +
81 files changed, 5213 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index ef12f3a..e4e061c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ git-patch-prop-local.sh
*.vcxproj.user
*.sdf
*.opensdf
+*.opendb
**/cpp/**/vs/x64/
**/cpp/**/vs/Win32/
**/dotnet/**/obj/
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index da43558..8e138fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -299,6 +299,15 @@ public class GridBinaryMarshaller {
/**
* Push binary context and return the old one.
*
+ * @return Old binary context.
+ */
+ public BinaryContext pushContext() {
+ return pushContext(ctx);
+ }
+
+ /**
+ * Push binary context and return the old one.
+ *
* @param ctx Binary context.
* @return Old binary context.
*/
@@ -315,11 +324,23 @@ public class GridBinaryMarshaller {
*
* @param oldCtx Old binary context.
*/
- private static void popContext(@Nullable BinaryContext oldCtx) {
+ public static void popContext(@Nullable BinaryContext oldCtx) {
BINARY_CTX.set(oldCtx);
}
/**
+ * Creates a reader.
+ *
+ * @param stream Stream.
+ * @return Reader.
+ */
+ public BinaryReaderExImpl reader(BinaryInputStream stream) {
+ assert stream != null;
+
+ return new BinaryReaderExImpl(ctx, stream, null);
+ }
+
+ /**
* Whether object must be deserialized anyway. I.e. it cannot be converted to BinaryObject.
*
* @param obj Object.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 26d3d4f..5acad6c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -69,10 +69,13 @@ import org.apache.ignite.internal.IgniteComponentType;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.IgniteTransactionsEx;
+import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -94,6 +97,7 @@ import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTransactionsImpl;
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.F0;
@@ -3409,23 +3413,38 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (val == null)
return null;
- if (val.getCacheStoreFactory() != null) {
+ IgniteCacheObjectProcessor objProc = ctx.cacheObjects();
+ BinaryContext oldCtx = null;
+
+ if (objProc instanceof CacheObjectBinaryProcessorImpl) {
+ GridBinaryMarshaller binMarsh = ((CacheObjectBinaryProcessorImpl)objProc).marshaller();
+
+ oldCtx = binMarsh == null ? null : binMarsh.pushContext();
+ }
+
+ try {
+ if (val.getCacheStoreFactory() != null) {
+ try {
+ marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
+ val.getCacheStoreFactory().getClass().getClassLoader());
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteCheckedException("Failed to validate cache configuration. " +
+ "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ }
+ }
+
try {
- marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
- val.getCacheStoreFactory().getClass().getClassLoader());
+ return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
}
catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration. " +
- "Cache store factory is not serializable. Cache name: " + U.maskName(val.getName()), e);
+ throw new IgniteCheckedException("Failed to validate cache configuration " +
+ "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
}
}
-
- try {
- return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
- }
- catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to validate cache configuration " +
- "(make sure all objects in cache configuration are serializable): " + U.maskName(val.getName()), e);
+ finally {
+ if (objProc instanceof CacheObjectBinaryProcessorImpl)
+ GridBinaryMarshaller.popContext(oldCtx);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
index e642b2d..d25acfc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformIgnition.java
@@ -142,9 +142,11 @@ public class PlatformIgnition {
* @return Configuration.
*/
private static IgniteConfiguration configuration(@Nullable String springCfgPath) {
+ if (springCfgPath == null)
+ return new IgniteConfiguration();
+
try {
- URL url = springCfgPath == null ? U.resolveIgniteUrl(IgnitionEx.DFLT_CFG) :
- U.resolveSpringUrl(springCfgPath);
+ URL url = U.resolveSpringUrl(springCfgPath);
IgniteBiTuple<IgniteConfiguration, GridSpringResourceContext> t = IgnitionEx.loadConfiguration(url);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 fb28008..b25e32e 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
@@ -74,6 +74,16 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
}
/** {@inheritDoc} */
+ @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
// No-op.
}
@@ -133,4 +143,9 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
@Override public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException {
return null;
}
+
+ /** {@inheritDoc} */
+ @Override public void getIgniteConfiguration(long memPtr) {
+ // No-op.
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 8e684e3..b59d93d 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
@@ -90,6 +90,24 @@ public interface PlatformProcessor extends GridProcessor {
public PlatformTarget getOrCreateCache(@Nullable String name) throws IgniteCheckedException;
/**
+ * Create cache.
+ *
+ * @param memPtr Stream with cache config.
+ * @return Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+ /**
+ * Get or create cache.
+ *
+ * @param memPtr Stream with cache config.
+ * @return Cache.
+ * @throws IgniteCheckedException If failed.
+ */
+ public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException;
+
+ /**
* Destroy dynamically created cache.
*
* @param name Cache name.
@@ -188,4 +206,11 @@ public interface PlatformProcessor extends GridProcessor {
* @throws IgniteException
*/
public PlatformTarget atomicLong(String name, long initVal, boolean create) throws IgniteException;
+
+ /**
+ * Gets the configuration of the current Ignite instance.
+ *
+ * @param memPtr Stream to write data to.
+ */
+ public void getIgniteConfiguration(long memPtr);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 dc6e0df..4ed8c25 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
@@ -22,11 +22,12 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteComputeImpl;
+import org.apache.ignite.internal.binary.*;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
-import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.processors.GridProcessorAdapter;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.datastreamer.DataStreamerImpl;
@@ -45,6 +46,7 @@ import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStrea
import org.apache.ignite.internal.processors.platform.messaging.PlatformMessaging;
import org.apache.ignite.internal.processors.platform.services.PlatformServices;
import org.apache.ignite.internal.processors.platform.transactions.PlatformTransactions;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -244,6 +246,26 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
}
/** {@inheritDoc} */
+ @Override public PlatformTarget createCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+ CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+ IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().createCache(cfg);
+
+ return new PlatformCache(platformCtx, cache.keepBinary(), false);
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformTarget getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
+ BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+ CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
+
+ IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg);
+
+ return new PlatformCache(platformCtx, cache.keepBinary(), false);
+ }
+
+ /** {@inheritDoc} */
@Override public void destroyCache(@Nullable String name) throws IgniteCheckedException {
ctx.grid().destroyCache(name);
}
@@ -338,6 +360,16 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
return new PlatformAtomicLong(platformCtx, atomicLong);
}
+ /** {@inheritDoc} */
+ @Override public void getIgniteConfiguration(long memPtr) {
+ PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
+ BinaryRawWriterEx writer = platformCtx.writer(stream);
+
+ PlatformConfigurationUtils.writeIgniteConfiguration(writer, ignite().configuration());
+
+ stream.synchronize();
+ }
+
/**
* Internal store initialization routine.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
index 8e7c51d..37fd335 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cache/PlatformCache.java
@@ -28,6 +28,7 @@ import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlFieldsQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.TextQuery;
+import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
@@ -41,6 +42,7 @@ import org.apache.ignite.internal.processors.platform.PlatformNativeException;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformContinuousQuery;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformFieldsQueryCursor;
import org.apache.ignite.internal.processors.platform.cache.query.PlatformQueryCursor;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.GridConcurrentFactory;
@@ -178,6 +180,9 @@ public class PlatformCache extends PlatformAbstractTarget {
/** */
public static final int OP_REPLACE_3 = 38;
+ /** */
+ public static final int OP_GET_CONFIG = 39;
+
/** Underlying JCache. */
private final IgniteCacheProxy cache;
@@ -516,6 +521,14 @@ public class PlatformCache extends PlatformAbstractTarget {
break;
+ case OP_GET_CONFIG:
+ CacheConfiguration ccfg = ((IgniteCache<Object, Object>)cache).
+ getConfiguration(CacheConfiguration.class);
+
+ PlatformConfigurationUtils.writeCacheConfiguration(writer, ccfg);
+
+ break;
+
default:
super.processOutStream(type, writer);
}
@@ -705,8 +718,7 @@ public class PlatformCache extends PlatformAbstractTarget {
}
/**
- * Clears the contents of the cache, without notifying listeners or
- * {@ignitelink javax.cache.integration.CacheWriter}s.
+ * Clears the contents of the cache, without notifying listeners or CacheWriters.
*
* @throws IllegalStateException if the cache is closed.
* @throws javax.cache.CacheException if there is a problem during the clear
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
index 47b1110..45d9208 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java
@@ -29,11 +29,8 @@ import org.apache.ignite.internal.processors.platform.cache.store.PlatformCacheS
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
-import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.lang.IgniteInClosureX;
-import org.apache.ignite.internal.util.typedef.C1;
-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.apache.ignite.lang.IgniteBiInClosure;
@@ -43,13 +40,9 @@ import org.jetbrains.annotations.Nullable;
import javax.cache.Cache;
import javax.cache.integration.CacheLoaderException;
import javax.cache.integration.CacheWriterException;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Set;
/**
* Wrapper for .NET cache store implementations.
@@ -102,6 +95,9 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
/** Properties. */
private Map<String, ?> props;
+ /** Native factory. */
+ private final Object nativeFactory;
+
/** Interop processor. */
protected PlatformContext platformCtx;
@@ -109,6 +105,22 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
protected long ptr;
/**
+ * Default ctor.
+ */
+ public PlatformDotNetCacheStore() {
+ nativeFactory = null;
+ }
+
+ /**
+ * Native factory ctor.
+ */
+ public PlatformDotNetCacheStore(Object nativeFactory) {
+ assert nativeFactory != null;
+
+ this.nativeFactory = nativeFactory;
+ }
+
+ /**
* Gets .NET class name.
*
* @return .NET class name.
@@ -175,7 +187,7 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
writer.writeByte(OP_LOAD_ALL);
writer.writeLong(session());
writer.writeString(ses.cacheName());
- writer.writeCollection((Collection) keys);
+ writer.writeCollection((Collection)keys);
}
}, new LoadAllCallback<>(platformCtx, loaded));
@@ -305,7 +317,8 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
* @throws org.apache.ignite.IgniteCheckedException
*/
public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException {
- A.notNull(typName, "typName");
+ A.ensure(typName != null || nativeFactory != null,
+ "Either typName or nativeFactory must be set in PlatformDotNetCacheStore");
platformCtx = PlatformUtils.platformContext(ctx.grid());
@@ -329,9 +342,13 @@ public class PlatformDotNetCacheStore<K, V> implements CacheStore<K, V>, Platfor
* @param convertBinary Convert binary flag.
*/
protected void write(BinaryRawWriterEx writer, boolean convertBinary) {
- writer.writeString(typName);
writer.writeBoolean(convertBinary);
- writer.writeMap(props);
+ writer.writeObjectDetached(nativeFactory);
+
+ if (nativeFactory == null) {
+ writer.writeString(typName);
+ writer.writeMap(props);
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
index 6b9b441..8728d77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java
@@ -19,31 +19,28 @@ package org.apache.ignite.internal.processors.platform.dotnet;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
-import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryBasicIdMapper;
-import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
-import org.apache.ignite.internal.MarshallerContextImpl;
-import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.BinaryReaderExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure;
import org.apache.ignite.internal.processors.platform.lifecycle.PlatformLifecycleBean;
-import org.apache.ignite.internal.processors.platform.memory.PlatformInputStream;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemory;
import org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManagerImpl;
import org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream;
+import org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lifecycle.LifecycleBean;
-import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.platform.dotnet.PlatformDotNetLifecycleBean;
import java.util.ArrayList;
@@ -177,15 +174,16 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
*/
@SuppressWarnings("ConstantConditions")
private void prepare(IgniteConfiguration igniteCfg, PlatformDotNetConfigurationEx interopCfg) {
- this.cfg = igniteCfg;
+ cfg = igniteCfg;
try (PlatformMemory outMem = memMgr.allocate()) {
try (PlatformMemory inMem = memMgr.allocate()) {
PlatformOutputStream out = outMem.output();
- BinaryRawWriterEx writer = marshaller().writer(out);
+ GridBinaryMarshaller marshaller = PlatformUtils.marshaller();
+ BinaryRawWriterEx writer = marshaller.writer(out);
- PlatformUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
+ PlatformConfigurationUtils.writeDotNetConfiguration(writer, interopCfg.unwrap());
List<PlatformDotNetLifecycleBean> beans = beans(igniteCfg);
@@ -201,7 +199,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
gate.extensionCallbackInLongLongOutLong(
PlatformUtils.OP_PREPARE_DOT_NET, outMem.pointer(), inMem.pointer());
- processPrepareResult(inMem.input());
+ processPrepareResult(marshaller.reader(inMem.input()));
}
}
}
@@ -211,9 +209,11 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
*
* @param in Input stream.
*/
- private void processPrepareResult(PlatformInputStream in) {
+ private void processPrepareResult(BinaryReaderExImpl in) {
assert cfg != null;
+ PlatformConfigurationUtils.readIgniteConfiguration(in, cfg);
+
List<PlatformDotNetLifecycleBean> beans = beans(cfg);
List<PlatformLifecycleBean> newBeans = new ArrayList<>();
@@ -265,28 +265,4 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
return res;
}
-
- /**
- * Create binary marshaller.
- *
- * @return Marshaller.
- */
- @SuppressWarnings("deprecation")
- private static GridBinaryMarshaller marshaller() {
- try {
- BinaryContext ctx =
- new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
-
- BinaryMarshaller marsh = new BinaryMarshaller();
-
- marsh.setContext(new MarshallerContextImpl(null));
-
- ctx.configure(marsh, new IgniteConfiguration());
-
- return new GridBinaryMarshaller(ctx);
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
new file mode 100644
index 0000000..32ab812
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -0,0 +1,621 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.utils;
+
+import org.apache.ignite.binary.BinaryRawReader;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.cache.CacheAtomicWriteOrderMode;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMemoryMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.*;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.platform.dotnet.PlatformDotNetCacheStoreFactoryNative;
+import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.spi.discovery.DiscoverySpi;
+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.multicast.TcpDiscoveryMulticastIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+
+import java.lang.management.ManagementFactory;
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Configuration utils.
+ */
+@SuppressWarnings("unchecked") public class PlatformConfigurationUtils {
+ /**
+ * Write .Net configuration to the stream.
+ *
+ * @param writer Writer.
+ * @param cfg Configuration.
+ */
+ public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
+ // 1. Write assemblies.
+ PlatformUtils.writeNullableCollection(writer, cfg.getAssemblies());
+
+ PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+
+ if (binaryCfg != null) {
+ writer.writeBoolean(true);
+
+ PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
+ new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
+ @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
+ writer.writeString(typ.getTypeName());
+ writer.writeString(typ.getNameMapper());
+ writer.writeString(typ.getIdMapper());
+ writer.writeString(typ.getSerializer());
+ writer.writeString(typ.getAffinityKeyFieldName());
+ writer.writeObject(typ.getKeepDeserialized());
+ writer.writeBoolean(typ.isEnum());
+ }
+ });
+
+ PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypes());
+ writer.writeString(binaryCfg.getDefaultNameMapper());
+ writer.writeString(binaryCfg.getDefaultIdMapper());
+ writer.writeString(binaryCfg.getDefaultSerializer());
+ writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+ }
+ else
+ writer.writeBoolean(false);
+ }
+
+ /**
+ * Reads cache configuration from a stream.
+ *
+ * @param in Stream.
+ * @return Cache configuration.
+ */
+ public static CacheConfiguration readCacheConfiguration(BinaryRawReaderEx in) {
+ assert in != null;
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(in.readInt()));
+ ccfg.setAtomicWriteOrderMode(CacheAtomicWriteOrderMode.fromOrdinal((byte)in.readInt()));
+ ccfg.setBackups(in.readInt());
+ ccfg.setCacheMode(CacheMode.fromOrdinal(in.readInt()));
+ ccfg.setCopyOnRead(in.readBoolean());
+ ccfg.setEagerTtl(in.readBoolean());
+ ccfg.setSwapEnabled(in.readBoolean());
+ ccfg.setEvictSynchronized(in.readBoolean());
+ ccfg.setEvictSynchronizedConcurrencyLevel(in.readInt());
+ ccfg.setEvictSynchronizedKeyBufferSize(in.readInt());
+ ccfg.setEvictSynchronizedTimeout(in.readLong());
+ ccfg.setInvalidate(in.readBoolean());
+ ccfg.setStoreKeepBinary(in.readBoolean());
+ ccfg.setLoadPreviousValue(in.readBoolean());
+ ccfg.setDefaultLockTimeout(in.readLong());
+ ccfg.setLongQueryWarningTimeout(in.readLong());
+ ccfg.setMaxConcurrentAsyncOperations(in.readInt());
+ ccfg.setEvictMaxOverflowRatio(in.readFloat());
+ ccfg.setMemoryMode(CacheMemoryMode.values()[in.readInt()]);
+ ccfg.setName(in.readString());
+ ccfg.setOffHeapMaxMemory(in.readLong());
+ ccfg.setReadFromBackup(in.readBoolean());
+ ccfg.setRebalanceBatchSize(in.readInt());
+ ccfg.setRebalanceDelay(in.readLong());
+ ccfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(in.readInt()));
+ ccfg.setRebalanceThrottle(in.readLong());
+ ccfg.setRebalanceTimeout(in.readLong());
+ ccfg.setSqlEscapeAll(in.readBoolean());
+ ccfg.setSqlOnheapRowCacheSize(in.readInt());
+ ccfg.setStartSize(in.readInt());
+ ccfg.setWriteBehindBatchSize(in.readInt());
+ ccfg.setWriteBehindEnabled(in.readBoolean());
+ ccfg.setWriteBehindFlushFrequency(in.readLong());
+ ccfg.setWriteBehindFlushSize(in.readInt());
+ ccfg.setWriteBehindFlushThreadCount(in.readInt());
+ ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(in.readInt()));
+
+ Object storeFactory = in.readObjectDetached();
+
+ if (storeFactory != null)
+ ccfg.setCacheStoreFactory(new PlatformDotNetCacheStoreFactoryNative(storeFactory));
+
+ int qryEntCnt = in.readInt();
+
+ if (qryEntCnt > 0) {
+ Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
+
+ for (int i = 0; i < qryEntCnt; i++)
+ entities.add(readQueryEntity(in));
+
+ ccfg.setQueryEntities(entities);
+ }
+
+ return ccfg;
+ }
+
+ /**
+ * Reads the query entity.
+ *
+ * @param in Stream.
+ * @return QueryEntity.
+ */
+ public static QueryEntity readQueryEntity(BinaryRawReader in) {
+ QueryEntity res = new QueryEntity();
+
+ res.setKeyType(in.readString());
+ res.setValueType(in.readString());
+
+ // Fields
+ int cnt = in.readInt();
+
+ if (cnt > 0) {
+ LinkedHashMap<String, String> fields = new LinkedHashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ fields.put(in.readString(), in.readString());
+
+ res.setFields(fields);
+ }
+
+ // Aliases
+ cnt = in.readInt();
+
+ if (cnt > 0) {
+ Map<String, String> aliases = new HashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ aliases.put(in.readString(), in.readString());
+
+ res.setAliases(aliases);
+ }
+
+ // Indexes
+ cnt = in.readInt();
+
+ if (cnt > 0) {
+ Collection<QueryIndex> indexes = new ArrayList<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ indexes.add(readQueryIndex(in));
+
+ res.setIndexes(indexes);
+ }
+
+ return res;
+ }
+
+ /**
+ * Reads the query index.
+ *
+ * @param in Reader.
+ * @return Query index.
+ */
+ public static QueryIndex readQueryIndex(BinaryRawReader in) {
+ QueryIndex res = new QueryIndex();
+
+ res.setName(in.readString());
+ res.setIndexType(QueryIndexType.values()[in.readByte()]);
+
+ int cnt = in.readInt();
+
+ if (cnt > 0) {
+ LinkedHashMap<String, Boolean> fields = new LinkedHashMap<>(cnt);
+
+ for (int i = 0; i < cnt; i++)
+ fields.put(in.readString(), !in.readBoolean());
+
+ res.setFields(fields);
+ }
+
+ return res;
+ }
+
+ /**
+ * Reads Ignite configuration.
+ * @param in Reader.
+ * @param cfg Configuration.
+ */
+ public static void readIgniteConfiguration(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+ if (!in.readBoolean())
+ return; // there is no config
+
+ cfg.setClientMode(in.readBoolean());
+ cfg.setIncludeEventTypes(in.readIntArray());
+ cfg.setMetricsExpireTime(in.readLong());
+ cfg.setMetricsHistorySize(in.readInt());
+ cfg.setMetricsLogFrequency(in.readLong());
+ cfg.setMetricsUpdateFrequency(in.readLong());
+ cfg.setNetworkSendRetryCount(in.readInt());
+ cfg.setNetworkSendRetryDelay(in.readLong());
+ cfg.setNetworkTimeout(in.readLong());
+ cfg.setWorkDirectory(in.readString());
+ cfg.setLocalHost(in.readString());
+
+ readCacheConfigurations(in, cfg);
+ readDiscoveryConfiguration(in, cfg);
+ }
+
+ /**
+ * Reads cache configurations from a stream and updates provided IgniteConfiguration.
+ *
+ * @param cfg IgniteConfiguration to update.
+ * @param in Reader.
+ */
+ public static void readCacheConfigurations(BinaryRawReaderEx in, IgniteConfiguration cfg) {
+ int len = in.readInt();
+
+ if (len == 0)
+ return;
+
+ List<CacheConfiguration> caches = new ArrayList<>();
+
+ for (int i = 0; i < len; i++)
+ caches.add(readCacheConfiguration(in));
+
+ CacheConfiguration[] oldCaches = cfg.getCacheConfiguration();
+ CacheConfiguration[] caches0 = caches.toArray(new CacheConfiguration[caches.size()]);
+
+ if (oldCaches == null)
+ cfg.setCacheConfiguration(caches0);
+ else {
+ CacheConfiguration[] mergedCaches = new CacheConfiguration[oldCaches.length + caches.size()];
+
+ System.arraycopy(oldCaches, 0, mergedCaches, 0, oldCaches.length);
+ System.arraycopy(caches0, 0, mergedCaches, oldCaches.length, caches.size());
+
+ cfg.setCacheConfiguration(mergedCaches);
+ }
+ }
+
+ /**
+ * Reads discovery configuration from a stream and updates provided IgniteConfiguration.
+ *
+ * @param cfg IgniteConfiguration to update.
+ * @param in Reader.
+ */
+ public static void readDiscoveryConfiguration(BinaryRawReader in, IgniteConfiguration cfg) {
+ boolean hasConfig = in.readBoolean();
+
+ if (!hasConfig)
+ return;
+
+ TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+ boolean hasIpFinder = in.readBoolean();
+
+ if (hasIpFinder) {
+ byte ipFinderType = in.readByte();
+
+ int addrCount = in.readInt();
+
+ ArrayList<String> addrs = null;
+
+ if (addrCount > 0) {
+ addrs = new ArrayList<>(addrCount);
+
+ for (int i = 0; i < addrCount; i++)
+ addrs.add(in.readString());
+ }
+
+ TcpDiscoveryVmIpFinder finder = null;
+ if (ipFinderType == 1) {
+ finder = new TcpDiscoveryVmIpFinder();
+ }
+ else if (ipFinderType == 2) {
+ TcpDiscoveryMulticastIpFinder finder0 = new TcpDiscoveryMulticastIpFinder();
+
+ finder0.setLocalAddress(in.readString());
+ finder0.setMulticastGroup(in.readString());
+ finder0.setMulticastPort(in.readInt());
+ finder0.setAddressRequestAttempts(in.readInt());
+ finder0.setResponseWaitTime(in.readInt());
+
+ boolean hasTtl = in.readBoolean();
+
+ if (hasTtl)
+ finder0.setTimeToLive(in.readInt());
+
+ finder = finder0;
+ }
+ else {
+ assert false;
+ }
+
+ finder.setAddresses(addrs);
+
+ disco.setIpFinder(finder);
+ }
+
+ disco.setSocketTimeout(in.readLong());
+ disco.setAckTimeout(in.readLong());
+ disco.setMaxAckTimeout(in.readLong());
+ disco.setNetworkTimeout(in.readLong());
+ disco.setJoinTimeout(in.readLong());
+
+ cfg.setDiscoverySpi(disco);
+ }
+
+ /**
+ * Writes cache configuration.
+ *
+ * @param writer Writer.
+ * @param ccfg Configuration.
+ */
+ public static void writeCacheConfiguration(BinaryRawWriter writer, CacheConfiguration ccfg) {
+ assert writer != null;
+ assert ccfg != null;
+
+ writer.writeInt(ccfg.getAtomicityMode() == null ?
+ CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE.ordinal() : ccfg.getAtomicityMode().ordinal());
+ writer.writeInt(ccfg.getAtomicWriteOrderMode() == null ? 0 : ccfg.getAtomicWriteOrderMode().ordinal());
+ writer.writeInt(ccfg.getBackups());
+ writer.writeInt(ccfg.getCacheMode() == null ?
+ CacheConfiguration.DFLT_CACHE_MODE.ordinal() : ccfg.getCacheMode().ordinal());
+ writer.writeBoolean(ccfg.isCopyOnRead());
+ writer.writeBoolean(ccfg.isEagerTtl());
+ writer.writeBoolean(ccfg.isSwapEnabled());
+ writer.writeBoolean(ccfg.isEvictSynchronized());
+ writer.writeInt(ccfg.getEvictSynchronizedConcurrencyLevel());
+ writer.writeInt(ccfg.getEvictSynchronizedKeyBufferSize());
+ writer.writeLong(ccfg.getEvictSynchronizedTimeout());
+ writer.writeBoolean(ccfg.isInvalidate());
+ writer.writeBoolean(ccfg.isStoreKeepBinary());
+ writer.writeBoolean(ccfg.isLoadPreviousValue());
+ writer.writeLong(ccfg.getDefaultLockTimeout());
+ writer.writeLong(ccfg.getLongQueryWarningTimeout());
+ writer.writeInt(ccfg.getMaxConcurrentAsyncOperations());
+ writer.writeFloat(ccfg.getEvictMaxOverflowRatio());
+ writer.writeInt(ccfg.getMemoryMode() == null ?
+ CacheConfiguration.DFLT_MEMORY_MODE.ordinal() : ccfg.getMemoryMode().ordinal());
+ writer.writeString(ccfg.getName());
+ writer.writeLong(ccfg.getOffHeapMaxMemory());
+ writer.writeBoolean(ccfg.isReadFromBackup());
+ writer.writeInt(ccfg.getRebalanceBatchSize());
+ writer.writeLong(ccfg.getRebalanceDelay());
+ writer.writeInt(ccfg.getRebalanceMode() == null ?
+ CacheConfiguration.DFLT_REBALANCE_MODE.ordinal() : ccfg.getRebalanceMode().ordinal());
+ writer.writeLong(ccfg.getRebalanceThrottle());
+ writer.writeLong(ccfg.getRebalanceTimeout());
+ writer.writeBoolean(ccfg.isSqlEscapeAll());
+ writer.writeInt(ccfg.getSqlOnheapRowCacheSize());
+ writer.writeInt(ccfg.getStartSize());
+ writer.writeInt(ccfg.getWriteBehindBatchSize());
+ writer.writeBoolean(ccfg.isWriteBehindEnabled());
+ writer.writeLong(ccfg.getWriteBehindFlushFrequency());
+ writer.writeInt(ccfg.getWriteBehindFlushSize());
+ writer.writeInt(ccfg.getWriteBehindFlushThreadCount());
+ writer.writeInt(ccfg.getWriteSynchronizationMode() == null ? 0 : ccfg.getWriteSynchronizationMode().ordinal());
+
+ if (ccfg.getCacheStoreFactory() instanceof PlatformDotNetCacheStoreFactoryNative)
+ writer.writeObject(((PlatformDotNetCacheStoreFactoryNative)ccfg.getCacheStoreFactory()).getNativeFactory());
+ else
+ writer.writeObject(null);
+
+ Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
+
+ if (qryEntities != null)
+ {
+ writer.writeInt(qryEntities.size());
+
+ for (QueryEntity e : qryEntities)
+ writeQueryEntity(writer, e);
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Write query entity.
+ *
+ * @param writer Writer.
+ * @param queryEntity Query entity.
+ */
+ private static void writeQueryEntity(BinaryRawWriter writer, QueryEntity queryEntity) {
+ assert queryEntity != null;
+
+ writer.writeString(queryEntity.getKeyType());
+ writer.writeString(queryEntity.getValueType());
+
+ // Fields
+ LinkedHashMap<String, String> fields = queryEntity.getFields();
+
+ if (fields != null) {
+ writer.writeInt(fields.size());
+
+ for (Map.Entry<String, String> field : fields.entrySet()) {
+ writer.writeString(field.getKey());
+ writer.writeString(field.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+
+ // Aliases
+ Map<String, String> aliases = queryEntity.getAliases();
+
+ if (aliases != null) {
+ writer.writeInt(aliases.size());
+
+ for (Map.Entry<String, String> alias : aliases.entrySet()) {
+ writer.writeString(alias.getKey());
+ writer.writeString(alias.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+
+ // Indexes
+ Collection<QueryIndex> indexes = queryEntity.getIndexes();
+
+ if (indexes != null) {
+ writer.writeInt(indexes.size());
+
+ for (QueryIndex index : indexes)
+ writeQueryIndex(writer, index);
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Writer query index.
+ *
+ * @param writer Writer.
+ * @param index Index.
+ */
+ private static void writeQueryIndex(BinaryRawWriter writer, QueryIndex index) {
+ assert index != null;
+
+ writer.writeString(index.getName());
+ writer.writeByte((byte)index.getIndexType().ordinal());
+
+ LinkedHashMap<String, Boolean> fields = index.getFields();
+
+ if (fields != null) {
+ writer.writeInt(fields.size());
+
+ for (Map.Entry<String, Boolean> field : fields.entrySet()) {
+ writer.writeString(field.getKey());
+ writer.writeBoolean(!field.getValue());
+ }
+ }
+ else
+ writer.writeInt(0);
+ }
+
+ /**
+ * Writes Ignite configuration.
+ *
+ * @param w Writer.
+ * @param cfg Configuration.
+ */
+ public static void writeIgniteConfiguration(BinaryRawWriter w, IgniteConfiguration cfg) {
+ assert w != null;
+ assert cfg != null;
+
+ w.writeBoolean(cfg.isClientMode());
+ w.writeIntArray(cfg.getIncludeEventTypes());
+ w.writeLong(cfg.getMetricsExpireTime());
+ w.writeInt(cfg.getMetricsHistorySize());
+ w.writeLong(cfg.getMetricsLogFrequency());
+ w.writeLong(cfg.getMetricsUpdateFrequency());
+ w.writeInt(cfg.getNetworkSendRetryCount());
+ w.writeLong(cfg.getNetworkSendRetryDelay());
+ w.writeLong(cfg.getNetworkTimeout());
+ w.writeString(cfg.getWorkDirectory());
+ w.writeString(cfg.getLocalHost());
+
+ CacheConfiguration[] cacheCfg = cfg.getCacheConfiguration();
+
+ if (cacheCfg != null) {
+ w.writeInt(cacheCfg.length);
+
+ for (CacheConfiguration ccfg : cacheCfg)
+ writeCacheConfiguration(w, ccfg);
+ }
+ else
+ w.writeInt(0);
+
+ writeDiscoveryConfiguration(w, cfg.getDiscoverySpi());
+
+ w.writeString(cfg.getIgniteHome());
+
+ w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getInit());
+ w.writeLong(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax());
+ }
+
+ /**
+ * Writes discovery configuration.
+ *
+ * @param w Writer.
+ * @param spi Disco.
+ */
+ private static void writeDiscoveryConfiguration(BinaryRawWriter w, DiscoverySpi spi) {
+ assert w != null;
+ assert spi != null;
+
+ if (!(spi instanceof TcpDiscoverySpi)) {
+ w.writeBoolean(false);
+ return;
+ }
+
+ w.writeBoolean(true);
+
+ TcpDiscoverySpi tcp = (TcpDiscoverySpi)spi;
+
+ TcpDiscoveryIpFinder finder = tcp.getIpFinder();
+
+ if (finder instanceof TcpDiscoveryVmIpFinder) {
+ w.writeBoolean(true);
+
+ boolean isMulticast = finder instanceof TcpDiscoveryMulticastIpFinder;
+
+ w.writeByte((byte)(isMulticast ? 2 : 1));
+
+ Collection<InetSocketAddress> addrs = finder.getRegisteredAddresses();
+
+ w.writeInt(addrs.size());
+
+ for (InetSocketAddress a : addrs)
+ w.writeString(a.toString());
+
+ if (isMulticast) {
+ TcpDiscoveryMulticastIpFinder multiFinder = (TcpDiscoveryMulticastIpFinder) finder;
+
+ w.writeString(multiFinder.getLocalAddress());
+ w.writeString(multiFinder.getMulticastGroup());
+ w.writeInt(multiFinder.getMulticastPort());
+ w.writeInt(multiFinder.getAddressRequestAttempts());
+ w.writeInt(multiFinder.getResponseWaitTime());
+
+ Integer ttl = multiFinder.getTimeToLive();
+ w.writeBoolean(ttl != null);
+
+ if (ttl != null)
+ w.writeInt(ttl);
+ }
+ }
+ else {
+ w.writeBoolean(false);
+ }
+
+ w.writeLong(tcp.getSocketTimeout());
+ w.writeLong(tcp.getAckTimeout());
+ w.writeLong(tcp.getMaxAckTimeout());
+ w.writeLong(tcp.getNetworkTimeout());
+ w.writeLong(tcp.getJoinTimeout());
+ }
+
+ /**
+ * Private constructor.
+ */
+ private PlatformConfigurationUtils() {
+ // No-op.
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
index 4a29637..d09b2c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java
@@ -22,10 +22,16 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CachePeekMode;
+import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.MarshallerContextImpl;
+import org.apache.ignite.internal.binary.BinaryContext;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.binary.BinaryNoopMetadataHandler;
import org.apache.ignite.internal.binary.BinaryRawReaderEx;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.processors.platform.PlatformContext;
import org.apache.ignite.internal.processors.platform.PlatformExtendedException;
import org.apache.ignite.internal.processors.platform.PlatformNativeException;
@@ -38,9 +44,7 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
-import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration;
+import org.apache.ignite.logger.NullLogger;
import org.jetbrains.annotations.Nullable;
import javax.cache.CacheException;
@@ -764,41 +768,27 @@ public class PlatformUtils {
}
/**
- * Write .Net configuration to the stream.
+ * Create binary marshaller.
*
- * @param writer Writer.
- * @param cfg Configuration.
+ * @return Marshaller.
*/
- public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
- // 1. Write assemblies.
- writeNullableCollection(writer, cfg.getAssemblies());
+ @SuppressWarnings("deprecation")
+ public static GridBinaryMarshaller marshaller() {
+ try {
+ BinaryContext ctx =
+ new BinaryContext(BinaryNoopMetadataHandler.instance(), new IgniteConfiguration(), new NullLogger());
- PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
+ BinaryMarshaller marsh = new BinaryMarshaller();
- if (binaryCfg != null) {
- writer.writeBoolean(true);
+ marsh.setContext(new MarshallerContextImpl(null));
- writeNullableCollection(writer, binaryCfg.getTypesConfiguration(),
- new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {
- @Override public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
- writer.writeString(typ.getTypeName());
- writer.writeString(typ.getNameMapper());
- writer.writeString(typ.getIdMapper());
- writer.writeString(typ.getSerializer());
- writer.writeString(typ.getAffinityKeyFieldName());
- writer.writeObject(typ.getKeepDeserialized());
- writer.writeBoolean(typ.isEnum());
- }
- });
+ ctx.configure(marsh, new IgniteConfiguration());
- writeNullableCollection(writer, binaryCfg.getTypes());
- writer.writeString(binaryCfg.getDefaultNameMapper());
- writer.writeString(binaryCfg.getDefaultIdMapper());
- writer.writeString(binaryCfg.getDefaultSerializer());
- writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
+ return new GridBinaryMarshaller(ctx);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
}
- else
- writer.writeBoolean(false);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
new file mode 100644
index 0000000..ec01483
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/platform/dotnet/PlatformDotNetCacheStoreFactoryNative.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.platform.dotnet;
+
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetCacheStore;
+
+import javax.cache.configuration.Factory;
+
+/**
+ * Cache store factory that wraps native factory object.
+ */
+public class PlatformDotNetCacheStoreFactoryNative implements Factory<PlatformDotNetCacheStore> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ private final Object nativeFactory;
+
+ /**
+ * Ctor.
+ *
+ * @param nativeFactory Native factory object.
+ */
+ public PlatformDotNetCacheStoreFactoryNative(Object nativeFactory) {
+ assert nativeFactory != null;
+
+ this.nativeFactory = nativeFactory;
+ }
+
+ /**
+ * Gets the wrapped factory object.
+ *
+ * @return Factory object.
+ */
+ public Object getNativeFactory() {
+ return nativeFactory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public PlatformDotNetCacheStore create() {
+ return new PlatformDotNetCacheStore(nativeFactory);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 67583ed..66f918f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -36,6 +36,8 @@ extern "C" {
void* IGNITE_CALL IgniteProcessorCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorCreateCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorGetOrCreateCache(gcj::JniContext* ctx, void* obj, char* name);
+ void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
+ void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr);
void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorAffinity(gcj::JniContext* ctx, void* obj, char* name);
void* IGNITE_CALL IgniteProcessorDataStreamer(gcj::JniContext* ctx, void* obj, char* name, bool keepPortable);
@@ -46,6 +48,7 @@ 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 IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr);
long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr);
void IGNITE_CALL IgniteTargetInStreamOutStream(gcj::JniContext* ctx, void* obj, int opType, long long inMemPtr, long long outMemPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 572f040..072a8ef 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -297,6 +297,8 @@ namespace ignite
jmethodID m_PlatformProcessor_cache;
jmethodID m_PlatformProcessor_createCache;
jmethodID m_PlatformProcessor_getOrCreateCache;
+ jmethodID m_PlatformProcessor_createCacheFromConfig;
+ jmethodID m_PlatformProcessor_getOrCreateCacheFromConfig;
jmethodID m_PlatformProcessor_destroyCache;
jmethodID m_PlatformProcessor_affinity;
jmethodID m_PlatformProcessor_dataStreamer;
@@ -308,6 +310,7 @@ namespace ignite
jmethodID m_PlatformProcessor_services;
jmethodID m_PlatformProcessor_extensions;
jmethodID m_PlatformProcessor_atomicLong;
+ jmethodID m_PlatformProcessor_getIgniteConfiguration;
jclass c_PlatformTarget;
jmethodID m_PlatformTarget_inStreamOutLong;
@@ -489,6 +492,10 @@ namespace ignite
jobject ProcessorCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
jobject ProcessorGetOrCreateCache(jobject obj, const char* name);
jobject ProcessorGetOrCreateCache(jobject obj, const char* name, JniErrorInfo* errInfo);
+ jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr);
+ jobject ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
+ jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr);
+ jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo);
void ProcessorDestroyCache(jobject obj, const char* name);
void ProcessorDestroyCache(jobject obj, const char* name, JniErrorInfo* errInfo);
jobject ProcessorAffinity(jobject obj, const char* name);
@@ -500,6 +507,7 @@ namespace ignite
jobject ProcessorServices(jobject obj, jobject prj);
jobject ProcessorExtensions(jobject obj);
jobject ProcessorAtomicLong(jobject obj, char* name, long long initVal, bool create);
+ void ProcessorGetIgniteConfiguration(jobject obj, long memPtr);
long long TargetInStreamOutLong(jobject obj, int type, long long memPtr, JniErrorInfo* errInfo = NULL);
void TargetInStreamOutStream(jobject obj, int opType, long long inMemPtr, long long outMemPtr, JniErrorInfo* errInfo = NULL);
@@ -618,6 +626,7 @@ namespace ignite
void ExceptionCheck(JNIEnv* env, JniErrorInfo* errInfo);
jobject LocalToGlobal(JNIEnv* env, jobject obj);
jobject ProcessorCache0(jobject proc, const char* name, jmethodID mthd, JniErrorInfo* errInfo);
+ jobject ProcessorCacheFromConfig0(jobject proc, long memPtr, jmethodID mthd, JniErrorInfo* errInfo);
};
JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 c947128..81df027 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -113,4 +113,7 @@ IgniteListenableCancel @110
IgniteListenableIsCancelled @111
IgniteTargetListenFutureAndGet @112
IgniteTargetListenFutureForOperationAndGet @113
-IgniteProcessorDestroyCache @114
\ No newline at end of file
+IgniteProcessorCreateCacheFromConfig @114
+IgniteProcessorGetOrCreateCacheFromConfig @115
+IgniteProcessorGetIgniteConfiguration @116
+IgniteProcessorDestroyCache @117
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 d4ffa7e..e9ec519 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -66,6 +66,14 @@ extern "C" {
return ctx->ProcessorGetOrCreateCache(static_cast<jobject>(obj), name);
}
+ void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+ }
+
+ void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorGetOrCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
+ }
+
void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name) {
ctx->ProcessorDestroyCache(static_cast<jobject>(obj), name);
}
@@ -106,6 +114,10 @@ extern "C" {
return ctx->ProcessorAtomicLong(static_cast<jobject>(obj), name, initVal, create);
}
+ void IGNITE_CALL IgniteProcessorGetIgniteConfiguration(gcj::JniContext* ctx, void* obj, long memPtr) {
+ return ctx->ProcessorGetIgniteConfiguration(static_cast<jobject>(obj), memPtr);
+ }
+
long long IGNITE_CALL IgniteTargetInStreamOutLong(gcj::JniContext* ctx, void* obj, int opType, long long memPtr) {
return ctx->TargetInStreamOutLong(static_cast<jobject>(obj), opType, memPtr);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 9e55742..e36c1e0 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -191,6 +191,8 @@ namespace ignite
JniMethod M_PLATFORM_PROCESSOR_CACHE = JniMethod("cache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE = JniMethod("createCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE = JniMethod("getOrCreateCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG = JniMethod("createCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+ JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG = JniMethod("getOrCreateCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_DESTROY_CACHE = JniMethod("destroyCache", "(Ljava/lang/String;)V", false);
JniMethod M_PLATFORM_PROCESSOR_AFFINITY = JniMethod("affinity", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
JniMethod M_PLATFORM_PROCESSOR_DATA_STREAMER = JniMethod("dataStreamer", "(Ljava/lang/String;Z)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
@@ -201,6 +203,7 @@ 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_GET_IGNITE_CONFIGURATION = JniMethod("getIgniteConfiguration", "(J)V", false);
const char* C_PLATFORM_TARGET = "org/apache/ignite/internal/processors/platform/PlatformTarget";
JniMethod M_PLATFORM_TARGET_IN_STREAM_OUT_LONG = JniMethod("inStreamOutLong", "(IJ)J", false);
@@ -636,6 +639,8 @@ namespace ignite
m_PlatformProcessor_cache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CACHE);
m_PlatformProcessor_createCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE);
m_PlatformProcessor_getOrCreateCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE);
+ m_PlatformProcessor_createCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG);
+ m_PlatformProcessor_getOrCreateCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG);
m_PlatformProcessor_destroyCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DESTROY_CACHE);
m_PlatformProcessor_affinity = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_AFFINITY);
m_PlatformProcessor_dataStreamer = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DATA_STREAMER);
@@ -647,6 +652,7 @@ 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_getIgniteConfiguration = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_IGNITE_CONFIGURATION);
c_PlatformTarget = FindClass(env, C_PLATFORM_TARGET);
m_PlatformTarget_inStreamOutLong = FindMethod(env, c_PlatformTarget, M_PLATFORM_TARGET_IN_STREAM_OUT_LONG);
@@ -1120,6 +1126,17 @@ namespace ignite
return LocalToGlobal(env, cache);
}
+ jobject JniContext::ProcessorCacheFromConfig0(jobject obj, long memPtr, jmethodID mthd, JniErrorInfo* errInfo)
+ {
+ JNIEnv* env = Attach();
+
+ jobject cache = env->CallObjectMethod(obj, mthd, memPtr);
+
+ ExceptionCheck(env, errInfo);
+
+ return LocalToGlobal(env, cache);
+ }
+
jobject JniContext::ProcessorCache(jobject obj, const char* name) {
return ProcessorCache(obj, name, NULL);
}
@@ -1164,6 +1181,24 @@ namespace ignite
ExceptionCheck(env, errInfo);
}
+ jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr) {
+ return ProcessorCreateCacheFromConfig(obj, memPtr, NULL);
+ }
+
+ jobject JniContext::ProcessorCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+ {
+ return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_createCacheFromConfig, errInfo);
+ }
+
+ jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr) {
+ return ProcessorGetOrCreateCacheFromConfig(obj, memPtr, NULL);
+ }
+
+ jobject JniContext::ProcessorGetOrCreateCacheFromConfig(jobject obj, long memPtr, JniErrorInfo* errInfo)
+ {
+ return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_getOrCreateCacheFromConfig, errInfo);
+ }
+
jobject JniContext::ProcessorAffinity(jobject obj, const char* name) {
JNIEnv* env = Attach();
@@ -1272,6 +1307,15 @@ namespace ignite
return LocalToGlobal(env, res);
}
+ void JniContext::ProcessorGetIgniteConfiguration(jobject obj, long memPtr)
+ {
+ JNIEnv* env = Attach();
+
+ env->CallVoidMethod(obj, jvm->GetMembers().m_PlatformProcessor_getIgniteConfiguration, memPtr);
+
+ ExceptionCheck(env);
+ }
+
long long JniContext::TargetInStreamOutLong(jobject obj, int opType, long long memPtr, JniErrorInfo* err) {
JNIEnv* env = Attach();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 5a1e176..481adfb 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
@@ -60,6 +60,7 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Cache\CacheConfigurationTest.cs" />
<Compile Include="Cache\CacheDynamicStartTest.cs" />
<Compile Include="Cache\CacheTestAsyncWrapper.cs" />
<Compile Include="Cache\CacheAbstractTest.cs" />
@@ -74,6 +75,7 @@
<Compile Include="Cache\CachePartitionedTest.cs" />
<Compile Include="Cache\CacheReplicatedAtomicTest.cs" />
<Compile Include="Cache\CacheReplicatedTest.cs" />
+ <Compile Include="Cache\Query\CacheQueriesCodeConfigurationTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAbstractTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicBackupTest.cs" />
<Compile Include="Cache\Query\Continuous\ContinuousQueryAtomicNoBackupTest.cs" />
@@ -113,6 +115,7 @@
<Compile Include="ExceptionsTest.cs" />
<Compile Include="ExecutableTest.cs" />
<Compile Include="FutureTest.cs" />
+ <Compile Include="IgniteConfigurationTest.cs" />
<Compile Include="IgniteTestBase.cs" />
<Compile Include="LifecycleTest.cs" />
<Compile Include="LoadDllTest.cs" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index 9232665..44db6f7 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -1341,6 +1341,15 @@ namespace Apache.Ignite.Core.Tests.Binary
}
}
+ [Test]
+ public void TestBinaryConfigurationValidation()
+ {
+ var cfg = new BinaryConfiguration(typeof (PropertyType)) {Types = new[] {"PropertyType"}};
+
+ // ReSharper disable once ObjectCreationAsStatement
+ Assert.Throws<BinaryObjectException>(() => new Marshaller(cfg));
+ }
+
private static void CheckKeepSerialized(BinaryConfiguration cfg, bool expKeep)
{
if (cfg.TypeConfigurations == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
index e57df6f..9f0528c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs
@@ -292,7 +292,7 @@ namespace Apache.Ignite.Core.Tests.Cache
public virtual void StartGrids() {
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
index 5a1af03..689804c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAffinityTest.cs
@@ -36,7 +36,7 @@ namespace Apache.Ignite.Core.Tests.Cache
{
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
cfg.JvmClasspath = TestUtils.CreateTestClasspath();
cfg.JvmOptions = TestUtils.TestJavaOptions();
[23/50] [abbrv] ignite git commit: IGNITE-2540: Removed unnecessary
ArrayList from GridNioServer.DirectNioClientWorker write processing methods.
Posted by vo...@apache.org.
IGNITE-2540: Removed unnecessary ArrayList from GridNioServer.DirectNioClientWorker write processing methods.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/afd3bc1e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/afd3bc1e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/afd3bc1e
Branch: refs/heads/ignite-1786
Commit: afd3bc1e3c249ae86071f0d15b41c6eedbdeb050
Parents: 10a2b7a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Feb 4 11:13:36 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 4 11:13:36 2016 +0300
----------------------------------------------------------------------
.../ignite/internal/util/nio/GridNioServer.java | 28 ++------------------
1 file changed, 2 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/afd3bc1e/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index 84c8157..c7679c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -980,8 +980,6 @@ public class GridNioServer<T> {
NioOperationFuture<?> req = ses.removeMeta(NIO_OPERATION.ordinal());
- List<NioOperationFuture<?>> doneFuts = null;
-
while (true) {
if (req == null) {
req = (NioOperationFuture<?>)ses.pollFuture();
@@ -1012,10 +1010,7 @@ public class GridNioServer<T> {
// Fill up as many messages as possible to write buffer.
while (finished) {
- if (doneFuts == null)
- doneFuts = new ArrayList<>();
-
- doneFuts.add(req);
+ req.onDone();
req = (NioOperationFuture<?>)ses.pollFuture();
@@ -1059,13 +1054,6 @@ public class GridNioServer<T> {
if (!skipWrite) {
int cnt = sockCh.write(buf);
- if (!F.isEmpty(doneFuts)) {
- for (int i = 0; i < doneFuts.size(); i++)
- doneFuts.get(i).onDone();
-
- doneFuts.clear();
- }
-
if (log.isTraceEnabled())
log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
@@ -1185,13 +1173,8 @@ public class GridNioServer<T> {
}
// Fill up as many messages as possible to write buffer.
- List<NioOperationFuture<?>> doneFuts = null;
-
while (finished) {
- if (doneFuts == null)
- doneFuts = new ArrayList<>();
-
- doneFuts.add(req);
+ req.onDone();
req = (NioOperationFuture<?>)ses.pollFuture();
@@ -1218,13 +1201,6 @@ public class GridNioServer<T> {
if (!skipWrite) {
int cnt = sockCh.write(buf);
- if (!F.isEmpty(doneFuts)) {
- for (int i = 0; i < doneFuts.size(); i++)
- doneFuts.get(i).onDone();
-
- doneFuts.clear();
- }
-
if (log.isTraceEnabled())
log.trace("Bytes sent [sockCh=" + sockCh + ", cnt=" + cnt + ']');
[06/50] [abbrv] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
new file mode 100644
index 0000000..b319be9
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -0,0 +1,601 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 MemberCanBePrivate.Global
+// ReSharper disable UnusedMember.Global
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Store;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Defines grid cache configuration.
+ /// </summary>
+ public class CacheConfiguration
+ {
+ /// <summary> Default size of rebalance thread pool. </summary>
+ public const int DefaultRebalanceThreadPoolSize = 2;
+
+ /// <summary> Default rebalance timeout.</summary>
+ public static readonly TimeSpan DefaultRebalanceTimeout = TimeSpan.FromMilliseconds(10000);
+
+ /// <summary> Time to wait between rebalance messages to avoid overloading CPU. </summary>
+ public static readonly TimeSpan DefaultRebalanceThrottle = TimeSpan.Zero;
+
+ /// <summary> Default number of backups. </summary>
+ public const int DefaultBackups = 0;
+
+ /// <summary> Default caching mode. </summary>
+ public const CacheMode DefaultCacheMode = CacheMode.Partitioned;
+
+ /// <summary> Default atomicity mode. </summary>
+ public const CacheAtomicityMode DefaultAtomicityMode = CacheAtomicityMode.Atomic;
+
+ /// <summary> Default lock timeout. </summary>
+ public static readonly TimeSpan DefaultLockTimeout = TimeSpan.Zero;
+
+ /// <summary> Initial default cache size. </summary>
+ public const int DefaultStartSize = 1500000;
+
+ /// <summary> Default cache size to use with eviction policy. </summary>
+ public const int DefaultCacheSize = 100000;
+
+ /// <summary> Default value for 'invalidate' flag that indicates if this is invalidation-based cache. </summary>
+ public const bool DefaultInvalidate = false;
+
+ /// <summary> Default rebalance mode for distributed cache. </summary>
+ public const CacheRebalanceMode DefaultRebalanceMode = CacheRebalanceMode.Async;
+
+ /// <summary> Default rebalance batch size in bytes. </summary>
+ public const int DefaultRebalanceBatchSize = 512*1024; // 512K
+
+ /// <summary> Default maximum eviction queue ratio. </summary>
+ public const float DefaultMaxEvictionOverflowRatio = 10;
+
+ /// <summary> Default eviction synchronized flag. </summary>
+ public const bool DefaultEvictSynchronized = false;
+
+ /// <summary> Default eviction key buffer size for batching synchronized evicts. </summary>
+ public const int DefaultEvictSynchronizedKeyBufferSize = 1024;
+
+ /// <summary> Default synchronous eviction timeout. </summary>
+ public static readonly TimeSpan DefaultEvictSynchronizedTimeout = TimeSpan.FromMilliseconds(10000);
+
+ /// <summary> Default synchronous eviction concurrency level. </summary>
+ public const int DefaultEvictSynchronizedConcurrencyLevel = 4;
+
+ /// <summary> Default value for eager ttl flag. </summary>
+ public const bool DefaultEagerTtl = true;
+
+ /// <summary> Default off-heap storage size is {@code -1} which means that off-heap storage is disabled. </summary>
+ public const long DefaultOffHeapMaxMemory = -1;
+
+ /// <summary> Default value for 'swapEnabled' flag. </summary>
+ public const bool DefaultEnableSwap = false;
+
+ /// <summary> Default value for 'maxConcurrentAsyncOps'. </summary>
+ public const int DefaultMaxConcurrentAsyncOperations = 500;
+
+ /// <summary> Default value for 'writeBehindEnabled' flag. </summary>
+ public const bool DefaultWriteBehindEnabled = false;
+
+ /// <summary> Default flush size for write-behind cache store. </summary>
+ public const int DefaultWriteBehindFlushSize = 10240; // 10K
+
+ /// <summary> Default flush frequency for write-behind cache store. </summary>
+ public static readonly TimeSpan DefaultWriteBehindFlushFrequency = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary> Default count of flush threads for write-behind cache store. </summary>
+ public const int DefaultWriteBehindFlushThreadCount = 1;
+
+ /// <summary> Default batch size for write-behind cache store. </summary>
+ public const int DefaultWriteBehindBatchSize = 512;
+
+ /// <summary> Default value for load previous value flag. </summary>
+ public const bool DefaultLoadPreviousValue = false;
+
+ /// <summary> Default memory mode. </summary>
+ public const CacheMemoryMode DefaultMemoryMode = CacheMemoryMode.OnheapTiered;
+
+ /// <summary> Default value for 'readFromBackup' flag. </summary>
+ public const bool DefaultReadFromBackup = true;
+
+ /// <summary> Default timeout after which long query warning will be printed. </summary>
+ public static readonly TimeSpan DefaultLongQueryWarningTimeout = TimeSpan.FromMilliseconds(3000);
+
+ /// <summary> Default size for onheap SQL row cache size. </summary>
+ public const int DefaultSqlOnheapRowCacheSize = 10*1024;
+
+ /// <summary> Default value for keep portable in store behavior .</summary>
+ public const bool DefaultKeepVinaryInStore = true;
+
+ /// <summary> Default value for 'copyOnRead' flag. </summary>
+ public const bool DefaultCopyOnRead = true;
+
+ /// <summary>
+ /// Gets or sets the cache name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ public CacheConfiguration() : this((string) null)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ public CacheConfiguration(string name)
+ {
+ Name = name;
+
+ Backups = DefaultBackups;
+ AtomicityMode = DefaultAtomicityMode;
+ CacheMode = DefaultCacheMode;
+ CopyOnRead = DefaultCopyOnRead;
+ EagerTtl = DefaultEagerTtl;
+ EvictSynchronizedKeyBufferSize = DefaultEvictSynchronizedKeyBufferSize;
+ EvictSynchronized = DefaultEvictSynchronized;
+ EvictSynchronizedConcurrencyLevel = DefaultEvictSynchronizedConcurrencyLevel;
+ EvictSynchronizedTimeout = DefaultEvictSynchronizedTimeout;
+ Invalidate = DefaultInvalidate;
+ KeepBinaryInStore = DefaultKeepVinaryInStore;
+ LoadPreviousValue = DefaultLoadPreviousValue;
+ LockTimeout = DefaultLockTimeout;
+ LongQueryWarningTimeout = DefaultLongQueryWarningTimeout;
+ MaxConcurrentAsyncOperations = DefaultMaxConcurrentAsyncOperations;
+ MaxEvictionOverflowRatio = DefaultMaxEvictionOverflowRatio;
+ MemoryMode = DefaultMemoryMode;
+ OffHeapMaxMemory = DefaultOffHeapMaxMemory;
+ ReadFromBackup = DefaultReadFromBackup;
+ RebalanceBatchSize = DefaultRebalanceBatchSize;
+ RebalanceMode = DefaultRebalanceMode;
+ RebalanceThrottle = DefaultRebalanceThrottle;
+ RebalanceTimeout = DefaultRebalanceTimeout;
+ SqlOnheapRowCacheSize = DefaultSqlOnheapRowCacheSize;
+ StartSize = DefaultStartSize;
+ EnableSwap = DefaultEnableSwap;
+ WriteBehindBatchSize = DefaultWriteBehindBatchSize;
+ WriteBehindEnabled = DefaultWriteBehindEnabled;
+ WriteBehindFlushFrequency = DefaultWriteBehindFlushFrequency;
+ WriteBehindFlushSize = DefaultWriteBehindFlushSize;
+ WriteBehindFlushThreadCount= DefaultWriteBehindFlushThreadCount;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class
+ /// and populates <see cref="QueryEntities"/> according to provided query types.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <param name="queryTypes">
+ /// Collection of types to be registered as query entities. These types should use
+ /// <see cref="QuerySqlFieldAttribute"/> to configure query fields and properties.
+ /// </param>
+ public CacheConfiguration(string name, params Type[] queryTypes) : this(name)
+ {
+ QueryEntities = queryTypes.Select(type => new QueryEntity {ValueType = type}).ToArray();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="name">Cache name.</param>
+ /// <param name="queryEntities">Query entities.</param>
+ public CacheConfiguration(string name, params QueryEntity[] queryEntities) : this(name)
+ {
+ QueryEntities = queryEntities;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="CacheConfiguration"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal CacheConfiguration(IBinaryRawReader reader)
+ {
+ AtomicityMode = (CacheAtomicityMode) reader.ReadInt();
+ AtomicWriteOrderMode = (CacheAtomicWriteOrderMode) reader.ReadInt();
+ Backups = reader.ReadInt();
+ CacheMode = (CacheMode) reader.ReadInt();
+ CopyOnRead = reader.ReadBoolean();
+ EagerTtl = reader.ReadBoolean();
+ EnableSwap = reader.ReadBoolean();
+ EvictSynchronized = reader.ReadBoolean();
+ EvictSynchronizedConcurrencyLevel = reader.ReadInt();
+ EvictSynchronizedKeyBufferSize = reader.ReadInt();
+ EvictSynchronizedTimeout = reader.ReadLongAsTimespan();
+ Invalidate = reader.ReadBoolean();
+ KeepBinaryInStore = reader.ReadBoolean();
+ LoadPreviousValue = reader.ReadBoolean();
+ LockTimeout = reader.ReadLongAsTimespan();
+ LongQueryWarningTimeout = reader.ReadLongAsTimespan();
+ MaxConcurrentAsyncOperations = reader.ReadInt();
+ MaxEvictionOverflowRatio = reader.ReadFloat();
+ MemoryMode = (CacheMemoryMode) reader.ReadInt();
+ Name = reader.ReadString();
+ OffHeapMaxMemory = reader.ReadLong();
+ ReadFromBackup = reader.ReadBoolean();
+ RebalanceBatchSize = reader.ReadInt();
+ RebalanceDelay = reader.ReadLongAsTimespan();
+ RebalanceMode = (CacheRebalanceMode) reader.ReadInt();
+ RebalanceThrottle = reader.ReadLongAsTimespan();
+ RebalanceTimeout = reader.ReadLongAsTimespan();
+ SqlEscapeAll = reader.ReadBoolean();
+ SqlOnheapRowCacheSize = reader.ReadInt();
+ StartSize = reader.ReadInt();
+ WriteBehindBatchSize = reader.ReadInt();
+ WriteBehindEnabled = reader.ReadBoolean();
+ WriteBehindFlushFrequency = reader.ReadLongAsTimespan();
+ WriteBehindFlushSize = reader.ReadInt();
+ WriteBehindFlushThreadCount = reader.ReadInt();
+ WriteSynchronizationMode = (CacheWriteSynchronizationMode) reader.ReadInt();
+ CacheStoreFactory = reader.ReadObject<IFactory<ICacheStore>>();
+
+ var count = reader.ReadInt();
+ QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instane to the specified writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteInt((int) AtomicityMode);
+ writer.WriteInt((int) AtomicWriteOrderMode);
+ writer.WriteInt(Backups);
+ writer.WriteInt((int) CacheMode);
+ writer.WriteBoolean(CopyOnRead);
+ writer.WriteBoolean(EagerTtl);
+ writer.WriteBoolean(EnableSwap);
+ writer.WriteBoolean(EvictSynchronized);
+ writer.WriteInt(EvictSynchronizedConcurrencyLevel);
+ writer.WriteInt(EvictSynchronizedKeyBufferSize);
+ writer.WriteLong((long) EvictSynchronizedTimeout.TotalMilliseconds);
+ writer.WriteBoolean(Invalidate);
+ writer.WriteBoolean(KeepBinaryInStore);
+ writer.WriteBoolean(LoadPreviousValue);
+ writer.WriteLong((long) LockTimeout.TotalMilliseconds);
+ writer.WriteLong((long) LongQueryWarningTimeout.TotalMilliseconds);
+ writer.WriteInt(MaxConcurrentAsyncOperations);
+ writer.WriteFloat(MaxEvictionOverflowRatio);
+ writer.WriteInt((int) MemoryMode);
+ writer.WriteString(Name);
+ writer.WriteLong(OffHeapMaxMemory);
+ writer.WriteBoolean(ReadFromBackup);
+ writer.WriteInt(RebalanceBatchSize);
+ writer.WriteLong((long) RebalanceDelay.TotalMilliseconds);
+ writer.WriteInt((int) RebalanceMode);
+ writer.WriteLong((long) RebalanceThrottle.TotalMilliseconds);
+ writer.WriteLong((long) RebalanceTimeout.TotalMilliseconds);
+ writer.WriteBoolean(SqlEscapeAll);
+ writer.WriteInt(SqlOnheapRowCacheSize);
+ writer.WriteInt(StartSize);
+ writer.WriteInt(WriteBehindBatchSize);
+ writer.WriteBoolean(WriteBehindEnabled);
+ writer.WriteLong((long) WriteBehindFlushFrequency.TotalMilliseconds);
+ writer.WriteInt(WriteBehindFlushSize);
+ writer.WriteInt(WriteBehindFlushThreadCount);
+ writer.WriteInt((int) WriteSynchronizationMode);
+ writer.WriteObject(CacheStoreFactory);
+
+ if (QueryEntities != null)
+ {
+ writer.WriteInt(QueryEntities.Count);
+
+ foreach (var entity in QueryEntities)
+ {
+ if (entity == null)
+ throw new InvalidOperationException("Invalid cache configuration: QueryEntity can't be null.");
+
+ entity.Write(writer);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+ /// <summary>
+ /// Gets or sets write synchronization mode. This mode controls whether the main
+ /// caller should wait for update on other nodes to complete or not.
+ /// </summary>
+ public CacheWriteSynchronizationMode WriteSynchronizationMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether eviction is synchronized between primary, backup and near nodes.
+ /// If this parameter is true and swap is disabled then <see cref="ICache{TK,TV}.LocalEvict"/>
+ /// will involve all nodes where an entry is kept.
+ /// If this property is set to false then eviction is done independently on different cache nodes.
+ /// Note that it's not recommended to set this value to true if cache store is configured since it will allow
+ /// to significantly improve cache performance.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronized)]
+ public bool EvictSynchronized { get; set; }
+
+ /// <summary>
+ /// Gets or sets size of the key buffer for synchronized evictions.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronizedKeyBufferSize)]
+ public int EvictSynchronizedKeyBufferSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets concurrency level for synchronized evictions.
+ /// This flag only makes sense with <see cref="EvictSynchronized"/> set to true.
+ /// When synchronized evictions are enabled, it is possible that local eviction policy will try
+ /// to evict entries faster than evictions can be synchronized with backup or near nodes.
+ /// This value specifies how many concurrent synchronous eviction sessions should be allowed
+ /// before the system is forced to wait and let synchronous evictions catch up with the eviction policy.
+ /// </summary>
+ [DefaultValue(DefaultEvictSynchronizedConcurrencyLevel)]
+ public int EvictSynchronizedConcurrencyLevel { get; set; }
+
+ /// <summary>
+ /// Gets or sets timeout for synchronized evictions
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:10")]
+ public TimeSpan EvictSynchronizedTimeout { get; set; }
+
+ /// <summary>
+ /// This value denotes the maximum size of eviction queue in percents of cache size
+ /// in case of distributed cache (replicated and partitioned) and using synchronized eviction
+ /// <para/>
+ /// That queue is used internally as a buffer to decrease network costs for synchronized eviction.
+ /// Once queue size reaches specified value all required requests for all entries in the queue
+ /// are sent to remote nodes and the queue is cleared.
+ /// </summary>
+ [DefaultValue(DefaultMaxEvictionOverflowRatio)]
+ public float MaxEvictionOverflowRatio { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether expired cache entries will be eagerly removed from cache.
+ /// When set to false, expired entries will be removed on next entry access.
+ /// </summary>
+ [DefaultValue(DefaultEagerTtl)]
+ public bool EagerTtl { get; set; }
+
+ /// <summary>
+ /// Gets or sets initial cache size which will be used to pre-create internal hash table after start.
+ /// </summary>
+ [DefaultValue(DefaultStartSize)]
+ public int StartSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether value should be loaded from store if it is not in the cache
+ /// for the following cache operations:
+ /// <list type="bullet">
+ /// <item><term><see cref="ICache{TK,TV}.PutIfAbsent"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.Replace(TK,TV)"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.Remove(TK)"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndPut"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndRemove"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndReplace"/></term></item>
+ /// <item><term><see cref="ICache{TK,TV}.GetAndPutIfAbsent"/></term></item>
+ /// </list>
+ /// </summary>
+ [DefaultValue(DefaultLoadPreviousValue)]
+ public bool LoadPreviousValue { get; set; }
+
+ /// <summary>
+ /// Gets or sets the flag indicating whether <see cref="ICacheStore"/> is working with binary objects
+ /// instead of deserialized objects.
+ /// </summary>
+ [DefaultValue(DefaultKeepVinaryInStore)]
+ public bool KeepBinaryInStore { get; set; }
+
+ /// <summary>
+ /// Gets or sets caching mode to use.
+ /// </summary>
+ [DefaultValue(DefaultCacheMode)]
+ public CacheMode CacheMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache atomicity mode.
+ /// </summary>
+ [DefaultValue(DefaultAtomicityMode)]
+ public CacheAtomicityMode AtomicityMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache write ordering mode.
+ /// </summary>
+ public CacheAtomicWriteOrderMode AtomicWriteOrderMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets number of nodes used to back up single partition for
+ /// <see cref="Configuration.CacheMode.Partitioned"/> cache.
+ /// </summary>
+ [DefaultValue(DefaultBackups)]
+ public int Backups { get; set; }
+
+ /// <summary>
+ /// Gets or sets default lock acquisition timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:00")]
+ public TimeSpan LockTimeout { get; set; }
+
+ /// <summary>
+ /// Invalidation flag. If true, values will be invalidated (nullified) upon commit in near cache.
+ /// </summary>
+ [DefaultValue(DefaultInvalidate)]
+ public bool Invalidate { get; set; }
+
+ /// <summary>
+ /// Gets or sets cache rebalance mode.
+ /// </summary>
+ [DefaultValue(DefaultRebalanceMode)]
+ public CacheRebalanceMode RebalanceMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets size (in number bytes) to be loaded within a single rebalance message.
+ /// Rebalancing algorithm will split total data set on every node into multiple batches prior to sending data.
+ /// </summary>
+ [DefaultValue(DefaultRebalanceBatchSize)]
+ public int RebalanceBatchSize { get; set; }
+
+ /// <summary>
+ /// Flag indicating whether Ignite should use swap storage by default.
+ /// </summary>
+ [DefaultValue(DefaultEnableSwap)]
+ public bool EnableSwap { get; set; }
+
+ /// <summary>
+ /// Gets or sets maximum number of allowed concurrent asynchronous operations, 0 for unlimited.
+ /// </summary>
+ [DefaultValue(DefaultMaxConcurrentAsyncOperations)]
+ public int MaxConcurrentAsyncOperations { get; set; }
+
+ /// <summary>
+ /// Flag indicating whether Ignite should use write-behind behaviour for the cache store.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindEnabled)]
+ public bool WriteBehindEnabled { get; set; }
+
+ /// <summary>
+ /// Maximum size of the write-behind cache. If cache size exceeds this value, all cached items are flushed
+ /// to the cache store and write cache is cleared.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindFlushSize)]
+ public int WriteBehindFlushSize { get; set; }
+
+ /// <summary>
+ /// Frequency with which write-behind cache is flushed to the cache store.
+ /// This value defines the maximum time interval between object insertion/deletion from the cache
+ /// at the moment when corresponding operation is applied to the cache store.
+ /// <para/>
+ /// If this value is 0, then flush is performed according to the flush size.
+ /// <para/>
+ /// Note that you cannot set both
+ /// <see cref="WriteBehindFlushSize"/> and <see cref="WriteBehindFlushFrequency"/> to 0.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan WriteBehindFlushFrequency { get; set; }
+
+ /// <summary>
+ /// Number of threads that will perform cache flushing. Cache flushing is performed when cache size exceeds
+ /// value defined by <see cref="WriteBehindFlushSize"/>, or flush interval defined by
+ /// <see cref="WriteBehindFlushFrequency"/> is elapsed.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindFlushThreadCount)]
+ public int WriteBehindFlushThreadCount { get; set; }
+
+ /// <summary>
+ /// Maximum batch size for write-behind cache store operations.
+ /// Store operations (get or remove) are combined in a batch of this size to be passed to
+ /// <see cref="ICacheStore.WriteAll"/> or <see cref="ICacheStore.DeleteAll"/> methods.
+ /// </summary>
+ [DefaultValue(DefaultWriteBehindBatchSize)]
+ public int WriteBehindBatchSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets rebalance timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:10")]
+ public TimeSpan RebalanceTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets delay upon a node joining or leaving topology (or crash)
+ /// after which rebalancing should be started automatically.
+ /// Rebalancing should be delayed if you plan to restart nodes
+ /// after they leave topology, or if you plan to start multiple nodes at once or one after another
+ /// and don't want to repartition and rebalance until all nodes are started.
+ /// </summary>
+ public TimeSpan RebalanceDelay { get; set; }
+
+ /// <summary>
+ /// Time to wait between rebalance messages to avoid overloading of CPU or network.
+ /// When rebalancing large data sets, the CPU or network can get over-consumed with rebalancing messages,
+ /// which consecutively may slow down the application performance. This parameter helps tune
+ /// the amount of time to wait between rebalance messages to make sure that rebalancing process
+ /// does not have any negative performance impact. Note that application will continue to work
+ /// properly while rebalancing is still in progress.
+ /// <para/>
+ /// Value of 0 means that throttling is disabled.
+ /// </summary>
+ public TimeSpan RebalanceThrottle { get; set; }
+
+ /// <summary>
+ /// Gets or sets maximum amount of memory available to off-heap storage. Possible values are
+ /// -1 means that off-heap storage is disabled. 0 means that Ignite will not limit off-heap storage
+ /// (it's up to user to properly add and remove entries from cache to ensure that off-heap storage
+ /// does not grow indefinitely.
+ /// Any positive value specifies the limit of off-heap storage in bytes.
+ /// </summary>
+ [DefaultValue(DefaultOffHeapMaxMemory)]
+ public long OffHeapMaxMemory { get; set; }
+
+ /// <summary>
+ /// Gets or sets memory mode for cache.
+ /// </summary>
+ [DefaultValue(DefaultMemoryMode)]
+ public CacheMemoryMode MemoryMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether data can be read from backup.
+ /// </summary>
+ [DefaultValue(DefaultReadFromBackup)]
+ public bool ReadFromBackup { get; set; }
+
+ /// <summary>
+ /// Gets or sets flag indicating whether copy of of the value stored in cache should be created
+ /// for cache operation implying return value.
+ /// </summary>
+ [DefaultValue(DefaultCopyOnRead)]
+ public bool CopyOnRead { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timeout after which long query warning will be printed.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:03")]
+ public TimeSpan LongQueryWarningTimeout { get; set; }
+
+ /// <summary>
+ /// If true all the SQL table and field names will be escaped with double quotes like
+ /// ({ "tableName"."fieldsName"}). This enforces case sensitivity for field names and
+ /// also allows having special characters in table and field names.
+ /// </summary>
+ public bool SqlEscapeAll { get; set; }
+
+ /// <summary>
+ /// Number of SQL rows which will be cached onheap to avoid deserialization on each SQL index access.
+ /// This setting only makes sense when offheap is enabled for this cache.
+ /// </summary>
+ [DefaultValue(DefaultSqlOnheapRowCacheSize)]
+ public int SqlOnheapRowCacheSize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the factory for underlying persistent storage for read-through and write-through operations.
+ /// </summary>
+ public IFactory<ICacheStore> CacheStoreFactory { get; set; }
+
+ /// <summary>
+ /// Gets or sets the query entity configuration.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryEntity> QueryEntities { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.cs
new file mode 100644
index 0000000..a072302
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMemoryMode.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.Cache.Configuration
+{
+ /// <summary>
+ /// Memory modes define whether cache entries are stored on heap memory, offheap memory, or in swap space.
+ /// </summary>
+ public enum CacheMemoryMode
+ {
+ /// <summary>
+ /// Entries will be stored on-heap first. The onheap tiered storage works as follows:
+ /// <list type="bullet">
+ /// <item><description>
+ /// Entries are cached on heap memory first.
+ /// </description></item>
+ /// <item><description>
+ /// If offheap memory is enabled and eviction policy evicts an entry from heap memory,
+ /// entry will be moved to offheap memory. If offheap memory is disabled, then entry is simply discarded.
+ /// </description></item>
+ /// <item><description>
+ /// If swap space is enabled and offheap memory fills up, then entry will be evicted into swap space.
+ /// If swap space is disabled, then entry will be discarded. If swap is enabled and offheap memory is disabled,
+ /// then entry will be evicted directly from heap memory into swap.
+ /// </description></item>
+ /// </list>
+ /// <para />
+ /// Note that heap memory evictions are handled by configured EvictionPolicy implementation. By default,
+ /// no eviction policy is enabled, so entries never leave heap memory space unless explicitly removed.
+ /// </summary>
+ OnheapTiered,
+
+ /// <summary>
+ /// Works the same as <see cref="OnheapTiered"/>, except that entries never end up in heap memory and get
+ /// stored in offheap memory right away. Entries get cached in offheap memory first and then
+ /// get evicted to swap, if one is configured.
+ /// </summary>
+ OffheapTiered,
+
+ /// <summary>
+ /// Entry keys will be stored on heap memory, and values will be stored in offheap memory.
+ /// Note that in this mode entries can be evicted only to swap.
+ /// </summary>
+ OffheapValues
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
new file mode 100644
index 0000000..6608354
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheMode.cs
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Caching modes.
+ /// </summary>
+ public enum CacheMode
+ {
+ /// <summary>
+ /// Specifies local-only cache behaviour. In this mode caches residing on
+ /// different grid nodes will not know about each other.
+ /// <para />
+ /// Other than distribution, <see cref="Local"/> caches still have all
+ /// the caching features, such as eviction, expiration, swapping,
+ /// querying, etc... This mode is very useful when caching read-only data
+ /// or data that automatically expires at a certain interval and
+ /// then automatically reloaded from persistence store.
+ /// </summary>
+ Local,
+
+ /// <summary>
+ /// Specifies fully replicated cache behavior. In this mode all the keys are distributed
+ /// to all participating nodes.
+ /// </summary>
+ Replicated,
+
+ /// <summary>
+ /// Specifies partitioned cache behaviour. In this mode the overall
+ /// key set will be divided into partitions and all partitions will be split
+ /// equally between participating nodes.
+ /// <para />
+ /// Note that partitioned cache is always fronted by local 'near' cache which stores most recent data.
+ /// </summary>
+ Partitioned
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
new file mode 100644
index 0000000..2ef2115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheRebalanceMode.cs
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Cache rebalance mode. When rebalancing is enabled (i.e. has value other than <see cref="None"/>),
+ /// distributed caches will attempt to rebalance all necessary values from other grid nodes.
+ /// <para />
+ /// Replicated caches will try to load the full set of cache entries from other nodes,
+ /// while partitioned caches will only load the entries for which current node is primary or backup.
+ /// <para />
+ /// Note that rebalance mode only makes sense for <see cref="CacheMode.Replicated"/>
+ /// and <see cref="CacheMode.Partitioned"/> caches. Caches with <see cref="CacheMode.Local"/>
+ /// mode are local by definition and therefore cannot rebalance any values from neighboring nodes.
+ /// </summary>
+ public enum CacheRebalanceMode
+ {
+ /// <summary>
+ /// Synchronous rebalance mode. Distributed caches will not start until all necessary data
+ /// is loaded from other available grid nodes.
+ /// </summary>
+ Sync,
+
+ /// <summary>
+ /// Asynchronous rebalance mode. Distributed caches will start immediately and will load all necessary
+ /// data from other available grid nodes in the background.
+ /// </summary>
+ Async,
+
+ /// <summary>
+ /// In this mode no rebalancing will take place which means that caches will be either loaded on
+ /// demand from persistent store whenever data is accessed, or will be populated explicitly.
+ /// </summary>
+ None
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
new file mode 100644
index 0000000..3257f15
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheWriteSynchronizationMode.cs
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Mode indicating how Ignite should wait for write replies from other nodes.
+ /// </summary>
+ public enum CacheWriteSynchronizationMode
+ {
+ /// <summary>
+ /// Mode indicating that Ignite should wait for write or commit replies from all nodes.
+ /// This behavior guarantees that whenever any of the atomic or transactional writes
+ /// complete, all other participating nodes which cache the written data have been updated.
+ /// </summary>
+ FullSync,
+
+ /// <summary>
+ /// Flag indicating that Ignite will not wait for write or commit responses from participating nodes,
+ /// which means that remote nodes may get their state updated a bit after any of the cache write methods
+ /// complete, or after {@link Transaction#commit()} method completes.
+ /// </summary>
+ FullAsync,
+
+ /// <summary>
+ /// This flag only makes sense for {@link CacheMode#PARTITIONED} mode. When enabled, Ignite will wait
+ /// for write or commit to complete on primary node, but will not wait for backups to be updated.
+ /// </summary>
+ PrimarySync
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
new file mode 100644
index 0000000..33849c7
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryAlias.cs
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents cache query configuration alias.
+ /// </summary>
+ public class QueryAlias
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+ /// </summary>
+ public QueryAlias()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryAlias"/> class.
+ /// </summary>
+ /// <param name="fullName">The full name.</param>
+ /// <param name="alias">The alias.</param>
+ public QueryAlias(string fullName, string alias)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(fullName, "fullName");
+ IgniteArgumentCheck.NotNullOrEmpty(alias, "alias");
+
+ FullName = fullName;
+ Alias = alias;
+ }
+
+ /// <summary>
+ /// Gets or sets the full name of the query field.
+ /// </summary>
+ public string FullName { get; set; }
+
+ /// <summary>
+ /// Gets or sets the alias for the full name.
+ /// </summary>
+ public string Alias { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
new file mode 100644
index 0000000..4151540
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -0,0 +1,401 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
+ using System.Reflection;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// Query entity is a description of cache entry (composed of key and value)
+ /// in a way of how it must be indexed and can be queried.
+ /// </summary>
+ public class QueryEntity
+ {
+ /** */
+ private Type _keyType;
+
+ /** */
+ private Type _valueType;
+
+ /** */
+ private string _valueTypeName;
+
+ /** */
+ private string _keyTypeName;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ public QueryEntity()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="valueType">Type of the cache entry value.</param>
+ public QueryEntity(Type valueType)
+ {
+ ValueType = valueType;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="keyType">Type of the key.</param>
+ /// <param name="valueType">Type of the value.</param>
+ public QueryEntity(Type keyType, Type valueType)
+ {
+ KeyType = keyType;
+ ValueType = valueType;
+ }
+
+ /// <summary>
+ /// Gets or sets key Java type name.
+ /// </summary>
+ public string KeyTypeName
+ {
+ get { return _keyTypeName; }
+ set
+ {
+ _keyTypeName = value;
+ _keyType = null;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the type of the key.
+ /// <para />
+ /// This is a shortcut for <see cref="KeyTypeName"/>. Getter will return null for non-primitive types.
+ /// <para />
+ /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+ /// <see cref="QuerySqlFieldAttribute"/>, if any.
+ /// </summary>
+ public Type KeyType
+ {
+ get { return _keyType ?? JavaTypes.GetDotNetType(KeyTypeName); }
+ set
+ {
+ RescanAttributes(value, _valueType); // Do this first because it can throw
+
+ KeyTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _keyType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets value Java type name.
+ /// </summary>
+ public string ValueTypeName
+ {
+ get { return _valueTypeName; }
+ set
+ {
+ _valueTypeName = value;
+ _valueType = null;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets the type of the value.
+ /// <para />
+ /// This is a shortcut for <see cref="ValueTypeName"/>. Getter will return null for non-primitive types.
+ /// <para />
+ /// Setting this property will overwrite <see cref="Fields"/> and <see cref="Indexes"/> according to
+ /// <see cref="QuerySqlFieldAttribute"/>, if any.
+ /// </summary>
+ public Type ValueType
+ {
+ get { return _valueType ?? JavaTypes.GetDotNetType(ValueTypeName); }
+ set
+ {
+ RescanAttributes(_keyType, value); // Do this first because it can throw
+
+ ValueTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _valueType = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets or sets query fields, a map from field name to Java type name.
+ /// The order of fields defines the order of columns returned by the 'select *' queries.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryField> Fields { get; set; }
+
+ /// <summary>
+ /// Gets or sets field name aliases: mapping from full name in dot notation to an alias
+ /// that will be used as SQL column name.
+ /// Example: {"parent.name" -> "parentName"}.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryAlias> Aliases { get; set; }
+
+ /// <summary>
+ /// Gets or sets the query indexes.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<QueryIndex> Indexes { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryEntity"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal QueryEntity(IBinaryRawReader reader)
+ {
+ KeyTypeName = reader.ReadString();
+ ValueTypeName = reader.ReadString();
+
+ var count = reader.ReadInt();
+ Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+ new QueryField(reader.ReadString(), reader.ReadString())).ToList();
+
+ count = reader.ReadInt();
+ Aliases = count == 0 ? null : Enumerable.Range(0, count)
+ .Select(x=> new QueryAlias(reader.ReadString(), reader.ReadString())).ToList();
+
+ count = reader.ReadInt();
+ Indexes = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryIndex(reader)).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instance.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteString(KeyTypeName);
+ writer.WriteString(ValueTypeName);
+
+ if (Fields != null)
+ {
+ writer.WriteInt(Fields.Count);
+
+ foreach (var field in Fields)
+ {
+ writer.WriteString(field.Name);
+ writer.WriteString(field.FieldTypeName);
+ }
+ }
+ else
+ writer.WriteInt(0);
+
+
+ if (Aliases != null)
+ {
+ writer.WriteInt(Aliases.Count);
+
+ foreach (var queryAlias in Aliases)
+ {
+ writer.WriteString(queryAlias.FullName);
+ writer.WriteString(queryAlias.Alias);
+ }
+ }
+ else
+ writer.WriteInt(0);
+
+ if (Indexes != null)
+ {
+ writer.WriteInt(Indexes.Count);
+
+ foreach (var index in Indexes)
+ {
+ if (index == null)
+ throw new InvalidOperationException("Invalid cache configuration: QueryIndex can't be null.");
+
+ index.Write(writer);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+
+ /// <summary>
+ /// Rescans the attributes in <see cref="KeyType"/> and <see cref="ValueType"/>.
+ /// </summary>
+ private void RescanAttributes(params Type[] types)
+ {
+ if (types.Length == 0 || types.All(t => t == null))
+ return;
+
+ var fields = new List<QueryField>();
+ var indexes = new List<QueryIndexEx>();
+
+ foreach (var type in types.Where(t => t != null))
+ ScanAttributes(type, fields, indexes, null, new HashSet<Type>());
+
+ if (fields.Any())
+ Fields = fields;
+
+ if (indexes.Any())
+ Indexes = GetGroupIndexes(indexes).ToArray();
+ }
+
+ /// <summary>
+ /// Gets the group indexes.
+ /// </summary>
+ /// <param name="indexes">Ungrouped indexes with their group names.</param>
+ /// <returns></returns>
+ private static IEnumerable<QueryIndex> GetGroupIndexes(List<QueryIndexEx> indexes)
+ {
+ return indexes.Where(idx => idx.IndexGroups != null)
+ .SelectMany(idx => idx.IndexGroups.Select(g => new {Index = idx, GroupName = g}))
+ .GroupBy(x => x.GroupName)
+ .Select(g =>
+ {
+ var idxs = g.Select(pair => pair.Index).ToArray();
+
+ var first = idxs.First();
+
+ return new QueryIndex(idxs.SelectMany(i => i.Fields).ToArray())
+ {
+ IndexType = first.IndexType,
+ Name = first.Name
+ };
+ })
+ .Concat(indexes.Where(idx => idx.IndexGroups == null));
+ }
+
+ /// <summary>
+ /// Scans specified type for occurences of <see cref="QuerySqlFieldAttribute"/>.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="fields">The fields.</param>
+ /// <param name="indexes">The indexes.</param>
+ /// <param name="parentPropName">Name of the parent property.</param>
+ /// <param name="visitedTypes">The visited types.</param>
+ private static void ScanAttributes(Type type, List<QueryField> fields, List<QueryIndexEx> indexes,
+ string parentPropName, ISet<Type> visitedTypes)
+ {
+ Debug.Assert(type != null);
+ Debug.Assert(fields != null);
+ Debug.Assert(indexes != null);
+
+ if (visitedTypes.Contains(type))
+ throw new InvalidOperationException("Recursive Query Field definition detected: " + type);
+
+ visitedTypes.Add(type);
+
+ foreach (var memberInfo in GetFieldsAndProperties(type))
+ {
+ var customAttributes = memberInfo.Key.GetCustomAttributes(true);
+
+ foreach (var attr in customAttributes.OfType<QuerySqlFieldAttribute>())
+ {
+ var columnName = attr.Name ?? memberInfo.Key.Name;
+
+ // Dot notation is required for nested SQL fields
+ if (parentPropName != null)
+ columnName = parentPropName + "." + columnName;
+
+ fields.Add(new QueryField(columnName, memberInfo.Value));
+
+ if (attr.IsIndexed)
+ indexes.Add(new QueryIndexEx(columnName, attr.IsDescending, QueryIndexType.Sorted,
+ attr.IndexGroups));
+
+ ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+ }
+
+ foreach (var attr in customAttributes.OfType<QueryTextFieldAttribute>())
+ {
+ var columnName = attr.Name ?? memberInfo.Key.Name;
+
+ // No dot notation for FullText index names
+ indexes.Add(new QueryIndexEx(columnName, false, QueryIndexType.FullText, null));
+
+ if (parentPropName != null)
+ columnName = parentPropName + "." + columnName;
+
+ fields.Add(new QueryField(columnName, memberInfo.Value));
+
+ ScanAttributes(memberInfo.Value, fields, indexes, columnName, visitedTypes);
+ }
+ }
+
+ visitedTypes.Remove(type);
+ }
+
+ /// <summary>
+ /// Gets the fields and properties.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <returns></returns>
+ private static IEnumerable<KeyValuePair<MemberInfo, Type>> GetFieldsAndProperties(Type type)
+ {
+ Debug.Assert(type != null);
+
+ if (type.IsPrimitive)
+ yield break;
+
+ var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
+ BindingFlags.DeclaredOnly;
+
+ while (type != typeof (object) && type != null)
+ {
+ foreach (var fieldInfo in type.GetFields(bindingFlags))
+ yield return new KeyValuePair<MemberInfo, Type>(fieldInfo, fieldInfo.FieldType);
+
+ foreach (var propertyInfo in type.GetProperties(bindingFlags))
+ yield return new KeyValuePair<MemberInfo, Type>(propertyInfo, propertyInfo.PropertyType);
+
+ type = type.BaseType;
+ }
+ }
+
+ /// <summary>
+ /// Extended index with group names.
+ /// </summary>
+ private class QueryIndexEx : QueryIndex
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexEx"/> class.
+ /// </summary>
+ /// <param name="fieldName">Name of the field.</param>
+ /// <param name="isDescending">if set to <c>true</c> [is descending].</param>
+ /// <param name="indexType">Type of the index.</param>
+ /// <param name="groups">The groups.</param>
+ public QueryIndexEx(string fieldName, bool isDescending, QueryIndexType indexType,
+ ICollection<string> groups)
+ : base(isDescending, indexType, fieldName)
+ {
+ IndexGroups = groups;
+ }
+
+ /// <summary>
+ /// Gets or sets the index groups.
+ /// </summary>
+ public ICollection<string> IndexGroups { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
new file mode 100644
index 0000000..8c70a29
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryField.cs
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// ReSharper disable UnusedAutoPropertyAccessor.Global
+// ReSharper disable MemberCanBePrivate.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents a queryable field.
+ /// </summary>
+ public class QueryField
+ {
+ /** */
+ private Type _type;
+
+ /** */
+ private string _fieldTypeName;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField"/> class.
+ /// </summary>
+ public QueryField()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField"/> class.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="javaFieldTypeName">Java type name.</param>
+ public QueryField(string name, string javaFieldTypeName)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+ IgniteArgumentCheck.NotNullOrEmpty(javaFieldTypeName, "typeName");
+
+ Name = name;
+ FieldTypeName = javaFieldTypeName;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryField" /> class.
+ /// </summary>
+ /// <param name="name">Name.</param>
+ /// <param name="fieldType">Type.</param>
+ public QueryField(string name, Type fieldType)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+ IgniteArgumentCheck.NotNull(fieldType, "type");
+
+ Name = name;
+ FieldType = fieldType;
+ }
+
+ /// <summary>
+ /// Gets the field name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the value.
+ /// <para />
+ /// This is a shortcut for <see cref="FieldTypeName"/>. Getter will return null for non-primitive types.
+ /// </summary>
+ public Type FieldType
+ {
+ get { return _type ?? JavaTypes.GetDotNetType(FieldTypeName); }
+ set
+ {
+ FieldTypeName = value == null
+ ? null
+ : (JavaTypes.GetJavaTypeName(value) ?? BinaryUtils.GetTypeName(value));
+
+ _type = value;
+ }
+ }
+
+ /// <summary>
+ /// Gets the Java type name.
+ /// </summary>
+ public string FieldTypeName
+ {
+ get { return _fieldTypeName; }
+ set
+ {
+ _fieldTypeName = value;
+ _type = null;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
new file mode 100644
index 0000000..7079606
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndex.cs
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 UnusedMember.Global
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// Represents cache query index configuration.
+ /// </summary>
+ public class QueryIndex
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ public QueryIndex()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(params string[] fieldNames) : this(false, fieldNames)
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="isDescending">Sort direction.</param>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(bool isDescending, params string[] fieldNames)
+ {
+ Fields = fieldNames.Select(f => new QueryIndexField(f, isDescending)).ToArray();
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex" /> class.
+ /// </summary>
+ /// <param name="isDescending">Sort direction.</param>
+ /// <param name="indexType">Type of the index.</param>
+ /// <param name="fieldNames">Names of the fields to index.</param>
+ public QueryIndex(bool isDescending, QueryIndexType indexType, params string[] fieldNames)
+ : this(isDescending, fieldNames)
+ {
+ IndexType = indexType;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ /// <param name="fields">The fields.</param>
+ public QueryIndex(params QueryIndexField[] fields)
+ {
+ if (fields == null || fields.Length == 0)
+ throw new ArgumentException("Query index must have at least one field");
+
+ if (fields.Any(f => f == null))
+ throw new ArgumentException("IndexField cannot be null.");
+
+ Fields = fields;
+ }
+
+ /// <summary>
+ /// Gets or sets the index name.
+ /// Will be set automatically if not specified.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the type of the index.
+ /// </summary>
+ public QueryIndexType IndexType { get; set; }
+
+ /// <summary>
+ /// Gets or sets a collection of fields to be indexed.
+ /// </summary>
+ public ICollection<QueryIndexField> Fields { get; private set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndex"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal QueryIndex(IBinaryRawReader reader)
+ {
+ Name = reader.ReadString();
+ IndexType = (QueryIndexType) reader.ReadByte();
+
+ var count = reader.ReadInt();
+ Fields = count == 0 ? null : Enumerable.Range(0, count).Select(x =>
+ new QueryIndexField(reader.ReadString(), reader.ReadBoolean())).ToList();
+ }
+
+ /// <summary>
+ /// Writes this instance.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteString(Name);
+ writer.WriteByte((byte) IndexType);
+
+ if (Fields != null)
+ {
+ writer.WriteInt(Fields.Count);
+
+ foreach (var field in Fields)
+ {
+ writer.WriteString(field.Name);
+ writer.WriteBoolean(field.IsDescending);
+ }
+ }
+ else
+ writer.WriteInt(0);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
new file mode 100644
index 0000000..0b11e9c
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexField.cs
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using Apache.Ignite.Core.Impl.Common;
+
+ /// <summary>
+ /// Represents an indexed field.
+ /// </summary>
+ public class QueryIndexField
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ public QueryIndexField()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ public QueryIndexField(string name)
+ {
+ IgniteArgumentCheck.NotNullOrEmpty(name, "name");
+
+ Name = name;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="QueryIndexField"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="isDescending">Sort direction.</param>
+ public QueryIndexField(string name, bool isDescending) : this (name)
+ {
+ IsDescending = isDescending;
+ }
+
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets a value indicating whether this index is descending. Default is false.
+ /// </summary>
+ public bool IsDescending { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
new file mode 100644
index 0000000..25fed62
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryIndexType.cs
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Query index type.
+ /// </summary>
+ public enum QueryIndexType
+ {
+ /// <summary>
+ /// Sorted index.
+ /// </summary>
+ Sorted,
+
+ /// <summary>
+ /// Fulltext index.
+ /// </summary>
+ FullText,
+
+ /// <summary>
+ /// Geo-spatial index.
+ /// </summary>
+ Geospatial
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.cs
new file mode 100644
index 0000000..a522115
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QuerySqlFieldAttribute.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.Cache.Configuration
+{
+ using System;
+ using System.Diagnostics.CodeAnalysis;
+
+ /// <summary>
+ /// Marks field or property for SQL queries.
+ /// <para />
+ /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+ public sealed class QuerySqlFieldAttribute : Attribute
+ {
+ /// <summary>
+ /// Gets or sets the sql field name.
+ /// If not provided, property or field name will be used.
+ /// </summary>
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether corresponding field should be indexed.
+ /// Just like with databases, field indexing may require additional overhead during updates,
+ /// but makes select operations faster.
+ /// </summary>
+ public bool IsIndexed { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether index for this field should be descending.
+ /// Ignored when <see cref="IsIndexed"/> is <c>false</c>.
+ /// </summary>
+ public bool IsDescending { get; set; }
+
+ /// <summary>
+ /// Gets or sets the collection of index groups this field belongs to.
+ /// Groups are used for compound indexes,
+ /// whenever index should be created on more than one field.
+ /// All fields within the same group will belong to the same index.
+ /// </summary>
+ [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
+ Justification = "Attribute initializers do not allow collections")]
+ public string[] IndexGroups { get; set; }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
new file mode 100644
index 0000000..6386496
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryTextFieldAttribute.cs
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using System;
+
+ /// <summary>
+ /// Marks field or property for Text queries.
+ /// <para />
+ /// Using this attribute is an alternative to <see cref="QueryEntity.Fields"/> in <see cref="CacheConfiguration"/>.
+ /// </summary>
+ [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
+ public sealed class QueryTextFieldAttribute : Attribute
+ {
+ /// <summary>
+ /// Gets or sets the text field name.
+ /// If not provided, property or field name will be used.
+ /// </summary>
+ public string Name { get; set; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
index 192dabf..f5e7cd2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/ICache.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Cache
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -66,6 +67,11 @@ namespace Apache.Ignite.Core.Cache
IIgnite Ignite { get; }
/// <summary>
+ /// Gets the cache configuration.
+ /// </summary>
+ CacheConfiguration GetConfiguration();
+
+ /// <summary>
/// Checks whether this cache contains no key-value mappings.
/// <para />
/// Semantically equals to <c>ICache.Size(CachePeekMode.PRIMARY) == 0</c>.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
new file mode 100644
index 0000000..67c2683
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Common/IFactory.cs
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Common
+{
+ using System;
+
+ /// <summary>
+ /// Factory that produces instances of a specific type.
+ /// Implementation can be passed over the wire and thus should be marked with <see cref="SerializableAttribute"/>.
+ /// </summary>
+ public interface IFactory<out T>
+ {
+ /// <summary>
+ /// Creates an instance of the cache store.
+ /// </summary>
+ /// <returns>New instance of the cache store.</returns>
+ T CreateInstance();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
new file mode 100644
index 0000000..2fcafbf
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/IDiscoverySpi.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Discovery
+{
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Discovery.Tcp;
+
+ /// <summary>
+ /// Represents a discovery service provider interface.
+ /// Only predefined implementation is supported now: <see cref="TcpDiscoverySpi"/>.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+ public interface IDiscoverySpi
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
new file mode 100644
index 0000000..c2f4329
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/ITcpDiscoveryIpFinder.cs
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery.Tcp
+{
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Represents an IP finder for <see cref="TcpDiscoverySpi"/>.
+ /// Only predefined implementations are supported now:
+ /// <see cref="TcpDiscoveryStaticIpFinder"/>, <see cref="TcpDiscoveryMulticastIpFinder"/>.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+ public interface ITcpDiscoveryIpFinder
+ {
+ // No-op.
+ }
+}
\ No newline at end of file
[24/50] [abbrv] ignite git commit: Added cache GET benchmark.
Posted by vo...@apache.org.
Added cache GET benchmark.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e2be94e6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e2be94e6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e2be94e6
Branch: refs/heads/ignite-1786
Commit: e2be94e62aecddeb7bf3409450a5a95a314ba186
Parents: afd3bc1
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Feb 4 15:31:18 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 4 15:31:18 2016 +0300
----------------------------------------------------------------------
.../jmh/cache/JmhCacheAbstractBenchmark.java | 3 +
.../benchmarks/jmh/cache/JmhCacheBenchmark.java | 145 +++++++++++++++++++
.../jmh/cache/JmhCachePutBenchmark.java | 124 ----------------
.../jmh/runner/JmhIdeBenchmarkRunner.java | 20 ++-
4 files changed, 160 insertions(+), 132 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2be94e6/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheAbstractBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheAbstractBenchmark.java
index e8829bb..709ab77 100644
--- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheAbstractBenchmark.java
+++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheAbstractBenchmark.java
@@ -58,6 +58,9 @@ public class JmhCacheAbstractBenchmark extends JmhAbstractBenchmark {
/** Default amount of nodes. */
protected static final int DFLT_DATA_NODES = 1;
+ /** Items count. */
+ protected static final int CNT = 100000;
+
/** IP finder shared across nodes. */
private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2be94e6/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheBenchmark.java
new file mode 100644
index 0000000..f55d16c
--- /dev/null
+++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCacheBenchmark.java
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.benchmarks.jmh.cache;
+
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.internal.benchmarks.jmh.runner.JmhIdeBenchmarkRunner;
+import org.apache.ignite.internal.benchmarks.model.IntValue;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.profile.GCProfiler;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+/**
+ * Put benchmark.
+ */
+@SuppressWarnings("unchecked")
+public class JmhCacheBenchmark extends JmhCacheAbstractBenchmark {
+ /**
+ * Set up routine.
+ *
+ * @throws Exception If failed.
+ */
+
+ public void setup() throws Exception {
+ super.setup();
+
+ IgniteDataStreamer<Integer, IntValue> dataLdr = node.dataStreamer(cache.getName());
+
+ for (int i = 0; i < CNT; i++)
+ dataLdr.addData(i, new IntValue(i));
+
+ dataLdr.close();
+
+ System.out.println("Cache populated.");
+ }
+
+ /**
+ * Test PUT operation.
+ *
+ * @throws Exception If failed.
+ */
+ @Benchmark
+ public void put() throws Exception {
+ int key = ThreadLocalRandom.current().nextInt(CNT);
+
+ cache.put(key, new IntValue(key));
+ }
+
+ /**
+ * Test PUT operation.
+ *
+ * @throws Exception If failed.
+ */
+ @Benchmark
+ public Object get() throws Exception {
+ int key = ThreadLocalRandom.current().nextInt(CNT);
+
+ return cache.get(key);
+ }
+
+ /**
+ * Run benchmarks.
+ *
+ * @param args Arguments.
+ * @throws Exception If failed.
+ */
+ public static void main(String[] args) throws Exception {
+ run("put", CacheAtomicityMode.ATOMIC);
+ run("get", CacheAtomicityMode.ATOMIC);
+ run("put", CacheAtomicityMode.TRANSACTIONAL);
+ run("get", CacheAtomicityMode.TRANSACTIONAL);
+ }
+
+ /**
+ * Run benchmarks for atomic cache.
+ *
+ * @param benchmark Benchmark name.
+ * @param atomicityMode Atomicity mode.
+ * @throws Exception If failed.
+ */
+ private static void run(String benchmark, CacheAtomicityMode atomicityMode) throws Exception {
+ run(benchmark, 4, true, atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC);
+ run(benchmark, 4, true, atomicityMode, CacheWriteSynchronizationMode.FULL_SYNC);
+ run(benchmark, 4, false, atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC);
+ run(benchmark, 4, false, atomicityMode, CacheWriteSynchronizationMode.FULL_SYNC);
+ }
+
+ /**
+ * Run benchmark.
+ *
+ * @param benchmark Benchmark to run.
+ * @param threads Amount of threads.
+ * @param client Client mode flag.
+ * @param atomicityMode Atomicity mode.
+ * @param writeSyncMode Write synchronization mode.
+ * @throws Exception If failed.
+ */
+ private static void run(String benchmark, int threads, boolean client, CacheAtomicityMode atomicityMode,
+ CacheWriteSynchronizationMode writeSyncMode) throws Exception {
+ String simpleClsName = JmhCacheBenchmark.class.getSimpleName();
+
+ String output = simpleClsName + "-" + benchmark +
+ "-" + threads + "-threads" +
+ "-" + (client ? "client" : "data") +
+ "-" + atomicityMode +
+ "-" + writeSyncMode;
+
+ JmhIdeBenchmarkRunner.create()
+ .forks(1)
+ .threads(threads)
+ .warmupIterations(10)
+ .measurementIterations(60)
+ .benchmarks(simpleClsName + "." + benchmark)
+ .output(output + ".jmh.log")
+ .profilers(GCProfiler.class)
+ .jvmArguments(
+ "-Xms4g",
+ "-Xmx4g",
+ "-XX:+UnlockCommercialFeatures",
+ "-XX:+FlightRecorder",
+ "-XX:StartFlightRecording=delay=30s,dumponexit=true,settings=alloc,filename=" + output + ".jfr",
+ JmhIdeBenchmarkRunner.createProperty(PROP_ATOMICITY_MODE, atomicityMode),
+ JmhIdeBenchmarkRunner.createProperty(PROP_WRITE_SYNC_MODE, writeSyncMode),
+ JmhIdeBenchmarkRunner.createProperty(PROP_DATA_NODES, 2),
+ JmhIdeBenchmarkRunner.createProperty(PROP_CLIENT_MODE, client))
+ .run();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2be94e6/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCachePutBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCachePutBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCachePutBenchmark.java
deleted file mode 100644
index 848e7ce..0000000
--- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/cache/JmhCachePutBenchmark.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.benchmarks.jmh.cache;
-
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.internal.benchmarks.jmh.runner.JmhIdeBenchmarkRunner;
-import org.apache.ignite.internal.benchmarks.model.IntValue;
-import org.openjdk.jmh.annotations.Benchmark;
-import org.openjdk.jmh.profile.GCProfiler;
-
-import java.util.concurrent.ThreadLocalRandom;
-
-/**
- * Put benchmark.
- */
-@SuppressWarnings("unchecked")
-public class JmhCachePutBenchmark extends JmhCacheAbstractBenchmark {
- /** Items count. */
- private static final int CNT = 100000;
-
- /**
- * Set up routine.
- *
- * @throws Exception If failed.
- */
-
- public void setup() throws Exception {
- super.setup();
-
- IgniteDataStreamer<Integer, IntValue> dataLdr = node.dataStreamer(cache.getName());
-
- for (int i = 0; i < CNT; i++)
- dataLdr.addData(i, new IntValue(i));
-
- dataLdr.close();
-
- System.out.println("Cache populated.");
- }
-
- /**
- * Test PUT operation.
- *
- * @throws Exception If failed.
- */
- @Benchmark
- public void testPut() throws Exception {
- int key = ThreadLocalRandom.current().nextInt(CNT);
-
- cache.put(key, new IntValue(key));
- }
-
- /**
- * Run benchmarks.
- *
- * @param args Arguments.
- * @throws Exception If failed.
- */
- public static void main(String[] args) throws Exception {
- run(CacheAtomicityMode.ATOMIC);
- }
-
- /**
- * Run benchmarks for atomic cache.
- *
- * @param atomicityMode Atomicity mode.
- * @throws Exception If failed.
- */
- private static void run(CacheAtomicityMode atomicityMode) throws Exception {
- run(4, true, atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC);
- run(4, true, atomicityMode, CacheWriteSynchronizationMode.FULL_SYNC);
- run(4, false, atomicityMode, CacheWriteSynchronizationMode.PRIMARY_SYNC);
- run(4, false, atomicityMode, CacheWriteSynchronizationMode.FULL_SYNC);
- }
-
- /**
- * Run benchmark.
- *
- * @param client Client mode flag.
- * @param writeSyncMode Write synchronization mode.
- * @throws Exception If failed.
- */
- private static void run(int threads, boolean client, CacheAtomicityMode atomicityMode,
- CacheWriteSynchronizationMode writeSyncMode) throws Exception {
- String output = "ignite-cache-put-" + threads + "-threads-" + (client ? "client" : "data") +
- "-" + atomicityMode + "-" + writeSyncMode;
-
- JmhIdeBenchmarkRunner.create()
- .forks(1)
- .threads(threads)
- .warmupIterations(10)
- .measurementIterations(60)
- .classes(JmhCachePutBenchmark.class)
- .output(output + ".jmh.log")
- .profilers(GCProfiler.class)
- .jvmArguments(
- "-Xms4g",
- "-Xmx4g",
- "-XX:+UnlockCommercialFeatures",
- "-XX:+FlightRecorder",
- "-XX:StartFlightRecording=delay=30s,dumponexit=true,settings=alloc,filename=" + output + ".jfr",
- JmhIdeBenchmarkRunner.createProperty(PROP_ATOMICITY_MODE, atomicityMode),
- JmhIdeBenchmarkRunner.createProperty(PROP_WRITE_SYNC_MODE, writeSyncMode),
- JmhIdeBenchmarkRunner.createProperty(PROP_DATA_NODES, 2),
- JmhIdeBenchmarkRunner.createProperty(PROP_CLIENT_MODE, client))
- .run();
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e2be94e6/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/runner/JmhIdeBenchmarkRunner.java
----------------------------------------------------------------------
diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/runner/JmhIdeBenchmarkRunner.java b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/runner/JmhIdeBenchmarkRunner.java
index af84862..0cad088 100644
--- a/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/runner/JmhIdeBenchmarkRunner.java
+++ b/modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/runner/JmhIdeBenchmarkRunner.java
@@ -42,8 +42,8 @@ public class JmhIdeBenchmarkRunner {
/** Output time unit. */
private TimeUnit outputTimeUnit = TimeUnit.SECONDS;
- /** Classes to run. */
- private Class[] clss;
+ /** Benchmarks to run. */
+ private Object[] benchmarks;
/** JVM arguments. */
private String[] jvmArgs;
@@ -123,11 +123,11 @@ public class JmhIdeBenchmarkRunner {
}
/**
- * @param clss Classes.
+ * @param benchmarks Benchmarks.
* @return This instance.
*/
- public JmhIdeBenchmarkRunner classes(Class... clss) {
- this.clss = clss;
+ public JmhIdeBenchmarkRunner benchmarks(Object... benchmarks) {
+ this.benchmarks = benchmarks;
return this;
}
@@ -191,9 +191,13 @@ public class JmhIdeBenchmarkRunner {
builder.getBenchModes().add(benchmarkMode);
}
- if (clss != null) {
- for (Class cls : clss)
- builder.include(cls.getSimpleName());
+ if (benchmarks != null) {
+ for (Object benchmark : benchmarks) {
+ if (benchmark instanceof Class)
+ builder.include(((Class)benchmark).getSimpleName());
+ else
+ builder.include(benchmark.toString());
+ }
}
if (jvmArgs != null)
[40/50] [abbrv] ignite git commit: IGNITE-1187: Need to improve
project setup in Eclipse
Posted by vo...@apache.org.
IGNITE-1187: Need to improve project setup in Eclipse
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e18dfdaf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e18dfdaf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e18dfdaf
Branch: refs/heads/ignite-1786
Commit: e18dfdafca3c01ba48958562e1d07c68e71c9302
Parents: a383f2e
Author: Edouard Chevalier <ed...@techmydata.net>
Authored: Mon Feb 8 14:09:03 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Feb 8 14:09:03 2016 +0300
----------------------------------------------------------------------
.gitignore | 3 ++
modules/yardstick/.gitignore | 2 +
parent/pom.xml | 92 ++++++++++++++++++++++++++++++++++++++-
3 files changed, 96 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e18dfdaf/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e4e061c..4073a58 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,6 @@ git-patch-prop-local.sh
**/cpp/**/vs/Win32/
**/dotnet/**/obj/
/modules/platforms/cpp/doc/
+.settings
+.classpath
+.project
http://git-wip-us.apache.org/repos/asf/ignite/blob/e18dfdaf/modules/yardstick/.gitignore
----------------------------------------------------------------------
diff --git a/modules/yardstick/.gitignore b/modules/yardstick/.gitignore
new file mode 100644
index 0000000..a2c5e4a
--- /dev/null
+++ b/modules/yardstick/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/libs
http://git-wip-us.apache.org/repos/asf/ignite/blob/e18dfdaf/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 437a30b..e189807 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -513,7 +513,7 @@
<Embed-Directory>lib</Embed-Directory>
<Embed-Transitive>${osgi.embed.transitive}</Embed-Transitive>
<_failok>${osgi.fail.ok}</_failok>
- <_invalidfilenames />
+ <_invalidfilenames/>
</instructions>
</configuration>
<executions>
@@ -1013,5 +1013,95 @@
</plugins>
</build>
</profile>
+ <profile>
+ <id>m2e</id>
+ <!--This profile is activated when eclipse interacts with maven (using m2e).-->
+ <activation>
+ <property>
+ <name>m2e.version</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <!--eclipse do not support duplicated package-info.java, in both src and test.-->
+ <artifactId>maven-compiler-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-testCompile</id>
+ <phase>test-compile</phase>
+ <configuration>
+ <testExcludes>
+ <exclude>**/package-info.java</exclude>
+ </testExcludes>
+ </configuration>
+ <goals>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <versionRange>[1.7,)</versionRange>
+ <goals>
+ <goal>run</goal>
+ <goal>properties-augmentation</goal>
+ <goal>licenses-file-rename</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>flatten-maven-plugin</artifactId>
+ <versionRange>[1.0.0-beta-3,)</versionRange>
+ <goals>
+ <goal>flatten</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <versionRange>[1.3.2,)</versionRange>
+ <goals>
+ <goal>java</goal>
+ <goal>default</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore></ignore>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+
</profiles>
</project>
[03/50] [abbrv] ignite git commit: 2224
Posted by vo...@apache.org.
2224
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/01135066
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/01135066
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/01135066
Branch: refs/heads/ignite-1786
Commit: 01135066d54df254a0b23afbbffca2ed103e3a8c
Parents: 62502b2
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Feb 2 15:25:05 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Feb 2 15:25:05 2016 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/IgniteCache.java | 45 +-
.../processors/cache/CacheEntryImplEx.java | 14 +-
.../processors/cache/GridCacheAdapter.java | 297 +++++--
.../processors/cache/GridCacheContext.java | 33 +-
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../processors/cache/GridCacheProxyImpl.java | 51 ++
.../processors/cache/IgniteCacheProxy.java | 51 ++
.../processors/cache/IgniteInternalCache.java | 85 ++
.../dht/CacheDistributedGetFutureAdapter.java | 15 -
.../distributed/dht/GridDhtCacheAdapter.java | 7 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 6 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 4 +-
.../dht/GridPartitionedGetFuture.java | 38 +-
.../dht/GridPartitionedSingleGetFuture.java | 17 +-
.../dht/atomic/GridDhtAtomicCache.java | 82 +-
.../dht/colocated/GridDhtColocatedCache.java | 42 +-
.../distributed/near/GridNearAtomicCache.java | 6 +-
.../distributed/near/GridNearCacheAdapter.java | 6 +-
.../distributed/near/GridNearCacheEntry.java | 3 +-
.../distributed/near/GridNearGetFuture.java | 45 +-
...arOptimisticSerializableTxPrepareFuture.java | 2 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 4 +
.../GridNearPessimisticTxPrepareFuture.java | 2 +
.../near/GridNearTransactionalCache.java | 9 +-
.../local/atomic/GridLocalAtomicCache.java | 97 ++-
.../cache/transactions/IgniteTxEntry.java | 32 +-
.../transactions/IgniteTxLocalAdapter.java | 196 +++--
.../cache/transactions/IgniteTxLocalEx.java | 3 +-
.../cache/transactions/IgniteTxManager.java | 2 +-
.../cache/CacheGetEntryAbstractTest.java | 803 +++++++++++++++++++
...GetEntryOptimisticReadCommittedSeltTest.java | 36 +
...etEntryOptimisticRepeatableReadSeltTest.java | 36 +
...eGetEntryOptimisticSerializableSeltTest.java | 36 +
...etEntryPessimisticReadCommittedSeltTest.java | 36 +
...tEntryPessimisticRepeatableReadSeltTest.java | 36 +
...GetEntryPessimisticSerializableSeltTest.java | 36 +
.../cache/CacheReadThroughRestartSelfTest.java | 43 +-
.../CacheSerializableTransactionsTest.java | 142 +++-
.../cache/GridCacheAbstractFullApiSelfTest.java | 141 ++++
.../GridCacheInterceptorAbstractSelfTest.java | 172 +++-
...GridCacheDhtEvictionNearReadersSelfTest.java | 2 +-
.../multijvm/IgniteCacheProcessProxy.java | 59 +-
.../testsuites/IgniteCacheTestSuite4.java | 12 +
.../config/benchmark-multicast.properties | 7 +
.../IgniteGetEntriesPutAllTxBenchmark.java | 73 ++
.../cache/IgnitePutGetEntryBenchmark.java | 47 ++
.../cache/IgnitePutGetEntryTxBenchmark.java | 73 ++
47 files changed, 2644 insertions(+), 342 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index 886dca6..a791e38 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -31,10 +31,12 @@ import javax.cache.CacheException;
import javax.cache.configuration.Configuration;
import javax.cache.event.CacheEntryRemovedListener;
import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.integration.CacheLoader;
import javax.cache.integration.CacheWriter;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.EntryProcessorResult;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CacheMode;
@@ -390,18 +392,59 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
* <code>null</code> value for a key.
*/
@IgniteAsyncSupported
- <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
+ public <T> Map<K, EntryProcessorResult<T>> invokeAll(Map<? extends K, ? extends EntryProcessor<K, V, T>> map,
Object... args);
/** {@inheritDoc} */
@IgniteAsyncSupported
@Override public V get(K key);
+ /**
+ * Gets an entry from the cache.
+ * <p>
+ * If the cache is configured to use read-through, and get would return null
+ * because the entry is missing from the cache, the Cache's {@link CacheLoader}
+ * is called in an attempt to load the entry.
+ *
+ * @param key the key whose associated value is to be returned
+ * @return the element, or null, if it does not exist.
+ * @throws IllegalStateException if the cache is {@link #isClosed()}
+ * @throws NullPointerException if the key is null
+ * @throws CacheException if there is a problem fetching the value
+ * @throws ClassCastException if the implementation is configured to perform
+ * runtime-type-checking, and the key or value types are incompatible with those that have been
+ * configured for the {@link Cache}
+ */
+ @IgniteAsyncSupported
+ public CacheEntry<K, V> getEntry(K key);
+
/** {@inheritDoc} */
@IgniteAsyncSupported
@Override public Map<K, V> getAll(Set<? extends K> keys);
/**
+ * Gets a collection of entries from the {@link Cache}.
+ * <p>
+ * If the cache is configured read-through, and a get for a key would
+ * return null because an entry is missing from the cache, the Cache's
+ * {@link CacheLoader} is called in an attempt to load the entry. If an
+ * entry cannot be loaded for a given key, the key will not be present in
+ * the returned Collection.
+ *
+ * @param keys The keys whose associated values are to be returned.
+ * @return A collection of entries that were found for the given keys. Entries not found
+ * in the cache are not in the returned collection.
+ * @throws NullPointerException if keys is null or if keys contains a null
+ * @throws IllegalStateException if the cache is {@link #isClosed()}
+ * @throws CacheException if there is a problem fetching the values
+ * @throws ClassCastException if the implementation is configured to perform
+ * runtime-type-checking, and the key or value types are incompatible with those that have been
+ * configured for the {@link Cache}
+ */
+ @IgniteAsyncSupported
+ public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys);
+
+ /**
* Gets values from cache. Will bypass started transaction, if any, i.e. will not enlist entries
* and will not lock any keys if pessimistic transaction is started by thread.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
index 1c7111a..af926c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImplEx.java
@@ -21,9 +21,13 @@ import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
+import static org.apache.ignite.internal.processors.cache.transactions.IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
+
/**
*
*/
@@ -54,6 +58,14 @@ public class CacheEntryImplEx<K, V> extends CacheEntryImpl<K, V> implements Cach
/** {@inheritDoc} */
public GridCacheVersion version() {
+ if (ver == GET_ENTRY_INVALID_VER_AFTER_GET) {
+ throw new IgniteException("Impossible to get entry version after " +
+ "get() inside OPTIMISTIC REPEATABLE_READ transaction. Use only getEntry() or getEntries() inside " +
+ "OPTIMISTIC REPEATABLE_READ transaction to solve this problem.");
+ }
+ else if (ver == GET_ENTRY_INVALID_VER_UPDATED)
+ throw new IgniteException("Impossible to get version for entry updated in transaction.");
+
return ver;
}
@@ -81,7 +93,7 @@ public class CacheEntryImplEx<K, V> extends CacheEntryImpl<K, V> implements Cach
String res = "CacheEntry [key=" + getKey() +
", val=" + getValue();
- if (ver != null) {
+ if (ver != null && ver != GET_ENTRY_INVALID_VER_AFTER_GET && ver != GET_ENTRY_INVALID_VER_UPDATED) {
res += ", topVer=" + ver.topologyVersion() +
", nodeOrder=" + ver.nodeOrder() +
", order=" + ver.order() +
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9fd65e5..69abc54 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -52,6 +52,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheInterceptor;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
@@ -607,7 +608,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/*task name*/null,
/*deserialize binary*/false,
/*skip values*/true,
- /*can remap*/true
+ /*can remap*/true,
+ false
);
}
@@ -633,7 +635,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/*task name*/null,
/*deserialize binary*/false,
/*skip values*/true,
- /*can remap*/true
+ /*can remap*/true,
+ false
).chain(new CX1<IgniteInternalFuture<Map<K, V>>, Boolean>() {
@Override public Boolean applyx(IgniteInternalFuture<Map<K, V>> fut) throws IgniteCheckedException {
Map<K, V> kvMap = fut.get();
@@ -1296,7 +1299,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
/*deserialize cache objects*/true,
/*skip values*/false,
- /*can remap*/true
+ /*can remap*/true,
+ false
).get().get(key);
}
@@ -1312,7 +1316,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
true,
false,
- /*can remap*/true
+ /*can remap*/true,
+ false
).chain(new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
@Override public V applyx(IgniteInternalFuture<Map<K, V>> e) throws IgniteCheckedException {
return e.get().get(key);
@@ -1332,7 +1337,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
/*deserialize cache objects*/true,
/*skip values*/false,
- /*can remap*/false
+ /*can remap*/false,
+ false
).get().get(key);
}
@@ -1352,7 +1358,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
!ctx.keepBinary(),
/*skip values*/false,
- /*can remap*/true);
+ /*can remap*/true,
+ false);
}
/**
@@ -1372,7 +1379,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
long start = statsEnabled ? System.nanoTime() : 0L;
- V val = get(key, !ctx.keepBinary());
+ V val = get(key, !ctx.keepBinary(), false);
if (ctx.config().getInterceptor() != null)
val = (V)ctx.config().getInterceptor().onGet(key, val);
@@ -1384,6 +1391,30 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
+ @Nullable @Override public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException {
+ A.notNull(key, "key");
+
+ boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+ long start = statsEnabled ? System.nanoTime() : 0L;
+
+ T2<V, GridCacheVersion> t = (T2<V, GridCacheVersion>)get(key, !ctx.keepBinary(), true);
+
+ CacheEntry<K, V> val = t != null ? new CacheEntryImplEx<>(key, t.get1(), t.get2()): null;
+
+ if (ctx.config().getInterceptor() != null) {
+ V val0 = (V)ctx.config().getInterceptor().onGet(key, t != null ? val.getValue() : null);
+
+ val = (val0 != null) ? new CacheEntryImplEx<>(key, val0, t != null ? t.get2() : null) : null;
+ }
+
+ if (statsEnabled)
+ metrics0().addGetTimeNanos(System.nanoTime() - start);
+
+ return val;
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteInternalFuture<V> getAsync(final K key) {
A.notNull(key, "key");
@@ -1391,7 +1422,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final long start = statsEnabled ? System.nanoTime() : 0L;
- IgniteInternalFuture<V> fut = getAsync(key, !ctx.keepBinary());
+ IgniteInternalFuture<V> fut = getAsync(key, !ctx.keepBinary(), false);
if (ctx.config().getInterceptor() != null)
fut = fut.chain(new CX1<IgniteInternalFuture<V>, V>() {
@@ -1407,6 +1438,42 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
+ @Override public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(final K key) {
+ A.notNull(key, "key");
+
+ final boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+ final long start = statsEnabled ? System.nanoTime() : 0L;
+
+ IgniteInternalFuture<T2<V, GridCacheVersion>> fut =
+ (IgniteInternalFuture<T2<V, GridCacheVersion>>)getAsync(key, !ctx.keepBinary(), true);
+
+ final boolean intercept = ctx.config().getInterceptor() != null;
+
+ IgniteInternalFuture<CacheEntry<K, V>> fr = fut.chain(
+ new CX1<IgniteInternalFuture<T2<V, GridCacheVersion>>, CacheEntry<K, V>>() {
+ @Override public CacheEntry<K, V> applyx(IgniteInternalFuture<T2<V, GridCacheVersion>> f)
+ throws IgniteCheckedException {
+ T2<V, GridCacheVersion> t = f.get();
+
+ CacheEntry<K, V> val = t != null ? new CacheEntryImplEx<>(key, t.get1(), t.get2()) : null;
+ if (intercept) {
+ V val0 = (V)ctx.config().getInterceptor().onGet(key, t != null ? val.getValue() : null);
+
+ return new CacheEntryImplEx<>(key, val0, t != null ? t.get2() : null);
+ }
+ else
+ return val;
+ }
+ });
+
+ if (statsEnabled)
+ fut.listen(new UpdateGetTimeStatClosure<T2<V, GridCacheVersion>>(metrics0(), start));
+
+ return fr;
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException {
A.notNull(keys, "keys");
@@ -1414,7 +1481,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
long start = statsEnabled ? System.nanoTime() : 0L;
- Map<K, V> map = getAll(keys, !ctx.keepBinary());
+ Map<K, V> map = getAll(keys, !ctx.keepBinary(), false);
if (ctx.config().getInterceptor() != null)
map = interceptGet(keys, map);
@@ -1426,6 +1493,32 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/** {@inheritDoc} */
+ @Override public Collection<CacheEntry<K, V>> getEntries(@Nullable Collection<? extends K> keys)
+ throws IgniteCheckedException {
+ A.notNull(keys, "keys");
+
+ boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+ long start = statsEnabled ? System.nanoTime() : 0L;
+
+ Map<K, T2<V, GridCacheVersion>> map = (Map<K, T2<V, GridCacheVersion>>)getAll(keys, !ctx.keepBinary(), true);
+
+ Collection<CacheEntry<K, V>> res = new HashSet<>();
+
+ if (ctx.config().getInterceptor() != null)
+ res = interceptGetEntries(keys, map);
+ else
+ for (Map.Entry<K, T2<V, GridCacheVersion>> e : map.entrySet())
+ res.add(new CacheEntryImplEx<>(e.getKey(), e.getValue().get1(), e.getValue().get2()));
+
+ if (statsEnabled)
+ metrics0().addGetTimeNanos(System.nanoTime() - start);
+
+ return res;
+ }
+
+
+ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) {
A.notNull(keys, "keys");
@@ -1433,7 +1526,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final long start = statsEnabled ? System.nanoTime() : 0L;
- IgniteInternalFuture<Map<K, V>> fut = getAllAsync(keys, !ctx.keepBinary());
+ IgniteInternalFuture<Map<K, V>> fut = getAllAsync(keys, !ctx.keepBinary(), false);
if (ctx.config().getInterceptor() != null)
return fut.chain(new CX1<IgniteInternalFuture<Map<K, V>>, Map<K, V>>() {
@@ -1448,6 +1541,45 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
return fut;
}
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(
+ @Nullable final Collection<? extends K> keys) {
+ A.notNull(keys, "keys");
+
+ final boolean statsEnabled = ctx.config().isStatisticsEnabled();
+
+ final long start = statsEnabled ? System.nanoTime() : 0L;
+
+ IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>> fut =
+ (IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>>)
+ ((IgniteInternalFuture)getAllAsync(keys, !ctx.keepBinary(), true));
+
+ final boolean intercept = ctx.config().getInterceptor() != null;
+
+ IgniteInternalFuture<Collection<CacheEntry<K, V>>> rf =
+ fut.chain(new CX1<IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>>, Collection<CacheEntry<K, V>>>() {
+ @Override public Collection<CacheEntry<K, V>> applyx(
+ IgniteInternalFuture<Map<K, T2<V, GridCacheVersion>>> f) throws IgniteCheckedException {
+ if (intercept)
+ return interceptGetEntries(keys, f.get());
+ else {
+ Map<K, CacheEntry<K, V>> res = U.newHashMap(f.get().size());
+
+ for (Map.Entry<K, T2<V, GridCacheVersion>> e : f.get().entrySet())
+ res.put(e.getKey(),
+ new CacheEntryImplEx<>(e.getKey(), e.getValue().get1(), e.getValue().get2()));
+
+ return res.values();
+ }
+ }
+ });
+
+ if (statsEnabled)
+ fut.listen(new UpdateGetTimeStatClosure<Map<K, T2<V, GridCacheVersion>>>(metrics0(), start));
+
+ return rf;
+ }
+
/**
* Applies cache interceptor on result of 'get' operation.
*
@@ -1490,6 +1622,53 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
/**
+ * Applies cache interceptor on result of 'getEntries' operation.
+ *
+ * @param keys All requested keys.
+ * @param map Result map.
+ * @return Map with values returned by cache interceptor..
+ */
+ @SuppressWarnings("IfMayBeConditional")
+ private Collection<CacheEntry<K, V>> interceptGetEntries(
+ @Nullable Collection<? extends K> keys, Map<K, T2<V, GridCacheVersion>> map) {
+ Map<K, CacheEntry<K, V>> res;
+
+ if (F.isEmpty(keys)) {
+ assert map.isEmpty();
+
+ return Collections.emptySet();
+ }
+
+ res = U.newHashMap(keys.size());
+
+ CacheInterceptor<K, V> interceptor = cacheCfg.getInterceptor();
+
+ assert interceptor != null;
+
+ for (Map.Entry<K, T2<V, GridCacheVersion>> e : map.entrySet()) {
+ V val = interceptor.onGet(e.getKey(), e.getValue().get1());
+
+ if (val != null)
+ res.put(e.getKey(), new CacheEntryImplEx<>(e.getKey(), val, e.getValue().get2()));
+ }
+
+ if (map.size() != keys.size()) { // Not all requested keys were in cache.
+ for (K key : keys) {
+ if (key != null) {
+ if (!map.containsKey(key)) {
+ V val = interceptor.onGet(key, null);
+
+ if (val != null)
+ res.put(key, new CacheEntryImplEx<>(key, val, null));
+ }
+ }
+ }
+ }
+
+ return res.values();
+ }
+
+ /**
* @param key Key.
* @param forcePrimary Force primary.
* @param skipTx Skip tx.
@@ -1498,6 +1677,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param deserializeBinary Deserialize binary.
* @param skipVals Skip values.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Future for the get operation.
*/
protected IgniteInternalFuture<V> getAsync(
@@ -1508,7 +1688,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
String taskName,
boolean deserializeBinary,
final boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
return getAllAsync(Collections.singletonList(key),
forcePrimary,
@@ -1517,7 +1698,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
skipVals,
- canRemap).chain(
+ canRemap,
+ needVer).chain(
new CX1<IgniteInternalFuture<Map<K, V>>, V>() {
@Override public V applyx(IgniteInternalFuture<Map<K, V>> e) throws IgniteCheckedException {
Map<K, V> map = e.get();
@@ -1544,6 +1726,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param deserializeBinary Deserialize binary.
* @param skipVals Skip values.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Future for the get operation.
* @see GridCacheAdapter#getAllAsync(Collection)
*/
@@ -1555,7 +1738,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
String taskName,
boolean deserializeBinary,
boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -1570,7 +1754,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
forcePrimary,
skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
skipVals,
- canRemap);
+ canRemap,
+ needVer);
}
/**
@@ -1584,6 +1769,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param expiry Expiry policy.
* @param skipVals Skip values.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Future for the get operation.
* @see GridCacheAdapter#getAllAsync(Collection)
*/
@@ -1596,7 +1782,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean forcePrimary,
@Nullable IgniteCacheExpiryPolicy expiry,
final boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -1613,7 +1800,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
skipVals,
false,
canRemap,
- false);
+ needVer);
}
/**
@@ -1708,20 +1895,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
ctx.evicts().touch(entry, topVer);
}
else {
- if (needVer) {
- assert keepCacheObjects;
-
- map.put((K1)key, (V1)new T2<>(res.get1(), res.get2()));
- }
- else {
- ctx.addResult(map,
- key,
- res.get1(),
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- true);
- }
+ ctx.addResult(map,
+ key,
+ res.get1(),
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ true,
+ needVer ? res.get2() : null);
if (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED))
ctx.evicts().touch(entry, topVer);
@@ -1783,20 +1964,14 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
// Don't put key-value pair into result map if value is null.
if (val != null) {
- if (needVer) {
- assert keepCacheObjects;
-
- map.put((K1)key, (V1)new T2<>(cacheVal, set ? verSet : ver));
- }
- else {
- ctx.addResult(map,
- key,
- cacheVal,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false);
- }
+ ctx.addResult(map,
+ key,
+ cacheVal,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ needVer ? set ? verSet : ver : null);
}
if (tx0 == null || (!tx0.implicit() &&
@@ -1889,11 +2064,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
}
else {
- assert !needVer;
-
return asyncOp(tx, new AsyncOp<Map<K1, V1>>(keys) {
@Override public IgniteInternalFuture<Map<K1, V1>> op(IgniteTxLocalAdapter tx) {
- return tx.getAllAsync(ctx, keys, deserializeBinary, skipVals, false, !readThrough);
+ return tx.getAllAsync(ctx, keys, deserializeBinary, skipVals, false, !readThrough, needVer);
}
}, ctx.operationContextPerCall());
}
@@ -4494,28 +4667,31 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
/**
* @param key Key.
* @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
* @return Cached value.
* @throws IgniteCheckedException If failed.
*/
- @Nullable public V get(K key, boolean deserializeBinary) throws IgniteCheckedException {
+ @Nullable public V get(K key, boolean deserializeBinary, final boolean needVer) throws IgniteCheckedException {
checkJta();
String taskName = ctx.kernalContext().job().currentTaskName();
- return get(key, taskName, deserializeBinary);
+ return get(key, taskName, deserializeBinary, needVer);
}
/**
* @param key Key.
* @param taskName Task name.
* @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
* @return Cached value.
* @throws IgniteCheckedException If failed.
*/
protected V get(
final K key,
String taskName,
- boolean deserializeBinary) throws IgniteCheckedException {
+ boolean deserializeBinary,
+ boolean needVer) throws IgniteCheckedException {
return getAsync(key,
!ctx.config().isReadFromBackup(),
/*skip tx*/false,
@@ -4523,15 +4699,17 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
false,
- /*can remap*/true).get();
+ /*can remap*/true,
+ needVer).get();
}
/**
* @param key Key.
* @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
* @return Read operation future.
*/
- public final IgniteInternalFuture<V> getAsync(final K key, boolean deserializeBinary) {
+ public final IgniteInternalFuture<V> getAsync(final K key, boolean deserializeBinary, final boolean needVer) {
try {
checkJta();
}
@@ -4548,28 +4726,32 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
false,
- /*can remap*/true);
+ /*can remap*/true,
+ needVer);
}
/**
* @param keys Keys.
* @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
* @return Map of cached values.
* @throws IgniteCheckedException If read failed.
*/
- public Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary) throws IgniteCheckedException {
+ public Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary,
+ boolean needVer) throws IgniteCheckedException {
checkJta();
- return getAllAsync(keys, deserializeBinary).get();
+ return getAllAsync(keys, deserializeBinary, needVer).get();
}
/**
* @param keys Keys.
* @param deserializeBinary Deserialize binary flag.
+ * @param needVer Need version.
* @return Read future.
*/
public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys,
- boolean deserializeBinary) {
+ boolean deserializeBinary, boolean needVer) {
String taskName = ctx.kernalContext().job().currentTaskName();
return getAllAsync(keys,
@@ -4579,7 +4761,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
taskName,
deserializeBinary,
/*skip vals*/false,
- /*can remap*/true);
+ /*can remap*/true,
+ needVer);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/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 fc48b9d..e875df0 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
@@ -49,12 +49,12 @@ import org.apache.ignite.internal.GridKernalContext;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.managers.communication.GridIoManager;
import org.apache.ignite.internal.managers.deployment.GridDeploymentManager;
import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
-import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
@@ -91,6 +91,7 @@ import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.GPC;
@@ -1882,6 +1883,7 @@ public class GridCacheContext<K, V> implements Externalizable {
* @param keepCacheObjects Keep cache objects flag.
* @param deserializeBinary Deserialize binary flag.
* @param cpy Copy flag.
+ * @param ver GridCacheVersion.
*/
@SuppressWarnings("unchecked")
public <K1, V1> void addResult(Map<K1, V1> map,
@@ -1890,7 +1892,8 @@ public class GridCacheContext<K, V> implements Externalizable {
boolean skipVals,
boolean keepCacheObjects,
boolean deserializeBinary,
- boolean cpy) {
+ boolean cpy,
+ final GridCacheVersion ver) {
assert key != null;
assert val != null || skipVals;
@@ -1902,10 +1905,32 @@ public class GridCacheContext<K, V> implements Externalizable {
assert key0 != null : key;
assert val0 != null : val;
- map.put((K1)key0, (V1)val0);
+ map.put((K1)key0, ver != null ? (V1)new T2<>(val0, ver) : (V1)val0);
}
else
- map.put((K1)key, (V1)(skipVals ? true : val));
+ map.put((K1)key,
+ (V1)(ver != null ?
+ (V1)new T2<>(skipVals ? true : val, ver) :
+ skipVals ? true : val));
+ }
+
+ /**
+ * @param map Map.
+ * @param key Key.
+ * @param val Value.
+ * @param skipVals Skip values flag.
+ * @param keepCacheObjects Keep cache objects flag.
+ * @param deserializeBinary Deserialize binary flag.
+ * @param cpy Copy flag.
+ */
+ public <K1, V1> void addResult(Map<K1, V1> map,
+ KeyCacheObject key,
+ CacheObject val,
+ boolean skipVals,
+ boolean keepCacheObjects,
+ boolean deserializeBinary,
+ boolean cpy) {
+ addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, cpy, null);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/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 2d25d16..64cfd01 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
@@ -882,7 +882,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
updateTtl(expiryPlc);
if (retVer) {
- resVer = isNear() ? ((GridNearCacheEntry)this).dhtVersion() : this.ver;
+ resVer = (isNear() && cctx.transactional()) ? ((GridNearCacheEntry)this).dhtVersion() : this.ver;
if (resVer == null)
ret = null;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 3a53942..9b4aff3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -31,6 +31,7 @@ import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.cache.affinity.Affinity;
@@ -307,6 +308,18 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
+ @Nullable @Override public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException {
+ CacheOperationContext prev = gate.enter(opCtx);
+
+ try {
+ return delegate.getEntry(key);
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public V getTopologySafe(K key) throws IgniteCheckedException {
CacheOperationContext prev = gate.enter(opCtx);
@@ -331,6 +344,18 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
+ @Override public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(K key) {
+ CacheOperationContext prev = gate.enter(opCtx);
+
+ try {
+ return delegate.getEntryAsync(key);
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public V getForcePrimary(K key) throws IgniteCheckedException {
CacheOperationContext prev = gate.enter(opCtx);
@@ -451,6 +476,19 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
+ @Override public Collection<CacheEntry<K, V>> getEntries(
+ @Nullable Collection<? extends K> keys) throws IgniteCheckedException {
+ CacheOperationContext prev = gate.enter(opCtx);
+
+ try {
+ return delegate.getEntries(keys);
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys) {
CacheOperationContext prev = gate.enter(opCtx);
@@ -463,6 +501,19 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
}
/** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(
+ @Nullable Collection<? extends K> keys) {
+ CacheOperationContext prev = gate.enter(opCtx);
+
+ try {
+ return delegate.getEntriesAsync(keys);
+ }
+ finally {
+ gate.leave(prev);
+ }
+ }
+
+ /** {@inheritDoc} */
@Nullable @Override public V getAndPut(K key, V val)
throws IgniteCheckedException {
CacheOperationContext prev = gate.enter(opCtx);
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index 9e66d4d..5ed8753 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -44,6 +44,7 @@ import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheEntryProcessor;
import org.apache.ignite.cache.CacheManager;
import org.apache.ignite.cache.CacheMetrics;
@@ -873,6 +874,31 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public CacheEntry<K, V> getEntry(K key) {
+ try {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ if (isAsync()) {
+ setFuture(delegate.getEntryAsync(key));
+
+ return null;
+ }
+ else
+ return delegate.getEntry(key);
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAll(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
@@ -898,6 +924,31 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V
}
/** {@inheritDoc} */
+ @Override public Collection<CacheEntry<K, V>> getEntries(Set<? extends K> keys) {
+ try {
+ GridCacheGateway<K, V> gate = this.gate;
+
+ CacheOperationContext prev = onEnter(gate, opCtx);
+
+ try {
+ if (isAsync()) {
+ setFuture(delegate.getEntriesAsync(keys));
+
+ return null;
+ }
+ else
+ return delegate.getEntries(keys);
+ }
+ finally {
+ onLeave(gate, prev);
+ }
+ }
+ catch (IgniteCheckedException e) {
+ throw cacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public Map<K, V> getAllOutTx(Set<? extends K> keys) {
try {
GridCacheGateway<K, V> gate = this.gate;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 433290c..68d0f06 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -31,6 +31,7 @@ import javax.cache.processor.EntryProcessorResult;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheMetrics;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CachePeekMode;
@@ -335,6 +336,28 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
@Nullable public V get(K key) throws IgniteCheckedException;
/**
+ * Retrieves value mapped to the specified key from cache. Value will only be returned if
+ * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+ * returned value is guaranteed to be consistent with the filter. The return value of {@code null}
+ * means entry did not pass the provided filter or cache has no mapping for the
+ * key.
+ * <p>
+ * If the value is not present in cache, then it will be looked up from swap storage. If
+ * it's not present in swap, or if swap is disable, and if read-through is allowed, value
+ * will be loaded from {@link CacheStore} persistent storage via
+ * <code>CacheStore#load(Transaction, Object)</code> method.
+ * <h2 class="header">Transactions</h2>
+ * This method is transactional and will enlist the entry into ongoing transaction
+ * if there is one.
+ *
+ * @param key Key to retrieve the value for.
+ * @return Value for the given key.
+ * @throws IgniteCheckedException If get operation failed.
+ * @throws NullPointerException if the key is {@code null}.
+ */
+ @Nullable public CacheEntry<K, V> getEntry(K key) throws IgniteCheckedException;
+
+ /**
* Asynchronously retrieves value mapped to the specified key from cache. Value will only be returned if
* its entry passed the optional filter provided. Filter check is atomic, and therefore the
* returned value is guaranteed to be consistent with the filter. The return value of {@code null}
@@ -356,6 +379,27 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
public IgniteInternalFuture<V> getAsync(K key);
/**
+ * Asynchronously retrieves value mapped to the specified key from cache. Value will only be returned if
+ * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+ * returned value is guaranteed to be consistent with the filter. The return value of {@code null}
+ * means entry did not pass the provided filter or cache has no mapping for the
+ * key.
+ * <p>
+ * If the value is not present in cache, then it will be looked up from swap storage. If
+ * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+ * will be loaded from {@link CacheStore} persistent storage via
+ * <code>CacheStore#load(Transaction, Object)</code> method.
+ * <h2 class="header">Transactions</h2>
+ * This method is transactional and will enlist the entry into ongoing transaction
+ * if there is one.
+ *
+ * @param key Key for the value to get.
+ * @return Future for the get operation.
+ * @throws NullPointerException if the key is {@code null}.
+ */
+ public IgniteInternalFuture<CacheEntry<K, V>> getEntryAsync(K key);
+
+ /**
* Retrieves values mapped to the specified keys from cache. Value will only be returned if
* its entry passed the optional filter provided. Filter check is atomic, and therefore the
* returned value is guaranteed to be consistent with the filter. If requested key-value pair
@@ -377,6 +421,27 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws IgniteCheckedException;
/**
+ * Retrieves values mapped to the specified keys from cache. Value will only be returned if
+ * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+ * returned value is guaranteed to be consistent with the filter. If requested key-value pair
+ * is not present in the returned map, then it means that its entry did not pass the provided
+ * filter or cache has no mapping for the key.
+ * <p>
+ * If some value is not present in cache, then it will be looked up from swap storage. If
+ * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+ * will be loaded from {@link CacheStore} persistent storage via
+ * <code>CacheStore#loadAll(Transaction, Collection, org.apache.ignite.lang.IgniteBiInClosure)</code> method.
+ * <h2 class="header">Transactions</h2>
+ * This method is transactional and will enlist the entry into ongoing transaction
+ * if there is one.
+ *
+ * @param keys Keys to get.
+ * @return Map of key-value pairs.
+ * @throws IgniteCheckedException If get operation failed.
+ */
+ public Collection<CacheEntry<K, V>> getEntries(@Nullable Collection<? extends K> keys) throws IgniteCheckedException;
+
+ /**
* Asynchronously retrieves values mapped to the specified keys from cache. Value will only be returned if
* its entry passed the optional filter provided. Filter check is atomic, and therefore the
* returned value is guaranteed to be consistent with the filter. If requested key-value pair
@@ -397,6 +462,26 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
public IgniteInternalFuture<Map<K, V>> getAllAsync(@Nullable Collection<? extends K> keys);
/**
+ * Asynchronously retrieves values mapped to the specified keys from cache. Value will only be returned if
+ * its entry passed the optional filter provided. Filter check is atomic, and therefore the
+ * returned value is guaranteed to be consistent with the filter. If requested key-value pair
+ * is not present in the returned map, then it means that its entry did not pass the provided
+ * filter or cache has no mapping for the key.
+ * <p>
+ * If some value is not present in cache, then it will be looked up from swap storage. If
+ * it's not present in swap, or if swap is disabled, and if read-through is allowed, value
+ * will be loaded from {@link CacheStore} persistent storage via
+ * <code>CacheStore#loadAll(Transaction, Collection, org.apache.ignite.lang.IgniteBiInClosure)</code> method.
+ * <h2 class="header">Transactions</h2>
+ * This method is transactional and will enlist the entry into ongoing transaction
+ * if there is one.
+ *
+ * @param keys Key for the value to get.
+ * @return Future for the get operation.
+ */
+ public IgniteInternalFuture<Collection<CacheEntry<K, V>>> getEntriesAsync(@Nullable Collection<? extends K> keys);
+
+ /**
* Stores given key-value pair in cache. If filters are provided, then entries will
* be stored in cache only if they pass the filter. Note that filter check is atomic,
* so value stored in cache is guaranteed to be consistent with the filters. If cache
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
index 7efaf49..28c94dd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/CacheDistributedGetFutureAdapter.java
@@ -153,21 +153,6 @@ public abstract class CacheDistributedGetFutureAdapter<K, V> extends GridCompoun
}
/**
- * @param map Result map.
- * @param key Key.
- * @param val Value.
- * @param ver Version.
- */
- @SuppressWarnings("unchecked")
- protected final void versionedResult(Map map, KeyCacheObject key, Object val, GridCacheVersion ver) {
- assert needVer;
- assert skipVals || val != null;
- assert ver != null;
-
- map.put(key, new T2<>(skipVals ? true : val, ver));
- }
-
- /**
* Affinity node to send get request to.
*
* @param affNodes All affinity nodes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 9cf8084..5be4e72 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -617,6 +617,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
* @param keys {@inheritDoc}
* @param forcePrimary {@inheritDoc}
* @param skipTx {@inheritDoc}
+ * @param needVer Need version.
* @return {@inheritDoc}
*/
@Override public IgniteInternalFuture<Map<K, V>> getAllAsync(
@@ -627,7 +628,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
String taskName,
boolean deserializeBinary,
boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ boolean needVer
) {
CacheOperationContext opCtx = ctx.operationContextPerCall();
@@ -640,7 +642,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
forcePrimary,
null,
skipVals,
- canRemap);
+ canRemap,
+ needVer);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index cb8c842..c926c13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -383,7 +383,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
/*deserialize binary*/false,
skipVals,
/*keep cache objects*/true,
- /*skip store*/!readThrough);
+ /*skip store*/!readThrough,
+ false);
}
}
else {
@@ -413,7 +414,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
/*deserialize binary*/false,
skipVals,
/*keep cache objects*/true,
- /*skip store*/!readThrough);
+ /*skip store*/!readThrough,
+ false);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index d8b2f37..41b28d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -946,7 +946,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (retVal ||
!F.isEmpty(e.entryProcessors()) ||
!F.isEmpty(e.filters()) ||
- e.serializableReadVersion() != null) {
+ e.entryReadVersion() != null) {
if (map == null)
map = new HashMap<>();
@@ -1013,7 +1013,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
throws IgniteCheckedException {
try {
for (IgniteTxEntry entry : entries) {
- GridCacheVersion serReadVer = entry.serializableReadVersion();
+ GridCacheVersion serReadVer = entry.entryReadVersion();
if (serReadVer != null) {
entry.cached().unswap();
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 1f2d7c5..2c9a760 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -490,17 +490,14 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
cache.removeIfObsolete(key);
}
else {
- if (needVer)
- versionedResult(locVals, key, v, ver);
- else {
- cctx.addResult(locVals,
- key,
- v,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- true);
- }
+ cctx.addResult(locVals,
+ key,
+ v,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ true,
+ ver);
return true;
}
@@ -552,17 +549,14 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
for (GridCacheEntryInfo info : infos) {
assert skipVals == (info.value() == null);
- if (needVer)
- versionedResult(map, info.key(), info.value(), info.version());
- else {
- cctx.addResult(map,
- info.key(),
- info.value(),
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false);
- }
+ cctx.addResult(map,
+ info.key(),
+ info.value(),
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ needVer ? info.version() : null);
}
return map;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index 0c811ae..01e61bf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -625,20 +625,13 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
assert !skipVals;
if (val != null) {
- if (needVer) {
- assert ver != null;
+ if (!keepCacheObjects) {
+ Object res = cctx.unwrapBinaryIfNeeded(val, !deserializeBinary);
- onDone(new T2<>(val, ver));
- }
- else {
- if (!keepCacheObjects) {
- Object res = cctx.unwrapBinaryIfNeeded(val, !deserializeBinary);
-
- onDone(res);
- }
- else
- onDone(val);
+ onDone(needVer ? new T2<>(res, ver) : res);
}
+ else
+ onDone(needVer ? new T2<>(val, ver) : val);
}
else
onDone(null);
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/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 cba4e61..b806906 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
@@ -93,6 +93,7 @@ import org.apache.ignite.internal.util.typedef.CO;
import org.apache.ignite.internal.util.typedef.CX1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.P1;
+import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -317,7 +318,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
}
/** {@inheritDoc} */
- @Override protected V get(K key, String taskName, boolean deserializeBinary) throws IgniteCheckedException {
+ @Override protected V get(K key, String taskName, boolean deserializeBinary, boolean needVer)
+ throws IgniteCheckedException {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
if (keyCheck)
@@ -339,7 +341,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
expiryPlc,
false,
skipStore,
- true).get();
+ true,
+ needVer).get();
}
/** {@inheritDoc} */
@@ -350,7 +353,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- final boolean canRemap) {
+ final boolean canRemap,
+ final boolean needVer) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
if (keyCheck)
@@ -376,7 +380,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
expiryPlc,
skipVals,
skipStore,
- canRemap);
+ canRemap,
+ needVer);
}
});
}
@@ -390,7 +395,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
final String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- final boolean canRemap
+ final boolean canRemap,
+ final boolean needVer
) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -420,7 +426,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
expiryPlc,
skipVals,
skipStore,
- canRemap);
+ canRemap,
+ needVer);
}
});
}
@@ -1098,6 +1105,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
* @param skipVals Skip values flag.
* @param skipStore Skip store flag.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Get future.
*/
private IgniteInternalFuture<V> getAsync0(KeyCacheObject key,
@@ -1108,7 +1116,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
@Nullable ExpiryPolicy expiryPlc,
boolean skipVals,
boolean skipStore,
- boolean canRemap
+ boolean canRemap,
+ boolean needVer
) {
AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() :
ctx.shared().exchange().readyAffinityVersion();
@@ -1126,7 +1135,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
expiry,
skipVals,
canRemap,
- false,
+ needVer,
false);
fut.init();
@@ -1145,6 +1154,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
* @param expiryPlc Expiry policy.
* @param skipVals Skip values flag.
* @param skipStore Skip store flag.
+ * @param needVer Need version.
* @return Get future.
*/
private IgniteInternalFuture<Map<K, V>> getAllAsync0(@Nullable Collection<KeyCacheObject> keys,
@@ -1155,7 +1165,8 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
@Nullable ExpiryPolicy expiryPlc,
boolean skipVals,
boolean skipStore,
- boolean canRemap
+ boolean canRemap,
+ boolean needVer
) {
AffinityTopologyVersion topVer = canRemap ? ctx.affinity().affinityTopologyVersion() :
ctx.shared().exchange().readyAffinityVersion();
@@ -1180,19 +1191,42 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (entry != null) {
boolean isNew = entry.isNewLocked();
- CacheObject v = entry.innerGet(null,
- /*swap*/true,
- /*read-through*/false,
- /*fail-fast*/true,
- /*unmarshal*/true,
- /**update-metrics*/false,
- /*event*/!skipVals,
- /*temporary*/false,
- subjId,
- null,
- taskName,
- expiry,
- !deserializeBinary);
+ CacheObject v = null;
+ GridCacheVersion ver = null;
+
+ if (needVer) {
+ T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ null,
+ /*swap*/true,
+ /*unmarshal*/true,
+ /**update-metrics*/false,
+ /*event*/!skipVals,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ true);
+
+ if (res != null) {
+ v = res.get1();
+ ver = res.get2();
+ }
+ }
+ else {
+ v = entry.innerGet(null,
+ /*swap*/true,
+ /*read-through*/false,
+ /*fail-fast*/true,
+ /*unmarshal*/true,
+ /**update-metrics*/false,
+ /*event*/!skipVals,
+ /*temporary*/false,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary);
+ }
// Entry was not in memory or in swap, so we remove it from cache.
if (v == null) {
@@ -1204,7 +1238,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
success = false;
}
else
- ctx.addResult(locVals, key, v, skipVals, false, deserializeBinary, true);
+ ctx.addResult(locVals, key, v, skipVals, false, deserializeBinary, true, ver);
}
else
success = false;
@@ -1256,7 +1290,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
expiry,
skipVals,
canRemap,
- false,
+ needVer,
false);
fut.init();
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index 073043d..dc4b6bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -200,7 +200,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- boolean canRemap) {
+ boolean canRemap,
+ final boolean needVer) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
if (keyCheck)
@@ -218,7 +219,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
deserializeBinary,
skipVals,
false,
- opCtx != null && opCtx.skipStore());
+ opCtx != null && opCtx.skipStore(),
+ needVer);
return fut.chain(new CX1<IgniteInternalFuture<Map<Object, Object>>, V>() {
@SuppressWarnings("unchecked")
@@ -258,7 +260,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
skipVals,
canRemap,
- /*needVer*/false,
+ needVer,
/*keepCacheObjects*/false);
fut.init();
@@ -275,7 +277,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -297,7 +300,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
deserializeBinary,
skipVals,
false,
- opCtx != null && opCtx.skipStore());
+ opCtx != null && opCtx.skipStore(),
+ needVer);
}
}, opCtx);
}
@@ -318,7 +322,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
deserializeBinary,
skipVals ? null : expiryPolicy(opCtx != null ? opCtx.expiry() : null),
skipVals,
- canRemap);
+ canRemap,
+ needVer);
}
/** {@inheritDoc} */
@@ -345,6 +350,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
* @param expiryPlc Expiry policy.
* @param skipVals Skip values flag.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Loaded values.
*/
public IgniteInternalFuture<Map<K, V>> loadAsync(
@@ -357,7 +363,8 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
boolean deserializeBinary,
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean skipVals,
- boolean canRemap) {
+ boolean canRemap,
+ boolean needVer) {
return loadAsync(keys,
readThrough,
forcePrimary,
@@ -367,7 +374,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
expiryPlc,
skipVals,
canRemap,
- false,
+ needVer,
false);
}
@@ -522,17 +529,14 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
if (locVals == null)
locVals = U.newHashMap(keys.size());
- if (needVer)
- locVals.put((K)key, (V)new T2<>((Object)(skipVals ? true : v), ver));
- else {
- ctx.addResult(locVals,
- key,
- v,
- skipVals,
- keepCacheObj,
- deserializeBinary,
- true);
- }
+ ctx.addResult(locVals,
+ key,
+ v,
+ skipVals,
+ keepCacheObj,
+ deserializeBinary,
+ true,
+ ver);
}
}
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index a2d5adb..63c073d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -400,7 +400,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
String taskName,
boolean deserializeBinary,
boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ boolean needVer
) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -423,7 +424,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> {
skipVals ? null : opCtx != null ? opCtx.expiry() : null,
skipVals,
opCtx != null && opCtx.skipStore(),
- canRemap);
+ canRemap,
+ needVer);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 5bf18d9..c750be6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -230,6 +230,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
* @param skipVal Skip value flag.
* @param skipStore Skip store flag.
* @param canRemap Can remap flag.
+ * @param needVer Need version.
* @return Loaded values.
*/
public IgniteInternalFuture<Map<K, V>> loadAsync(@Nullable IgniteInternalTx tx,
@@ -241,7 +242,8 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
@Nullable ExpiryPolicy expiryPlc,
boolean skipVal,
boolean skipStore,
- boolean canRemap
+ boolean canRemap,
+ boolean needVer
) {
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -261,7 +263,7 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda
expiry,
skipVal,
canRemap,
- false,
+ needVer,
false);
// init() will register future for responses if future has remote mappings.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index c0a1617..026fb4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -350,7 +350,8 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
null,
false,
/*skip store*/false,
- /*can remap*/true
+ /*can remap*/true,
+ false
).get().get(keyValue(false));
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 9291001..06fc0a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -650,26 +650,25 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
*/
@SuppressWarnings("unchecked")
private void addResult(KeyCacheObject key, CacheObject v, GridCacheVersion ver) {
- if (needVer) {
- V val0 = (V)new T2<>(skipVals ? true : v, ver);
+ if (keepCacheObjects) {
+ K key0 = (K)key;
+ V val0 = needVer ?
+ (V)new T2<>(skipVals ? true : v, ver) :
+ (V)(skipVals ? true : v);
- add(new GridFinishedFuture<>(Collections.singletonMap((K)key, val0)));
+ add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
}
else {
- if (keepCacheObjects) {
- K key0 = (K)key;
- V val0 = (V)(skipVals ? true : v);
-
- add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
- }
- else {
- K key0 = (K)cctx.unwrapBinaryIfNeeded(key, !deserializeBinary, false);
- V val0 = !skipVals ?
+ K key0 = (K)cctx.unwrapBinaryIfNeeded(key, !deserializeBinary, false);
+ V val0 = needVer ?
+ (V)new T2<>(!skipVals ?
+ (V)cctx.unwrapBinaryIfNeeded(v, !deserializeBinary, false) :
+ (V)Boolean.TRUE, ver) :
+ !skipVals ?
(V)cctx.unwrapBinaryIfNeeded(v, !deserializeBinary, false) :
(V)Boolean.TRUE;
- add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
- }
+ add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0)));
}
}
@@ -741,16 +740,14 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
assert skipVals == (info.value() == null);
- if (needVer)
- versionedResult(map, key, val, info.version());
- else
- cctx.addResult(map,
- key,
- val,
- skipVals,
- keepCacheObjects,
- deserializeBinary,
- false);
+ cctx.addResult(map,
+ key,
+ val,
+ skipVals,
+ keepCacheObjects,
+ deserializeBinary,
+ false,
+ needVer ? info.version() : null);
}
catch (GridCacheEntryRemovedException ignore) {
if (log.isDebugEnabled())
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 4f9f227..52ebfc8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -107,7 +107,7 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
if (txEntry != null) {
if (entry.context().isLocal()) {
- GridCacheVersion serReadVer = txEntry.serializableReadVersion();
+ GridCacheVersion serReadVer = txEntry.entryReadVersion();
if (serReadVer != null) {
GridCacheContext ctx = entry.context();
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index bae0327..b968e57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -279,6 +279,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
* @param topLocked {@code True} if thread already acquired lock preventing topology change.
*/
private void prepareSingle(IgniteTxEntry write, boolean topLocked) {
+ write.clearEntryReadVersion();
+
AffinityTopologyVersion topVer = tx.topologyVersion();
assert topVer.topologyVersion() > 0;
@@ -339,6 +341,8 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
Queue<GridDistributedTxMapping> mappings = new ArrayDeque<>();
for (IgniteTxEntry write : writes) {
+ write.clearEntryReadVersion();
+
GridDistributedTxMapping updated = map(write, topVer, cur, topLocked);
if (cur != updated) {
[48/50] [abbrv] ignite git commit: IGNITE-2380: Added ability to
start Ignite using configuration from app.config. This closes #417.
Posted by vo...@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-1786
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;
+ }
+ }
+}
[35/50] [abbrv] ignite git commit: Fixed code style.
Posted by vo...@apache.org.
Fixed code style.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bad04209
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bad04209
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bad04209
Branch: refs/heads/ignite-1786
Commit: bad042097f5030c6eef31f4a24e987876ae9176e
Parents: e88cc67
Author: sboikov <sb...@gridgain.com>
Authored: Mon Feb 8 09:47:27 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Feb 8 09:47:27 2016 +0300
----------------------------------------------------------------------
.../util/nio/SelectedSelectionKeySet.java | 65 +++++++++++++-------
1 file changed, 43 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bad04209/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
index 9aa245d..389975a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
@@ -21,63 +21,85 @@ import java.nio.channels.SelectionKey;
import java.util.AbstractSet;
import java.util.Iterator;
+/**
+ *
+ */
final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
-
+ /** */
private SelectionKey[] keysA;
+
+ /** */
private int keysASize;
+
+ /** */
private SelectionKey[] keysB;
+
+ /** */
private int keysBSize;
+
+ /** */
private boolean isA = true;
+ /**
+ *
+ */
SelectedSelectionKeySet() {
keysA = new SelectionKey[1024];
keysB = keysA.clone();
}
- @Override
- public boolean add(SelectionKey o) {
- if (o == null) {
+ /** {@inheritDoc} */
+ @Override public boolean add(SelectionKey o) {
+ if (o == null)
return false;
- }
if (isA) {
int size = keysASize;
keysA[size ++] = o;
keysASize = size;
- if (size == keysA.length) {
+ if (size == keysA.length)
doubleCapacityA();
- }
- } else {
+ }
+ else {
int size = keysBSize;
keysB[size ++] = o;
keysBSize = size;
- if (size == keysB.length) {
+ if (size == keysB.length)
doubleCapacityB();
- }
}
return true;
}
+ /**
+ *
+ */
private void doubleCapacityA() {
SelectionKey[] newKeysA = new SelectionKey[keysA.length << 1];
System.arraycopy(keysA, 0, newKeysA, 0, keysASize);
keysA = newKeysA;
}
+ /**
+ *
+ */
private void doubleCapacityB() {
SelectionKey[] newKeysB = new SelectionKey[keysB.length << 1];
System.arraycopy(keysB, 0, newKeysB, 0, keysBSize);
keysB = newKeysB;
}
+ /**
+ * @return Selection keys.
+ */
SelectionKey[] flip() {
if (isA) {
isA = false;
keysA[keysASize] = null;
keysBSize = 0;
return keysA;
- } else {
+ }
+ else {
isA = true;
keysB[keysBSize] = null;
keysASize = 0;
@@ -85,27 +107,26 @@ final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
}
}
- @Override
- public int size() {
- if (isA) {
+ /** {@inheritDoc} */
+ @Override public int size() {
+ if (isA)
return keysASize;
- } else {
+ else
return keysBSize;
- }
}
- @Override
- public boolean remove(Object o) {
+ /** {@inheritDoc} */
+ @Override public boolean remove(Object o) {
return false;
}
- @Override
- public boolean contains(Object o) {
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object o) {
return false;
}
- @Override
- public Iterator<SelectionKey> iterator() {
+ /** {@inheritDoc} */
+ @Override public Iterator<SelectionKey> iterator() {
throw new UnsupportedOperationException();
}
}
[07/50] [abbrv] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
new file mode 100644
index 0000000..2e6a8a1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -0,0 +1,538 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ 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.Static;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests cache configuration propagation.
+ /// </summary>
+ public class CacheConfigurationTest
+ {
+ /** */
+ private IIgnite _ignite;
+
+ /** */
+ private const string CacheName = "cacheName";
+
+ /** */
+ private static int _factoryProp;
+
+
+ /// <summary>
+ /// Fixture set up.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ CacheConfiguration = new List<CacheConfiguration>
+ {
+ new CacheConfiguration(),
+ GetCustomCacheConfiguration()
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ GridName = CacheName,
+ BinaryConfiguration = new BinaryConfiguration(typeof(Entity)),
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+ }
+ }
+ };
+
+ _ignite = Ignition.Start(cfg);
+ }
+
+ /// <summary>
+ /// Fixture tear down.
+ /// </summary>
+ [TestFixtureTearDown]
+ public void FixtureTearDown()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the default configuration.
+ /// </summary>
+ [Test]
+ public void TestDefaultConfiguration()
+ {
+ AssertConfigIsDefault(new CacheConfiguration());
+
+ AssertConfigIsDefault(_ignite.GetCache<int, int>(null).GetConfiguration());
+
+ AssertConfigIsDefault(_ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == null));
+ }
+
+ /// <summary>
+ /// Tests the custom configuration.
+ /// </summary>
+ [Test]
+ public void TestCustomConfiguration()
+ {
+ AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+ _ignite.GetCache<int, int>(CacheName).GetConfiguration());
+
+ AssertConfigsAreEqual(GetCustomCacheConfiguration(),
+ _ignite.GetConfiguration().CacheConfiguration.Single(c => c.Name == CacheName));
+ }
+
+ /// <summary>
+ /// Tests the create from configuration.
+ /// </summary>
+ [Test]
+ public void TestCreateFromConfiguration()
+ {
+ var cacheName = Guid.NewGuid().ToString();
+ var cfg = GetCustomCacheConfiguration(cacheName);
+
+ var cache = _ignite.CreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+ // Can't create existing cache
+ Assert.Throws<IgniteException>(() => _ignite.CreateCache<int, int>(cfg));
+
+ // Check put-get
+ cache[1] = new Entity { Foo = 1 };
+ Assert.AreEqual(1, cache[1].Foo);
+ }
+
+ /// <summary>
+ /// Tests the get or create from configuration.
+ /// </summary>
+ [Test]
+ public void TestGetOrCreateFromConfiguration()
+ {
+ var cacheName = Guid.NewGuid().ToString();
+ var cfg = GetCustomCacheConfiguration(cacheName);
+
+ var cache = _ignite.GetOrCreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache.GetConfiguration());
+
+ var cache2 = _ignite.GetOrCreateCache<int, Entity>(cfg);
+ AssertConfigsAreEqual(cfg, cache2.GetConfiguration());
+
+ // Check put-get
+ cache[1] = new Entity { Foo = 1 };
+ Assert.AreEqual(1, cache[1].Foo);
+ }
+
+ /// <summary>
+ /// Tests the cache store.
+ /// </summary>
+ [Test]
+ public void TestCacheStore()
+ {
+ _factoryProp = 0;
+
+ var factory = new CacheStoreFactoryTest {TestProperty = 15};
+
+ var cache = _ignite.CreateCache<int, int>(new CacheConfiguration("cacheWithStore")
+ {
+ CacheStoreFactory = factory
+ });
+
+ Assert.AreEqual(factory.TestProperty, _factoryProp);
+
+ var factory0 = cache.GetConfiguration().CacheStoreFactory as CacheStoreFactoryTest;
+
+ Assert.IsNotNull(factory0);
+ Assert.AreEqual(factory.TestProperty, factory0.TestProperty);
+ }
+
+ /// <summary>
+ /// Asserts the configuration is default.
+ /// </summary>
+ private static void AssertConfigIsDefault(CacheConfiguration cfg)
+ {
+ Assert.AreEqual(CacheConfiguration.DefaultBackups, cfg.Backups);
+ Assert.AreEqual(CacheConfiguration.DefaultAtomicityMode, cfg.AtomicityMode);
+ Assert.AreEqual(CacheConfiguration.DefaultCacheMode, cfg.CacheMode);
+ Assert.AreEqual(CacheConfiguration.DefaultCopyOnRead, cfg.CopyOnRead);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEagerTtl, cfg.EagerTtl);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedKeyBufferSize, cfg.EvictSynchronizedKeyBufferSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronized, cfg.EvictSynchronized);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedConcurrencyLevel, cfg.EvictSynchronizedConcurrencyLevel);
+ Assert.AreEqual(CacheConfiguration.DefaultEvictSynchronizedTimeout, cfg.EvictSynchronizedTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultInvalidate, cfg.Invalidate);
+ Assert.AreEqual(CacheConfiguration.DefaultKeepVinaryInStore, cfg.KeepBinaryInStore);
+ Assert.AreEqual(CacheConfiguration.DefaultLoadPreviousValue, cfg.LoadPreviousValue);
+ Assert.AreEqual(CacheConfiguration.DefaultLockTimeout, cfg.LockTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultLongQueryWarningTimeout, cfg.LongQueryWarningTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultMaxConcurrentAsyncOperations, cfg.MaxConcurrentAsyncOperations);
+ Assert.AreEqual(CacheConfiguration.DefaultMaxEvictionOverflowRatio, cfg.MaxEvictionOverflowRatio);
+ Assert.AreEqual(CacheConfiguration.DefaultMemoryMode, cfg.MemoryMode);
+ Assert.AreEqual(CacheConfiguration.DefaultOffHeapMaxMemory, cfg.OffHeapMaxMemory);
+ Assert.AreEqual(CacheConfiguration.DefaultReadFromBackup, cfg.ReadFromBackup);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceBatchSize, cfg.RebalanceBatchSize);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceMode, cfg.RebalanceMode);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceThrottle, cfg.RebalanceThrottle);
+ Assert.AreEqual(CacheConfiguration.DefaultRebalanceTimeout, cfg.RebalanceTimeout);
+ Assert.AreEqual(CacheConfiguration.DefaultSqlOnheapRowCacheSize, cfg.SqlOnheapRowCacheSize);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultStartSize, cfg.StartSize);
+ Assert.AreEqual(CacheConfiguration.DefaultEnableSwap, cfg.EnableSwap);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindBatchSize, cfg.WriteBehindBatchSize);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindEnabled, cfg.WriteBehindEnabled);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushFrequency, cfg.WriteBehindFlushFrequency);
+ Assert.AreEqual(CacheConfiguration.DefaultWriteBehindFlushSize, cfg.WriteBehindFlushSize);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(CacheConfiguration x, CacheConfiguration y)
+ {
+ Assert.AreEqual(x.Backups, y.Backups);
+ Assert.AreEqual(x.AtomicityMode, y.AtomicityMode);
+ Assert.AreEqual(x.CacheMode, y.CacheMode);
+ Assert.AreEqual(x.CopyOnRead, y.CopyOnRead);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.EagerTtl, y.EagerTtl);
+ Assert.AreEqual(x.EvictSynchronizedKeyBufferSize, y.EvictSynchronizedKeyBufferSize);
+ Assert.AreEqual(x.EvictSynchronized, y.EvictSynchronized);
+ Assert.AreEqual(x.EvictSynchronizedConcurrencyLevel, y.EvictSynchronizedConcurrencyLevel);
+ Assert.AreEqual(x.EvictSynchronizedTimeout, y.EvictSynchronizedTimeout);
+ Assert.AreEqual(x.Invalidate, y.Invalidate);
+ Assert.AreEqual(x.KeepBinaryInStore, y.KeepBinaryInStore);
+ Assert.AreEqual(x.LoadPreviousValue, y.LoadPreviousValue);
+ Assert.AreEqual(x.LockTimeout, y.LockTimeout);
+ Assert.AreEqual(x.LongQueryWarningTimeout, y.LongQueryWarningTimeout);
+ Assert.AreEqual(x.MaxConcurrentAsyncOperations, y.MaxConcurrentAsyncOperations);
+ Assert.AreEqual(x.MaxEvictionOverflowRatio, y.MaxEvictionOverflowRatio);
+ Assert.AreEqual(x.MemoryMode, y.MemoryMode);
+ Assert.AreEqual(x.OffHeapMaxMemory, y.OffHeapMaxMemory);
+ Assert.AreEqual(x.ReadFromBackup, y.ReadFromBackup);
+ Assert.AreEqual(x.RebalanceBatchSize, y.RebalanceBatchSize);
+ Assert.AreEqual(x.RebalanceMode, y.RebalanceMode);
+ Assert.AreEqual(x.RebalanceThrottle, y.RebalanceThrottle);
+ Assert.AreEqual(x.RebalanceTimeout, y.RebalanceTimeout);
+ Assert.AreEqual(x.SqlOnheapRowCacheSize, y.SqlOnheapRowCacheSize);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.StartSize, y.StartSize);
+ Assert.AreEqual(x.EnableSwap, y.EnableSwap);
+ Assert.AreEqual(x.WriteBehindBatchSize, y.WriteBehindBatchSize);
+ Assert.AreEqual(x.WriteBehindEnabled, y.WriteBehindEnabled);
+ Assert.AreEqual(x.WriteBehindFlushFrequency, y.WriteBehindFlushFrequency);
+ Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
+
+ AssertConfigsAreEqual(x.QueryEntities, y.QueryEntities);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryEntity> x, ICollection<QueryEntity> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryEntity x, QueryEntity y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.KeyTypeName, y.KeyTypeName);
+ Assert.AreEqual(x.ValueTypeName, y.ValueTypeName);
+
+ AssertConfigsAreEqual(x.Fields, y.Fields);
+ AssertConfigsAreEqual(x.Aliases, y.Aliases);
+
+ AssertConfigsAreEqual(x.Indexes, y.Indexes);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryIndex> x, ICollection<QueryIndex> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryField> x, ICollection<QueryField> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryAlias> x, ICollection<QueryAlias> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(ICollection<QueryIndexField> x, ICollection<QueryIndexField> y)
+ {
+ if (x == null)
+ {
+ Assert.IsNull(y);
+ return;
+ }
+
+ Assert.AreEqual(x.Count, y.Count);
+
+ for (var i = 0; i < x.Count; i++)
+ AssertConfigsAreEqual(x.ElementAt(i), y.ElementAt(i));
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryIndex x, QueryIndex y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.IndexType, y.IndexType);
+
+ AssertConfigsAreEqual(x.Fields, y.Fields);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryField x, QueryField y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.FieldTypeName, y.FieldTypeName);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryAlias x, QueryAlias y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.FullName, y.FullName);
+ Assert.AreEqual(x.Alias, y.Alias);
+ }
+
+ /// <summary>
+ /// Asserts that two configurations have the same properties.
+ /// </summary>
+ private static void AssertConfigsAreEqual(QueryIndexField x, QueryIndexField y)
+ {
+ Assert.IsNotNull(x);
+ Assert.IsNotNull(y);
+
+ Assert.AreEqual(x.Name, y.Name);
+ Assert.AreEqual(x.IsDescending, y.IsDescending);
+ }
+
+ /// <summary>
+ /// Gets the custom cache configuration.
+ /// </summary>
+ private static CacheConfiguration GetCustomCacheConfiguration(string name = null)
+ {
+ return new CacheConfiguration
+ {
+ Name = name ?? CacheName,
+ OffHeapMaxMemory = 1,
+ StartSize = 2,
+ MaxConcurrentAsyncOperations = 3,
+ WriteBehindFlushThreadCount = 4,
+ LongQueryWarningTimeout = TimeSpan.FromSeconds(5),
+ LoadPreviousValue = true,
+ EvictSynchronizedKeyBufferSize = 6,
+ CopyOnRead = true,
+ WriteBehindFlushFrequency = TimeSpan.FromSeconds(6),
+ WriteBehindFlushSize = 7,
+ EvictSynchronized = true,
+ AtomicWriteOrderMode = CacheAtomicWriteOrderMode.Primary,
+ AtomicityMode = CacheAtomicityMode.Atomic,
+ Backups = 8,
+ CacheMode = CacheMode.Partitioned,
+ EagerTtl = true,
+ EnableSwap = true,
+ EvictSynchronizedConcurrencyLevel = 9,
+ EvictSynchronizedTimeout = TimeSpan.FromSeconds(10),
+ Invalidate = true,
+ KeepBinaryInStore = true,
+ LockTimeout = TimeSpan.FromSeconds(11),
+ MaxEvictionOverflowRatio = 0.5f,
+ MemoryMode = CacheMemoryMode.OnheapTiered,
+ ReadFromBackup = true,
+ RebalanceBatchSize = 12,
+ RebalanceDelay = TimeSpan.FromSeconds(13),
+ RebalanceMode = CacheRebalanceMode.Async,
+ RebalanceThrottle = TimeSpan.FromSeconds(15),
+ RebalanceTimeout = TimeSpan.FromSeconds(16),
+ SqlEscapeAll = true,
+ SqlOnheapRowCacheSize = 17,
+ WriteBehindBatchSize = 18,
+ WriteBehindEnabled = false,
+ WriteSynchronizationMode = CacheWriteSynchronizationMode.PrimarySync,
+ QueryEntities = new[]
+ {
+ new QueryEntity
+ {
+ KeyTypeName = "Integer",
+ ValueTypeName = "java.lang.String",
+ Fields = new[]
+ {
+ new QueryField("length", typeof(int)),
+ new QueryField("name", typeof(string)),
+ new QueryField("location", typeof(string)),
+ },
+ Aliases = new [] {new QueryAlias("length", "len") },
+ Indexes = new[]
+ {
+ new QueryIndex("name") {Name = "index1" },
+ new QueryIndex(new QueryIndexField("location", true))
+ {
+ Name= "index2",
+ IndexType = QueryIndexType.FullText
+ }
+ }
+ }
+ }
+ };
+ }
+
+ /// <summary>
+ /// Test factory.
+ /// </summary>
+ [Serializable]
+ private class CacheStoreFactoryTest : IFactory<ICacheStore>
+ {
+ /// <summary>
+ /// Gets or sets the test property.
+ /// </summary>
+ /// <value>
+ /// The test property.
+ /// </value>
+ public int TestProperty { get; set; }
+
+ /// <summary>
+ /// Creates an instance of the cache store.
+ /// </summary>
+ /// <returns>
+ /// New instance of the cache store.
+ /// </returns>
+ public ICacheStore CreateInstance()
+ {
+ _factoryProp = TestProperty;
+
+ return new CacheStoreTest();
+ }
+ }
+
+ /// <summary>
+ /// Test store.
+ /// </summary>
+ private class CacheStoreTest : CacheStoreAdapter
+ {
+ /** <inheritdoc /> */
+ public override object Load(object key)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public override void Write(object key, object val)
+ {
+ // No-op.
+ }
+
+ /** <inheritdoc /> */
+ public override void Delete(object key)
+ {
+ // No-op.
+ }
+ }
+
+ /// <summary>
+ /// Test entity.
+ /// </summary>
+ private class Entity
+ {
+ /// <summary>
+ /// Gets or sets the foo.
+ /// </summary>
+ public int Foo { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
index 63443b7..7c18a34 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheDynamicStartTest.cs
@@ -79,9 +79,9 @@ namespace Apache.Ignite.Core.Tests.Cache
/// <param name="name">Grid name.</param>
/// <param name="springCfg">Spring configuration.</param>
/// <returns>Configuration.</returns>
- private static IgniteConfigurationEx CreateConfiguration(string name, string springCfg)
+ private static IgniteConfiguration CreateConfiguration(string name, string springCfg)
{
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ var cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
index 33c9f11..09e57dc 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheTestAsyncWrapper.cs
@@ -23,6 +23,7 @@ namespace Apache.Ignite.Core.Tests.Cache
using System.Diagnostics;
using System.Threading.Tasks;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -58,6 +59,12 @@ namespace Apache.Ignite.Core.Tests.Cache
}
/** <inheritDoc /> */
+ public CacheConfiguration GetConfiguration()
+ {
+ return _cache.GetConfiguration();
+ }
+
+ /** <inheritDoc /> */
public bool IsEmpty()
{
return _cache.IsEmpty();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
new file mode 100644
index 0000000..a969127
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 MemberCanBePrivate.Local
+// ReSharper disable UnusedAutoPropertyAccessor.Local
+// ReSharper disable UnusedMember.Local
+namespace Apache.Ignite.Core.Tests.Cache.Query
+{
+ using System;
+ using System.Linq;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Cache.Query;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests queries with in-code configuration.
+ /// </summary>
+ public class CacheQueriesCodeConfigurationTest
+ {
+ const string CacheName = "personCache";
+
+ /// <summary>
+ /// Tests the SQL query.
+ /// </summary>
+ [Test]
+ public void TestQueryEntityConfiguration()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)),
+ CacheConfiguration = new[]
+ {
+ new CacheConfiguration(CacheName, new QueryEntity(typeof (int), typeof (QueryPerson))
+ {
+ Fields = new[]
+ {
+ new QueryField("Name", typeof (string)),
+ new QueryField("Age", typeof (int))
+ },
+ Indexes = new[]
+ {
+ new QueryIndex(false, QueryIndexType.FullText, "Name"), new QueryIndex("Age")
+ }
+ })
+ }
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var cache = ignite.GetCache<int, QueryPerson>(CacheName);
+
+ Assert.IsNotNull(cache);
+
+ cache[1] = new QueryPerson("Arnold", 10);
+ cache[2] = new QueryPerson("John", 20);
+
+ using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > 10")))
+ {
+ Assert.AreEqual(2, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof (QueryPerson), "Ar*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests the attribute configuration.
+ /// </summary>
+ [Test]
+ public void TestAttributeConfiguration()
+ {
+ // ReSharper disable once ObjectCreationAsStatement
+ Assert.Throws<InvalidOperationException>(() => new QueryEntity(typeof (RecursiveQuery)));
+
+ var qe = new QueryEntity {ValueType = typeof(AttributeTest) };
+
+ Assert.AreEqual(typeof(AttributeTest), qe.ValueType);
+
+ var fields = qe.Fields.ToArray();
+
+ CollectionAssert.AreEquivalent(new[]
+ {
+ "SqlField", "IndexedField1", "FullTextField", "Inner", "Inner.Foo",
+ "GroupIndex1", "GroupIndex2", "GroupIndex3"
+ }, fields.Select(x => x.Name));
+
+ var idx = qe.Indexes.ToArray();
+
+ Assert.AreEqual(QueryIndexType.Sorted, idx[0].IndexType);
+ Assert.AreEqual(QueryIndexType.Sorted, idx[1].IndexType);
+ Assert.AreEqual(QueryIndexType.Sorted, idx[2].IndexType);
+ Assert.AreEqual(QueryIndexType.FullText, idx[3].IndexType);
+
+ CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex2"}, idx[0].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"GroupIndex1", "GroupIndex3"}, idx[1].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"IndexedField1"}, idx[2].Fields.Select(f => f.Name));
+ CollectionAssert.AreEquivalent(new[] {"FullTextField"}, idx[3].Fields.Select(f => f.Name));
+ }
+
+ /// <summary>
+ /// Tests the attribute configuration query.
+ /// </summary>
+ [Test]
+ public void TestAttributeConfigurationQuery()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ BinaryConfiguration = new BinaryConfiguration(
+ typeof (AttributeQueryPerson), typeof (AttributeQueryAddress)),
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var cache = ignite.GetOrCreateCache<int, AttributeQueryPerson>(new CacheConfiguration(CacheName,
+ typeof (AttributeQueryPerson)));
+
+ Assert.IsNotNull(cache);
+
+ cache[1] = new AttributeQueryPerson("Arnold", 10)
+ {
+ Address = new AttributeQueryAddress {Country = "USA", Street = "Pine Tree road"}
+ };
+
+ cache[2] = new AttributeQueryPerson("John", 20);
+
+ using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "age > ?", 10)))
+ {
+ Assert.AreEqual(2, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new SqlQuery(typeof(AttributeQueryPerson), "Country = ?", "USA")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Ar*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+
+ using (var cursor = cache.Query(new TextQuery(typeof(AttributeQueryPerson), "Pin*")))
+ {
+ Assert.AreEqual(1, cursor.GetAll().Single().Key);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Test person.
+ /// </summary>
+ private class AttributeQueryPerson
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AttributeQueryPerson"/> class.
+ /// </summary>
+ /// <param name="name">The name.</param>
+ /// <param name="age">The age.</param>
+ public AttributeQueryPerson(string name, int age)
+ {
+ Name = name;
+ Age = age;
+ }
+
+ /// <summary>
+ /// Gets or sets the name.
+ /// </summary>
+ /// <value>
+ /// The name.
+ /// </value>
+ [QueryTextField]
+ public string Name { get; set; }
+
+ /// <summary>
+ /// Gets or sets the age.
+ /// </summary>
+ /// <value>
+ /// The age.
+ /// </value>
+ [QuerySqlField]
+ public int Age { get; set; }
+
+ /// <summary>
+ /// Gets or sets the address.
+ /// </summary>
+ /// <value>
+ /// The address.
+ /// </value>
+ [QuerySqlField]
+ public AttributeQueryAddress Address { get; set; }
+ }
+
+ /// <summary>
+ /// Address.
+ /// </summary>
+ private class AttributeQueryAddress
+ {
+ /// <summary>
+ /// Gets or sets the country.
+ /// </summary>
+ /// <value>
+ /// The country.
+ /// </value>
+ [QuerySqlField]
+ public string Country { get; set; }
+
+ /// <summary>
+ /// Gets or sets the street.
+ /// </summary>
+ /// <value>
+ /// The street.
+ /// </value>
+ [QueryTextField]
+ public string Street { get; set; }
+ }
+
+ /// <summary>
+ /// Query.
+ /// </summary>
+ private class RecursiveQuery
+ {
+ /// <summary>
+ /// Gets or sets the inner.
+ /// </summary>
+ /// <value>
+ /// The inner.
+ /// </value>
+ [QuerySqlField]
+ public RecursiveQuery Inner { get; set; }
+ }
+
+ /// <summary>
+ /// Attribute test class.
+ /// </summary>
+ private class AttributeTest
+ {
+ [QuerySqlField]
+ public double SqlField { get; set; }
+
+ [QuerySqlField(IsIndexed = true, Name = "IndexedField1")]
+ public int IndexedField { get; set; }
+
+ [QueryTextField]
+ public string FullTextField { get; set; }
+
+ [QuerySqlField]
+ public AttributeTestInner Inner { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1", "group2"})]
+ public string GroupIndex1 { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group1"})]
+ public string GroupIndex2 { get; set; }
+
+ [QuerySqlField(IsIndexed = true, IndexGroups = new[] {"group2"})]
+ public string GroupIndex3 { get; set; }
+ }
+
+ /// <summary>
+ /// Inner class.
+ /// </summary>
+ private class AttributeTestInner
+ {
+ /// <summary>
+ /// Gets or sets the foo.
+ /// </summary>
+ /// <value>
+ /// The foo.
+ /// </value>
+ [QuerySqlField]
+ public string Foo { get; set; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
index 08a98f6..8020649 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesTest.cs
@@ -57,7 +57,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
TestUtils.JvmDebug = true;
TestUtils.KillProcesses();
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ IgniteConfiguration cfg = new IgniteConfiguration
{
BinaryConfiguration = new BinaryConfiguration
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
index bdca918..0036abd 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/Continuous/ContinuousQueryAbstractTest.cs
@@ -95,7 +95,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query.Continuous
GC.Collect();
TestUtils.JvmDebug = true;
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
+ IgniteConfiguration cfg = new IgniteConfiguration();
BinaryConfiguration portCfg = new BinaryConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
index 137215e..5cc0849 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreSessionTest.cs
@@ -55,7 +55,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
TestUtils.JvmDebug = true;
- IgniteConfigurationEx cfg = new IgniteConfigurationEx
+ IgniteConfiguration cfg = new IgniteConfiguration
{
GridName = IgniteName,
JvmClasspath = TestUtils.CreateTestClasspath(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
index 1270138..b48cdc9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Store/CacheStoreTest.cs
@@ -23,7 +23,6 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
using Apache.Ignite.Core.Cache.Store;
- using Apache.Ignite.Core.Impl;
using NUnit.Framework;
/// <summary>
@@ -137,24 +136,18 @@ namespace Apache.Ignite.Core.Tests.Cache.Store
[TestFixtureSetUp]
public void BeforeTests()
{
- //TestUtils.JVM_DEBUG = true;
-
TestUtils.KillProcesses();
TestUtils.JvmDebug = true;
- IgniteConfigurationEx cfg = new IgniteConfigurationEx();
-
- cfg.GridName = GridName;
- cfg.JvmClasspath = TestUtils.CreateTestClasspath();
- cfg.JvmOptions = TestUtils.TestJavaOptions();
- cfg.SpringConfigUrl = "config\\native-client-test-cache-store.xml";
-
- BinaryConfiguration portCfg = new BinaryConfiguration();
-
- portCfg.Types = new List<string> { typeof(Key).FullName, typeof(Value).FullName };
-
- cfg.BinaryConfiguration = portCfg;
+ var cfg = new IgniteConfiguration
+ {
+ GridName = GridName,
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ SpringConfigUrl = "config\\native-client-test-cache-store.xml",
+ BinaryConfiguration = new BinaryConfiguration(typeof (Key), typeof (Value))
+ };
Ignition.Start(cfg);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
index 20ae629..f5a04c1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Dataload/DataStreamerTest.cs
@@ -461,9 +461,9 @@ namespace Apache.Ignite.Core.Tests.Dataload
/// Gets the Ignite configuration.
/// </summary>
/// <param name="gridName">Grid name.</param>
- private static IgniteConfigurationEx GetIgniteConfiguration(string gridName)
+ private static IgniteConfiguration GetIgniteConfiguration(string gridName)
{
- return new IgniteConfigurationEx
+ return new IgniteConfiguration
{
GridName = gridName,
SpringConfigUrl = "config\\native-client-test-cache.xml",
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
index 79297da..50ecfac 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/ExceptionsTest.cs
@@ -285,7 +285,7 @@ namespace Apache.Ignite.Core.Tests
/// </summary>
private static IIgnite StartGrid(string gridName = null)
{
- return Ignition.Start(new IgniteConfigurationEx
+ return Ignition.Start(new IgniteConfiguration
{
SpringConfigUrl = "config\\native-client-test-cache.xml",
JvmOptions = TestUtils.TestJavaOptions(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
new file mode 100644
index 0000000..15f5804
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/IgniteConfigurationTest.cs
@@ -0,0 +1,367 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma warning disable 618 // deprecated SpringConfigUrl
+namespace Apache.Ignite.Core.Tests
+{
+ using System;
+ using System.ComponentModel;
+ using System.IO;
+ using System.Linq;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Discovery;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+ using Apache.Ignite.Core.Events;
+ using NUnit.Framework;
+
+ /// <summary>
+ /// Tests code-based configuration.
+ /// </summary>
+ public class IgniteConfigurationTest
+ {
+ /// <summary>
+ /// Fixture setup.
+ /// </summary>
+ [TestFixtureSetUp]
+ public void FixtureSetUp()
+ {
+ Ignition.StopAll(true);
+ }
+
+ /// <summary>
+ /// Tests the default configuration properties.
+ /// </summary>
+ [Test]
+ public void TestDefaultConfigurationProperties()
+ {
+ CheckDefaultProperties(new IgniteConfiguration());
+ }
+
+ /// <summary>
+ /// Tests the default value attributes.
+ /// </summary>
+ [Test]
+ public void TestDefaultValueAttributes()
+ {
+ CheckDefaultValueAttributes(new IgniteConfiguration());
+ CheckDefaultValueAttributes(new TcpDiscoverySpi());
+ CheckDefaultValueAttributes(new CacheConfiguration());
+ CheckDefaultValueAttributes(new TcpDiscoveryMulticastIpFinder());
+ }
+
+ /// <summary>
+ /// Tests all configuration properties.
+ /// </summary>
+ [Test]
+ public void TestAllConfigurationProperties()
+ {
+ var cfg = new IgniteConfiguration(GetCustomConfig());
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var resCfg = ignite.GetConfiguration();
+
+ var disco = (TcpDiscoverySpi) cfg.DiscoverySpi;
+ var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi;
+
+ Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout);
+ Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout);
+ Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout);
+ Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout);
+ Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout);
+
+ var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder;
+ var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder;
+
+ // There can be extra IPv6 endpoints
+ Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray());
+
+ Assert.AreEqual(cfg.GridName, resCfg.GridName);
+ Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes);
+ Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime);
+ Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize);
+ Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency);
+ Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency);
+ Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
+ Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
+ Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
+ Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
+ Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
+ Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
+ Assert.IsTrue(File.Exists(resCfg.JvmDllPath));
+ Assert.AreEqual(cfg.Localhost, resCfg.Localhost);
+ }
+ }
+
+ /// <summary>
+ /// Tests the spring XML.
+ /// </summary>
+ [Test]
+ public void TestSpringXml()
+ {
+ // When Spring XML is used, all properties are ignored.
+ var cfg = GetCustomConfig();
+
+ cfg.SpringConfigUrl = "config\\marshaller-default.xml";
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ var resCfg = ignite.GetConfiguration();
+
+ CheckDefaultProperties(resCfg);
+ }
+ }
+
+ /// <summary>
+ /// Tests the client mode.
+ /// </summary>
+ [Test]
+ public void TestClientMode()
+ {
+ using (var ignite = Ignition.Start(new IgniteConfiguration
+ {
+ Localhost = "127.0.0.1",
+ DiscoverySpi = GetStaticDiscovery()
+ }))
+ using (var ignite2 = Ignition.Start(new IgniteConfiguration
+ {
+ Localhost = "127.0.0.1",
+ DiscoverySpi = GetStaticDiscovery(),
+ GridName = "client",
+ ClientMode = true
+ }))
+ {
+ const string cacheName = "cache";
+
+ ignite.CreateCache<int, int>(cacheName);
+
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ Assert.AreEqual(1, ignite.GetCluster().ForCacheNodes(cacheName).GetNodes().Count);
+
+ Assert.AreEqual(false, ignite.GetConfiguration().ClientMode);
+ Assert.AreEqual(true, ignite2.GetConfiguration().ClientMode);
+ }
+ }
+
+ /// <summary>
+ /// Tests the default spi.
+ /// </summary>
+ [Test]
+ public void TestDefaultSpi()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ AckTimeout = TimeSpan.FromDays(2),
+ MaxAckTimeout = TimeSpan.MaxValue,
+ JoinTimeout = TimeSpan.MaxValue,
+ NetworkTimeout = TimeSpan.MaxValue,
+ SocketTimeout = TimeSpan.MaxValue
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ Localhost = "127.0.0.1"
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ cfg.GridName = "ignite2";
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Tests the invalid timeouts.
+ /// </summary>
+ [Test]
+ public void TestInvalidTimeouts()
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ AckTimeout = TimeSpan.FromMilliseconds(-5),
+ JoinTimeout = TimeSpan.MinValue,
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ };
+
+ Assert.Throws<IgniteException>(() => Ignition.Start(cfg));
+ }
+
+ /// <summary>
+ /// Tests the static ip finder.
+ /// </summary>
+ [Test]
+ public void TestStaticIpFinder()
+ {
+ TestIpFinders(new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] {"127.0.0.1:47500"}
+ }, new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] {"127.0.0.1:47501"}
+ });
+ }
+
+ /// <summary>
+ /// Tests the multicast ip finder.
+ /// </summary>
+ [Test]
+ public void TestMulticastIpFinder()
+ {
+ TestIpFinders(
+ new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.222", MulticastPort = 54522},
+ new TcpDiscoveryMulticastIpFinder {MulticastGroup = "228.111.111.223", MulticastPort = 54522});
+ }
+
+ /// <summary>
+ /// Tests the ip finders.
+ /// </summary>
+ /// <param name="ipFinder">The ip finder.</param>
+ /// <param name="ipFinder2">The ip finder2.</param>
+ private static void TestIpFinders(TcpDiscoveryIpFinderBase ipFinder, TcpDiscoveryIpFinderBase ipFinder2)
+ {
+ var cfg = new IgniteConfiguration
+ {
+ DiscoverySpi =
+ new TcpDiscoverySpi
+ {
+ IpFinder = ipFinder
+ },
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ Localhost = "127.0.0.1"
+ };
+
+ using (var ignite = Ignition.Start(cfg))
+ {
+ // Start with the same endpoint
+ cfg.GridName = "ignite2";
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count);
+ }
+
+ // Start with incompatible endpoint and check that there are 2 topologies
+ ((TcpDiscoverySpi) cfg.DiscoverySpi).IpFinder = ipFinder2;
+
+ using (var ignite2 = Ignition.Start(cfg))
+ {
+ Assert.AreEqual(1, ignite.GetCluster().GetNodes().Count);
+ Assert.AreEqual(1, ignite2.GetCluster().GetNodes().Count);
+ }
+ }
+ }
+
+ /// <summary>
+ /// Checks the default properties.
+ /// </summary>
+ /// <param name="cfg">The CFG.</param>
+ private static void CheckDefaultProperties(IgniteConfiguration cfg)
+ {
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsExpireTime, cfg.MetricsExpireTime);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsHistorySize, cfg.MetricsHistorySize);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsLogFrequency, cfg.MetricsLogFrequency);
+ Assert.AreEqual(IgniteConfiguration.DefaultMetricsUpdateFrequency, cfg.MetricsUpdateFrequency);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkTimeout, cfg.NetworkTimeout);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryCount, cfg.NetworkSendRetryCount);
+ Assert.AreEqual(IgniteConfiguration.DefaultNetworkSendRetryDelay, cfg.NetworkSendRetryDelay);
+ }
+
+ /// <summary>
+ /// Checks the default value attributes.
+ /// </summary>
+ /// <param name="obj">The object.</param>
+ private static void CheckDefaultValueAttributes(object obj)
+ {
+ var props = obj.GetType().GetProperties();
+
+ foreach (var prop in props)
+ {
+ var attr = prop.GetCustomAttributes(true).OfType<DefaultValueAttribute>().FirstOrDefault();
+ var propValue = prop.GetValue(obj, null);
+
+ if (attr != null)
+ Assert.AreEqual(attr.Value, propValue);
+ else if (prop.PropertyType.IsValueType)
+ Assert.AreEqual(Activator.CreateInstance(prop.PropertyType), propValue);
+ else
+ Assert.IsNull(propValue);
+ }
+ }
+
+ /// <summary>
+ /// Gets the custom configuration.
+ /// </summary>
+ private static IgniteConfiguration GetCustomConfig()
+ {
+ return new IgniteConfiguration
+ {
+ DiscoverySpi = new TcpDiscoverySpi
+ {
+ NetworkTimeout = TimeSpan.FromSeconds(1),
+ AckTimeout = TimeSpan.FromSeconds(2),
+ MaxAckTimeout = TimeSpan.FromSeconds(3),
+ SocketTimeout = TimeSpan.FromSeconds(4),
+ JoinTimeout = TimeSpan.FromSeconds(5),
+ IpFinder = new TcpDiscoveryStaticIpFinder
+ {
+ Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" }
+ }
+ },
+ GridName = "gridName1",
+ IncludedEventTypes = EventType.SwapspaceAll,
+ MetricsExpireTime = TimeSpan.FromMinutes(7),
+ MetricsHistorySize = 125,
+ MetricsLogFrequency = TimeSpan.FromMinutes(8),
+ MetricsUpdateFrequency = TimeSpan.FromMinutes(9),
+ NetworkSendRetryCount = 54,
+ NetworkTimeout = TimeSpan.FromMinutes(10),
+ NetworkSendRetryDelay = TimeSpan.FromMinutes(11),
+ WorkDirectory = Path.GetTempPath(),
+ JvmOptions = TestUtils.TestJavaOptions(),
+ JvmClasspath = TestUtils.CreateTestClasspath(),
+ Localhost = "127.0.0.1"
+ };
+ }
+
+ /// <summary>
+ /// Gets the static discovery.
+ /// </summary>
+ /// <returns></returns>
+ private static IDiscoverySpi GetStaticDiscovery()
+ {
+ return new TcpDiscoverySpi
+ {
+ IpFinder = new TcpDiscoveryStaticIpFinder {Endpoints = new[] {"127.0.0.1:47500", "127.0.0.1:47501"}}
+ };
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
index 541de0c..7def56f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/MarshallerTest.cs
@@ -34,7 +34,7 @@ namespace Apache.Ignite.Core.Tests
{
using (var grid = Ignition.Start("config\\marshaller-default.xml"))
{
- var cache = grid.GetOrCreateCache<int, int>(null);
+ var cache = grid.GetOrCreateCache<int, int>((string) null);
cache.Put(1, 1);
@@ -51,7 +51,7 @@ namespace Apache.Ignite.Core.Tests
{
using (var grid = Ignition.Start("config\\marshaller-explicit.xml"))
{
- var cache = grid.GetOrCreateCache<int, int>(null);
+ var cache = grid.GetOrCreateCache<int, int>((string) null);
cache.Put(1, 1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
index 07caaf3..a36e30f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/SerializationTest.cs
@@ -43,7 +43,7 @@ namespace Apache.Ignite.Core.Tests
[TestFixtureSetUp]
public void SetUp()
{
- var cfg = new IgniteConfigurationEx
+ var cfg = new IgniteConfiguration
{
GridName = GridName,
JvmClasspath = TestUtils.CreateTestClasspath(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
index 2b0ab8e..a1083b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/TestRunner.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests
using System;
using System.Diagnostics;
using System.Reflection;
+ using Apache.Ignite.Core.Tests.Cache.Query;
using Apache.Ignite.Core.Tests.Memory;
using NUnit.ConsoleRunner;
@@ -31,9 +32,9 @@ namespace Apache.Ignite.Core.Tests
Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.AutoFlush = true;
- //TestOne(typeof(ContinuousQueryAtomiclBackupTest), "TestInitialQuery");
+ TestOne(typeof(IgniteConfigurationTest), "TestStaticIpFinder");
- TestAll(typeof (ExecutableTest));
+ //TestAll(typeof (CacheQueriesCodeConfigurationTest));
//TestAllInAssembly();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 7de8330..1c83168 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -17,6 +17,7 @@
<OutputPath>bin\x64\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\x64\Debug\Apache.Ignite.Core.XML</DocumentationFile>
<RunCodeAnalysis>true</RunCodeAnalysis>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -25,6 +26,7 @@
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<Optimize>true</Optimize>
<DocumentationFile>bin\x64\Release\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -34,6 +36,7 @@
<OutputPath>bin\x86\Debug\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>DEBUG;CODE_ANALYSIS</DefineConstants>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\x86\Debug\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
@@ -41,6 +44,7 @@
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
<Optimize>true</Optimize>
<DocumentationFile>bin\x86\Release\Apache.Ignite.Core.XML</DocumentationFile>
<CodeAnalysisRuleSet>Apache.Ignite.Core.ruleset</CodeAnalysisRuleSet>
@@ -65,6 +69,8 @@
<Compile Include="Cache\CacheException.cs" />
<Compile Include="Cache\CachePartialUpdateException.cs" />
<Compile Include="Cache\CachePeekMode.cs" />
+ <Compile Include="Cache\Configuration\QueryAlias.cs" />
+ <Compile Include="Cache\Configuration\QueryTextFieldAttribute.cs" />
<Compile Include="Cache\Event\CacheEntryEventType.cs" />
<Compile Include="Cache\Event\ICacheEntryEvent.cs" />
<Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
@@ -98,6 +104,7 @@
<Compile Include="Cache\Store\CacheStoreAdapter.cs" />
<Compile Include="Cache\Store\CacheStoreException.cs" />
<Compile Include="Cache\Store\ICacheStore.cs" />
+ <Compile Include="Common\IFactory.cs" />
<Compile Include="Cache\Store\ICacheStoreSession.cs" />
<Compile Include="Cache\Store\Package-Info.cs" />
<Compile Include="Cluster\ClusterGroupEmptyException.cs" />
@@ -128,6 +135,25 @@
<Compile Include="Compute\IComputeJobResult.cs" />
<Compile Include="Compute\IComputeReducer.cs" />
<Compile Include="Compute\IComputeTask.cs" />
+ <Compile Include="Cache\Configuration\CacheAtomicityMode.cs" />
+ <Compile Include="Cache\Configuration\CacheAtomicWriteOrderMode.cs" />
+ <Compile Include="Cache\Configuration\CacheConfiguration.cs" />
+ <Compile Include="Cache\Configuration\CacheMemoryMode.cs" />
+ <Compile Include="Cache\Configuration\CacheMode.cs" />
+ <Compile Include="Cache\Configuration\CacheRebalanceMode.cs" />
+ <Compile Include="Cache\Configuration\CacheWriteSynchronizationMode.cs" />
+ <Compile Include="Discovery\Tcp\ITcpDiscoveryIpFinder.cs" />
+ <Compile Include="Discovery\Tcp\TcpDiscoverySpi.cs" />
+ <Compile Include="Cache\Configuration\QueryIndexField.cs" />
+ <Compile Include="Discovery\IDiscoverySpi.cs" />
+ <Compile Include="Discovery\Tcp\TcpDiscoveryIpFinderBase.cs" />
+ <Compile Include="Discovery\Tcp\Multicast\TcpDiscoveryMulticastIpFinder.cs" />
+ <Compile Include="Cache\Configuration\QueryEntity.cs" />
+ <Compile Include="Cache\Configuration\QueryField.cs" />
+ <Compile Include="Cache\Configuration\QueryIndex.cs" />
+ <Compile Include="Cache\Configuration\QueryIndexType.cs" />
+ <Compile Include="Cache\Configuration\QuerySqlFieldAttribute.cs" />
+ <Compile Include="Discovery\Tcp\Static\TcpDiscoveryStaticIpFinder.cs" />
<Compile Include="Compute\Package-Info.cs" />
<Compile Include="Datastream\IDataStreamer.cs" />
<Compile Include="Datastream\IStreamReceiver.cs" />
@@ -158,6 +184,7 @@
<Compile Include="Ignition.cs" />
<Compile Include="IIgnite.cs" />
<Compile Include="Impl\Binary\BinaryEnum.cs" />
+ <Compile Include="Impl\Binary\JavaTypes.cs" />
<Compile Include="Impl\Cache\CacheAffinityImpl.cs" />
<Compile Include="Impl\Cache\CacheEntry.cs" />
<Compile Include="Impl\Cache\CacheEntryFilterHolder.cs" />
@@ -235,7 +262,6 @@
<Compile Include="Impl\Events\Events.cs" />
<Compile Include="Impl\Events\RemoteListenEventFilter.cs" />
<Compile Include="Impl\ExceptionUtils.cs" />
- <Compile Include="Impl\IgniteConfigurationEx.cs" />
<Compile Include="Impl\Ignite.cs" />
<Compile Include="Impl\IgniteManager.cs" />
<Compile Include="Impl\IgniteProxy.cs" />
@@ -405,6 +431,7 @@
<None Include="Apache.Ignite.Core.ruleset" />
<None Include="Apache.Ignite.Core.snk" />
</ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
index 4d82a65..fa2fb1c 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Binary/BinaryConfiguration.cs
@@ -17,8 +17,10 @@
namespace Apache.Ignite.Core.Binary
{
+ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Linq;
using Apache.Ignite.Core.Impl.Common;
/// <summary>
@@ -27,7 +29,7 @@ namespace Apache.Ignite.Core.Binary
public class BinaryConfiguration
{
/// <summary>
- /// Constructor.
+ /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
/// </summary>
public BinaryConfiguration()
{
@@ -35,9 +37,9 @@ namespace Apache.Ignite.Core.Binary
}
/// <summary>
- /// Copying constructor.
+ /// Initializes a new instance of the <see cref="BinaryConfiguration" /> class.
/// </summary>
- /// <param name="cfg">Configuration to copy.</param>
+ /// <param name="cfg">The binary configuration to copy.</param>
public BinaryConfiguration(BinaryConfiguration cfg)
{
IgniteArgumentCheck.NotNull(cfg, "cfg");
@@ -47,15 +49,20 @@ namespace Apache.Ignite.Core.Binary
DefaultKeepDeserialized = cfg.DefaultKeepDeserialized;
DefaultSerializer = cfg.DefaultSerializer;
- Types = cfg.Types != null ? new List<string>(cfg.Types) : null;
+ TypeConfigurations = cfg.TypeConfigurations == null
+ ? null
+ : cfg.TypeConfigurations.Select(x => new BinaryTypeConfiguration(x)).ToList();
- if (cfg.TypeConfigurations != null)
- {
- TypeConfigurations = new List<BinaryTypeConfiguration>(cfg.TypeConfigurations.Count);
+ Types = cfg.Types == null ? null : cfg.Types.ToList();
+ }
- foreach (BinaryTypeConfiguration typeCfg in cfg.TypeConfigurations)
- TypeConfigurations.Add(new BinaryTypeConfiguration(typeCfg));
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BinaryConfiguration"/> class.
+ /// </summary>
+ /// <param name="binaryTypes">Binary types to register.</param>
+ public BinaryConfiguration(params Type[] binaryTypes)
+ {
+ TypeConfigurations = binaryTypes.Select(t => new BinaryTypeConfiguration(t)).ToList();
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
new file mode 100644
index 0000000..c9a41e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicWriteOrderMode.cs
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ /// <summary>
+ /// Cache write ordering mode. This enumeration is taken into account only in
+ /// <see cref="CacheAtomicityMode.Atomic"/> atomicity mode.
+ /// Write ordering mode determines which node assigns the write version, sender or the primary node.
+ /// </summary>
+ public enum CacheAtomicWriteOrderMode
+ {
+ /// <summary>
+ /// In this mode, write versions are assigned on a sender node which generally leads to better
+ /// performance in <see cref="CacheWriteSynchronizationMode.FullSync"/> synchronization mode,
+ /// since in this case sender can send write requests to primary and backups at the same time.
+ /// <para/>
+ /// This mode will be automatically configured only with <see cref="CacheWriteSynchronizationMode.FullSync"/>
+ /// write synchronization mode, as for other synchronization modes it does not render better performance.
+ /// </summary>
+ Clock,
+
+ /// <summary>
+ /// Cache version is assigned only on primary node. This means that sender will only send write request
+ /// to primary node, which in turn will assign write version and forward it to backups.
+ /// </summary>
+ Primary
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
new file mode 100644
index 0000000..8c36a77
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheAtomicityMode.cs
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Cache.Configuration
+{
+ using Apache.Ignite.Core.Cache;
+
+ /// <summary>
+ /// Cache atomicity mode.
+ /// </summary>
+ public enum CacheAtomicityMode
+ {
+ /// <summary>
+ /// Specifies fully ACID-compliant transactional cache behavior.
+ /// </summary>
+ Transactional,
+
+ /// <summary>
+ /// Specifies atomic-only cache behaviour. In this mode distributed transactions and distributed
+ /// locking are not supported. Disabling transactions and locking allows to achieve much higher
+ /// performance and throughput ratios.
+ /// <para/>
+ /// In addition to transactions and locking, one of the main differences to <see cref="Atomic"/> mode
+ /// is that bulk writes, such as <see cref="ICache{TK,TV}.PutAll"/>
+ /// and <see cref="ICache{TK,TV}.RemoveAll(System.Collections.Generic.IEnumerable{TK})"/> methods,
+ /// become simple batch operations which can partially fail. In case of partial
+ /// failure, <see cref="CachePartialUpdateException"/>will be thrown which will contain a list of keys
+ /// for which the update failed. It is recommended that bulk writes are used
+ /// whenever multiple keys need to be inserted or updated in cache, as they reduce number of network trips and
+ /// provide better performance.
+ /// <para/>
+ /// Note that even without locking and transactions, <see cref="Atomic"/> mode still provides
+ /// full consistency guarantees across all cache nodes.
+ /// <para/>
+ /// Also note that all data modifications in <see cref="Atomic"/> mode are guaranteed to be atomic
+ /// and consistent with writes to the underlying persistent store, if one is configured.
+ /// </summary>
+ Atomic
+ }
+}
\ No newline at end of file
[29/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/88b0eeb6
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/88b0eeb6
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/88b0eeb6
Branch: refs/heads/ignite-1786
Commit: 88b0eeb6f81a3c84c3874298d1f2cbb7192bd505
Parents: f3e9ae4 a30f84a
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 5 12:24:00 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 5 12:24:00 2016 +0300
----------------------------------------------------------------------
.../internal/processors/cache/GridCacheAdapter.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
[21/50] [abbrv] ignite git commit: Fixed GridFactorySelfTest which
started failing due to minor change in exception message.
Posted by vo...@apache.org.
Fixed GridFactorySelfTest which started failing due to minor change in exception message.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/74d9d05b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/74d9d05b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/74d9d05b
Branch: refs/heads/ignite-1786
Commit: 74d9d05b7cee071dad4c50a3a053781d78a488a8
Parents: d1e2957
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Thu Feb 4 09:36:52 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Thu Feb 4 09:36:52 2016 +0300
----------------------------------------------------------------------
.../test/java/org/apache/ignite/internal/GridFactorySelfTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/74d9d05b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
index d72b577..cca3e8b 100644
--- a/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/internal/GridFactorySelfTest.java
@@ -469,7 +469,7 @@ public class GridFactorySelfTest extends GridCommonAbstractTest {
String msg = e.getMessage();
if (msg != null &&
- (msg.contains("Default grid instance has already been started.") ||
+ (msg.contains("Default Ignite instance has already been started.") ||
msg.contains("Ignite instance with this name has already been started:")))
info("Caught expected exception: " + msg);
else
[18/50] [abbrv] ignite git commit: 2224 Added Javadoc about new
methods to CacheEntry
Posted by vo...@apache.org.
2224 Added Javadoc about new methods to CacheEntry
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e7de923e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e7de923e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e7de923e
Branch: refs/heads/ignite-1786
Commit: e7de923e6c34bdb4e276bd4314868541087d66f1
Parents: 60c8b07
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Feb 3 13:11:10 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Feb 3 13:11:10 2016 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/cache/CacheEntry.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e7de923e/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
index d92f9fb..19585a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheEntry.java
@@ -24,9 +24,9 @@ import org.apache.ignite.IgniteCache;
/**
* Cache entry that extends {@link javax.cache.Cache.Entry} by providing additional entry related information.
- *
- * To get an instance of {@code CacheEntry} use {@link javax.cache.Cache.Entry#unwrap(Class)} method by passing
- * {@code CacheEntry} class to it as the argument.
+ * <p>
+ * To get an instance of {@code CacheEntry} from {@link javax.cache.Cache.Entry} use
+ * {@link javax.cache.Cache.Entry#unwrap(Class)} method by passing {@code CacheEntry} class to it as the argument.
* <p>
* {@code CacheEntry} is supported only for {@link javax.cache.Cache.Entry} returned by one of the following methods:
* <ul>
@@ -36,6 +36,9 @@ import org.apache.ignite.IgniteCache;
* <li>{@link IgniteCache#randomEntry()}</li>
* </ul>
* <p>
+ * To get an instance of {@code CacheEntry} directly use {@link IgniteCache#getEntry(Object)} or
+ * {@link IgniteCache#getEntries(Set)} methods.
+ * <p>
* {@code CacheEntry} is not supported for {@link javax.cache.Cache#iterator()} because of performance reasons.
* {@link javax.cache.Cache#iterator()} loads entries from all the cluster nodes and to speed up the load additional
* information, like entry's version, is ignored.
[41/50] [abbrv] ignite git commit: .NET: Fixed remaining analysis
warnings
Posted by vo...@apache.org.
.NET: Fixed remaining analysis warnings
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cbaa6e02
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cbaa6e02
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cbaa6e02
Branch: refs/heads/ignite-1786
Commit: cbaa6e02010ee1aa8a1b4c8ee903c77ee560d8b1
Parents: e18dfda
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Feb 8 14:14:30 2016 +0300
Committer: Pavel Tupitsyn <pt...@gridgain.com>
Committed: Mon Feb 8 14:14:30 2016 +0300
----------------------------------------------------------------------
.../Cache/Query/CacheQueriesCodeConfigurationTest.cs | 4 ++--
.../Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs | 4 ++--
.../Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs | 4 +++-
.../Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs | 6 ++++--
4 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/cbaa6e02/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
index a969127..684dd62 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/Query/CacheQueriesCodeConfigurationTest.cs
@@ -189,7 +189,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
/// <value>
/// The name.
/// </value>
- [QueryTextField]
+ [QueryTextField(Name = "Name")]
public string Name { get; set; }
/// <summary>
@@ -258,7 +258,7 @@ namespace Apache.Ignite.Core.Tests.Cache.Query
[QuerySqlField]
public double SqlField { get; set; }
- [QuerySqlField(IsIndexed = true, Name = "IndexedField1")]
+ [QuerySqlField(IsIndexed = true, Name = "IndexedField1", IsDescending = true)]
public int IndexedField { get; set; }
[QueryTextField]
http://git-wip-us.apache.org/repos/asf/ignite/blob/cbaa6e02/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
index 4151540..4ce0211 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/QueryEntity.cs
@@ -358,8 +358,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
if (type.IsPrimitive)
yield break;
- var bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
- BindingFlags.DeclaredOnly;
+ const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
+ BindingFlags.DeclaredOnly;
while (type != typeof (object) && type != null)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/cbaa6e02/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
index 25adf56..5df5ea1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
@@ -124,7 +124,9 @@ namespace Apache.Ignite.Core.Discovery.Tcp.Multicast
writer.WriteInt(TimeToLive.Value);
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Gets the type code to be used in Java to determine ip finder type.
+ /// </summary>
protected override byte TypeCode
{
get { return TypeCodeMulticastIpFinder; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/cbaa6e02/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
index 331ca48..4672ed9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
@@ -74,8 +74,10 @@ namespace Apache.Ignite.Core.Discovery.Tcp.Static
else
writer.WriteInt(0);
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Gets the type code to be used in Java to determine ip finder type.
+ /// </summary>
protected override byte TypeCode
{
get { return TypeCodeVmIpFinder; }
[10/50] [abbrv] ignite git commit: ignite-2080 Data alignment issues
with Unsafe
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
new file mode 100644
index 0000000..f3ff781
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/io/GridUnsafeDataInputOutputByteOrderSelfTest.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.util.io;
+
+import java.io.ByteArrayInputStream;
+import java.util.Random;
+import junit.framework.TestCase;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * Grid unsafe data input/output byte order sanity tests.
+ */
+public class GridUnsafeDataInputOutputByteOrderSelfTest extends TestCase {
+ /** Array length. */
+ private static final int ARR_LEN = 16;
+
+ /** Length bytes. */
+ private static final int LEN_BYTES = 4;
+
+ /** Rnd. */
+ private static Random RND = new Random();
+
+ /** Out. */
+ private GridUnsafeDataOutput out;
+
+ /** In. */
+ private GridUnsafeDataInput in;
+
+ /** {@inheritDoc} */
+ @Override protected void setUp() throws Exception {
+ out = new GridUnsafeDataOutput(16 * 8+ LEN_BYTES);
+ in = new GridUnsafeDataInput();
+ in.inputStream(new ByteArrayInputStream(out.internalArray()));
+ }
+
+ /** {@inheritDoc} */
+ @Override public void tearDown() throws Exception {
+ in.close();
+ out.close();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ short val = (short)RND.nextLong();
+
+ out.writeShort(val);
+
+ assertEquals(val, getShortByByteLE(out.internalArray()));
+ assertEquals(val, in.readShort());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArray() throws Exception {
+ short[] arr = new short[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (short)RND.nextLong();
+
+ out.writeShortArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getShortByByteLE(outArr, i * 2+ LEN_BYTES));
+
+ assertArrayEquals(arr, in.readShortArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testChar() throws Exception {
+ char val = (char)RND.nextLong();
+
+ out.writeChar(val);
+
+ assertEquals(val, getCharByByteLE(out.internalArray()));
+ assertEquals(val, in.readChar());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArray() throws Exception {
+ char[] arr = new char[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (char)RND.nextLong();
+
+ out.writeCharArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getCharByByteLE(outArr, i * 2+ LEN_BYTES));
+
+ assertArrayEquals(arr, in.readCharArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInt() throws Exception {
+ int val = RND.nextInt();
+
+ out.writeInt(val);
+
+ assertEquals(val, getIntByByteLE(out.internalArray()));
+ assertEquals(val, in.readInt());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArray() throws Exception {
+ int[] arr = new int[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextInt();
+
+ out.writeIntArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getIntByByteLE(outArr, i * 4+ LEN_BYTES));
+
+ assertArrayEquals(arr, in.readIntArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLong() throws Exception {
+ long val = RND.nextLong();
+
+ out.writeLong(val);
+
+ assertEquals(val, getLongByByteLE(out.internalArray()));
+ assertEquals(val, in.readLong());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArray() throws Exception {
+ long[] arr = new long[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextLong();
+
+ out.writeLongArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getLongByByteLE(outArr, i * 8+ LEN_BYTES));
+
+ assertArrayEquals(arr, in.readLongArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ float val = RND.nextFloat();
+
+ out.writeFloat(val);
+
+ assertEquals(val, getFloatByByteLE(out.internalArray()), 0);
+ assertEquals(val, in.readFloat(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArray() throws Exception {
+ float[] arr = new float[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextFloat();
+
+ out.writeFloatArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getFloatByByteLE(outArr, i * 4+ LEN_BYTES), 0);
+
+ assertArrayEquals(arr, in.readFloatArray(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ double val = RND.nextDouble();
+
+ out.writeDouble(val);
+
+ assertEquals(val, getDoubleByByteLE(out.internalArray()), 0);
+ assertEquals(val, in.readDouble(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArray() throws Exception {
+ double[] arr = new double[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextDouble();
+
+ out.writeDoubleArray(arr);
+
+ byte[] outArr = out.internalArray();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8+ LEN_BYTES), 0);
+
+ assertArrayEquals(arr, in.readDoubleArray(), 0);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
index 37e7afe..1bbae51 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridBasicPerformanceTest.java
@@ -50,7 +50,6 @@ import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentLinkedDeque8;
import org.jsr166.ThreadLocalRandom8;
-import sun.misc.Unsafe;
/**
* Tests synchronization performance vs. lock.
@@ -948,16 +947,14 @@ public class GridBasicPerformanceTest {
GridTimer t = new GridTimer("unsafe");
- Unsafe unsafe = GridUnsafe.unsafe();
-
int mem = 1024;
for (int i = 0; i < MAX; i++) {
- addrs[i] = unsafe.allocateMemory(mem);
+ addrs[i] = GridUnsafe.allocateMemory(mem);
- unsafe.putByte(addrs[i] + RAND.nextInt(mem), (byte)RAND.nextInt(mem));
+ GridUnsafe.putByte(addrs[i] + RAND.nextInt(mem), (byte)RAND.nextInt(mem));
- v = unsafe.getByte(addrs[i] + RAND.nextInt(mem));
+ v = GridUnsafe.getByte(addrs[i] + RAND.nextInt(mem));
}
X.println("Unsafe [time=" + t.stop() + "ms, v=" + v + ']');
@@ -965,7 +962,7 @@ public class GridBasicPerformanceTest {
Thread.sleep(5000L);
for (long l : addrs)
- unsafe.freeMemory(l);
+ GridUnsafe.freeMemory(l);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 2d5b2c5..7bb2cf3 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -1101,7 +1101,7 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
// On Windows and Mac machines two nodes can reside on the same port
// (if one node has localHost="127.0.0.1" and another has localHost="0.0.0.0").
// So two nodes do not even discover each other.
- if (U.isWindows() || U.isMacOs())
+ if (U.isWindows() || U.isMacOs() || U.isSolaris())
return;
try {
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 27511ff..3c83d86 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -206,7 +206,7 @@ public abstract class GridAbstractTest extends TestCase {
* @throws Exception If failed.
*/
protected <T> T allocateInstance(Class<T> cls) throws Exception {
- return (T)GridUnsafe.unsafe().allocateInstance(cls);
+ return (T)GridUnsafe.allocateInstance(cls);
}
/**
@@ -215,7 +215,7 @@ public abstract class GridAbstractTest extends TestCase {
*/
@Nullable protected <T> T allocateInstance0(Class<T> cls) {
try {
- return (T)GridUnsafe.unsafe().allocateInstance(cls);
+ return (T)GridUnsafe.allocateInstance(cls);
}
catch (InstantiationException e) {
e.printStackTrace();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 5eb7b66..3ec55d0 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -46,6 +46,8 @@ import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompac
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
+import org.apache.ignite.internal.binary.streams.BinaryHeapStreamByteOrderSelfTest;
+import org.apache.ignite.internal.binary.streams.BinaryOffheapStreamByteOrderSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest;
@@ -132,6 +134,10 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(BinaryTxCacheLocalEntriesSelfTest.class);
suite.addTestSuite(BinaryAtomicCacheLocalEntriesSelfTest.class);
+ // Byte order
+ suite.addTestSuite(BinaryHeapStreamByteOrderSelfTest.class);
+ suite.addTestSuite(BinaryOffheapStreamByteOrderSelfTest.class);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
index 1065fbd..e4a2bee 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteMarshallerSelfTestSuite.java
@@ -19,6 +19,8 @@ package org.apache.ignite.testsuites;
import java.util.Set;
import junit.framework.TestSuite;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2ByteOrderSelfTest;
+import org.apache.ignite.internal.util.io.GridUnsafeDataInputOutputByteOrderSelfTest;
import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
@@ -55,8 +57,10 @@ public class IgniteMarshallerSelfTestSuite extends TestSuite {
GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, OptimizedObjectStreamSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, GridUnsafeDataOutputArraySizingSelfTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, GridUnsafeDataInputOutputByteOrderSelfTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerNodeFailoverTest.class, ignoredTests);
GridTestUtils.addTestIfNeeded(suite, OptimizedMarshallerSerialPersistentFieldsSelfTest.class, ignoredTests);
+ GridTestUtils.addTestIfNeeded(suite, DirectByteBufferStreamImplV2ByteOrderSelfTest.class, ignoredTests);
return suite;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
index 0efdf2b..b940c72 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleJob.java
@@ -39,6 +39,7 @@ import org.apache.ignite.internal.processors.hadoop.counter.HadoopPerformanceCou
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimap;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap;
import org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipList;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -56,8 +57,6 @@ import org.apache.ignite.thread.IgniteThread;
import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.PARTITION_HASHMAP_SIZE;
import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.SHUFFLE_REDUCER_NO_SORTING;
import static org.apache.ignite.internal.processors.hadoop.HadoopJobProperty.get;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
/**
* Shuffle job.
@@ -299,7 +298,7 @@ public class HadoopShuffleJob<T> implements AutoCloseable {
/** */
@Override public void copyTo(long ptr) {
- UNSAFE.copyMemory(buf, BYTE_ARR_OFF + off, null, ptr, size);
+ GridUnsafe.copyMemory(buf, GridUnsafe.BYTE_ARR_OFF + off, null, ptr, size);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
index 87a0ee0..69dfe64 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/HadoopShuffleMessage.java
@@ -24,13 +24,11 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.processors.hadoop.HadoopJobId;
import org.apache.ignite.internal.processors.hadoop.message.HadoopMessage;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
/**
* Shuffle message.
*/
@@ -167,11 +165,11 @@ public class HadoopShuffleMessage implements HadoopMessage {
private void add(byte marker, long ptr, int size) {
buf[off++] = marker;
- UNSAFE.putInt(buf, BYTE_ARR_OFF + off, size);
+ GridUnsafe.putInt(buf, GridUnsafe.BYTE_ARR_OFF + off, size);
off += 4;
- UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF + off, size);
+ GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF + off, size);
off += size;
}
@@ -183,7 +181,7 @@ public class HadoopShuffleMessage implements HadoopMessage {
for (int i = 0; i < off;) {
byte marker = buf[i++];
- int size = UNSAFE.getInt(buf, BYTE_ARR_OFF + i);
+ int size = GridUnsafe.getInt(buf, GridUnsafe.BYTE_ARR_OFF + i);
i += 4;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
index 99d8963..f7b1a73 100644
--- a/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
+++ b/modules/hadoop/src/main/java/org/apache/ignite/internal/processors/hadoop/shuffle/streams/HadoopDataOutStream.java
@@ -20,11 +20,9 @@ package org.apache.ignite.internal.processors.hadoop.shuffle.streams;
import java.io.DataOutput;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
/**
* Data output stream.
*/
@@ -69,7 +67,7 @@ public class HadoopDataOutStream extends OutputStream implements DataOutput {
/** {@inheritDoc} */
@Override public void write(byte[] b, int off, int len) {
- UNSAFE.copyMemory(b, BYTE_ARR_OFF + off, null, move(len), len);
+ GridUnsafe.copyMemory(b, GridUnsafe.BYTE_ARR_OFF + off, null, move(len), len);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
index d5deaac..a37d74b 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopConcurrentHashMultimapSelftest.java
@@ -36,14 +36,12 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobInfo;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskContext;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskInput;
import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.io.GridDataInput;
import org.apache.ignite.internal.util.io.GridUnsafeDataInput;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
import org.apache.ignite.internal.util.typedef.X;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
-
/**
*
*/
@@ -162,7 +160,7 @@ public class HadoopConcurrentHashMultimapSelftest extends HadoopAbstractMapTest
private void read(long ptr, int size, Writable w) {
assert size == 4 : size;
- UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF, size);
+ GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF, size);
dataInput.bytes(buf, size);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
index 969eeab..f70ef2f 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/internal/processors/hadoop/shuffle/collections/HadoopSkipListSelfTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.hadoop.HadoopJobInfo;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskContext;
import org.apache.ignite.internal.processors.hadoop.HadoopTaskInput;
import org.apache.ignite.internal.util.GridRandom;
+import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.io.GridDataInput;
import org.apache.ignite.internal.util.io.GridUnsafeDataInput;
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
@@ -45,8 +46,6 @@ import org.apache.ignite.internal.util.typedef.X;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.max;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory.UNSAFE;
/**
* Skip list tests.
@@ -201,7 +200,7 @@ public class HadoopSkipListSelfTest extends HadoopAbstractMapTest {
private void read(long ptr, int size, Writable w) {
assert size == 4 : size;
- UNSAFE.copyMemory(null, ptr, buf, BYTE_ARR_OFF, size);
+ GridUnsafe.copyMemory(null, ptr, buf, GridUnsafe.BYTE_ARR_OFF, size);
dataInput.bytes(buf, size);
[28/50] [abbrv] ignite git commit: IGNITE-2508: Fixed hotspot in
GridDhtPartitionTopologyImpl caused by excessive HashSet allocations from
"nodes(int, AffinityTopologyVersion)" method.
Posted by vo...@apache.org.
IGNITE-2508: Fixed hotspot in GridDhtPartitionTopologyImpl caused by excessive HashSet allocations from "nodes(int, AffinityTopologyVersion)" method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f3e9ae40
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f3e9ae40
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f3e9ae40
Branch: refs/heads/ignite-1786
Commit: f3e9ae40d31ebe2bd7c338fa2ec6b9c72fe88c31
Parents: 532b373
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Fri Feb 5 12:23:33 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 5 12:23:33 2016 +0300
----------------------------------------------------------------------
.../affinity/GridAffinityAssignment.java | 36 +++++++++++++++++++-
.../affinity/GridAffinityAssignmentCache.java | 2 +-
.../cache/GridCacheAffinityManager.java | 30 +++++++++++++---
.../dht/GridDhtPartitionTopologyImpl.java | 9 +++--
4 files changed, 67 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3e9ae40/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
index 810843c..7b2bea3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignment.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.affinity;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -31,7 +32,7 @@ import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Cached affinity calculations.
*/
-class GridAffinityAssignment implements Serializable {
+public class GridAffinityAssignment implements Serializable {
/** */
private static final long serialVersionUID = 0L;
@@ -47,6 +48,9 @@ class GridAffinityAssignment implements Serializable {
/** Map of backup node partitions. */
private final Map<UUID, Set<Integer>> backup;
+ /** Assignment node IDs */
+ private transient volatile List<HashSet<UUID>> assignmentIds;
+
/**
* Constructs cached affinity calculations item.
*
@@ -112,6 +116,36 @@ class GridAffinityAssignment implements Serializable {
}
/**
+ * Get affinity node IDs for partition.
+ *
+ * @param part Partition.
+ * @return Affinity nodes IDs.
+ */
+ public HashSet<UUID> getIds(int part) {
+ assert part >= 0 && part < assignment.size() : "Affinity partition is out of range" +
+ " [part=" + part + ", partitions=" + assignment.size() + ']';
+
+ List<HashSet<UUID>> assignmentIds0 = assignmentIds;
+
+ if (assignmentIds0 == null) {
+ assignmentIds0 = new ArrayList<>();
+
+ for (List<ClusterNode> assignmentPart : assignment) {
+ HashSet<UUID> partIds = new HashSet<>();
+
+ for (ClusterNode node : assignmentPart)
+ partIds.add(node.id());
+
+ assignmentIds0.add(partIds);
+ }
+
+ assignmentIds = assignmentIds0;
+ }
+
+ return assignmentIds0.get(part);
+ }
+
+ /**
* Get primary partitions for specified node ID.
*
* @param nodeId Node ID to get primary partitions for.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3e9ae40/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index d728927..26e4d98 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -428,7 +428,7 @@ public class GridAffinityAssignmentCache {
* @param topVer Topology version.
* @return Cached affinity.
*/
- private GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
+ public GridAffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) {
if (topVer.equals(AffinityTopologyVersion.NONE))
topVer = lastVersion();
else
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3e9ae40/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 375219a..21975da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -17,11 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
@@ -29,6 +24,7 @@ import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
import org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -36,6 +32,12 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.lang.IgniteFuture;
import org.jetbrains.annotations.Nullable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
/**
* Cache affinity manager.
*/
@@ -246,6 +248,24 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
}
/**
+ * Get affinity assignment for the given topology version.
+ *
+ * @param topVer Toplogy version.
+ * @return Affinity affignment.
+ */
+ public GridAffinityAssignment assignment(AffinityTopologyVersion topVer) {
+ if (cctx.isLocal())
+ topVer = new AffinityTopologyVersion(1);
+
+ GridAffinityAssignmentCache aff0 = aff;
+
+ if (aff0 == null)
+ throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name());
+
+ return aff0.cachedAffinity(topVer);
+ }
+
+ /**
* @param key Key to check.
* @param topVer Topology version.
* @return Primary node for given key.
http://git-wip-us.apache.org/repos/asf/ignite/blob/f3e9ae40/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 2ab8a12..d6fc8f1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -36,6 +36,7 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.affinity.GridAffinityAssignment;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
@@ -693,7 +694,9 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
/** {@inheritDoc} */
@Override public Collection<ClusterNode> nodes(int p, AffinityTopologyVersion topVer) {
- Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
+ GridAffinityAssignment affAssignment = cctx.affinity().assignment(topVer);
+
+ Collection<ClusterNode> affNodes = affAssignment.get(p);
lock.readLock().lock();
@@ -708,9 +711,9 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
Collection<UUID> nodeIds = part2node.get(p);
if (!F.isEmpty(nodeIds)) {
- Collection<UUID> affIds = new HashSet<>(F.viewReadOnly(affNodes, F.node2id()));
-
for (UUID nodeId : nodeIds) {
+ HashSet<UUID> affIds = affAssignment.getIds(p);
+
if (!affIds.contains(nodeId) && hasState(p, nodeId, OWNING, MOVING, RENTING)) {
ClusterNode n = cctx.discovery().node(nodeId);
[14/50] [abbrv] ignite git commit: ignite-2080 Data alignment issues
with Unsafe
Posted by vo...@apache.org.
ignite-2080 Data alignment issues with Unsafe
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a87decdc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a87decdc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a87decdc
Branch: refs/heads/ignite-1786
Commit: a87decdca4009a2af857d8ca6a46e5a719786a6d
Parents: 4035d40
Author: agura <ag...@gridgain.com>
Authored: Mon Jan 11 14:53:02 2016 +0300
Committer: agura <ag...@gridgain.com>
Committed: Tue Feb 2 20:26:24 2016 +0300
----------------------------------------------------------------------
.../internal/binary/BinaryClassDescriptor.java | 6 +-
.../internal/binary/BinaryFieldAccessor.java | 45 +-
.../internal/binary/BinaryMarshaller.java | 5 +-
.../binary/BinaryObjectOffheapImpl.java | 34 +-
.../internal/binary/BinaryPrimitives.java | 117 +-
.../streams/BinaryAbstractInputStream.java | 53 +-
.../streams/BinaryAbstractOutputStream.java | 90 +-
.../binary/streams/BinaryAbstractStream.java | 34 -
.../binary/streams/BinaryHeapInputStream.java | 43 +-
.../binary/streams/BinaryHeapOutputStream.java | 86 +-
.../streams/BinaryMemoryAllocatorChunk.java | 9 +-
.../streams/BinaryOffheapInputStream.java | 42 +-
.../streams/BinaryOffheapOutputStream.java | 94 +-
.../internal/direct/DirectMessageReader.java | 2 +-
.../internal/direct/DirectMessageWriter.java | 2 +-
.../stream/v1/DirectByteBufferStreamImplV1.java | 106 +-
.../stream/v2/DirectByteBufferStreamImplV2.java | 351 ++++-
.../cache/GridCacheEvictionManager.java | 7 +-
.../cache/GridCacheOffheapSwapEntry.java | 24 +-
.../cache/GridCacheSwapEntryImpl.java | 61 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 8 +-
.../dht/atomic/GridDhtAtomicCache.java | 13 +-
.../local/atomic/GridLocalAtomicCache.java | 9 +-
.../IgniteCacheObjectProcessorImpl.java | 7 +-
.../platform/memory/PlatformAbstractMemory.java | 6 +-
.../PlatformBigEndianOutputStreamImpl.java | 14 +-
.../memory/PlatformInputStreamImpl.java | 53 +-
.../platform/memory/PlatformMemoryUtils.java | 108 +-
.../memory/PlatformOutputStreamImpl.java | 58 +-
.../ignite/internal/util/GridHandleTable.java | 17 +-
.../ignite/internal/util/GridJavaProcess.java | 3 -
.../internal/util/GridSpinReadWriteLock.java | 10 +-
.../apache/ignite/internal/util/GridUnsafe.java | 1483 +++++++++++++++++-
.../ignite/internal/util/IgniteUtils.java | 99 +-
.../internal/util/io/GridUnsafeDataInput.java | 145 +-
.../internal/util/io/GridUnsafeDataOutput.java | 165 +-
.../util/offheap/unsafe/GridUnsafeMap.java | 75 +-
.../util/offheap/unsafe/GridUnsafeMemory.java | 106 +-
.../optimized/OptimizedClassDescriptor.java | 22 +-
.../optimized/OptimizedMarshaller.java | 5 +-
.../optimized/OptimizedMarshallerUtils.java | 44 +-
.../optimized/OptimizedObjectInputStream.java | 10 +-
.../java/org/apache/ignite/GridTestIoUtils.java | 117 +-
.../ignite/internal/GridAffinitySelfTest.java | 2 +-
.../binary/BinaryFieldsOffheapSelfTest.java | 13 +-
.../BinaryFooterOffsetsOffheapSelfTest.java | 13 +-
.../binary/BinaryMarshallerSelfTest.java | 17 +-
...naryObjectBuilderDefaultMappersSelfTest.java | 24 +-
.../mutabletest/GridBinaryTestClasses.java | 3 +-
.../AbstractBinaryStreamByteOrderSelfTest.java | 464 ++++++
.../BinaryHeapStreamByteOrderSelfTest.java | 29 +
.../BinaryOffheapStreamByteOrderSelfTest.java | 31 +
...ByteBufferStreamImplV2ByteOrderSelfTest.java | 244 +++
.../cache/GridCacheConcurrentMapSelfTest.java | 13 +-
...ContinuousQueryFailoverAbstractSelfTest.java | 6 +
...dUnsafeDataInputOutputByteOrderSelfTest.java | 249 +++
.../ignite/lang/GridBasicPerformanceTest.java | 11 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 2 +-
.../testframework/junits/GridAbstractTest.java | 4 +-
.../IgniteBinaryObjectsTestSuite.java | 6 +
.../IgniteMarshallerSelfTestSuite.java | 4 +
.../hadoop/shuffle/HadoopShuffleJob.java | 5 +-
.../hadoop/shuffle/HadoopShuffleMessage.java | 10 +-
.../shuffle/streams/HadoopDataOutStream.java | 6 +-
.../HadoopConcurrentHashMultimapSelftest.java | 6 +-
.../collections/HadoopSkipListSelfTest.java | 5 +-
66 files changed, 3851 insertions(+), 1104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index 233e74b..5cb8a86 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -46,16 +46,12 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
/**
* Binary class descriptor.
*/
public class BinaryClassDescriptor {
/** */
- public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
@GridToStringExclude
private final BinaryContext ctx;
@@ -776,7 +772,7 @@ public class BinaryClassDescriptor {
*/
private Object newInstance() throws BinaryObjectException {
try {
- return ctor != null ? ctor.newInstance() : UNSAFE.allocateInstance(cls);
+ return ctor != null ? ctor.newInstance() : GridUnsafe.allocateInstance(cls);
}
catch (InstantiationException | InvocationTargetException | IllegalAccessException e) {
throw new BinaryObjectException("Failed to instantiate instance: " + cls, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
index 2d69cbd..8c8bf27 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryFieldAccessor.java
@@ -17,11 +17,6 @@
package org.apache.ignite.internal.binary;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.internal.util.GridUnsafe;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
-
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.sql.Timestamp;
@@ -29,6 +24,9 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+import org.apache.ignite.internal.util.typedef.internal.U;
/**
* Field accessor to speedup access.
@@ -157,9 +155,6 @@ public abstract class BinaryFieldAccessor {
* Base primitive field accessor.
*/
private static abstract class AbstractPrimitiveAccessor extends BinaryFieldAccessor {
- /** Unsafe instance. */
- protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Offset. */
protected final long offset;
@@ -175,7 +170,7 @@ public abstract class BinaryFieldAccessor {
assert field != null;
- offset = UNSAFE.objectFieldOffset(field);
+ offset = GridUnsafe.objectFieldOffset(field);
}
}
@@ -196,7 +191,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- byte val = UNSAFE.getByte(obj, offset);
+ byte val = GridUnsafe.getByteField(obj, offset);
writer.writeByteFieldPrimitive(val);
}
@@ -205,7 +200,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
byte val = reader.readByte(id);
- UNSAFE.putByte(obj, offset, val);
+ GridUnsafe.putByteField(obj, offset, val);
}
}
@@ -226,7 +221,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- boolean val = UNSAFE.getBoolean(obj, offset);
+ boolean val = GridUnsafe.getBooleanField(obj, offset);
writer.writeBooleanFieldPrimitive(val);
}
@@ -235,7 +230,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
boolean val = reader.readBoolean(id);
- UNSAFE.putBoolean(obj, offset, val);
+ GridUnsafe.putBooleanField(obj, offset, val);
}
}
@@ -256,7 +251,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- short val = UNSAFE.getShort(obj, offset);
+ short val = GridUnsafe.getShortField(obj, offset);
writer.writeShortFieldPrimitive(val);
}
@@ -265,7 +260,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
short val = reader.readShort(id);
- UNSAFE.putShort(obj, offset, val);
+ GridUnsafe.putShortField(obj, offset, val);
}
}
@@ -286,7 +281,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- char val = UNSAFE.getChar(obj, offset);
+ char val = GridUnsafe.getCharField(obj, offset);
writer.writeCharFieldPrimitive(val);
}
@@ -295,7 +290,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
char val = reader.readChar(id);
- UNSAFE.putChar(obj, offset, val);
+ GridUnsafe.putCharField(obj, offset, val);
}
}
@@ -316,7 +311,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- int val = UNSAFE.getInt(obj, offset);
+ int val = GridUnsafe.getIntField(obj, offset);
writer.writeIntFieldPrimitive(val);
}
@@ -325,7 +320,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
int val = reader.readInt(id);
- UNSAFE.putInt(obj, offset, val);
+ GridUnsafe.putIntField(obj, offset, val);
}
}
@@ -346,7 +341,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- long val = UNSAFE.getLong(obj, offset);
+ long val = GridUnsafe.getLongField(obj, offset);
writer.writeLongFieldPrimitive(val);
}
@@ -355,7 +350,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
long val = reader.readLong(id);
- UNSAFE.putLong(obj, offset, val);
+ GridUnsafe.putLongField(obj, offset, val);
}
}
@@ -376,7 +371,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- float val = UNSAFE.getFloat(obj, offset);
+ float val = GridUnsafe.getFloatField(obj, offset);
writer.writeFloatFieldPrimitive(val);
}
@@ -385,7 +380,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
float val = reader.readFloat(id);
- UNSAFE.putFloat(obj, offset, val);
+ GridUnsafe.putFloatField(obj, offset, val);
}
}
@@ -406,7 +401,7 @@ public abstract class BinaryFieldAccessor {
@Override public void write(Object obj, BinaryWriterExImpl writer) throws BinaryObjectException {
writer.writeFieldIdNoSchemaUpdate(id);
- double val = UNSAFE.getDouble(obj, offset);
+ double val = GridUnsafe.getDoubleField(obj, offset);
writer.writeDoubleFieldPrimitive(val);
}
@@ -415,7 +410,7 @@ public abstract class BinaryFieldAccessor {
@Override public void read(Object obj, BinaryReaderExImpl reader) throws BinaryObjectException {
double val = reader.readDouble(id);
- UNSAFE.putDouble(obj, offset, val);
+ GridUnsafe.putDoubleField(obj, offset, val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
index 5480967..29a1fca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
@@ -24,7 +24,6 @@ import java.io.OutputStream;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.marshaller.AbstractMarshaller;
import org.apache.ignite.marshaller.MarshallerContext;
import org.jetbrains.annotations.Nullable;
@@ -52,9 +51,7 @@ public class BinaryMarshaller extends AbstractMarshaller {
@SuppressWarnings({"TypeParameterExtendsFinalClass", "ErrorNotRethrown"})
public static boolean available() {
try {
- Unsafe unsafe = GridUnsafe.unsafe();
-
- Class<? extends Unsafe> unsafeCls = unsafe.getClass();
+ Class<? extends Unsafe> unsafeCls = Unsafe.class;
unsafeCls.getMethod("allocateInstance", Class.class);
unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
index 696a34b..07ab4d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryObjectOffheapImpl.java
@@ -17,6 +17,16 @@
package org.apache.ignite.internal.binary;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -26,23 +36,10 @@ import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.UUID;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -54,9 +51,6 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
private static final long serialVersionUID = 0L;
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
private final BinaryContext ctx;
/** */
@@ -97,22 +91,22 @@ public class BinaryObjectOffheapImpl extends BinaryObjectExImpl implements Exter
/** {@inheritDoc} */
@Override public int typeId() {
- return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.TYPE_ID_POS);
+ return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.TYPE_ID_POS);
}
/** {@inheritDoc} */
@Override public int length() {
- return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.TOTAL_LEN_POS);
+ return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.TOTAL_LEN_POS);
}
/** {@inheritDoc} */
@Override public int hashCode() {
- return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.HASH_CODE_POS);
+ return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.HASH_CODE_POS);
}
/** {@inheritDoc} */
@Override protected int schemaId() {
- return UNSAFE.getInt(ptr + start + GridBinaryMarshaller.SCHEMA_ID_POS);
+ return BinaryPrimitives.readInt(ptr, start + GridBinaryMarshaller.SCHEMA_ID_POS);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
index a6a867c..8b82fad 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryPrimitives.java
@@ -18,33 +18,20 @@
package org.apache.ignite.internal.binary;
import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
-import java.nio.ByteOrder;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
/**
* Primitives writer.
*/
public abstract class BinaryPrimitives {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
- private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** Whether little endian is set. */
- private static final boolean BIG_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
-
/**
* @param arr Array.
* @param off Offset.
* @param val Value.
*/
public static void writeByte(byte[] arr, int off, byte val) {
- UNSAFE.putByte(arr, BYTE_ARR_OFF + off, val);
+ GridUnsafe.putByte(arr, GridUnsafe.BYTE_ARR_OFF + off, val);
}
/**
@@ -53,7 +40,7 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static byte readByte(byte[] arr, int off) {
- return UNSAFE.getByte(arr, BYTE_ARR_OFF + off);
+ return GridUnsafe.getByte(arr, GridUnsafe.BYTE_ARR_OFF + off);
}
/**
@@ -62,7 +49,7 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static byte readByte(long ptr, int off) {
- return UNSAFE.getByte(ptr + off);
+ return GridUnsafe.getByte(ptr + off);
}
/**
@@ -73,7 +60,7 @@ public abstract class BinaryPrimitives {
public static byte[] readByteArray(byte[] arr, int off, int len) {
byte[] arr0 = new byte[len];
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, arr0, BYTE_ARR_OFF, len);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, arr0, GridUnsafe.BYTE_ARR_OFF, len);
return arr0;
}
@@ -86,7 +73,7 @@ public abstract class BinaryPrimitives {
public static byte[] readByteArray(long ptr, int off, int len) {
byte[] arr0 = new byte[len];
- UNSAFE.copyMemory(null, ptr + off, arr0, BYTE_ARR_OFF, len);
+ GridUnsafe.copyMemory(null, ptr + off, arr0, GridUnsafe.BYTE_ARR_OFF, len);
return arr0;
}
@@ -124,10 +111,12 @@ public abstract class BinaryPrimitives {
* @param val Value.
*/
public static void writeShort(byte[] arr, int off, short val) {
- if (BIG_ENDIAN)
- val = Short.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- UNSAFE.putShort(arr, BYTE_ARR_OFF + off, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(arr, pos, val);
+ else
+ GridUnsafe.putShort(arr, pos, val);
}
/**
@@ -136,12 +125,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static short readShort(byte[] arr, int off) {
- short val = UNSAFE.getShort(arr, BYTE_ARR_OFF + off);
-
- if (BIG_ENDIAN)
- val = Short.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(arr, pos) : GridUnsafe.getShort(arr, pos);
}
/**
@@ -150,12 +136,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static short readShort(long ptr, int off) {
- short val = UNSAFE.getShort(ptr + off);
-
- if (BIG_ENDIAN)
- val = Short.reverseBytes(val);
+ long addr = ptr + off;
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
}
/**
@@ -164,10 +147,12 @@ public abstract class BinaryPrimitives {
* @param val Value.
*/
public static void writeChar(byte[] arr, int off, char val) {
- if (BIG_ENDIAN)
- val = Character.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- UNSAFE.putChar(arr, BYTE_ARR_OFF + off, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(arr, pos, val);
+ else
+ GridUnsafe.putChar(arr, pos, val);
}
/**
@@ -176,12 +161,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static char readChar(byte[] arr, int off) {
- char val = UNSAFE.getChar(arr, BYTE_ARR_OFF + off);
-
- if (BIG_ENDIAN)
- val = Character.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getCharLE(arr, pos): GridUnsafe.getChar(arr, pos);
}
/**
@@ -190,12 +172,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static char readChar(long ptr, int off) {
- char val = UNSAFE.getChar(ptr + off);
+ long addr = ptr + off;
- if (BIG_ENDIAN)
- val = Character.reverseBytes(val);
-
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getCharLE(addr) : GridUnsafe.getChar(addr);
}
/**
@@ -206,7 +185,7 @@ public abstract class BinaryPrimitives {
public static char[] readCharArray(byte[] arr, int off, int len) {
char[] arr0 = new char[len];
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, arr0, CHAR_ARR_OFF, len << 1);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, arr0, GridUnsafe.CHAR_ARR_OFF, len << 1);
if (BIG_ENDIAN) {
for (int i = 0; i < len; i++)
@@ -224,7 +203,7 @@ public abstract class BinaryPrimitives {
public static char[] readCharArray(long ptr, int off, int len) {
char[] arr0 = new char[len];
- UNSAFE.copyMemory(null, ptr + off, arr0, CHAR_ARR_OFF, len << 1);
+ GridUnsafe.copyMemory(null, ptr + off, arr0, GridUnsafe.CHAR_ARR_OFF, len << 1);
if (BIG_ENDIAN) {
for (int i = 0; i < len; i++)
@@ -240,10 +219,12 @@ public abstract class BinaryPrimitives {
* @param val Value.
*/
public static void writeInt(byte[] arr, int off, int val) {
- if (BIG_ENDIAN)
- val = Integer.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- UNSAFE.putInt(arr, BYTE_ARR_OFF + off, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(arr, pos, val);
+ else
+ GridUnsafe.putInt(arr, pos, val);
}
/**
@@ -252,12 +233,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static int readInt(byte[] arr, int off) {
- int val = UNSAFE.getInt(arr, BYTE_ARR_OFF + off);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- if (BIG_ENDIAN)
- val = Integer.reverseBytes(val);
-
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(arr, pos) : GridUnsafe.getInt(arr, pos);
}
/**
@@ -266,12 +244,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static int readInt(long ptr, int off) {
- int val = UNSAFE.getInt(ptr + off);
-
- if (BIG_ENDIAN)
- val = Integer.reverseBytes(val);
+ long addr = ptr + off;
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
}
/**
@@ -280,10 +255,12 @@ public abstract class BinaryPrimitives {
* @param val Value.
*/
public static void writeLong(byte[] arr, int off, long val) {
- if (BIG_ENDIAN)
- val = Long.reverseBytes(val);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- UNSAFE.putLong(arr, BYTE_ARR_OFF + off, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(arr, pos, val);
+ else
+ GridUnsafe.putLong(arr, pos, val);
}
/**
@@ -292,12 +269,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static long readLong(byte[] arr, int off) {
- long val = UNSAFE.getLong(arr, BYTE_ARR_OFF + off);
+ long pos = GridUnsafe.BYTE_ARR_OFF + off;
- if (BIG_ENDIAN)
- val = Long.reverseBytes(val);
-
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getLongLE(arr, pos) : GridUnsafe.getLong(arr, pos);
}
/**
@@ -306,12 +280,9 @@ public abstract class BinaryPrimitives {
* @return Value.
*/
public static long readLong(long ptr, int off) {
- long val = UNSAFE.getLong(ptr + off);
-
- if (BIG_ENDIAN)
- val = Long.reverseBytes(val);
+ long addr = ptr + off;
- return val;
+ return BIG_ENDIAN ? GridUnsafe.getLongLE(addr) : GridUnsafe.getLong(addr);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
index 334f455..b6c30bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractInputStream.java
@@ -18,6 +18,9 @@
package org.apache.ignite.internal.binary.streams;
import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
/**
* Binary abstract input stream.
@@ -40,7 +43,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
byte[] res = new byte[cnt];
- copyAndShift(res, BYTE_ARR_OFF, cnt);
+ copyAndShift(res, GridUnsafe.BYTE_ARR_OFF, cnt);
return res;
}
@@ -56,7 +59,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
boolean[] res = new boolean[cnt];
- copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
+ copyAndShift(res, GridUnsafe.BOOLEAN_ARR_OFF, cnt);
return res;
}
@@ -69,9 +72,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
shift(2);
- if (!LITTLE_ENDIAN)
- res = Short.reverseBytes(res);
-
return res;
}
@@ -83,9 +83,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
short[] res = new short[cnt];
- copyAndShift(res, SHORT_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.SHORT_ARR_OFF, len);
- if (!LITTLE_ENDIAN) {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++)
res[i] = Short.reverseBytes(res[i]);
}
@@ -101,9 +101,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
shift(2);
- if (!LITTLE_ENDIAN)
- res = Character.reverseBytes(res);
-
return res;
}
@@ -115,9 +112,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
char[] res = new char[cnt];
- copyAndShift(res, CHAR_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.CHAR_ARR_OFF, len);
- if (!LITTLE_ENDIAN) {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++)
res[i] = Character.reverseBytes(res[i]);
}
@@ -133,9 +130,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
shift(4);
- if (!LITTLE_ENDIAN)
- res = Integer.reverseBytes(res);
-
return res;
}
@@ -147,9 +141,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
int[] res = new int[cnt];
- copyAndShift(res, INT_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.INT_ARR_OFF, len);
- if (!LITTLE_ENDIAN) {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++)
res[i] = Integer.reverseBytes(res[i]);
}
@@ -200,17 +194,17 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
float[] res = new float[cnt];
- if (LITTLE_ENDIAN)
- copyAndShift(res, FLOAT_ARR_OFF, len);
- else {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++) {
int x = readIntFast();
shift(4);
- res[i] = Float.intBitsToFloat(Integer.reverseBytes(x));
+ res[i] = Float.intBitsToFloat(x);
}
}
+ else
+ copyAndShift(res, GridUnsafe.FLOAT_ARR_OFF, len);
return res;
}
@@ -223,9 +217,6 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
shift(8);
- if (!LITTLE_ENDIAN)
- res = Long.reverseBytes(res);
-
return res;
}
@@ -237,9 +228,9 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
long[] res = new long[cnt];
- copyAndShift(res, LONG_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.LONG_ARR_OFF, len);
- if (!LITTLE_ENDIAN) {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++)
res[i] = Long.reverseBytes(res[i]);
}
@@ -260,17 +251,17 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
double[] res = new double[cnt];
- if (LITTLE_ENDIAN)
- copyAndShift(res, DOUBLE_ARR_OFF, len);
- else {
+ if (BIG_ENDIAN) {
for (int i = 0; i < res.length; i++) {
long x = readLongFast();
shift(8);
- res[i] = Double.longBitsToDouble(Long.reverseBytes(x));
+ res[i] = Double.longBitsToDouble(x);
}
}
+ else
+ copyAndShift(res, GridUnsafe.DOUBLE_ARR_OFF, len);
return res;
}
@@ -280,7 +271,7 @@ public abstract class BinaryAbstractInputStream extends BinaryAbstractStream
if (len > remaining())
len = remaining();
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
+ copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
return len;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
index 4221cbe..b9df68e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractOutputStream.java
@@ -17,6 +17,10 @@
package org.apache.ignite.internal.binary.streams;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
/**
* Base binary output stream.
*/
@@ -36,7 +40,7 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
@Override public void writeByteArray(byte[] val) {
ensureCapacity(pos + val.length);
- copyAndShift(val, BYTE_ARR_OFF, val.length);
+ copyAndShift(val, GridUnsafe.BYTE_ARR_OFF, val.length);
}
/** {@inheritDoc} */
@@ -48,16 +52,13 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
@Override public void writeBooleanArray(boolean[] val) {
ensureCapacity(pos + val.length);
- copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
+ copyAndShift(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length);
}
/** {@inheritDoc} */
@Override public void writeShort(short val) {
ensureCapacity(pos + 2);
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
-
writeShortFast(val);
shift(2);
@@ -69,23 +70,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, SHORT_ARR_OFF, cnt);
- else {
- for (short item : val)
- writeShortFast(Short.reverseBytes(item));
+ if (BIG_ENDIAN) {
+ for (short item : val) {
+ writeShortFast(item);
- shift(cnt);
+ shift(2);
+ }
}
+ else
+ copyAndShift(val, GridUnsafe.SHORT_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@Override public void writeChar(char val) {
ensureCapacity(pos + 2);
- if (!LITTLE_ENDIAN)
- val = Character.reverseBytes(val);
-
writeCharFast(val);
shift(2);
@@ -97,23 +96,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, CHAR_ARR_OFF, cnt);
- else {
- for (char item : val)
- writeCharFast(Character.reverseBytes(item));
+ if (BIG_ENDIAN) {
+ for (char item : val) {
+ writeCharFast(item);
- shift(cnt);
+ shift(2);
+ }
}
+ else
+ copyAndShift(val, GridUnsafe.CHAR_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@Override public void writeInt(int val) {
ensureCapacity(pos + 4);
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
-
writeIntFast(val);
shift(4);
@@ -139,14 +136,15 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, INT_ARR_OFF, cnt);
- else {
- for (int item : val)
- writeIntFast(Integer.reverseBytes(item));
+ if (BIG_ENDIAN) {
+ for (int item : val) {
+ writeIntFast(item);
- shift(cnt);
+ shift(4);
+ }
}
+ else
+ copyAndShift(val, GridUnsafe.INT_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@@ -160,24 +158,21 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, FLOAT_ARR_OFF, cnt);
- else {
+ if (BIG_ENDIAN) {
for (float item : val) {
- writeIntFast(Integer.reverseBytes(Float.floatToIntBits(item)));
+ writeIntFast(Float.floatToIntBits(item));
shift(4);
}
}
+ else
+ copyAndShift(val, GridUnsafe.FLOAT_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@Override public void writeLong(long val) {
ensureCapacity(pos + 8);
- if (!LITTLE_ENDIAN)
- val = Long.reverseBytes(val);
-
writeLongFast(val);
shift(8);
@@ -189,14 +184,15 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, LONG_ARR_OFF, cnt);
- else {
- for (long item : val)
- writeLongFast(Long.reverseBytes(item));
+ if (BIG_ENDIAN) {
+ for (long item : val) {
+ writeLongFast(item);
- shift(cnt);
+ shift(8);
+ }
}
+ else
+ copyAndShift(val, GridUnsafe.LONG_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@@ -210,22 +206,22 @@ public abstract class BinaryAbstractOutputStream extends BinaryAbstractStream
ensureCapacity(pos + cnt);
- if (LITTLE_ENDIAN)
- copyAndShift(val, DOUBLE_ARR_OFF, cnt);
- else {
+ if (BIG_ENDIAN) {
for (double item : val) {
- writeLongFast(Long.reverseBytes(Double.doubleToLongBits(item)));
+ writeLongFast(Double.doubleToLongBits(item));
shift(8);
}
}
+ else
+ copyAndShift(val, GridUnsafe.DOUBLE_ARR_OFF, cnt);
}
/** {@inheritDoc} */
@Override public void write(byte[] arr, int off, int len) {
ensureCapacity(pos + len);
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
+ copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
index 1e8ce09..2983cbc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryAbstractStream.java
@@ -17,10 +17,6 @@
package org.apache.ignite.internal.binary.streams;
-import java.nio.ByteOrder;
-import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
-
/**
* Binary abstract stream.
*/
@@ -31,36 +27,6 @@ public abstract class BinaryAbstractStream implements BinaryStream {
/** Byte: one. */
protected static final byte BYTE_ONE = 1;
- /** Whether little endian is used on the platform. */
- protected static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
- /** Unsafe instance. */
- protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: boolean. */
- protected static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
- /** Array offset: byte. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Array offset: short. */
- protected static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
- /** Array offset: char. */
- protected static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** Array offset: int. */
- protected static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
- /** Array offset: float. */
- protected static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
- /** Array offset: long. */
- protected static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
- /** Array offset: double. */
- protected static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
/** Position. */
protected int pos;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
index 732b8c7..b584373 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapInputStream.java
@@ -18,9 +18,12 @@
package org.apache.ignite.internal.binary.streams;
import java.util.Arrays;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
/**
- * Binary off-heap input stream.
+ * Binary heap input stream.
*/
public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
/**
@@ -75,7 +78,7 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
if (data.length < len) {
byte[] data0 = new byte[len];
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, data0, BYTE_ARR_OFF, data.length);
+ GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, data0, GridUnsafe.BYTE_ARR_OFF, data.length);
data = data0;
}
@@ -97,7 +100,7 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
@Override public byte[] arrayCopy() {
byte[] res = new byte[len];
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, res.length);
+ GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, res, GridUnsafe.BYTE_ARR_OFF, res.length);
return res;
}
@@ -114,53 +117,57 @@ public final class BinaryHeapInputStream extends BinaryAbstractInputStream {
/** {@inheritDoc} */
@Override protected void copyAndShift(Object target, long off, int len) {
- UNSAFE.copyMemory(data, BYTE_ARR_OFF + pos, target, off, len);
+ GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF + pos, target, off, len);
shift(len);
}
/** {@inheritDoc} */
@Override protected short readShortFast() {
- return UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(data, off) : GridUnsafe.getShort(data, off);
+
}
/** {@inheritDoc} */
@Override protected char readCharFast() {
- return UNSAFE.getChar(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getCharLE(data, off) : GridUnsafe.getChar(data, off);
}
/** {@inheritDoc} */
@Override protected int readIntFast() {
- return UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(data, off) : GridUnsafe.getInt(data, off);
}
/** {@inheritDoc} */
@Override protected long readLongFast() {
- return UNSAFE.getLong(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getLongLE(data, off) : GridUnsafe.getLong(data, off);
}
/** {@inheritDoc} */
@Override protected byte readBytePositioned0(int pos) {
- return UNSAFE.getByte(data, BYTE_ARR_OFF + pos);
+ return GridUnsafe.getByte(data, GridUnsafe.BYTE_ARR_OFF + pos);
}
/** {@inheritDoc} */
@Override protected short readShortPositioned0(int pos) {
- short res = UNSAFE.getShort(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- if (!LITTLE_ENDIAN)
- res = Short.reverseBytes(res);
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(data, off) : GridUnsafe.getShort(data, off);
- return res;
}
/** {@inheritDoc} */
@Override protected int readIntPositioned0(int pos) {
- int res = UNSAFE.getInt(data, BYTE_ARR_OFF + pos);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- if (!LITTLE_ENDIAN)
- res = Integer.reverseBytes(res);
-
- return res;
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(data, off) : GridUnsafe.getInt(data, off);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
index 7553f3b..2c31641 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryHeapOutputStream.java
@@ -17,6 +17,10 @@
package org.apache.ignite.internal.binary.streams;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
/**
* Binary heap output stream.
*/
@@ -71,7 +75,7 @@ public final class BinaryHeapOutputStream extends BinaryAbstractOutputStream {
@Override public byte[] arrayCopy() {
byte[] res = new byte[pos];
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, res, BYTE_ARR_OFF, pos);
+ GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, res, GridUnsafe.BYTE_ARR_OFF, pos);
return res;
}
@@ -88,88 +92,120 @@ public final class BinaryHeapOutputStream extends BinaryAbstractOutputStream {
/** {@inheritDoc} */
@Override protected void copyAndShift(Object src, long off, int len) {
- UNSAFE.copyMemory(src, off, data, BYTE_ARR_OFF + pos, len);
+ GridUnsafe.copyMemory(src, off, data, GridUnsafe.BYTE_ARR_OFF + pos, len);
shift(len);
}
/** {@inheritDoc} */
@Override protected void writeShortFast(short val) {
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(data, off, val);
+ else
+ GridUnsafe.putShort(data, off, val);
}
/** {@inheritDoc} */
@Override protected void writeCharFast(char val) {
- UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(data, off, val);
+ else
+ GridUnsafe.putChar(data, off, val);
}
/** {@inheritDoc} */
@Override protected void writeIntFast(int val) {
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(data, off, val);
+ else
+ GridUnsafe.putInt(data, off, val);
}
/** {@inheritDoc} */
@Override protected void writeLongFast(long val) {
- UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(data, off, val);
+ else
+ GridUnsafe.putLong(data, off, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteByte(byte val) {
- UNSAFE.putByte(data, BYTE_ARR_OFF + pos++, val);
+ GridUnsafe.putByte(data, GridUnsafe.BYTE_ARR_OFF + pos++, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteShort(short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(data, off, val);
+ else
+ GridUnsafe.putShort(data, off, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteShort(int pos, short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putShort(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(data, off, val);
+ else
+ GridUnsafe.putShort(data, off, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteChar(char val) {
- if (!LITTLE_ENDIAN)
- val = Character.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putChar(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(data, off, val);
+ else
+ GridUnsafe.putChar(data, off, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(data, off, val);
+ else
+ GridUnsafe.putInt(data, off, val);
shift(4);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int pos, int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putInt(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(data, off, val);
+ else
+ GridUnsafe.putInt(data, off, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteLong(long val) {
- if (!LITTLE_ENDIAN)
- val = Long.reverseBytes(val);
+ long off = GridUnsafe.BYTE_ARR_OFF + pos;
- UNSAFE.putLong(data, BYTE_ARR_OFF + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(data, off, val);
+ else
+ GridUnsafe.putLong(data, off, val);
shift(8);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
index 7c73742..f9db7da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryMemoryAllocatorChunk.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.binary.streams;
import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RECHECK;
@@ -27,12 +26,6 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_MARSHAL_BUFFERS_RE
* Memory allocator chunk.
*/
public class BinaryMemoryAllocatorChunk {
- /** Unsafe instance. */
- protected static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: byte. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
/** Buffer size re-check frequency. */
private static final Long CHECK_FREQ = Long.getLong(IGNITE_MARSHAL_BUFFERS_RECHECK, 10000);
@@ -79,7 +72,7 @@ public class BinaryMemoryAllocatorChunk {
if (this.data == data)
this.data = newData;
- UNSAFE.copyMemory(data, BYTE_ARR_OFF, newData, BYTE_ARR_OFF, data.length);
+ GridUnsafe.copyMemory(data, GridUnsafe.BYTE_ARR_OFF, newData, GridUnsafe.BYTE_ARR_OFF, data.length);
return newData;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
index cff002f..9230846 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapInputStream.java
@@ -17,6 +17,10 @@
package org.apache.ignite.internal.binary.streams;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
/**
* Binary off-heap input stream.
*/
@@ -70,7 +74,7 @@ public class BinaryOffheapInputStream extends BinaryAbstractInputStream {
@Override public byte[] arrayCopy() {
byte[] res = new byte[len];
- UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, res.length);
+ GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, res.length);
return res;
}
@@ -82,59 +86,61 @@ public class BinaryOffheapInputStream extends BinaryAbstractInputStream {
/** {@inheritDoc} */
@Override protected byte readByteAndShift() {
- return UNSAFE.getByte(ptr + pos++);
+ return GridUnsafe.getByte(ptr + pos++);
}
/** {@inheritDoc} */
@Override protected void copyAndShift(Object target, long off, int len) {
- UNSAFE.copyMemory(null, ptr + pos, target, off, len);
+ GridUnsafe.copyMemory(null, ptr + pos, target, off, len);
shift(len);
}
/** {@inheritDoc} */
@Override protected short readShortFast() {
- return UNSAFE.getShort(ptr + pos);
+ long addr = ptr + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
}
/** {@inheritDoc} */
@Override protected char readCharFast() {
- return UNSAFE.getChar(ptr + pos);
+ long addr = ptr + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getCharLE(addr) : GridUnsafe.getChar(addr);
}
/** {@inheritDoc} */
@Override protected int readIntFast() {
- return UNSAFE.getInt(ptr + pos);
+ long addr = ptr + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
}
/** {@inheritDoc} */
@Override protected long readLongFast() {
- return UNSAFE.getLong(ptr + pos);
+ long addr = ptr + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getLongLE(addr) : GridUnsafe.getLong(addr);
}
/** {@inheritDoc} */
@Override protected byte readBytePositioned0(int pos) {
- return UNSAFE.getByte(ptr + pos);
+ return GridUnsafe.getByte(ptr + pos);
}
/** {@inheritDoc} */
@Override protected short readShortPositioned0(int pos) {
- short res = UNSAFE.getShort(ptr + pos);
-
- if (!LITTLE_ENDIAN)
- res = Short.reverseBytes(res);
+ long addr = ptr + pos;
- return res;
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(addr) : GridUnsafe.getShort(addr);
}
/** {@inheritDoc} */
@Override protected int readIntPositioned0(int pos) {
- int res = UNSAFE.getInt(ptr + pos);
+ long addr = ptr + pos;
- if (!LITTLE_ENDIAN)
- res = Integer.reverseBytes(res);
-
- return res;
+ return BIG_ENDIAN ? GridUnsafe.getIntLE(addr) : GridUnsafe.getInt(addr);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
index 080a357..1cb9f4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/streams/BinaryOffheapOutputStream.java
@@ -17,6 +17,10 @@
package org.apache.ignite.internal.binary.streams;
+import org.apache.ignite.internal.util.GridUnsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+
/**
* Binary offheap output stream.
*/
@@ -73,7 +77,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
@Override public byte[] arrayCopy() {
byte[] res = new byte[pos];
- UNSAFE.copyMemory(null, ptr, res, BYTE_ARR_OFF, pos);
+ GridUnsafe.copyMemory(null, ptr, res, GridUnsafe.BYTE_ARR_OFF, pos);
return res;
}
@@ -94,34 +98,54 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
/** {@inheritDoc} */
@Override protected void writeByteAndShift(byte val) {
- UNSAFE.putByte(ptr + pos++, val);
+ GridUnsafe.putByte(ptr + pos++, val);
}
/** {@inheritDoc} */
@Override protected void copyAndShift(Object src, long offset, int len) {
- UNSAFE.copyMemory(src, offset, null, ptr + pos, len);
+ GridUnsafe.copyMemory(src, offset, null, ptr + pos, len);
shift(len);
}
/** {@inheritDoc} */
@Override protected void writeShortFast(short val) {
- UNSAFE.putShort(ptr + pos, val);
+ long addr = ptr + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(addr, val);
+ else
+ GridUnsafe.putShort(addr, val);
}
/** {@inheritDoc} */
@Override protected void writeCharFast(char val) {
- UNSAFE.putChar(ptr + pos, val);
+ long addr = ptr + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(addr, val);
+ else
+ GridUnsafe.putChar(addr, val);
}
/** {@inheritDoc} */
@Override protected void writeIntFast(int val) {
- UNSAFE.putInt(ptr + pos, val);
+ long addr = ptr + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(addr, val);
+ else
+ GridUnsafe.putInt(addr, val);
}
/** {@inheritDoc} */
@Override protected void writeLongFast(long val) {
- UNSAFE.putLong(ptr + pos, val);
+ long addr = ptr + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(addr, val);
+ else
+ GridUnsafe.putLong(addr, val);
}
/** {@inheritDoc} */
@@ -131,61 +155,73 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
/** {@inheritDoc} */
@Override public void unsafeWriteByte(byte val) {
- UNSAFE.putByte(ptr + pos++, val);
+ GridUnsafe.putByte(ptr + pos++, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteShort(short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putShort(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(addr, val);
+ else
+ GridUnsafe.putShort(addr, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteShort(int pos, short val) {
- if (!LITTLE_ENDIAN)
- val = Short.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putShort(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(addr, val);
+ else
+ GridUnsafe.putShort(addr, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteChar(char val) {
- if (!LITTLE_ENDIAN)
- val = Character.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putChar(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(addr, val);
+ else
+ GridUnsafe.putChar(addr, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putInt(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(addr, val);
+ else
+ GridUnsafe.putInt(addr, val);
shift(4);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int pos, int val) {
- if (!LITTLE_ENDIAN)
- val = Integer.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putInt(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(addr, val);
+ else
+ GridUnsafe.putInt(addr, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteLong(long val) {
- if (!LITTLE_ENDIAN)
- val = Long.reverseBytes(val);
+ long addr = ptr + pos;
- UNSAFE.putLong(ptr + pos, val);
+ if (BIG_ENDIAN)
+ GridUnsafe.putLongLE(addr, val);
+ else
+ GridUnsafe.putLong(addr, val);
shift(8);
}
@@ -197,7 +233,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
* @return Pointer.
*/
protected long allocate(int cap) {
- return UNSAFE.allocateMemory(cap);
+ return GridUnsafe.allocateMemory(cap);
}
/**
@@ -208,7 +244,7 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
* @return New pointer.
*/
protected long reallocate(long ptr, int cap) {
- return UNSAFE.reallocateMemory(ptr, cap);
+ return GridUnsafe.reallocateMemory(ptr, cap);
}
/**
@@ -217,6 +253,6 @@ public class BinaryOffheapOutputStream extends BinaryAbstractOutputStream {
* @param ptr Pointer.
*/
protected void release(long ptr) {
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
index 10bc7e2..b567a03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageReader.java
@@ -26,8 +26,8 @@ import org.apache.ignite.internal.direct.state.DirectMessageState;
import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
-import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.plugin.extensions.communication.Message;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
index b265c6c..be17113 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/DirectMessageWriter.java
@@ -26,9 +26,9 @@ import org.apache.ignite.internal.direct.state.DirectMessageState;
import org.apache.ignite.internal.direct.state.DirectMessageStateItem;
import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
import org.apache.ignite.internal.direct.stream.v1.DirectByteBufferStreamImplV1;
-import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.direct.stream.v2.DirectByteBufferStreamImplV2;
import org.apache.ignite.lang.IgniteOutClosure;
import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.plugin.extensions.communication.Message;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
index 67fa9e7..2187945 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v1/DirectByteBufferStreamImplV1.java
@@ -37,7 +37,6 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemTy
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
/**
@@ -45,33 +44,6 @@ import sun.nio.ch.DirectBuffer;
*/
public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
- private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
- /** */
- private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
- /** */
- private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
- /** */
- private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
- /** */
- private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
- /** */
- private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** */
- private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
- /** */
private static final byte[] BYTE_ARR_EMPTY = new byte[0];
/** */
@@ -303,7 +275,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
this.buf = buf;
heapArr = buf.isDirect() ? null : buf.array();
- baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : BYTE_ARR_OFF;
+ baseOff = buf.isDirect() ? ((DirectBuffer)buf).address() : GridUnsafe.BYTE_ARR_OFF;
}
}
@@ -324,7 +296,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putByte(heapArr, baseOff + pos, val);
+ GridUnsafe.putByte(heapArr, baseOff + pos, val);
buf.position(pos + 1);
}
@@ -337,7 +309,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putShort(heapArr, baseOff + pos, val);
+ GridUnsafe.putShort(heapArr, baseOff + pos, val);
buf.position(pos + 2);
}
@@ -350,7 +322,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putInt(heapArr, baseOff + pos, val);
+ GridUnsafe.putInt(heapArr, baseOff + pos, val);
buf.position(pos + 4);
}
@@ -363,7 +335,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putLong(heapArr, baseOff + pos, val);
+ GridUnsafe.putLong(heapArr, baseOff + pos, val);
buf.position(pos + 8);
}
@@ -378,7 +350,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putFloat(heapArr, baseOff + pos, val);
+ GridUnsafe.putFloat(heapArr, baseOff + pos, val);
buf.position(pos + 4);
}
@@ -391,7 +363,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putDouble(heapArr, baseOff + pos, val);
+ GridUnsafe.putDouble(heapArr, baseOff + pos, val);
buf.position(pos + 8);
}
@@ -404,7 +376,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putChar(heapArr, baseOff + pos, val);
+ GridUnsafe.putChar(heapArr, baseOff + pos, val);
buf.position(pos + 2);
}
@@ -417,7 +389,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putBoolean(heapArr, baseOff + pos, val);
+ GridUnsafe.putBoolean(heapArr, baseOff + pos, val);
buf.position(pos + 1);
}
@@ -426,7 +398,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeByteArray(byte[] val) {
if (val != null)
- lastFinished = writeArray(val, BYTE_ARR_OFF, val.length, val.length);
+ lastFinished = writeArray(val, GridUnsafe.BYTE_ARR_OFF, val.length, val.length);
else
writeInt(-1);
}
@@ -434,7 +406,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeByteArray(byte[] val, long off, int len) {
if (val != null)
- lastFinished = writeArray(val, BYTE_ARR_OFF + off, len, len);
+ lastFinished = writeArray(val, GridUnsafe.BYTE_ARR_OFF + off, len, len);
else
writeInt(-1);
}
@@ -442,7 +414,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeShortArray(short[] val) {
if (val != null)
- lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
+ lastFinished = writeArray(val, GridUnsafe.SHORT_ARR_OFF, val.length, val.length << 1);
else
writeInt(-1);
}
@@ -450,7 +422,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeIntArray(int[] val) {
if (val != null)
- lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
+ lastFinished = writeArray(val, GridUnsafe.INT_ARR_OFF, val.length, val.length << 2);
else
writeInt(-1);
}
@@ -458,7 +430,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeLongArray(long[] val) {
if (val != null)
- lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
+ lastFinished = writeArray(val, GridUnsafe.LONG_ARR_OFF, val.length, val.length << 3);
else
writeInt(-1);
}
@@ -466,7 +438,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeFloatArray(float[] val) {
if (val != null)
- lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
+ lastFinished = writeArray(val, GridUnsafe.FLOAT_ARR_OFF, val.length, val.length << 2);
else
writeInt(-1);
}
@@ -474,7 +446,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeDoubleArray(double[] val) {
if (val != null)
- lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
+ lastFinished = writeArray(val, GridUnsafe.DOUBLE_ARR_OFF, val.length, val.length << 3);
else
writeInt(-1);
}
@@ -482,7 +454,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeCharArray(char[] val) {
if (val != null)
- lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+ lastFinished = writeArray(val, GridUnsafe.CHAR_ARR_OFF, val.length, val.length << 1);
else
writeInt(-1);
}
@@ -490,7 +462,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeBooleanArray(boolean[] val) {
if (val != null)
- lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length);
+ lastFinished = writeArray(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length, val.length);
else
writeInt(-1);
}
@@ -653,7 +625,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 1);
- return UNSAFE.getByte(heapArr, baseOff + pos);
+ return GridUnsafe.getByte(heapArr, baseOff + pos);
}
else
return 0;
@@ -668,7 +640,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 2);
- return UNSAFE.getShort(heapArr, baseOff + pos);
+ return GridUnsafe.getShort(heapArr, baseOff + pos);
}
else
return 0;
@@ -683,7 +655,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 4);
- return UNSAFE.getInt(heapArr, baseOff + pos);
+ return GridUnsafe.getInt(heapArr, baseOff + pos);
}
else
return 0;
@@ -698,7 +670,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 8);
- return UNSAFE.getLong(heapArr, baseOff + pos);
+ return GridUnsafe.getLong(heapArr, baseOff + pos);
}
else
return 0;
@@ -713,7 +685,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 4);
- return UNSAFE.getFloat(heapArr, baseOff + pos);
+ return GridUnsafe.getFloat(heapArr, baseOff + pos);
}
else
return 0;
@@ -728,7 +700,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 8);
- return UNSAFE.getDouble(heapArr, baseOff + pos);
+ return GridUnsafe.getDouble(heapArr, baseOff + pos);
}
else
return 0;
@@ -743,7 +715,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 2);
- return UNSAFE.getChar(heapArr, baseOff + pos);
+ return GridUnsafe.getChar(heapArr, baseOff + pos);
}
else
return 0;
@@ -758,7 +730,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
buf.position(pos + 1);
- return UNSAFE.getBoolean(heapArr, baseOff + pos);
+ return GridUnsafe.getBoolean(heapArr, baseOff + pos);
}
else
return false;
@@ -766,42 +738,42 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public byte[] readByteArray() {
- return readArray(BYTE_ARR_CREATOR, 0, BYTE_ARR_OFF);
+ return readArray(BYTE_ARR_CREATOR, 0, GridUnsafe.BYTE_ARR_OFF);
}
/** {@inheritDoc} */
@Override public short[] readShortArray() {
- return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
+ return readArray(SHORT_ARR_CREATOR, 1, GridUnsafe.SHORT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public int[] readIntArray() {
- return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
+ return readArray(INT_ARR_CREATOR, 2, GridUnsafe.INT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public long[] readLongArray() {
- return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
+ return readArray(LONG_ARR_CREATOR, 3, GridUnsafe.LONG_ARR_OFF);
}
/** {@inheritDoc} */
@Override public float[] readFloatArray() {
- return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
+ return readArray(FLOAT_ARR_CREATOR, 2, GridUnsafe.FLOAT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public double[] readDoubleArray() {
- return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
+ return readArray(DOUBLE_ARR_CREATOR, 3, GridUnsafe.DOUBLE_ARR_OFF);
}
/** {@inheritDoc} */
@Override public char[] readCharArray() {
- return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
+ return readArray(CHAR_ARR_CREATOR, 1, GridUnsafe.CHAR_ARR_OFF);
}
/** {@inheritDoc} */
@Override public boolean[] readBooleanArray() {
- return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF);
+ return readArray(BOOLEAN_ARR_CREATOR, 0, GridUnsafe.BOOLEAN_ARR_OFF);
}
/** {@inheritDoc} */
@@ -1037,7 +1009,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
int remaining = buf.remaining();
if (toWrite <= remaining) {
- UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
+ GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
pos += toWrite;
@@ -1048,7 +1020,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
return true;
}
else {
- UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
+ GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
pos += remaining;
@@ -1103,7 +1075,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
lastFinished = toRead <= remaining;
if (lastFinished) {
- UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
+ GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
buf.position(pos + toRead);
@@ -1116,7 +1088,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
return arr;
}
else {
- UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
+ GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
buf.position(pos + remaining);
@@ -1360,7 +1332,7 @@ public class DirectByteBufferStreamImplV1 implements DirectByteBufferStream {
/**
* Array creator.
*/
- private static interface ArrayCreator<T> {
+ private interface ArrayCreator<T> {
/**
* @param len Array length or {@code -1} if array was not fully read.
* @return New array.
[45/50] [abbrv] ignite git commit: IGNITE-1563 .NET: Implemented
"atomics": AtomicReference and AtomicSequence. This closes #455.
Posted by vo...@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);
[09/50] [abbrv] ignite git commit: fixed npe -
https://issues.apache.org/jira/browse/IGNITE-2532
Posted by vo...@apache.org.
fixed npe - https://issues.apache.org/jira/browse/IGNITE-2532
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4035d40f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4035d40f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4035d40f
Branch: refs/heads/ignite-1786
Commit: 4035d40f18fa2d829eaa17c0496eeecfad81fee1
Parents: ee20f1d
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Feb 2 16:42:35 2016 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Feb 2 16:42:35 2016 +0300
----------------------------------------------------------------------
.../multicast/TcpDiscoveryMulticastIpFinder.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4035d40f/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 8402cbf..75b5f91 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -116,7 +116,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
private String locAddr;
/** Time to live. */
- private Integer ttl;
+ private int ttl = -1;
/** */
@GridToStringExclude
@@ -267,6 +267,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
* <p>
* If TTL is {@code 0}, packets are not transmitted on the network,
* but may be delivered locally.
+ * <p>
+ * Default value is {@code -1} which corresponds to system default value.
*
* @param ttl Time to live.
*/
@@ -307,7 +309,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
throw new IgniteSpiException("Invalid number of address request attempts, " +
"value greater than zero is expected: " + addrReqAttempts);
- if (ttl != null && (ttl < 0 || ttl > 255))
+ if (ttl != -1 && (ttl < 0 || ttl > 255))
throw new IgniteSpiException("Time-to-live value is out of 0 <= TTL <= 255 range: " + ttl);
if (F.isEmpty(getRegisteredAddresses()))
@@ -545,7 +547,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
sock.setSoTimeout(resWaitTime);
- if (ttl != null)
+ if (ttl != -1)
sock.setTimeToLive(ttl);
reqPckt.setData(MSG_ADDR_REQ_DATA);
@@ -817,7 +819,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
sock.joinGroup(mcastGrp);
- if (ttl != null)
+ if (ttl != -1)
sock.setTimeToLive(ttl);
return sock;
@@ -908,4 +910,4 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
}
}
}
-}
\ No newline at end of file
+}
[25/50] [abbrv] ignite git commit: Fixed broken osgi-related Kafka
tests.
Posted by vo...@apache.org.
Fixed broken osgi-related Kafka tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/532b3735
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/532b3735
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/532b3735
Branch: refs/heads/ignite-1786
Commit: 532b37358de4f5c4143b6692178dca23e37f1fda
Parents: e2be94e
Author: shtykh_roman <rs...@yahoo.com>
Authored: Fri Feb 5 12:32:06 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Fri Feb 5 12:32:06 2016 +0900
----------------------------------------------------------------------
modules/osgi-karaf/src/main/resources/features.xml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/532b3735/modules/osgi-karaf/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/modules/osgi-karaf/src/main/resources/features.xml b/modules/osgi-karaf/src/main/resources/features.xml
index 983aeed..584429d 100644
--- a/modules/osgi-karaf/src/main/resources/features.xml
+++ b/modules/osgi-karaf/src/main/resources/features.xml
@@ -154,16 +154,15 @@
<feature name="ignite-kafka" version="${project.version}" description="Apache Ignite :: Kafka">
<details>
- <![CDATA[The Apache Ignite Kafka module + dependencies. This module installs the Scala 2.10 library bundle.]]>
+ <![CDATA[The Apache Ignite Kafka module + dependencies. This module installs the Scala 2.1 library bundle.]]>
</details>
<feature prerequisite="true">wrap</feature>
- <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala210.library.version}</bundle>
- <bundle start="true" dependency="true">mvn:org.apache.zookeeper/zookeeper/${zookeeper.version}</bundle>
- <bundle start="true" dependency="true">wrap:mvn:com.101tec/zkclient/${zkclient.version}$Bundle-SymbolicName=zkclient&Bundle-Version=${zkclient.version}&Export-Package=*;-noimport:=true;version=${zkclient.version}</bundle>
+ <bundle start="true" dependency="true">mvn:org.scala-lang/scala-library/${scala211.library.version}</bundle>
<bundle start="true" dependency="true">wrap:mvn:com.yammer.metrics/metrics-core/${yammer.metrics.core.version}$Bundle-SymbolicName=yammer-metrics-core&Bundle-Version=2.2.0&Export-Package=*;-noimport:=true;version=${yammer.metrics.core.version}</bundle>
<bundle start="true" dependency="true">wrap:mvn:com.yammer.metrics/metrics-annotation/${yammer.metrics.annotation.version}$Bundle-SymbolicName=yammer-metrics-annotation&Bundle-Version=2.2.0&Export-Package=*;-noimport:=true;version=${yammer.metrics.annotation.version}</bundle>
- <bundle start="true" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka-clients/${kafka.clients.bundle.version}</bundle>
- <bundle start="true" dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka_2.10/${kafka.bundle.version}</bundle>
+ <bundle start="true" dependency="true">wrap:mvn:org.apache.kafka/connect-api/${kafka.version}$Bundle-SymbolicName=connect-api&Bundle-Version=${kafka.version}</bundle>
+ <bundle start="true" dependency="true">wrap:mvn:org.apache.kafka/kafka_2.11/${kafka.version}$Bundle-SymbolicName=kafka_2.11&Bundle-Version=${kafka.version}</bundle>
+ <bundle start="true" dependency="true">wrap:mvn:org.apache.kafka/kafka-clients/${kafka.version}$Bundle-SymbolicName=kafka-clients&Bundle-Version=${kafka.version}</bundle>
<bundle start="true">mvn:org.apache.ignite/ignite-kafka/${project.version}</bundle>
</feature>
@@ -317,6 +316,7 @@
<details>
<![CDATA[The Apache Ignite ZooKeeper module + dependencies.]]>
</details>
+ <bundle start="true" dependency="true">mvn:org.apache.zookeeper/zookeeper/${zookeeper.version}</bundle>
<bundle start="true" dependency="true">mvn:com.google.guava/guava/${guava16.version}</bundle>
<bundle start="true" dependency="true">mvn:org.codehaus.jackson/jackson-core-asl/${jackson.version}</bundle>
<bundle start="true" dependency="true">mvn:org.codehaus.jackson/jackson-mapper-asl/${jackson.version}</bundle>
[43/50] [abbrv] ignite git commit: Renamed the method.
Posted by vo...@apache.org.
Renamed the method.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fa246cd2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fa246cd2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fa246cd2
Branch: refs/heads/ignite-1786
Commit: fa246cd2fa8bbf389677f256612124d4a1482afa
Parents: 26719d3
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Mon Feb 8 17:55:35 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Feb 8 17:55:35 2016 +0300
----------------------------------------------------------------------
.../main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fa246cd2/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
index 62420f7..42d6b5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.java
@@ -59,7 +59,7 @@ public class BinaryBasicNameMapper implements BinaryNameMapper {
*
* @param isSimpleName Whether to use simple name of class or not.
*/
- public void setLowerCase(boolean isSimpleName) {
+ public void setSimpleName(boolean isSimpleName) {
this.isSimpleName = isSimpleName;
}
[30/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/cc5067bc
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/cc5067bc
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/cc5067bc
Branch: refs/heads/ignite-1786
Commit: cc5067bc5a14a711f6c197c7d48069bf445893b7
Parents: 3602d46 88b0eeb
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Feb 5 13:02:36 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Feb 5 13:02:36 2016 +0300
----------------------------------------------------------------------
.../jmh/cache/JmhCacheAbstractBenchmark.java | 3 +
.../benchmarks/jmh/cache/JmhCacheBenchmark.java | 145 +++++++++++++++++++
.../jmh/cache/JmhCachePutBenchmark.java | 124 ----------------
.../jmh/runner/JmhIdeBenchmarkRunner.java | 20 ++-
.../affinity/GridAffinityAssignment.java | 36 ++++-
.../affinity/GridAffinityAssignmentCache.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 10 +-
.../cache/GridCacheAffinityManager.java | 30 +++-
.../dht/GridDhtPartitionTopologyImpl.java | 9 +-
.../osgi-karaf/src/main/resources/features.xml | 12 +-
10 files changed, 238 insertions(+), 153 deletions(-)
----------------------------------------------------------------------
[26/50] [abbrv] ignite git commit: Renamed args array.
Posted by vo...@apache.org.
Renamed args array.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a30f84aa
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a30f84aa
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a30f84aa
Branch: refs/heads/ignite-1786
Commit: a30f84aaece33e81ab420a6466a516ebf220366a
Parents: 532b373
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Feb 5 11:21:56 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Feb 5 11:21:56 2016 +0300
----------------------------------------------------------------------
.../internal/processors/cache/GridCacheAdapter.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/a30f84aa/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 2c3a197..9f54ddb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -5545,7 +5545,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
private final IgniteBiPredicate<K, V> p;
/** */
- private final Object[] args;
+ private final Object[] loadArgs;
/** */
private final ExpiryPolicy plc;
@@ -5554,15 +5554,15 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param cacheName Cache name.
* @param topVer Affinity topology version.
* @param p Predicate.
- * @param args Arguments.
+ * @param loadArgs Arguments.
* @param plc Policy.
*/
- private LoadCacheJob(String cacheName, AffinityTopologyVersion topVer, IgniteBiPredicate<K, V> p, Object[] args,
+ private LoadCacheJob(String cacheName, AffinityTopologyVersion topVer, IgniteBiPredicate<K, V> p, Object[] loadArgs,
ExpiryPolicy plc) {
super(cacheName, topVer);
this.p = p;
- this.args = args;
+ this.loadArgs = loadArgs;
this.plc = plc;
}
@@ -5574,7 +5574,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (plc != null)
cache = cache.withExpiryPolicy(plc);
- cache.localLoadCache(p, args);
+ cache.localLoadCache(p, loadArgs);
return null;
}
[31/50] [abbrv] ignite git commit: IGNITE-2324: .NET: Minor fixes as
per static code analysis. This closes #436.
Posted by vo...@apache.org.
IGNITE-2324: .NET: Minor fixes as per static code analysis. This closes #436.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/42109899
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/42109899
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/42109899
Branch: refs/heads/ignite-1786
Commit: 42109899a26989aa0d2affff27d327973ea489b2
Parents: cc5067b
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Fri Feb 5 17:02:31 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 5 17:02:31 2016 +0300
----------------------------------------------------------------------
.../Cache/CachePartialUpdateException.cs | 1 -
.../Cache/Store/CacheStoreAdapter.cs | 1 -
.../Compute/ComputeTaskAdapter.cs | 1 -
.../Compute/ComputeTaskSplitAdapter.cs | 1 -
.../Apache.Ignite.Core/Events/EventBase.cs | 1 -
.../Apache.Ignite.Core/Impl/Common/Future.cs | 14 +-
.../Impl/Common/FutureType.cs | 18 +-
.../Closure/ComputeAbstractClosureTask.cs | 1 -
.../Apache.Ignite.Core/Impl/Handle/Handle.cs | 8 +-
.../Impl/Memory/PlatformMemoryStream.cs | 320 +++++++++++++++----
10 files changed, 291 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
index b80913f..907af14 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/CachePartialUpdateException.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Cache
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.Serialization;
- using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Exception thrown from non-transactional cache in case when update succeeded only partially.
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
index 3f3b558..a38678d 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Store/CacheStoreAdapter.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Cache.Store
using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
- using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Cache storage convenience adapter. It provides default implementation for
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
index f2d2e14..79f32a6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskAdapter.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Compute
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
- using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Convenience adapter for <see cref="IComputeTask{TArg,TJobRes,TTaskRes}"/> interface
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
index bc152b5..f6a2f07 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Compute/ComputeTaskSplitAdapter.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Compute
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl;
- using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Compute;
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
index 962d577..ed60332 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Events/EventBase.cs
@@ -25,7 +25,6 @@ namespace Apache.Ignite.Core.Events
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary;
- using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Base event implementation.
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
index 7e6f418..746577a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/Future.cs
@@ -89,7 +89,10 @@ namespace Apache.Ignite.Core.Impl.Common
return Task;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Set result from stream.
+ /// </summary>
+ /// <param name="stream">Stream.</param>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public void OnResult(IBinaryStream stream)
{
@@ -103,7 +106,10 @@ namespace Apache.Ignite.Core.Impl.Common
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Set error result.
+ /// </summary>
+ /// <param name="err">Exception.</param>
public void OnError(Exception err)
{
if (err is IgniteFutureCancelledException)
@@ -112,7 +118,9 @@ namespace Apache.Ignite.Core.Impl.Common
_taskCompletionSource.TrySetException(err);
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Set null result.
+ /// </summary>
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public void OnNullResult()
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
index c9f1555..c1649c9 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Common/FutureType.cs
@@ -25,31 +25,31 @@ namespace Apache.Ignite.Core.Impl.Common
[SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue", Justification = "Interoperability")]
public enum FutureType
{
- /** Future type: byte. */
+ /// <summary> Future type: byte. </summary>
Byte = 1,
- /** Future type: boolean. */
+ /// <summary> Future type: boolean. </summary>
Bool = 2,
- /** Future type: short. */
+ /// <summary> Future type: short. </summary>
Short = 3,
- /** Future type: char. */
+ /// <summary> Future type: char. </summary>
Char = 4,
- /** Future type: int. */
+ /// <summary> Future type: int. </summary>
Int = 5,
- /** Future type: float. */
+ /// <summary> Future type: float. </summary>
Float = 6,
- /** Future type: long. */
+ /// <summary> Future type: long. </summary>
Long = 7,
- /** Future type: double. */
+ /// <summary> Future type: double. </summary>
Double = 8,
- /** Future type: object. */
+ /// <summary> Future type: object. </summary>
Object = 9
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
index 220dbf8..c967c7b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Compute/Closure/ComputeAbstractClosureTask.cs
@@ -22,7 +22,6 @@ namespace Apache.Ignite.Core.Impl.Compute.Closure
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
- using Apache.Ignite.Core.Impl.Common;
/// <summary>
/// Base class for all tasks working with closures.
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
index 0168963..fb56891 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Handle/Handle.cs
@@ -53,14 +53,18 @@ namespace Apache.Ignite.Core.Impl.Handle
get { return _target; }
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Release the resource.
+ /// </summary>
public void Release()
{
if (Interlocked.CompareExchange(ref _released, 1, 0) == 0)
_releaseAction(_target);
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Resource released flag.
+ /// </summary>
public bool Released
{
get { return Thread.VolatileRead(ref _released) == 1; }
http://git-wip-us.apache.org/repos/asf/ignite/blob/42109899/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
index ba0da19..5ad033e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformMemoryStream.cs
@@ -83,7 +83,10 @@ namespace Apache.Ignite.Core.Impl.Memory
#region WRITE
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write byte.
+ /// </summary>
+ /// <param name="val">Byte value.</param>
public void WriteByte(byte val)
{
int curPos = EnsureWriteCapacityAndShift(Len1);
@@ -91,7 +94,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*(_data + curPos) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write byte array.
+ /// </summary>
+ /// <param name="val">Byte array.</param>
public void WriteByteArray(byte[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -102,13 +108,19 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write bool.
+ /// </summary>
+ /// <param name="val">Bool value.</param>
public void WriteBool(bool val)
{
WriteByte(val ? (byte)1 : (byte)0);
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Write bool array.
+ /// </summary>
+ /// <param name="val">Bool array.</param>
public void WriteBoolArray(bool[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -119,7 +131,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write short.
+ /// </summary>
+ /// <param name="val">Short value.</param>
public virtual void WriteShort(short val)
{
int curPos = EnsureWriteCapacityAndShift(Len2);
@@ -127,7 +142,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((short*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write short array.
+ /// </summary>
+ /// <param name="val">Short array.</param>
public virtual void WriteShortArray(short[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -138,7 +156,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write char.
+ /// </summary>
+ /// <param name="val">Char value.</param>
public virtual void WriteChar(char val)
{
int curPos = EnsureWriteCapacityAndShift(Len2);
@@ -146,7 +167,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((char*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write char array.
+ /// </summary>
+ /// <param name="val">Char array.</param>
public virtual void WriteCharArray(char[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -157,7 +181,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write int.
+ /// </summary>
+ /// <param name="val">Int value.</param>
public virtual void WriteInt(int val)
{
int curPos = EnsureWriteCapacityAndShift(Len4);
@@ -165,7 +192,11 @@ namespace Apache.Ignite.Core.Impl.Memory
*((int*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write int to specific position.
+ /// </summary>
+ /// <param name="writePos">Position.</param>
+ /// <param name="val">Value.</param>
[SuppressMessage("Microsoft.Usage", "CA2233:OperationsShouldNotOverflow", MessageId = "writePos+4")]
public virtual void WriteInt(int writePos, int val)
{
@@ -174,7 +205,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((int*)(_data + writePos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write int array.
+ /// </summary>
+ /// <param name="val">Int array.</param>
public virtual void WriteIntArray(int[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -185,7 +219,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write long.
+ /// </summary>
+ /// <param name="val">Long value.</param>
public virtual void WriteLong(long val)
{
int curPos = EnsureWriteCapacityAndShift(Len8);
@@ -193,7 +230,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((long*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write long array.
+ /// </summary>
+ /// <param name="val">Long array.</param>
public virtual void WriteLongArray(long[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -204,7 +244,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write float.
+ /// </summary>
+ /// <param name="val">Float value.</param>
public virtual void WriteFloat(float val)
{
int curPos = EnsureWriteCapacityAndShift(Len4);
@@ -212,7 +255,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((float*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write float array.
+ /// </summary>
+ /// <param name="val">Float array.</param>
public virtual void WriteFloatArray(float[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -223,7 +269,10 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write double.
+ /// </summary>
+ /// <param name="val">Double value.</param>
public virtual void WriteDouble(double val)
{
int curPos = EnsureWriteCapacityAndShift(Len8);
@@ -231,7 +280,10 @@ namespace Apache.Ignite.Core.Impl.Memory
*((double*)(_data + curPos)) = val;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write double array.
+ /// </summary>
+ /// <param name="val">Double array.</param>
public virtual void WriteDoubleArray(double[] val)
{
IgniteArgumentCheck.NotNull(val, "val");
@@ -242,7 +294,16 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write string.
+ /// </summary>
+ /// <param name="chars">Characters.</param>
+ /// <param name="charCnt">Char count.</param>
+ /// <param name="byteCnt">Byte count.</param>
+ /// <param name="encoding">Encoding.</param>
+ /// <returns>
+ /// Amounts of bytes written.
+ /// </returns>
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods")]
public int WriteString(char* chars, int charCnt, int byteCnt, Encoding encoding)
{
@@ -254,7 +315,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return encoding.GetBytes(chars, charCnt, _data + curPos, byteCnt);
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write arbitrary data.
+ /// </summary>
+ /// <param name="src">Source array.</param>
+ /// <param name="off">Offset</param>
+ /// <param name="cnt">Count.</param>
public void Write(byte[] src, int off, int cnt)
{
IgniteArgumentCheck.NotNull(src, "src");
@@ -265,25 +331,40 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Write arbitrary data.
+ /// </summary>
+ /// <param name="src">Source.</param>
+ /// <param name="cnt">Count.</param>
public void Write(byte* src, int cnt)
{
CopyFromAndShift(src, cnt);
}
-
+
#endregion WRITE
-
+
#region READ
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read byte.
+ /// </summary>
+ /// <returns>
+ /// Byte value.
+ /// </returns>
public byte ReadByte()
{
int curPos = EnsureReadCapacityAndShift(Len1);
return *(_data + curPos);
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Read byte array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Byte array.
+ /// </returns>
public byte[] ReadByteArray(int cnt)
{
int curPos = EnsureReadCapacityAndShift(cnt);
@@ -297,14 +378,25 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Read bool.
+ /// </summary>
+ /// <returns>
+ /// Bool value.
+ /// </returns>
public bool ReadBool()
{
return ReadByte() == 1;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read bool array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Bool array.
+ /// </returns>
public bool[] ReadBoolArray(int cnt)
{
bool[] res = new bool[cnt];
@@ -317,7 +409,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read short.
+ /// </summary>
+ /// <returns>
+ /// Short value.
+ /// </returns>
public virtual short ReadShort()
{
int curPos = EnsureReadCapacityAndShift(Len2);
@@ -325,7 +422,13 @@ namespace Apache.Ignite.Core.Impl.Memory
return *((short*)(_data + curPos));
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read short array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Short array.
+ /// </returns>
public virtual short[] ReadShortArray(int cnt)
{
short[] res = new short[cnt];
@@ -338,7 +441,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read char.
+ /// </summary>
+ /// <returns>
+ /// Char value.
+ /// </returns>
public virtual char ReadChar()
{
int curPos = EnsureReadCapacityAndShift(Len2);
@@ -346,7 +454,13 @@ namespace Apache.Ignite.Core.Impl.Memory
return *((char*)(_data + curPos));
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read char array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Char array.
+ /// </returns>
public virtual char[] ReadCharArray(int cnt)
{
char[] res = new char[cnt];
@@ -359,15 +473,26 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read int.
+ /// </summary>
+ /// <returns>
+ /// Int value.
+ /// </returns>
public virtual int ReadInt()
{
int curPos = EnsureReadCapacityAndShift(Len4);
return *((int*)(_data + curPos));
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Read int array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Int array.
+ /// </returns>
public virtual int[] ReadIntArray(int cnt)
{
int[] res = new int[cnt];
@@ -380,15 +505,26 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read long.
+ /// </summary>
+ /// <returns>
+ /// Long value.
+ /// </returns>
public virtual long ReadLong()
{
int curPos = EnsureReadCapacityAndShift(Len8);
return *((long*)(_data + curPos));
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Read long array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Long array.
+ /// </returns>
public virtual long[] ReadLongArray(int cnt)
{
long[] res = new long[cnt];
@@ -401,7 +537,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read float.
+ /// </summary>
+ /// <returns>
+ /// Float value.
+ /// </returns>
public virtual float ReadFloat()
{
int curPos = EnsureReadCapacityAndShift(Len4);
@@ -409,7 +550,13 @@ namespace Apache.Ignite.Core.Impl.Memory
return *((float*)(_data + curPos));
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read float array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Float array.
+ /// </returns>
public virtual float[] ReadFloatArray(int cnt)
{
float[] res = new float[cnt];
@@ -422,7 +569,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read double.
+ /// </summary>
+ /// <returns>
+ /// Double value.
+ /// </returns>
public virtual double ReadDouble()
{
int curPos = EnsureReadCapacityAndShift(Len8);
@@ -430,7 +582,13 @@ namespace Apache.Ignite.Core.Impl.Memory
return *((double*)(_data + curPos));
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read double array.
+ /// </summary>
+ /// <param name="cnt">Count.</param>
+ /// <returns>
+ /// Double array.
+ /// </returns>
public virtual double[] ReadDoubleArray(int cnt)
{
double[] res = new double[cnt];
@@ -443,7 +601,12 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read arbitrary data.
+ /// </summary>
+ /// <param name="dest">Destination array.</param>
+ /// <param name="off">Offset.</param>
+ /// <param name="cnt">Count.</param>
public void Read(byte[] dest, int off, int cnt)
{
IgniteArgumentCheck.NotNull(dest, "dest");
@@ -454,7 +617,11 @@ namespace Apache.Ignite.Core.Impl.Memory
}
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Read arbitrary data.
+ /// </summary>
+ /// <param name="dest">Destination.</param>
+ /// <param name="cnt">Count.</param>
public void Read(byte* dest, int cnt)
{
CopyToAndShift(dest, cnt);
@@ -516,7 +683,19 @@ namespace Apache.Ignite.Core.Impl.Memory
_pos = 0;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Seek to the given positoin.
+ /// </summary>
+ /// <param name="offset">Offset.</param>
+ /// <param name="origin">Seek origin.</param>
+ /// <returns>
+ /// Position.
+ /// </returns>
+ /// <exception cref="System.ArgumentException">
+ /// Unsupported seek origin: + origin
+ /// or
+ /// Seek before origin: + newPos
+ /// </exception>
public int Seek(int offset, SeekOrigin origin)
{
int newPos;
@@ -651,26 +830,41 @@ namespace Apache.Ignite.Core.Impl.Memory
return newCap;
}
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Position.
+ /// </summary>
public int Position
{
get { return _pos; }
}
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Gets remaining bytes in the stream.
+ /// </summary>
+ /// <value>
+ /// Remaining bytes.
+ /// </value>
public int Remaining
{
get { return _len - _pos; }
}
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Finalizes an instance of the <see cref="PlatformMemoryStream"/> class.
+ /// </summary>
~PlatformMemoryStream()
{
Dispose(false);
@@ -698,14 +892,24 @@ namespace Apache.Ignite.Core.Impl.Memory
#endregion
#region ARRAYS
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Gets underlying array, avoiding copying if possible.
+ /// </summary>
+ /// <returns>
+ /// Underlying array.
+ /// </returns>
public byte[] GetArray()
{
return GetArrayCopy();
}
-
- /** <inheritdoc /> */
+
+ /// <summary>
+ /// Gets underlying data in a new array.
+ /// </summary>
+ /// <returns>
+ /// New array with data.
+ /// </returns>
public byte[] GetArrayCopy()
{
byte[] res = new byte[_mem.Length];
@@ -718,7 +922,13 @@ namespace Apache.Ignite.Core.Impl.Memory
return res;
}
- /** <inheritdoc /> */
+ /// <summary>
+ /// Check whether array passed as argument is the same as the stream hosts.
+ /// </summary>
+ /// <param name="arr">Array.</param>
+ /// <returns>
+ /// <c>True</c> if they are same.
+ /// </returns>
public bool IsSameArray(byte[] arr)
{
return false;
[32/50] [abbrv] ignite git commit: IGNITE-2329: Implemented a bunch
of optimizations: - Garbageless NIO Selector - Get rid of unnecessary
ArrayList allocations in GridCacheMvccManager. - Optimized "force keys"
futures logic.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
index 0a7845b..662cee3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteTxPreloadAbstractTest.java
@@ -231,4 +231,4 @@ public abstract class IgniteTxPreloadAbstractTest extends GridCacheAbstractSelfT
return cfg;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
index b4e1ae6..2247acf 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
@@ -33,6 +33,7 @@ import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -233,8 +234,20 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest {
List<KeyCacheObject> cacheKeys = F.asList(ctx.toCacheKeyObject(1), ctx.toCacheKeyObject(2));
- ((IgniteKernal)g1).internalCache(null).preloader().request(cacheKeys, new AffinityTopologyVersion(2)).get();
- ((IgniteKernal)g2).internalCache(null).preloader().request(cacheKeys, new AffinityTopologyVersion(2)).get();
+ IgniteInternalFuture<Object> f1 = ((IgniteKernal)g1).internalCache(null).preloader().request(
+ cacheKeys,
+ new AffinityTopologyVersion(2));
+
+ if (f1 != null)
+ f1.get();
+
+
+ IgniteInternalFuture<Object> f2 = ((IgniteKernal)g2).internalCache(null).preloader().request(
+ cacheKeys,
+ new AffinityTopologyVersion(2));
+
+ if (f2 != null)
+ f2.get();
IgniteCache<Integer, String> cache1 = g1.cache(null);
IgniteCache<Integer, String> cache2 = g2.cache(null);
@@ -602,4 +615,4 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest {
lock1.unlock();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java
index a21ed30..5865cad 100644
--- a/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/lang/GridTupleSelfTest.java
@@ -20,10 +20,12 @@ package org.apache.ignite.lang;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.NoSuchElementException;
import org.apache.ignite.internal.util.lang.GridTuple;
import org.apache.ignite.internal.util.lang.GridTuple3;
import org.apache.ignite.internal.util.lang.GridTupleV;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.testframework.junits.common.GridCommonTest;
@@ -102,6 +104,44 @@ public class GridTupleSelfTest extends GridCommonAbstractTest {
/**
* JUnit.
*/
+ public void testGridTuple2AsMap() {
+ String str1 = "A test string 1";
+ String str2 = "A test string 2";
+
+ IgniteBiTuple<String, String> tpl = new IgniteBiTuple<>();
+
+ tpl.put(str1, str2);
+
+ assertEquals(str2, tpl.get(str1));
+ assertEquals(1, tpl.size());
+
+ assert tpl.containsKey(str1);
+ assert tpl.containsValue(str2);
+
+ Iterator<Map.Entry<String, String>> it = tpl.entrySet().iterator();
+
+ assert it.hasNext();
+
+ Map.Entry<String, String> next = it.next();
+
+ assertEquals(str1, next.getKey());
+ assertEquals(str2, next.getValue());
+
+ assert !it.hasNext();
+
+ next = F.firstEntry(tpl);
+
+ assertEquals(str1, next.getKey());
+ assertEquals(str2, next.getValue());
+
+ tpl = new IgniteBiTuple<>();
+
+ assert !tpl.entrySet().iterator().hasNext();
+ }
+
+ /**
+ * JUnit.
+ */
public void testGridTuple3AsIterable() {
String str1 = "A test string 1";
String str2 = "A test string 2";
@@ -166,4 +206,4 @@ public class GridTupleSelfTest extends GridCommonAbstractTest {
info("Caught expected exception: " + e);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 53eefdd..437a30b 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -780,6 +780,7 @@
<exclude>**/NOTICE*</exclude>
<exclude>**/LICENSE*</exclude>
<exclude>src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffHeapSnapTreeMap.java</exclude><!--BSD license-->
+ <exclude>src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java</exclude><!-- Apache 2.0 license -->
<exclude>src/main/java/org/apache/ignite/internal/util/snaptree/*.java</exclude><!--BSD license-->
<exclude>src/main/java/org/jsr166/*.java</exclude>
<exclude>src/test/java/org/apache/ignite/p2p/p2p.properties</exclude><!--test depends on file content-->
[04/50] [abbrv] ignite git commit: 1523
Posted by vo...@apache.org.
1523
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28a5247d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28a5247d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28a5247d
Branch: refs/heads/ignite-1786
Commit: 28a5247d37ba65bdcb6119f97023f32d511b5f1e
Parents: 0113506
Author: Anton Vinogradov <av...@apache.org>
Authored: Tue Feb 2 15:37:12 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Tue Feb 2 15:37:12 2016 +0300
----------------------------------------------------------------------
.../internal/binary/BinaryEnumObjectImpl.java | 2 +-
.../processors/cache/GridCacheProcessor.java | 2 +-
.../ignite/internal/util/IgniteUtils.java | 7 ++
.../ignite/spi/discovery/tcp/ClientImpl.java | 6 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 11 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 1 -
.../TcpDiscoveryCustomEventMessage.java | 10 +-
.../GridCacheReplicatedPreloadSelfTest.java | 108 ++++++++++++++++++
.../tests/p2p/CacheDeploymentTestEnumValue.java | 47 ++++++++
.../p2p/CacheDeploymentTestStoreFactory.java | 113 +++++++++++++++++++
10 files changed, 297 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
index fd4a4d8..ab76b6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryEnumObjectImpl.java
@@ -110,7 +110,7 @@ public class BinaryEnumObjectImpl implements BinaryObjectEx, Externalizable, Cac
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public <T> T deserialize() throws BinaryObjectException {
- Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, null, true);
+ Class cls = BinaryUtils.resolveClass(ctx, typeId, clsName, ctx.configuration().getClassLoader(), true);
return BinaryEnumCache.get(cls, ord);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 13048ec..26d3d4f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -3421,7 +3421,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
try {
- return marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
+ return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config().getClassLoader()));
}
catch (IgniteCheckedException e) {
throw new IgniteCheckedException("Failed to validate cache configuration " +
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
index 0bf937d..6c0b8e6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java
@@ -2193,6 +2193,13 @@ public abstract class IgniteUtils {
}
/**
+ * @return Class loader passed as an argument or classloader used to load Ignite itself in case argument is null.
+ */
+ public static ClassLoader resolveClassLoader(ClassLoader ldr) {
+ return ldr != null ? ldr : gridClassLoader;
+ }
+
+ /**
* @param parent Parent to find.
* @param ldr Loader to check.
* @return {@code True} if parent found.
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 850cc24..b12f7a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -1665,7 +1665,8 @@ class ClientImpl extends TcpDiscoveryImpl {
if (dataMap != null) {
for (Map.Entry<UUID, Map<Integer, byte[]>> entry : dataMap.entrySet())
- spi.onExchange(getLocalNodeId(), entry.getKey(), entry.getValue(), null);
+ spi.onExchange(getLocalNodeId(), entry.getKey(), entry.getValue(),
+ U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
}
locNode.setAttributes(msg.clientNodeAttributes());
@@ -1961,7 +1962,8 @@ class ClientImpl extends TcpDiscoveryImpl {
if (node != null && node.visible()) {
try {
- DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh);
+ DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
+ spi.ignite().configuration().getClassLoader());
notifyDiscovery(EVT_DISCOVERY_CUSTOM_EVT, topVer, node, allVisibleNodes(), msgObj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c69a611..0106b0a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -3600,7 +3600,8 @@ class ServerImpl extends TcpDiscoveryImpl {
Map<Integer, byte[]> data = msg.newNodeDiscoveryData();
if (data != null)
- spi.onExchange(node.id(), node.id(), data, U.gridClassLoader());
+ spi.onExchange(node.id(), node.id(), data,
+ U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
msg.addDiscoveryData(locNodeId, spi.collectExchangeData(node.id()));
@@ -3679,7 +3680,8 @@ class ServerImpl extends TcpDiscoveryImpl {
// Notify outside of synchronized block.
if (dataMap != null) {
for (Map.Entry<UUID, Map<Integer, byte[]>> entry : dataMap.entrySet())
- spi.onExchange(node.id(), entry.getKey(), entry.getValue(), U.gridClassLoader());
+ spi.onExchange(node.id(), entry.getKey(), entry.getValue(),
+ U.resolveClassLoader(spi.ignite().configuration().getClassLoader()));
}
processMessageFailedNodes(msg);
@@ -4604,7 +4606,7 @@ class ServerImpl extends TcpDiscoveryImpl {
DiscoverySpiCustomMessage msgObj = null;
try {
- msgObj = msg.message(spi.marsh);
+ msgObj = msg.message(spi.marsh, spi.ignite().configuration().getClassLoader());
}
catch (Throwable e) {
U.error(log, "Failed to unmarshal discovery custom message.", e);
@@ -4727,7 +4729,8 @@ class ServerImpl extends TcpDiscoveryImpl {
if (node != null) {
try {
- DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh);
+ DiscoverySpiCustomMessage msgObj = msg.message(spi.marsh,
+ spi.ignite().configuration().getClassLoader());
lsnr.onDiscovery(DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT,
msg.topologyVersion(),
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index f9273c3..0d41cd2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1700,7 +1700,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
* @param joiningNodeID Joining node ID.
* @param nodeId Remote node ID for which data is provided.
* @param data Collection of marshalled discovery data objects from different components.
- * @param clsLdr Class loader for discovery data unmarshalling.
*/
protected void onExchange(UUID joiningNodeID,
UUID nodeId,
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
index 8f14459..e10de46 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryCustomEventMessage.java
@@ -74,8 +74,16 @@ public class TcpDiscoveryCustomEventMessage extends TcpDiscoveryAbstractMessage
* @throws java.lang.Throwable if unmarshal failed.
*/
@Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh) throws Throwable {
+ return message(marsh, null);
+ }
+
+ /**
+ * @return Deserialized message,
+ * @throws java.lang.Throwable if unmarshal failed.
+ */
+ @Nullable public DiscoverySpiCustomMessage message(@NotNull Marshaller marsh, ClassLoader ldr) throws Throwable {
if (msg == null) {
- msg = marsh.unmarshal(msgBytes, U.gridClassLoader());
+ msg = marsh.unmarshal(msgBytes, U.resolveClassLoader(ldr));
assert msg != null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index 5649b34..523f641 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
+import javax.cache.configuration.Factory;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CachePeekMode;
@@ -70,6 +71,12 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
private int poolSize = 2;
/** */
+ private volatile boolean needStore = false;
+
+ /** */
+ private volatile boolean isClient = false;
+
+ /** */
private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
/** {@inheritDoc} */
@@ -104,6 +111,9 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
if (getTestGridName(1).equals(gridName) || cfg.getMarshaller() instanceof BinaryMarshaller)
cfg.setClassLoader(getExternalClassLoader());
+ if (isClient)
+ cfg.setClientMode(true);
+
return cfg;
}
@@ -122,6 +132,20 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
cacheCfg.setRebalanceBatchSize(batchSize);
cacheCfg.setRebalanceThreadPoolSize(poolSize);
+ if (needStore) {
+ Object sf = null;
+
+ try {
+ sf = getExternalClassLoader().
+ loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ cacheCfg.setCacheStoreFactory((Factory)sf);
+ }
+
return cacheCfg;
}
@@ -233,6 +257,18 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
assert v2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
+ Object e1 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestEnumValue").getEnumConstants()[0];
+
+ cache1.put(2, e1);
+
+ Object e2 = cache2.get(2);
+
+ assert e2 != null;
+ assert e2.toString().equals(e1.toString());
+ assert !e2.getClass().getClassLoader().equals(getClass().getClassLoader());
+ assert e2.getClass().getClassLoader().getClass().getName().contains("GridDeploymentClassLoader") ||
+ grid(2).configuration().getMarshaller() instanceof BinaryMarshaller;
+
stopGrid(1);
Ignite g3 = startGrid(3);
@@ -259,6 +295,78 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If test failed.
*/
+ public void testStore() throws Exception {
+ try {
+ Ignite g1 = startGrid(1);
+
+ if (g1.configuration().getMarshaller() instanceof BinaryMarshaller) {
+ stopAllGrids();
+
+ needStore = true;
+
+ g1 = startGrid(1);
+
+ ClassLoader ldr = grid(1).configuration().getClassLoader();
+
+ CacheConfiguration cfg = defaultCacheConfiguration();
+
+ Ignite g2 = startGrid(2); // Checks deserialization at node join.
+
+ isClient = true;
+
+ Ignite g3 = startGrid(3);
+
+ isClient = false;
+
+ IgniteCache<Integer, Object> cache1 = g1.cache(null);
+ IgniteCache<Integer, Object> cache2 = g2.cache(null);
+ IgniteCache<Integer, Object> cache3 = g3.cache(null);
+
+ cache1.put(1, 1);
+
+ assertEquals(1, cache2.get(1));
+ assertEquals(1, cache3.get(1));
+
+ needStore = false;
+
+ stopAllGrids();
+
+ g1 = startGrid(1);
+ g2 = startGrid(2);
+
+ isClient = true;
+
+ g3 = startGrid(3);
+
+ isClient = false;
+
+ Object sf = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestStoreFactory").newInstance();
+
+ cfg.setCacheStoreFactory((Factory)sf);
+ cfg.setName("customStore");
+
+ cache1 = g1.createCache(cfg);
+
+ cache2 = g2.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+ cache3 = g3.getOrCreateCache(cfg); // Checks deserialization at cache creation.
+
+ cache1.put(1, 1);
+
+ assertEquals(1, cache2.get(1));
+ assertEquals(1, cache3.get(1));
+ }
+ }
+ finally {
+ needStore = false;
+ isClient = false;
+
+ stopAllGrids();
+ }
+ }
+
+ /**
+ * @throws Exception If test failed.
+ */
public void testSync() throws Exception {
preloadMode = SYNC;
batchSize = 512;
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
new file mode 100644
index 0000000..cc70e2d
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestEnumValue.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+/**
+ * Test enum for cache deployment tests.
+ */
+public enum CacheDeploymentTestEnumValue {
+ ONE("one"),
+ TWO("two"),
+ THREE("three");
+
+ /** */
+ private String value;
+
+ /** */
+ CacheDeploymentTestEnumValue(String value) {
+ this.value = value;
+ }
+
+ /** */
+ public String getValue() {
+ return value;
+ }
+
+ /** */
+ @Override public String toString() {
+ return "CacheDeploymentTestEnumValue{" +
+ "value='" + value + '\'' +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28a5247d/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
----------------------------------------------------------------------
diff --git a/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
new file mode 100644
index 0000000..1a0fc17
--- /dev/null
+++ b/modules/extdata/p2p/src/main/java/org/apache/ignite/tests/p2p/CacheDeploymentTestStoreFactory.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.tests.p2p;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import javax.cache.Cache;
+import javax.cache.configuration.Factory;
+import javax.cache.integration.CacheLoaderException;
+import javax.cache.integration.CacheWriterException;
+import org.apache.ignite.cache.store.CacheStore;
+import org.apache.ignite.internal.processors.cache.store.CacheLocalStore;
+import org.apache.ignite.lang.IgniteBiInClosure;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Test store factory for cache deployment tests.
+ */
+public class CacheDeploymentTestStoreFactory implements Factory<CacheStore<Integer, String>>, Serializable {
+ /** {@inheritDoc} */
+ @Override public CacheStore<Integer, String> create() {
+ return new TestLocalStore();
+ }
+
+ /**
+ *
+ */
+ @CacheLocalStore
+ public static class TestLocalStore<K, V> implements CacheStore<K, IgniteBiTuple<V, ?>>, Serializable {
+ /** */
+ private Map<K, IgniteBiTuple<V, ?>> map = new ConcurrentHashMap<>();
+
+ /** {@inheritDoc} */
+ @Override public void loadCache(IgniteBiInClosure<K, IgniteBiTuple<V, ?>> clo, @Nullable Object... args)
+ throws CacheLoaderException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void sessionEnd(boolean commit) throws CacheWriterException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteBiTuple<V, ?> load(K key) throws CacheLoaderException {
+ return map.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map<K, IgniteBiTuple<V, ?>> loadAll(Iterable<? extends K> keys) throws CacheLoaderException {
+ Map<K, IgniteBiTuple<V, ?>> res = new HashMap<>();
+
+ for (K key : keys) {
+ IgniteBiTuple<V, ?> val = map.get(key);
+
+ if (val != null)
+ res.put(key, val);
+ }
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void write(Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>> entry)
+ throws CacheWriterException {
+ map.put(entry.getKey(), entry.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeAll(Collection<Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>>> entries)
+ throws CacheWriterException {
+ for (Cache.Entry<? extends K, ? extends IgniteBiTuple<V, ?>> e : entries)
+ map.put(e.getKey(), e.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void delete(Object key) throws CacheWriterException {
+ map.remove(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void deleteAll(Collection<?> keys) throws CacheWriterException {
+ for (Object key : keys)
+ map.remove(key);
+ }
+
+ /**
+ * Clear store.
+ */
+ public void clear() {
+ map.clear();
+ }
+ }
+}
\ No newline at end of file
[47/50] [abbrv] ignite git commit: IGNITE-2380: Added ability to
start Ignite using configuration from app.config. This closes #417.
Posted by vo...@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
[44/50] [abbrv] ignite git commit: IGNITE-2509 - Fixed evictions for
OFFHEAP_VALUES memory mode - Fixes #452.
Posted by vo...@apache.org.
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-1786
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);
[42/50] [abbrv] ignite git commit: IGNITE-2264: Minor refactoring to
GridDistributedTxMapping mapping handling.
Posted by vo...@apache.org.
IGNITE-2264: Minor refactoring to GridDistributedTxMapping mapping handling.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/26719d3c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/26719d3c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/26719d3c
Branch: refs/heads/ignite-1786
Commit: 26719d3c1221177616a4f291b73950f69e5ed833
Parents: cbaa6e0
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Feb 8 15:49:38 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Feb 8 15:49:38 2016 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtTxPrepareFuture.java | 33 +++++-----
...arOptimisticSerializableTxPrepareFuture.java | 4 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 2 +-
.../GridNearPessimisticTxPrepareFuture.java | 2 +-
.../cache/distributed/near/GridNearTxLocal.java | 66 +++++++++++---------
5 files changed, 56 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/26719d3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 4c783f7..732c298 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -1202,8 +1202,6 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
for (GridDistributedTxMapping nearMapping : tx.nearMap().values()) {
if (!tx.dhtMap().containsKey(nearMapping.node().id())) {
- assert nearMapping.writes() != null;
-
MiniFuture fut = new MiniFuture(nearMapping.node().id(), null, nearMapping);
add(fut); // Append new future.
@@ -1223,24 +1221,25 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
tx.taskNameHash(),
tx.activeCachesDeploymentEnabled());
- for (IgniteTxEntry entry : nearMapping.writes()) {
- try {
- if (entry.explicitVersion() == null) {
- GridCacheMvccCandidate added = entry.cached().candidate(version());
+ for (IgniteTxEntry entry : nearMapping.entries()) {
+ if (CU.writes().apply(entry)) {
+ try {
+ if (entry.explicitVersion() == null) {
+ GridCacheMvccCandidate added = entry.cached().candidate(version());
- assert added != null : "Null candidate for non-group-lock entry " +
- "[added=" + added + ", entry=" + entry + ']';
- assert added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
- "[added=" + added + ", entry=" + entry + ']';
+ assert added != null : "Null candidate for non-group-lock entry " +
+ "[added=" + added + ", entry=" + entry + ']';
+ assert added.dhtLocal() : "Got non-dht-local candidate for prepare future" +
+ "[added=" + added + ", entry=" + entry + ']';
- if (added != null && added.ownerVersion() != null)
- req.owned(entry.txKey(), added.ownerVersion());
- }
+ if (added != null && added.ownerVersion() != null)
+ req.owned(entry.txKey(), added.ownerVersion());
+ }
- break;
- }
- catch (GridCacheEntryRemovedException ignore) {
- assert false : "Got removed exception on entry with dht local candidate: " + entry;
+ break;
+ } catch (GridCacheEntryRemovedException ignore) {
+ assert false : "Got removed exception on entry with dht local candidate: " + entry;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/26719d3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 52ebfc8..d5483cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -443,7 +443,7 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
m.clientFirst(),
tx.activeCachesDeploymentEnabled());
- for (IgniteTxEntry txEntry : m.writes()) {
+ for (IgniteTxEntry txEntry : m.entries()) {
if (txEntry.op() == TRANSFORM)
req.addDhtVersion(txEntry.txKey(), null);
}
@@ -451,7 +451,7 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
// Must lock near entries separately.
if (m.near()) {
try {
- tx.optimisticLockEntries(F.concat(false, m.writes(), m.reads()));
+ tx.optimisticLockEntries(m.entries());
tx.userPrepare();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/26719d3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index b968e57..8476dc3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -436,7 +436,7 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearOptimisticTxPrepa
m.clientFirst(),
tx.activeCachesDeploymentEnabled());
- for (IgniteTxEntry txEntry : m.writes()) {
+ for (IgniteTxEntry txEntry : m.entries()) {
if (txEntry.op() == TRANSFORM)
req.addDhtVersion(txEntry.txKey(), null);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/26719d3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index 615a92b..9adf580 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -230,7 +230,7 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
false,
tx.activeCachesDeploymentEnabled());
- for (IgniteTxEntry txEntry : m.writes()) {
+ for (IgniteTxEntry txEntry : m.entries()) {
if (txEntry.op() == TRANSFORM)
req.addDhtVersion(txEntry.txKey(), null);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/26719d3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index 0853b77..a70fb3a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -661,55 +661,61 @@ public class GridNearTxLocal extends GridDhtTxLocalAdapter {
Collection<GridCacheVersion> committedVers,
Collection<GridCacheVersion> rolledbackVers)
{
- readyNearLocks(mapping.writes(), mapping.dhtVersion(), pendingVers, committedVers, rolledbackVers);
- readyNearLocks(mapping.reads(), mapping.dhtVersion(), pendingVers, committedVers, rolledbackVers);
+ // Process writes, then reads.
+ for (IgniteTxEntry txEntry : mapping.entries()) {
+ if (CU.writes().apply(txEntry))
+ readyNearLock(txEntry, mapping.dhtVersion(), pendingVers, committedVers, rolledbackVers);
+ }
+
+ for (IgniteTxEntry txEntry : mapping.entries()) {
+ if (CU.reads().apply(txEntry))
+ readyNearLock(txEntry, mapping.dhtVersion(), pendingVers, committedVers, rolledbackVers);
+ }
}
/**
- * @param entries Entries.
+ * @param txEntry TX entry.
* @param dhtVer DHT version.
* @param pendingVers Pending versions.
* @param committedVers Committed versions.
* @param rolledbackVers Rolled back versions.
*/
- void readyNearLocks(Collection<IgniteTxEntry> entries,
+ void readyNearLock(IgniteTxEntry txEntry,
GridCacheVersion dhtVer,
Collection<GridCacheVersion> pendingVers,
Collection<GridCacheVersion> committedVers,
Collection<GridCacheVersion> rolledbackVers)
{
- for (IgniteTxEntry txEntry : entries) {
- while (true) {
- GridCacheContext cacheCtx = txEntry.cached().context();
+ while (true) {
+ GridCacheContext cacheCtx = txEntry.cached().context();
- assert cacheCtx.isNear();
+ assert cacheCtx.isNear();
- GridDistributedCacheEntry entry = (GridDistributedCacheEntry)txEntry.cached();
+ GridDistributedCacheEntry entry = (GridDistributedCacheEntry)txEntry.cached();
- try {
- // Handle explicit locks.
- GridCacheVersion explicit = txEntry.explicitVersion();
-
- if (explicit == null) {
- entry.readyNearLock(xidVer,
- dhtVer,
- committedVers,
- rolledbackVers,
- pendingVers);
- }
-
- break;
+ try {
+ // Handle explicit locks.
+ GridCacheVersion explicit = txEntry.explicitVersion();
+
+ if (explicit == null) {
+ entry.readyNearLock(xidVer,
+ dhtVer,
+ committedVers,
+ rolledbackVers,
+ pendingVers);
}
- catch (GridCacheEntryRemovedException ignored) {
- assert entry.obsoleteVersion() != null;
- if (log.isDebugEnabled())
- log.debug("Replacing obsolete entry in remote transaction [entry=" + entry +
- ", tx=" + this + ']');
+ break;
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ assert entry.obsoleteVersion() != null;
- // Replace the entry.
- txEntry.cached(txEntry.context().cache().entryEx(txEntry.key()));
- }
+ if (log.isDebugEnabled())
+ log.debug("Replacing obsolete entry in remote transaction [entry=" + entry +
+ ", tx=" + this + ']');
+
+ // Replace the entry.
+ txEntry.cached(txEntry.context().cache().entryEx(txEntry.key()));
}
}
}
[49/50] [abbrv] ignite git commit: IGNITE-2575: Added validation of
IGFS endpoint port value. This closes #469.
Posted by vo...@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-1786
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.
[37/50] [abbrv] ignite git commit: Merge remote-tracking branch
'origin/master'
Posted by vo...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d844e959
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d844e959
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d844e959
Branch: refs/heads/ignite-1786
Commit: d844e95991408970598b324b204c4b6942e67e13
Parents: f07adff bad0420
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Mon Feb 8 10:31:14 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Feb 8 10:31:14 2016 +0300
----------------------------------------------------------------------
.../util/nio/SelectedSelectionKeySet.java | 65 +++++++++++++-------
1 file changed, 43 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
[02/50] [abbrv] ignite git commit: 2224
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
index 8170008..615a92b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearPessimisticTxPrepareFuture.java
@@ -176,6 +176,8 @@ public class GridNearPessimisticTxPrepareFuture extends GridNearTxPrepareFutureA
txMapping = new GridDhtTxMapping();
for (IgniteTxEntry txEntry : tx.allEntries()) {
+ txEntry.clearEntryReadVersion();
+
GridCacheContext cacheCtx = txEntry.context();
List<ClusterNode> nodes = cacheCtx.affinity().nodes(txEntry.key(), topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index a09dec0..a3130cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -122,7 +122,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -146,7 +147,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
deserializeBinary,
skipVals,
false,
- skipStore);
+ skipStore,
+ needVer);
}
}, opCtx);
}
@@ -162,7 +164,8 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
skipVals ? null : opCtx != null ? opCtx.expiry() : null,
skipVals,
skipStore,
- canRemap);
+ canRemap,
+ needVer);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 6130ead..fed3e33 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -477,7 +477,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Override @Nullable public V get(K key, boolean deserializeBinary) throws IgniteCheckedException {
+ @Override @Nullable public V get(K key, boolean deserializeBinary, boolean needVer) throws IgniteCheckedException {
String taskName = ctx.kernalContext().job().currentTaskName();
Map<K, V> m = getAllInternal(Collections.singleton(key),
@@ -485,7 +485,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
ctx.readThrough(),
taskName,
deserializeBinary,
- false);
+ false,
+ needVer);
assert m.isEmpty() || m.size() == 1 : m.size();
@@ -494,7 +495,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Override public final Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary)
+ @Override public final Map<K, V> getAll(Collection<? extends K> keys, boolean deserializeBinary, boolean needVer)
throws IgniteCheckedException {
A.notNull(keys, "keys");
@@ -505,7 +506,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
ctx.readThrough(),
taskName,
deserializeBinary,
- false);
+ false,
+ needVer);
}
@@ -519,7 +521,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
final String taskName,
final boolean deserializeBinary,
final boolean skipVals,
- boolean canRemap
+ boolean canRemap,
+ final boolean needVer
) {
A.notNull(keys, "keys");
@@ -528,7 +531,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
return asyncOp(new Callable<Map<K, V>>() {
@Override public Map<K, V> call() throws Exception {
- return getAllInternal(keys, swapOrOffheap, storeEnabled, taskName, deserializeBinary, skipVals);
+ return getAllInternal(keys, swapOrOffheap, storeEnabled, taskName, deserializeBinary, skipVals, needVer);
}
});
}
@@ -542,6 +545,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
* @param taskName Task name.
* @param deserializeBinary Deserialize binary .
* @param skipVals Skip value flag.
+ * @param needVer Need version.
* @return Key-value map.
* @throws IgniteCheckedException If failed.
*/
@@ -551,7 +555,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
boolean storeEnabled,
String taskName,
boolean deserializeBinary,
- boolean skipVals
+ boolean skipVals,
+ boolean needVer
) throws IgniteCheckedException {
ctx.checkSecurity(SecurityPermission.CACHE_READ);
@@ -584,24 +589,65 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
entry = swapOrOffheap ? entryEx(cacheKey) : peekEx(cacheKey);
if (entry != null) {
- CacheObject v = entry.innerGet(null,
- /*swap*/swapOrOffheap,
- /*read-through*/false,
- /*fail-fast*/false,
- /*unmarshal*/true,
- /**update-metrics*/true,
- /**event*/!skipVals,
- /**temporary*/false,
- subjId,
- null,
- taskName,
- expiry,
- !deserializeBinary);
+ CacheObject v ;
+ GridCacheVersion ver;
- if (v != null)
- ctx.addResult(vals, cacheKey, v, skipVals, false, deserializeBinary, true);
- else
- success = false;
+ if (needVer) {
+ T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(
+ null,
+ /*swap*/swapOrOffheap,
+ /*unmarshal*/true,
+ /**update-metrics*/false,
+ /*event*/!skipVals,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary);
+
+ if (res != null) {
+ v = res.get1();
+ ver = res.get2();
+
+ ctx.addResult(
+ vals,
+ cacheKey,
+ v,
+ skipVals,
+ false,
+ deserializeBinary,
+ true,
+ ver);
+ }else
+ success = false;
+ }
+ else {
+ v = entry.innerGet(null,
+ /*swap*/swapOrOffheap,
+ /*read-through*/false,
+ /*fail-fast*/false,
+ /*unmarshal*/true,
+ /**update-metrics*/true,
+ /**event*/!skipVals,
+ /**temporary*/false,
+ subjId,
+ null,
+ taskName,
+ expiry,
+ !deserializeBinary);
+
+ if (v != null) {
+ ctx.addResult(vals,
+ cacheKey,
+ v,
+ skipVals,
+ false,
+ deserializeBinary,
+ true);
+ }
+ else
+ success = false;
+ }
}
else {
if (!storeEnabled && configuration().isStatisticsEnabled() && !skipVals)
@@ -638,7 +684,8 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
/*force primary*/false,
expiry,
skipVals,
- /*can remap*/true).get();
+ /*can remap*/true,
+ needVer).get();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index f731975..8b871a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -25,6 +25,7 @@ import java.util.UUID;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import javax.cache.expiry.ExpiryPolicy;
import javax.cache.processor.EntryProcessor;
+import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
@@ -73,6 +74,12 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
/** Dummy version for any existing entry read in SERIALIZABLE transaction. */
public static final GridCacheVersion SER_READ_NOT_EMPTY_VER = new GridCacheVersion(0, 0, 0, 1);
+ /** */
+ public static final GridCacheVersion GET_ENTRY_INVALID_VER_UPDATED = new GridCacheVersion(0, 0, 0, 2);
+
+ /** */
+ public static final GridCacheVersion GET_ENTRY_INVALID_VER_AFTER_GET = new GridCacheVersion(0, 0, 0, 3);
+
/** Prepared flag updater. */
private static final AtomicIntegerFieldUpdater<IgniteTxEntry> PREPARED_UPD =
AtomicIntegerFieldUpdater.newUpdater(IgniteTxEntry.class, "prepared");
@@ -918,13 +925,30 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
}
/**
- * @param serReadVer Read version for serializable transaction.
+ * Gets stored entry version. Version is stored for all entries in serializable transaction or
+ * when value is read using {@link IgniteCache#getEntry(Object)} method.
+ *
+ * @return Entry version.
+ */
+ @Nullable public GridCacheVersion entryReadVersion() {
+ return serReadVer;
+ }
+
+ /**
+ * @param ver Entry version.
*/
- public void serializableReadVersion(GridCacheVersion serReadVer) {
+ public void entryReadVersion(GridCacheVersion ver) {
assert this.serReadVer == null;
- assert serReadVer != null;
+ assert ver != null;
- this.serReadVer = serReadVer;
+ this.serReadVer = ver;
+ }
+
+ /**
+ * Clears recorded read version, should be done before starting commit of not serializable/optimistic transaction.
+ */
+ public void clearEntryReadVersion() {
+ serReadVer = null;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index aad9841..a999358 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -58,6 +58,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheUpdateTxResult;
import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtDetachedCacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry;
import org.apache.ignite.internal.processors.cache.dr.GridCacheDrInfo;
import org.apache.ignite.internal.processors.cache.store.CacheStoreManager;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
@@ -1342,7 +1343,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
/**
* Checks if there is a cached or swapped value for
- * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean)} method.
+ * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean, boolean)} method.
*
* @param cacheCtx Cache context.
* @param keys Key to enlist.
@@ -1368,7 +1369,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
boolean deserializeBinary,
boolean skipVals,
boolean keepCacheObjects,
- boolean skipStore
+ boolean skipStore,
+ final boolean needVer
) throws IgniteCheckedException {
assert !F.isEmpty(keys);
assert keysCnt == keys.size();
@@ -1381,7 +1383,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
AffinityTopologyVersion topVer = topologyVersion();
- boolean needReadVer = serializable() && optimistic();
+ boolean needReadVer = (serializable() && optimistic()) || needVer;
// In this loop we cover only read-committed or optimistic transactions.
// Transactions that are pessimistic and not read-committed are covered
@@ -1403,31 +1405,89 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (!F.isEmpty(txEntry.entryProcessors()))
val = txEntry.applyEntryProcessors(val);
- if (val != null)
- cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false);
+ if (val != null) {
+ GridCacheVersion ver = null;
+
+ if (needVer) {
+ if (txEntry.op() != READ)
+ ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_UPDATED;
+ else {
+ ver = txEntry.entryReadVersion();
+
+ if (ver == null && pessimistic()) {
+ while (true) {
+ try {
+ GridCacheEntryEx cached = txEntry.cached();
+
+ ver = cached.isNear() ?
+ ((GridNearCacheEntry)cached).dhtVersion() : cached.version();
+
+ break;
+ }
+ catch (GridCacheEntryRemovedException rmvdErr) {
+ txEntry.cached(entryEx(cacheCtx, txEntry.txKey(), topVer));
+ }
+ }
+ }
+
+ if (ver == null) {
+ assert optimistic() && repeatableRead() : this;
+
+ ver = IgniteTxEntry.GET_ENTRY_INVALID_VER_AFTER_GET;
+ }
+ }
+
+ assert ver != null;
+ }
+
+ cacheCtx.addResult(map, key, val, skipVals, keepCacheObjects, deserializeBinary, false, ver);
+ }
}
else {
assert txEntry.op() == TRANSFORM;
while (true) {
try {
+ GridCacheVersion readVer = null;
+
Object transformClo =
- (txEntry.op() == TRANSFORM && cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
+ (txEntry.op() == TRANSFORM &&
+ cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
F.first(txEntry.entryProcessors()) : null;
- val = txEntry.cached().innerGet(this,
- /*swap*/true,
- /*read-through*/false,
- /*fail fast*/true,
- /*unmarshal*/true,
- /*metrics*/true,
- /*event*/!skipVals,
- /*temporary*/false,
- CU.subjectId(this, cctx),
- transformClo,
- resolveTaskName(),
- null,
- txEntry.keepBinary());
+ if (needVer) {
+ T2<CacheObject, GridCacheVersion> res = txEntry.cached().innerGetVersioned(
+ this,
+ /*swap*/true,
+ /*unmarshal*/true,
+ /*update-metrics*/true,
+ /*event*/!skipVals,
+ CU.subjectId(this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+
+ if (res != null) {
+ val = res.get1();
+ readVer = res.get2();
+ }
+ }
+ else {
+ val = txEntry.cached().innerGet(this,
+ /*swap*/true,
+ /*read-through*/false,
+ /*fail fast*/true,
+ /*unmarshal*/true,
+ /*metrics*/true,
+ /*event*/!skipVals,
+ /*temporary*/false,
+ CU.subjectId(this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+ }
if (val != null) {
if (!readCommitted() && !skipVals)
@@ -1442,7 +1502,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
deserializeBinary,
- false);
+ false,
+ readVer);
}
else
missed.put(key, txEntry.cached().version());
@@ -1517,7 +1578,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
deserializeBinary,
- false);
+ false,
+ needVer ? readVer : null);
}
else
missed.put(key, ver);
@@ -1549,7 +1611,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
assert readVer != null;
- txEntry.serializableReadVersion(readVer);
+ txEntry.entryReadVersion(readVer);
}
}
}
@@ -1600,7 +1662,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
/**
* Loads all missed keys for
- * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean)} method.
+ * {@link #getAllAsync(GridCacheContext, Collection, boolean, boolean, boolean, boolean, boolean)} method.
*
* @param cacheCtx Cache context.
* @param map Return map.
@@ -1618,12 +1680,14 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
final boolean deserializeBinary,
final boolean skipVals,
final boolean keepCacheObjects,
- final boolean skipStore
+ final boolean skipStore,
+ final boolean needVer
+
) {
if (log.isDebugEnabled())
log.debug("Loading missed values for missed map: " + missedMap);
- final boolean needReadVer = serializable() && optimistic();
+ final boolean needReadVer = (serializable() && optimistic()) || needVer;
return new GridEmbeddedFuture<>(
new C2<Void, Exception, Map<K, V>>() {
@@ -1685,7 +1749,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
deserializeBinary,
- false);
+ false,
+ needVer ? loadVer : null);
}
}
else {
@@ -1696,7 +1761,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
assert loadVer != null;
- txEntry.serializableReadVersion(loadVer);
+ txEntry.entryReadVersion(loadVer);
}
if (visibleVal != null) {
@@ -1706,7 +1771,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
deserializeBinary,
- false);
+ false,
+ needVer ? loadVer : null);
}
}
}
@@ -1715,13 +1781,15 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Override public <K, V> IgniteInternalFuture<Map<K, V>> getAllAsync(
final GridCacheContext cacheCtx,
Collection<KeyCacheObject> keys,
final boolean deserializeBinary,
final boolean skipVals,
final boolean keepCacheObjects,
- final boolean skipStore) {
+ final boolean skipStore,
+ final boolean needVer) {
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -1751,7 +1819,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
deserializeBinary,
skipVals,
keepCacheObjects,
- skipStore);
+ skipStore,
+ needVer);
if (single && missed.isEmpty())
return new GridFinishedFuture<>(retMap);
@@ -1797,25 +1866,48 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
while (true) {
GridCacheEntryEx cached = txEntry.cached();
+ CacheObject val = null;
+ GridCacheVersion readVer = null;
+
try {
Object transformClo =
(!F.isEmpty(txEntry.entryProcessors()) &&
cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ)) ?
F.first(txEntry.entryProcessors()) : null;
- CacheObject val = cached.innerGet(IgniteTxLocalAdapter.this,
- cacheCtx.isSwapOrOffheapEnabled(),
- /*read-through*/false,
- /*fail-fast*/true,
- /*unmarshal*/true,
- /*metrics*/true,
- /*events*/!skipVals,
- /*temporary*/true,
- CU.subjectId(IgniteTxLocalAdapter.this, cctx),
- transformClo,
- resolveTaskName(),
- null,
- txEntry.keepBinary());
+ if (needVer) {
+ T2<CacheObject, GridCacheVersion> res = cached.innerGetVersioned(
+ IgniteTxLocalAdapter.this,
+ /*swap*/cacheCtx.isSwapOrOffheapEnabled(),
+ /*unmarshal*/true,
+ /**update-metrics*/true,
+ /*event*/!skipVals,
+ CU.subjectId(IgniteTxLocalAdapter.this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+
+ if (res != null) {
+ val = res.get1();
+ readVer = res.get2();
+ }
+ }
+ else{
+ val = cached.innerGet(IgniteTxLocalAdapter.this,
+ cacheCtx.isSwapOrOffheapEnabled(),
+ /*read-through*/false,
+ /*fail-fast*/true,
+ /*unmarshal*/true,
+ /*metrics*/true,
+ /*events*/!skipVals,
+ /*temporary*/true,
+ CU.subjectId(IgniteTxLocalAdapter.this, cctx),
+ transformClo,
+ resolveTaskName(),
+ null,
+ txEntry.keepBinary());
+ }
// If value is in cache and passed the filter.
if (val != null) {
@@ -1832,7 +1924,11 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
skipVals,
keepCacheObjects,
deserializeBinary,
- false);
+ false,
+ readVer);
+
+ if (readVer != null)
+ txEntry.entryReadVersion(readVer);
}
// Even though we bring the value back from lock acquisition,
@@ -1858,7 +1954,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
deserializeBinary,
skipVals,
keepCacheObjects,
- skipStore);
+ skipStore,
+ needVer);
}
return new GridFinishedFuture<>(Collections.<K, V>emptyMap());
@@ -1924,7 +2021,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
deserializeBinary,
skipVals,
keepCacheObjects,
- skipStore);
+ skipStore,
+ needVer);
}
return new GridFinishedFuture<>(retMap);
@@ -2315,7 +2413,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
assert loadVer != null;
- e.serializableReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
+ e.entryReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
}
if (singleRmv) {
@@ -2508,7 +2606,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
assert readVer != null;
- txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+ txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
}
}
@@ -2561,7 +2659,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
if (needReadVer) {
assert readVer != null;
- txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
+ txEntry.entryReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer);
}
if (retval && !transform)
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
index a5d3373..78f517c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalEx.java
@@ -76,7 +76,8 @@ public interface IgniteTxLocalEx extends IgniteInternalTx {
boolean deserializeBinary,
boolean skipVals,
boolean keepCacheObjects,
- boolean skipStore);
+ boolean skipStore,
+ boolean needVer);
/**
* @param cacheCtx Cache context.
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 3e43726..28a7cc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1419,7 +1419,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
assert !entry1.detached() : "Expected non-detached entry for near transaction " +
"[locNodeId=" + cctx.localNodeId() + ", entry=" + entry1 + ']';
- GridCacheVersion serReadVer = txEntry1.serializableReadVersion();
+ GridCacheVersion serReadVer = txEntry1.entryReadVersion();
assert serReadVer == null || (tx.optimistic() && tx.serializable()) : txEntry1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
new file mode 100644
index 0000000..c0ba42c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryAbstractTest.java
@@ -0,0 +1,803 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Collection;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.cache.CacheEntry;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMode.LOCAL;
+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;
+import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public abstract class CacheGetEntryAbstractTest extends GridCacheAbstractSelfTest {
+ /** */
+ private static final String UPDATED_ENTRY_ERR = "Impossible to get version for entry updated in transaction";
+
+ /** */
+ private static final String ENTRY_AFTER_GET_ERR = "Impossible to get entry version after get()";
+
+ /** {@inheritDoc} */
+ @Override protected int gridCount() {
+ return 3;
+ }
+
+ /**
+ * @return Transaction concurrency.
+ */
+ abstract protected TransactionConcurrency concurrency();
+
+ /**
+ *
+ * @return Transaction isolation.
+ */
+ abstract protected TransactionIsolation isolation();
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 60_000;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMarshaller(null);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNear() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setName("near");
+ cfg.setNearConfiguration(new NearCacheConfiguration());
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNearTransactional() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setName("nearT");
+ cfg.setNearConfiguration(new NearCacheConfiguration());
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitioned() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setName("partitioned");
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPartitionedTransactional() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setName("partitionedT");
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocal() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(LOCAL);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setName("local");
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLocalTransactional() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(LOCAL);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setName("localT");
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicated() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(REPLICATED);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setName("replicated");
+
+ test(cfg);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReplicatedTransactional() throws Exception {
+ CacheConfiguration cfg = new CacheConfiguration();
+
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ cfg.setCacheMode(REPLICATED);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setName("replicatedT");
+
+ test(cfg);
+ }
+
+ /**
+ * @param cfg Cache configuration.
+ * @throws Exception If failed.
+ */
+ private void test(CacheConfiguration cfg) throws Exception {
+ test(cfg, true);
+
+ test(cfg, false);
+ }
+
+ /**
+ * @param cfg Cache configuration.
+ * @param oneEntry If {@code true} then single entry is tested.
+ * @throws Exception If failed.
+ */
+ private void test(CacheConfiguration cfg, final boolean oneEntry) throws Exception {
+ final IgniteCache<Integer, TestValue> cache = grid(0).createCache(cfg);
+
+ try {
+ init(cache);
+
+ test(cache, null, null, null, oneEntry);
+
+ if (cfg.getAtomicityMode() == TRANSACTIONAL) {
+ TransactionConcurrency txConcurrency = concurrency();
+ TransactionIsolation txIsolation = isolation();
+
+ try (Transaction tx = grid(0).transactions().txStart(txConcurrency, txIsolation)) {
+ initTx(cache);
+
+ test(cache, txConcurrency, txIsolation, tx, oneEntry);
+
+ tx.commit();
+ }
+
+ testConcurrentTx(cache, OPTIMISTIC, REPEATABLE_READ, oneEntry);
+ testConcurrentTx(cache, OPTIMISTIC, READ_COMMITTED, oneEntry);
+
+ testConcurrentTx(cache, PESSIMISTIC, REPEATABLE_READ, oneEntry);
+ testConcurrentTx(cache, PESSIMISTIC, READ_COMMITTED, oneEntry);
+ }
+ }
+ finally {
+ cache.destroy();
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param txConcurrency Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @param oneEntry If {@code true} then single entry is tested.
+ * @throws Exception If failed.
+ */
+ private void testConcurrentTx(final IgniteCache<Integer, TestValue> cache,
+ final TransactionConcurrency txConcurrency,
+ final TransactionIsolation txIsolation,
+ final boolean oneEntry) throws Exception {
+ GridTestUtils.runMultiThreaded(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ IgniteTransactions txs = grid(0).transactions();
+
+ long stopTime = System.currentTimeMillis() + 3000;
+
+ while (System.currentTimeMillis() < stopTime) {
+ Set<Integer> keys = new LinkedHashSet<>();
+
+ for (int i = 0; i < 100; i++)
+ keys.add(i);
+
+ try (Transaction tx = txs.txStart(txConcurrency, txIsolation)) {
+ if (oneEntry) {
+ for (int i = 0; i < 100; i++)
+ cache.getEntry(i);
+ }
+ else
+ cache.getEntries(keys);
+
+ for (int i = 0; i < 100; i++)
+ cache.put(i, new TestValue(i));
+
+ tx.commit();
+ }
+ }
+
+ return null;
+ }
+ }, 10, "tx-thread");
+ }
+
+ /**
+ * @param base Start value.
+ * @return Keys.
+ */
+ private Set<Integer> getKeys(int base) {
+ int start = 0;
+ int finish = 100;
+
+ Set<Integer> keys = new HashSet<>(finish - start);
+
+ for (int i = base + start; i < base + finish; ++i)
+ keys.add(i);
+
+ return keys;
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxKeys() {
+ return getKeys(0);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxWithBinaryKeys() {
+ return getKeys(1_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxKeys2() {
+ return getKeys(2_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxWithBinaryKeys2() {
+ return getKeys(3_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxKeys3() {
+ return getKeys(4_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdBeforeTxWithBinaryKeys3() {
+ return getKeys(5_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> removedBeforeTxKeys() {
+ return getKeys(6_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> removedBeforeTxWithBinaryKeys() {
+ return getKeys(7_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdAtTxKeys() {
+ return getKeys(8_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> createdAtTxWithBinaryKeys() {
+ return getKeys(9_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> removedAtTxKeys() {
+ return getKeys(10_000);
+ }
+
+ /**
+ * @return Keys.
+ */
+ private Set<Integer> removedAtTxWithBinaryKeys() {
+ return getKeys(11_000);
+ }
+
+ /**
+ * @param cache Cacge.
+ */
+ private void init(IgniteCache<Integer, TestValue> cache) {
+ Set<Integer> keys = new HashSet<>();
+
+ keys.addAll(createdBeforeTxKeys());
+ keys.addAll(createdBeforeTxWithBinaryKeys());
+ keys.addAll(createdBeforeTxKeys2());
+ keys.addAll(createdBeforeTxWithBinaryKeys2());
+ keys.addAll(createdBeforeTxKeys3());
+ keys.addAll(createdBeforeTxWithBinaryKeys3());
+ keys.addAll(removedBeforeTxKeys());
+ keys.addAll(removedBeforeTxWithBinaryKeys());
+ keys.addAll(removedAtTxKeys());
+ keys.addAll(removedAtTxWithBinaryKeys());
+
+ for (int i : keys)
+ cache.put(i, new TestValue(i));
+
+ for (int i : removedBeforeTxKeys())
+ cache.remove(i);
+
+ for (int i : removedBeforeTxWithBinaryKeys())
+ cache.remove(i);
+ }
+
+ /**
+ * @param cache Cache.
+ */
+ private void initTx(IgniteCache<Integer, TestValue> cache) {
+ for (int i : createdAtTxKeys())
+ cache.put(i, new TestValue(i));
+
+ for (int i : createdAtTxWithBinaryKeys())
+ cache.put(i, new TestValue(i));
+
+ for (int i : removedAtTxKeys())
+ cache.remove(i);
+
+ for (int i : removedAtTxWithBinaryKeys())
+ cache.remove(i);
+ }
+
+ /**
+ * @param e Entry.
+ * @param cache Cache.
+ * @throws Exception If failed.
+ */
+ private void compareVersionWithPrimaryNode(CacheEntry<Integer, ?> e, IgniteCache<Integer, TestValue> cache)
+ throws Exception {
+ CacheConfiguration cfg = cache.getConfiguration(CacheConfiguration.class);
+
+ if (cfg.getCacheMode() != LOCAL) {
+ Ignite prim = primaryNode(e.getKey(), cache.getName());
+
+ GridCacheAdapter<Object, Object> cacheAdapter = ((IgniteKernal)prim).internalCache(cache.getName());
+
+ if (cfg.getNearConfiguration() != null)
+ cacheAdapter = ((GridNearCacheAdapter)cacheAdapter).dht();
+
+ IgniteCacheObjectProcessor cacheObjects = cacheAdapter.context().cacheObjects();
+
+ CacheObjectContext cacheObjCtx = cacheAdapter.context().cacheObjectContext();
+
+ GridCacheMapEntry mapEntry = cacheAdapter.map().getEntry(cacheObjects.toCacheKeyObject(
+ cacheObjCtx, e.getKey(), true));
+
+ assertNotNull("No entry for key: " + e.getKey(), mapEntry);
+ assertEquals(mapEntry.version(), e.version());
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param i Key.
+ * @param oneEntry If {@code true} then single entry is tested.
+ * @param getVerErr Not null error if entry version access should fail.
+ * @param expKeys Expected keys with values.
+ * @throws Exception If failed.
+ */
+ private void checkData(IgniteCache<Integer, TestValue> cache,
+ int i,
+ boolean oneEntry,
+ @Nullable String getVerErr,
+ Set<Integer> expKeys) throws Exception {
+ if (oneEntry) {
+ final CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+ if (getVerErr == null)
+ compareVersionWithPrimaryNode(e, cache);
+ else {
+ Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ e.version();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+
+ assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+ }
+
+ assertEquals(e.getValue().val, i);
+ }
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ int expCnt = 0;
+
+ for (int j = 0; j < 10; j++) {
+ Integer key = i + j;
+
+ set.add(key);
+
+ if (expKeys.contains(key))
+ expCnt++;
+ }
+
+ Collection<CacheEntry<Integer, TestValue>> entries = cache.getEntries(set);
+
+ assertEquals(expCnt, entries.size());
+
+ for (final CacheEntry<Integer, TestValue> e : entries) {
+ if (getVerErr == null)
+ compareVersionWithPrimaryNode(e, cache);
+ else {
+ Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ e.version();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+
+ assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+ }
+
+ assertEquals((Integer)e.getValue().val, e.getKey());
+
+ assertTrue(set.contains(e.getValue().val));
+ }
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param i Key.
+ * @param oneEntry If {@code true} then single entry is tested.
+ * @param getVerErr Not null error if entry version access should fail.
+ * @param expKeys Expected keys with values.
+ * @throws Exception If failed.
+ */
+ private void checkBinaryData(IgniteCache<Integer, TestValue> cache,
+ int i,
+ boolean oneEntry,
+ @Nullable String getVerErr,
+ Set<Integer> expKeys) throws Exception {
+ IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+ if (oneEntry) {
+ final CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+ if (getVerErr == null)
+ compareVersionWithPrimaryNode(e, cache);
+ else {
+ Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ e.version();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+
+ assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+ }
+
+ assertEquals(((TestValue)e.getValue().deserialize()).val, i);
+ }
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ int expCnt = 0;
+
+ for (int j = 0; j < 10; j++) {
+ Integer key = i + j;
+
+ set.add(key);
+
+ if (expKeys.contains(key))
+ expCnt++;
+ }
+
+ Collection<CacheEntry<Integer, BinaryObject>> entries = cacheB.getEntries(set);
+
+ assertEquals(expCnt, entries.size());
+
+ for (final CacheEntry<Integer, BinaryObject> e : entries) {
+ if (getVerErr == null)
+ compareVersionWithPrimaryNode(e, cache);
+ else {
+ Throwable err = GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ e.version();
+
+ return null;
+ }
+ }, IgniteException.class, null);
+
+ assertTrue("Unexpected error message: " + err.getMessage(), err.getMessage().startsWith(getVerErr));
+ }
+
+ TestValue tv = e.getValue().deserialize();
+
+ assertEquals((Integer)tv.val, e.getKey());
+
+ assertTrue(set.contains((tv).val));
+ }
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param i Key.
+ * @param oneEntry If {@code true} then single entry is tested.
+ */
+ private void checkRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry) {
+ if (oneEntry) {
+ CacheEntry<Integer, TestValue> e = cache.getEntry(i);
+
+ assertNull(e);
+ }
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ for (int j = 0; j < 10; j++)
+ set.add(i + j);
+
+ Collection<CacheEntry<Integer, TestValue>> es = cache.getEntries(set);
+
+ assertTrue(es.isEmpty());
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param i Key.
+ * @param oneEntry If {@code true} then single entry is tested.
+ */
+ private void checkBinaryRemoved(IgniteCache<Integer, TestValue> cache, int i, boolean oneEntry) {
+ IgniteCache<Integer, BinaryObject> cacheB = cache.withKeepBinary();
+
+ if (oneEntry) {
+ CacheEntry<Integer, BinaryObject> e = cacheB.getEntry(i);
+
+ assertNull(e);
+ }
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ for (int j = 0; j < 10; j++)
+ set.add(i + j);
+
+ Collection<CacheEntry<Integer, BinaryObject>> es = cacheB.getEntries(set);
+
+ assertTrue(es.isEmpty());
+ }
+ }
+
+ /**
+ * @param cache Cache.
+ * @param txConcurrency Transaction concurrency.
+ * @param txIsolation Transaction isolation.
+ * @param tx Transaction.
+ * @param oneEntry If {@code true} then single entry is tested.
+ * @throws Exception If failed.
+ */
+ private void test(IgniteCache<Integer, TestValue> cache,
+ TransactionConcurrency txConcurrency,
+ TransactionIsolation txIsolation,
+ Transaction tx,
+ boolean oneEntry) throws Exception {
+ if (tx == null) {
+ Set<Integer> keys = createdBeforeTxKeys();
+
+ for (int i : keys)
+ checkData(cache, i, oneEntry, null, keys);
+
+ keys = createdBeforeTxWithBinaryKeys();
+
+ for (int i : keys)
+ checkBinaryData(cache, i, oneEntry, null, keys);
+
+ for (int i : removedBeforeTxKeys())
+ checkRemoved(cache, i, oneEntry);
+
+ for (int i : removedBeforeTxWithBinaryKeys())
+ checkBinaryRemoved(cache, i, oneEntry);
+ }
+ else {
+ Set<Integer> keys = createdBeforeTxKeys2();
+
+ for (int i : keys) {
+ checkData(cache, i, oneEntry, null, keys);
+ checkData(cache, i, oneEntry, null, keys);
+ }
+
+ keys = createdBeforeTxWithBinaryKeys2();
+
+ for (int i : keys) {
+ checkBinaryData(cache, i, oneEntry, null, keys);
+ checkBinaryData(cache, i, oneEntry, null, keys);
+ }
+
+ String verGetErr = null;
+
+ if (txConcurrency == OPTIMISTIC && txIsolation == REPEATABLE_READ)
+ verGetErr = ENTRY_AFTER_GET_ERR;
+
+ keys = createdBeforeTxKeys3();
+
+ for (int i : keys) {
+ if (oneEntry)
+ cache.get(i);
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ for (int j = 0; j < 10; j++)
+ set.add(i + j);
+
+ cache.getAll(set);
+ }
+
+ checkData(cache, i, oneEntry, verGetErr, keys);
+ }
+
+ keys = createdBeforeTxWithBinaryKeys3();
+
+ for (int i : keys) {
+ if (oneEntry)
+ cache.get(i);
+ else {
+ Set<Integer> set = new HashSet<>();
+
+ for (int j = 0; j < 10; j++)
+ set.add(i + j);
+
+ cache.getAll(set);
+ }
+
+ checkBinaryData(cache, i, oneEntry, verGetErr, keys);
+ }
+
+ keys = createdAtTxKeys();
+
+ for (int i : keys)
+ checkData(cache, i, oneEntry, UPDATED_ENTRY_ERR, keys);
+
+ keys = createdAtTxWithBinaryKeys();
+
+ for (int i : keys)
+ checkBinaryData(cache, i, oneEntry, UPDATED_ENTRY_ERR, keys);
+
+ for (int i : removedBeforeTxKeys())
+ checkRemoved(cache, i, oneEntry);
+
+ for (int i : removedBeforeTxWithBinaryKeys())
+ checkBinaryRemoved(cache, i, oneEntry);
+
+ for (int i : removedAtTxKeys())
+ checkRemoved(cache, i, oneEntry);
+
+ for (int i : removedAtTxWithBinaryKeys())
+ checkBinaryRemoved(cache, i, oneEntry);
+ }
+ }
+
+ /**
+ *
+ */
+ private static class TestValue implements Serializable {
+ /** */
+ private int val;
+
+ /**
+ * @param val Value.
+ */
+ public TestValue(int val) {
+ this.val = val;
+ }
+
+ /**
+ * @return Value.
+ */
+ public int value() {
+ return val;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(TestValue.class, this);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..acc21df
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticReadCommittedSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.OPTIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.READ_COMMITTED;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..6153869
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticRepeatableReadSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.OPTIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.REPEATABLE_READ;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
new file mode 100644
index 0000000..6ded4a9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryOptimisticSerializableSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryOptimisticSerializableSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.OPTIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.SERIALIZABLE;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
new file mode 100644
index 0000000..975d271
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticReadCommittedSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticReadCommittedSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.PESSIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.READ_COMMITTED;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
new file mode 100644
index 0000000..dac64d9
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticRepeatableReadSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticRepeatableReadSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.PESSIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.REPEATABLE_READ;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
new file mode 100644
index 0000000..70f71ce
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheGetEntryPessimisticSerializableSeltTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.transactions.TransactionConcurrency;
+import org.apache.ignite.transactions.TransactionIsolation;
+
+/**
+ * Test getEntry and getEntries methods.
+ */
+public class CacheGetEntryPessimisticSerializableSeltTest extends CacheGetEntryAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected TransactionConcurrency concurrency() {
+ return TransactionConcurrency.PESSIMISTIC;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected TransactionIsolation isolation() {
+ return TransactionIsolation.SERIALIZABLE;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
index c606a2a..b60ada7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
@@ -85,6 +85,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
* @throws Exception If failed.
*/
public void testReadThroughInTx() throws Exception {
+ testReadThroughInTx(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReadEntryThroughInTx() throws Exception {
+ testReadThroughInTx(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testReadThroughInTx(boolean needVer) throws Exception {
IgniteCache<String, Integer> cache = grid(1).cache(null);
for (int k = 0; k < 1000; k++)
@@ -104,7 +118,14 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
for (int k = 0; k < 1000; k++) {
String key = "key" + k;
- assertNotNull("Null value for key: " + key, cache.get(key));
+ if (needVer) {
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ }
+ else {
+ assertNotNull("Null value for key: " + key, cache.get(key));
+ assertNotNull("Null value for key: " + key, cache.get(key));
+ }
}
tx.commit();
@@ -117,6 +138,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
* @throws Exception If failed.
*/
public void testReadThrough() throws Exception {
+ testReadThrough(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReadEntryThrough() throws Exception {
+ testReadThrough(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void testReadThrough(boolean needVer) throws Exception {
IgniteCache<String, Integer> cache = grid(1).cache(null);
for (int k = 0; k < 1000; k++)
@@ -132,8 +167,10 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
for (int k = 0; k < 1000; k++) {
String key = "key" + k;
-
- assertNotNull("Null value for key: " + key, cache.get(key));
+ if (needVer)
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ else
+ assertNotNull("Null value for key: " + key, cache.get(key));
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/01135066/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 9906ad3..4baef66 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -46,6 +47,7 @@ import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cache.CacheEntry;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
import org.apache.ignite.cache.store.CacheStore;
@@ -575,6 +577,20 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxCommitReadOnlyGetAll() throws Exception {
+ testTxCommitReadOnlyGetAll(false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxCommitReadOnlyGetEntries() throws Exception {
+ testTxCommitReadOnlyGetAll(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxCommitReadOnlyGetAll(boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -591,9 +607,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
keys.add(i);
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Map<Integer, Integer> map = cache.getAll(keys);
+ if (needVer) {
+ Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
- assertTrue(map.isEmpty());
+ assertTrue(c.isEmpty());
+ }
+ else {
+ Map<Integer, Integer> map = cache.getAll(keys);
+
+ assertTrue(map.isEmpty());
+ }
tx.commit();
}
@@ -602,9 +625,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, null, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Map<Integer, Integer> map = cache.getAll(keys);
+ if (needVer) {
+ Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
- assertTrue(map.isEmpty());
+ assertTrue(c.isEmpty());
+ }
+ else {
+ Map<Integer, Integer> map = cache.getAll(keys);
+
+ assertTrue(map.isEmpty());
+ }
tx.rollback();
}
@@ -653,21 +683,35 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxConflictRead1() throws Exception {
- txConflictRead(true);
+ txConflictRead(true, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictRead2() throws Exception {
- txConflictRead(false);
+ txConflictRead(false, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntry1() throws Exception {
+ txConflictRead(true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntry2() throws Exception {
+ txConflictRead(false, true);
}
/**
* @param noVal If {@code true} there is no cache value when read in tx.
* @throws Exception If failed.
*/
- private void txConflictRead(boolean noVal) throws Exception {
+ private void txConflictRead(boolean noVal, boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -693,9 +737,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
try {
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val);
+ assertEquals(expVal, val == null ? null : val.getValue());
+ }
+ else {
+ Integer val = cache.get(key);
+
+ assertEquals(expVal, val);
+ }
updateKey(cache, key, 1);
@@ -711,9 +762,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, 1, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Object val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(1, val);
+ assertEquals((Integer)1, val.getValue());
+ }
+ else {
+ Object val = cache.get(key);
+
+ assertEquals(1, val);
+ }
tx.commit();
}
@@ -731,28 +789,56 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxConflictReadWrite1() throws Exception {
- txConflictReadWrite(true, false);
+ txConflictReadWrite(true, false, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadWrite2() throws Exception {
- txConflictReadWrite(false, false);
+ txConflictReadWrite(false, false, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadRemove1() throws Exception {
- txConflictReadWrite(true, true);
+ txConflictReadWrite(true, true, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadRemove2() throws Exception {
- txConflictReadWrite(false, true);
+ txConflictReadWrite(false, true, false);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntryWrite1() throws Exception {
+ txConflictReadWrite(true, false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntryWrite2() throws Exception {
+ txConflictReadWrite(false, false, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntryRemove1() throws Exception {
+ txConflictReadWrite(true, true, true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxConflictReadEntryRemove2() throws Exception {
+ txConflictReadWrite(false, true, true);
}
/**
@@ -760,7 +846,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @param rmv If {@code true} tests remove, otherwise put.
* @throws Exception If failed.
*/
- private void txConflictReadWrite(boolean noVal, boolean rmv) throws Exception {
+ private void txConflictReadWrite(boolean noVal, boolean rmv, boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -786,9 +872,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
try {
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val);
+ assertEquals(expVal, val == null ? null : val.getValue());
+ }
+ else {
+ Integer val = cache.get(key);
+
+ assertEquals(expVal, val);
+ }
updateKey(cache, key, 1);
@@ -809,9 +902,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, 1, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
+
+ assertEquals(1, (Object)val.getValue());
+ }
+ else {
+ Integer val = cache.get(key);
- assertEquals(1, (Object) val);
+ assertEquals(1, (Object)val);
+ }
if (rmv)
cache.remove(key);
@@ -4239,7 +4339,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
ignite.destroyCache(cacheName);
}
catch (IgniteException ignore) {
- // No-op.
+ // No-op.
}
GridTestSwapSpaceSpi spi = (GridTestSwapSpaceSpi)ignite.configuration().getSwapSpaceSpi();
[20/50] [abbrv] ignite git commit: Improved exception handling in
IgniteContext
Posted by vo...@apache.org.
Improved exception handling in IgniteContext
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d1e2957a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d1e2957a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d1e2957a
Branch: refs/heads/ignite-1786
Commit: d1e2957a7440b7a781439811ab9bdfedf38bd640
Parents: 500bd3a
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Wed Feb 3 18:44:44 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Wed Feb 3 18:44:44 2016 -0800
----------------------------------------------------------------------
.../scala/org/apache/ignite/spark/IgniteContext.scala | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/d1e2957a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
index 6e48017..57fe84f 100644
--- a/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
+++ b/modules/spark/src/main/scala/org/apache/ignite/spark/IgniteContext.scala
@@ -20,7 +20,7 @@ package org.apache.ignite.spark
import org.apache.ignite.internal.IgnitionEx
import org.apache.ignite.internal.util.IgniteUtils
-import org.apache.ignite.{IgniteSystemProperties, Ignition, Ignite}
+import org.apache.ignite._
import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
import org.apache.spark.{Logging, SparkContext}
import org.apache.spark.sql.SQLContext
@@ -146,14 +146,19 @@ class IgniteContext[K, V](
Ignition.ignite(igniteCfg.getGridName)
}
catch {
- case e: Exception ⇒
+ case e: IgniteIllegalStateException ⇒
try {
igniteCfg.setClientMode(client || driver)
Ignition.start(igniteCfg)
}
catch {
- case e: Exception ⇒ Ignition.ignite(igniteCfg.getGridName)
+ case e: IgniteException ⇒ {
+ logError("Failed to start Ignite client. Will try to use an existing instance with name: "
+ + igniteCfg.getGridName, e)
+
+ Ignition.ignite(igniteCfg.getGridName)
+ }
}
}
}
[11/50] [abbrv] ignite git commit: ignite-2080 Data alignment issues
with Unsafe
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
index 359d36c..3f58447 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
@@ -45,8 +45,23 @@ import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.REHASH;
*/
public class GridUnsafeMap implements GridOffHeapMap {
/** Header size. */
- private static final int HEADER = 4 /*hash*/ + 4 /*key-size*/ + 4 /*value-size*/ + 8 /*queue-address*/ +
- 8 /*next-address*/;
+ private static final int HEADER_SIZE = 8 /*queue-address*/ + 8 /*next-address*/ + 4 /*hash*/ + 4 /*key-size*/
+ + 4 /*value-size*/;
+
+ /** Header queue address offset. */
+ private static final long HEADER_QUEUE_ADDR_OFF = 0;
+
+ /** Header next address offset. */
+ private static final long HEADER_NEXT_ADDR_OFF = 8;
+
+ /** Header hash offset. */
+ private static final long HEADER_HASH_OFF = 16;
+
+ /** Header key size offset. */
+ private static final long HEADER_KEY_SIZE_OFF = 20;
+
+ /** Header value size. */
+ private static final long HEADER_VALUE_SIZE = 24;
/** Debug flag. */
private static final boolean DEBUG = false;
@@ -789,7 +804,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = Entry.readKeyLength(entryAddr, mem);
int valLen = Entry.readValueLength(entryAddr, mem);
- byte[] valBytes = mem.readBytes(entryAddr + HEADER + keyLen, valLen);
+ byte[] valBytes = mem.readBytes(entryAddr + HEADER_SIZE + keyLen, valLen);
bin.add(F.t(Entry.readKeyBytes(entryAddr, mem), valBytes));
}
@@ -860,9 +875,9 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = Entry.readKeyLength(entryAddr, mem);
int valLen = Entry.readValueLength(entryAddr, mem);
- T2<Long, Integer> keyPtr = new T2<>(entryAddr + HEADER, keyLen);
+ T2<Long, Integer> keyPtr = new T2<>(entryAddr + HEADER_SIZE, keyLen);
- T2<Long, Integer> valPtr = new T2<>(entryAddr + HEADER + keyLen, valLen);
+ T2<Long, Integer> valPtr = new T2<>(entryAddr + HEADER_SIZE + keyLen, valLen);
T res = c.apply(keyPtr, valPtr);
@@ -1033,7 +1048,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = Entry.readKeyLength(cur, mem);
int valLen = Entry.readValueLength(cur, mem);
- valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+ valBytes = mem.readBytes(cur + HEADER_SIZE + keyLen, valLen);
}
if (rmvEvicted) {
@@ -1101,7 +1116,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
if (cnt + 1 > threshold)
rehash();
- int size = HEADER + keyBytes.length + valBytes.length;
+ int size = HEADER_SIZE + keyBytes.length + valBytes.length;
boolean poll = !mem.reserve(size);
@@ -1230,7 +1245,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
}
}
- size = HEADER + keyBytes.length + valBytes.length;
+ size = HEADER_SIZE + keyBytes.length + valBytes.length;
poll = !mem.reserve(size);
@@ -1332,7 +1347,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
keyLen = Entry.readKeyLength(cur, mem);
valLen = Entry.readValueLength(cur, mem);
- long valPtr = cur + HEADER + keyLen;
+ long valPtr = cur + HEADER_SIZE + keyLen;
if (!p.apply(valPtr, valLen))
return null;
@@ -1353,7 +1368,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
valLen = Entry.readValueLength(cur, mem);
}
- valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+ valBytes = mem.readBytes(cur + HEADER_SIZE + keyLen, valLen);
}
else
valBytes = EMPTY_BYTES;
@@ -1445,7 +1460,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = Entry.readKeyLength(addr, mem);
int valLen = Entry.readValueLength(addr, mem);
- return new IgniteBiTuple<>(addr + HEADER + keyLen, valLen);
+ return new IgniteBiTuple<>(addr + HEADER_SIZE + keyLen, valLen);
}
addr = Entry.nextAddress(addr, mem);
@@ -1510,7 +1525,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = Entry.readKeyLength(addr, mem);
int valLen = Entry.readValueLength(addr, mem);
- return mem.readBytes(addr + HEADER + keyLen, valLen);
+ return mem.readBytes(addr + HEADER_SIZE + keyLen, valLen);
}
}
@@ -1570,7 +1585,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Entry memory size.
*/
static int size(byte[] keyBytes, byte[] valBytes) {
- return HEADER + keyBytes.length + valBytes.length;
+ return HEADER_SIZE + keyBytes.length + valBytes.length;
}
/**
@@ -1579,7 +1594,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Entry size.
*/
static int size(long addr, GridUnsafeMemory mem) {
- return HEADER + readKeyLength(addr, mem) + readValueLength(addr, mem);
+ return HEADER_SIZE + readKeyLength(addr, mem) + readValueLength(addr, mem);
}
/**
@@ -1588,7 +1603,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Hash.
*/
static int hash(long ptr, GridUnsafeMemory mem) {
- return mem.readInt(ptr);
+ return mem.readInt(ptr + HEADER_HASH_OFF);
}
/**
@@ -1597,7 +1612,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void hash(long ptr, int hash, GridUnsafeMemory mem) {
- mem.writeInt(ptr, hash);
+ mem.writeInt(ptr + HEADER_HASH_OFF, hash);
}
/**
@@ -1606,7 +1621,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Key length.
*/
static int readKeyLength(long ptr, GridUnsafeMemory mem) {
- int len = mem.readInt(ptr + 4);
+ int len = mem.readInt(ptr + HEADER_KEY_SIZE_OFF);
assert len >= 0 : "Invalid key length [addr=" + String.format("0x%08x", ptr) +
", len=" + Long.toHexString(len) + ']';
@@ -1622,7 +1637,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void writeKeyLength(long ptr, int len, GridUnsafeMemory mem) {
- mem.writeInt(ptr + 4, len);
+ mem.writeInt(ptr + HEADER_KEY_SIZE_OFF, len);
}
/**
@@ -1631,7 +1646,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Value length.
*/
static int readValueLength(long ptr, GridUnsafeMemory mem) {
- int len = mem.readInt(ptr + 8);
+ int len = mem.readInt(ptr + HEADER_VALUE_SIZE);
assert len >= 0 : "Invalid value length [addr=" + String.format("0x%08x", ptr) +
", len=" + Integer.toHexString(len) + ']';
@@ -1647,7 +1662,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void writeValueLength(long ptr, int len, GridUnsafeMemory mem) {
- mem.writeInt(ptr + 8, len);
+ mem.writeInt(ptr + HEADER_VALUE_SIZE, len);
}
/**
@@ -1656,7 +1671,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Queue address.
*/
static long queueAddress(long ptr, GridUnsafeMemory mem) {
- return mem.readLong(ptr + 12);
+ return mem.readLong(ptr + HEADER_QUEUE_ADDR_OFF);
}
/**
@@ -1665,7 +1680,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void queueAddress(long ptr, long qAddr, GridUnsafeMemory mem) {
- mem.writeLong(ptr + 12, qAddr);
+ mem.writeLong(ptr + HEADER_QUEUE_ADDR_OFF, qAddr);
}
/**
@@ -1675,7 +1690,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return {@code True} if changed to zero.
*/
static boolean clearQueueAddress(long ptr, long qAddr, GridUnsafeMemory mem) {
- return mem.casLong(ptr + 12, qAddr, 0);
+ return mem.casLong(ptr + HEADER_QUEUE_ADDR_OFF, qAddr, 0);
}
/**
@@ -1684,7 +1699,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @return Next address.
*/
static long nextAddress(long ptr, GridUnsafeMemory mem) {
- return mem.readLong(ptr + 20);
+ return mem.readLong(ptr + HEADER_NEXT_ADDR_OFF);
}
/**
@@ -1695,7 +1710,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void nextAddress(long ptr, long addr, GridUnsafeMemory mem) {
- mem.writeLong(ptr + 20, addr);
+ mem.writeLong(ptr + HEADER_NEXT_ADDR_OFF, addr);
}
/**
@@ -1706,7 +1721,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
static byte[] readKeyBytes(long ptr, GridUnsafeMemory mem) {
int keyLen = readKeyLength(ptr, mem);
- return mem.readBytes(ptr + HEADER, keyLen);
+ return mem.readBytes(ptr + HEADER_SIZE, keyLen);
}
/**
@@ -1715,7 +1730,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void writeKeyBytes(long ptr, byte[] keyBytes, GridUnsafeMemory mem) {
- mem.writeBytes(ptr + HEADER, keyBytes);
+ mem.writeBytes(ptr + HEADER_SIZE, keyBytes);
}
/**
@@ -1727,7 +1742,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
int keyLen = readKeyLength(ptr, mem);
int valLen = readValueLength(ptr, mem);
- return mem.readBytes(ptr + HEADER + keyLen, valLen);
+ return mem.readBytes(ptr + HEADER_SIZE + keyLen, valLen);
}
/**
@@ -1746,7 +1761,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
* @param mem Memory.
*/
static void writeValueBytes(long ptr, int keyLen, byte[] valBytes, GridUnsafeMemory mem) {
- mem.writeBytes(ptr + HEADER + keyLen, valBytes);
+ mem.writeBytes(ptr + HEADER_SIZE + keyLen, valBytes);
}
/**
@@ -1799,7 +1814,7 @@ public class GridUnsafeMap implements GridOffHeapMap {
static boolean keyEquals(long ptr, byte[] keyBytes, GridUnsafeMemory mem) {
long len = readKeyLength(ptr, mem);
- return len == keyBytes.length && mem.compare(ptr + HEADER, keyBytes);
+ return len == keyBytes.length && GridUnsafeMemory.compare(ptr + HEADER_SIZE, keyBytes);
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
index cf0cb5c..87ba2f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMemory.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.util.offheap.GridOffHeapOutOfMemoryException;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteBiTuple;
-import sun.misc.Unsafe;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_OFFHEAP_SAFE_RELEASE;
import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.ALLOCATE;
@@ -35,18 +34,9 @@ import static org.apache.ignite.internal.util.offheap.GridOffHeapEvent.RELEASE;
* Unsafe memory.
*/
public class GridUnsafeMemory {
- /** Unsafe handle. */
- public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Free byte. */
private static final byte FREE = (byte)0;
- /** Byte array offset. */
- public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Address size. */
- private static final int ADDR_SIZE = UNSAFE.addressSize();
-
/** Safe offheap release flag. */
private static final boolean SAFE_RELEASE = IgniteSystemProperties.getBoolean(IGNITE_OFFHEAP_SAFE_RELEASE);
@@ -174,7 +164,7 @@ public class GridUnsafeMemory {
cnt.addAndGet(size);
try {
- long ptr = UNSAFE.allocateMemory(size);
+ long ptr = GridUnsafe.allocateMemory(size);
if (init)
fill(ptr, size, FREE);
@@ -198,7 +188,7 @@ public class GridUnsafeMemory {
* @param b Value.
*/
public void fill(long ptr, long size, byte b) {
- UNSAFE.setMemory(ptr, size, b);
+ GridUnsafe.setMemory(ptr, size, b);
}
/**
@@ -233,7 +223,7 @@ public class GridUnsafeMemory {
if (SAFE_RELEASE)
fill(ptr, size, (byte)0xAB);
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
cnt.addAndGet(-size);
@@ -247,7 +237,7 @@ public class GridUnsafeMemory {
* @return Long value.
*/
public long readLong(long ptr) {
- return UNSAFE.getLong(ptr);
+ return GridUnsafe.getLong(ptr);
}
/**
@@ -255,7 +245,7 @@ public class GridUnsafeMemory {
* @param v Long value.
*/
public void writeLong(long ptr, long v) {
- UNSAFE.putLong(ptr, v);
+ GridUnsafe.putLong(ptr, v);
}
/**
@@ -263,7 +253,7 @@ public class GridUnsafeMemory {
* @return Long value.
*/
public long readLongVolatile(long ptr) {
- return UNSAFE.getLongVolatile(null, ptr);
+ return GridUnsafe.getLongVolatile(null, ptr);
}
/**
@@ -271,7 +261,7 @@ public class GridUnsafeMemory {
* @param v Long value.
*/
public void writeLongVolatile(long ptr, long v) {
- UNSAFE.putLongVolatile(null, ptr, v);
+ GridUnsafe.putLongVolatile(null, ptr, v);
}
/**
@@ -281,7 +271,7 @@ public class GridUnsafeMemory {
* @return {@code true} If operation succeeded.
*/
public boolean casLong(long ptr, long exp, long v) {
- return UNSAFE.compareAndSwapLong(null, ptr, exp, v);
+ return GridUnsafe.compareAndSwapLong(null, ptr, exp, v);
}
/**
@@ -289,7 +279,7 @@ public class GridUnsafeMemory {
* @return Integer value.
*/
public int readInt(long ptr) {
- return UNSAFE.getInt(ptr);
+ return GridUnsafe.getInt(ptr);
}
/**
@@ -297,7 +287,7 @@ public class GridUnsafeMemory {
* @param v Integer value.
*/
public void writeInt(long ptr, int v) {
- UNSAFE.putInt(ptr, v);
+ GridUnsafe.putInt(ptr, v);
}
/**
@@ -305,7 +295,7 @@ public class GridUnsafeMemory {
* @return Integer value.
*/
public int readIntVolatile(long ptr) {
- return UNSAFE.getIntVolatile(null, ptr);
+ return GridUnsafe.getIntVolatile(null, ptr);
}
/**
@@ -313,7 +303,7 @@ public class GridUnsafeMemory {
* @param v Integer value.
*/
public void writeIntVolatile(long ptr, int v) {
- UNSAFE.putIntVolatile(null, ptr, v);
+ GridUnsafe.putIntVolatile(null, ptr, v);
}
/**
@@ -323,7 +313,7 @@ public class GridUnsafeMemory {
* @return {@code true} If operation succeeded.
*/
public boolean casInt(long ptr, int exp, int v) {
- return UNSAFE.compareAndSwapInt(null, ptr, exp, v);
+ return GridUnsafe.compareAndSwapInt(null, ptr, exp, v);
}
/**
@@ -331,7 +321,7 @@ public class GridUnsafeMemory {
* @return Float value.
*/
public float readFloat(long ptr) {
- return UNSAFE.getFloat(ptr);
+ return GridUnsafe.getFloat(ptr);
}
/**
@@ -339,7 +329,7 @@ public class GridUnsafeMemory {
* @param v Value.
*/
public void writeFloat(long ptr, float v) {
- UNSAFE.putFloat(ptr, v);
+ GridUnsafe.putFloat(ptr, v);
}
/**
@@ -347,7 +337,7 @@ public class GridUnsafeMemory {
* @return Double value.
*/
public double readDouble(long ptr) {
- return UNSAFE.getDouble(ptr);
+ return GridUnsafe.getDouble(ptr);
}
/**
@@ -355,7 +345,7 @@ public class GridUnsafeMemory {
* @param v Value.
*/
public void writeDouble(long ptr, double v) {
- UNSAFE.putDouble(ptr, v);
+ GridUnsafe.putDouble(ptr, v);
}
/**
@@ -363,7 +353,7 @@ public class GridUnsafeMemory {
* @return Short value.
*/
public short readShort(long ptr) {
- return UNSAFE.getShort(ptr);
+ return GridUnsafe.getShort(ptr);
}
/**
@@ -371,7 +361,7 @@ public class GridUnsafeMemory {
* @param v Short value.
*/
public void writeShort(long ptr, short v) {
- UNSAFE.putShort(ptr, v);
+ GridUnsafe.putShort(ptr, v);
}
/**
@@ -379,7 +369,7 @@ public class GridUnsafeMemory {
* @return Integer value.
*/
public byte readByte(long ptr) {
- return UNSAFE.getByte(ptr);
+ return GridUnsafe.getByte(ptr);
}
/**
@@ -387,7 +377,7 @@ public class GridUnsafeMemory {
* @return Integer value.
*/
public byte readByteVolatile(long ptr) {
- return UNSAFE.getByteVolatile(null, ptr);
+ return GridUnsafe.getByteVolatile(null, ptr);
}
/**
@@ -395,7 +385,7 @@ public class GridUnsafeMemory {
* @param v Integer value.
*/
public void writeByte(long ptr, byte v) {
- UNSAFE.putByte(ptr, v);
+ GridUnsafe.putByte(ptr, v);
}
/**
@@ -403,7 +393,7 @@ public class GridUnsafeMemory {
* @param v Integer value.
*/
public void writeByteVolatile(long ptr, byte v) {
- UNSAFE.putByteVolatile(null, ptr, v);
+ GridUnsafe.putByteVolatile(null, ptr, v);
}
/**
@@ -483,8 +473,8 @@ public class GridUnsafeMemory {
int words = size / 8;
for (int i = 0; i < words; i++) {
- long w1 = UNSAFE.getLong(ptr1);
- long w2 = UNSAFE.getLong(ptr2);
+ long w1 = GridUnsafe.getLong(ptr1);
+ long w2 = GridUnsafe.getLong(ptr2);
if (w1 != w2)
return false;
@@ -496,8 +486,8 @@ public class GridUnsafeMemory {
int left = size % 8;
for (int i = 0; i < left; i++) {
- byte b1 = UNSAFE.getByte(ptr1);
- byte b2 = UNSAFE.getByte(ptr2);
+ byte b1 = GridUnsafe.getByte(ptr1);
+ byte b2 = GridUnsafe.getByte(ptr2);
if (b1 != b2)
return false;
@@ -517,7 +507,7 @@ public class GridUnsafeMemory {
* @return {@code True} if equals.
*/
public static boolean compare(long ptr, byte[] bytes) {
- final int addrSize = ADDR_SIZE;
+ final int addrSize = GridUnsafe.ADDR_SIZE;
// Align reads to address size.
int off = (int)(ptr % addrSize);
@@ -527,7 +517,7 @@ public class GridUnsafeMemory {
if (align != addrSize) {
for (int i = 0; i < align && i < len; i++) {
- if (UNSAFE.getByte(ptr) != bytes[i])
+ if (GridUnsafe.getByte(ptr) != bytes[i])
return false;
ptr++;
@@ -550,19 +540,14 @@ public class GridUnsafeMemory {
for (int i = 0; i < words; i++) {
int step = i * addrSize + align;
- int word = UNSAFE.getInt(ptr);
+ int word = GridUnsafe.getInt(ptr);
- int comp = 0;
-
- comp |= (0xffL & bytes[step + 3]) << 24;
- comp |= (0xffL & bytes[step + 2]) << 16;
- comp |= (0xffL & bytes[step + 1]) << 8;
- comp |= (0xffL & bytes[step]);
+ int comp = GridUnsafe.getInt(bytes, GridUnsafe.BYTE_ARR_OFF + step);
if (word != comp)
return false;
- ptr += ADDR_SIZE;
+ ptr += GridUnsafe.ADDR_SIZE;
}
break;
@@ -571,23 +556,14 @@ public class GridUnsafeMemory {
for (int i = 0; i < words; i++) {
int step = i * addrSize + align;
- long word = UNSAFE.getLong(ptr);
-
- long comp = 0;
+ long word = GridUnsafe.getLong(ptr);
- comp |= (0xffL & bytes[step + 7]) << 56;
- comp |= (0xffL & bytes[step + 6]) << 48;
- comp |= (0xffL & bytes[step + 5]) << 40;
- comp |= (0xffL & bytes[step + 4]) << 32;
- comp |= (0xffL & bytes[step + 3]) << 24;
- comp |= (0xffL & bytes[step + 2]) << 16;
- comp |= (0xffL & bytes[step + 1]) << 8;
- comp |= (0xffL & bytes[step]);
+ long comp = GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + step);
if (word != comp)
return false;
- ptr += ADDR_SIZE;
+ ptr += GridUnsafe.ADDR_SIZE;
}
break;
@@ -596,7 +572,7 @@ public class GridUnsafeMemory {
if (left != 0) {
// Compare left overs byte by byte.
for (int i = 0; i < left; i++)
- if (UNSAFE.getByte(ptr + i) != bytes[i + align + words * ADDR_SIZE])
+ if (GridUnsafe.getByte(ptr + i) != bytes[i + align + words * GridUnsafe.ADDR_SIZE])
return false;
}
@@ -618,7 +594,7 @@ public class GridUnsafeMemory {
* @return The same array as passed in one.
*/
public byte[] readBytes(long ptr, byte[] arr) {
- UNSAFE.copyMemory(null, ptr, arr, BYTE_ARR_OFF, arr.length);
+ GridUnsafe.copyMemory(null, ptr, arr, GridUnsafe.BYTE_ARR_OFF, arr.length);
return arr;
}
@@ -631,7 +607,7 @@ public class GridUnsafeMemory {
* @return The same array as passed in one.
*/
public byte[] readBytes(long ptr, byte[] arr, int off, int len) {
- UNSAFE.copyMemory(null, ptr, arr, BYTE_ARR_OFF + off, len);
+ GridUnsafe.copyMemory(null, ptr, arr, GridUnsafe.BYTE_ARR_OFF + off, len);
return arr;
}
@@ -643,7 +619,7 @@ public class GridUnsafeMemory {
* @param arr Array.
*/
public void writeBytes(long ptr, byte[] arr) {
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
}
/**
@@ -655,7 +631,7 @@ public class GridUnsafeMemory {
* @param len Length.
*/
public void writeBytes(long ptr, byte[] arr, int off, int len) {
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF + off, null, ptr, len);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF + off, null, ptr, len);
}
/**
@@ -666,7 +642,7 @@ public class GridUnsafeMemory {
* @param len Length in bytes.
*/
public void copyMemory(long srcPtr, long destPtr, long len) {
- UNSAFE.copyMemory(srcPtr, destPtr, len);
+ GridUnsafe.copyMemory(srcPtr, destPtr, len);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
index a4f4cdc..c5be139 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
@@ -47,7 +47,6 @@ import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.MarshallerExclusions;
-import sun.misc.Unsafe;
import static java.lang.reflect.Modifier.isFinal;
import static java.lang.reflect.Modifier.isPrivate;
@@ -92,9 +91,6 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.co
* Class descriptor.
*/
class OptimizedClassDescriptor {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Class. */
private final Class<?> cls;
@@ -273,7 +269,7 @@ class OptimizedClassDescriptor {
type = PROPS;
try {
- dfltsFieldOff = UNSAFE.objectFieldOffset(Properties.class.getDeclaredField("defaults"));
+ dfltsFieldOff = GridUnsafe.objectFieldOffset(Properties.class.getDeclaredField("defaults"));
}
catch (NoSuchFieldException e) {
throw new IOException(e);
@@ -285,7 +281,7 @@ class OptimizedClassDescriptor {
type = HASH_MAP;
try {
- loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+ loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
}
catch (NoSuchFieldException e) {
throw new IOException(e);
@@ -295,7 +291,7 @@ class OptimizedClassDescriptor {
type = HASH_SET;
try {
- loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+ loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
}
catch (NoSuchFieldException e) {
throw new IOException(e);
@@ -307,8 +303,10 @@ class OptimizedClassDescriptor {
type = LINKED_HASH_MAP;
try {
- loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
- accessOrderFieldOff = UNSAFE.objectFieldOffset(LinkedHashMap.class.getDeclaredField("accessOrder"));
+ loadFactorFieldOff =
+ GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+ accessOrderFieldOff =
+ GridUnsafe.objectFieldOffset(LinkedHashMap.class.getDeclaredField("accessOrder"));
}
catch (NoSuchFieldException e) {
throw new IOException(e);
@@ -318,7 +316,7 @@ class OptimizedClassDescriptor {
type = LINKED_HASH_SET;
try {
- loadFactorFieldOff = UNSAFE.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
+ loadFactorFieldOff = GridUnsafe.objectFieldOffset(HashMap.class.getDeclaredField("loadFactor"));
}
catch (NoSuchFieldException e) {
throw new IOException(e);
@@ -472,7 +470,7 @@ class OptimizedClassDescriptor {
fieldInfo = new FieldInfo(f,
serField.getName(),
- UNSAFE.objectFieldOffset(f),
+ GridUnsafe.objectFieldOffset(f),
fieldType(serField.getType()));
}
@@ -496,7 +494,7 @@ class OptimizedClassDescriptor {
if (!isStatic(mod) && !isTransient(mod)) {
FieldInfo fieldInfo = new FieldInfo(f, f.getName(),
- UNSAFE.objectFieldOffset(f), fieldType(f.getType()));
+ GridUnsafe.objectFieldOffset(f), fieldType(f.getType()));
clsFields.add(fieldInfo);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
index b2c98b2..b3caca2 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteSystemProperties;
-import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.AbstractMarshaller;
import org.jetbrains.annotations.Nullable;
@@ -274,9 +273,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
@SuppressWarnings({"TypeParameterExtendsFinalClass", "ErrorNotRethrown"})
public static boolean available() {
try {
- Unsafe unsafe = GridUnsafe.unsafe();
-
- Class<? extends Unsafe> unsafeCls = unsafe.getClass();
+ Class<? extends Unsafe> unsafeCls = Unsafe.class;
unsafeCls.getMethod("allocateInstance", Class.class);
unsafeCls.getMethod("copyMemory", Object.class, long.class, Object.class, long.class, long.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index da92b90..fa6f962 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -34,16 +34,12 @@ import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.jdk.JdkMarshaller;
-import sun.misc.Unsafe;
/**
* Miscellaneous utility methods to facilitate {@link OptimizedMarshaller}.
*/
class OptimizedMarshallerUtils {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
static final long HASH_SET_MAP_OFF;
/** */
@@ -158,12 +154,12 @@ class OptimizedMarshallerUtils {
long mapOff;
try {
- mapOff = UNSAFE.objectFieldOffset(HashSet.class.getDeclaredField("map"));
+ mapOff = GridUnsafe.objectFieldOffset(HashSet.class.getDeclaredField("map"));
}
catch (NoSuchFieldException e) {
try {
// Workaround for legacy IBM JRE.
- mapOff = UNSAFE.objectFieldOffset(HashSet.class.getDeclaredField("backingMap"));
+ mapOff = GridUnsafe.objectFieldOffset(HashSet.class.getDeclaredField("backingMap"));
}
catch (NoSuchFieldException e2) {
throw new IgniteException("Initialization failure.", e2);
@@ -358,7 +354,7 @@ class OptimizedMarshallerUtils {
* @return Byte value.
*/
static byte getByte(Object obj, long off) {
- return UNSAFE.getByte(obj, off);
+ return GridUnsafe.getByteField(obj, off);
}
/**
@@ -369,7 +365,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setByte(Object obj, long off, byte val) {
- UNSAFE.putByte(obj, off, val);
+ GridUnsafe.putByteField(obj, off, val);
}
/**
@@ -380,7 +376,7 @@ class OptimizedMarshallerUtils {
* @return Short value.
*/
static short getShort(Object obj, long off) {
- return UNSAFE.getShort(obj, off);
+ return GridUnsafe.getShortField(obj, off);
}
/**
@@ -391,7 +387,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setShort(Object obj, long off, short val) {
- UNSAFE.putShort(obj, off, val);
+ GridUnsafe.putShortField(obj, off, val);
}
/**
@@ -402,7 +398,7 @@ class OptimizedMarshallerUtils {
* @return Integer value.
*/
static int getInt(Object obj, long off) {
- return UNSAFE.getInt(obj, off);
+ return GridUnsafe.getIntField(obj, off);
}
/**
@@ -413,7 +409,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setInt(Object obj, long off, int val) {
- UNSAFE.putInt(obj, off, val);
+ GridUnsafe.putIntField(obj, off, val);
}
/**
@@ -424,7 +420,7 @@ class OptimizedMarshallerUtils {
* @return Long value.
*/
static long getLong(Object obj, long off) {
- return UNSAFE.getLong(obj, off);
+ return GridUnsafe.getLongField(obj, off);
}
/**
@@ -435,7 +431,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setLong(Object obj, long off, long val) {
- UNSAFE.putLong(obj, off, val);
+ GridUnsafe.putLongField(obj, off, val);
}
/**
@@ -446,7 +442,7 @@ class OptimizedMarshallerUtils {
* @return Float value.
*/
static float getFloat(Object obj, long off) {
- return UNSAFE.getFloat(obj, off);
+ return GridUnsafe.getFloatField(obj, off);
}
/**
@@ -457,7 +453,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setFloat(Object obj, long off, float val) {
- UNSAFE.putFloat(obj, off, val);
+ GridUnsafe.putFloatField(obj, off, val);
}
/**
@@ -468,7 +464,7 @@ class OptimizedMarshallerUtils {
* @return Double value.
*/
static double getDouble(Object obj, long off) {
- return UNSAFE.getDouble(obj, off);
+ return GridUnsafe.getDoubleField(obj, off);
}
/**
@@ -479,7 +475,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setDouble(Object obj, long off, double val) {
- UNSAFE.putDouble(obj, off, val);
+ GridUnsafe.putDoubleField(obj, off, val);
}
/**
@@ -490,7 +486,7 @@ class OptimizedMarshallerUtils {
* @return Char value.
*/
static char getChar(Object obj, long off) {
- return UNSAFE.getChar(obj, off);
+ return GridUnsafe.getCharField(obj, off);
}
/**
@@ -501,7 +497,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setChar(Object obj, long off, char val) {
- UNSAFE.putChar(obj, off, val);
+ GridUnsafe.putCharField(obj, off, val);
}
/**
@@ -512,7 +508,7 @@ class OptimizedMarshallerUtils {
* @return Boolean value.
*/
static boolean getBoolean(Object obj, long off) {
- return UNSAFE.getBoolean(obj, off);
+ return GridUnsafe.getBooleanField(obj, off);
}
/**
@@ -523,7 +519,7 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setBoolean(Object obj, long off, boolean val) {
- UNSAFE.putBoolean(obj, off, val);
+ GridUnsafe.putBooleanField(obj, off, val);
}
/**
@@ -534,7 +530,7 @@ class OptimizedMarshallerUtils {
* @return Value.
*/
static Object getObject(Object obj, long off) {
- return UNSAFE.getObject(obj, off);
+ return GridUnsafe.getObjectField(obj, off);
}
/**
@@ -545,6 +541,6 @@ class OptimizedMarshallerUtils {
* @param val Value.
*/
static void setObject(Object obj, long off, Object val) {
- UNSAFE.putObject(obj, off, val);
+ GridUnsafe.putObjectField(obj, off, val);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index ce9ee0b..988a777 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -45,7 +45,6 @@ import org.apache.ignite.internal.util.io.GridDataInput;
import org.apache.ignite.internal.util.typedef.internal.SB;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.marshaller.MarshallerContext;
-import sun.misc.Unsafe;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.ARRAY_LIST;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.BOOLEAN;
@@ -98,9 +97,6 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.se
* Optimized object input stream.
*/
class OptimizedObjectInputStream extends ObjectInputStream {
- /** Unsafe. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Dummy object for HashSet. */
private static final Object DUMMY = new Object();
@@ -544,7 +540,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
Object obj;
try {
- obj = UNSAFE.allocateInstance(cls);
+ obj = GridUnsafe.allocateInstance(cls);
}
catch (InstantiationException e) {
throw new IOException(e);
@@ -642,7 +638,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
@SuppressWarnings("unchecked")
HashSet<?> readHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
try {
- HashSet<Object> set = (HashSet<Object>)UNSAFE.allocateInstance(HashSet.class);
+ HashSet<Object> set = (HashSet<Object>)GridUnsafe.allocateInstance(HashSet.class);
handles.assign(set);
@@ -714,7 +710,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
@SuppressWarnings("unchecked")
LinkedHashSet<?> readLinkedHashSet(long mapFieldOff) throws ClassNotFoundException, IOException {
try {
- LinkedHashSet<Object> set = (LinkedHashSet<Object>)UNSAFE.allocateInstance(LinkedHashSet.class);
+ LinkedHashSet<Object> set = (LinkedHashSet<Object>)GridUnsafe.allocateInstance(LinkedHashSet.class);
handles.assign(set);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java b/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
index de09e06..983afde 100644
--- a/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/GridTestIoUtils.java
@@ -40,7 +40,6 @@ import static junit.framework.Assert.fail;
* IO test utilities.
*/
public final class GridTestIoUtils {
-
/**
* Serializes a given object into byte array.
*
@@ -187,6 +186,122 @@ public final class GridTestIoUtils {
assertEquals(expSize.longValue(), pos);
}
+ /**
+ * Gets short value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static short getShortByByteLE(byte[] arr) {
+ return getShortByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets short value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static short getShortByByteLE(byte[] arr, int off) {
+ return (short)((arr[off] & 0xff) | arr[off + 1] << 8);
+ }
+
+ /**
+ * Gets char value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static char getCharByByteLE(byte[] arr) {
+ return getCharByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets char value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static char getCharByByteLE(byte[] arr, int off) {
+ return (char)((arr[off] & 0xff) | arr[off + 1] << 8);
+ }
+
+ /**
+ * Gets integer value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static int getIntByByteLE(byte[] arr) {
+ return getIntByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets integer value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static int getIntByByteLE(byte[] arr, int off) {
+ return ((int)arr[off] & 0xff) | ((int)arr[off + 1] & 0xff) << 8 |
+ ((int)arr[off + 2] & 0xff) << 16 | ((int)arr[off + 3] & 0xff) << 24;
+ }
+
+ /**
+ * Gets long value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static long getLongByByteLE(byte[] arr) {
+ return getLongByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets long value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static long getLongByByteLE(byte[] arr, int off) {
+ return ((long)arr[off] & 0xff) | ((long)arr[off + 1] & 0xff) << 8 | ((long)arr[off + 2] & 0xff) << 16 |
+ ((long)arr[off + 3] & 0xff) << 24 | ((long)arr[off + 4] & 0xff) << 32 | ((long)arr[off + 5] & 0xff) << 40 |
+ ((long)arr[off + 6] & 0xff) << 48 | ((long)arr[off + 7] & 0xff) << 56;
+ }
+
+ /**
+ * Gets float value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static float getFloatByByteLE(byte[] arr) {
+ return getFloatByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets float value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static float getFloatByByteLE(byte[] arr, int off) {
+ return Float.intBitsToFloat(getIntByByteLE(arr, off));
+ }
+
+ /**
+ * Gets double value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ */
+ public static double getDoubleByByteLE(byte[] arr) {
+ return getDoubleByByteLE(arr, 0);
+ }
+
+ /**
+ * Gets double value from byte array assuming that value stored in little-endian byte order.
+ *
+ * @param arr Byte array.
+ * @param off Offset.
+ */
+ public static double getDoubleByByteLE(byte[] arr, int off) {
+ return Double.longBitsToDouble(getLongByByteLE(arr, off));
+ }
/**
* Closes resource.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
index 0515685..a75023f 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinitySelfTest.java
@@ -116,7 +116,7 @@ public class GridAffinitySelfTest extends GridCommonAbstractTest {
return F.view(Arrays.asList(g.configuration().getCacheConfiguration()), new IgnitePredicate<CacheConfiguration>() {
@Override public boolean apply(CacheConfiguration c) {
return !CU.MARSH_CACHE_NAME.equals(c.getName()) && !CU.UTILITY_CACHE_NAME.equals(c.getName()) &&
- !CU.ATOMICS_CACHE_NAME.equals(c.getName());
+ !CU.ATOMICS_CACHE_NAME.equals(c.getName()) && !CU.SYS_CACHE_HADOOP_MR.equals(c.getName());
}
});
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
index 87cc527..1546252 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFieldsOffheapSelfTest.java
@@ -19,18 +19,11 @@ package org.apache.ignite.internal.binary;
import org.apache.ignite.internal.util.GridUnsafe;
import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
/**
* Field tests for heap-based binaries.
*/
public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
- /** Unsafe instance. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Byte array offset for unsafe mechanics. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
/** Allocated unsafe pointer. */
private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
@@ -40,7 +33,7 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
// Cleanup allocated objects.
for (Long ptr : ptrs)
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
ptrs.clear();
}
@@ -49,11 +42,11 @@ public class BinaryFieldsOffheapSelfTest extends BinaryFieldsAbstractSelfTest {
@Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
- long ptr = UNSAFE.allocateMemory(arr.length);
+ long ptr = GridUnsafe.allocateMemory(arr.length);
ptrs.add(ptr);
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
return new BinaryObjectOffheapImpl(binaryContext(marsh), ptr, 0, arr.length);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
index fe9ba17..796c027 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryFooterOffsetsOffheapSelfTest.java
@@ -19,18 +19,11 @@ package org.apache.ignite.internal.binary;
import org.apache.ignite.internal.util.GridUnsafe;
import org.eclipse.jetty.util.ConcurrentHashSet;
-import sun.misc.Unsafe;
/**
* Compact offsets tests for offheap binary objects.
*/
public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstractSelfTest {
- /** Unsafe instance. */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Byte array offset for unsafe mechanics. */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
/** Allocated unsafe pointer. */
private final ConcurrentHashSet<Long> ptrs = new ConcurrentHashSet<>();
@@ -40,7 +33,7 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
// Cleanup allocated objects.
for (Long ptr : ptrs)
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
ptrs.clear();
}
@@ -49,11 +42,11 @@ public class BinaryFooterOffsetsOffheapSelfTest extends BinaryFooterOffsetsAbstr
@Override protected BinaryObjectExImpl toBinary(BinaryMarshaller marsh, Object obj) throws Exception {
byte[] arr = marsh.marshal(obj);
- long ptr = UNSAFE.allocateMemory(arr.length);
+ long ptr = GridUnsafe.allocateMemory(arr.length);
ptrs.add(ptr);
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
return new BinaryObjectOffheapImpl(ctx, ptr, 0, arr.length);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
index fa0f9a7..37b908a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java
@@ -88,7 +88,6 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import sun.misc.Unsafe;
import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
import static org.junit.Assert.assertArrayEquals;
@@ -99,12 +98,6 @@ import static org.junit.Assert.assertNotEquals;
*/
@SuppressWarnings({"OverlyStrongTypeCast", "ArrayHashCode", "ConstantConditions"})
public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
/**
* @throws Exception If failed.
*/
@@ -2378,13 +2371,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertFalse(offheapObj2.equals(offheapObj));
}
finally {
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
if (ptr1 > 0)
- UNSAFE.freeMemory(ptr1);
+ GridUnsafe.freeMemory(ptr1);
if (ptr2 > 0)
- UNSAFE.freeMemory(ptr2);
+ GridUnsafe.freeMemory(ptr2);
}
}
@@ -2975,9 +2968,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
private long copyOffheap(BinaryObjectImpl obj) {
byte[] arr = obj.array();
- long ptr = UNSAFE.allocateMemory(arr.length);
+ long ptr = GridUnsafe.allocateMemory(arr.length);
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr, arr.length);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr, arr.length);
return ptr;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
index 059703e..990c928 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -46,7 +46,8 @@ import org.apache.ignite.internal.util.GridUnsafe;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import sun.misc.Unsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
/**
* Binary builder test.
@@ -54,12 +55,6 @@ import sun.misc.Unsafe;
@SuppressWarnings("ResultOfMethodCallIgnored")
public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstractTest {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
private static IgniteConfiguration cfg;
/** {@inheritDoc} */
@@ -766,16 +761,21 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
- long ptr = UNSAFE.allocateMemory(arr.length + 5);
+ long ptr = GridUnsafe.allocateMemory(arr.length + 5);
try {
long ptr0 = ptr;
- UNSAFE.putBoolean(null, ptr0++, false);
+ GridUnsafe.putBoolean(null, ptr0++, false);
+
+ int len = arr.length;
- UNSAFE.putInt(ptr0, arr.length);
+ if (BIG_ENDIAN)
+ GridUnsafe.putIntLE(ptr0, len);
+ else
+ GridUnsafe.putInt(ptr0, len);
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
+ GridUnsafe.copyMemory(arr, GridUnsafe.BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
BinaryObject offheapObj = (BinaryObject)
((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
@@ -801,7 +801,7 @@ public class BinaryObjectBuilderDefaultMappersSelfTest extends GridCommonAbstrac
assertEquals(offheapObj, po);
}
finally {
- UNSAFE.freeMemory(ptr);
+ GridUnsafe.freeMemory(ptr);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
index ae615b1..5ddb87d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/mutabletest/GridBinaryTestClasses.java
@@ -31,14 +31,13 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
-
import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryReader;
import org.apache.ignite.binary.BinaryWriter;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.util.lang.GridMapEntry;
-import org.apache.ignite.binary.BinaryObject;
/**
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..c68a886
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/AbstractBinaryStreamByteOrderSelfTest.java
@@ -0,0 +1,464 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.binary.streams;
+
+import java.util.Random;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Assert;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+
+/**
+ * Binary input/output streams byte order sanity tests.
+ */
+public abstract class AbstractBinaryStreamByteOrderSelfTest extends GridCommonAbstractTest {
+ /** Array length. */
+ protected static final int ARR_LEN = 16;
+
+ /** Rnd. */
+ private static final Random RND = new Random();
+
+ /** Out. */
+ protected BinaryAbstractOutputStream out;
+
+ /** In. */
+ protected BinaryAbstractInputStream in;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ super.beforeTest();
+
+ init();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ out.close();
+ }
+
+ /**
+ * Initializes streams.
+ */
+ protected abstract void init();
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ short val = (short)RND.nextLong();
+
+ reset();
+
+ out.unsafeWriteShort(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readShort());
+
+ reset();
+
+ out.unsafeWriteShort(0, val);
+ out.shift(2);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readShortFast());
+
+ reset();
+
+ out.writeShortFast(val);
+ out.shift(2);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readShortPositioned(0));
+
+ reset();
+
+ out.writeShort(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readShortPositioned(0));
+
+ reset();
+
+ out.writeShort(0, val);
+ out.shift(2);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readShortPositioned(0));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArray() throws Exception {
+ short[] arr = new short[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (short)RND.nextLong();
+
+ out.writeShortArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getShortByByteLE(outArr, i * 2));
+
+ Assert.assertArrayEquals(arr, in.readShortArray(ARR_LEN));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testChar() throws Exception {
+ char val = (char)RND.nextLong();
+
+ reset();
+
+ out.unsafeWriteChar(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readChar());
+
+ reset();
+
+ out.writeCharFast(val);
+ out.shift(2);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readCharFast());
+
+ reset();
+
+ out.writeChar(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readChar());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArray() throws Exception {
+ char[] arr = new char[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (char)RND.nextLong();
+
+ out.writeCharArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getCharByByteLE(outArr, i * 2));
+
+ Assert.assertArrayEquals(arr, in.readCharArray(ARR_LEN));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testInt() throws Exception {
+ int val = RND.nextInt();
+
+ reset();
+
+ out.unsafeWriteInt(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readInt());
+
+ reset();
+
+ out.unsafeWriteInt(0, val);
+ out.shift(4);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readIntFast());
+
+ reset();
+
+ out.writeIntFast(val);
+ out.shift(4);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readIntPositioned(0));
+
+ reset();
+
+ out.writeInt(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readIntPositioned(0));
+
+ reset();
+
+ out.writeInt(0, val);
+ out.shift(4);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readIntPositioned(0));
+
+ reset();
+
+ out.writeIntArray(new int[] {val});
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readIntArray(1)[0]);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArray() throws Exception {
+ int[] arr = new int[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextInt();
+
+ out.writeIntArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getIntByByteLE(outArr, i * 4));
+
+ Assert.assertArrayEquals(arr, in.readIntArray(ARR_LEN));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLong() throws Exception {
+ long val = RND.nextLong();
+
+ reset();
+
+ out.unsafeWriteLong(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readLong());
+
+ reset();
+
+ out.writeLongFast(val);
+ out.shift(8);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readLongFast());
+
+ reset();
+
+ out.writeLong(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readLong());
+
+ reset();
+
+ out.writeLongArray(new long[] {val});
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readLongArray(1)[0]);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArray() throws Exception {
+ long[] arr = new long[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextLong();
+
+ out.writeLongArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getLongByByteLE(outArr, i * 8));
+
+ Assert.assertArrayEquals(arr, in.readLongArray(ARR_LEN));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ float val = RND.nextFloat();
+
+ reset();
+
+ out.unsafeWriteFloat(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readFloat(), 0);
+
+ reset();
+
+ out.writeFloat(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readFloat(), 0);
+
+ reset();
+
+ out.writeFloatArray(new float[] {val});
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readFloatArray(1)[0], 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArray() throws Exception {
+ float[] arr = new float[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextFloat();
+
+ out.writeFloatArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getFloatByByteLE(outArr, i * 4), 0);
+
+ Assert.assertArrayEquals(arr, in.readFloatArray(ARR_LEN), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ double val = RND.nextDouble();
+
+ reset();
+
+ out.unsafeWriteDouble(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readDouble(), 0);
+
+ reset();
+
+ out.writeDouble(val);
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readDouble(), 0);
+
+ reset();
+
+ out.writeDoubleArray(new double[] {val});
+
+ checkValueLittleEndian(val);
+ assertEquals(val, in.readDoubleArray(1)[0], 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArray() throws Exception {
+ double[] arr = new double[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextDouble();
+
+ out.writeDoubleArray(arr);
+
+ byte[] outArr = array();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8), 0);
+
+ Assert.assertArrayEquals(arr, in.readDoubleArray(ARR_LEN), 0);
+ }
+
+ /**
+ *
+ */
+ private void reset() {
+ in.position(0);
+ out.position(0);
+ }
+
+ /**
+ *
+ */
+ private byte[] array() {
+ return out.array();
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(short exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getShortByByteLE(arr));
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(char exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getCharByByteLE(arr));
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(int exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getIntByByteLE(arr));
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(long exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getLongByByteLE(arr));
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(float exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getFloatByByteLE(arr), 0);
+ }
+
+ /**
+ * @param exp Expected.
+ */
+ private void checkValueLittleEndian(double exp) {
+ byte[] arr = array();
+
+ assertEquals(exp, getDoubleByByteLE(arr), 0);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..4b86748
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryHeapStreamByteOrderSelfTest.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary.streams;
+
+/**
+ * Binary heap input/output stream byte order sanity tests.
+ */
+public class BinaryHeapStreamByteOrderSelfTest extends AbstractBinaryStreamByteOrderSelfTest {
+ /** {@inheritDoc} */
+ @Override protected void init() {
+ out = new BinaryHeapOutputStream(ARR_LEN * 8);
+ in = new BinaryHeapInputStream(out.array());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java
new file mode 100644
index 0000000..6e9c41a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/streams/BinaryOffheapStreamByteOrderSelfTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary.streams;
+
+/**
+ * Binary offheap input/output stream byte order sanity tests.
+ */
+public class BinaryOffheapStreamByteOrderSelfTest extends AbstractBinaryStreamByteOrderSelfTest {
+ /** {@inheritDoc} */
+ @Override protected void init() {
+ int cap = ARR_LEN * 8;
+
+ out = new BinaryOffheapOutputStream(cap);
+ in = new BinaryOffheapInputStream(((BinaryOffheapOutputStream)out).pointer(), cap);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
new file mode 100644
index 0000000..d96f796
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2ByteOrderSelfTest.java
@@ -0,0 +1,244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.direct.stream.v2;
+
+import java.nio.ByteBuffer;
+import java.util.Random;
+import junit.framework.TestCase;
+import org.apache.ignite.internal.direct.stream.DirectByteBufferStream;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.plugin.extensions.communication.MessageFactory;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.GridTestIoUtils.getCharByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getDoubleByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getFloatByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getIntByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getLongByByteLE;
+import static org.apache.ignite.GridTestIoUtils.getShortByByteLE;
+import static org.junit.Assert.assertArrayEquals;
+
+/**
+ * {@link DirectByteBufferStreamImplV2} byte order sanity tests.
+ */
+public class DirectByteBufferStreamImplV2ByteOrderSelfTest extends TestCase {
+ /** Array length. */
+ private static final int ARR_LEN = 16;
+
+ /** Length bytes. */
+ private static final int LEN_BYTES = 1;
+
+ /** Rnd. */
+ private static final Random RND = new Random();
+
+ /** Stream. */
+ private DirectByteBufferStream stream;
+
+ /** Buff. */
+ private ByteBuffer buff;
+
+ /** Array. */
+ private byte[] outArr;
+
+ /** {@inheritDoc} */
+ @Override public void setUp() throws Exception {
+ super.setUp();
+
+ stream = new DirectByteBufferStreamImplV2(new MessageFactory() {
+ @Nullable @Override public Message create(byte type) {
+ return null;
+ }
+ });
+
+ outArr = new byte[ARR_LEN * 8 + LEN_BYTES];
+
+ buff = ByteBuffer.wrap(outArr);
+
+ stream.setBuffer(buff);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShort() throws Exception {
+ short val = (short)RND.nextLong();
+
+ stream.writeShort(val);
+
+ buff.rewind();
+
+ assertEquals(val, getShortByByteLE(outArr));
+ assertEquals(val, stream.readShort());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArray() throws Exception {
+ short[] arr = new short[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (short)RND.nextLong();
+
+ stream.writeShortArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getShortByByteLE(outArr, i * 2 + LEN_BYTES));
+
+ assertArrayEquals(arr, stream.readShortArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testChar() throws Exception {
+ char val = (char)RND.nextLong();
+
+ stream.writeChar(val);
+
+ buff.rewind();
+
+ assertEquals(val, getCharByByteLE(outArr));
+ assertEquals(val, stream.readChar());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArray() throws Exception {
+ char[] arr = new char[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = (char)RND.nextLong();
+
+ stream.writeCharArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getCharByByteLE(outArr, i * 2 + LEN_BYTES));
+
+ assertArrayEquals(arr, stream.readCharArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArray() throws Exception {
+ int[] arr = new int[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextInt();
+
+ stream.writeIntArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getIntByByteLE(outArr, i * 4 + LEN_BYTES));
+
+ assertArrayEquals(arr, stream.readIntArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArray() throws Exception {
+ long[] arr = new long[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextLong();
+
+ stream.writeLongArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getLongByByteLE(outArr, i * 8 + LEN_BYTES));
+
+ assertArrayEquals(arr, stream.readLongArray());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloat() throws Exception {
+ float val = RND.nextFloat();
+
+ stream.writeFloat(val);
+
+ buff.rewind();
+
+ assertEquals(val, getFloatByByteLE(outArr), 0);
+ assertEquals(val, stream.readFloat(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArray() throws Exception {
+ float[] arr = new float[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextFloat();
+
+ stream.writeFloatArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getFloatByByteLE(outArr, i * 4 + LEN_BYTES), 0);
+
+ assertArrayEquals(arr, stream.readFloatArray(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDouble() throws Exception {
+ double val = RND.nextDouble();
+
+ stream.writeDouble(val);
+
+ buff.rewind();
+
+ assertEquals(val, getDoubleByByteLE(outArr), 0);
+ assertEquals(val, stream.readDouble(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArray() throws Exception {
+ double[] arr = new double[ARR_LEN];
+
+ for (int i = 0; i < ARR_LEN; i++)
+ arr[i] = RND.nextDouble();
+
+ stream.writeDoubleArray(arr);
+
+ buff.rewind();
+
+ for (int i = 0; i < ARR_LEN; i++)
+ assertEquals(arr[i], getDoubleByByteLE(outArr, i * 8 + LEN_BYTES), 0);
+
+ assertArrayEquals(arr, stream.readDoubleArray(), 0);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
index 5bb6794..4887b79 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMapSelfTest.java
@@ -27,7 +27,6 @@ import javax.cache.Cache;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-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;
@@ -165,17 +164,11 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest {
Iterator<Cache.Entry<Integer, String>> it = null;
- boolean created = false;
-
for (int i = start; i < start + cnt; i++) {
int key = i % cnt;
- if (!created && i >= start + tid * 100) {
- if (it == null)
- it = c.iterator();
-
- created = true;
- }
+ if (it == null && i >= start + tid * 100)
+ it = c.iterator();
c.put(key, Integer.toString(key));
@@ -342,7 +335,7 @@ public class GridCacheConcurrentMapSelfTest extends GridCommonAbstractTest {
return null;
}
- }, Runtime.getRuntime().availableProcessors());
+ }, Math.min(16, Runtime.getRuntime().availableProcessors()));
for (int r = 0; r < 10; r++) {
System.gc();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/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 5de3d0f..1c65f9b 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
@@ -228,6 +228,12 @@ public abstract class CacheContinuousQueryFailoverAbstractSelfTest extends GridC
qryClnCache.put(keys.get(0), 100);
}
+ GridTestUtils.waitForCondition(new GridAbsPredicate() {
+ @Override public boolean apply() {
+ return lsnr.evts.size() == 1;
+ }
+ }, 5000);
+
assertEquals(lsnr.evts.size(), 1);
}
[34/50] [abbrv] ignite git commit: IGNITE-2450 - Fixed
java.lang.reflect.Proxy serialization
Posted by vo...@apache.org.
IGNITE-2450 - Fixed java.lang.reflect.Proxy serialization
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e88cc676
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e88cc676
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e88cc676
Branch: refs/heads/ignite-1786
Commit: e88cc676fea65087edb698ff8557de329c344f71
Parents: 75961ee
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Fri Feb 5 12:55:27 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Fri Feb 5 12:55:27 2016 -0800
----------------------------------------------------------------------
.../internal/binary/BinaryClassDescriptor.java | 22 ++++
.../internal/binary/BinaryReaderExImpl.java | 8 +-
.../ignite/internal/binary/BinaryUtils.java | 48 ++++---
.../ignite/internal/binary/BinaryWriteMode.java | 3 +
.../internal/binary/BinaryWriterExImpl.java | 34 +++++
.../internal/binary/GridBinaryMarshaller.java | 3 +
.../optimized/OptimizedClassDescriptor.java | 37 +++++-
.../optimized/OptimizedMarshallerUtils.java | 3 +
.../optimized/OptimizedObjectInputStream.java | 15 ++-
.../optimized/OptimizedObjectOutputStream.java | 4 +-
...namicProxySerializationMultiJvmSelfTest.java | 131 +++++++++++++++++++
.../junits/multijvm/IgniteNodeRunner.java | 16 ++-
.../junits/multijvm/IgniteProcessProxy.java | 19 +--
.../ignite/testsuites/IgniteBasicTestSuite.java | 3 +
.../testsuites/IgniteBinaryBasicTestSuite.java | 2 +
15 files changed, 313 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
index 5cb8a86..e831e96 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryClassDescriptor.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -109,6 +110,9 @@ public class BinaryClassDescriptor {
/** */
private final boolean excluded;
+ /** */
+ private final Class<?>[] intfs;
+
/**
* @param ctx Context.
* @param cls Class.
@@ -229,6 +233,16 @@ public class BinaryClassDescriptor {
fields = null;
stableFieldsMeta = null;
stableSchema = null;
+ intfs = null;
+
+ break;
+
+ case PROXY:
+ ctor = null;
+ fields = null;
+ stableFieldsMeta = null;
+ stableSchema = null;
+ intfs = cls.getInterfaces();
break;
@@ -237,6 +251,7 @@ public class BinaryClassDescriptor {
fields = null;
stableFieldsMeta = null;
stableSchema = null;
+ intfs = null;
break;
@@ -291,6 +306,8 @@ public class BinaryClassDescriptor {
stableSchema = schemaBuilder.build();
+ intfs = null;
+
break;
default:
@@ -611,6 +628,11 @@ public class BinaryClassDescriptor {
break;
+ case PROXY:
+ writer.doWriteProxy((Proxy)obj, intfs);
+
+ break;
+
case BINARY_OBJ:
writer.doWriteBinaryObject((BinaryObjectImpl)obj);
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
index 607dabc..f9e7aa5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryReaderExImpl.java
@@ -68,6 +68,7 @@ import static org.apache.ignite.internal.binary.GridBinaryMarshaller.NULL;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OBJ;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OBJ_ARR;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.OPTM_MARSH;
+import static org.apache.ignite.internal.binary.GridBinaryMarshaller.PROXY;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.SHORT;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.SHORT_ARR;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.STRING;
@@ -1621,6 +1622,11 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
break;
+ case PROXY:
+ obj = BinaryUtils.doReadProxy(in, ctx, ldr, this);
+
+ break;
+
case OPTM_MARSH:
obj = BinaryUtils.doReadOptimized(in, ctx, ldr);
@@ -2013,7 +2019,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
/**
* Flag.
*/
- private static enum Flag {
+ private enum Flag {
/** Regular. */
NORMAL,
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
index a82b65f..c3343d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryUtils.java
@@ -17,28 +17,15 @@
package org.apache.ignite.internal.binary;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryCollectionFactory;
-import org.apache.ignite.binary.BinaryInvalidTypeException;
-import org.apache.ignite.binary.BinaryMapFactory;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.internal.binary.builder.BinaryLazyValue;
-import org.apache.ignite.internal.binary.streams.BinaryInputStream;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.jetbrains.annotations.Nullable;
-import org.jsr166.ConcurrentHashMap8;
-
import java.io.ByteArrayInputStream;
import java.io.Externalizable;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.Array;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
@@ -58,6 +45,20 @@ import java.util.TreeSet;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryCollectionFactory;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.internal.binary.builder.BinaryLazyValue;
+import org.apache.ignite.internal.binary.streams.BinaryInputStream;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.jetbrains.annotations.Nullable;
+import org.jsr166.ConcurrentHashMap8;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -1042,6 +1043,8 @@ public class BinaryUtils {
return BinaryWriteMode.ENUM;
else if (cls == Class.class)
return BinaryWriteMode.CLASS;
+ else if (Proxy.class.isAssignableFrom(cls))
+ return BinaryWriteMode.PROXY;
else
return BinaryWriteMode.OBJECT;
}
@@ -1365,6 +1368,21 @@ public class BinaryUtils {
}
/**
+ * @return Value.
+ */
+ public static Object doReadProxy(BinaryInputStream in, BinaryContext ctx, ClassLoader ldr,
+ BinaryReaderHandlesHolder handles) {
+ Class<?>[] intfs = new Class<?>[in.readInt()];
+
+ for (int i = 0; i < intfs.length; i++)
+ intfs[i] = doReadClass(in, ctx, ldr);
+
+ InvocationHandler ih = (InvocationHandler)doReadObject(in, ctx, ldr, handles);
+
+ return Proxy.newProxyInstance(ldr != null ? ldr : U.gridClassLoader(), intfs, ih);
+ }
+
+ /**
* Read plain type.
*
* @param in Input stream.
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteMode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteMode.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteMode.java
index b037945..7e8c9bd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteMode.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriteMode.java
@@ -148,6 +148,9 @@ public enum BinaryWriteMode {
CLASS(GridBinaryMarshaller.CLASS),
/** */
+ PROXY(GridBinaryMarshaller.PROXY),
+
+ /** */
BINARY(GridBinaryMarshaller.BINARY_OBJ),
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
index 877a2db..8060a13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java
@@ -19,7 +19,9 @@ package org.apache.ignite.internal.binary;
import java.io.IOException;
import java.io.ObjectOutput;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
@@ -817,6 +819,38 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
}
/**
+ * @param proxy Proxy.
+ */
+ public void doWriteProxy(Proxy proxy, Class<?>[] intfs) {
+ if (proxy == null)
+ out.writeByte(GridBinaryMarshaller.NULL);
+ else {
+ out.unsafeEnsure(1 + 4);
+
+ out.unsafeWriteByte(GridBinaryMarshaller.PROXY);
+ out.unsafeWriteInt(intfs.length);
+
+ for (Class<?> intf : intfs) {
+ BinaryClassDescriptor desc = ctx.descriptorForClass(intf, false);
+
+ if (desc.registered())
+ out.writeInt(desc.typeId());
+ else {
+ out.writeInt(GridBinaryMarshaller.UNREGISTERED_TYPE_ID);
+
+ doWriteString(intf.getName());
+ }
+ }
+
+ InvocationHandler ih = Proxy.getInvocationHandler(proxy);
+
+ assert ih != null;
+
+ doWriteObject(ih);
+ }
+ }
+
+ /**
* @param po Binary object.
*/
public void doWriteBinaryObject(@Nullable BinaryObjectImpl po) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
index 8e138fc..67e741b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java
@@ -144,6 +144,9 @@ public class GridBinaryMarshaller {
/** Timestamp array. */
public static final byte TIMESTAMP_ARR = 34;
+ /** Proxy. */
+ public static final byte PROXY = 35;
+
/** */
public static final byte NULL = (byte)101;
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
index c5be139..5a5b54d 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
@@ -26,9 +26,11 @@ import java.io.ObjectStreamField;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -79,6 +81,7 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.LO
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.LONG_ARR;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.OBJ_ARR;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.PROPS;
+import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.PROXY;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SERIALIZABLE;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SHORT;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SHORT_ARR;
@@ -160,6 +163,9 @@ class OptimizedClassDescriptor {
/** Access order field offset. */
private long accessOrderFieldOff;
+ /** Proxy interfaces. */
+ private Class<?>[] proxyIntfs;
+
/**
* Creates descriptor for class.
*
@@ -329,6 +335,11 @@ class OptimizedClassDescriptor {
isCls = true;
}
+ else if (Proxy.class.isAssignableFrom(cls)) {
+ type = PROXY;
+
+ proxyIntfs = cls.getInterfaces();
+ }
else {
Class<?> c = cls;
@@ -558,6 +569,13 @@ class OptimizedClassDescriptor {
}
/**
+ * @return {@code True} if descriptor is for {@link Proxy}.
+ */
+ boolean isProxy() {
+ return type == PROXY;
+ }
+
+ /**
* Replaces object.
*
* @param obj Object.
@@ -738,6 +756,23 @@ class OptimizedClassDescriptor {
break;
+ case PROXY:
+ out.writeInt(proxyIntfs.length);
+
+ for (Class<?> intf : proxyIntfs) {
+ OptimizedClassDescriptor intfDesc = classDescriptor(clsMap, intf, ctx, mapper);
+
+ intfDesc.writeTypeData(out);
+ }
+
+ InvocationHandler ih = Proxy.getInvocationHandler(obj);
+
+ assert ih != null;
+
+ out.writeObject(ih);
+
+ break;
+
case ENUM:
writeTypeData(out);
@@ -1017,4 +1052,4 @@ class OptimizedClassDescriptor {
return fields.get(i);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index fa6f962..923f385 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -136,6 +136,9 @@ class OptimizedMarshallerUtils {
static final byte CLS = 28;
/** */
+ static final byte PROXY = 29;
+
+ /** */
static final byte ENUM = 100;
/** */
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index 988a777..95a301b 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -25,8 +25,10 @@ import java.io.ObjectInputValidation;
import java.io.ObjectStreamClass;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -77,6 +79,7 @@ import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.LO
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.NULL;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.OBJ_ARR;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.PROPS;
+import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.PROXY;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SERIALIZABLE;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SHORT;
import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.SHORT_ARR;
@@ -297,6 +300,16 @@ class OptimizedObjectInputStream extends ObjectInputStream {
case CLS:
return readClass();
+ case PROXY:
+ Class<?>[] intfs = new Class<?>[readInt()];
+
+ for (int i = 0; i < intfs.length; i++)
+ intfs[i] = readClass();
+
+ InvocationHandler ih = (InvocationHandler)readObject();
+
+ return Proxy.newProxyInstance(clsLdr != null ? clsLdr : U.gridClassLoader(), intfs, ih);
+
case ENUM:
case EXTERNALIZABLE:
case SERIALIZABLE:
@@ -1215,4 +1228,4 @@ class OptimizedObjectInputStream extends ObjectInputStream {
return objs[fieldInfo.getIndex(name)] != null ? (T)objs[fieldInfo.getIndex(name)] : dflt;
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
index d884564..96cbbcd 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
@@ -227,7 +227,7 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
int handle = -1;
- if (!desc.isPrimitive() && !desc.isEnum() && !desc.isClass())
+ if (!desc.isPrimitive() && !desc.isEnum() && !desc.isClass() && !desc.isProxy())
handle = handles.lookup(obj);
if (obj0 != obj) {
@@ -895,4 +895,4 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
objs[i] = F.t(info.type(), val);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
new file mode 100644
index 0000000..d22aeac
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/DynamicProxySerializationMultiJvmSelfTest.java
@@ -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.
+ */
+
+package org.apache.ignite.marshaller;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.concurrent.Callable;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.lang.IgniteCallable;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Multi-JVM test for dynamic proxy serialization.
+ */
+public class DynamicProxySerializationMultiJvmSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static Callable<Marshaller> marshFactory;
+
+ /** {@inheritDoc} */
+ @Override protected boolean isMultiJvm() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setMarshaller(marshFactory.call());
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOptimized() throws Exception {
+ marshFactory = new Callable<Marshaller>() {
+ @Override public Marshaller call() throws Exception {
+ return new OptimizedMarshaller(false);
+ }
+ };
+
+ doTest();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBinary() throws Exception {
+ marshFactory = new Callable<Marshaller>() {
+ @Override public Marshaller call() throws Exception {
+ return new BinaryMarshaller();
+ }
+ };
+
+ doTest();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void doTest() throws Exception {
+ try {
+ Ignite ignite = startGrids(2);
+
+ MyProxy p = (MyProxy)Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class[] { MyProxy.class }, new InvocationHandler() {
+ @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if ("value".equals(method.getName()))
+ return 42;
+
+ throw new IllegalStateException();
+ }
+ });
+
+ int val = ignite.compute(ignite.cluster().forRemotes()).call(new MyCallable(p));
+
+ assertEquals(42, val);
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+
+ /**
+ */
+ private static class MyCallable implements IgniteCallable<Integer> {
+ /** */
+ private final MyProxy p;
+
+ /**
+ * @param p Proxy.
+ */
+ public MyCallable(MyProxy p) {
+ this.p = p;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Integer call() throws Exception {
+ return p.value();
+ }
+ }
+
+ /**
+ */
+ private static interface MyProxy {
+ /**
+ * @return Value.
+ */
+ public int value();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
index 0597eda..7d1a37d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteNodeRunner.java
@@ -17,7 +17,6 @@
package org.apache.ignite.testframework.junits.multijvm;
-import com.thoughtworks.xstream.XStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
@@ -29,6 +28,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
+import com.thoughtworks.xstream.XStream;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.Ignition;
@@ -100,12 +100,14 @@ public class IgniteNodeRunner {
String fileName = IGNITE_CONFIGURATION_FILE + cfg.getNodeId();
try(OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) {
- cfg.setMBeanServer(null);
- cfg.setMarshaller(null);
- cfg.setDiscoverySpi(null);
- cfg.setGridLogger(null);
+ IgniteConfiguration cfg0 = new IgniteConfiguration(cfg);
+
+ cfg0.setMBeanServer(null);
+ cfg0.setMarshaller(null);
+ cfg0.setDiscoverySpi(null);
+ cfg0.setGridLogger(null);
- new XStream().toXML(cfg, out);
+ new XStream().toXML(cfg0, out);
}
return fileName;
@@ -176,4 +178,4 @@ public class IgniteNodeRunner {
return res;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index fed42e1..a2e0d5a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -19,7 +19,6 @@ package org.apache.ignite.testframework.junits.multijvm;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -31,10 +30,10 @@ import org.apache.ignite.IgniteAtomicLong;
import org.apache.ignite.IgniteAtomicReference;
import org.apache.ignite.IgniteAtomicSequence;
import org.apache.ignite.IgniteAtomicStamped;
+import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteCompute;
import org.apache.ignite.IgniteCountDownLatch;
-import org.apache.ignite.IgniteSemaphore;
import org.apache.ignite.IgniteDataStreamer;
import org.apache.ignite.IgniteEvents;
import org.apache.ignite.IgniteException;
@@ -42,9 +41,9 @@ import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.IgniteIllegalStateException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteMessaging;
-import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteQueue;
import org.apache.ignite.IgniteScheduler;
+import org.apache.ignite.IgniteSemaphore;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.IgniteSet;
import org.apache.ignite.IgniteTransactions;
@@ -76,6 +75,7 @@ import org.apache.ignite.lang.IgniteInClosure;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.plugin.IgnitePlugin;
import org.apache.ignite.plugin.PluginNotFoundException;
import org.apache.ignite.resources.IgniteInstanceResource;
@@ -121,14 +121,17 @@ public class IgniteProcessProxy implements IgniteEx {
String cfgFileName = IgniteNodeRunner.storeToFile(cfg.setNodeId(id));
- List<String> jvmArgs = U.jvmArgs();
-
Collection<String> filteredJvmArgs = new ArrayList<>();
- for (String arg : jvmArgs) {
- if(arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
+ Marshaller marsh = cfg.getMarshaller();
+
+ if (marsh != null)
+ filteredJvmArgs.add("-D" + IgniteTestResources.MARSH_CLASS_NAME + "=" + marsh.getClass().getName());
+
+ for (String arg : U.jvmArgs()) {
+ if (arg.startsWith("-Xmx") || arg.startsWith("-Xms") ||
arg.startsWith("-cp") || arg.startsWith("-classpath") ||
- arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME))
+ (marsh != null && arg.startsWith("-D" + IgniteTestResources.MARSH_CLASS_NAME)))
filteredJvmArgs.add(arg);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
index dece258..c904ef4 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBasicTestSuite.java
@@ -44,6 +44,7 @@ import org.apache.ignite.internal.processors.service.ClosureServiceClientsNodesT
import org.apache.ignite.internal.product.GridProductVersionSelfTest;
import org.apache.ignite.internal.util.nio.IgniteExceptionInNioWorkerSelfTest;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.DynamicProxySerializationMultiJvmSelfTest;
import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest;
import org.apache.ignite.messaging.GridMessagingSelfTest;
import org.apache.ignite.messaging.IgniteMessagingWithClientTest;
@@ -116,6 +117,8 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
+ GridTestUtils.addTestIfNeeded(suite, DynamicProxySerializationMultiJvmSelfTest.class, ignoredTests);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/e88cc676/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
index cbb87fa..e0c06dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.util.IgniteUtilsSelfTest;
import org.apache.ignite.internal.util.io.GridUnsafeDataOutputArraySizingSelfTest;
import org.apache.ignite.internal.util.nio.GridNioSelfTest;
import org.apache.ignite.internal.util.nio.GridNioSslSelfTest;
+import org.apache.ignite.marshaller.DynamicProxySerializationMultiJvmSelfTest;
import org.apache.ignite.marshaller.jdk.GridJdkMarshallerSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
import org.apache.ignite.marshaller.optimized.OptimizedMarshallerNodeFailoverTest;
@@ -84,6 +85,7 @@ public class IgniteBinaryBasicTestSuite extends TestSuite {
ignoredTests.add(GridMessagingSelfTest.class);
ignoredTests.add(GridVersionSelfTest.class);
ignoredTests.add(GridDeploymentMessageCountSelfTest.class);
+ ignoredTests.add(DynamicProxySerializationMultiJvmSelfTest.class);
// TODO: check and delete if pass.
ignoredTests.add(IgniteDaemonNodeMarshallerCacheTest.class);
[27/50] [abbrv] ignite git commit: Failing tests hotfix
Posted by vo...@apache.org.
Failing tests hotfix
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3602d465
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3602d465
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3602d465
Branch: refs/heads/ignite-1786
Commit: 3602d46573ee98ce440fbcc4457f38252aa8351b
Parents: afd3bc1
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Feb 5 12:06:42 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Feb 5 12:06:42 2016 +0300
----------------------------------------------------------------------
.../cache/IgniteCacheAbstractQuerySelfTest.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3602d465/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 1507543..8ef3f9b 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -386,7 +386,15 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
assertEquals(1, res.getValue().intValue());
- U.sleep(1020);
+ U.sleep(800); // Less than minimal amount of time that must pass before a cache entry is considered expired.
+
+ qry = cache.query(new SqlQuery<Integer, Integer>(Integer.class, "1=1")).getAll();
+
+ res = F.first(qry);
+
+ assertEquals(1, res.getValue().intValue());
+
+ U.sleep(1200); // No expiry guarantee here. Test should be refactored in case of fails.
qry = cache.query(new SqlQuery<Integer, Integer>(Integer.class, "1=1")).getAll();
[33/50] [abbrv] ignite git commit: IGNITE-2329: Implemented a bunch
of optimizations: - Garbageless NIO Selector - Get rid of unnecessary
ArrayList allocations in GridCacheMvccManager. - Optimized "force keys"
futures logic.
Posted by vo...@apache.org.
IGNITE-2329: Implemented a bunch of optimizations:
- Garbageless NIO Selector
- Get rid of unnecessary ArrayList allocations in GridCacheMvccManager.
- Optimized "force keys" futures logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/75961eee
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/75961eee
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/75961eee
Branch: refs/heads/ignite-1786
Commit: 75961eee2513427d94a1c7e0dbb96ac46195544b
Parents: 4210989
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Fri Feb 5 21:13:26 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Fri Feb 5 21:13:26 2016 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 12 +-
.../processors/cache/GridCacheAdapter.java | 37 +-
.../processors/cache/GridCacheMvccManager.java | 42 +-
.../processors/cache/GridCachePreloader.java | 6 +
.../cache/GridCachePreloaderAdapter.java | 5 +
.../processors/cache/GridCacheUtils.java | 21 +-
.../dht/GridClientPartitionTopology.java | 5 +
.../distributed/dht/GridDhtCacheAdapter.java | 72 ++-
.../distributed/dht/GridDhtEmbeddedFuture.java | 13 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 176 ++++---
.../distributed/dht/GridDhtGetSingleFuture.java | 476 +++++++++++++++++++
.../distributed/dht/GridDhtLocalPartition.java | 76 +--
.../distributed/dht/GridDhtPartitionState.java | 2 +-
.../dht/GridDhtPartitionTopology.java | 5 +
.../dht/GridDhtPartitionTopologyImpl.java | 9 +
.../distributed/dht/GridDhtTxPrepareFuture.java | 7 +-
.../dht/atomic/GridDhtAtomicCache.java | 2 +-
.../dht/colocated/GridDhtColocatedCache.java | 40 +-
.../dht/preloader/GridDhtPreloader.java | 16 +
.../cache/distributed/near/GridNearTxLocal.java | 1 -
.../IgniteCacheObjectProcessorImpl.java | 2 +-
.../util/future/GridCompoundFuture.java | 2 +-
.../ignite/internal/util/nio/GridNioServer.java | 143 +++++-
.../util/nio/GridSelectorNioSessionImpl.java | 2 +-
.../util/nio/SelectedSelectionKeySet.java | 111 +++++
.../org/apache/ignite/lang/IgniteBiTuple.java | 6 +-
.../IgniteTxPreloadAbstractTest.java | 2 +-
.../near/GridCacheNearReadersSelfTest.java | 19 +-
.../apache/ignite/lang/GridTupleSelfTest.java | 42 +-
parent/pom.xml | 1 +
30 files changed, 1119 insertions(+), 234 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index de7c10b..6f07702 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -370,11 +370,21 @@ public final class IgniteSystemProperties {
/**
* Manages {@link OptimizedMarshaller} behavior of {@code serialVersionUID} computation for
* {@link Serializable} classes.
- * */
+ */
public static final String IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID =
"IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID";
/**
+ * If set to {@code true}, then default selected keys set is used inside
+ * {@code GridNioServer} which lead to some extra garbage generation when
+ * processing selected keys.
+ * <p>
+ * Default value is {@code false}. Should be switched to {@code true} if there are
+ * any problems in communication layer.
+ */
+ public static final String IGNITE_NO_SELECTOR_OPTS = "IGNITE_NO_SELECTOR_OPTS";
+
+ /**
* Enforces singleton.
*/
private IgniteSystemProperties() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 9f54ddb..84eb0b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -101,7 +101,6 @@ import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
import org.apache.ignite.internal.transactions.IgniteTxRollbackCheckedException;
import org.apache.ignite.internal.util.F0;
-import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -1823,7 +1822,8 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
* @param needVer If {@code true} returns values as tuples containing value and version.
* @return Future.
*/
- public final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(@Nullable final Collection<KeyCacheObject> keys,
+ public final <K1, V1> IgniteInternalFuture<Map<K1, V1>> getAllAsync0(
+ @Nullable final Collection<KeyCacheObject> keys,
final boolean readThrough,
boolean checkTx,
@Nullable final UUID subjId,
@@ -1834,7 +1834,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
final boolean keepCacheObjects,
boolean canRemap,
final boolean needVer
- ) {
+ ) {
if (F.isEmpty(keys))
return new GridFinishedFuture<>(Collections.<K1, V1>emptyMap());
@@ -1853,11 +1853,16 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (tx == null || tx.implicit()) {
try {
- final AffinityTopologyVersion topVer = tx == null
- ? (canRemap ? ctx.affinity().affinityTopologyVersion(): ctx.shared().exchange().readyAffinityVersion())
- : tx.topologyVersion();
+ final AffinityTopologyVersion topVer = tx == null ?
+ (canRemap ?
+ ctx.affinity().affinityTopologyVersion() : ctx.shared().exchange().readyAffinityVersion()) :
+ tx.topologyVersion();
+
+ int keysSize = keys.size();
- final Map<K1, V1> map = new GridLeanMap<>(keys.size());
+ final Map<K1, V1> map = keysSize == 1 ?
+ (Map<K1, V1>)new IgniteBiTuple<>() :
+ U.<K1, V1>newHashMap(keysSize);
final boolean storeEnabled = !skipVals && readThrough && ctx.readThrough();
@@ -1893,7 +1898,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
GridCacheVersion ver = entry.version();
if (misses == null)
- misses = new GridLeanMap<>();
+ misses = new HashMap<>();
misses.put(key, ver);
}
@@ -1913,7 +1918,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
if (tx == null || (!tx.implicit() && tx.isolation() == READ_COMMITTED))
ctx.evicts().touch(entry, topVer);
- if (keys.size() == 1)
+ if (keysSize == 1)
// Safe to return because no locks are required in READ_COMMITTED mode.
return new GridFinishedFuture<>(map);
}
@@ -2051,17 +2056,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
}
);
}
- else {
- // If misses is not empty and store is disabled, we should touch missed entries.
- if (misses != null) {
- for (KeyCacheObject key : misses.keySet()) {
- GridCacheEntryEx entry = peekEx(key);
-
- if (entry != null)
- ctx.evicts().touch(entry, topVer);
- }
- }
- }
+ else
+ // Misses can be non-zero only if store is enabled.
+ assert misses == null;
return new GridFinishedFuture<>(map);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
index c7d1f62..b2c23f5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java
@@ -17,6 +17,18 @@
package org.apache.ignite.internal.processors.cache;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.ConcurrentMap;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.events.DiscoveryEvent;
@@ -52,18 +64,6 @@ import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import org.jsr166.ConcurrentLinkedDeque8;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.ConcurrentMap;
-
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.util.GridConcurrentFactory.newMap;
@@ -77,12 +77,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
private static final int MAX_REMOVED_LOCKS = 10240;
/** Pending locks per thread. */
- private final ThreadLocal<LinkedList<GridCacheMvccCandidate>> pending =
- new ThreadLocal<LinkedList<GridCacheMvccCandidate>>() {
- @Override protected LinkedList<GridCacheMvccCandidate> initialValue() {
- return new LinkedList<>();
- }
- };
+ private final ThreadLocal<Deque<GridCacheMvccCandidate>> pending = new ThreadLocal<>();
/** Pending near local locks and topology version per thread. */
private ConcurrentMap<Long, GridCacheExplicitLockSpan> pendingExplicit;
@@ -683,7 +678,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
* @return Remote candidates.
*/
public Collection<GridCacheMvccCandidate> remoteCandidates() {
- Collection<GridCacheMvccCandidate> rmtCands = new LinkedList<>();
+ Collection<GridCacheMvccCandidate> rmtCands = new ArrayList<>();
for (GridDistributedCacheEntry entry : locked())
rmtCands.addAll(entry.remoteMvccSnapshot());
@@ -697,7 +692,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
* @return Local candidates.
*/
public Collection<GridCacheMvccCandidate> localCandidates() {
- Collection<GridCacheMvccCandidate> locCands = new LinkedList<>();
+ Collection<GridCacheMvccCandidate> locCands = new ArrayList<>();
for (GridDistributedCacheEntry entry : locked()) {
try {
@@ -726,7 +721,10 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
if (cacheCtx.isNear() || cand.singleImplicit())
return true;
- LinkedList<GridCacheMvccCandidate> queue = pending.get();
+ Deque<GridCacheMvccCandidate> queue = pending.get();
+
+ if (queue == null)
+ pending.set(queue = new ArrayDeque<>());
GridCacheMvccCandidate prev = null;
@@ -751,7 +749,7 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter {
* Reset MVCC context.
*/
public void contextReset() {
- pending.set(new LinkedList<GridCacheMvccCandidate>());
+ pending.set(null);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
index c8fcb90..be019fc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
@@ -137,6 +137,12 @@ public interface GridCachePreloader {
public IgniteInternalFuture<Boolean> rebalanceFuture();
/**
+ * @return {@code true} if there is no need to force keys preloading
+ * (e.g. rebalancing has been completed).
+ */
+ public boolean needForceKeys();
+
+ /**
* Requests that preloader sends the request for the key.
*
* @param keys Keys to request.
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
index a1704fc..5d98c6f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
@@ -93,6 +93,11 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
}
/** {@inheritDoc} */
+ @Override public boolean needForceKeys() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
@Override public void onReconnected() {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 8723827..cd21794 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -751,23 +751,28 @@ public class GridCacheUtils {
* @param <T> Collection element type.
* @return Reducer.
*/
- public static <T> IgniteReducer<Collection<T>, Collection<T>> collectionsReducer() {
+ public static <T> IgniteReducer<Collection<T>, Collection<T>> collectionsReducer(final int size) {
return new IgniteReducer<Collection<T>, Collection<T>>() {
- private final Collection<T> ret = new ConcurrentLinkedQueue<>();
+ private List<T> ret;
+
+ @Override public synchronized boolean collect(Collection<T> c) {
+ if (c == null)
+ return true;
+
+ if (ret == null)
+ ret = new ArrayList<>(size);
- @Override public boolean collect(Collection<T> c) {
- if (c != null)
- ret.addAll(c);
+ ret.addAll(c);
return true;
}
- @Override public Collection<T> reduce() {
- return ret;
+ @Override public synchronized Collection<T> reduce() {
+ return ret == null ? Collections.<T>emptyList() : ret;
}
/** {@inheritDoc} */
- @Override public String toString() {
+ @Override public synchronized String toString() {
return "Collection reducer: " + ret;
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
index dcfc038..ad4943e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridClientPartitionTopology.java
@@ -336,6 +336,11 @@ public class GridClientPartitionTopology implements GridDhtPartitionTopology {
}
/** {@inheritDoc} */
+ @Override public void releasePartitions(int... parts) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
@Override public List<GridDhtLocalPartition> localPartitions() {
return Collections.emptyList();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 5be4e72..8e456e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -698,7 +698,8 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
@Nullable UUID subjId,
int taskNameHash,
@Nullable IgniteCacheExpiryPolicy expiry,
- boolean skipVals) {
+ boolean skipVals
+ ) {
GridDhtGetFuture<K, V> fut = new GridDhtGetFuture<>(ctx,
msgId,
reader,
@@ -718,21 +719,63 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
/**
* @param nodeId Node ID.
+ * @param msgId Message ID.
+ * @param key Key.
+ * @param addRdr Add reader flag.
+ * @param readThrough Read through flag.
+ * @param topVer Topology version flag.
+ * @param subjId Subject ID.
+ * @param taskNameHash Task name hash.
+ * @param expiry Expiry.
+ * @param skipVals Skip vals flag.
+ * @return Future for the operation.
+ */
+ private IgniteInternalFuture<GridCacheEntryInfo> getDhtSingleAsync(
+ UUID nodeId,
+ long msgId,
+ KeyCacheObject key,
+ boolean addRdr,
+ boolean readThrough,
+ AffinityTopologyVersion topVer,
+ @Nullable UUID subjId,
+ int taskNameHash,
+ @Nullable IgniteCacheExpiryPolicy expiry,
+ boolean skipVals
+ ) {
+ GridDhtGetSingleFuture<K, V> fut = new GridDhtGetSingleFuture<>(
+ ctx,
+ msgId,
+ nodeId,
+ key,
+ addRdr,
+ readThrough,
+ /*tx*/null,
+ topVer,
+ subjId,
+ taskNameHash,
+ expiry,
+ skipVals);
+
+ fut.init();
+
+ return fut;
+ }
+
+ /**
+ * @param nodeId Node ID.
* @param req Get request.
*/
protected void processNearSingleGetRequest(final UUID nodeId, final GridNearSingleGetRequest req) {
assert ctx.affinityNode();
- long ttl = req.accessTtl();
-
- final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.forAccess(ttl);
-
- Map<KeyCacheObject, Boolean> map = Collections.singletonMap(req.key(), req.addReader());
+ final CacheExpiryPolicy expiryPlc = CacheExpiryPolicy.forAccess(req.accessTtl());
- IgniteInternalFuture<Collection<GridCacheEntryInfo>> fut =
- getDhtAsync(nodeId,
+ IgniteInternalFuture<GridCacheEntryInfo> fut =
+ getDhtSingleAsync(
+ nodeId,
req.messageId(),
- map,
+ req.key(),
+ req.addReader(),
req.readThrough(),
req.topologyVersion(),
req.subjectId(),
@@ -740,19 +783,16 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
expiryPlc,
req.skipValues());
- fut.listen(new CI1<IgniteInternalFuture<Collection<GridCacheEntryInfo>>>() {
- @Override public void apply(IgniteInternalFuture<Collection<GridCacheEntryInfo>> f) {
+ fut.listen(new CI1<IgniteInternalFuture<GridCacheEntryInfo>>() {
+ @Override public void apply(IgniteInternalFuture<GridCacheEntryInfo> f) {
GridNearSingleGetResponse res;
- GridDhtFuture<Collection<GridCacheEntryInfo>> fut =
- (GridDhtFuture<Collection<GridCacheEntryInfo>>)f;
+ GridDhtFuture<GridCacheEntryInfo> fut = (GridDhtFuture<GridCacheEntryInfo>)f;
try {
- Collection<GridCacheEntryInfo> entries = fut.get();
+ GridCacheEntryInfo info = fut.get();
if (F.isEmpty(fut.invalidPartitions())) {
- GridCacheEntryInfo info = F.first(entries);
-
Message res0 = null;
if (info != null) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtEmbeddedFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtEmbeddedFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtEmbeddedFuture.java
index 0d10a93..1b9f743 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtEmbeddedFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtEmbeddedFuture.java
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Collections;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.future.GridEmbeddedFuture;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.lang.IgniteBiClosure;
@@ -32,10 +31,6 @@ public class GridDhtEmbeddedFuture<A, B> extends GridEmbeddedFuture<A, B> implem
/** */
private static final long serialVersionUID = 0L;
- /** Retries. */
- @GridToStringInclude
- private Collection<Integer> invalidParts;
-
/**
* @param c Closure.
* @param embedded Embedded.
@@ -45,8 +40,6 @@ public class GridDhtEmbeddedFuture<A, B> extends GridEmbeddedFuture<A, B> implem
IgniteInternalFuture<B> embedded
) {
super(c, embedded);
-
- invalidParts = Collections.emptyList();
}
/**
@@ -58,17 +51,15 @@ public class GridDhtEmbeddedFuture<A, B> extends GridEmbeddedFuture<A, B> implem
IgniteBiClosure<B, Exception, IgniteInternalFuture<A>> c
) {
super(embedded, c);
-
- invalidParts = Collections.emptyList();
}
/** {@inheritDoc} */
@Override public Collection<Integer> invalidPartitions() {
- return invalidParts;
+ return Collections.emptyList();
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridDhtEmbeddedFuture.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index c926c13..fa753b0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.distributed.dht;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@@ -82,7 +83,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
private Map<KeyCacheObject, Boolean> keys;
/** Reserved partitions. */
- private Collection<GridDhtLocalPartition> parts = new HashSet<>();
+ private int[] parts;
/** Future ID. */
private IgniteUuid futId;
@@ -137,7 +138,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
@Nullable IgniteCacheExpiryPolicy expiryPlc,
boolean skipVals
) {
- super(CU.<GridCacheEntryInfo>collectionsReducer());
+ super(CU.<GridCacheEntryInfo>collectionsReducer(keys.size()));
assert reader != null;
assert !F.isEmpty(keys);
@@ -194,8 +195,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
@Override public boolean onDone(Collection<GridCacheEntryInfo> res, Throwable err) {
if (super.onDone(res, err)) {
// Release all partitions reserved by this future.
- for (GridDhtLocalPartition part : parts)
- part.release();
+ if (parts != null)
+ cctx.topology().releasePartitions(parts);
return true;
}
@@ -209,68 +210,92 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
private void map(final Map<KeyCacheObject, Boolean> keys) {
GridDhtFuture<Object> fut = cctx.dht().dhtPreloader().request(keys.keySet(), topVer);
- if (!F.isEmpty(fut.invalidPartitions())) {
- if (retries == null)
- retries = new HashSet<>();
+ if (fut != null) {
+ if (!F.isEmpty(fut.invalidPartitions())) {
+ if (retries == null)
+ retries = new HashSet<>();
- retries.addAll(fut.invalidPartitions());
- }
+ retries.addAll(fut.invalidPartitions());
+ }
- add(new GridEmbeddedFuture<>(
- new IgniteBiClosure<Object, Exception, Collection<GridCacheEntryInfo>>() {
- @Override public Collection<GridCacheEntryInfo> apply(Object o, Exception e) {
- if (e != null) { // Check error first.
- if (log.isDebugEnabled())
- log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
+ add(new GridEmbeddedFuture<>(
+ new IgniteBiClosure<Object, Exception, Collection<GridCacheEntryInfo>>() {
+ @Override public Collection<GridCacheEntryInfo> apply(Object o, Exception e) {
+ if (e != null) { // Check error first.
+ if (log.isDebugEnabled())
+ log.debug("Failed to request keys from preloader [keys=" + keys + ", err=" + e + ']');
- onDone(e);
+ onDone(e);
+ }
+ else
+ map0(keys);
+
+ // Finish this one.
+ return Collections.emptyList();
}
+ },
+ fut));
+ }
+ else
+ map0(keys);
+ }
- Map<KeyCacheObject, Boolean> mappedKeys = null;
+ /**
+ * @param keys Keys to map.
+ */
+ private void map0(Map<KeyCacheObject, Boolean> keys) {
+ Map<KeyCacheObject, Boolean> mappedKeys = null;
- // Assign keys to primary nodes.
- for (Map.Entry<KeyCacheObject, Boolean> key : keys.entrySet()) {
- int part = cctx.affinity().partition(key.getKey());
+ // Assign keys to primary nodes.
+ for (Map.Entry<KeyCacheObject, Boolean> key : keys.entrySet()) {
+ int part = cctx.affinity().partition(key.getKey());
- if (retries == null || !retries.contains(part)) {
- if (!map(key.getKey(), parts)) {
- if (retries == null)
- retries = new HashSet<>();
+ if (retries == null || !retries.contains(part)) {
+ if (!map(key.getKey())) {
+ if (retries == null)
+ retries = new HashSet<>();
- retries.add(part);
+ retries.add(part);
- if (mappedKeys == null) {
- mappedKeys = U.newLinkedHashMap(keys.size());
+ if (mappedKeys == null) {
+ mappedKeys = U.newLinkedHashMap(keys.size());
- for (Map.Entry<KeyCacheObject, Boolean> key1 : keys.entrySet()) {
- if (key1.getKey() == key.getKey())
- break;
+ for (Map.Entry<KeyCacheObject, Boolean> key1 : keys.entrySet()) {
+ if (key1.getKey() == key.getKey())
+ break;
- mappedKeys.put(key.getKey(), key1.getValue());
- }
- }
- }
- else if (mappedKeys != null)
- mappedKeys.put(key.getKey(), key.getValue());
+ mappedKeys.put(key.getKey(), key1.getValue());
}
}
+ }
+ else if (mappedKeys != null)
+ mappedKeys.put(key.getKey(), key.getValue());
+ }
+ }
- // Add new future.
- add(getAsync(mappedKeys == null ? keys : mappedKeys));
+ // Add new future.
+ IgniteInternalFuture<Collection<GridCacheEntryInfo>> fut = getAsync(mappedKeys == null ? keys : mappedKeys);
- // Finish this one.
- return Collections.emptyList();
- }
- },
- fut));
+ // Optimization to avoid going through compound future,
+ // if getAsync() has been completed and no other futures added to this
+ // compound future.
+ if (fut.isDone() && futuresSize() == 0) {
+ if (fut.error() != null)
+ onDone(fut.error());
+ else
+ onDone(fut.result());
+
+ return;
+ }
+
+ add(fut);
}
/**
* @param key Key.
- * @param parts Parts to map.
* @return {@code True} if mapped.
*/
- private boolean map(KeyCacheObject key, Collection<GridDhtLocalPartition> parts) {
+ private boolean map(KeyCacheObject key) {
GridDhtLocalPartition part = topVer.topologyVersion() > 0 ?
cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) :
cache().topology().localPartition(key, false);
@@ -278,10 +303,12 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
if (part == null)
return false;
- if (!parts.contains(part)) {
+ if (parts == null || !F.contains(parts, part.id())) {
// By reserving, we make sure that partition won't be unloaded while processed.
if (part.reserve()) {
- parts.add(part);
+ parts = parts == null ? new int[1] : Arrays.copyOf(parts, parts.length + 1);
+
+ parts[parts.length - 1] = part.id();
return true;
}
@@ -422,37 +449,56 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
);
}
+ if (fut.isDone()) {
+ if (fut.error() != null)
+ onDone(fut.error());
+ else
+ return new GridFinishedFuture<>(toEntryInfos(fut.result()));
+ }
+
return new GridEmbeddedFuture<>(
new C2<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>, Exception, Collection<GridCacheEntryInfo>>() {
- @Override public Collection<GridCacheEntryInfo> apply(Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>> map, Exception e) {
+ @Override public Collection<GridCacheEntryInfo> apply(
+ Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>> map, Exception e
+ ) {
if (e != null) {
onDone(e);
return Collections.emptyList();
}
- else {
- Collection<GridCacheEntryInfo> infos = new ArrayList<>(map.size());
+ else
+ return toEntryInfos(map);
+ }
+ },
+ fut);
+ }
- for (Map.Entry<KeyCacheObject, T2<CacheObject, GridCacheVersion>> entry : map.entrySet()) {
- T2<CacheObject, GridCacheVersion> val = entry.getValue();
+ /**
+ * @param map Map to convert.
+ * @return List of infos.
+ */
+ private Collection<GridCacheEntryInfo> toEntryInfos(Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>> map) {
+ if (map.isEmpty())
+ return Collections.emptyList();
- assert val != null;
+ Collection<GridCacheEntryInfo> infos = new ArrayList<>(map.size());
- GridCacheEntryInfo info = new GridCacheEntryInfo();
+ for (Map.Entry<KeyCacheObject, T2<CacheObject, GridCacheVersion>> entry : map.entrySet()) {
+ T2<CacheObject, GridCacheVersion> val = entry.getValue();
- info.cacheId(cctx.cacheId());
- info.key(entry.getKey());
- info.value(skipVals ? null : val.get1());
- info.version(val.get2());
+ assert val != null;
- infos.add(info);
- }
+ GridCacheEntryInfo info = new GridCacheEntryInfo();
- return infos;
- }
- }
- },
- fut);
+ info.cacheId(cctx.cacheId());
+ info.key(entry.getKey());
+ info.value(skipVals ? null : val.get1());
+ info.version(val.get2());
+
+ infos.add(info);
+ }
+
+ return infos;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
new file mode 100644
index 0000000..d9851c7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetSingleFuture.java
@@ -0,0 +1,476 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.distributed.dht;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheObject;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
+import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
+import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.lang.IgniteUuid;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ *
+ */
+public final class GridDhtGetSingleFuture<K, V> extends GridFutureAdapter<GridCacheEntryInfo>
+ implements GridDhtFuture<GridCacheEntryInfo> {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Logger reference. */
+ private static final AtomicReference<IgniteLogger> logRef = new AtomicReference<>();
+
+ /** Logger. */
+ private static IgniteLogger log;
+
+ /** Message ID. */
+ private long msgId;
+
+ /** */
+ private UUID reader;
+
+ /** Read through flag. */
+ private boolean readThrough;
+
+ /** Context. */
+ private GridCacheContext<K, V> cctx;
+
+ /** Key. */
+ private KeyCacheObject key;
+
+ /** */
+ private boolean addRdr;
+
+ /** Reserved partitions. */
+ private int part = -1;
+
+ /** Future ID. */
+ private IgniteUuid futId;
+
+ /** Version. */
+ private GridCacheVersion ver;
+
+ /** Topology version .*/
+ private AffinityTopologyVersion topVer;
+
+ /** Transaction. */
+ private IgniteTxLocalEx tx;
+
+ /** Retries because ownership changed. */
+ private Collection<Integer> retries;
+
+ /** Subject ID. */
+ private UUID subjId;
+
+ /** Task name. */
+ private int taskNameHash;
+
+ /** Expiry policy. */
+ private IgniteCacheExpiryPolicy expiryPlc;
+
+ /** Skip values flag. */
+ private boolean skipVals;
+
+ /**
+ * @param cctx Context.
+ * @param msgId Message ID.
+ * @param reader Reader.
+ * @param key Key.
+ * @param addRdr Add reader flag.
+ * @param readThrough Read through flag.
+ * @param tx Transaction.
+ * @param topVer Topology version.
+ * @param subjId Subject ID.
+ * @param taskNameHash Task name hash code.
+ * @param expiryPlc Expiry policy.
+ * @param skipVals Skip values flag.
+ */
+ public GridDhtGetSingleFuture(
+ GridCacheContext<K, V> cctx,
+ long msgId,
+ UUID reader,
+ KeyCacheObject key,
+ Boolean addRdr,
+ boolean readThrough,
+ @Nullable IgniteTxLocalEx tx,
+ @NotNull AffinityTopologyVersion topVer,
+ @Nullable UUID subjId,
+ int taskNameHash,
+ @Nullable IgniteCacheExpiryPolicy expiryPlc,
+ boolean skipVals
+ ) {
+ assert reader != null;
+ assert key != null;
+
+ this.reader = reader;
+ this.cctx = cctx;
+ this.msgId = msgId;
+ this.key = key;
+ this.addRdr = addRdr;
+ this.readThrough = readThrough;
+ this.tx = tx;
+ this.topVer = topVer;
+ this.subjId = subjId;
+ this.taskNameHash = taskNameHash;
+ this.expiryPlc = expiryPlc;
+ this.skipVals = skipVals;
+
+ futId = IgniteUuid.randomUuid();
+
+ ver = tx == null ? cctx.versions().next() : tx.xidVersion();
+
+ if (log == null)
+ log = U.logger(cctx.kernalContext(), logRef, GridDhtGetSingleFuture.class);
+ }
+
+ /**
+ * Initializes future.
+ */
+ void init() {
+ map();
+ }
+
+ /**
+ * @return Future ID.
+ */
+ public IgniteUuid futureId() {
+ return futId;
+ }
+
+ /**
+ * @return Future version.
+ */
+ public GridCacheVersion version() {
+ return ver;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean onDone(GridCacheEntryInfo res, Throwable err) {
+ if (super.onDone(res, err)) {
+ // Release all partitions reserved by this future.
+ if (part != -1)
+ cctx.topology().releasePartitions(part);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ *
+ */
+ private void map() {
+ if (cctx.dht().dhtPreloader().needForceKeys()) {
+ GridDhtFuture<Object> fut = cctx.dht().dhtPreloader().request(
+ Collections.singleton(key),
+ topVer);
+
+ if (fut != null) {
+ if (F.isEmpty(fut.invalidPartitions())) {
+ if (retries == null)
+ retries = new HashSet<>();
+
+ retries.addAll(fut.invalidPartitions());
+ }
+
+ fut.listen(
+ new IgniteInClosure<IgniteInternalFuture<Object>>() {
+ @Override public void apply(IgniteInternalFuture<Object> fut) {
+ Throwable e = fut.error();
+
+ if (e != null) { // Check error first.
+ if (log.isDebugEnabled())
+ log.debug("Failed to request keys from preloader " +
+ "[keys=" + key + ", err=" + e + ']');
+
+ onDone(e);
+ }
+ else
+ map0();
+ }
+ }
+ );
+
+ return;
+ }
+ }
+
+ map0();
+ }
+
+ /**
+ *
+ */
+ private void map0() {
+ // Assign keys to primary nodes.
+ int part = cctx.affinity().partition(key);
+
+ if (retries == null || !retries.contains(part)) {
+ if (!map(key)) {
+ retries = Collections.singleton(part);
+
+ onDone((GridCacheEntryInfo)null);
+
+ return;
+ }
+ }
+
+ getAsync();
+ }
+
+ /** {@inheritDoc} */
+ @Override public Collection<Integer> invalidPartitions() {
+ return retries == null ? Collections.<Integer>emptyList() : retries;
+ }
+
+ /**
+ * @param key Key.
+ * @return {@code True} if mapped.
+ */
+ private boolean map(KeyCacheObject key) {
+ GridDhtLocalPartition part = topVer.topologyVersion() > 0 ?
+ cache().topology().localPartition(cctx.affinity().partition(key), topVer, true) :
+ cache().topology().localPartition(key, false);
+
+ if (part == null)
+ return false;
+
+ assert this.part == -1;
+
+ // By reserving, we make sure that partition won't be unloaded while processed.
+ if (part.reserve()) {
+ this.part = part.id();
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings( {"unchecked", "IfMayBeConditional"})
+ private void getAsync() {
+ assert part != -1;
+
+ String taskName0 = cctx.kernalContext().job().currentTaskName();
+
+ if (taskName0 == null)
+ taskName0 = cctx.kernalContext().task().resolveTaskName(taskNameHash);
+
+ final String taskName = taskName0;
+
+ IgniteInternalFuture<Boolean> rdrFut = null;
+
+ ClusterNode readerNode = cctx.discovery().node(reader);
+
+ if (readerNode != null && !readerNode.isLocal() && cctx.discovery().cacheNearNode(readerNode, cctx.name())) {
+ while (true) {
+ GridDhtCacheEntry e = cache().entryExx(key, topVer);
+
+ try {
+ if (e.obsolete())
+ continue;
+
+ boolean addReader = (!e.deleted() && addRdr && !skipVals);
+
+ if (addReader)
+ e.unswap(false);
+
+ // Register reader. If there are active transactions for this entry,
+ // then will wait for their completion before proceeding.
+ // TODO: GG-4003:
+ // TODO: What if any transaction we wait for actually removes this entry?
+ // TODO: In this case seems like we will be stuck with untracked near entry.
+ // TODO: To fix, check that reader is contained in the list of readers once
+ // TODO: again after the returned future completes - if not, try again.
+ rdrFut = addReader ? e.addReader(reader, msgId, topVer) : null;
+
+ break;
+ }
+ catch (IgniteCheckedException err) {
+ onDone(err);
+
+ return;
+ }
+ catch (GridCacheEntryRemovedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Got removed entry when getting a DHT value: " + e);
+ }
+ finally {
+ cctx.evicts().touch(e, topVer);
+ }
+ }
+ }
+
+ IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut;
+
+ if (rdrFut == null || rdrFut.isDone()) {
+ if (tx == null) {
+ fut = cache().getDhtAllAsync(
+ Collections.singleton(key),
+ readThrough,
+ subjId,
+ taskName,
+ expiryPlc,
+ skipVals,
+ /*can remap*/true);
+ }
+ else {
+ fut = tx.getAllAsync(cctx,
+ Collections.singleton(key),
+ /*deserialize binary*/false,
+ skipVals,
+ /*keep cache objects*/true,
+ /*skip store*/!readThrough,
+ false);
+ }
+ }
+ else {
+ rdrFut.listen(
+ new IgniteInClosure<IgniteInternalFuture<Boolean>>() {
+ @Override public void apply(IgniteInternalFuture<Boolean> fut) {
+ Throwable e = fut.error();
+
+ if (e != null) {
+ onDone(e);
+
+ return;
+ }
+
+ IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut0;
+
+ if (tx == null) {
+ fut0 = cache().getDhtAllAsync(
+ Collections.singleton(key),
+ readThrough,
+ subjId,
+ taskName,
+ expiryPlc,
+ skipVals,
+ /*can remap*/true);
+ }
+ else {
+ fut0 = tx.getAllAsync(cctx,
+ Collections.singleton(key),
+ /*deserialize binary*/false,
+ skipVals,
+ /*keep cache objects*/true,
+ /*skip store*/!readThrough,
+ false
+ );
+ }
+
+ fut0.listen(createGetFutureListener());
+ }
+ }
+ );
+
+ return;
+ }
+
+ if (fut.isDone())
+ onResult(fut);
+ else
+ fut.listen(createGetFutureListener());
+ }
+
+ /**
+ * @return Listener for get future.
+ */
+ @NotNull private IgniteInClosure<IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>>>
+ createGetFutureListener() {
+ return new IgniteInClosure<IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>>>() {
+ @Override public void apply(
+ IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut
+ ) {
+ onResult(fut);
+ }
+ };
+ }
+
+ /**
+ * @param fut Completed future to finish this process with.
+ */
+ private void onResult(IgniteInternalFuture<Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>>> fut) {
+ assert fut.isDone();
+
+ if (fut.error() != null)
+ onDone(fut.error());
+ else {
+ try {
+ onDone(toEntryInfo(fut.get()));
+ }
+ catch (IgniteCheckedException e) {
+ assert false; // Should never happen.
+ }
+ }
+ }
+
+ /**
+ * @param map Map to convert.
+ * @return List of infos.
+ */
+ private GridCacheEntryInfo toEntryInfo(Map<KeyCacheObject, T2<CacheObject, GridCacheVersion>> map) {
+ if (map.isEmpty())
+ return null;
+
+ T2<CacheObject, GridCacheVersion> val = map.get(key);
+
+ assert val != null;
+
+ GridCacheEntryInfo info = new GridCacheEntryInfo();
+
+ info.cacheId(cctx.cacheId());
+ info.key(key);
+ info.value(skipVals ? null : val.get1());
+ info.version(val.get2());
+
+ return info;
+ }
+
+ /**
+ * @return DHT cache.
+ */
+ private GridDhtCacheAdapter<K, V> cache() {
+ return (GridDhtCacheAdapter<K, V>)cctx.cache();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index c4312b5..4fc1eaf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -26,7 +26,6 @@ import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.atomic.AtomicStampedReference;
import java.util.concurrent.locks.ReentrantLock;
import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
@@ -83,8 +82,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
/** State. */
@GridToStringExclude
- private final AtomicStampedReference<GridDhtPartitionState> state =
- new AtomicStampedReference<>(MOVING, 0);
+ private final AtomicLong state = new AtomicLong((long)MOVING.ordinal() << 32);
/** Rent future. */
@GridToStringExclude
@@ -153,8 +151,9 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
* @return {@code false} If such reservation already added.
*/
public boolean addReservation(GridDhtPartitionsReservation r) {
- assert state.getReference() != EVICTED : "we can reserve only active partitions";
- assert state.getStamp() != 0 : "partition must be already reserved before adding group reservation";
+ assert GridDhtPartitionState.fromOrdinal((int)(state.get() >> 32)) != EVICTED :
+ "we can reserve only active partitions";
+ assert (state.get() & 0xFFFF) != 0 : "partition must be already reserved before adding group reservation";
return reservations.addIfAbsent(r);
}
@@ -185,14 +184,14 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
* @return Partition state.
*/
public GridDhtPartitionState state() {
- return state.getReference();
+ return GridDhtPartitionState.fromOrdinal((int)(state.get() >> 32));
}
/**
* @return Reservations.
*/
public int reservations() {
- return state.getStamp();
+ return (int)(state.get() & 0xFFFF);
}
/**
@@ -385,14 +384,12 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
*/
@Override public boolean reserve() {
while (true) {
- int reservations = state.getStamp();
+ long reservations = state.get();
- GridDhtPartitionState s = state.getReference();
-
- if (s == EVICTED)
+ if ((int)(reservations >> 32) == EVICTED.ordinal())
return false;
- if (state.compareAndSet(s, s, reservations, reservations + 1))
+ if (state.compareAndSet(reservations, reservations + 1))
return true;
}
}
@@ -402,17 +399,15 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
*/
@Override public void release() {
while (true) {
- int reservations = state.getStamp();
+ long reservations = state.get();
- if (reservations == 0)
+ if ((int)(reservations & 0xFFFF) == 0)
return;
- GridDhtPartitionState s = state.getReference();
-
- assert s != EVICTED;
+ assert (int)(reservations >> 32) != EVICTED.ordinal();
// Decrement reservations.
- if (state.compareAndSet(s, s, reservations, --reservations)) {
+ if (state.compareAndSet(reservations, --reservations)) {
tryEvict();
break;
@@ -421,23 +416,32 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
}
/**
+ * @param reservations Current aggregated value.
+ * @param toState State to switch to.
+ * @return {@code true} if cas succeeds.
+ */
+ private boolean casState(long reservations, GridDhtPartitionState toState) {
+ return state.compareAndSet(reservations, (reservations & 0xFFFF) | ((long)toState.ordinal() << 32));
+ }
+
+ /**
* @return {@code True} if transitioned to OWNING state.
*/
boolean own() {
while (true) {
- int reservations = state.getStamp();
+ long reservations = state.get();
- GridDhtPartitionState s = state.getReference();
+ int ord = (int)(reservations >> 32);
- if (s == RENTING || s == EVICTED)
+ if (ord == RENTING.ordinal() || ord == EVICTED.ordinal())
return false;
- if (s == OWNING)
+ if (ord == OWNING.ordinal())
return true;
- assert s == MOVING;
+ assert ord == MOVING.ordinal();
- if (state.compareAndSet(MOVING, OWNING, reservations, reservations)) {
+ if (casState(reservations, OWNING)) {
if (log.isDebugEnabled())
log.debug("Owned partition: " + this);
@@ -455,14 +459,14 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
*/
IgniteInternalFuture<?> rent(boolean updateSeq) {
while (true) {
- int reservations = state.getStamp();
+ long reservations = state.get();
- GridDhtPartitionState s = state.getReference();
+ int ord = (int)(reservations >> 32);
- if (s == RENTING || s == EVICTED)
+ if (ord == RENTING.ordinal() || ord == EVICTED.ordinal())
return rent;
- if (state.compareAndSet(s, RENTING, reservations, reservations)) {
+ if (casState(reservations, RENTING)) {
if (log.isDebugEnabled())
log.debug("Moved partition to RENTING state: " + this);
@@ -481,9 +485,13 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
* @param updateSeq Update sequence.
*/
void tryEvictAsync(boolean updateSeq) {
+ long reservations = state.get();
+
+ int ord = (int)(reservations >> 32);
+
if (map.isEmpty() && !GridQueryProcessor.isEnabled(cctx.config()) &&
- state.getReference() == RENTING && state.getStamp() == 0 &&
- state.compareAndSet(RENTING, EVICTED, 0, 0)) {
+ ord == RENTING.ordinal() && (reservations & 0xFFFF) == 0 &&
+ casState(reservations, EVICTED)) {
if (log.isDebugEnabled())
log.debug("Evicted partition: " + this);
@@ -520,13 +528,17 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
*
*/
public void tryEvict() {
- if (state.getReference() != RENTING || state.getStamp() != 0 || groupReserved())
+ long reservations = state.get();
+
+ int ord = (int)(reservations >> 32);
+
+ if (ord != RENTING.ordinal() || (reservations & 0xFFFF) != 0 || groupReserved())
return;
// Attempt to evict partition entries from cache.
clearAll();
- if (map.isEmpty() && state.compareAndSet(RENTING, EVICTED, 0, 0)) {
+ if (map.isEmpty() && casState(reservations, EVICTED)) {
if (log.isDebugEnabled())
log.debug("Evicted partition: " + this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
index 7b49369..041f135 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionState.java
@@ -52,4 +52,4 @@ public enum GridDhtPartitionState {
public boolean active() {
return this != EVICTED;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
index dd06d6f..84889f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopology.java
@@ -112,6 +112,11 @@ public interface GridDhtPartitionTopology {
throws GridDhtInvalidPartitionException;
/**
+ * @param parts Partitions to release (should be reserved before).
+ */
+ public void releasePartitions(int... parts);
+
+ /**
* @param key Cache key.
* @param create If {@code true}, then partition will be created if it's not there.
* @return Local partition.
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index d6fc8f1..0e579ac 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -612,6 +612,15 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
}
/** {@inheritDoc} */
+ @Override public void releasePartitions(int... parts) {
+ assert parts != null;
+ assert parts.length > 0;
+
+ for (int i = 0; i < parts.length; i++)
+ locParts.get(parts[i]).release();
+ }
+
+ /** {@inheritDoc} */
@Override public GridDhtLocalPartition localPartition(Object key, boolean create) {
return localPartition(cctx.affinity().partition(key), AffinityTopologyVersion.NONE, create);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 41b28d5..4c783f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -988,7 +988,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
lastForceFut = cctx.cacheContext(cacheId).preloader().request(keys, tx.topologyVersion());
- if (compFut != null)
+ if (compFut != null && lastForceFut != null)
compFut.add(lastForceFut);
}
@@ -997,11 +997,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
return compFut;
}
- else {
- assert lastForceFut != null;
-
+ else
return lastForceFut;
- }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/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 f6f57ee..6c7bac5 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
@@ -1309,7 +1309,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
) {
IgniteInternalFuture<Object> forceFut = preldr.request(req.keys(), req.topologyVersion());
- if (forceFut.isDone())
+ if (forceFut == null || forceFut.isDone())
updateAllAsyncInternal0(nodeId, req, completionCb);
else {
forceFut.listen(new CI1<IgniteInternalFuture<Object>>() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index dc4b6bd..1a2eb22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -897,28 +897,24 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
IgniteInternalFuture<Object> keyFut = ctx.dht().dhtPreloader().request(keys, topVer);
// Prevent embedded future creation if possible.
- if (keyFut.isDone()) {
- try {
- // Check for exception.
- keyFut.get();
-
- return lockAllAsync0(cacheCtx,
- tx,
- threadId,
- ver,
- topVer,
- keys,
- txRead,
- retval,
- timeout,
- accessTtl,
- filter,
- skipStore,
- keepBinary);
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
+ if (keyFut == null || keyFut.isDone()) {
+ // Check for exception.
+ if (keyFut != null && keyFut.error() != null)
+ return new GridFinishedFuture<>(keyFut.error());
+
+ return lockAllAsync0(cacheCtx,
+ tx,
+ threadId,
+ ver,
+ topVer,
+ keys,
+ txRead,
+ retval,
+ timeout,
+ accessTtl,
+ filter,
+ skipStore,
+ keepBinary);
}
else {
return new GridEmbeddedFuture<>(keyFut,
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index f0054e4..6ec02a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -403,6 +403,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
try {
demandLock.readLock().lock();
+
try {
demander.handleSupplyMessage(idx, id, s);
}
@@ -692,12 +693,27 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
}
}
+ /** {@inheritDoc} */
+ @Override public boolean needForceKeys() {
+ if (cctx.rebalanceEnabled()) {
+ IgniteInternalFuture<Boolean> rebalanceFut = rebalanceFuture();
+
+ if (rebalanceFut.isDone() && Boolean.TRUE.equals(rebalanceFut.result()))
+ return false;
+ }
+
+ return true;
+ }
+
/**
* @param keys Keys to request.
* @return Future for request.
*/
@SuppressWarnings( {"unchecked", "RedundantCast"})
@Override public GridDhtFuture<Object> request(Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer) {
+ if (!needForceKeys())
+ return null;
+
final GridDhtForceKeysFuture<?, ?> fut = new GridDhtForceKeysFuture<>(cctx, topVer, keys, this);
IgniteInternalFuture<?> topReadyFut = cctx.affinity().affinityReadyFuturex(topVer);
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
index b7b480e..0853b77 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
@@ -23,7 +23,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import javax.cache.expiry.ExpiryPolicy;
import org.apache.ignite.IgniteCheckedException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 54dd69e..2e825b2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -302,7 +302,7 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
ClassLoader ldr = ctx.p2pEnabled() ?
IgniteUtils.detectClassLoader(IgniteUtils.detectClass(this.val)) : U.gridClassLoader();
- Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
+ Object val = ctx.processor().unmarshal(ctx, valBytes, ldr);
return new KeyCacheObjectImpl(val, valBytes);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index c382497..3409341 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -258,7 +258,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> implements Ig
/**
* @return Futures size.
*/
- private int futuresSize() {
+ protected int futuresSize() {
synchronized (futs) {
return futs.size();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
index c7679c0..75fa9f2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioServer.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.util.nio;
import java.io.IOException;
+import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
@@ -43,10 +44,10 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
-
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
@@ -102,6 +103,24 @@ public class GridNioServer<T> {
/** SSL write buf limit. */
private static final int WRITE_BUF_LIMIT = GridNioSessionMetaKey.nextUniqueKey();
+ /** */
+ private static final boolean DISABLE_KEYSET_OPTIMIZATION =
+ IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_NO_SELECTOR_OPTS);
+
+ /**
+ *
+ */
+ static {
+ // This is a workaround for JDK bug (NPE in Selector.open()).
+ // http://bugs.sun.com/view_bug.do?bug_id=6427854
+ try {
+ Selector.open().close();
+ }
+ catch (IOException ignored) {
+ // No-op.
+ }
+ }
+
/** Accept worker thread. */
@GridToStringExclude
private final IgniteThread acceptThread;
@@ -184,17 +203,6 @@ public class GridNioServer<T> {
/** Optional listener to monitor outbound message queue size. */
private IgniteBiInClosure<GridNioSession, Integer> msgQueueLsnr;
- /** Static initializer ensures single-threaded execution of workaround. */
- static {
- // This is a workaround for JDK bug (NPE in Selector.open()).
- // http://bugs.sun.com/view_bug.do?bug_id=6427854
- try {
- Selector.open().close();
- }
- catch (IOException ignored) {
- }
- }
-
/**
* @param addr Address.
* @param port Port.
@@ -445,10 +453,8 @@ public class GridNioServer<T> {
// Change from 0 to 1 means that worker thread should be waken up.
clientWorkers.get(ses.selectorIndex()).offer(fut);
- IgniteBiInClosure<GridNioSession, Integer> lsnr0 = msgQueueLsnr;
-
- if (lsnr0 != null)
- lsnr0.apply(ses, msgCnt);
+ if (msgQueueLsnr != null)
+ msgQueueLsnr.apply(ses, msgCnt);
}
/**
@@ -1239,6 +1245,9 @@ public class GridNioServer<T> {
/** Selector to select read events. */
private Selector selector;
+ /** Selected keys. */
+ private SelectedSelectionKeySet selectedKeys;
+
/** Worker index. */
private final int idx;
@@ -1253,7 +1262,7 @@ public class GridNioServer<T> {
throws IgniteCheckedException {
super(gridName, name, log);
- selector = createSelector(null);
+ createSelector();
this.idx = idx;
}
@@ -1262,10 +1271,11 @@ public class GridNioServer<T> {
@Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
try {
boolean reset = false;
+
while (!closed) {
try {
if (reset)
- selector = createSelector(null);
+ createSelector();
bodyInternal();
}
@@ -1290,6 +1300,50 @@ public class GridNioServer<T> {
}
/**
+ * @throws IgniteCheckedException If failed.
+ */
+ private void createSelector() throws IgniteCheckedException {
+ selectedKeys = null;
+
+ selector = GridNioServer.this.createSelector(null);
+
+ if (DISABLE_KEYSET_OPTIMIZATION)
+ return;
+
+ try {
+ SelectedSelectionKeySet selectedKeySet = new SelectedSelectionKeySet();
+
+ Class<?> selectorImplClass =
+ Class.forName("sun.nio.ch.SelectorImpl", false, U.gridClassLoader());
+
+ // Ensure the current selector implementation is what we can instrument.
+ if (!selectorImplClass.isAssignableFrom(selector.getClass()))
+ return;
+
+ Field selectedKeysField = selectorImplClass.getDeclaredField("selectedKeys");
+ Field publicSelectedKeysField = selectorImplClass.getDeclaredField("publicSelectedKeys");
+
+ selectedKeysField.setAccessible(true);
+ publicSelectedKeysField.setAccessible(true);
+
+ selectedKeysField.set(selector, selectedKeySet);
+ publicSelectedKeysField.set(selector, selectedKeySet);
+
+ selectedKeys = selectedKeySet;
+
+ if (log.isDebugEnabled())
+ log.debug("Instrumented an optimized java.util.Set into: " + selector);
+ }
+ catch (Exception e) {
+ selectedKeys = null;
+
+ if (log.isDebugEnabled())
+ log.debug("Failed to instrument an optimized java.util.Set into selector [selector=" + selector
+ + ", err=" + e + ']');
+ }
+ }
+
+ /**
* Adds socket channel to the registration queue and wakes up reading thread.
*
* @param req Change request.
@@ -1385,7 +1439,10 @@ public class GridNioServer<T> {
// Wake up every 2 seconds to check if closed.
if (selector.select(2000) > 0) {
// Walk through the ready keys collection and process network events.
- processSelectedKeys(selector.selectedKeys());
+ if (selectedKeys == null)
+ processSelectedKeys(selector.selectedKeys());
+ else
+ processSelectedKeysOptimized(selectedKeys.flip());
}
long now = U.currentTimeMillis();
@@ -1431,10 +1488,58 @@ public class GridNioServer<T> {
* @param keys Selected keys.
* @throws ClosedByInterruptException If this thread was interrupted while reading data.
*/
+ private void processSelectedKeysOptimized(SelectionKey[] keys) throws ClosedByInterruptException {
+ for (int i = 0; ; i ++) {
+ final SelectionKey key = keys[i];
+
+ if (key == null)
+ break;
+
+ // null out entry in the array to allow to have it GC'ed once the Channel close
+ // See https://github.com/netty/netty/issues/2363
+ keys[i] = null;
+
+ // Was key closed?
+ if (!key.isValid())
+ continue;
+
+ GridSelectorNioSessionImpl ses = (GridSelectorNioSessionImpl)key.attachment();
+
+ assert ses != null;
+
+ try {
+ if (key.isReadable())
+ processRead(key);
+
+ if (key.isValid() && key.isWritable())
+ processWrite(key);
+ }
+ catch (ClosedByInterruptException e) {
+ // This exception will be handled in bodyInternal() method.
+ throw e;
+ }
+ catch (Exception e) {
+ if (!closed)
+ U.warn(log, "Failed to process selector key (will close): " + ses, e);
+
+ close(ses, new GridNioException(e));
+ }
+ }
+ }
+
+ /**
+ * Processes keys selected by a selector.
+ *
+ * @param keys Selected keys.
+ * @throws ClosedByInterruptException If this thread was interrupted while reading data.
+ */
private void processSelectedKeys(Set<SelectionKey> keys) throws ClosedByInterruptException {
if (log.isTraceEnabled())
log.trace("Processing keys in client worker: " + keys.size());
+ if (keys.isEmpty())
+ return;
+
for (Iterator<SelectionKey> iter = keys.iterator(); iter.hasNext(); ) {
SelectionKey key = iter.next();
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
index deb7d2b..1241f99 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridSelectorNioSessionImpl.java
@@ -309,4 +309,4 @@ class GridSelectorNioSessionImpl extends GridNioSessionImpl {
@Override public String toString() {
return S.toString(GridSelectorNioSessionImpl.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
new file mode 100644
index 0000000..9aa245d
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/SelectedSelectionKeySet.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2013 The Netty Project
+ *
+ * The Netty Project licenses this file to you under the Apache License,
+ * version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.ignite.internal.util.nio;
+
+
+import java.nio.channels.SelectionKey;
+import java.util.AbstractSet;
+import java.util.Iterator;
+
+final class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
+
+ private SelectionKey[] keysA;
+ private int keysASize;
+ private SelectionKey[] keysB;
+ private int keysBSize;
+ private boolean isA = true;
+
+ SelectedSelectionKeySet() {
+ keysA = new SelectionKey[1024];
+ keysB = keysA.clone();
+ }
+
+ @Override
+ public boolean add(SelectionKey o) {
+ if (o == null) {
+ return false;
+ }
+
+ if (isA) {
+ int size = keysASize;
+ keysA[size ++] = o;
+ keysASize = size;
+ if (size == keysA.length) {
+ doubleCapacityA();
+ }
+ } else {
+ int size = keysBSize;
+ keysB[size ++] = o;
+ keysBSize = size;
+ if (size == keysB.length) {
+ doubleCapacityB();
+ }
+ }
+
+ return true;
+ }
+
+ private void doubleCapacityA() {
+ SelectionKey[] newKeysA = new SelectionKey[keysA.length << 1];
+ System.arraycopy(keysA, 0, newKeysA, 0, keysASize);
+ keysA = newKeysA;
+ }
+
+ private void doubleCapacityB() {
+ SelectionKey[] newKeysB = new SelectionKey[keysB.length << 1];
+ System.arraycopy(keysB, 0, newKeysB, 0, keysBSize);
+ keysB = newKeysB;
+ }
+
+ SelectionKey[] flip() {
+ if (isA) {
+ isA = false;
+ keysA[keysASize] = null;
+ keysBSize = 0;
+ return keysA;
+ } else {
+ isA = true;
+ keysB[keysBSize] = null;
+ keysASize = 0;
+ return keysB;
+ }
+ }
+
+ @Override
+ public int size() {
+ if (isA) {
+ return keysASize;
+ } else {
+ return keysBSize;
+ }
+ }
+
+ @Override
+ public boolean remove(Object o) {
+ return false;
+ }
+
+ @Override
+ public boolean contains(Object o) {
+ return false;
+ }
+
+ @Override
+ public Iterator<SelectionKey> iterator() {
+ throw new UnsupportedOperationException();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/75961eee/modules/core/src/main/java/org/apache/ignite/lang/IgniteBiTuple.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/lang/IgniteBiTuple.java b/modules/core/src/main/java/org/apache/ignite/lang/IgniteBiTuple.java
index 6098007..89e5f16 100644
--- a/modules/core/src/main/java/org/apache/ignite/lang/IgniteBiTuple.java
+++ b/modules/core/src/main/java/org/apache/ignite/lang/IgniteBiTuple.java
@@ -250,7 +250,9 @@ public class IgniteBiTuple<V1, V2> implements Map<V1, V2>, Map.Entry<V1, V2>,
/** {@inheritDoc} */
@Override public Set<Map.Entry<V1, V2>> entrySet() {
- return Collections.<Entry<V1, V2>>singleton(this);
+ return isEmpty() ?
+ Collections.<Entry<V1,V2>>emptySet() :
+ Collections.<Entry<V1, V2>>singleton(this);
}
/** {@inheritDoc} */
@@ -301,4 +303,4 @@ public class IgniteBiTuple<V1, V2> implements Map<V1, V2>, Map.Entry<V1, V2>,
@Override public String toString() {
return S.toString(IgniteBiTuple.class, this);
}
-}
\ No newline at end of file
+}
[36/50] [abbrv] ignite git commit: IGNITE-1759: .NET: Improved GUID
handling for different platforms and endians. This closes #437.
Posted by vo...@apache.org.
IGNITE-1759: .NET: Improved GUID handling for different platforms and endians. This closes #437.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f07adff7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f07adff7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f07adff7
Branch: refs/heads/ignite-1786
Commit: f07adff7bb601971bb6c83b0459113678f387592
Parents: e88cc67
Author: Pavel Tupitsyn <pt...@gridgain.com>
Authored: Mon Feb 8 10:30:57 2016 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Mon Feb 8 10:30:57 2016 +0300
----------------------------------------------------------------------
.../Binary/BinarySelfTest.cs | 32 ++++
.../Impl/Binary/BinaryUtils.cs | 166 ++++++++++++++++---
2 files changed, 172 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/f07adff7/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
index 44db6f7..f49a28a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Binary/BinarySelfTest.cs
@@ -26,12 +26,15 @@ namespace Apache.Ignite.Core.Tests.Binary
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.IO;
using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Impl.Binary;
using Apache.Ignite.Core.Impl.Binary.IO;
using NUnit.Framework;
+ using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+ using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
/// <summary>
///
@@ -476,6 +479,35 @@ namespace Apache.Ignite.Core.Tests.Binary
Assert.AreEqual(vals, newVals);
}
+ /// <summary>
+ /// Checks that both methods produce identical results.
+ /// </summary>
+ [Test]
+ public void TestGuidSlowFast()
+ {
+ var stream = new BinaryHeapStream(128);
+
+ var guid = Guid.NewGuid();
+
+ BinaryUtils.WriteGuidFast(guid, stream);
+
+ stream.Seek(0, SeekOrigin.Begin);
+ Assert.AreEqual(guid, BinaryUtils.ReadGuidFast(stream));
+
+ stream.Seek(0, SeekOrigin.Begin);
+ Assert.AreEqual(guid, BinaryUtils.ReadGuidSlow(stream));
+
+
+ stream.Seek(0, SeekOrigin.Begin);
+ BinaryUtils.WriteGuidFast(guid, stream);
+
+ stream.Seek(0, SeekOrigin.Begin);
+ Assert.AreEqual(guid, BinaryUtils.ReadGuidFast(stream));
+
+ stream.Seek(0, SeekOrigin.Begin);
+ Assert.AreEqual(guid, BinaryUtils.ReadGuidSlow(stream));
+ }
+
/**
* <summary>Check write of enum.</summary>
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/f07adff7/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
index 06dec2c..9066bd1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryUtils.cs
@@ -243,6 +243,17 @@ namespace Apache.Ignite.Core.Impl.Binary
private static readonly CopyOnWriteConcurrentDictionary<Type, Func<BinaryReader, bool, object>>
ArrayReaders = new CopyOnWriteConcurrentDictionary<Type, Func<BinaryReader, bool, object>>();
+ /** Flag indicating whether Guid struct is sequential in current runtime. */
+ private static readonly bool IsGuidSequential = GetIsGuidSequential();
+
+ /** Guid writer. */
+ public static readonly Action<Guid, IBinaryStream> WriteGuid = IsGuidSequential
+ ? (Action<Guid, IBinaryStream>)WriteGuidFast : WriteGuidSlow;
+
+ /** Guid reader. */
+ public static readonly Func<IBinaryStream, Guid?> ReadGuid = IsGuidSequential
+ ? (Func<IBinaryStream, Guid?>)ReadGuidFast : ReadGuidSlow;
+
/// <summary>
/// Default marshaller.
/// </summary>
@@ -900,12 +911,33 @@ namespace Apache.Ignite.Core.Impl.Binary
return vals;
}
- /**
- * <summary>Write GUID.</summary>
- * <param name="val">GUID.</param>
- * <param name="stream">Stream.</param>
- */
- public static unsafe void WriteGuid(Guid val, IBinaryStream stream)
+ /// <summary>
+ /// Gets a value indicating whether <see cref="Guid"/> fields are stored sequentially in memory.
+ /// </summary>
+ /// <returns></returns>
+ private static unsafe bool GetIsGuidSequential()
+ {
+ // Check that bitwise conversion returns correct result
+ var guid = Guid.NewGuid();
+
+ var bytes = guid.ToByteArray();
+
+ var bytes0 = (byte*) &guid;
+
+ for (var i = 0; i < bytes.Length; i++)
+ if (bytes[i] != bytes0[i])
+ return false;
+
+ return true;
+ }
+
+ /// <summary>
+ /// Writes a guid with bitwise conversion, assuming that <see cref="Guid"/>
+ /// is laid out in memory sequentially and without gaps between fields.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ /// <param name="stream">The stream.</param>
+ public static unsafe void WriteGuidFast(Guid val, IBinaryStream stream)
{
var jguid = new JavaGuid(val);
@@ -913,13 +945,47 @@ namespace Apache.Ignite.Core.Impl.Binary
stream.Write((byte*) ptr, 16);
}
-
- /**
- * <summary>Read GUID.</summary>
- * <param name="stream">Stream.</param>
- * <returns>GUID</returns>
- */
- public static unsafe Guid? ReadGuid(IBinaryStream stream)
+
+ /// <summary>
+ /// Writes a guid byte by byte.
+ /// </summary>
+ /// <param name="val">The value.</param>
+ /// <param name="stream">The stream.</param>
+ public static unsafe void WriteGuidSlow(Guid val, IBinaryStream stream)
+ {
+ var bytes = val.ToByteArray();
+ byte* jBytes = stackalloc byte[16];
+
+ jBytes[0] = bytes[6]; // c1
+ jBytes[1] = bytes[7]; // c2
+
+ jBytes[2] = bytes[4]; // b1
+ jBytes[3] = bytes[5]; // b2
+
+ jBytes[4] = bytes[0]; // a1
+ jBytes[5] = bytes[1]; // a2
+ jBytes[6] = bytes[2]; // a3
+ jBytes[7] = bytes[3]; // a4
+
+ jBytes[8] = bytes[15]; // k
+ jBytes[9] = bytes[14]; // j
+ jBytes[10] = bytes[13]; // i
+ jBytes[11] = bytes[12]; // h
+ jBytes[12] = bytes[11]; // g
+ jBytes[13] = bytes[10]; // f
+ jBytes[14] = bytes[9]; // e
+ jBytes[15] = bytes[8]; // d
+
+ stream.Write(jBytes, 16);
+ }
+
+ /// <summary>
+ /// Reads a guid with bitwise conversion, assuming that <see cref="Guid"/>
+ /// is laid out in memory sequentially and without gaps between fields.
+ /// </summary>
+ /// <param name="stream">The stream.</param>
+ /// <returns>Guid.</returns>
+ public static unsafe Guid? ReadGuidFast(IBinaryStream stream)
{
JavaGuid jguid;
@@ -931,7 +997,43 @@ namespace Apache.Ignite.Core.Impl.Binary
return *(Guid*) (&dotnetGuid);
}
-
+
+ /// <summary>
+ /// Reads a guid byte by byte.
+ /// </summary>
+ /// <param name="stream">The stream.</param>
+ /// <returns>Guid.</returns>
+ public static unsafe Guid? ReadGuidSlow(IBinaryStream stream)
+ {
+ byte* jBytes = stackalloc byte[16];
+
+ stream.Read(jBytes, 16);
+
+ var bytes = new byte[16];
+
+ bytes[0] = jBytes[4]; // a1
+ bytes[1] = jBytes[5]; // a2
+ bytes[2] = jBytes[6]; // a3
+ bytes[3] = jBytes[7]; // a4
+
+ bytes[4] = jBytes[2]; // b1
+ bytes[5] = jBytes[3]; // b2
+
+ bytes[6] = jBytes[0]; // c1
+ bytes[7] = jBytes[1]; // c2
+
+ bytes[8] = jBytes[15]; // d
+ bytes[9] = jBytes[14]; // e
+ bytes[10] = jBytes[13]; // f
+ bytes[11] = jBytes[12]; // g
+ bytes[12] = jBytes[11]; // h
+ bytes[13] = jBytes[10]; // i
+ bytes[14] = jBytes[9]; // j
+ bytes[15] = jBytes[8]; // k
+
+ return new Guid(bytes);
+ }
+
/// <summary>
/// Write GUID array.
/// </summary>
@@ -1689,7 +1791,7 @@ namespace Apache.Ignite.Core.Impl.Binary
private struct GuidAccessor
{
public readonly ulong ABC;
- public readonly ulong DEGHIJK;
+ public readonly ulong DEFGHIJK;
/// <summary>
/// Initializes a new instance of the <see cref="GuidAccessor"/> struct.
@@ -1699,21 +1801,28 @@ namespace Apache.Ignite.Core.Impl.Binary
{
var l = val.CBA;
- ABC = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
- ((l << 16) & 0x0000FFFF00000000);
+ if (BitConverter.IsLittleEndian)
+ ABC = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
+ ((l << 16) & 0x0000FFFF00000000);
+ else
+ ABC = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
+ ((l >> 16) & 0x00000000FFFF0000);
- DEGHIJK = ReverseByteOrder(val.KJIHGED);
+ // This is valid in any endianness (symmetrical)
+ DEFGHIJK = ReverseByteOrder(val.KJIHGFED);
}
}
/// <summary>
/// Struct with Java-style Guid memory layout.
/// </summary>
- [StructLayout(LayoutKind.Sequential, Pack = 0)]
+ [StructLayout(LayoutKind.Explicit)]
private struct JavaGuid
{
- public readonly ulong CBA;
- public readonly ulong KJIHGED;
+ [FieldOffset(0)] public readonly ulong CBA;
+ [FieldOffset(8)] public readonly ulong KJIHGFED;
+ [SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
+ [FieldOffset(0)] public unsafe fixed byte Bytes [16];
/// <summary>
/// Initializes a new instance of the <see cref="JavaGuid"/> struct.
@@ -1721,17 +1830,22 @@ namespace Apache.Ignite.Core.Impl.Binary
/// <param name="val">The value.</param>
public unsafe JavaGuid(Guid val)
{
- // .Net returns bytes in the following order: _a(4), _b(2), _c(2), _d, _e, _g, _h, _i, _j, _k.
+ // .Net returns bytes in the following order: _a(4), _b(2), _c(2), _d, _e, _f, _g, _h, _i, _j, _k.
// And _a, _b and _c are always in little endian format irrespective of system configuration.
- // To be compliant with Java we rearrange them as follows: _c, _b_, a_, _k, _j, _i, _h, _g, _e, _d.
+ // To be compliant with Java we rearrange them as follows: _c, _b_, a_, _k, _j, _i, _h, _g, _f, _e, _d.
var accessor = *((GuidAccessor*)&val);
var l = accessor.ABC;
- CBA = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
- ((l >> 16) & 0x00000000FFFF0000);
+ if (BitConverter.IsLittleEndian)
+ CBA = ((l << 32) & 0xFFFFFFFF00000000) | ((l >> 48) & 0x000000000000FFFF) |
+ ((l >> 16) & 0x00000000FFFF0000);
+ else
+ CBA = ((l >> 32) & 0x00000000FFFFFFFF) | ((l << 48) & 0xFFFF000000000000) |
+ ((l << 16) & 0x0000FFFF00000000);
- KJIHGED = ReverseByteOrder(accessor.DEGHIJK);
+ // This is valid in any endianness (symmetrical)
+ KJIHGFED = ReverseByteOrder(accessor.DEFGHIJK);
}
}
}
[46/50] [abbrv] ignite git commit: IGNITE-1563 .NET: Implemented
"atomics": AtomicReference and AtomicSequence. This closes #455.
Posted by vo...@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-1786
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);
[15/50] [abbrv] ignite git commit: Minor exception message fix
Posted by vo...@apache.org.
Minor exception message fix
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/57194e2a
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/57194e2a
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/57194e2a
Branch: refs/heads/ignite-1786
Commit: 57194e2a6bb82719d63f658f8c1429569003214e
Parents: a87decd
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Feb 2 16:35:42 2016 -0800
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Feb 2 16:35:42 2016 -0800
----------------------------------------------------------------------
.../core/src/main/java/org/apache/ignite/internal/IgnitionEx.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/57194e2a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 8f23b05..193e28e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -118,7 +118,6 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_KEEP_ALIVE_TIME;
import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_PUBLIC_THREADPOOL_QUEUE_CAP;
import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_KEEP_ALIVE_TIME;
-import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_MAX_THREAD_CNT;
import static org.apache.ignite.configuration.IgniteConfiguration.DFLT_SYSTEM_THREADPOOL_QUEUE_CAP;
import static org.apache.ignite.internal.IgniteComponentType.SPRING;
import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.RESTART_JVM;
@@ -986,7 +985,7 @@ public class IgnitionEx {
if (old != null) {
if (name == null)
- throw new IgniteCheckedException("Default grid instance has already been started.");
+ throw new IgniteCheckedException("Default Ignite instance has already been started.");
else
throw new IgniteCheckedException("Ignite instance with this name has already been started: " + name);
}
[39/50] [abbrv] ignite git commit: Merge remote-tracking branch
'apache-main/master' into master-main
Posted by vo...@apache.org.
Merge remote-tracking branch 'apache-main/master' into master-main
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/a383f2e7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/a383f2e7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/a383f2e7
Branch: refs/heads/ignite-1786
Commit: a383f2e79401ecf5f60526aeec4bd8fa51679013
Parents: bf3a5ea d844e95
Author: Denis Magda <dm...@gridgain.com>
Authored: Mon Feb 8 13:43:06 2016 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Mon Feb 8 13:43:06 2016 +0300
----------------------------------------------------------------------
.../Binary/BinarySelfTest.cs | 32 ++++
.../Impl/Binary/BinaryUtils.cs | 166 ++++++++++++++++---
2 files changed, 172 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
[05/50] [abbrv] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.cs
new file mode 100644
index 0000000..25adf56
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Multicast/TcpDiscoveryMulticastIpFinder.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.Discovery.Tcp.Multicast
+{
+ using System;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Multicast-based IP finder.
+ /// <para />
+ /// When TCP discovery starts this finder sends multicast request and waits
+ /// for some time when others nodes reply to this request with messages containing their addresses
+ /// </summary>
+ public class TcpDiscoveryMulticastIpFinder : TcpDiscoveryStaticIpFinder
+ {
+ /// <summary>
+ /// Default multicast port.
+ /// </summary>
+ public const int DefaultMulticastPort = 47400;
+
+ /// <summary>
+ /// Default address request attempts.
+ /// </summary>
+ public const int DefaultAddressRequestAttempts = 2;
+
+ /// <summary>
+ /// Default response timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultResponseTimeout = TimeSpan.FromMilliseconds(500);
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+ /// </summary>
+ public TcpDiscoveryMulticastIpFinder()
+ {
+ MulticastPort = DefaultMulticastPort;
+ AddressRequestAttempts = DefaultAddressRequestAttempts;
+ ResponseTimeout = DefaultResponseTimeout;
+ }
+
+ /// <summary>
+ /// Gets or sets the local address.
+ /// If provided address is non-loopback then multicast socket is bound to this interface.
+ /// If local address is not set or is any local address then IP finder
+ /// creates multicast sockets for all found non-loopback addresses.
+ /// </summary>
+ public string LocalAddress { get; set; }
+
+ /// <summary>
+ /// Gets or sets the IP address of the multicast group.
+ /// </summary>
+ public string MulticastGroup { get; set; }
+
+ /// <summary>
+ /// Gets or sets the port number which multicast messages are sent to.
+ /// </summary>
+ [DefaultValue(DefaultMulticastPort)]
+ public int MulticastPort { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of attempts to send multicast address request. IP finder re-sends
+ /// request only in case if no reply for previous request is received.
+ /// </summary>
+ [DefaultValue(DefaultAddressRequestAttempts)]
+ public int AddressRequestAttempts { get; set; }
+
+ /// <summary>
+ /// Gets or sets the response timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:00.5")]
+ public TimeSpan ResponseTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the time to live for multicast packets sent out on this
+ /// IP finder in order to control the scope of the multicast.
+ /// </summary>
+ public byte? TimeToLive { get; set; } // TODO: Nullable?
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryMulticastIpFinder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoveryMulticastIpFinder(IBinaryRawReader reader) : base(reader)
+ {
+ LocalAddress = reader.ReadString();
+ MulticastGroup = reader.ReadString();
+ MulticastPort = reader.ReadInt();
+ AddressRequestAttempts = reader.ReadInt();
+ ResponseTimeout = TimeSpan.FromMilliseconds(reader.ReadInt());
+ TimeToLive = reader.ReadBoolean() ? (byte?) reader.ReadInt() : null;
+ }
+
+ /** <inheritdoc /> */
+ internal override void Write(IBinaryRawWriter writer)
+ {
+ base.Write(writer);
+
+ writer.WriteString(LocalAddress);
+ writer.WriteString(MulticastGroup);
+ writer.WriteInt(MulticastPort);
+ writer.WriteInt(AddressRequestAttempts);
+ writer.WriteInt((int) ResponseTimeout.TotalMilliseconds);
+
+ writer.WriteBoolean(TimeToLive.HasValue);
+
+ if (TimeToLive.HasValue)
+ writer.WriteInt(TimeToLive.Value);
+ }
+
+ /** <inheritdoc /> */
+ protected override byte TypeCode
+ {
+ get { return TypeCodeMulticastIpFinder; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
new file mode 100644
index 0000000..331ca48
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/Static/TcpDiscoveryStaticIpFinder.cs
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp.Static
+{
+ using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+ using Apache.Ignite.Core.Binary;
+
+ /// <summary>
+ /// IP Finder which works only with pre-configured list of IP addresses.
+ /// </summary>
+ public class TcpDiscoveryStaticIpFinder : TcpDiscoveryIpFinderBase
+ {
+ /// <summary>
+ /// Gets or sets the end points.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<string> Endpoints { get; set; }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+ /// </summary>
+ public TcpDiscoveryStaticIpFinder()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryStaticIpFinder"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoveryStaticIpFinder(IBinaryRawReader reader)
+ {
+ var count = reader.ReadInt();
+
+ if (count > 0)
+ {
+ Endpoints = new List<string>(count);
+
+ for (int i = 0; i < count; i++)
+ Endpoints.Add(reader.ReadString());
+ }
+ }
+
+ /** <inheritdoc /> */
+ internal override void Write(IBinaryRawWriter writer)
+ {
+ base.Write(writer);
+
+ var eps = Endpoints;
+
+ if (eps != null)
+ {
+ writer.WriteInt(eps.Count);
+
+ foreach (var ep in eps)
+ writer.WriteString(ep);
+ }
+ else
+ writer.WriteInt(0);
+ }
+
+ /** <inheritdoc /> */
+ protected override byte TypeCode
+ {
+ get { return TypeCodeVmIpFinder; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
new file mode 100644
index 0000000..e06a88d
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoveryIpFinderBase.cs
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.Discovery.Tcp
+{
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Discovery.Tcp.Multicast;
+ using Apache.Ignite.Core.Discovery.Tcp.Static;
+
+ /// <summary>
+ /// Base IpFinder class.
+ /// </summary>
+ public abstract class TcpDiscoveryIpFinderBase : ITcpDiscoveryIpFinder
+ {
+ /** */
+ protected const byte TypeCodeVmIpFinder = 1;
+
+ /** */
+ protected const byte TypeCodeMulticastIpFinder = 2;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoveryIpFinderBase"/> class.
+ /// Prevents user-defined implementations.
+ /// </summary>
+ protected internal TcpDiscoveryIpFinderBase()
+ {
+ // No-op.
+ }
+
+ /// <summary>
+ /// Writes this instance to the specified writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal virtual void Write(IBinaryRawWriter writer)
+ {
+ writer.WriteByte(TypeCode);
+ }
+
+ /// <summary>
+ /// Gets the type code to be used in Java to determine ip finder type.
+ /// </summary>
+ protected abstract byte TypeCode { get; }
+
+ /// <summary>
+ /// Reads the instance.
+ /// </summary>
+ internal static TcpDiscoveryIpFinderBase ReadInstance(IBinaryRawReader reader)
+ {
+ var code = reader.ReadByte();
+
+ switch (code)
+ {
+ case TypeCodeVmIpFinder:
+ return new TcpDiscoveryStaticIpFinder(reader);
+
+ case TypeCodeMulticastIpFinder:
+ return new TcpDiscoveryMulticastIpFinder(reader);
+
+ default:
+ return null;
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
new file mode 100644
index 0000000..ea946e8
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs
@@ -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.
+ */
+
+namespace Apache.Ignite.Core.Discovery.Tcp
+{
+ using System;
+ using System.ComponentModel;
+ using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Impl.Binary;
+
+ /// <summary>
+ /// TCP discover service provider.
+ /// </summary>
+ public class TcpDiscoverySpi : IDiscoverySpi
+ {
+ /// <summary>
+ /// Default socket timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultSocketTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default acknowledgement timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultAckTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default maximum acknowledgement timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultMaxAckTimeout = TimeSpan.FromMinutes(10);
+
+ /// <summary>
+ /// Default network timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default join timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultJoinTimeout = TimeSpan.Zero;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+ /// </summary>
+ public TcpDiscoverySpi()
+ {
+ SocketTimeout = DefaultSocketTimeout;
+ AckTimeout = DefaultAckTimeout;
+ MaxAckTimeout = DefaultMaxAckTimeout;
+ NetworkTimeout = DefaultNetworkTimeout;
+ JoinTimeout = DefaultJoinTimeout;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TcpDiscoverySpi"/> class.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ internal TcpDiscoverySpi(BinaryReader reader)
+ {
+ IpFinder = reader.ReadBoolean() ? TcpDiscoveryIpFinderBase.ReadInstance(reader) : null;
+
+ SocketTimeout = reader.ReadLongAsTimespan();
+ AckTimeout = reader.ReadLongAsTimespan();
+ MaxAckTimeout = reader.ReadLongAsTimespan();
+ NetworkTimeout = reader.ReadLongAsTimespan();
+ JoinTimeout = reader.ReadLongAsTimespan();
+ }
+
+ /// <summary>
+ /// Gets or sets the IP finder which defines how nodes will find each other on the network.
+ /// </summary>
+ public ITcpDiscoveryIpFinder IpFinder { get; set; }
+
+ /// <summary>
+ /// Gets or sets the socket timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan SocketTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the timeout for receiving acknowledgement for sent message.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan AckTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the maximum timeout for receiving acknowledgement for sent message.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:10:00")]
+ public TimeSpan MaxAckTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan NetworkTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the join timeout.
+ /// </summary>
+ public TimeSpan JoinTimeout { get; set; }
+
+ /// <summary>
+ /// Writes this instance to the specified writer.
+ /// </summary>
+ internal void Write(IBinaryRawWriter writer)
+ {
+ var ipFinder = IpFinder;
+
+ if (ipFinder != null)
+ {
+ writer.WriteBoolean(true);
+
+ var finder = ipFinder as TcpDiscoveryIpFinderBase;
+
+ if (finder == null)
+ throw new InvalidOperationException("Unsupported IP finder: " + ipFinder.GetType());
+
+ finder.Write(writer);
+ }
+ else
+ writer.WriteBoolean(false);
+
+ writer.WriteLong((long) SocketTimeout.TotalMilliseconds);
+ writer.WriteLong((long) AckTimeout.TotalMilliseconds);
+ writer.WriteLong((long) MaxAckTimeout.TotalMilliseconds);
+ writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+ writer.WriteLong((long) JoinTimeout.TotalMilliseconds);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 a85e24c..d18e790 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -21,6 +21,7 @@ namespace Apache.Ignite.Core
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Common;
using Apache.Ignite.Core.Compute;
@@ -93,6 +94,15 @@ namespace Apache.Ignite.Core
ICache<TK, TV> GetOrCreateCache<TK, TV>(string name);
/// <summary>
+ /// Gets existing cache with the given name or creates new one using provided configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="configuration">Cache configuration.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration);
+
+ /// <summary>
/// Dynamically starts new cache using template configuration.
/// </summary>
/// <typeparam name="TK">Cache key type.</typeparam>
@@ -102,8 +112,17 @@ namespace Apache.Ignite.Core
ICache<TK, TV> CreateCache<TK, TV>(string name);
/// <summary>
- /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}"/> or
- /// <see cref="GetOrCreateCache{TK,TV}"/>) cache.
+ /// Dynamically starts new cache using provided configuration.
+ /// </summary>
+ /// <typeparam name="TK">Cache key type.</typeparam>
+ /// <typeparam name="TV">Cache value type.</typeparam>
+ /// <param name="configuration">Cache configuration.</param>
+ /// <returns>Existing or newly created cache.</returns>
+ ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration);
+
+ /// <summary>
+ /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}(string)"/> or
+ /// <see cref="GetOrCreateCache{TK,TV}(string)"/>) cache.
/// </summary>
/// <param name="name">The name of the cache to stop.</param>
void DestroyCache(string name);
@@ -171,5 +190,11 @@ namespace Apache.Ignite.Core
/// or null if it does not exist and <c>create</c> flag is not set.</returns>
/// <exception cref="IgniteException">If atomic long could not be fetched or created.</exception>
IAtomicLong GetAtomicLong(string name, long initialValue, bool create);
+
+ /// <summary>
+ /// Gets the configuration of this Ignite instance.
+ /// </summary>
+ [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
+ IgniteConfiguration GetConfiguration();
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
index a4c37d1..1dd22ea 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfiguration.cs
@@ -15,12 +15,27 @@
* limitations under the License.
*/
-namespace Apache.Ignite.Core
+#pragma warning disable 618 // deprecated SpringConfigUrl
+ namespace Apache.Ignite.Core
{
+ using System;
using System.Collections.Generic;
+ using System.ComponentModel;
+ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+ using System.IO;
+ using System.Linq;
using Apache.Ignite.Core.Binary;
+ using Apache.Ignite.Core.Cache.Configuration;
+ using Apache.Ignite.Core.Discovery;
+ using Apache.Ignite.Core.Discovery.Tcp;
+ using Apache.Ignite.Core.Events;
+ using Apache.Ignite.Core.Impl;
+ using Apache.Ignite.Core.Impl.Binary;
+ using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Lifecycle;
+ using BinaryReader = Apache.Ignite.Core.Impl.Binary.BinaryReader;
+ using BinaryWriter = Apache.Ignite.Core.Impl.Binary.BinaryWriter;
/// <summary>
/// Grid configuration.
@@ -38,40 +53,238 @@ namespace Apache.Ignite.Core
public const int DefaultJvmMaxMem = 1024;
/// <summary>
- /// Default constructor.
+ /// Default metrics expire time.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsExpireTime = TimeSpan.MaxValue;
+
+ /// <summary>
+ /// Default metrics history size.
+ /// </summary>
+ public const int DefaultMetricsHistorySize = 10000;
+
+ /// <summary>
+ /// Default metrics log frequency.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsLogFrequency = TimeSpan.FromMilliseconds(60000);
+
+ /// <summary>
+ /// Default metrics update frequency.
+ /// </summary>
+ public static readonly TimeSpan DefaultMetricsUpdateFrequency = TimeSpan.FromMilliseconds(2000);
+
+ /// <summary>
+ /// Default network timeout.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkTimeout = TimeSpan.FromMilliseconds(5000);
+
+ /// <summary>
+ /// Default network retry delay.
+ /// </summary>
+ public static readonly TimeSpan DefaultNetworkSendRetryDelay = TimeSpan.FromMilliseconds(1000);
+
+ /// <summary>
+ /// Default network retry count.
+ /// </summary>
+ public const int DefaultNetworkSendRetryCount = 3;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
/// </summary>
public IgniteConfiguration()
{
JvmInitialMemoryMb = DefaultJvmInitMem;
JvmMaxMemoryMb = DefaultJvmMaxMem;
+
+ MetricsExpireTime = DefaultMetricsExpireTime;
+ MetricsHistorySize = DefaultMetricsHistorySize;
+ MetricsLogFrequency = DefaultMetricsLogFrequency;
+ MetricsUpdateFrequency = DefaultMetricsUpdateFrequency;
+ NetworkTimeout = DefaultNetworkTimeout;
+ NetworkSendRetryCount = DefaultNetworkSendRetryCount;
+ NetworkSendRetryDelay = DefaultNetworkSendRetryDelay;
}
/// <summary>
- /// Copying constructor.
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class.
/// </summary>
- /// <param name="cfg">Configuration.</param>
- internal IgniteConfiguration(IgniteConfiguration cfg)
+ /// <param name="configuration">The configuration to copy.</param>
+ public IgniteConfiguration(IgniteConfiguration configuration)
{
- SpringConfigUrl = cfg.SpringConfigUrl;
- JvmDllPath = cfg.JvmDllPath;
- IgniteHome = cfg.IgniteHome;
- JvmClasspath = cfg.JvmClasspath;
- SuppressWarnings = cfg.SuppressWarnings;
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ CopyLocalProperties(configuration);
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var marsh = new Marshaller(configuration.BinaryConfiguration);
+
+ configuration.WriteCore(marsh.StartMarshal(stream));
+
+ stream.SynchronizeOutput();
+
+ stream.Seek(0, SeekOrigin.Begin);
+
+ ReadCore(marsh.StartUnmarshal(stream));
+ }
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="IgniteConfiguration"/> class from a reader.
+ /// </summary>
+ /// <param name="binaryReader">The binary reader.</param>
+ internal IgniteConfiguration(BinaryReader binaryReader)
+ {
+ Read(binaryReader);
+ }
+
+ /// <summary>
+ /// Writes this instance to a writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ internal void Write(BinaryWriter writer)
+ {
+ Debug.Assert(writer != null);
+
+ if (!string.IsNullOrEmpty(SpringConfigUrl))
+ {
+ // Do not write details when there is Spring config.
+ writer.WriteBoolean(false);
+ return;
+ }
+
+ writer.WriteBoolean(true); // details are present
+
+ WriteCore(writer);
+ }
+
+ /// <summary>
+ /// Writes this instance to a writer.
+ /// </summary>
+ /// <param name="writer">The writer.</param>
+ private void WriteCore(BinaryWriter writer)
+ {
+ // Simple properties
+ writer.WriteBoolean(ClientMode);
+ writer.WriteIntArray(IncludedEventTypes == null ? null : IncludedEventTypes.ToArray());
+
+ writer.WriteLong((long) MetricsExpireTime.TotalMilliseconds);
+ writer.WriteInt(MetricsHistorySize);
+ writer.WriteLong((long) MetricsLogFrequency.TotalMilliseconds);
+ var metricsUpdateFreq = (long) MetricsUpdateFrequency.TotalMilliseconds;
+ writer.WriteLong(metricsUpdateFreq >= 0 ? metricsUpdateFreq : -1);
+ writer.WriteInt(NetworkSendRetryCount);
+ writer.WriteLong((long) NetworkSendRetryDelay.TotalMilliseconds);
+ writer.WriteLong((long) NetworkTimeout.TotalMilliseconds);
+ writer.WriteString(WorkDirectory);
+ writer.WriteString(Localhost);
+
+ // Cache config
+ var caches = CacheConfiguration;
+
+ if (caches == null)
+ writer.WriteInt(0);
+ else
+ {
+ writer.WriteInt(caches.Count);
+
+ foreach (var cache in caches)
+ cache.Write(writer);
+ }
+
+ // Discovery config
+ var disco = DiscoverySpi;
+
+ if (disco != null)
+ {
+ writer.WriteBoolean(true);
+
+ var tcpDisco = disco as TcpDiscoverySpi;
+
+ if (tcpDisco == null)
+ throw new InvalidOperationException("Unsupported discovery SPI: " + disco.GetType());
+
+ tcpDisco.Write(writer);
+ }
+ else
+ writer.WriteBoolean(false);
+ }
+
+ /// <summary>
+ /// Reads data from specified reader into current instance.
+ /// </summary>
+ /// <param name="r">The binary reader.</param>
+ private void ReadCore(BinaryReader r)
+ {
+ // Simple properties
+ ClientMode = r.ReadBoolean();
+ IncludedEventTypes = r.ReadIntArray();
- JvmOptions = cfg.JvmOptions != null ? new List<string>(cfg.JvmOptions) : null;
- Assemblies = cfg.Assemblies != null ? new List<string>(cfg.Assemblies) : null;
+ MetricsExpireTime = r.ReadLongAsTimespan();
+ MetricsHistorySize = r.ReadInt();
+ MetricsLogFrequency = r.ReadLongAsTimespan();
+ MetricsUpdateFrequency = r.ReadLongAsTimespan();
+ NetworkSendRetryCount = r.ReadInt();
+ NetworkSendRetryDelay = r.ReadLongAsTimespan();
+ NetworkTimeout = r.ReadLongAsTimespan();
+ WorkDirectory = r.ReadString();
+ Localhost = r.ReadString();
- BinaryConfiguration = cfg.BinaryConfiguration != null
- ? new BinaryConfiguration(cfg.BinaryConfiguration)
- : null;
+ // Cache config
+ var cacheCfgCount = r.ReadInt();
+ CacheConfiguration = new List<CacheConfiguration>(cacheCfgCount);
+ for (int i = 0; i < cacheCfgCount; i++)
+ CacheConfiguration.Add(new CacheConfiguration(r));
- LifecycleBeans = cfg.LifecycleBeans != null ? new List<ILifecycleBean>(cfg.LifecycleBeans) : null;
+ // Discovery config
+ DiscoverySpi = r.ReadBoolean() ? new TcpDiscoverySpi(r) : null;
+ }
+
+ /// <summary>
+ /// Reads data from specified reader into current instance.
+ /// </summary>
+ /// <param name="binaryReader">The binary reader.</param>
+ private void Read(BinaryReader binaryReader)
+ {
+ var r = binaryReader;
+
+ CopyLocalProperties(r.Marshaller.Ignite.Configuration);
+
+ ReadCore(r);
+
+ // Misc
+ IgniteHome = r.ReadString();
- JvmInitialMemoryMb = cfg.JvmInitialMemoryMb;
- JvmMaxMemoryMb = cfg.JvmMaxMemoryMb;
+ JvmInitialMemoryMb = (int) (r.ReadLong()/1024/2014);
+ JvmMaxMemoryMb = (int) (r.ReadLong()/1024/2014);
+
+ // Local data (not from reader)
+ JvmDllPath = Process.GetCurrentProcess().Modules.OfType<ProcessModule>()
+ .Single(x => string.Equals(x.ModuleName, IgniteUtils.FileJvmDll, StringComparison.OrdinalIgnoreCase))
+ .FileName;
+ }
+
+ /// <summary>
+ /// Copies the local properties (properties that are not written in Write method).
+ /// </summary>
+ private void CopyLocalProperties(IgniteConfiguration cfg)
+ {
+ GridName = cfg.GridName;
+ BinaryConfiguration = cfg.BinaryConfiguration == null
+ ? null
+ : new BinaryConfiguration(cfg.BinaryConfiguration);
+ JvmClasspath = cfg.JvmClasspath;
+ JvmOptions = cfg.JvmOptions;
+ Assemblies = cfg.Assemblies;
+ SuppressWarnings = cfg.SuppressWarnings;
+ LifecycleBeans = cfg.LifecycleBeans;
}
/// <summary>
+ /// Grid name which is used if not provided in configuration file.
+ /// </summary>
+ public string GridName { get; set; }
+
+ /// <summary>
/// Gets or sets the binary configuration.
/// </summary>
/// <value>
@@ -80,9 +293,22 @@ namespace Apache.Ignite.Core
public BinaryConfiguration BinaryConfiguration { get; set; }
/// <summary>
+ /// Gets or sets the cache configuration.
+ /// </summary>
+ /// <value>
+ /// The cache configuration.
+ /// </value>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<CacheConfiguration> CacheConfiguration { get; set; }
+
+ /// <summary>
/// URL to Spring configuration file.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")]
+ [Obsolete("Ignite.NET can be configured natively without Spring. " +
+ "Setting this property will ignore all other properties except " +
+ "IgniteHome, Assemblies, SuppressWarnings, LifecycleBeans, JvmOptions, JvmdllPath, IgniteHome, " +
+ "JvmInitialMemoryMb, JvmMaxMemoryMb.")]
public string SpringConfigUrl { get; set; }
/// <summary>
@@ -115,7 +341,7 @@ namespace Apache.Ignite.Core
/// assemblies reside.
/// </summary>
[SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
- public IList<string> Assemblies { get; set; }
+ public ICollection<string> Assemblies { get; set; }
/// <summary>
/// Whether to suppress warnings.
@@ -132,12 +358,95 @@ namespace Apache.Ignite.Core
/// Initial amount of memory in megabytes given to JVM. Maps to -Xms Java option.
/// Defaults to <see cref="DefaultJvmInitMem"/>.
/// </summary>
+ [DefaultValue(DefaultJvmInitMem)]
public int JvmInitialMemoryMb { get; set; }
/// <summary>
/// Maximum amount of memory in megabytes given to JVM. Maps to -Xmx Java option.
/// Defaults to <see cref="DefaultJvmMaxMem"/>.
/// </summary>
+ [DefaultValue(DefaultJvmMaxMem)]
public int JvmMaxMemoryMb { get; set; }
+
+ /// <summary>
+ /// Gets or sets the discovery service provider.
+ /// Null for default discovery.
+ /// </summary>
+ public IDiscoverySpi DiscoverySpi { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether node should start in client mode.
+ /// Client node cannot hold data in the caches.
+ /// Default is null and takes this setting from Spring configuration.
+ /// </summary>
+ public bool ClientMode { get; set; }
+
+ /// <summary>
+ /// Gets or sets a set of event types (<see cref="EventType" />) to be recorded by Ignite.
+ /// </summary>
+ [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+ public ICollection<int> IncludedEventTypes { get; set; }
+
+ /// <summary>
+ /// Gets or sets the time after which a certain metric value is considered expired.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "10675199.02:48:05.4775807")]
+ public TimeSpan MetricsExpireTime { get; set; }
+
+ /// <summary>
+ /// Gets or sets the number of metrics kept in history to compute totals and averages.
+ /// </summary>
+ [DefaultValue(DefaultMetricsHistorySize)]
+ public int MetricsHistorySize { get; set; }
+
+ /// <summary>
+ /// Gets or sets the frequency of metrics log print out.
+ /// <see cref="TimeSpan.Zero"/> to disable metrics print out.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:01:00")]
+ public TimeSpan MetricsLogFrequency { get; set; }
+
+ /// <summary>
+ /// Gets or sets the job metrics update frequency.
+ /// <see cref="TimeSpan.Zero"/> to update metrics on job start/finish.
+ /// Negative value to never update metrics.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:02")]
+ public TimeSpan MetricsUpdateFrequency { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network send retry count.
+ /// </summary>
+ [DefaultValue(DefaultNetworkSendRetryCount)]
+ public int NetworkSendRetryCount { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network send retry delay.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:01")]
+ public TimeSpan NetworkSendRetryDelay { get; set; }
+
+ /// <summary>
+ /// Gets or sets the network timeout.
+ /// </summary>
+ [DefaultValue(typeof(TimeSpan), "00:00:05")]
+ public TimeSpan NetworkTimeout { get; set; }
+
+ /// <summary>
+ /// Gets or sets the work directory.
+ /// If not provided, a folder under <see cref="IgniteHome"/> will be used.
+ /// </summary>
+ public string WorkDirectory { get; set; }
+
+ /// <summary>
+ /// Gets or sets system-wide local address or host for all Ignite components to bind to.
+ /// If provided it will override all default local bind settings within Ignite.
+ /// <para />
+ /// If <c>null</c> then Ignite tries to use local wildcard address.That means that all services
+ /// will be available on all network interfaces of the host machine.
+ /// <para />
+ /// It is strongly recommended to set this parameter for all production environments.
+ /// </summary>
+ public string Localhost { get; set; }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 3a27ad1..0549010 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Ignition.cs
@@ -15,6 +15,7 @@
* limitations under the License.
*/
+#pragma warning disable 618 // deprecated SpringConfigUrl
namespace Apache.Ignite.Core
{
using System;
@@ -41,7 +42,7 @@ namespace Apache.Ignite.Core
/// <summary>
/// This class defines a factory for the main Ignite API.
/// <p/>
- /// Use <see cref="Ignition.Start()"/> method to start Ignite with default configuration.
+ /// Use <see cref="Start()"/> method to start Ignite with default configuration.
/// <para/>
/// All members are thread-safe and may be used concurrently from multiple threads.
/// </summary>
@@ -51,9 +52,6 @@ namespace Apache.Ignite.Core
internal const string EnvIgniteSpringConfigUrlPrefix = "IGNITE_SPRING_CONFIG_URL_PREFIX";
/** */
- private const string DefaultCfg = "config/default-config.xml";
-
- /** */
private static readonly object SyncRoot = new object();
/** GC warning flag. */
@@ -125,15 +123,6 @@ namespace Apache.Ignite.Core
{
IgniteArgumentCheck.NotNull(cfg, "cfg");
- // Copy configuration to avoid changes to user-provided instance.
- IgniteConfigurationEx cfgEx = cfg as IgniteConfigurationEx;
-
- cfg = cfgEx == null ? new IgniteConfiguration(cfg) : new IgniteConfigurationEx(cfgEx);
-
- // Set default Spring config if needed.
- if (cfg.SpringConfigUrl == null)
- cfg.SpringConfigUrl = DefaultCfg;
-
lock (SyncRoot)
{
// 1. Check GC settings.
@@ -146,9 +135,11 @@ namespace Apache.Ignite.Core
IgniteManager.CreateJvmContext(cfg, cbs);
- var gridName = cfgEx != null ? cfgEx.GridName : null;
+ var gridName = cfg.GridName;
- var cfgPath = Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
+ var cfgPath = cfg.SpringConfigUrl == null
+ ? null
+ : Environment.GetEnvironmentVariable(EnvIgniteSpringConfigUrlPrefix) + cfg.SpringConfigUrl;
// 3. Create startup object which will guide us through the rest of the process.
_startup = new Startup(cfg, cbs);
@@ -229,7 +220,7 @@ namespace Apache.Ignite.Core
{
BinaryReader reader = BinaryUtils.Marshaller.StartUnmarshal(inStream);
- PrepareConfiguration(reader);
+ PrepareConfiguration(reader, outStream);
PrepareLifecycleBeans(reader, outStream, handleRegistry);
}
@@ -245,7 +236,8 @@ namespace Apache.Ignite.Core
/// Preapare configuration.
/// </summary>
/// <param name="reader">Reader.</param>
- private static void PrepareConfiguration(BinaryReader reader)
+ /// <param name="outStream">Response stream.</param>
+ private static void PrepareConfiguration(BinaryReader reader, PlatformMemoryStream outStream)
{
// 1. Load assemblies.
IgniteConfiguration cfg = _startup.Configuration;
@@ -264,6 +256,9 @@ namespace Apache.Ignite.Core
cfg.BinaryConfiguration = binaryCfg;
_startup.Marshaller = new Marshaller(cfg.BinaryConfiguration);
+
+ // 3. Send configuration details to Java
+ cfg.Write(_startup.Marshaller.StartMarshal(outStream));
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
index 9b43564..efe1df4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Binary.cs
@@ -104,9 +104,6 @@ namespace Apache.Ignite.Core.Impl.Binary
if (obj0 == null)
throw new ArgumentException("Unsupported object type: " + obj.GetType());
- if (obj0 is BinaryEnum)
- throw new InvalidOperationException("Builder cannot be created for enum.");
-
IBinaryTypeDescriptor desc = _marsh.GetDescriptor(true, obj0.TypeId);
return Builder0(null, obj0, desc);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
index c3dcc3a..f3f8457 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/BinaryReaderExtensions.cs
@@ -17,6 +17,7 @@
namespace Apache.Ignite.Core.Impl.Binary
{
+ using System;
using System.Collections.Generic;
using Apache.Ignite.Core.Binary;
@@ -48,5 +49,23 @@ namespace Apache.Ignite.Core.Impl.Binary
{
return (Dictionary<TKey, TValue>) reader.ReadDictionary(size => new Dictionary<TKey, TValue>(size));
}
+
+ /// <summary>
+ /// Reads long as timespan with range checks.
+ /// </summary>
+ /// <param name="reader">The reader.</param>
+ /// <returns>TimeSpan.</returns>
+ public static TimeSpan ReadLongAsTimespan(this IBinaryRawReader reader)
+ {
+ long ms = reader.ReadLong();
+
+ if (ms >= TimeSpan.MaxValue.TotalMilliseconds)
+ return TimeSpan.MaxValue;
+
+ if (ms <= TimeSpan.MinValue.TotalMilliseconds)
+ return TimeSpan.MinValue;
+
+ return TimeSpan.FromMilliseconds(ms);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.cs
new file mode 100644
index 0000000..fccbfae
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/JavaTypes.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.Binary
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ /// <summary>
+ /// Provides mapping between Java and .NET basic types.
+ /// </summary>
+ internal static class JavaTypes
+ {
+ /** */
+ private static readonly Dictionary<Type, string> NetToJava = new Dictionary<Type, string>
+ {
+ {typeof (bool), "java.lang.Boolean"},
+ {typeof (byte), "java.lang.Byte"},
+ {typeof (sbyte), "java.lang.Byte"},
+ {typeof (short), "java.lang.Short"},
+ {typeof (ushort), "java.lang.Short"},
+ {typeof (char), "java.lang.Character"},
+ {typeof (int), "java.lang.Integer"},
+ {typeof (uint), "java.lang.Integer"},
+ {typeof (long), "java.lang.Long"},
+ {typeof (ulong), "java.lang.Long"},
+ {typeof (float), "java.lang.Float"},
+ {typeof (double), "java.lang.Double"},
+ {typeof (string), "java.lang.String"},
+ {typeof (decimal), "java.math.BigDecimal"},
+ {typeof (Guid), "java.util.UUID"}
+ };
+
+ /** */
+ private static readonly Dictionary<string, Type> JavaToNet =
+ NetToJava.GroupBy(x => x.Value).ToDictionary(g => g.Key, g => g.First().Key);
+
+ /** */
+ private static readonly string MappedTypes = string.Join(", ", NetToJava.Keys.Select(x => x.Name));
+
+ /// <summary>
+ /// Gets the corresponding Java type name.
+ /// </summary>
+ public static string GetJavaTypeName(Type type)
+ {
+ if (type == null)
+ return null;
+
+ string res;
+
+ return NetToJava.TryGetValue(type, out res) ? res : null;
+ }
+
+ /// <summary>
+ /// Gets .NET type that corresponds to specified Java type name.
+ /// </summary>
+ /// <param name="javaTypeName">Name of the java type.</param>
+ /// <returns></returns>
+ public static Type GetDotNetType(string javaTypeName)
+ {
+ if (string.IsNullOrEmpty(javaTypeName))
+ return null;
+
+ Type res;
+
+ return JavaToNet.TryGetValue(javaTypeName, out res) ? res : null;
+ }
+
+ /// <summary>
+ /// Gets the supported types as a comma-separated string.
+ /// </summary>
+ public static string SupportedTypesString
+ {
+ get { return MappedTypes; }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
index 4274744..73f3618 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Binary/Marshaller.cs
@@ -88,11 +88,11 @@ namespace Apache.Ignite.Core.Impl.Binary
foreach (BinaryTypeConfiguration typeCfg in typeCfgs)
AddUserType(cfg, typeCfg, typeResolver, dfltSerializer);
- ICollection<string> types = cfg.Types;
+ var typeNames = cfg.Types;
- if (types != null)
- foreach (string type in types)
- AddUserType(cfg, new BinaryTypeConfiguration(type), typeResolver, dfltSerializer);
+ if (typeNames != null)
+ foreach (string typeName in typeNames)
+ AddUserType(cfg, new BinaryTypeConfiguration(typeName), typeResolver, dfltSerializer);
if (cfg.DefaultSerializer == null)
cfg.DefaultSerializer = dfltSerializer;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index f55863e..d1296ec 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl.Cache
using System.Threading.Tasks;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cache.Expiry;
using Apache.Ignite.Core.Cache.Query;
using Apache.Ignite.Core.Cache.Query.Continuous;
@@ -68,7 +69,7 @@ namespace Apache.Ignite.Core.Impl.Cache
/** Async instance. */
private readonly Lazy<CacheImpl<TK, TV>> _asyncInstance;
-
+
/// <summary>
/// Constructor.
/// </summary>
@@ -152,6 +153,12 @@ namespace Apache.Ignite.Core.Impl.Cache
}
/** <inheritDoc /> */
+ public CacheConfiguration GetConfiguration()
+ {
+ return DoInOp((int) CacheOp.GetConfig, stream => new CacheConfiguration(Marshaller.StartUnmarshal(stream)));
+ }
+
+ /** <inheritDoc /> */
public bool IsEmpty()
{
return GetSize() == 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
index 1709dc5..61ccb5f 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheOp.cs
@@ -59,6 +59,7 @@ namespace Apache.Ignite.Core.Impl.Cache
RemoveBool = 35,
RemoveObj = 36,
Replace2 = 37,
- Replace3 = 38
+ Replace3 = 38,
+ GetConfig = 39
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
index 5aa806b..7785280 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/Store/CacheStore.cs
@@ -101,15 +101,25 @@ namespace Apache.Ignite.Core.Impl.Cache.Store
{
using (var stream = IgniteManager.Memory.Get(memPtr).GetStream())
{
- var reader = BinaryUtils.Marshaller.StartUnmarshal(stream, BinaryMode.KeepBinary);
+ var reader = BinaryUtils.Marshaller.StartUnmarshal(stream);
- var className = reader.ReadString();
var convertBinary = reader.ReadBoolean();
- var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+ var factory = reader.ReadObject<IFactory<ICacheStore>>();
- var store = IgniteUtils.CreateInstance<ICacheStore>(className);
+ ICacheStore store;
+
+ if (factory != null)
+ store = factory.CreateInstance();
+ else
+ {
+ var className = reader.ReadString();
+ var propertyMap = reader.ReadDictionaryAsGeneric<string, object>();
+
+ store = IgniteUtils.CreateInstance<ICacheStore>(className);
+
+ IgniteUtils.SetProperties(store, propertyMap);
+ }
- IgniteUtils.SetProperties(store, propertyMap);
return new CacheStore(store, convertBinary, registry);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 ffc8be8..9d27117 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -25,6 +25,7 @@ namespace Apache.Ignite.Core.Impl
using System.Linq;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
@@ -339,12 +340,46 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var writer = Marshaller.StartMarshal(stream);
+
+ configuration.Write(writer);
+
+ stream.SynchronizeOutput();
+
+ return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, stream.MemoryPointer));
+ }
+ }
+
+ /** <inheritdoc /> */
public ICache<TK, TV> CreateCache<TK, TV>(string name)
{
return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, name));
}
/** <inheritdoc /> */
+ public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+ using (var stream = IgniteManager.Memory.Allocate().GetStream())
+ {
+ var writer = Marshaller.StartMarshal(stream);
+
+ configuration.Write(writer);
+
+ stream.SynchronizeOutput();
+
+ return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, stream.MemoryPointer));
+ }
+ }
+
+ /** <inheritdoc /> */
public void DestroyCache(string name)
{
UU.ProcessorDestroyCache(_proc, name);
@@ -450,6 +485,19 @@ namespace Apache.Ignite.Core.Impl
return new AtomicLong(nativeLong, Marshaller, name);
}
+ /** <inheritdoc /> */
+ public IgniteConfiguration GetConfiguration()
+ {
+ using (var stream = IgniteManager.Memory.Allocate(1024).GetStream())
+ {
+ UU.ProcessorGetIgniteConfiguration(_proc, stream.MemoryPointer);
+
+ stream.SynchronizeInput();
+
+ return new IgniteConfiguration(_marsh.StartUnmarshal(stream));
+ }
+ }
+
/// <summary>
/// Gets internal projection.
/// </summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
deleted file mode 100644
index 358e805..0000000
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteConfigurationEx.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Apache.Ignite.Core.Impl
-{
- /// <summary>
- /// Internal extensions for IgniteConfiguration.
- /// </summary>
- internal class IgniteConfigurationEx : IgniteConfiguration
- {
- /// <summary>
- /// Default constructor.
- /// </summary>
- public IgniteConfigurationEx()
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfiguration cfg) : base(cfg)
- {
- // No-op.
- }
-
- /// <summary>
- /// Copying constructor.
- /// </summary>
- /// <param name="cfg">Configuration.</param>
- public IgniteConfigurationEx(IgniteConfigurationEx cfg)
- : this((IgniteConfiguration) cfg)
- {
- GridName = cfg.GridName;
- }
-
- /// <summary>
- /// Grid name which is used if not provided in configuration file.
- /// </summary>
- public string GridName { get; set; }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
index 6803772..a61edf4 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteManager.cs
@@ -50,7 +50,7 @@ namespace Apache.Ignite.Core.Impl
private static JvmConfiguration _jvmCfg;
/** Memory manager. */
- private static PlatformMemoryManager _mem;
+ private static readonly PlatformMemoryManager Mem = new PlatformMemoryManager(1024);
/// <summary>
/// Create JVM.
@@ -86,7 +86,6 @@ namespace Apache.Ignite.Core.Impl
{
_ctx = ctx;
_jvmCfg = jvmCfg;
- _mem = new PlatformMemoryManager(1024);
}
}
}
@@ -96,7 +95,7 @@ namespace Apache.Ignite.Core.Impl
/// </summary>
internal static PlatformMemoryManager Memory
{
- get { return _mem; }
+ get { return Mem; }
}
/// <summary>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 16062e2..46bc3ca 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Impl
using System.Diagnostics.CodeAnalysis;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Cache;
+ using Apache.Ignite.Core.Cache.Configuration;
using Apache.Ignite.Core.Cluster;
using Apache.Ignite.Core.Compute;
using Apache.Ignite.Core.Datastream;
@@ -232,19 +233,28 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ return _ignite.GetOrCreateCache<TK, TV>(configuration);
+ }
+
+ /** <inheritdoc /> */
public ICache<TK, TV> CreateCache<TK, TV>(string name)
{
return _ignite.CreateCache<TK, TV>(name);
}
/** <inheritdoc /> */
+ public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
+ {
+ return _ignite.CreateCache<TK, TV>(configuration);
+ }
public void DestroyCache(string name)
{
_ignite.DestroyCache(name);
}
/** <inheritdoc /> */
-
public IClusterNode GetLocalNode()
{
return _ignite.GetCluster().GetLocalNode();
@@ -324,6 +334,12 @@ namespace Apache.Ignite.Core.Impl
}
/** <inheritdoc /> */
+ public IgniteConfiguration GetConfiguration()
+ {
+ return _ignite.GetConfiguration();
+ }
+
+ /** <inheritdoc /> */
public void WriteBinary(IBinaryWriter writer)
{
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
index fe4548c..3206fc8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteUtils.cs
@@ -47,7 +47,7 @@ namespace Apache.Ignite.Core.Impl
private static readonly string[] JvmDllLookupPaths = {@"jre\bin\server", @"jre\bin\default"};
/** File: jvm.dll. */
- private const string FileJvmDll = "jvm.dll";
+ internal const string FileJvmDll = "jvm.dll";
/** File: Ignite.Common.dll. */
internal const string FileIgniteJniDll = "ignite.common.dll";
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
index 851d24f..8e54261 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Memory/PlatformRawMemory.cs
@@ -85,7 +85,7 @@ namespace Apache.Ignite.Core.Impl.Memory
/** <inheritdoc /> */
public void Release()
{
- throw new NotSupportedException();
+ // Memory can only be released by native platform.
}
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
index 229ff8c..51a49d0 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Transactions/TransactionsImpl.cs
@@ -70,7 +70,7 @@ namespace Apache.Ignite.Core.Impl.Transactions
concurrency = (TransactionConcurrency) reader.ReadInt();
isolation = (TransactionIsolation) reader.ReadInt();
- timeout = TimeSpan.FromMilliseconds(reader.ReadLong());
+ timeout = reader.ReadLongAsTimespan();
});
_dfltConcurrency = concurrency;
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 7a73bee..17df94a 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -24,7 +24,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
/// Ignite JNI native methods.
/// </summary>
[SuppressUnmanagedCodeSecurity]
- internal unsafe static class IgniteJniNativeMethods
+ internal static unsafe class IgniteJniNativeMethods
{
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteReallocate")]
public static extern int Reallocate(long memPtr, int cap);
@@ -52,9 +52,15 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCache")]
public static extern void* ProcessorCreateCache(void* ctx, void* obj, sbyte* name);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateCacheFromConfig")]
+ public static extern void* ProcessorCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCache")]
public static extern void* ProcessorGetOrCreateCache(void* ctx, void* obj, sbyte* name);
+ [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCacheFromConfig")]
+ public static extern void* ProcessorGetOrCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorDestroyCache")]
public static extern void ProcessorDestroyCache(void* ctx, void* obj, sbyte* name);
@@ -87,6 +93,9 @@ 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 = "IgniteProcessorGetIgniteConfiguration")]
+ public static extern void ProcessorGetIgniteConfiguration(void* ctx, void* obj, long memPtr);
+
[DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteTargetInStreamOutLong")]
public static extern long TargetInStreamOutLong(void* ctx, void* target, int opType, long memPtr);
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/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 f460c9f..ad62f38 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -21,7 +21,6 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
using Apache.Ignite.Core.Common;
-
using JNI = IgniteJniNativeMethods;
/// <summary>
@@ -102,7 +101,7 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
{
JNI.IgnitionStopAll(ctx, cancel);
}
-
+
internal static void ProcessorReleaseStart(IUnmanagedTarget target)
{
JNI.ProcessorReleaseStart(target.Context, target.Target);
@@ -147,6 +146,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static IUnmanagedTarget ProcessorCreateCache(IUnmanagedTarget target, long memPtr)
+ {
+ void* res = JNI.ProcessorCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+ return target.ChangeTarget(res);
+ }
+
internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, string name)
{
sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -163,6 +169,13 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static IUnmanagedTarget ProcessorGetOrCreateCache(IUnmanagedTarget target, long memPtr)
+ {
+ void* res = JNI.ProcessorGetOrCreateCacheFromConfig(target.Context, target.Target, memPtr);
+
+ return target.ChangeTarget(res);
+ }
+
internal static void ProcessorDestroyCache(IUnmanagedTarget target, string name)
{
sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
@@ -268,6 +281,11 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
}
}
+ internal static void ProcessorGetIgniteConfiguration(IUnmanagedTarget target, long memPtr)
+ {
+ JNI.ProcessorGetIgniteConfiguration(target.Context, target.Target, memPtr);
+ }
+
#endregion
#region NATIVE METHODS: TARGET
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee20f1d9/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index c0f49c8..53eefdd 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -837,6 +837,7 @@
<exclude>**/*.slnrel</exclude>
<exclude>**/*.DotSettings</exclude>
<exclude>**/*.FxCop</exclude>
+ <exclude>**/*.ruleset</exclude>
<exclude>**/*.csproj</exclude>
<exclude>**/*.csprojrel</exclude>
<exclude>**/*.vcxproj</exclude>
[13/50] [abbrv] ignite git commit: ignite-2080 Data alignment issues
with Unsafe
Posted by vo...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
index 1a4c4bb..7958793 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
@@ -38,41 +38,22 @@ import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemTy
import org.apache.ignite.plugin.extensions.communication.MessageFactory;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-import sun.misc.Unsafe;
import sun.nio.ch.DirectBuffer;
+import static org.apache.ignite.internal.util.GridUnsafe.BIG_ENDIAN;
+import static org.apache.ignite.internal.util.GridUnsafe.BYTE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.CHAR_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.DOUBLE_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.FLOAT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.LONG_ARR_OFF;
+import static org.apache.ignite.internal.util.GridUnsafe.SHORT_ARR_OFF;
+
/**
* Direct marshalling I/O stream (version 2).
*/
public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
- private static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
- /** */
- private static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
- /** */
- private static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
- /** */
- private static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
- /** */
- private static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
- /** */
- private static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** */
- private static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
- /** */
private static final byte[] BYTE_ARR_EMPTY = new byte[0];
/** */
@@ -343,7 +324,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putByte(heapArr, baseOff + pos, val);
+ GridUnsafe.putByte(heapArr, baseOff + pos, val);
buf.position(pos + 1);
}
@@ -356,7 +337,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putShort(heapArr, baseOff + pos, val);
+ long off = baseOff + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putShortLE(heapArr, off, val);
+ else
+ GridUnsafe.putShort(heapArr, off, val);
buf.position(pos + 2);
}
@@ -377,12 +363,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
while ((val & 0xFFFF_FF80) != 0) {
byte b = (byte)(val | 0x80);
- UNSAFE.putByte(heapArr, baseOff + pos++, b);
+ GridUnsafe.putByte(heapArr, baseOff + pos++, b);
val >>>= 7;
}
- UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
+ GridUnsafe.putByte(heapArr, baseOff + pos++, (byte)val);
buf.position(pos);
}
@@ -403,12 +389,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
while ((val & 0xFFFF_FFFF_FFFF_FF80L) != 0) {
byte b = (byte)(val | 0x80);
- UNSAFE.putByte(heapArr, baseOff + pos++, b);
+ GridUnsafe.putByte(heapArr, baseOff + pos++, b);
val >>>= 7;
}
- UNSAFE.putByte(heapArr, baseOff + pos++, (byte)val);
+ GridUnsafe.putByte(heapArr, baseOff + pos++, (byte)val);
buf.position(pos);
}
@@ -421,7 +407,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putFloat(heapArr, baseOff + pos, val);
+ long off = baseOff + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putFloatLE(heapArr, off, val);
+ else
+ GridUnsafe.putFloat(heapArr, off, val);
buf.position(pos + 4);
}
@@ -434,7 +425,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putDouble(heapArr, baseOff + pos, val);
+ long off = baseOff + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putDoubleLE(heapArr, off, val);
+ else
+ GridUnsafe.putDouble(heapArr, off, val);
buf.position(pos + 8);
}
@@ -447,7 +443,12 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putChar(heapArr, baseOff + pos, val);
+ long off = baseOff + pos;
+
+ if (BIG_ENDIAN)
+ GridUnsafe.putCharLE(heapArr, off, val);
+ else
+ GridUnsafe.putChar(heapArr, off, val);
buf.position(pos + 2);
}
@@ -460,7 +461,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (lastFinished) {
int pos = buf.position();
- UNSAFE.putBoolean(heapArr, baseOff + pos, val);
+ GridUnsafe.putBoolean(heapArr, baseOff + pos, val);
buf.position(pos + 1);
}
@@ -485,7 +486,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeShortArray(short[] val) {
if (val != null)
- lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, SHORT_ARR_OFF, val.length, 2, 1);
+ else
+ lastFinished = writeArray(val, SHORT_ARR_OFF, val.length, val.length << 1);
else
writeInt(-1);
}
@@ -493,7 +497,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeIntArray(int[] val) {
if (val != null)
- lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, INT_ARR_OFF, val.length, 4, 2);
+ else
+ lastFinished = writeArray(val, INT_ARR_OFF, val.length, val.length << 2);
else
writeInt(-1);
}
@@ -501,7 +508,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeLongArray(long[] val) {
if (val != null)
- lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, LONG_ARR_OFF, val.length, 8, 3);
+ else
+ lastFinished = writeArray(val, LONG_ARR_OFF, val.length, val.length << 3);
else
writeInt(-1);
}
@@ -509,7 +519,10 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeFloatArray(float[] val) {
if (val != null)
- lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, FLOAT_ARR_OFF, val.length, 4, 2);
+ else
+ lastFinished = writeArray(val, FLOAT_ARR_OFF, val.length, val.length << 2);
else
writeInt(-1);
}
@@ -517,15 +530,22 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeDoubleArray(double[] val) {
if (val != null)
- lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, DOUBLE_ARR_OFF, val.length, 8, 3);
+ else
+ lastFinished = writeArray(val, DOUBLE_ARR_OFF, val.length, val.length << 3);
else
writeInt(-1);
}
/** {@inheritDoc} */
@Override public void writeCharArray(char[] val) {
- if (val != null)
- lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+ if (val != null) {
+ if (BIG_ENDIAN)
+ lastFinished = writeArrayLE(val, CHAR_ARR_OFF, val.length, 2, 1);
+ else
+ lastFinished = writeArray(val, CHAR_ARR_OFF, val.length, val.length << 1);
+ }
else
writeInt(-1);
}
@@ -533,7 +553,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public void writeBooleanArray(boolean[] val) {
if (val != null)
- lastFinished = writeArray(val, BOOLEAN_ARR_OFF, val.length, val.length);
+ lastFinished = writeArray(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length, val.length);
else
writeInt(-1);
}
@@ -793,7 +813,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 1);
- return UNSAFE.getByte(heapArr, baseOff + pos);
+ return GridUnsafe.getByte(heapArr, baseOff + pos);
}
else
return 0;
@@ -808,7 +828,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 2);
- return UNSAFE.getShort(heapArr, baseOff + pos);
+ long off = baseOff + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getShortLE(heapArr, off) : GridUnsafe.getShort(heapArr, off);
}
else
return 0;
@@ -823,7 +845,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
while (buf.hasRemaining()) {
int pos = buf.position();
- byte b = UNSAFE.getByte(heapArr, baseOff + pos);
+ byte b = GridUnsafe.getByte(heapArr, baseOff + pos);
buf.position(pos + 1);
@@ -860,7 +882,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
while (buf.hasRemaining()) {
int pos = buf.position();
- byte b = UNSAFE.getByte(heapArr, baseOff + pos);
+ byte b = GridUnsafe.getByte(heapArr, baseOff + pos);
buf.position(pos + 1);
@@ -897,7 +919,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 4);
- return UNSAFE.getFloat(heapArr, baseOff + pos);
+ long off = baseOff + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getFloatLE(heapArr, off) : GridUnsafe.getFloat(heapArr, off);
}
else
return 0;
@@ -912,7 +936,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 8);
- return UNSAFE.getDouble(heapArr, baseOff + pos);
+ long off = baseOff + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getDoubleLE(heapArr, off) : GridUnsafe.getDouble(heapArr, off);
}
else
return 0;
@@ -927,7 +953,9 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 2);
- return UNSAFE.getChar(heapArr, baseOff + pos);
+ long off = baseOff + pos;
+
+ return BIG_ENDIAN ? GridUnsafe.getCharLE(heapArr, off) : GridUnsafe.getChar(heapArr, off);
}
else
return 0;
@@ -942,7 +970,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
buf.position(pos + 1);
- return UNSAFE.getBoolean(heapArr, baseOff + pos);
+ return GridUnsafe.getBoolean(heapArr, baseOff + pos);
}
else
return false;
@@ -955,37 +983,55 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/** {@inheritDoc} */
@Override public short[] readShortArray() {
- return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(SHORT_ARR_CREATOR, 2, 1, SHORT_ARR_OFF);
+ else
+ return readArray(SHORT_ARR_CREATOR, 1, SHORT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public int[] readIntArray() {
- return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(INT_ARR_CREATOR, 4, 2, INT_ARR_OFF);
+ else
+ return readArray(INT_ARR_CREATOR, 2, INT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public long[] readLongArray() {
- return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(LONG_ARR_CREATOR, 8, 3, LONG_ARR_OFF);
+ else
+ return readArray(LONG_ARR_CREATOR, 3, LONG_ARR_OFF);
}
/** {@inheritDoc} */
@Override public float[] readFloatArray() {
- return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(FLOAT_ARR_CREATOR, 4, 2, FLOAT_ARR_OFF);
+ else
+ return readArray(FLOAT_ARR_CREATOR, 2, FLOAT_ARR_OFF);
}
/** {@inheritDoc} */
@Override public double[] readDoubleArray() {
- return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(DOUBLE_ARR_CREATOR, 8, 3, DOUBLE_ARR_OFF);
+ else
+ return readArray(DOUBLE_ARR_CREATOR, 3, DOUBLE_ARR_OFF);
}
/** {@inheritDoc} */
@Override public char[] readCharArray() {
- return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
+ if (BIG_ENDIAN)
+ return readArrayLE(CHAR_ARR_CREATOR, 2, 1, CHAR_ARR_OFF);
+ else
+ return readArray(CHAR_ARR_CREATOR, 1, CHAR_ARR_OFF);
}
/** {@inheritDoc} */
@Override public boolean[] readBooleanArray() {
- return readArray(BOOLEAN_ARR_CREATOR, 0, BOOLEAN_ARR_OFF);
+ return readArray(BOOLEAN_ARR_CREATOR, 0, GridUnsafe.BOOLEAN_ARR_OFF);
}
/** {@inheritDoc} */
@@ -1274,14 +1320,8 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
assert bytes >= 0;
assert bytes >= arrOff;
- if (arrOff == -1) {
- writeInt(len);
-
- if (!lastFinished)
- return false;
-
- arrOff = 0;
- }
+ if (writeArrayLength(len))
+ return false;
int toWrite = bytes - arrOff;
int pos = buf.position();
@@ -1289,7 +1329,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
if (toWrite <= remaining) {
if (toWrite > 0) {
- UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
+ GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, toWrite);
buf.position(pos + toWrite);
}
@@ -1300,7 +1340,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
}
else {
if (remaining > 0) {
- UNSAFE.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
+ GridUnsafe.copyMemory(arr, off + arrOff, heapArr, baseOff + pos, remaining);
buf.position(pos + remaining);
@@ -1312,6 +1352,80 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
}
/**
+ * @param arr Array.
+ * @param off Offset.
+ * @param len Length.
+ * @param typeSize Primitive type size in bytes. Needs for byte reverse.
+ * @return Whether array was fully written.
+ */
+ private boolean writeArrayLE(Object arr, long off, int len, int typeSize, int shiftCnt) {
+ assert arr != null;
+ assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive();
+ assert off > 0;
+ assert len >= 0;
+
+ int bytes = len << shiftCnt;
+
+ assert bytes >= arrOff;
+
+ if (writeArrayLength(len))
+ return false;
+
+ int toWrite = (bytes - arrOff) >> shiftCnt;
+ int remaining = buf.remaining() >> shiftCnt;
+
+ if (toWrite <= remaining) {
+ writeArrayLE(arr, off, toWrite, typeSize);
+
+ arrOff = -1;
+
+ return true;
+ }
+ else {
+ if (remaining > 0)
+ writeArrayLE(arr, off, remaining, typeSize);
+
+ return false;
+ }
+ }
+
+ /**
+ * @param arr Array.
+ * @param off Offset.
+ * @param len Length.
+ * @param typeSize Primitive type size in bytes.
+ */
+ private void writeArrayLE(Object arr, long off, int len, int typeSize) {
+ int pos = buf.position();
+
+ for (int i = 0; i < len; i++) {
+ for (int j = 0; j < typeSize; j++) {
+ byte b = GridUnsafe.getByteField(arr, off + arrOff + (typeSize - j - 1));
+
+ GridUnsafe.putByte(heapArr, baseOff + pos++, b);
+ }
+
+ buf.position(pos);
+ arrOff += typeSize;
+ }
+ }
+
+ /**
+ * @param len Length.
+ */
+ private boolean writeArrayLength(int len) {
+ if (arrOff == -1) {
+ writeInt(len);
+
+ if (!lastFinished)
+ return true;
+
+ arrOff = 0;
+ }
+ return false;
+ }
+
+ /**
* @param creator Array creator.
* @param lenShift Array length shift size.
* @param off Base offset.
@@ -1351,7 +1465,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
lastFinished = toRead <= remaining;
if (lastFinished) {
- UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
+ GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, toRead);
buf.position(pos + toRead);
@@ -1364,7 +1478,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
return arr;
}
else {
- UNSAFE.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
+ GridUnsafe.copyMemory(heapArr, baseOff + pos, tmpArr, off + tmpArrOff, remaining);
buf.position(pos + remaining);
@@ -1375,6 +1489,95 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
}
/**
+ * @param creator Array creator.
+ * @param typeSize Primitive type size in bytes.
+ * @param lenShift Array length shift size.
+ * @param off Base offset.
+ * @return Array or special value if it was not fully read.
+ */
+ @SuppressWarnings("unchecked")
+ private <T> T readArrayLE(ArrayCreator<T> creator, int typeSize, int lenShift, long off) {
+ assert creator != null;
+
+ if (tmpArr == null) {
+ int len = readInt();
+
+ if (!lastFinished)
+ return null;
+
+ switch (len) {
+ case -1:
+ lastFinished = true;
+
+ return null;
+
+ case 0:
+ lastFinished = true;
+
+ return creator.create(0);
+
+ default:
+ tmpArr = creator.create(len);
+ tmpArrBytes = len << lenShift;
+ }
+ }
+
+ int toRead = (tmpArrBytes - tmpArrOff) >> lenShift;
+ int remaining = buf.remaining() >> lenShift;
+
+ lastFinished = toRead <= buf.remaining();
+
+ if (lastFinished) {
+ readArrayLE(typeSize, off, toRead);
+
+ T arr = (T)tmpArr;
+
+ tmpArr = null;
+ tmpArrBytes = 0;
+ tmpArrOff = 0;
+
+ return arr;
+ }
+ else {
+ for (int i = 0; i < remaining; i++) {
+ int pos = buf.position();
+
+ for (int j = 0; j < typeSize; j++) {
+ byte b = GridUnsafe.getByte(heapArr, baseOff + pos + (typeSize - j - 1));
+
+ GridUnsafe.putByteField(tmpArr, off + tmpArrOff + j, b);
+ }
+
+ buf.position(pos + typeSize);
+ tmpArrOff += typeSize;
+ }
+
+ tmpArrOff += buf.remaining();
+
+ return null;
+ }
+ }
+
+ /**
+ * @param typeSize Primitive type size in bytes.
+ * @param off Offset.
+ * @param toRead To read.
+ */
+ private void readArrayLE(int typeSize, long off, int toRead) {
+ for (int i = 0; i < toRead; i++) {
+ int pos = buf.position();
+
+ for (int j = 0; j < typeSize; j++) {
+ byte b = GridUnsafe.getByte(heapArr, baseOff + pos + (typeSize - j - 1));
+
+ GridUnsafe.putByteField(tmpArr, off + tmpArrOff++, b);
+ }
+
+ buf.position(pos + typeSize);
+ }
+ }
+
+ /**
* @param type Type.
* @param val Value.
* @param writer Writer.
@@ -1583,7 +1786,7 @@ public class DirectByteBufferStreamImplV2 implements DirectByteBufferStream {
/**
* Array creator.
*/
- private static interface ArrayCreator<T> {
+ private interface ArrayCreator<T> {
/**
* @param len Array length or {@code -1} if array was not fully read.
* @return New array.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 845e204..3a7bc8e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -103,9 +103,6 @@ import static org.jsr166.ConcurrentLinkedDeque8.Node;
* Cache eviction manager.
*/
public class GridCacheEvictionManager extends GridCacheManagerAdapter {
- /** Unsafe instance. */
- private static final sun.misc.Unsafe unsafe = GridUnsafe.unsafe();
-
/** Attribute name used to queue node in entry metadata. */
private static final int META_KEY = GridMetadataAwareAdapter.EntryKey.CACHE_EVICTION_MANAGER_KEY.key();
@@ -985,7 +982,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
continue;
// Lock entry.
- unsafe.monitorEnter(entry);
+ GridUnsafe.monitorEnter(entry);
locked.add(entry);
@@ -1028,7 +1025,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
for (ListIterator<GridCacheEntryEx> it = locked.listIterator(locked.size()); it.hasPrevious();) {
GridCacheEntryEx e = it.previous();
- unsafe.monitorExit(e);
+ GridUnsafe.monitorExit(e);
}
// Remove entries and fire events outside the locks.
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
index ea036af..82e115c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheOffheapSwapEntry.java
@@ -23,7 +23,6 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
/**
* GridCacheSwapEntry over offheap pointer.
@@ -41,9 +40,6 @@ import sun.misc.Unsafe;
*/
public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
private final long ptr;
/** */
@@ -70,17 +66,17 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
long readPtr = ptr + GridCacheSwapEntryImpl.VERSION_OFFSET;
- boolean verEx = UNSAFE.getByte(readPtr++) != 0;
+ boolean verEx = GridUnsafe.getByte(readPtr++) != 0;
ver = U.readVersion(readPtr, verEx);
readPtr += verEx ? GridCacheSwapEntryImpl.VERSION_EX_SIZE : GridCacheSwapEntryImpl.VERSION_SIZE;
- type = UNSAFE.getByte(readPtr + 4);
+ type = GridUnsafe.getByte(readPtr + 4);
valPtr = readPtr;
- assert (ptr + size) > (UNSAFE.getInt(valPtr) + valPtr + 5);
+ assert (ptr + size) > (GridUnsafe.getInt(valPtr) + valPtr + 5);
}
/**
@@ -94,11 +90,11 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
ptr += GridCacheSwapEntryImpl.VERSION_OFFSET; // Skip ttl, expire time.
- boolean verEx = UNSAFE.getByte(ptr++) != 0;
+ boolean verEx = GridUnsafe.getByte(ptr++) != 0;
ptr += verEx ? GridCacheSwapEntryImpl.VERSION_EX_SIZE : GridCacheSwapEntryImpl.VERSION_SIZE;
- assert (ptr + size) > (UNSAFE.getInt(ptr) + ptr + 5);
+ assert (ptr + size) > (GridUnsafe.getInt(ptr) + ptr + 5);
return ptr;
}
@@ -108,7 +104,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
* @return TTL.
*/
public static long timeToLive(long ptr) {
- return UNSAFE.getLong(ptr);
+ return GridUnsafe.getLong(ptr);
}
/**
@@ -116,7 +112,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
* @return Expire time.
*/
public static long expireTime(long ptr) {
- return UNSAFE.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
+ return GridUnsafe.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
}
/**
@@ -126,7 +122,7 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
public static GridCacheVersion version(long ptr) {
long addr = ptr + GridCacheSwapEntryImpl.VERSION_OFFSET;
- boolean verEx = UNSAFE.getByte(addr) != 0;
+ boolean verEx = GridUnsafe.getByte(addr) != 0;
addr++;
@@ -165,12 +161,12 @@ public class GridCacheOffheapSwapEntry implements GridCacheSwapEntry {
/** {@inheritDoc} */
@Override public long ttl() {
- return UNSAFE.getLong(ptr);
+ return GridUnsafe.getLong(ptr);
}
/** {@inheritDoc} */
@Override public long expireTime() {
- return UNSAFE.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
+ return GridUnsafe.getLong(ptr + GridCacheSwapEntryImpl.EXPIRE_TIME_OFFSET);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
index 6b1266f..02f74e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
@@ -26,19 +26,12 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
-import sun.misc.Unsafe;
/**
* Swap entry.
*/
public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- private static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** */
static final int EXPIRE_TIME_OFFSET = 8;
/** */
@@ -108,7 +101,7 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
* @return TTL.
*/
public static long timeToLive(byte[] bytes) {
- return UNSAFE.getLong(bytes, BYTE_ARR_OFF);
+ return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF);
}
/**
@@ -116,7 +109,7 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
* @return Expire time.
*/
public static long expireTime(byte[] bytes) {
- return UNSAFE.getLong(bytes, BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
+ return GridUnsafe.getLong(bytes, GridUnsafe.BYTE_ARR_OFF + EXPIRE_TIME_OFFSET);
}
/**
@@ -124,9 +117,9 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
* @return Version.
*/
public static GridCacheVersion version(byte[] bytes) {
- long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+ long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
- boolean verEx = UNSAFE.getByte(bytes, off++) != 0;
+ boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
return U.readVersion(bytes, off, verEx);
}
@@ -136,21 +129,21 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
* @return Value if value is byte array, otherwise {@code null}.
*/
@Nullable public static IgniteBiTuple<byte[], Byte> getValue(byte[] bytes) {
- long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+ long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
- boolean verEx = UNSAFE.getByte(bytes, off++) != 0;
+ boolean verEx = GridUnsafe.getByte(bytes, off++) != 0;
off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
- int arrLen = UNSAFE.getInt(bytes, off);
+ int arrLen = GridUnsafe.getInt(bytes, off);
off += 4;
- byte type = UNSAFE.getByte(bytes, off++);
+ byte type = GridUnsafe.getByte(bytes, off++);
byte[] valBytes = new byte[arrLen];
- UNSAFE.copyMemory(bytes, off, valBytes, BYTE_ARR_OFF, arrLen);
+ GridUnsafe.copyMemory(bytes, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
return new IgniteBiTuple<>(valBytes, type);
}
@@ -235,25 +228,25 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
byte[] arr = new byte[size];
- long off = BYTE_ARR_OFF;
+ long off = GridUnsafe.BYTE_ARR_OFF;
- UNSAFE.putLong(arr, off, ttl);
+ GridUnsafe.putLong(arr, off, ttl);
off += 8;
- UNSAFE.putLong(arr, off, expireTime);
+ GridUnsafe.putLong(arr, off, expireTime);
off += 8;
off = U.writeVersion(arr, off, ver);
- UNSAFE.putInt(arr, off, len);
+ GridUnsafe.putInt(arr, off, len);
off += 4;
- UNSAFE.putByte(arr, off++, type);
+ GridUnsafe.putByte(arr, off++, type);
- UNSAFE.copyMemory(valBytes.array(), BYTE_ARR_OFF, arr, off, len);
+ GridUnsafe.copyMemory(valBytes.array(), GridUnsafe.BYTE_ARR_OFF, arr, off, len);
off += len;
@@ -271,21 +264,21 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
*/
public static GridCacheSwapEntryImpl unmarshal(byte[] arr, boolean valOnly) {
if (valOnly) {
- long off = BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
+ long off = GridUnsafe.BYTE_ARR_OFF + VERSION_OFFSET; // Skip ttl, expire time.
- boolean verEx = UNSAFE.getByte(arr, off++) != 0;
+ boolean verEx = GridUnsafe.getByte(arr, off++) != 0;
off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
- int arrLen = UNSAFE.getInt(arr, off);
+ int arrLen = GridUnsafe.getInt(arr, off);
off += 4;
- byte type = UNSAFE.getByte(arr, off++);
+ byte type = GridUnsafe.getByte(arr, off++);
byte[] valBytes = new byte[arrLen];
- UNSAFE.copyMemory(arr, off, valBytes, BYTE_ARR_OFF, arrLen);
+ GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
return new GridCacheSwapEntryImpl(ByteBuffer.wrap(valBytes),
type,
@@ -296,31 +289,31 @@ public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
null);
}
- long off = BYTE_ARR_OFF;
+ long off = GridUnsafe.BYTE_ARR_OFF;
- long ttl = UNSAFE.getLong(arr, off);
+ long ttl = GridUnsafe.getLong(arr, off);
off += 8;
- long expireTime = UNSAFE.getLong(arr, off);
+ long expireTime = GridUnsafe.getLong(arr, off);
off += 8;
- boolean verEx = UNSAFE.getBoolean(arr, off++);
+ boolean verEx = GridUnsafe.getBoolean(arr, off++);
GridCacheVersion ver = U.readVersion(arr, off, verEx);
off += verEx ? VERSION_EX_SIZE : VERSION_SIZE;
- int arrLen = UNSAFE.getInt(arr, off);
+ int arrLen = GridUnsafe.getInt(arr, off);
off += 4;
- byte type = UNSAFE.getByte(arr, off++);
+ byte type = GridUnsafe.getByte(arr, off++);
byte[] valBytes = new byte[arrLen];
- UNSAFE.copyMemory(arr, off, valBytes, BYTE_ARR_OFF, arrLen);
+ GridUnsafe.copyMemory(arr, off, valBytes, GridUnsafe.BYTE_ARR_OFF, arrLen);
off += arrLen;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/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 a21331e..0fef6f8 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
@@ -102,7 +102,6 @@ import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.spi.IgniteNodeValidationResult;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import sun.misc.Unsafe;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
import static org.apache.ignite.IgniteSystemProperties.getBoolean;
@@ -113,9 +112,6 @@ import static org.apache.ignite.IgniteSystemProperties.getBoolean;
public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorImpl implements
CacheObjectBinaryProcessor {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
public static final IgniteProductVersion BINARY_CFG_CHECK_SINCE = IgniteProductVersion.fromString("1.5.6");
/** */
@@ -430,11 +426,11 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
public Object unmarshal(long ptr, boolean forceHeap) throws BinaryObjectException {
assert ptr > 0 : ptr;
- int size = UNSAFE.getInt(ptr);
+ int size = GridUnsafe.getInt(ptr);
ptr += 4;
- byte type = UNSAFE.getByte(ptr++);
+ byte type = GridUnsafe.getByte(ptr++);
if (type != CacheObject.TYPE_BYTE_ARR) {
assert size > 0 : size;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/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 b806906..f6f57ee 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
@@ -138,9 +138,6 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
private static final int DEFERRED_UPDATE_RESPONSE_TIMEOUT =
Integer.getInteger(IGNITE_ATOMIC_DEFERRED_ACK_TIMEOUT, 500);
- /** Unsafe instance. */
- private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Update reply closure. */
private CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> updateReplyClos;
@@ -2463,10 +2460,10 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
try {
GridDhtCacheEntry entry = entryExx(key, topVer);
- UNSAFE.monitorEnter(entry);
+ GridUnsafe.monitorEnter(entry);
if (entry.obsolete())
- UNSAFE.monitorExit(entry);
+ GridUnsafe.monitorExit(entry);
else
return Collections.singletonList(entry);
}
@@ -2506,13 +2503,13 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
if (entry == null)
continue;
- UNSAFE.monitorEnter(entry);
+ GridUnsafe.monitorEnter(entry);
if (entry.obsolete()) {
// Unlock all locked.
for (int j = 0; j <= i; j++) {
if (locked.get(j) != null)
- UNSAFE.monitorExit(locked.get(j));
+ GridUnsafe.monitorExit(locked.get(j));
}
// Clear entries.
@@ -2561,7 +2558,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
// That's why releasing locks in the finally block..
for (GridCacheMapEntry entry : locked) {
if (entry != null)
- UNSAFE.monitorExit(entry);
+ GridUnsafe.monitorExit(entry);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index fed3e33..8e5fe9e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -89,9 +89,6 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
/** */
private static final long serialVersionUID = 0L;
- /** Unsafe instance. */
- private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** */
private GridCachePreloader preldr;
@@ -1553,12 +1550,12 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
for (int i = 0; i < locked.size(); i++) {
GridCacheEntryEx entry = locked.get(i);
- UNSAFE.monitorEnter(entry);
+ GridUnsafe.monitorEnter(entry);
if (entry.obsolete()) {
// Unlock all locked.
for (int j = 0; j <= i; j++)
- UNSAFE.monitorExit(locked.get(j));
+ GridUnsafe.monitorExit(locked.get(j));
// Clear entries.
locked.clear();
@@ -1589,7 +1586,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
*/
private void unlockEntries(Iterable<GridCacheEntryEx> locked) {
for (GridCacheEntryEx entry : locked)
- UNSAFE.monitorExit(entry);
+ GridUnsafe.monitorExit(entry);
AffinityTopologyVersion topVer = ctx.affinity().affinityTopologyVersion();
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
index 5b764b6..54dd69e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cacheobject/IgniteCacheObjectProcessorImpl.java
@@ -51,9 +51,6 @@ import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
*
*/
public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter implements IgniteCacheObjectProcessor {
- /** */
- private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
-
/** Immutable classes. */
private static final Collection<Class<?>> IMMUTABLE_CLS = new HashSet<>();
@@ -138,9 +135,9 @@ public class IgniteCacheObjectProcessorImpl extends GridProcessorAdapter impleme
{
assert valPtr != 0;
- int size = UNSAFE.getInt(valPtr);
+ int size = GridUnsafe.getInt(valPtr);
- byte type = UNSAFE.getByte(valPtr + 4);
+ byte type = GridUnsafe.getByte(valPtr + 4);
byte[] bytes = U.copyMemory(valPtr + 5, size);
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
index e305c71..606a23c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformAbstractMemory.java
@@ -17,13 +17,15 @@
package org.apache.ignite.internal.processors.platform.memory;
+import org.apache.ignite.internal.util.GridUnsafe;
+
/**
* Interop memory chunk abstraction.
*/
public abstract class PlatformAbstractMemory implements PlatformMemory {
/** Stream factory. */
- private static final StreamFactory STREAM_FACTORY = PlatformMemoryUtils.LITTLE_ENDIAN ?
- new LittleEndianStreamFactory() : new BigEndianStreamFactory();
+ private static final StreamFactory STREAM_FACTORY = GridUnsafe.BIG_ENDIAN ?
+ new BigEndianStreamFactory() : new LittleEndianStreamFactory();
/** Cross-platform memory pointer. */
protected long memPtr;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
index 2f6ad5c..b16f42f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformBigEndianOutputStreamImpl.java
@@ -17,7 +17,7 @@
package org.apache.ignite.internal.processors.platform.memory;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
/**
* Interop output stream implementation working with BIG ENDIAN architecture.
@@ -46,7 +46,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (short item : val) {
- UNSAFE.putShort(startPos, Short.reverseBytes(item));
+ GridUnsafe.putShort(startPos, Short.reverseBytes(item));
startPos += 2;
}
@@ -68,7 +68,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (char item : val) {
- UNSAFE.putChar(startPos, Character.reverseBytes(item));
+ GridUnsafe.putChar(startPos, Character.reverseBytes(item));
startPos += 2;
}
@@ -90,7 +90,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (int item : val) {
- UNSAFE.putInt(startPos, Integer.reverseBytes(item));
+ GridUnsafe.putInt(startPos, Integer.reverseBytes(item));
startPos += 4;
}
@@ -117,7 +117,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (float item : val) {
- UNSAFE.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
+ GridUnsafe.putInt(startPos, Integer.reverseBytes(Float.floatToIntBits(item)));
startPos += 4;
}
@@ -139,7 +139,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (long item : val) {
- UNSAFE.putLong(startPos, Long.reverseBytes(item));
+ GridUnsafe.putLong(startPos, Long.reverseBytes(item));
startPos += 8;
}
@@ -156,7 +156,7 @@ public class PlatformBigEndianOutputStreamImpl extends PlatformOutputStreamImpl
long startPos = data + pos;
for (double item : val) {
- UNSAFE.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
+ GridUnsafe.putLong(startPos, Long.reverseBytes(Double.doubleToLongBits(item)));
startPos += 8;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
index 13da8c5..5e26905 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformInputStreamImpl.java
@@ -18,16 +18,7 @@
package org.apache.ignite.internal.processors.platform.memory;
import org.apache.ignite.IgniteException;
-
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BOOLEAN_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.CHAR_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.DOUBLE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.FLOAT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.INT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.LONG_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.SHORT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
/**
* Interop input stream implementation.
@@ -64,14 +55,14 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public byte readByte() {
ensureEnoughData(1);
- return UNSAFE.getByte(data + pos++);
+ return GridUnsafe.getByte(data + pos++);
}
/** {@inheritDoc} */
@Override public byte[] readByteArray(int cnt) {
byte[] res = new byte[cnt];
- copyAndShift(res, BYTE_ARR_OFF, cnt);
+ copyAndShift(res, GridUnsafe.BYTE_ARR_OFF, cnt);
return res;
}
@@ -85,7 +76,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public boolean[] readBooleanArray(int cnt) {
boolean[] res = new boolean[cnt];
- copyAndShift(res, BOOLEAN_ARR_OFF, cnt);
+ copyAndShift(res, GridUnsafe.BOOLEAN_ARR_OFF, cnt);
return res;
}
@@ -94,7 +85,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public short readShort() {
ensureEnoughData(2);
- short res = UNSAFE.getShort(data + pos);
+ short res = GridUnsafe.getShort(data + pos);
shift(2);
@@ -107,7 +98,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
short[] res = new short[cnt];
- copyAndShift(res, SHORT_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.SHORT_ARR_OFF, len);
return res;
}
@@ -116,7 +107,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public char readChar() {
ensureEnoughData(2);
- char res = UNSAFE.getChar(data + pos);
+ char res = GridUnsafe.getChar(data + pos);
shift(2);
@@ -129,7 +120,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
char[] res = new char[cnt];
- copyAndShift(res, CHAR_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.CHAR_ARR_OFF, len);
return res;
}
@@ -138,7 +129,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public int readInt() {
ensureEnoughData(4);
- int res = UNSAFE.getInt(data + pos);
+ int res = GridUnsafe.getInt(data + pos);
shift(4);
@@ -152,7 +143,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
if (delta > 0)
ensureEnoughData(delta);
- return UNSAFE.getByte(data + pos);
+ return GridUnsafe.getByte(data + pos);
}
/** {@inheritDoc} */
@@ -162,7 +153,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
if (delta > 0)
ensureEnoughData(delta);
- return UNSAFE.getShort(data + pos);
+ return GridUnsafe.getShort(data + pos);
}
/** {@inheritDoc} */
@@ -172,7 +163,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
if (delta > 0)
ensureEnoughData(delta);
- return UNSAFE.getInt(data + pos);
+ return GridUnsafe.getInt(data + pos);
}
/** {@inheritDoc} */
@@ -181,7 +172,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
int[] res = new int[cnt];
- copyAndShift(res, INT_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.INT_ARR_OFF, len);
return res;
}
@@ -190,7 +181,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public float readFloat() {
ensureEnoughData(4);
- float res = UNSAFE.getFloat(data + pos);
+ float res = GridUnsafe.getFloat(data + pos);
shift(4);
@@ -203,7 +194,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
float[] res = new float[cnt];
- copyAndShift(res, FLOAT_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.FLOAT_ARR_OFF, len);
return res;
}
@@ -212,7 +203,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public long readLong() {
ensureEnoughData(8);
- long res = UNSAFE.getLong(data + pos);
+ long res = GridUnsafe.getLong(data + pos);
shift(8);
@@ -225,7 +216,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
long[] res = new long[cnt];
- copyAndShift(res, LONG_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.LONG_ARR_OFF, len);
return res;
}
@@ -234,7 +225,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
@Override public double readDouble() {
ensureEnoughData(8);
- double res = UNSAFE.getDouble(data + pos);
+ double res = GridUnsafe.getDouble(data + pos);
shift(8);
@@ -247,7 +238,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
double[] res = new double[cnt];
- copyAndShift(res, DOUBLE_ARR_OFF, len);
+ copyAndShift(res, GridUnsafe.DOUBLE_ARR_OFF, len);
return res;
}
@@ -257,7 +248,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
if (len > remaining())
len = remaining();
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
+ copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
return len;
}
@@ -290,7 +281,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
if (dataCopy == null) {
dataCopy = new byte[len];
- UNSAFE.copyMemory(null, data, dataCopy, BYTE_ARR_OFF, dataCopy.length);
+ GridUnsafe.copyMemory(null, data, dataCopy, GridUnsafe.BYTE_ARR_OFF, dataCopy.length);
}
return dataCopy;
@@ -333,7 +324,7 @@ public class PlatformInputStreamImpl implements PlatformInputStream {
private void copyAndShift(Object target, long off, int cnt) {
ensureEnoughData(cnt);
- UNSAFE.copyMemory(null, data + pos, target, off, cnt);
+ GridUnsafe.copyMemory(null, data + pos, target, off, cnt);
shift(cnt);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
index 2520a47..894658c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformMemoryUtils.java
@@ -17,44 +17,12 @@
package org.apache.ignite.internal.processors.platform.memory;
-import java.nio.ByteOrder;
import org.apache.ignite.internal.util.GridUnsafe;
-import sun.misc.Unsafe;
/**
* Utility classes for memory management.
*/
public class PlatformMemoryUtils {
- /** Unsafe instance. */
- public static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** Array offset: boolean. */
- public static final long BOOLEAN_ARR_OFF = UNSAFE.arrayBaseOffset(boolean[].class);
-
- /** Array offset: byte. */
- public static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** Array offset: short. */
- public static final long SHORT_ARR_OFF = UNSAFE.arrayBaseOffset(short[].class);
-
- /** Array offset: char. */
- public static final long CHAR_ARR_OFF = UNSAFE.arrayBaseOffset(char[].class);
-
- /** Array offset: int. */
- public static final long INT_ARR_OFF = UNSAFE.arrayBaseOffset(int[].class);
-
- /** Array offset: float. */
- public static final long FLOAT_ARR_OFF = UNSAFE.arrayBaseOffset(float[].class);
-
- /** Array offset: long. */
- public static final long LONG_ARR_OFF = UNSAFE.arrayBaseOffset(long[].class);
-
- /** Array offset: double. */
- public static final long DOUBLE_ARR_OFF = UNSAFE.arrayBaseOffset(double[].class);
-
- /** Whether little endian is used on the platform. */
- public static final boolean LITTLE_ENDIAN = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
-
/** Header length. */
public static final int POOL_HDR_LEN = 64;
@@ -97,7 +65,7 @@ public class PlatformMemoryUtils {
* @return Data pointer.
*/
public static long data(long memPtr) {
- return UNSAFE.getLong(memPtr);
+ return GridUnsafe.getLong(memPtr);
}
/**
@@ -107,7 +75,7 @@ public class PlatformMemoryUtils {
* @return Capacity.
*/
public static int capacity(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_CAP);
+ return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_CAP);
}
/**
@@ -119,7 +87,7 @@ public class PlatformMemoryUtils {
public static void capacity(long memPtr, int cap) {
assert !isExternal(memPtr) : "Attempt to update external memory chunk capacity: " + memPtr;
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
}
/**
@@ -129,7 +97,7 @@ public class PlatformMemoryUtils {
* @return Length.
*/
public static int length(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_LEN);
+ return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_LEN);
}
/**
@@ -139,7 +107,7 @@ public class PlatformMemoryUtils {
* @param len Length.
*/
public static void length(long memPtr, int len) {
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, len);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_LEN, len);
}
/**
@@ -149,7 +117,7 @@ public class PlatformMemoryUtils {
* @return Flags.
*/
public static int flags(long memPtr) {
- return UNSAFE.getInt(memPtr + MEM_HDR_OFF_FLAGS);
+ return GridUnsafe.getInt(memPtr + MEM_HDR_OFF_FLAGS);
}
/**
@@ -161,7 +129,7 @@ public class PlatformMemoryUtils {
public static void flags(long memPtr, int flags) {
assert !isExternal(memPtr) : "Attempt to update external memory chunk flags: " + memPtr;
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_FLAGS, flags);
}
/**
@@ -237,13 +205,13 @@ public class PlatformMemoryUtils {
public static long allocateUnpooled(int cap) {
assert cap > 0;
- long memPtr = UNSAFE.allocateMemory(MEM_HDR_LEN);
- long dataPtr = UNSAFE.allocateMemory(cap);
+ long memPtr = GridUnsafe.allocateMemory(MEM_HDR_LEN);
+ long dataPtr = GridUnsafe.allocateMemory(cap);
- UNSAFE.putLong(memPtr, dataPtr); // Write address.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_LEN, 0); // Write length.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
+ GridUnsafe.putLong(memPtr, dataPtr); // Write address.
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write capacity.
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_LEN, 0); // Write length.
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_FLAGS, 0); // Write flags.
return memPtr;
}
@@ -262,12 +230,12 @@ public class PlatformMemoryUtils {
long dataPtr = data(memPtr);
- long newDataPtr = UNSAFE.reallocateMemory(dataPtr, cap);
+ long newDataPtr = GridUnsafe.reallocateMemory(dataPtr, cap);
if (dataPtr != newDataPtr)
- UNSAFE.putLong(memPtr, newDataPtr); // Write new data address if needed.
+ GridUnsafe.putLong(memPtr, newDataPtr); // Write new data address if needed.
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap); // Write new capacity.
}
/**
@@ -279,8 +247,8 @@ public class PlatformMemoryUtils {
assert !isExternal(memPtr) : "Attempt to release external memory chunk directly: " + memPtr;
assert !isPooled(memPtr) : "Attempt to release pooled memory chunk directly: " + memPtr;
- UNSAFE.freeMemory(data(memPtr));
- UNSAFE.freeMemory(memPtr);
+ GridUnsafe.freeMemory(data(memPtr));
+ GridUnsafe.freeMemory(memPtr);
}
/** --- POOLED MEMORY MANAGEMENT. --- */
@@ -291,9 +259,9 @@ public class PlatformMemoryUtils {
* @return Pool pointer.
*/
public static long allocatePool() {
- long poolPtr = UNSAFE.allocateMemory(POOL_HDR_LEN);
+ long poolPtr = GridUnsafe.allocateMemory(POOL_HDR_LEN);
- UNSAFE.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
+ GridUnsafe.setMemory(poolPtr, POOL_HDR_LEN, (byte)0);
flags(poolPtr + POOL_HDR_OFF_MEM_1, FLAG_POOLED);
flags(poolPtr + POOL_HDR_OFF_MEM_2, FLAG_POOLED);
@@ -309,23 +277,23 @@ public class PlatformMemoryUtils {
*/
public static void releasePool(long poolPtr) {
// Clean predefined memory chunks.
- long mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
+ long mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_1);
if (mem != 0)
- UNSAFE.freeMemory(mem);
+ GridUnsafe.freeMemory(mem);
- mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
+ mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_2);
if (mem != 0)
- UNSAFE.freeMemory(mem);
+ GridUnsafe.freeMemory(mem);
- mem = UNSAFE.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
+ mem = GridUnsafe.getLong(poolPtr + POOL_HDR_OFF_MEM_3);
if (mem != 0)
- UNSAFE.freeMemory(mem);
+ GridUnsafe.freeMemory(mem);
// Clean pool chunk.
- UNSAFE.freeMemory(poolPtr);
+ GridUnsafe.freeMemory(poolPtr);
}
/**
@@ -376,24 +344,24 @@ public class PlatformMemoryUtils {
assert isPooled(memPtr);
assert !isAcquired(memPtr);
- long data = UNSAFE.getLong(memPtr);
+ long data = GridUnsafe.getLong(memPtr);
if (data == 0) {
// First allocation of the chunk.
- data = UNSAFE.allocateMemory(cap);
+ data = GridUnsafe.allocateMemory(cap);
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ GridUnsafe.putLong(memPtr, data);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
}
else {
// Ensure that we have enough capacity.
int curCap = capacity(memPtr);
if (cap > curCap) {
- data = UNSAFE.reallocateMemory(data, cap);
+ data = GridUnsafe.reallocateMemory(data, cap);
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ GridUnsafe.putLong(memPtr, data);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
}
}
@@ -411,17 +379,17 @@ public class PlatformMemoryUtils {
assert isPooled(memPtr);
assert isAcquired(memPtr);
- long data = UNSAFE.getLong(memPtr);
+ long data = GridUnsafe.getLong(memPtr);
assert data != 0;
int curCap = capacity(memPtr);
if (cap > curCap) {
- data = UNSAFE.reallocateMemory(data, cap);
+ data = GridUnsafe.reallocateMemory(data, cap);
- UNSAFE.putLong(memPtr, data);
- UNSAFE.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
+ GridUnsafe.putLong(memPtr, data);
+ GridUnsafe.putInt(memPtr + MEM_HDR_OFF_CAP, cap);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
index 59d8981..cb30336 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/memory/PlatformOutputStreamImpl.java
@@ -17,15 +17,7 @@
package org.apache.ignite.internal.processors.platform.memory;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BOOLEAN_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.BYTE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.CHAR_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.DOUBLE_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.FLOAT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.INT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.LONG_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.SHORT_ARR_OFF;
-import static org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils.UNSAFE;
+import org.apache.ignite.internal.util.GridUnsafe;
/**
* Interop output stream implementation.
@@ -59,12 +51,12 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
@Override public void writeByte(byte val) {
ensureCapacity(pos + 1);
- UNSAFE.putByte(data + pos++, val);
+ GridUnsafe.putByte(data + pos++, val);
}
/** {@inheritDoc} */
@Override public void writeByteArray(byte[] val) {
- copyAndShift(val, BYTE_ARR_OFF, val.length);
+ copyAndShift(val, GridUnsafe.BYTE_ARR_OFF, val.length);
}
/** {@inheritDoc} */
@@ -74,63 +66,63 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
/** {@inheritDoc} */
@Override public void writeBooleanArray(boolean[] val) {
- copyAndShift(val, BOOLEAN_ARR_OFF, val.length);
+ copyAndShift(val, GridUnsafe.BOOLEAN_ARR_OFF, val.length);
}
/** {@inheritDoc} */
@Override public void writeShort(short val) {
ensureCapacity(pos + 2);
- UNSAFE.putShort(data + pos, val);
+ GridUnsafe.putShort(data + pos, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void writeShortArray(short[] val) {
- copyAndShift(val, SHORT_ARR_OFF, val.length << 1);
+ copyAndShift(val, GridUnsafe.SHORT_ARR_OFF, val.length << 1);
}
/** {@inheritDoc} */
@Override public void writeChar(char val) {
ensureCapacity(pos + 2);
- UNSAFE.putChar(data + pos, val);
+ GridUnsafe.putChar(data + pos, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void writeCharArray(char[] val) {
- copyAndShift(val, CHAR_ARR_OFF, val.length << 1);
+ copyAndShift(val, GridUnsafe.CHAR_ARR_OFF, val.length << 1);
}
/** {@inheritDoc} */
@Override public void writeInt(int val) {
ensureCapacity(pos + 4);
- UNSAFE.putInt(data + pos, val);
+ GridUnsafe.putInt(data + pos, val);
shift(4);
}
/** {@inheritDoc} */
@Override public void writeIntArray(int[] val) {
- copyAndShift(val, INT_ARR_OFF, val.length << 2);
+ copyAndShift(val, GridUnsafe.INT_ARR_OFF, val.length << 2);
}
/** {@inheritDoc} */
@Override public void writeShort(int pos, short val) {
ensureCapacity(pos + 2);
- UNSAFE.putShort(data + pos, val);
+ GridUnsafe.putShort(data + pos, val);
}
/** {@inheritDoc} */
@Override public void writeInt(int pos, int val) {
ensureCapacity(pos + 4);
- UNSAFE.putInt(data + pos, val);
+ GridUnsafe.putInt(data + pos, val);
}
/** {@inheritDoc} */
@@ -140,21 +132,21 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
/** {@inheritDoc} */
@Override public void writeFloatArray(float[] val) {
- copyAndShift(val, FLOAT_ARR_OFF, val.length << 2);
+ copyAndShift(val, GridUnsafe.FLOAT_ARR_OFF, val.length << 2);
}
/** {@inheritDoc} */
@Override public void writeLong(long val) {
ensureCapacity(pos + 8);
- UNSAFE.putLong(data + pos, val);
+ GridUnsafe.putLong(data + pos, val);
shift(8);
}
/** {@inheritDoc} */
@Override public void writeLongArray(long[] val) {
- copyAndShift(val, LONG_ARR_OFF, val.length << 3);
+ copyAndShift(val, GridUnsafe.LONG_ARR_OFF, val.length << 3);
}
/** {@inheritDoc} */
@@ -164,12 +156,12 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
/** {@inheritDoc} */
@Override public void writeDoubleArray(double[] val) {
- copyAndShift(val, DOUBLE_ARR_OFF, val.length << 3);
+ copyAndShift(val, GridUnsafe.DOUBLE_ARR_OFF, val.length << 3);
}
/** {@inheritDoc} */
@Override public void write(byte[] arr, int off, int len) {
- copyAndShift(arr, BYTE_ARR_OFF + off, len);
+ copyAndShift(arr, GridUnsafe.BYTE_ARR_OFF + off, len);
}
/** {@inheritDoc} */
@@ -234,7 +226,7 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
/** {@inheritDoc} */
@Override public void unsafeWriteByte(byte val) {
- UNSAFE.putByte(data + pos++, val);
+ GridUnsafe.putByte(data + pos++, val);
}
/** {@inheritDoc} */
@@ -244,38 +236,38 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
/** {@inheritDoc} */
@Override public void unsafeWriteShort(short val) {
- UNSAFE.putShort(data + pos, val);
+ GridUnsafe.putShort(data + pos, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteShort(int pos, short val) {
- UNSAFE.putShort(data + pos, val);
+ GridUnsafe.putShort(data + pos, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteChar(char val) {
- UNSAFE.putChar(data + pos, val);
+ GridUnsafe.putChar(data + pos, val);
shift(2);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int val) {
- UNSAFE.putInt(data + pos, val);
+ GridUnsafe.putInt(data + pos, val);
shift(4);
}
/** {@inheritDoc} */
@Override public void unsafeWriteInt(int pos, int val) {
- UNSAFE.putInt(data + pos, val);
+ GridUnsafe.putInt(data + pos, val);
}
/** {@inheritDoc} */
@Override public void unsafeWriteLong(long val) {
- UNSAFE.putLong(data + pos, val);
+ GridUnsafe.putLong(data + pos, val);
shift(8);
}
@@ -335,7 +327,7 @@ public class PlatformOutputStreamImpl implements PlatformOutputStream {
private void copyAndShift(Object src, long off, int len) {
ensureCapacity(pos + len);
- UNSAFE.copyMemory(src, off, null, data + pos, len);
+ GridUnsafe.copyMemory(src, off, null, data + pos, len);
shift(len);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
index 319a633..dd85bcf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridHandleTable.java
@@ -18,19 +18,14 @@
package org.apache.ignite.internal.util;
import java.util.Arrays;
-import sun.misc.Unsafe;
+
+import static org.apache.ignite.internal.util.GridUnsafe.INT_ARR_OFF;
/**
* Lightweight identity hash table which maps objects to integer handles,
* assigned in ascending order.
*/
public class GridHandleTable {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- private static final long intArrOff = UNSAFE.arrayBaseOffset(int[].class);
-
/** Number of mappings in table/next available handle. */
private int size;
@@ -111,8 +106,8 @@ public class GridHandleTable {
* Resets table to its initial (empty) state.
*/
public void clear() {
- UNSAFE.copyMemory(spineEmpty, intArrOff, spine, intArrOff, spineEmpty.length << 2);
- UNSAFE.copyMemory(nextEmpty, intArrOff, next, intArrOff, nextEmpty.length << 2);
+ GridUnsafe.copyMemory(spineEmpty, INT_ARR_OFF, spine, INT_ARR_OFF, spineEmpty.length << 2);
+ GridUnsafe.copyMemory(nextEmpty, INT_ARR_OFF, next, INT_ARR_OFF, nextEmpty.length << 2);
Arrays.fill(objs, null);
@@ -153,7 +148,7 @@ public class GridHandleTable {
Arrays.fill(spineEmpty, -1);
- UNSAFE.copyMemory(spineEmpty, intArrOff, spine, intArrOff, spineEmpty.length << 2);
+ GridUnsafe.copyMemory(spineEmpty, INT_ARR_OFF, spine, INT_ARR_OFF, spineEmpty.length << 2);
for (int i = 0; i < this.size; i++) {
Object obj = objs[i];
@@ -171,7 +166,7 @@ public class GridHandleTable {
int newLen = (next.length << 1) + 1;
int[] newNext = new int[newLen];
- UNSAFE.copyMemory(next, intArrOff, newNext, intArrOff, size << 2);
+ GridUnsafe.copyMemory(next, INT_ARR_OFF, newNext, INT_ARR_OFF, size << 2);
next = newNext;
nextEmpty = new int[newLen];
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 3371eb8..8a0b0ae 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -128,9 +128,6 @@ public final class GridJavaProcess {
public static GridJavaProcess exec(String clsName, String params, @Nullable IgniteLogger log,
@Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC,
@Nullable String javaHome, @Nullable Collection<String> jvmArgs, @Nullable String cp) throws Exception {
- if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
- throw new Exception("Your OS is not supported.");
-
GridJavaProcess gjProc = new GridJavaProcess();
gjProc.log = log;
http://git-wip-us.apache.org/repos/asf/ignite/blob/a87decdc/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
index a1fa892..4f23979 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridSpinReadWriteLock.java
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
-import sun.misc.Unsafe;
/**
*
@@ -29,9 +28,6 @@ import sun.misc.Unsafe;
@GridToStringExclude
public class GridSpinReadWriteLock {
/** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
private static final long PENDING_WLOCKS_OFFS;
/** */
@@ -42,10 +38,10 @@ public class GridSpinReadWriteLock {
*/
static {
try {
- STATE_OFFS = UNSAFE.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("state"));
+ STATE_OFFS = GridUnsafe.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("state"));
PENDING_WLOCKS_OFFS =
- UNSAFE.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("pendingWLocks"));
+ GridUnsafe.objectFieldOffset(GridSpinReadWriteLock.class.getDeclaredField("pendingWLocks"));
}
catch (NoSuchFieldException e) {
throw new Error(e);
@@ -403,7 +399,7 @@ public class GridSpinReadWriteLock {
* @return {@code True} on success.
*/
private boolean compareAndSet(long offs, int expect, int update) {
- return UNSAFE.compareAndSwapInt(this, offs, expect, update);
+ return GridUnsafe.compareAndSwapInt(this, offs, expect, update);
}
/** {@inheritDoc} */