You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/02/02 18:17:44 UTC
[01/16] ignite git commit: IGNITE-1069 Added output of node type
(server or client) in Visor commandline for node command. - Fixes #442.
Repository: ignite
Updated Branches:
refs/heads/ignite-2407 4ac9e3f2a -> bc388fde8
IGNITE-1069 Added output of node type (server or client) in Visor commandline for node command. - Fixes #442.
Signed-off-by: AKuznetsov <ak...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/58dce88b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/58dce88b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/58dce88b
Branch: refs/heads/ignite-2407
Commit: 58dce88b8dd0762c413850af2dfeadbdd22c519f
Parents: c3b83fe
Author: kcheng <kc...@gmail.com>
Authored: Mon Feb 1 20:31:34 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Feb 1 20:31:34 2016 +0700
----------------------------------------------------------------------
.../org/apache/ignite/visor/commands/node/VisorNodeCommand.scala | 1 +
.../src/main/scala/org/apache/ignite/visor/visor.scala | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58dce88b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
index f4a1f87..9ba0129 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/commands/node/VisorNodeCommand.scala
@@ -157,6 +157,7 @@ class VisorNodeCommand extends VisorConsoleCommand {
t += ("ID", node.id)
t += ("ID8", nid8(node))
+ t += ("Node Type", if (node.isClient) "Client" else "Server")
t += ("Order", node.order)
(0 /: sortAddresses(node.addresses))((b, a) => { t += ("Address (" + b + ")", a); b + 1 })
http://git-wip-us.apache.org/repos/asf/ignite/blob/58dce88b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
----------------------------------------------------------------------
diff --git a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
index 986089b..a4eed69 100644
--- a/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
+++ b/modules/visor-console/src/main/scala/org/apache/ignite/visor/visor.scala
@@ -1800,7 +1800,7 @@ object visor extends VisorTag {
val t = VisorTextTable()
- t #= ("#", "Node ID8(@), IP", "Up Time", "CPUs", "CPU Load", "Free Heap")
+ t #= ("#", "Node ID8(@), IP","Node Type", "Up Time", "CPUs", "CPU Load", "Free Heap")
val nodes = ignite.cluster.nodes().toList
@@ -1826,6 +1826,7 @@ object visor extends VisorTag {
t += (
i,
nodeId8Addr(n.id),
+ if (n.isClient) "Client" else "Server",
X.timeSpan2HMS(m.getUpTime),
n.metrics.getTotalCpus,
safePercent(cpuLoadPct),
[02/16] ignite git commit: IGNITE-2191 - Support classes with the
same simple name for Binary marshaller - Fixes #398.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
index 93c80d3..33656fb 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
@@ -43,6 +43,7 @@ import org.yardstickframework.BenchmarkServer;
import org.yardstickframework.BenchmarkUtils;
import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_VALUES;
+import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MARSHALLER;
/**
* Standalone Ignite node.
@@ -150,6 +151,8 @@ public class IgniteNode implements BenchmarkServer {
c.setCommunicationSpi(commSpi);
ignite = IgniteSpring.start(c, appCtx);
+
+ BenchmarkUtils.println("Configured marshaller: " + ignite.cluster().localNode().attribute(ATTR_MARSHALLER));
}
/**
[08/16] ignite git commit: 2224
Posted by sb...@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();
[07/16] ignite git commit: 2224
Posted by sb...@apache.org.
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");
+ }
+}
[09/16] ignite git commit: 2224
Posted by sb...@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-2407
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) {
[03/16] ignite git commit: IGNITE-2191 - Support classes with the
same simple name for Binary marshaller - Fixes #398.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
new file mode 100644
index 0000000..041238f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridDefaultBinaryMappersBinaryMetaDataSelfTest.java
@@ -0,0 +1,389 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.Binarylizable;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Binary meta data test.
+ */
+public class GridDefaultBinaryMappersBinaryMetaDataSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static IgniteConfiguration cfg;
+
+ /** */
+ private static int idx;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+ bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+
+ bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
+
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ cfg.setCacheConfiguration(ccfg);
+
+ GridDefaultBinaryMappersBinaryMetaDataSelfTest.cfg = cfg;
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTest() throws Exception {
+ idx = 0;
+
+ startGrid();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopGrid();
+ }
+
+ /**
+ * @return Binaries API.
+ */
+ protected IgniteBinary binaries() {
+ return grid().binary();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetAll() throws Exception {
+ binaries().toBinary(new TestObject2());
+
+ Collection<BinaryType> metas = binaries().types();
+
+ assertEquals(2, metas.size());
+
+ for (BinaryType meta : metas) {
+ Collection<String> fields;
+
+ if (expectedTypeName(TestObject1.class.getName()).equals(meta.typeName())) {
+ fields = meta.fieldNames();
+
+ assertEquals(7, fields.size());
+
+ assertTrue(fields.contains("intVal"));
+ assertTrue(fields.contains("strVal"));
+ assertTrue(fields.contains("arrVal"));
+ assertTrue(fields.contains("obj1Val"));
+ assertTrue(fields.contains("obj2Val"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("int", meta.fieldTypeName("intVal"));
+ assertEquals("String", meta.fieldTypeName("strVal"));
+ assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+ assertEquals("Object", meta.fieldTypeName("obj1Val"));
+ assertEquals("Object", meta.fieldTypeName("obj2Val"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+ else if (expectedTypeName(TestObject2.class.getName()).equals(meta.typeName())) {
+ fields = meta.fieldNames();
+
+ assertEquals(7, fields.size());
+
+ assertTrue(fields.contains("boolVal"));
+ assertTrue(fields.contains("dateVal"));
+ assertTrue(fields.contains("uuidArrVal"));
+ assertTrue(fields.contains("objVal"));
+ assertTrue(fields.contains("mapVal"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("boolean", meta.fieldTypeName("boolVal"));
+ assertEquals("Date", meta.fieldTypeName("dateVal"));
+ assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+ assertEquals("Object", meta.fieldTypeName("objVal"));
+ assertEquals("Map", meta.fieldTypeName("mapVal"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+ else
+ assert false : meta.typeName();
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoConfiguration() throws Exception {
+ binaries().toBinary(new TestObject3());
+
+ assertNotNull(binaries().type(TestObject3.class));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testReflection() throws Exception {
+ BinaryType meta = binaries().type(TestObject1.class);
+
+ assertNotNull(meta);
+
+ assertEquals(expectedTypeName(TestObject1.class.getName()), meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(7, fields.size());
+
+ assertTrue(fields.contains("intVal"));
+ assertTrue(fields.contains("strVal"));
+ assertTrue(fields.contains("arrVal"));
+ assertTrue(fields.contains("obj1Val"));
+ assertTrue(fields.contains("obj2Val"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("int", meta.fieldTypeName("intVal"));
+ assertEquals("String", meta.fieldTypeName("strVal"));
+ assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+ assertEquals("Object", meta.fieldTypeName("obj1Val"));
+ assertEquals("Object", meta.fieldTypeName("obj2Val"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type name.
+ */
+ private String expectedTypeName(String clsName) {
+ BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper();
+
+ if (mapper == null)
+ mapper = BinaryContext.defaultNameMapper();
+
+ return mapper.typeName(clsName);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBinaryMarshalAware() throws Exception {
+ binaries().toBinary(new TestObject2());
+
+ BinaryType meta = binaries().type(TestObject2.class);
+
+ assertNotNull(meta);
+
+ assertEquals(expectedTypeName(TestObject2.class.getName()), meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(7, fields.size());
+
+ assertTrue(fields.contains("boolVal"));
+ assertTrue(fields.contains("dateVal"));
+ assertTrue(fields.contains("uuidArrVal"));
+ assertTrue(fields.contains("objVal"));
+ assertTrue(fields.contains("mapVal"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("boolean", meta.fieldTypeName("boolVal"));
+ assertEquals("Date", meta.fieldTypeName("dateVal"));
+ assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+ assertEquals("Object", meta.fieldTypeName("objVal"));
+ assertEquals("Map", meta.fieldTypeName("mapVal"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMerge() throws Exception {
+ binaries().toBinary(new TestObject2());
+
+ idx = 1;
+
+ binaries().toBinary(new TestObject2());
+
+ BinaryType meta = binaries().type(TestObject2.class);
+
+ assertNotNull(meta);
+
+ assertEquals(expectedTypeName(TestObject2.class.getName()), meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(9, fields.size());
+
+ assertTrue(fields.contains("boolVal"));
+ assertTrue(fields.contains("dateVal"));
+ assertTrue(fields.contains("uuidArrVal"));
+ assertTrue(fields.contains("objVal"));
+ assertTrue(fields.contains("mapVal"));
+ assertTrue(fields.contains("charVal"));
+ assertTrue(fields.contains("colVal"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("boolean", meta.fieldTypeName("boolVal"));
+ assertEquals("Date", meta.fieldTypeName("dateVal"));
+ assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
+ assertEquals("Object", meta.fieldTypeName("objVal"));
+ assertEquals("Map", meta.fieldTypeName("mapVal"));
+ assertEquals("char", meta.fieldTypeName("charVal"));
+ assertEquals("Collection", meta.fieldTypeName("colVal"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSerializedObject() throws Exception {
+ TestObject1 obj = new TestObject1();
+
+ obj.intVal = 10;
+ obj.strVal = "str";
+ obj.arrVal = new byte[] {2, 4, 6};
+ obj.obj1Val = null;
+ obj.obj2Val = new TestObject2();
+ obj.decVal = BigDecimal.ZERO;
+ obj.decArrVal = new BigDecimal[] { BigDecimal.ONE };
+
+ BinaryObject po = binaries().toBinary(obj);
+
+ info(po.toString());
+
+ BinaryType meta = po.type();
+
+ assertNotNull(meta);
+
+ assertEquals(expectedTypeName(TestObject1.class.getName()), meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(7, fields.size());
+
+ assertTrue(fields.contains("intVal"));
+ assertTrue(fields.contains("strVal"));
+ assertTrue(fields.contains("arrVal"));
+ assertTrue(fields.contains("obj1Val"));
+ assertTrue(fields.contains("obj2Val"));
+ assertTrue(fields.contains("decVal"));
+ assertTrue(fields.contains("decArrVal"));
+
+ assertEquals("int", meta.fieldTypeName("intVal"));
+ assertEquals("String", meta.fieldTypeName("strVal"));
+ assertEquals("byte[]", meta.fieldTypeName("arrVal"));
+ assertEquals("Object", meta.fieldTypeName("obj1Val"));
+ assertEquals("Object", meta.fieldTypeName("obj2Val"));
+ assertEquals("decimal", meta.fieldTypeName("decVal"));
+ assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
+ }
+
+ /**
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class TestObject1 {
+ /** */
+ private int intVal;
+
+ /** */
+ private String strVal;
+
+ /** */
+ private byte[] arrVal;
+
+ /** */
+ private TestObject1 obj1Val;
+
+ /** */
+ private TestObject2 obj2Val;
+
+ /** */
+ private BigDecimal decVal;
+
+ /** */
+ private BigDecimal[] decArrVal;
+ }
+
+ /**
+ */
+ private static class TestObject2 implements Binarylizable {
+ /** {@inheritDoc} */
+ @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
+ writer.writeBoolean("boolVal", false);
+ writer.writeDate("dateVal", new Date());
+ writer.writeUuidArray("uuidArrVal", null);
+ writer.writeObject("objVal", null);
+ writer.writeMap("mapVal", new HashMap<>());
+ writer.writeDecimal("decVal", BigDecimal.ZERO);
+ writer.writeDecimalArray("decArrVal", new BigDecimal[] { BigDecimal.ONE });
+
+ if (idx == 1) {
+ writer.writeChar("charVal", (char)0);
+ writer.writeCollection("colVal", null);
+ }
+
+ BinaryRawWriter raw = writer.rawWriter();
+
+ raw.writeChar((char)0);
+ raw.writeCollection(null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
+ // No-op.
+ }
+ }
+
+ /**
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class TestObject3 {
+ /** */
+ private int intVal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
new file mode 100644
index 0000000..74c13ce
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Binary meta data test.
+ */
+public class GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest
+ extends GridDefaultBinaryMappersBinaryMetaDataSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+ bCfg.setNameMapper(new BinaryBasicNameMapper());
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+ return cfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
new file mode 100644
index 0000000..8705f6a
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/TestMappedObject.java
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+/**
+ *
+ */
+public class TestMappedObject {
+
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
new file mode 100644
index 0000000..88a1296
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactDefaultMappersSelfTest.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.binary.noncompact;
+
+import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
+
+/**
+ * Binary builder test for objects with non-compact footer.
+ */
+public class BinaryObjectBuilderNonCompactDefaultMappersSelfTest extends BinaryObjectBuilderDefaultMappersSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
deleted file mode 100644
index c698783..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSelfTest.java
+++ /dev/null
@@ -1,30 +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.binary.noncompact;
-
-import org.apache.ignite.internal.binary.BinaryObjectBuilderSelfTest;
-
-/**
- * Binary builder test for objects with non-compact footer.
- */
-public class BinaryObjectBuilderNonCompactSelfTest extends BinaryObjectBuilderSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean compactFooter() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.java
new file mode 100644
index 0000000..821c41b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/noncompact/BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.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.noncompact;
+
+import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
+
+/**
+ * Binary builder test for objects with non-compact footer.
+ */
+public class BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest
+ extends BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean compactFooter() {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
index ea16c1f..3e96cf7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConditionalDeploymentSelfTest.java
@@ -21,8 +21,8 @@ import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.managers.communication.GridIoMessageFactory;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.CO;
import org.apache.ignite.plugin.extensions.communication.Message;
@@ -91,6 +91,8 @@ public class GridCacheConditionalDeploymentSelfTest extends GridCommonAbstractTe
startGrid(1);
+ awaitPartitionMapExchange();
+
ignite0.cache(null).put(1, new TestValue());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
index 2da781b..271e3b5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectsAbstractSelfTest.java
@@ -30,6 +30,7 @@ import javax.cache.processor.MutableEntry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.CachePeekMode;
@@ -38,6 +39,7 @@ 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.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryObjectImpl;
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
@@ -77,6 +79,9 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
/** */
private static final int ENTRY_CNT = 100;
+ /** */
+ private static IgniteConfiguration cfg;
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -109,6 +114,8 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
cfg.setMarshaller(new BinaryMarshaller());
+ this.cfg = cfg;
+
return cfg;
}
@@ -200,8 +207,14 @@ public abstract class GridCacheBinaryObjectsAbstractSelfTest extends GridCommonA
assertNotNull(str);
- assertTrue("Unexpected toString: " + str,
- str.startsWith("TestReferenceObject") && str.contains("obj=TestReferenceObject ["));
+ BinaryNameMapper nameMapper = BinaryContext.defaultNameMapper();
+
+ if (cfg.getBinaryConfiguration() != null && cfg.getBinaryConfiguration().getNameMapper() != null)
+ nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+ String typeName = nameMapper.typeName(TestReferenceObject.class.getName());
+
+ assertTrue("Unexpected toString: " + str, str.startsWith(typeName) && str.contains("obj=" + typeName + " ["));
TestReferenceObject obj1_r = po.deserialize();
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
index 0cfa88b..63ed30e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreAbstractSelfTest.java
@@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.cache.Cache;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.cache.store.CacheStoreAdapter;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -46,6 +48,9 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
/** */
private static final TestStore STORE = new TestStore();
+ /** */
+ protected static IgniteConfiguration cfg;
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -53,6 +58,9 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
BinaryConfiguration bCfg = new BinaryConfiguration();
+ bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+ bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+
bCfg.setClassNames(Arrays.asList(Key.class.getName(), Value.class.getName()));
cfg.setBinaryConfiguration(bCfg);
@@ -75,6 +83,8 @@ public abstract class GridCacheBinaryStoreAbstractSelfTest extends GridCommonAbs
cfg.setDiscoverySpi(disco);
+ GridCacheBinaryStoreAbstractSelfTest.cfg = cfg;
+
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
new file mode 100644
index 0000000..47fc53b
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesDefaultMappersSelfTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.binary;
+
+import java.util.Map;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.binary.BinaryContext;
+
+/**
+ * Tests for cache store with binary.
+ */
+public class GridCacheBinaryStoreBinariesDefaultMappersSelfTest extends GridCacheBinaryStoreAbstractSelfTest {
+ /** {@inheritDoc} */
+ @Override protected boolean keepBinaryInStore() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void populateMap(Map<Object, Object> map, int... idxs) {
+ assert map != null;
+ assert idxs != null;
+
+ for (int idx : idxs)
+ map.put(binary(new Key(idx)), binary(new Value(idx)));
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void checkMap(Map<Object, Object> map, int... idxs) {
+ assert map != null;
+ assert idxs != null;
+
+ assertEquals(idxs.length, map.size());
+
+ for (int idx : idxs) {
+ Object val = map.get(binary(new Key(idx)));
+
+ assertTrue(String.valueOf(val), val instanceof BinaryObject);
+
+ BinaryObject po = (BinaryObject)val;
+
+ assertEquals(expectedTypeName(Value.class.getName()), po.type().typeName());
+ assertEquals(new Integer(idx), po.field("idx"));
+ }
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type name.
+ */
+ private String expectedTypeName(String clsName) {
+ BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+ if (nameMapper == null)
+ nameMapper = BinaryContext.defaultNameMapper();
+
+ return nameMapper.typeName(clsName);
+ }
+
+ /**
+ * @param obj Object.
+ * @return Binary object.
+ */
+ private Object binary(Object obj) {
+ return grid().binary().toBinary(obj);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java
deleted file mode 100644
index 4d163b3..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSelfTest.java
+++ /dev/null
@@ -1,66 +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.binary;
-
-import java.util.Map;
-import org.apache.ignite.binary.BinaryObject;
-
-/**
- * Tests for cache store with binary.
- */
-public class GridCacheBinaryStoreBinariesSelfTest extends GridCacheBinaryStoreAbstractSelfTest {
- /** {@inheritDoc} */
- @Override protected boolean keepBinaryInStore() {
- return true;
- }
-
- /** {@inheritDoc} */
- @Override protected void populateMap(Map<Object, Object> map, int... idxs) {
- assert map != null;
- assert idxs != null;
-
- for (int idx : idxs)
- map.put(binary(new Key(idx)), binary(new Value(idx)));
- }
-
- /** {@inheritDoc} */
- @Override protected void checkMap(Map<Object, Object> map, int... idxs) {
- assert map != null;
- assert idxs != null;
-
- assertEquals(idxs.length, map.size());
-
- for (int idx : idxs) {
- Object val = map.get(binary(new Key(idx)));
-
- assertTrue(String.valueOf(val), val instanceof BinaryObject);
-
- BinaryObject po = (BinaryObject)val;
-
- assertEquals("Value", po.type().typeName());
- assertEquals(new Integer(idx), po.field("idx"));
- }
- }
-
- /**
- * @param obj Object.
- * @return Binary object.
- */
- private Object binary(Object obj) {
- return grid().binary().toBinary(obj);
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
new file mode 100644
index 0000000..0aee2f2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.java
@@ -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.
+ */
+package org.apache.ignite.internal.processors.cache.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Tests for cache store with binary.
+ */
+public class GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest
+ extends GridCacheBinaryStoreBinariesDefaultMappersSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+ bCfg.setNameMapper(new BinaryBasicNameMapper());
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+ return cfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java b/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
index 491f38f..d13f117 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/config/GridTestProperties.java
@@ -79,6 +79,9 @@ public final class GridTestProperties {
public static final String BINARY_COMPACT_FOOTERS = "binary.marshaller.compact.footers";
/** */
+ public static final String BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER = "binary.marshaller.use.simple.name.mapper";
+
+ /** */
static {
// Initialize IGNITE_HOME system property.
String igniteHome = System.getProperty("IGNITE_HOME");
@@ -321,4 +324,4 @@ public final class GridTestProperties {
return props;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 8bf877a..27511ff 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
@@ -50,6 +50,7 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.Ignition;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
@@ -104,6 +105,7 @@ import org.springframework.context.support.FileSystemXmlApplicationContext;
import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.PRIMARY;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER;
/**
* Common abstract test for Ignite tests.
@@ -732,7 +734,14 @@ public abstract class GridAbstractTest extends TestCase {
startingGrid.set(gridName);
try {
- return IgnitionEx.start(optimize(getConfiguration(gridName)), ctx);
+ Ignite node = IgnitionEx.start(optimize(getConfiguration(gridName)), ctx);
+
+ IgniteConfiguration cfg = node.configuration();
+
+ log.info("Node started with the following configuration [id=" + node.cluster().localNode().id()
+ + ", marshaller=" + cfg.getMarshaller() + ", binaryCfg=" + cfg.getBinaryConfiguration() + "]");
+
+ return node;
}
finally {
startingGrid.set(null);
@@ -1143,6 +1152,18 @@ public abstract class GridAbstractTest extends TestCase {
}
}
+ if (Boolean.valueOf(GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER))) {
+ BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+ if (bCfg == null) {
+ bCfg = new BinaryConfiguration();
+
+ cfg.setBinaryConfiguration(bCfg);
+ }
+
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+ }
+
if (gridName != null && gridName.matches(".*\\d")) {
String idStr = UUID.randomUUID().toString();
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 bcd1ede..dece258 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
@@ -111,7 +111,7 @@ public class IgniteBasicTestSuite extends TestSuite {
suite.addTestSuite(GridFailFastNodeFailureDetectionSelfTest.class);
suite.addTestSuite(OffHeapTieredTransactionSelfTest.class);
suite.addTestSuite(IgniteSlowClientDetectionSelfTest.class);
- suite.addTestSuite(IgniteDaemonNodeMarshallerCacheTest.class);
+ GridTestUtils.addTestIfNeeded(suite, IgniteDaemonNodeMarshallerCacheTest.class, ignoredTests);
suite.addTestSuite(IgniteMarshallerCacheConcurrentReadWriteTest.class);
suite.addTestSuite(IgniteExceptionInNioWorkerSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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
new file mode 100644
index 0000000..cbb87fa
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryBasicTestSuite.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import java.util.HashSet;
+import java.util.Set;
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.ClusterGroupSelfTest;
+import org.apache.ignite.internal.GridReleaseTypeSelfTest;
+import org.apache.ignite.internal.GridVersionSelfTest;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.managers.deployment.GridDeploymentMessageCountSelfTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingNearErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingRebalanceErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingTxErrorTest;
+import org.apache.ignite.internal.processors.cache.IgniteDaemonNodeMarshallerCacheTest;
+import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
+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.jdk.GridJdkMarshallerSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerEnumSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerNodeFailoverTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerSerialPersistentFieldsSelfTest;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshallerTest;
+import org.apache.ignite.marshaller.optimized.OptimizedObjectStreamSelfTest;
+import org.apache.ignite.messaging.GridMessagingNoPeerClassLoadingSelfTest;
+import org.apache.ignite.messaging.GridMessagingSelfTest;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Basic test suite.
+ */
+public class IgniteBinaryBasicTestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+ TestSuite suite = new TestSuite("GridGain Binary Basic Test Suite");
+
+ Set<Class> ignoredTests = new HashSet<>();
+
+ // Tests that are not ready to be used with PortableMarshaller
+ ignoredTests.add(GridJdkMarshallerSelfTest.class);
+ ignoredTests.add(OptimizedMarshallerEnumSelfTest.class);
+ ignoredTests.add(OptimizedMarshallerSelfTest.class);
+ ignoredTests.add(OptimizedMarshallerTest.class);
+ ignoredTests.add(OptimizedObjectStreamSelfTest.class);
+ ignoredTests.add(GridUnsafeDataOutputArraySizingSelfTest.class);
+ ignoredTests.add(OptimizedMarshallerNodeFailoverTest.class);
+ ignoredTests.add(OptimizedMarshallerSerialPersistentFieldsSelfTest.class);
+ ignoredTests.add(GridNioSslSelfTest.class);
+ ignoredTests.add(GridNioSelfTest.class);
+ ignoredTests.add(IgniteCacheP2pUnmarshallingErrorTest.class);
+ ignoredTests.add(IgniteCacheP2pUnmarshallingTxErrorTest.class);
+ ignoredTests.add(IgniteCacheP2pUnmarshallingNearErrorTest.class);
+ ignoredTests.add(IgniteCacheP2pUnmarshallingRebalanceErrorTest.class);
+ ignoredTests.add(GridReleaseTypeSelfTest.class);
+ ignoredTests.add(GridStartupWithSpecifiedWorkDirectorySelfTest.class);
+ ignoredTests.add(IgniteUtilsSelfTest.class);
+ ignoredTests.add(ClusterGroupSelfTest.class);
+ ignoredTests.add(GridMessagingNoPeerClassLoadingSelfTest.class);
+ ignoredTests.add(GridMessagingSelfTest.class);
+ ignoredTests.add(GridVersionSelfTest.class);
+ ignoredTests.add(GridDeploymentMessageCountSelfTest.class);
+
+ // TODO: check and delete if pass.
+ ignoredTests.add(IgniteDaemonNodeMarshallerCacheTest.class);
+
+ suite.addTest(IgniteBasicTestSuite.suite(ignoredTests));
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
new file mode 100644
index 0000000..d3ea755
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ *
+ */
+public class IgniteBinaryObjectsSimpleNameMapperComputeGridTestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception If failed.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+ return IgniteComputeGridTestSuite.suite();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 9651f6d..5eb7b66 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
@@ -18,6 +18,9 @@
package org.apache.ignite.testsuites;
import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryBasicIdMapperSelfTest;
+import org.apache.ignite.internal.binary.BinaryBasicNameMapperSelfTest;
+import org.apache.ignite.internal.binary.BinaryConfigurationConsistencySelfTest;
import org.apache.ignite.internal.binary.BinaryEnumsSelfTest;
import org.apache.ignite.internal.binary.BinaryFieldsHeapSelfTest;
import org.apache.ignite.internal.binary.BinaryFieldsOffheapSelfTest;
@@ -25,19 +28,24 @@ import org.apache.ignite.internal.binary.BinaryFooterOffsetsHeapSelfTest;
import org.apache.ignite.internal.binary.BinaryFooterOffsetsOffheapSelfTest;
import org.apache.ignite.internal.binary.BinaryMarshallerSelfTest;
import org.apache.ignite.internal.binary.BinaryObjectBuilderAdditionalSelfTest;
-import org.apache.ignite.internal.binary.BinaryObjectBuilderSelfTest;
+import org.apache.ignite.internal.binary.BinaryObjectBuilderDefaultMappersSelfTest;
+import org.apache.ignite.internal.binary.BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest;
+import org.apache.ignite.internal.binary.BinarySimpleNameTestPropertySelfTest;
import org.apache.ignite.internal.binary.GridBinaryAffinityKeySelfTest;
import org.apache.ignite.internal.binary.GridBinaryMarshallerCtxDisabledSelfTest;
-import org.apache.ignite.internal.binary.GridBinaryMetaDataSelfTest;
import org.apache.ignite.internal.binary.GridBinaryWildcardsSelfTest;
+import org.apache.ignite.internal.binary.GridDefaultBinaryMappersBinaryMetaDataSelfTest;
+import org.apache.ignite.internal.binary.GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryFieldsHeapNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryFieldsOffheapNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsHeapNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryFooterOffsetsOffheapNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryMarshallerNonCompactSelfTest;
import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderAdditionalNonCompactSelfTest;
-import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactSelfTest;
-import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSelfTest;
+import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompactDefaultMappersSelfTest;
+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.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataMultinodeTest;
import org.apache.ignite.internal.processors.cache.binary.GridCacheClientNodeBinaryObjectMetadataTest;
@@ -68,22 +76,31 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite("Ignite Binary Objects Test Suite");
+ suite.addTestSuite(BinarySimpleNameTestPropertySelfTest.class);
+
+ suite.addTestSuite(BinaryBasicIdMapperSelfTest.class);
+ suite.addTestSuite(BinaryBasicNameMapperSelfTest.class);
+
suite.addTestSuite(BinaryMarshallerSelfTest.class);
+ suite.addTestSuite(BinaryConfigurationConsistencySelfTest.class);
suite.addTestSuite(GridBinaryMarshallerCtxDisabledSelfTest.class);
- suite.addTestSuite(BinaryObjectBuilderSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderDefaultMappersSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.class);
suite.addTestSuite(BinaryObjectBuilderAdditionalSelfTest.class);
suite.addTestSuite(BinaryFieldsHeapSelfTest.class);
suite.addTestSuite(BinaryFieldsOffheapSelfTest.class);
suite.addTestSuite(BinaryFooterOffsetsHeapSelfTest.class);
suite.addTestSuite(BinaryFooterOffsetsOffheapSelfTest.class);
suite.addTestSuite(BinaryEnumsSelfTest.class);
- suite.addTestSuite(GridBinaryMetaDataSelfTest.class);
+ suite.addTestSuite(GridDefaultBinaryMappersBinaryMetaDataSelfTest.class);
+ suite.addTestSuite(GridSimpleLowerCaseBinaryMappersBinaryMetaDataSelfTest.class);
suite.addTestSuite(GridBinaryAffinityKeySelfTest.class);
suite.addTestSuite(GridBinaryWildcardsSelfTest.class);
// Tests for objects with non-compact footers.
suite.addTestSuite(BinaryMarshallerNonCompactSelfTest.class);
- suite.addTestSuite(BinaryObjectBuilderNonCompactSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderNonCompactDefaultMappersSelfTest.class);
+ suite.addTestSuite(BinaryObjectBuilderNonCompactSimpleNameLowerCaseMappersSelfTest.class);
suite.addTestSuite(BinaryObjectBuilderAdditionalNonCompactSelfTest.class);
suite.addTestSuite(BinaryFieldsHeapNonCompactSelfTest.class);
suite.addTestSuite(BinaryFieldsOffheapNonCompactSelfTest.class);
@@ -105,7 +122,8 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
suite.addTestSuite(GridCacheBinaryObjectsPartitionedNearDisabledOffheapTieredSelfTest.class);
suite.addTestSuite(GridCacheBinaryStoreObjectsSelfTest.class);
- suite.addTestSuite(GridCacheBinaryStoreBinariesSelfTest.class);
+ suite.addTestSuite(GridCacheBinaryStoreBinariesDefaultMappersSelfTest.class);
+ suite.addTestSuite(GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest.class);
suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataTest.class);
suite.addTestSuite(GridCacheClientNodeBinaryObjectMetadataMultinodeTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
new file mode 100644
index 0000000..77020bd
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperBasicTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Basic test suite.
+ */
+public class IgniteBinarySimpleNameMapperBasicTestSuite extends TestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+ return IgniteBinaryBasicTestSuite.suite();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
new file mode 100644
index 0000000..bbf4297
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheFullApiTestSuite.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Cache full API suite with binary marshaller and simple name mapper.
+ */
+public class IgniteBinarySimpleNameMapperCacheFullApiTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception In case of error.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+ return IgniteCacheFullApiSelfTestSuite.suite();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
index 3bab1f9..89ead35 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite.java
@@ -21,90 +21,10 @@ import junit.framework.TestSuite;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.processors.cache.BinarySerializationQuerySelfTest;
import org.apache.ignite.internal.processors.cache.BinarySerializationQueryWithReflectiveSerializerSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheLocalQueryMetricsSelfTest;
-import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsDistributedSelfTest;
-import org.apache.ignite.internal.processors.cache.CachePartitionedQueryMetricsLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsDistributedSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheReplicatedQueryMetricsLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.CacheScanPartitionQueryFallbackSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheCrossCacheQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryIndexingDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQueryInternalKeysSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheQuerySerializationSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheReduceQueryMultithreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteBinaryObjectFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteBinaryWrappedObjectFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.IgniteCacheBinaryObjectsScanSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheCollocatedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheDuplicateEntityConfigurationSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheFieldsQueryNoDataSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheLargeResultSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheNoClassQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapEvictQueryTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapTieredMultithreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheP2pUnmarshallingQueryErrorTest;
-import org.apache.ignite.internal.processors.cache.IgniteCachePartitionedQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryEvictsMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryIndexSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryLoadSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedOffHeapTieredSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheQueryOffheapMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.IgniteCacheSqlQueryMultiThreadedSelfTest;
-import org.apache.ignite.internal.processors.cache.SqlFieldsQuerySelfTest;
import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest;
import org.apache.ignite.internal.processors.cache.binary.distributed.dht.GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicNearEnabledQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheAtomicQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheClientQueryReplicatedNodeRestartSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQueryP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCachePartitionedSnapshotEnabledQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.IgniteCacheQueryNodeRestartSelfTest2;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQueryP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.replicated.IgniteCacheReplicatedQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalAtomicQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.local.IgniteCacheLocalQuerySelfTest;
import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryLostPartitionTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverAtomicReplicatedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxReplicatedSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.CacheContinuousQueryFailoverTxSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicNearEnabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicP2PDisabledSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryLocalSelfTest;
-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.GridCacheContinuousQueryReplicatedAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.GridCacheContinuousQueryReplicatedOneNodeSelfTest;
-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;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientReconnectTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTest;
-import org.apache.ignite.internal.processors.cache.query.continuous.IgniteCacheContinuousQueryClientTxReconnectTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryAtomicSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryLocalSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryPartitionedSelfTest;
-import org.apache.ignite.internal.processors.cache.reducefields.GridCacheReduceFieldsQueryReplicatedSelfTest;
-import org.apache.ignite.internal.processors.query.IgniteSqlSplitterSelfTest;
-import org.apache.ignite.internal.processors.query.h2.sql.BaseH2CompareQueryTest;
-import org.apache.ignite.internal.processors.query.h2.sql.GridQueryParsingTest;
-import org.apache.ignite.internal.processors.query.h2.sql.H2CompareBigQueryTest;
-import org.apache.ignite.spi.communication.tcp.GridOrderedMessageCancelSelfTest;
import org.apache.ignite.testframework.config.GridTestProperties;
/**
@@ -118,122 +38,24 @@ public class IgniteBinaryCacheQueryTestSuite extends TestSuite {
public static TestSuite suite() throws Exception {
GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
- TestSuite suite = new TestSuite("Grid Cache Query Test Suite using BinaryMarshaller");
+ TestSuite suite = IgniteCacheQuerySelfTestSuite.suite();
// Serialization.
suite.addTestSuite(BinarySerializationQuerySelfTest.class);
suite.addTestSuite(BinarySerializationQueryWithReflectiveSerializerSelfTest.class);
- // Parsing.
- suite.addTestSuite(GridQueryParsingTest.class);
-
- // Config.
- suite.addTestSuite(IgniteCacheDuplicateEntityConfigurationSelfTest.class);
-
- // Queries tests.
- suite.addTestSuite(IgniteSqlSplitterSelfTest.class);
- suite.addTestSuite(GridCacheQueryIndexDisabledSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryLoadSelfTest.class);
- suite.addTestSuite(IgniteCacheLocalQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheLocalAtomicQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheReplicatedQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheReplicatedQueryP2PDisabledSelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedQuerySelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedSnapshotEnabledQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheAtomicQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheAtomicNearEnabledQuerySelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedQueryP2PDisabledSelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedQueryMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryIndexSelfTest.class);
- suite.addTestSuite(IgniteCacheCollocatedQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheLargeResultSelfTest.class);
- suite.addTestSuite(GridCacheQueryInternalKeysSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryMultiThreadedOffHeapTieredSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryEvictsMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryOffheapMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryOffheapEvictsMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheOffheapEvictQueryTest.class);
- suite.addTestSuite(IgniteCacheSqlQueryMultiThreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheOffheapTieredMultithreadedSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest.class);
- suite.addTestSuite(IgniteCacheQueryNodeRestartSelfTest2.class);
- suite.addTestSuite(IgniteCacheClientQueryReplicatedNodeRestartSelfTest.class);
- suite.addTestSuite(GridCacheReduceQueryMultithreadedSelfTest.class);
- suite.addTestSuite(GridCacheCrossCacheQuerySelfTest.class);
- suite.addTestSuite(GridCacheQuerySerializationSelfTest.class);
suite.addTestSuite(IgniteCacheBinaryObjectsScanSelfTest.class);
- suite.addTestSuite(IgniteBinaryObjectFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteBinaryWrappedObjectFieldsQuerySelfTest.class);
-
- // Scan queries.
- suite.addTestSuite(CacheScanPartitionQueryFallbackSelfTest.class);
-
- // Fields queries.
- suite.addTestSuite(SqlFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheLocalFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheReplicatedFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheReplicatedFieldsQueryP2PEnabledSelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheAtomicFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCacheAtomicNearEnabledFieldsQuerySelfTest.class);
- suite.addTestSuite(IgniteCachePartitionedFieldsQueryP2PEnabledSelfTest.class);
- suite.addTestSuite(IgniteCacheFieldsQueryNoDataSelfTest.class);
-
- // Continuous queries.
- suite.addTestSuite(GridCacheContinuousQueryLocalSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryLocalAtomicSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryReplicatedSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryReplicatedAtomicSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryReplicatedP2PDisabledSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryPartitionedSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryPartitionedOnlySelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryPartitionedP2PDisabledSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryTxSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryAtomicSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryAtomicNearEnabledSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryAtomicP2PDisabledSelfTest.class);
- suite.addTestSuite(GridCacheContinuousQueryReplicatedOneNodeSelfTest.class);
- suite.addTestSuite(IgniteCacheContinuousQueryClientTest.class);
- suite.addTestSuite(IgniteCacheContinuousQueryClientReconnectTest.class);
- suite.addTestSuite(IgniteCacheContinuousQueryClientTxReconnectTest.class);
- suite.addTestSuite(CacheContinuousQueryFailoverAtomicPrimaryWriteOrderSelfTest.class);
- suite.addTestSuite(CacheContinuousQueryFailoverAtomicReplicatedSelfTest.class);
- suite.addTestSuite(CacheContinuousQueryFailoverTxSelfTest.class);
- suite.addTestSuite(CacheContinuousQueryFailoverTxReplicatedSelfTest.class);
suite.addTestSuite(CacheContinuousQueryLostPartitionTest.class);
- // Reduce fields queries.
- suite.addTestSuite(GridCacheReduceFieldsQueryLocalSelfTest.class);
- suite.addTestSuite(GridCacheReduceFieldsQueryPartitionedSelfTest.class);
- suite.addTestSuite(GridCacheReduceFieldsQueryAtomicSelfTest.class);
- suite.addTestSuite(GridCacheReduceFieldsQueryReplicatedSelfTest.class);
-
- suite.addTestSuite(GridCacheQueryIndexingDisabledSelfTest.class);
-
//Should be adjusted. Not ready to be used with BinaryMarshaller.
//suite.addTestSuite(GridCacheBinarySwapScanQuerySelfTest.class);
- suite.addTestSuite(GridOrderedMessageCancelSelfTest.class);
-
- // Ignite cache and H2 comparison.
- suite.addTestSuite(BaseH2CompareQueryTest.class);
- suite.addTestSuite(H2CompareBigQueryTest.class);
-
- // Metrics tests
- suite.addTestSuite(CacheLocalQueryMetricsSelfTest.class);
- suite.addTestSuite(CachePartitionedQueryMetricsDistributedSelfTest.class);
- suite.addTestSuite(CachePartitionedQueryMetricsLocalSelfTest.class);
- suite.addTestSuite(CacheReplicatedQueryMetricsDistributedSelfTest.class);
- suite.addTestSuite(CacheReplicatedQueryMetricsLocalSelfTest.class);
-
- //Unmarshallig query test.
- suite.addTestSuite(IgniteCacheP2pUnmarshallingQueryErrorTest.class);
- suite.addTestSuite(IgniteCacheNoClassQuerySelfTest.class);
-
suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedAtomicSelfTest.class);
suite.addTestSuite(GridCacheBinaryDuplicateIndexObjectPartitionedTransactionalSelfTest.class);
+ //TODO: the following tests= was never tested with binary. Exclude or pass?
+// suite.addTestSuite(IgniteSqlSchemaIndexingTest.class);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
new file mode 100644
index 0000000..3eed980
--- /dev/null
+++ b/modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinarySimpleNameMapperCacheQueryTestSuite.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.testsuites;
+
+import junit.framework.TestSuite;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.testframework.config.GridTestProperties;
+
+/**
+ * Cache query suite with binary marshaller.
+ */
+public class IgniteBinarySimpleNameMapperCacheQueryTestSuite extends TestSuite {
+ /**
+ * @return Suite.
+ * @throws Exception In case of error.
+ */
+ public static TestSuite suite() throws Exception {
+ GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+ GridTestProperties.setProperty(GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+ return IgniteBinaryCacheQueryTestSuite.suite();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
index 434f468..ef29a89 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid2.xml
@@ -45,6 +45,27 @@
</list>
</property>
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+ <property name="compactFooter" value="false"/>
+ <property name="typeConfigurations">
+ <list>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeEnum" />
+ <property name="enum" value="true" />
+ </bean>
+ </list>
+ </property>
+
+ </bean>
+ </property>
+
<property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="ipFinder">
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
index 31ccdf0..d1c96b6 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Config/Compute/compute-grid3.xml
@@ -25,14 +25,35 @@
<property name="localHost" value="127.0.0.1"/>
<property name="connectorConfiguration"><null/></property>
- <property name="clientMode" value="true"/>
+ <property name="clientMode" value="true"/>
- <property name="gridName" value="grid3"/>
+ <property name="gridName" value="grid3"/>
- <property name="metricsUpdateFrequency" value="1000"/>
- <property name="metricsLogFrequency" value="0"/>
+ <property name="metricsUpdateFrequency" value="1000"/>
+ <property name="metricsLogFrequency" value="0"/>
- <property name="discoverySpi">
+ <property name="binaryConfiguration">
+ <bean class="org.apache.ignite.configuration.BinaryConfiguration">
+ <property name="compactFooter" value="false"/>
+ <property name="typeConfigurations">
+ <list>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeJavaBinarizable"/>
+ </bean>
+ <bean class="org.apache.ignite.binary.BinaryTypeConfiguration">
+ <property name="typeName" value="org.apache.ignite.platform.PlatformComputeEnum" />
+ <property name="enum" value="true" />
+ </bean>
+ </list>
+ </property>
+
+ </bean>
+ </property>
+
+ <property name="discoverySpi">
<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
<property name="forceServerMode" value="true"/>
[06/16] ignite git commit: IGNITE-2191 - Support classes with the
same simple name for Binary marshaller - Fixes #398.
Posted by sb...@apache.org.
IGNITE-2191 - Support classes with the same simple name for Binary marshaller - Fixes #398.
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/62502b2c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/62502b2c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/62502b2c
Branch: refs/heads/ignite-2407
Commit: 62502b2c44d7d35584b31c8f1284b810840f9a8d
Parents: 58dce88
Author: ashutak <as...@gridgain.com>
Authored: Mon Feb 1 18:12:03 2016 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Mon Feb 1 18:12:03 2016 +0300
----------------------------------------------------------------------
.../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 +-
.../configuration/BinaryConfiguration.java | 28 +
.../configuration/IgniteConfiguration.java | 8 +-
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../internal/binary/BinaryClassDescriptor.java | 23 +-
.../ignite/internal/binary/BinaryContext.java | 347 ++++--
.../internal/binary/BinaryEnumObjectImpl.java | 11 +-
.../internal/binary/BinaryInternalIdMapper.java | 161 ---
.../internal/binary/BinaryInternalMapper.java | 131 ++
.../binary/BinaryMetadataCollector.java | 22 +-
.../internal/binary/BinaryReaderExImpl.java | 14 +-
.../internal/binary/BinaryWriterExImpl.java | 30 +-
.../binary/builder/BinaryBuilderSerializer.java | 16 +-
.../binary/builder/BinaryObjectBuilderImpl.java | 2 +-
.../binary/CacheObjectBinaryProcessorImpl.java | 123 +-
.../cpp/PlatformCppConfigurationClosure.java | 32 +
.../PlatformDotNetConfigurationClosure.java | 34 +-
.../binary/BinaryBasicIdMapperSelfTest.java | 51 +
.../binary/BinaryBasicNameMapperSelfTest.java | 50 +
.../BinaryConfigurationConsistencySelfTest.java | 231 ++++
.../internal/binary/BinaryEnumsSelfTest.java | 12 +-
.../binary/BinaryMarshallerSelfTest.java | 508 ++++++--
.../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 +
...BuilderNonCompactDefaultMappersSelfTest.java | 30 +
.../BinaryObjectBuilderNonCompactSelfTest.java | 30 -
...mpactSimpleNameLowerCaseMappersSelfTest.java | 31 +
.../GridCacheConditionalDeploymentSelfTest.java | 4 +-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 17 +-
.../GridCacheBinaryStoreAbstractSelfTest.java | 10 +
...naryStoreBinariesDefaultMappersSelfTest.java | 81 ++
.../GridCacheBinaryStoreBinariesSelfTest.java | 66 -
...yStoreBinariesSimpleNameMappersSelfTest.java | 40 +
.../config/GridTestProperties.java | 5 +-
.../testframework/junits/GridAbstractTest.java | 23 +-
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +-
.../testsuites/IgniteBinaryBasicTestSuite.java | 95 ++
...ctsSimpleNameMapperComputeGridTestSuite.java | 38 +
.../IgniteBinaryObjectsTestSuite.java | 34 +-
...iteBinarySimpleNameMapperBasicTestSuite.java | 38 +
...rySimpleNameMapperCacheFullApiTestSuite.java | 39 +
.../IgniteBinaryCacheQueryTestSuite.java | 186 +--
...narySimpleNameMapperCacheQueryTestSuite.java | 38 +
.../Config/Compute/compute-grid2.xml | 21 +
.../Config/Compute/compute-grid3.xml | 31 +-
.../org/apache/ignite/yardstick/IgniteNode.java | 3 +
58 files changed, 4381 insertions(+), 2275 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
new file mode 100644
index 0000000..da31751
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicIdMapper.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.binary;
+
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Base binary ID mapper implementation.
+ */
+public class BinaryBasicIdMapper implements BinaryIdMapper {
+ /** Default lower case flag setting. */
+ public static final boolean DFLT_LOWER_CASE = true;
+
+ /** Maximum lower-case character. */
+ private static final char MAX_LOWER_CASE_CHAR = 0x7e;
+
+ /** Cached lower-case characters. */
+ private static final char[] LOWER_CASE_CHARS;
+
+ /** */
+ private boolean isLowerCase = DFLT_LOWER_CASE;
+
+ /**
+ * Static initializer.
+ */
+ static {
+ LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
+
+ for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
+ LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
+ }
+
+ /**
+ * Default constructor.
+ */
+ public BinaryBasicIdMapper() {
+ }
+
+ /**
+ * @param isLowerCase Whether to use strings in lower case or not.
+ * <p>
+ * Defaults to {@link #DFLT_LOWER_CASE}.
+ */
+ public BinaryBasicIdMapper(boolean isLowerCase) {
+ this.isLowerCase = isLowerCase;
+ }
+
+ /**
+ * Get type ID.
+ *
+ * @param typeName Type name.
+ * @return Type ID.
+ */
+ public int typeId(String typeName) {
+ A.notNull(typeName, "typeName");
+
+ int id = isLowerCase ? lowerCaseHashCode(typeName) : typeName.hashCode();
+
+ if (id != 0)
+ return id;
+ else {
+ throw new BinaryObjectException("Binary ID mapper resolved type ID to zero " +
+ "(either change type's name or use custom ID mapper) " +
+ "[name=" + typeName + ", isLowerCase=" + isLowerCase + "]");
+ }
+ }
+
+ /**
+ * Get field ID.
+ *
+ * @param typeId Type ID.
+ * @param fieldName Field name.
+ * @return Field ID.
+ */
+ public int fieldId(int typeId, String fieldName) {
+ A.notNull(fieldName, "fieldName");
+
+ int id = isLowerCase ? lowerCaseHashCode(fieldName) : fieldName.hashCode();
+
+ if (id != 0)
+ return id;
+ else {
+ throw new BinaryObjectException("Binary ID mapper resolved field ID to zero " +
+ "(either change filed's name or use custom ID mapper) " +
+ "[name=" + fieldName + ", isLowerCase=" + isLowerCase + "]");
+ }
+ }
+
+ /**
+ * Gets whether to use strings in lower case or not.
+ *
+ * @return Whether to use strings in lower case or not.
+ */
+ public boolean isLowerCase() {
+ return isLowerCase;
+ }
+
+ /**
+ * Sets whether to use strings in lower case or not.
+ *
+ * @param isLowerCase Whether to use strings in lower case or not.
+ */
+ public void setLowerCase(boolean isLowerCase) {
+ this.isLowerCase = isLowerCase;
+ }
+
+ /**
+ * Routine to calculate string hash code an
+ *
+ * @param str String.
+ * @return Hash code for given string converted to lower case.
+ */
+ private static int lowerCaseHashCode(String str) {
+ int len = str.length();
+
+ int h = 0;
+
+ for (int i = 0; i < len; i++) {
+ int c = str.charAt(i);
+
+ c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
+
+ h = 31 * h + c;
+ }
+
+ return h;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof BinaryBasicIdMapper))
+ return false;
+
+ BinaryBasicIdMapper mapper = (BinaryBasicIdMapper)o;
+
+ return isLowerCase == mapper.isLowerCase;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return (isLowerCase ? 1 : 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "BinaryBaseIdMapper [isLowerCase=" + isLowerCase + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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
new file mode 100644
index 0000000..62420f7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryBasicNameMapper.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.binary;
+
+import org.apache.ignite.internal.util.typedef.internal.A;
+
+/**
+ * Base binary name mapper implementation.
+ */
+public class BinaryBasicNameMapper implements BinaryNameMapper {
+ /** Default use simple name flag setting. */
+ public static final boolean DFLT_SIMPLE_NAME = false;
+
+ /** */
+ private boolean isSimpleName = DFLT_SIMPLE_NAME;
+
+ /**
+ * Default constructor.
+ */
+ public BinaryBasicNameMapper() {
+ // No-op.
+ }
+
+ /**
+ * @param isSimpleName Whether to use simple name of class or not.
+ * <p>
+ * Defaults to {@link #DFLT_SIMPLE_NAME}.
+ */
+ public BinaryBasicNameMapper(boolean isSimpleName) {
+ this.isSimpleName = isSimpleName;
+ }
+
+ /**
+ * Gets whether to use simple name of class or not.
+ *
+ * @return Whether to use simple name of class or not.
+ */
+ public boolean isSimpleName() {
+ return isSimpleName;
+ }
+
+ /**
+ * Sets whether to use simple name of class or not.
+ *
+ * @param isSimpleName Whether to use simple name of class or not.
+ */
+ public void setLowerCase(boolean isSimpleName) {
+ this.isSimpleName = isSimpleName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String typeName(String clsName) {
+ A.notNull(clsName, "clsName");
+
+ return isSimpleName ? simpleName(clsName) : clsName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String fieldName(String fieldName) {
+ A.notNull(fieldName, "fieldName");
+
+ return fieldName;
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type name.
+ */
+ private static String simpleName(String clsName) {
+ assert clsName != null;
+
+ int idx = clsName.lastIndexOf('$');
+
+ if (idx == clsName.length() - 1)
+ // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
+ idx = -1;
+ else if (idx >= 0) {
+ String typeName = clsName.substring(idx + 1);
+
+ try {
+ Integer.parseInt(typeName);
+
+ // This is an anonymous class. Don't cut off enclosing class name for it.
+ idx = -1;
+ }
+ catch (NumberFormatException ignore) {
+ // This is a lambda class.
+ if (clsName.indexOf("$$Lambda$") > 0)
+ idx = -1;
+ else
+ return typeName;
+ }
+ }
+
+ if (idx < 0)
+ idx = clsName.lastIndexOf('.');
+
+ return idx >= 0 ? clsName.substring(idx + 1) : clsName;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof BinaryBasicNameMapper))
+ return false;
+
+ BinaryBasicNameMapper mapper = (BinaryBasicNameMapper)o;
+
+ if (isSimpleName != mapper.isSimpleName)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return (isSimpleName ? 1 : 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "BinaryBaseNameMapper [isSimpleName=" + isSimpleName + ']';
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
index 4c31140..dac5c44 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryIdMapper.java
@@ -30,26 +30,29 @@ package org.apache.ignite.binary;
* Binary ID mapper can be configured for all binary objects via
* {@link org.apache.ignite.configuration.BinaryConfiguration#getIdMapper()} method,
* or for a specific binary type via {@link BinaryTypeConfiguration#getIdMapper()} method.
+ * @see BinaryNameMapper
*/
public interface BinaryIdMapper {
/**
- * Gets type ID for provided class name.
+ * Gets type ID for provided type name.
* <p>
* If {@code 0} is returned, hash code of class simple name will be used.
*
- * @param clsName Class name.
+ * @param typeName Type name. Type name is a result of {@link BinaryNameMapper#typeName(String)} call for an
+ * initial class or type name.
* @return Type ID.
+ * @see BinaryNameMapper#typeName(String)
*/
- public int typeId(String clsName);
+ public int typeId(String typeName);
/**
- * Gets ID for provided field.
- * <p>
- * If {@code 0} is returned, hash code of field name will be used.
+ * Gets ID for provided field name. <p> If {@code 0} is returned, hash code of field name will be used.
*
* @param typeId Type ID.
- * @param fieldName Field name.
+ * @param fieldName Field name. Filed anme is a result of {@link BinaryNameMapper#fieldName(String)} call for an
+ * initial filed name.
* @return Field ID.
+ * @see BinaryNameMapper#fieldName(String)
*/
public int fieldId(int typeId, String fieldName);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.java
new file mode 100644
index 0000000..2db0aeb
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryNameMapper.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.binary;
+
+import org.apache.ignite.configuration.BinaryConfiguration;
+
+/**
+ * Maps type and field names to different names. Prepares class/type names
+ * and field names before pass them to {@link BinaryIdMapper}.
+ * <p>
+ * Binary name mapper can be configured for all binary objects via
+ * {@link BinaryConfiguration#getNameMapper()} method,
+ * or for a specific binary type via {@link BinaryTypeConfiguration#getNameMapper()} method.
+ * @see BinaryIdMapper
+ */
+public interface BinaryNameMapper {
+ /**
+ * Gets type clsName.
+ *
+ * @param clsName Class came
+ * @return Type name.
+ */
+ String typeName(String clsName);
+
+ /**
+ * Gets field name.
+ *
+ * @param fieldName Field name.
+ * @return Field name.
+ */
+ String fieldName(String fieldName);
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
index a00c061..fea0af7 100644
--- a/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/binary/BinaryTypeConfiguration.java
@@ -36,6 +36,9 @@ public class BinaryTypeConfiguration {
/** ID mapper. */
private BinaryIdMapper idMapper;
+ /** Name mapper. */
+ private BinaryNameMapper nameMapper;
+
/** Serializer. */
private BinarySerializer serializer;
@@ -107,6 +110,24 @@ public class BinaryTypeConfiguration {
}
/**
+ * Gets name mapper.
+ *
+ * @return Name mapper.
+ */
+ public BinaryNameMapper getNameMapper() {
+ return nameMapper;
+ }
+
+ /**
+ * Sets name mapper.
+ *
+ * @param nameMapper Name mapper.
+ */
+ public void setNameMapper(BinaryNameMapper nameMapper) {
+ this.nameMapper = nameMapper;
+ }
+
+ /**
* Gets serializer.
*
* @return Serializer.
@@ -146,4 +167,4 @@ public class BinaryTypeConfiguration {
@Override public String toString() {
return S.toString(BinaryTypeConfiguration.class, this, super.toString());
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
index 1151245..30d77de 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/BinaryConfiguration.java
@@ -20,8 +20,10 @@ package org.apache.ignite.configuration;
import java.util.ArrayList;
import java.util.Collection;
import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.internal.util.typedef.internal.S;
/**
* Configuration object for Ignite Binary Objects.
@@ -34,6 +36,9 @@ public class BinaryConfiguration {
/** ID mapper. */
private BinaryIdMapper idMapper;
+ /** Name mapper. */
+ private BinaryNameMapper nameMapper;
+
/** Serializer. */
private BinarySerializer serializer;
@@ -75,6 +80,24 @@ public class BinaryConfiguration {
}
/**
+ * Gets name mapper.
+ *
+ * @return Name mapper.
+ */
+ public BinaryNameMapper getNameMapper() {
+ return nameMapper;
+ }
+
+ /**
+ * Sets name mapper.
+ *
+ * @param nameMapper Name mapper.
+ */
+ public void setNameMapper(BinaryNameMapper nameMapper) {
+ this.nameMapper = nameMapper;
+ }
+
+ /**
* Gets serializer.
*
* @return Serializer.
@@ -136,4 +159,9 @@ public class BinaryConfiguration {
public void setCompactFooter(boolean compactFooter) {
this.compactFooter = compactFooter;
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryConfiguration.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index 6598dc0..f705638 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -2002,8 +2002,10 @@ public class IgniteConfiguration {
*
* @param cacheKeyCfg Cache key configuration.
*/
- public void setCacheKeyConfiguration(CacheKeyConfiguration... cacheKeyCfg) {
+ public IgniteConfiguration setCacheKeyConfiguration(CacheKeyConfiguration... cacheKeyCfg) {
this.cacheKeyCfg = cacheKeyCfg;
+
+ return this;
}
/**
@@ -2020,8 +2022,10 @@ public class IgniteConfiguration {
*
* @param binaryCfg Binary configuration object.
*/
- public void setBinaryConfiguration(BinaryConfiguration binaryCfg) {
+ public IgniteConfiguration setBinaryConfiguration(BinaryConfiguration binaryCfg) {
this.binaryCfg = binaryCfg;
+
+ return this;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 3c5f960..da6f40d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -147,6 +147,9 @@ public final class IgniteNodeAttributes {
/** Update notifier enabled. */
public static final String ATTR_UPDATE_NOTIFIER_ENABLED = ATTR_PREFIX + ".update.notifier.enabled";
+ /** Binary configuration. */
+ public static final String ATTR_BINARY_CONFIGURATION = ATTR_PREFIX + ".binary.config";
+
/**
* Enforces singleton.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 eb45ac6..233e74b 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
@@ -34,13 +34,14 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryReflectiveSerializer;
import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.Binarylizable;
import org.apache.ignite.internal.processors.cache.CacheObjectImpl;
import org.apache.ignite.internal.util.GridUnsafe;
+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 org.apache.ignite.marshaller.MarshallerExclusions;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
@@ -55,6 +56,7 @@ public class BinaryClassDescriptor {
public static final Unsafe UNSAFE = GridUnsafe.unsafe();
/** */
+ @GridToStringExclude
private final BinaryContext ctx;
/** */
@@ -64,7 +66,7 @@ public class BinaryClassDescriptor {
private final BinarySerializer serializer;
/** ID mapper. */
- private final BinaryIdMapper idMapper;
+ private final BinaryInternalMapper mapper;
/** */
private final BinaryWriteMode mode;
@@ -118,7 +120,7 @@ public class BinaryClassDescriptor {
* @param typeId Type ID.
* @param typeName Type name.
* @param affKeyFieldName Affinity key field name.
- * @param idMapper ID mapper.
+ * @param mapper Mapper.
* @param serializer Serializer.
* @param metaDataEnabled Metadata enabled flag.
* @param registered Whether typeId has been successfully registered by MarshallerContext or not.
@@ -131,14 +133,14 @@ public class BinaryClassDescriptor {
int typeId,
String typeName,
@Nullable String affKeyFieldName,
- @Nullable BinaryIdMapper idMapper,
+ @Nullable BinaryInternalMapper mapper,
@Nullable BinarySerializer serializer,
boolean metaDataEnabled,
boolean registered
) throws BinaryObjectException {
assert ctx != null;
assert cls != null;
- assert idMapper != null;
+ assert mapper != null;
// If serializer is not defined at this point, then we have to user OptimizedMarshaller.
useOptMarshaller = serializer == null;
@@ -154,7 +156,7 @@ public class BinaryClassDescriptor {
this.typeName = typeName;
this.affKeyFieldName = affKeyFieldName;
this.serializer = serializer;
- this.idMapper = idMapper;
+ this.mapper = mapper;
this.registered = registered;
schemaReg = ctx.schemaRegistry(typeId);
@@ -269,7 +271,7 @@ public class BinaryClassDescriptor {
assert added : name;
- int fieldId = idMapper.fieldId(typeId, name);
+ int fieldId = this.mapper.fieldId(typeId, name);
if (!ids.add(fieldId))
throw new BinaryObjectException("Duplicate field ID: " + name);
@@ -635,7 +637,7 @@ public class BinaryClassDescriptor {
if (schemaReg.schema(schemaId) == null) {
// This is new schema, let's update metadata.
BinaryMetadataCollector collector =
- new BinaryMetadataCollector(typeId, typeName, idMapper);
+ new BinaryMetadataCollector(typeId, typeName, mapper);
if (serializer != null)
serializer.writeBinary(obj, collector);
@@ -804,4 +806,9 @@ public class BinaryClassDescriptor {
throw new BinaryObjectException("Failed to get constructor for class: " + cls.getName(), e);
}
}
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryClassDescriptor.class, this);
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 163532d..cf19bdf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -17,10 +17,39 @@
package org.apache.ignite.internal.binary;
+import java.io.Externalizable;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentMap;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryInvalidTypeException;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryReflectiveSerializer;
import org.apache.ignite.binary.BinarySerializer;
@@ -31,7 +60,6 @@ import org.apache.ignite.cache.affinity.AffinityKey;
import org.apache.ignite.cache.affinity.AffinityKeyMapped;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgnitionEx;
import org.apache.ignite.internal.processors.cache.binary.BinaryMetadataKey;
import org.apache.ignite.internal.processors.datastructures.CollocatedQueueItemKey;
import org.apache.ignite.internal.processors.datastructures.CollocatedSetItemKey;
@@ -46,32 +74,6 @@ import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
-import java.io.Externalizable;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.math.BigDecimal;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentMap;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
/**
* Binary context.
*/
@@ -80,6 +82,14 @@ public class BinaryContext {
private static final ClassLoader dfltLdr = U.gridClassLoader();
/** */
+ private static final BinaryInternalMapper DFLT_MAPPER =
+ new BinaryInternalMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(true), false);
+
+ /** */
+ static final BinaryInternalMapper SIMPLE_NAME_LOWER_CASE_MAPPER =
+ new BinaryInternalMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true), false);
+
+ /** */
private final ConcurrentMap<Class<?>, BinaryClassDescriptor> descByCls = new ConcurrentHashMap8<>();
/** Holds classes loaded by default class loader only. */
@@ -97,14 +107,14 @@ public class BinaryContext {
/** */
private final Map<Class<? extends Map>, Byte> mapTypes = new HashMap<>();
- /** */
- private final ConcurrentMap<Integer, BinaryIdMapper> mappers = new ConcurrentHashMap8<>(0);
+ /** Maps typeId to mappers. */
+ private final ConcurrentMap<Integer, BinaryInternalMapper> typeId2Mapper = new ConcurrentHashMap8<>(0);
/** Affinity key field names. */
private final ConcurrentMap<Integer, String> affKeyFieldNames = new ConcurrentHashMap8<>(0);
- /** */
- private final Map<String, BinaryIdMapper> typeMappers = new ConcurrentHashMap8<>(0);
+ /** Maps className to mapper */
+ private final ConcurrentMap<String, BinaryInternalMapper> cls2Mappers = new ConcurrentHashMap8<>(0);
/** */
private BinaryMetadataHandler metaHnd;
@@ -271,6 +281,7 @@ public class BinaryContext {
optmMarsh.setContext(marshCtx);
configure(
+ binaryCfg.getNameMapper(),
binaryCfg.getIdMapper(),
binaryCfg.getSerializer(),
binaryCfg.getTypeConfigurations()
@@ -286,6 +297,7 @@ public class BinaryContext {
* @throws BinaryObjectException In case of error.
*/
private void configure(
+ BinaryNameMapper globalNameMapper,
BinaryIdMapper globalIdMapper,
BinarySerializer globalSerializer,
Collection<BinaryTypeConfiguration> typeCfgs
@@ -306,13 +318,20 @@ public class BinaryContext {
if (clsName == null)
throw new BinaryObjectException("Class name is required for binary type configuration.");
+ // Resolve mapper.
BinaryIdMapper idMapper = globalIdMapper;
if (typeCfg.getIdMapper() != null)
idMapper = typeCfg.getIdMapper();
- idMapper = BinaryInternalIdMapper.create(idMapper);
+ BinaryNameMapper nameMapper = globalNameMapper;
+
+ if (typeCfg.getNameMapper() != null)
+ nameMapper = typeCfg.getNameMapper();
+
+ BinaryInternalMapper mapper = resolveMapper(nameMapper, idMapper);
+ // Resolve serializer.
BinarySerializer serializer = globalSerializer;
if (typeCfg.getSerializer() != null)
@@ -322,25 +341,25 @@ public class BinaryContext {
String pkgName = clsName.substring(0, clsName.length() - 2);
for (String clsName0 : classesInPackage(pkgName))
- descs.add(clsName0, idMapper, serializer, affFields.get(clsName0),
+ descs.add(clsName0, mapper, serializer, affFields.get(clsName0),
typeCfg.isEnum(), true);
}
else
- descs.add(clsName, idMapper, serializer, affFields.get(clsName),
+ descs.add(clsName, mapper, serializer, affFields.get(clsName),
typeCfg.isEnum(), false);
}
}
for (TypeDescriptor desc : descs.descriptors())
- registerUserType(desc.clsName, desc.idMapper, desc.serializer, desc.affKeyFieldName, desc.isEnum);
+ registerUserType(desc.clsName, desc.mapper, desc.serializer, desc.affKeyFieldName, desc.isEnum);
- BinaryInternalIdMapper dfltMapper = BinaryInternalIdMapper.create(globalIdMapper);
+ BinaryInternalMapper globalMapper = resolveMapper(globalNameMapper, globalIdMapper);
// Put affinity field names for unconfigured types.
for (Map.Entry<String, String> entry : affFields.entrySet()) {
String typeName = entry.getKey();
- int typeId = dfltMapper.typeId(typeName);
+ int typeId = globalMapper.typeId(typeName);
affKeyFieldNames.putIfAbsent(typeId, entry.getValue());
}
@@ -350,6 +369,52 @@ public class BinaryContext {
}
/**
+ * @param nameMapper Name mapper.
+ * @param idMapper ID mapper.
+ * @return Mapper.
+ */
+ private static BinaryInternalMapper resolveMapper(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) {
+ if ((nameMapper == null || (DFLT_MAPPER.nameMapper().equals(nameMapper)))
+ && (idMapper == null || DFLT_MAPPER.idMapper().equals(idMapper)))
+ return DFLT_MAPPER;
+
+ if (nameMapper != null && nameMapper instanceof BinaryBasicNameMapper
+ && ((BinaryBasicNameMapper)nameMapper).isSimpleName()
+ && idMapper != null && idMapper instanceof BinaryBasicIdMapper
+ && ((BinaryBasicIdMapper)idMapper).isLowerCase())
+ return SIMPLE_NAME_LOWER_CASE_MAPPER;
+
+ if (nameMapper == null)
+ nameMapper = DFLT_MAPPER.nameMapper();
+
+ if (idMapper == null)
+ idMapper = DFLT_MAPPER.idMapper();
+
+ return new BinaryInternalMapper(nameMapper, idMapper, true);
+ }
+
+ /**
+ * @return Intenal mpper used as default.
+ */
+ public static BinaryInternalMapper defaultMapper() {
+ return DFLT_MAPPER;
+ }
+
+ /**
+ * @return ID mapper used as default.
+ */
+ public static BinaryIdMapper defaultIdMapper() {
+ return DFLT_MAPPER.idMapper();
+ }
+
+ /**
+ * @return Name mapper used as default.
+ */
+ public static BinaryNameMapper defaultNameMapper() {
+ return DFLT_MAPPER.nameMapper();
+ }
+
+ /**
* @param cls Class.
*/
private void addSystemClassAffinityKey(Class<?> cls) {
@@ -502,7 +567,8 @@ public class BinaryContext {
if (desc == null) {
desc = registerClassDescriptor(cls, deserialize);
- assert desc.typeId() == typeId;
+ assert desc.typeId() == typeId : "Duplicate typeId [typeId=" + typeId + ", cls=" + cls
+ + ", desc=" + desc + "]";
}
return desc;
@@ -526,7 +592,7 @@ public class BinaryContext {
clsName.hashCode(),
clsName,
null,
- BinaryInternalIdMapper.defaultInstance(),
+ SIMPLE_NAME_LOWER_CASE_MAPPER,
null,
false,
true /* registered */
@@ -552,11 +618,13 @@ public class BinaryContext {
private BinaryClassDescriptor registerUserClassDescriptor(Class<?> cls, boolean deserialize) {
boolean registered;
- String typeName = typeName(cls.getName());
+ final String clsName = cls.getName();
+
+ BinaryInternalMapper mapper = userTypeMapper(clsName);
- BinaryIdMapper idMapper = userTypeIdMapper(typeName);
+ final String typeName = mapper.typeName(clsName);
- int typeId = idMapper.typeId(typeName);
+ final int typeId = mapper.typeId(clsName);
try {
registered = marshCtx.registerClass(typeId, cls);
@@ -575,7 +643,7 @@ public class BinaryContext {
typeId,
typeName,
affFieldName,
- idMapper,
+ mapper,
serializer,
true,
registered
@@ -595,7 +663,7 @@ public class BinaryContext {
descByCls.put(cls, desc);
- mappers.putIfAbsent(typeId, idMapper);
+ typeId2Mapper.putIfAbsent(typeId, mapper);
return desc;
}
@@ -656,9 +724,7 @@ public class BinaryContext {
* @return Type ID.
*/
public int typeId(String typeName) {
- String typeName0 = typeName(typeName);
-
- Integer id = predefinedTypeNames.get(typeName0);
+ Integer id = predefinedTypeNames.get(SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(typeName));
if (id != null)
return id;
@@ -666,7 +732,9 @@ public class BinaryContext {
if (marshCtx.isSystemType(typeName))
return typeName.hashCode();
- return userTypeIdMapper(typeName0).typeId(typeName0);
+ BinaryInternalMapper mapper = userTypeMapper(typeName);
+
+ return mapper.typeId(typeName);
}
/**
@@ -675,27 +743,107 @@ public class BinaryContext {
* @return Field ID.
*/
public int fieldId(int typeId, String fieldName) {
- return userTypeIdMapper(typeId).fieldId(typeId, fieldName);
+ BinaryInternalMapper mapper = userTypeMapper(typeId);
+
+ return mapper.fieldId(typeId, fieldName);
}
/**
* @param typeId Type ID.
* @return Instance of ID mapper.
*/
- public BinaryIdMapper userTypeIdMapper(int typeId) {
- BinaryIdMapper idMapper = mappers.get(typeId);
+ public BinaryInternalMapper userTypeMapper(int typeId) {
+ BinaryInternalMapper mapper = typeId2Mapper.get(typeId);
- return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
+ return mapper != null ? mapper : SIMPLE_NAME_LOWER_CASE_MAPPER;
}
/**
- * @param typeName Type name.
+ * @param clsName Type name.
* @return Instance of ID mapper.
*/
- private BinaryIdMapper userTypeIdMapper(String typeName) {
- BinaryIdMapper idMapper = typeMappers.get(typeName);
+ private BinaryInternalMapper userTypeMapper(String clsName) {
+ BinaryInternalMapper mapper = cls2Mappers.get(clsName);
+
+ if (mapper != null)
+ return mapper;
+
+ mapper = resolveMapper(clsName, igniteCfg.getBinaryConfiguration());
+
+ BinaryInternalMapper prevMap = cls2Mappers.putIfAbsent(clsName, mapper);
+
+ if (prevMap != null && !mapper.equals(prevMap))
+ throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper
+ + ", prevMap=" + prevMap + "]");
+
+ prevMap = typeId2Mapper.putIfAbsent(mapper.typeId(clsName), mapper);
- return idMapper != null ? idMapper : BinaryInternalIdMapper.defaultInstance();
+ if (prevMap != null && !mapper.equals(prevMap))
+ throw new IgniteException("Different mappers [clsName=" + clsName + ", newMapper=" + mapper
+ + ", prevMap=" + prevMap + "]");
+
+ return mapper;
+ }
+
+ /**
+ * @param clsName Type name.
+ * @param cfg Binary configuration.
+ * @return Mapper according to configuration.
+ */
+ private static BinaryInternalMapper resolveMapper(String clsName, BinaryConfiguration cfg) {
+ assert clsName != null;
+
+ if (cfg == null)
+ return DFLT_MAPPER;
+
+ BinaryIdMapper globalIdMapper = cfg.getIdMapper();
+ BinaryNameMapper globalNameMapper = cfg.getNameMapper();
+
+ Collection<BinaryTypeConfiguration> typeCfgs = cfg.getTypeConfigurations();
+
+ if (typeCfgs != null) {
+ for (BinaryTypeConfiguration typeCfg : typeCfgs) {
+ String typeCfgName = typeCfg.getTypeName();
+
+ // Pattern.
+ if (typeCfgName != null && typeCfgName.endsWith(".*")) {
+ String pkgName = typeCfgName.substring(0, typeCfgName.length() - 2);
+
+ int dotIndex = clsName.lastIndexOf('.');
+
+ if (dotIndex > 0) {
+ String typePkgName = clsName.substring(0, dotIndex);
+
+ if (pkgName.equals(typePkgName)) {
+ // Resolve mapper.
+ BinaryIdMapper idMapper = globalIdMapper;
+
+ if (typeCfg.getIdMapper() != null)
+ idMapper = typeCfg.getIdMapper();
+
+ BinaryNameMapper nameMapper = globalNameMapper;
+
+ if (typeCfg.getNameMapper() != null)
+ nameMapper = typeCfg.getNameMapper();
+
+ return resolveMapper(nameMapper, idMapper);
+ }
+ }
+ }
+ }
+ }
+
+ return resolveMapper(globalNameMapper, globalIdMapper);
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type name.
+ */
+ public String userTypeName(String clsName) {
+ BinaryInternalMapper mapper = userTypeMapper(clsName);
+
+ return mapper.typeName(clsName);
}
/**
@@ -728,25 +876,25 @@ public class BinaryContext {
* @return GridBinaryClassDescriptor.
*/
public BinaryClassDescriptor registerPredefinedType(Class<?> cls, int id, String affFieldName) {
- String typeName = typeName(cls.getName());
+ String simpleClsName = SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName());
if (id == 0)
- id = BinaryInternalIdMapper.defaultInstance().typeId(typeName);
+ id = SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(simpleClsName);
BinaryClassDescriptor desc = new BinaryClassDescriptor(
this,
cls,
false,
id,
- typeName,
+ simpleClsName,
affFieldName,
- BinaryInternalIdMapper.defaultInstance(),
+ SIMPLE_NAME_LOWER_CASE_MAPPER,
new BinaryReflectiveSerializer(),
false,
true /* registered */
);
- predefinedTypeNames.put(typeName, id);
+ predefinedTypeNames.put(simpleClsName, id);
predefinedTypes.put(id, desc);
descByCls.put(cls, desc);
@@ -759,7 +907,7 @@ public class BinaryContext {
/**
* @param clsName Class name.
- * @param idMapper ID mapper.
+ * @param mapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
* @param isEnum If enum.
@@ -767,12 +915,12 @@ public class BinaryContext {
*/
@SuppressWarnings("ErrorNotRethrown")
public void registerUserType(String clsName,
- BinaryIdMapper idMapper,
+ BinaryInternalMapper mapper,
@Nullable BinarySerializer serializer,
@Nullable String affKeyFieldName,
boolean isEnum)
throws BinaryObjectException {
- assert idMapper != null;
+ assert mapper != null;
Class<?> cls = null;
@@ -783,15 +931,15 @@ public class BinaryContext {
// No-op.
}
- String typeName = typeName(clsName);
+ String typeName = mapper.typeName(clsName);
- int id = idMapper.typeId(typeName);
+ int id = mapper.typeId(clsName);
//Workaround for IGNITE-1358
if (predefinedTypes.get(id) != null)
throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
- if (mappers.put(id, idMapper) != null)
+ if (typeId2Mapper.put(id, mapper) != null)
throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
if (affKeyFieldName != null) {
@@ -799,7 +947,7 @@ public class BinaryContext {
throw new BinaryObjectException("Duplicate type ID [clsName=" + clsName + ", id=" + id + ']');
}
- typeMappers.put(typeName, idMapper);
+ cls2Mappers.put(clsName, mapper);
Map<String, Integer> fieldsMeta = null;
Collection<BinarySchema> schemas = null;
@@ -820,7 +968,7 @@ public class BinaryContext {
id,
typeName,
affKeyFieldName,
- idMapper,
+ mapper,
serializer,
true,
true /* registered */
@@ -858,7 +1006,9 @@ public class BinaryContext {
public BinaryFieldImpl createField(int typeId, String fieldName) {
BinarySchemaRegistry schemaReg = schemaRegistry(typeId);
- int fieldId = userTypeIdMapper(typeId).fieldId(typeId, fieldName);
+ BinaryInternalMapper mapper = userTypeMapper(typeId);
+
+ int fieldId = mapper.fieldId(typeId, fieldName);
return new BinaryFieldImpl(typeId, schemaReg, fieldName, fieldId);
}
@@ -954,43 +1104,6 @@ public class BinaryContext {
}
/**
- * @param clsName Class name.
- * @return Type name.
- */
- @SuppressWarnings("ResultOfMethodCallIgnored")
- public static String typeName(String clsName) {
- assert clsName != null;
-
- int idx = clsName.lastIndexOf('$');
-
- if (idx == clsName.length() - 1)
- // This is a regular (not inner) class name that ends with '$'. Common use case for Scala classes.
- idx = -1;
- else if (idx >= 0) {
- String typeName = clsName.substring(idx + 1);
-
- try {
- Integer.parseInt(typeName);
-
- // This is an anonymous class. Don't cut off enclosing class name for it.
- idx = -1;
- }
- catch (NumberFormatException ignore) {
- // This is a lambda class.
- if (clsName.indexOf("$$Lambda$") > 0)
- idx = -1;
- else
- return typeName;
- }
- }
-
- if (idx < 0)
- idx = clsName.lastIndexOf('.');
-
- return idx >= 0 ? clsName.substring(idx + 1) : clsName;
- }
-
- /**
* Undeployment callback invoked when class loader is being undeployed.
*
* Some marshallers may want to clean their internal state that uses the undeployed class loader somehow.
@@ -1017,7 +1130,7 @@ public class BinaryContext {
* Add type descriptor.
*
* @param clsName Class name.
- * @param idMapper ID mapper.
+ * @param mapper Mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
* @param isEnum Enum flag.
@@ -1025,14 +1138,14 @@ public class BinaryContext {
* @throws BinaryObjectException If failed.
*/
private void add(String clsName,
- BinaryIdMapper idMapper,
+ BinaryInternalMapper mapper,
BinarySerializer serializer,
String affKeyFieldName,
boolean isEnum,
boolean canOverride)
throws BinaryObjectException {
TypeDescriptor desc = new TypeDescriptor(clsName,
- idMapper,
+ mapper,
serializer,
affKeyFieldName,
isEnum,
@@ -1063,8 +1176,8 @@ public class BinaryContext {
/** Class name. */
private final String clsName;
- /** ID mapper. */
- private BinaryIdMapper idMapper;
+ /** Mapper. */
+ private BinaryInternalMapper mapper;
/** Serializer. */
private BinarySerializer serializer;
@@ -1082,16 +1195,16 @@ public class BinaryContext {
* Constructor.
*
* @param clsName Class name.
- * @param idMapper ID mapper.
+ * @param mapper ID mapper.
* @param serializer Serializer.
* @param affKeyFieldName Affinity key field name.
* @param isEnum Enum type.
* @param canOverride Whether this descriptor can be override.
*/
- private TypeDescriptor(String clsName, BinaryIdMapper idMapper, BinarySerializer serializer,
- String affKeyFieldName, boolean isEnum, boolean canOverride) {
+ private TypeDescriptor(String clsName, BinaryInternalMapper mapper,
+ BinarySerializer serializer, String affKeyFieldName, boolean isEnum, boolean canOverride) {
this.clsName = clsName;
- this.idMapper = idMapper;
+ this.mapper = mapper;
this.serializer = serializer;
this.affKeyFieldName = affKeyFieldName;
this.isEnum = isEnum;
@@ -1108,7 +1221,7 @@ public class BinaryContext {
assert clsName.equals(other.clsName);
if (canOverride) {
- idMapper = other.idMapper;
+ mapper = other.mapper;
serializer = other.serializer;
affKeyFieldName = other.affKeyFieldName;
isEnum = other.isEnum;
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 180e20a..fd4a4d8 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
@@ -17,6 +17,11 @@
package org.apache.ignite.internal.binary;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
@@ -31,12 +36,6 @@ import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.nio.ByteBuffer;
-
/**
* Binary enum object.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
deleted file mode 100644
index 14d7d6f..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalIdMapper.java
+++ /dev/null
@@ -1,161 +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.binary;
-
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Internal ID mapper. Mimics ID mapper interface, but provides default implementation and offers slightly better
- * performance on micro-level in default case because it doesn't need virtual calls.
- */
-public class BinaryInternalIdMapper implements BinaryIdMapper {
- /** Maximum lower-case character. */
- private static final char MAX_LOWER_CASE_CHAR = 0x7e;
-
- /** Cached lower-case characters. */
- private static final char[] LOWER_CASE_CHARS;
-
- /** Default implementation. */
- private static final BinaryInternalIdMapper DFLT = new BinaryInternalIdMapper();
-
- /**
- * Static initializer.
- */
- static {
- LOWER_CASE_CHARS = new char[MAX_LOWER_CASE_CHAR + 1];
-
- for (char c = 0; c <= MAX_LOWER_CASE_CHAR; c++)
- LOWER_CASE_CHARS[c] = Character.toLowerCase(c);
- }
-
- /**
- * Get default instance.
- *
- * @return Default instance.
- */
- public static BinaryInternalIdMapper defaultInstance() {
- return DFLT;
- }
-
- /**
- * Create internal mapper.
- *
- * @param mapper Public mapper.
- * @return Internal mapper.
- */
- public static BinaryInternalIdMapper create(@Nullable BinaryIdMapper mapper) {
- return mapper == null ? DFLT : new Wrapper(mapper);
- }
-
- /**
- * Private constructor.
- */
- protected BinaryInternalIdMapper() {
- // No-op.
- }
-
- /**
- * Get type ID.
- *
- * @param typeName Type name.
- * @return Type ID.
- */
- public int typeId(String typeName) {
- assert typeName != null;
-
- return lowerCaseHashCode(typeName, true);
- }
-
- /**
- * Get field ID.
- *
- * @param typeId Type ID.
- * @param fieldName Field name.
- * @return Field ID.
- */
- public int fieldId(int typeId, String fieldName) {
- assert fieldName != null;
-
- return lowerCaseHashCode(fieldName, false);
- }
-
- /**
- * Routine to calculate string hash code an
- *
- * @param str String.
- * @param type {@code True} if this is type name, false otherwise.
- * @return Hash code for given string converted to lower case.
- */
- private static int lowerCaseHashCode(String str, boolean type) {
- int len = str.length();
-
- int h = 0;
-
- for (int i = 0; i < len; i++) {
- int c = str.charAt(i);
-
- c = c <= MAX_LOWER_CASE_CHAR ? LOWER_CASE_CHARS[c] : Character.toLowerCase(c);
-
- h = 31 * h + c;
- }
-
- if (h != 0)
- return h;
- else {
- String what = type ? "type" : "field";
-
- throw new BinaryObjectException("Default binary ID mapper resolved " + what + " ID to zero " +
- "(either change " + what + "'s name or use custom ID mapper) [name=" + str + ']');
- }
- }
-
- /**
- * Wrapping ID mapper.
- */
- private static class Wrapper extends BinaryInternalIdMapper {
- /** Delegate. */
- private final BinaryIdMapper mapper;
-
- /**
- * Constructor.
- *
- * @param mapper Delegate.
- */
- private Wrapper(BinaryIdMapper mapper) {
- assert mapper != null;
-
- this.mapper = mapper;
- }
-
- /** {@inheritDoc} */
- @Override public int typeId(String typeName) {
- int id = mapper.typeId(typeName);
-
- return id != 0 ? id : super.typeId(typeName);
- }
-
- /** {@inheritDoc} */
- @Override public int fieldId(int typeId, String fieldName) {
- int id = mapper.fieldId(typeId, fieldName);
-
- return id != 0 ? id : super.fieldId(typeId, fieldName);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.java
new file mode 100644
index 0000000..1adc8c7
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryInternalMapper.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.internal.binary;
+
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.internal.util.typedef.internal.S;
+
+/**
+ * Internal binary mapper.
+ */
+public class BinaryInternalMapper {
+ /** */
+ private final BinaryNameMapper nameMapper;
+
+ /** */
+ private final BinaryIdMapper idMapper;
+
+ /** */
+ private boolean checkOnZeroId;
+
+ /**
+ * @param nameMapper Name mapper.
+ * @param idMapper Id mapper.
+ * @param checkOnZeroId Whether checks on zero id or not.
+ */
+ public BinaryInternalMapper(BinaryNameMapper nameMapper, BinaryIdMapper idMapper, boolean checkOnZeroId) {
+ assert nameMapper != null;
+ assert idMapper != null;
+
+ this.nameMapper = nameMapper;
+ this.idMapper = idMapper;
+ this.checkOnZeroId = checkOnZeroId;
+ }
+
+ /**
+ * @return Name mapper.
+ */
+ public BinaryNameMapper nameMapper() {
+ return nameMapper;
+ }
+
+ /**
+ * @return ID mapper.
+ */
+ public BinaryIdMapper idMapper() {
+ return idMapper;
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type ID.
+ */
+ public int typeId(String clsName) {
+ int id = idMapper.typeId(nameMapper.typeName(clsName));
+
+ if (!checkOnZeroId)
+ return id;
+
+ return id != 0 ? id : BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(clsName);
+ }
+
+ /**
+ * @param typeId Type ID.
+ * @param fieldName Field name.
+ * @return Field ID.
+ */
+ public int fieldId(int typeId, String fieldName) {
+ int id = idMapper.fieldId(typeId, nameMapper.fieldName(fieldName));
+
+ if (!checkOnZeroId)
+ return id;
+
+ return id != 0 ? id : BinaryContext.SIMPLE_NAME_LOWER_CASE_MAPPER.fieldId(typeId, fieldName);
+ }
+
+ /**
+ * @param clsName Class name.
+ * @return Type name.
+ */
+ public String typeName(String clsName) {
+ return nameMapper.typeName(clsName);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof BinaryInternalMapper))
+ return false;
+
+ BinaryInternalMapper mapper = (BinaryInternalMapper)o;
+
+ return checkOnZeroId == mapper.checkOnZeroId
+ && idMapper.equals(mapper.idMapper)
+ && nameMapper.equals(mapper.nameMapper);
+
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = nameMapper.hashCode();
+
+ res = 31 * res + idMapper.hashCode();
+
+ res = 31 * res + (checkOnZeroId ? 1 : 0);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(BinaryInternalMapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
index 54f2b13..e8574ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMetadataCollector.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.binary;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.jetbrains.annotations.Nullable;
-
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -33,6 +27,10 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.jetbrains.annotations.Nullable;
/**
* Writer for meta data collection.
@@ -44,8 +42,8 @@ class BinaryMetadataCollector implements BinaryWriter {
/** Type name. */
private final String typeName;
- /** ID mapper. */
- private final BinaryIdMapper idMapper;
+ /** Name mapper. */
+ private final BinaryInternalMapper mapper;
/** Collected metadata. */
private final Map<String, Integer> meta = new HashMap<>();
@@ -58,12 +56,12 @@ class BinaryMetadataCollector implements BinaryWriter {
*
* @param typeId Type ID.
* @param typeName Type name.
- * @param idMapper ID mapper.
+ * @param mapper Name mapper.
*/
- BinaryMetadataCollector(int typeId, String typeName, BinaryIdMapper idMapper) {
+ BinaryMetadataCollector(int typeId, String typeName, BinaryInternalMapper mapper) {
this.typeId = typeId;
this.typeName = typeName;
- this.idMapper = idMapper;
+ this.mapper = mapper;
}
/**
@@ -272,6 +270,6 @@ class BinaryMetadataCollector implements BinaryWriter {
);
}
- schemaBuilder.addField(idMapper.fieldId(typeId, name));
+ schemaBuilder.addField(mapper.fieldId(typeId, name));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 8f9cc92..607dabc 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
@@ -26,9 +26,7 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
-
import org.apache.ignite.binary.BinaryCollectionFactory;
-import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryInvalidTypeException;
import org.apache.ignite.binary.BinaryMapFactory;
import org.apache.ignite.binary.BinaryObject;
@@ -40,6 +38,7 @@ import org.apache.ignite.internal.util.typedef.internal.SB;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BINARY_OBJ;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BOOLEAN;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BOOLEAN_ARR;
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.BYTE;
@@ -69,7 +68,6 @@ 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.BINARY_OBJ;
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;
@@ -115,8 +113,8 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
/** Footer end. */
private final int footerLen;
- /** ID mapper. */
- private final BinaryIdMapper idMapper;
+ /** Mapper. */
+ private final BinaryInternalMapper mapper;
/** Schema Id. */
private final int schemaId;
@@ -247,7 +245,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
dataStart = start + DFLT_HDR_LEN;
}
- idMapper = userType ? ctx.userTypeIdMapper(typeId) : BinaryInternalIdMapper.defaultInstance();
+ mapper = userType ? ctx.userTypeMapper(typeId) : BinaryContext.defaultMapper();
schema = BinaryUtils.hasSchema(flags) ? getOrCreateSchema() : null;
}
else {
@@ -256,7 +254,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
rawOff = 0;
footerStart = 0;
footerLen = 0;
- idMapper = null;
+ mapper = null;
schemaId = 0;
userType = false;
fieldIdLen = 0;
@@ -1653,7 +1651,7 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Bina
private int fieldId(String name) {
assert name != null;
- return idMapper.fieldId(typeId, name);
+ return mapper.fieldId(typeId, name);
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 6e05b40..877a2db 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
@@ -17,16 +17,6 @@
package org.apache.ignite.internal.binary;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
-import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.jetbrains.annotations.Nullable;
-
import java.io.IOException;
import java.io.ObjectOutput;
import java.lang.reflect.InvocationTargetException;
@@ -37,6 +27,14 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryRawWriter;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.internal.binary.streams.BinaryHeapOutputStream;
+import org.apache.ignite.internal.binary.streams.BinaryOutputStream;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jetbrains.annotations.Nullable;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -77,8 +75,8 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
/** Amount of written fields. */
private int fieldCnt;
- /** ID mapper. */
- private BinaryIdMapper idMapper;
+ /** */
+ private BinaryInternalMapper mapper;
/**
* @param ctx Context.
@@ -1642,10 +1640,12 @@ public class BinaryWriterExImpl implements BinaryWriter, BinaryRawWriterEx, Obje
if (rawOffPos != 0)
throw new BinaryObjectException("Individual field can't be written after raw writer is acquired.");
- if (idMapper == null)
- idMapper = ctx.userTypeIdMapper(typeId);
+ if (mapper == null)
+ mapper = ctx.userTypeMapper(typeId);
+
+ assert mapper != null;
- int id = idMapper.fieldId(typeId, fieldName);
+ int id = mapper.fieldId(typeId, fieldName);
writeFieldId(id);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
index a095242..6e5a621 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryBuilderSerializer.java
@@ -17,17 +17,15 @@
package org.apache.ignite.internal.binary.builder;
+import java.util.Collection;
+import java.util.IdentityHashMap;
+import java.util.Map;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.internal.binary.BinaryMetadata;
import org.apache.ignite.internal.binary.BinaryObjectExImpl;
+import org.apache.ignite.internal.binary.BinaryUtils;
import org.apache.ignite.internal.binary.BinaryWriterExImpl;
import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
-import org.apache.ignite.internal.binary.BinaryUtils;
-
-import java.util.Collection;
-import java.util.IdentityHashMap;
-import java.util.Map;
/**
*
@@ -100,8 +98,10 @@ class BinaryBuilderSerializer {
}
if (val.getClass().isEnum()) {
- String typeName = BinaryContext.typeName(val.getClass().getName());
- int typeId = writer.context().typeId(typeName);
+ String clsName = val.getClass().getName();
+
+ int typeId = writer.context().typeId(clsName);
+ String typeName = writer.context().userTypeName(clsName);
BinaryMetadata meta = new BinaryMetadata(typeId, typeName, null, null, null, true);
writer.context().updateMetadata(typeId, meta);
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
index 8353cdb..e2290d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/BinaryObjectBuilderImpl.java
@@ -90,7 +90,7 @@ public class BinaryObjectBuilderImpl implements BinaryObjectBuilder {
* @param ctx Binary context.
*/
public BinaryObjectBuilderImpl(BinaryContext ctx, String clsName) {
- this(ctx, ctx.typeId(clsName), BinaryContext.typeName(clsName));
+ this(ctx, ctx.typeId(clsName), ctx.userTypeName(clsName));
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 c9d6dad..a21331e 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
@@ -22,9 +22,10 @@ import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
@@ -39,16 +40,20 @@ import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteBinary;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.GridKernalContext;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.IgniteNodeAttributes;
+import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryEnumObjectImpl;
import org.apache.ignite.internal.binary.BinaryMarshaller;
import org.apache.ignite.internal.binary.BinaryMetadata;
@@ -57,12 +62,12 @@ import org.apache.ignite.internal.binary.BinaryObjectEx;
import org.apache.ignite.internal.binary.BinaryObjectImpl;
import org.apache.ignite.internal.binary.BinaryObjectOffheapImpl;
import org.apache.ignite.internal.binary.BinaryTypeImpl;
-import org.apache.ignite.internal.binary.GridBinaryMarshaller;
-import org.apache.ignite.internal.binary.BinaryContext;
import org.apache.ignite.internal.binary.BinaryUtils;
+import org.apache.ignite.internal.binary.GridBinaryMarshaller;
import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
import org.apache.ignite.internal.binary.streams.BinaryInputStream;
import org.apache.ignite.internal.binary.streams.BinaryOffheapInputStream;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
import org.apache.ignite.internal.processors.cache.CacheEntryPredicateAdapter;
@@ -92,11 +97,16 @@ import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiPredicate;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.lang.IgniteProductVersion;
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;
+
/**
* Binary processor implementation.
*/
@@ -106,6 +116,9 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
private static final Unsafe UNSAFE = GridUnsafe.unsafe();
/** */
+ public static final IgniteProductVersion BINARY_CFG_CHECK_SINCE = IgniteProductVersion.fromString("1.5.6");
+
+ /** */
private final CountDownLatch startLatch = new CountDownLatch(1);
/** */
@@ -204,16 +217,46 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
};
- BinaryMarshaller pMarh0 = (BinaryMarshaller)marsh;
+ BinaryMarshaller bMarsh0 = (BinaryMarshaller)marsh;
binaryCtx = new BinaryContext(metaHnd, ctx.config(), ctx.log(BinaryContext.class));
- IgniteUtils.invoke(BinaryMarshaller.class, pMarh0, "setBinaryContext", binaryCtx,
- ctx.config());
+ IgniteUtils.invoke(BinaryMarshaller.class, bMarsh0, "setBinaryContext", binaryCtx, ctx.config());
binaryMarsh = new GridBinaryMarshaller(binaryCtx);
binaries = new IgniteBinaryImpl(ctx, this);
+
+ if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK)) {
+ BinaryConfiguration bCfg = ctx.config().getBinaryConfiguration();
+
+ if (bCfg != null) {
+ Map<String, Object> map = new HashMap<>();
+
+ map.put("globIdMapper", bCfg.getIdMapper() != null ? bCfg.getIdMapper().getClass().getName() : null);
+ map.put("globSerializer", bCfg.getSerializer() != null ? bCfg.getSerializer().getClass() : null);
+ map.put("compactFooter", bCfg.isCompactFooter());
+
+ if (bCfg.getTypeConfigurations() != null) {
+ Map<Object, Object> typeCfgsMap = new HashMap<>();
+
+ for (BinaryTypeConfiguration c : bCfg.getTypeConfigurations()) {
+ typeCfgsMap.put(
+ c.getTypeName() != null,
+ Arrays.asList(
+ c.getIdMapper() != null ? c.getIdMapper().getClass() : null,
+ c.getSerializer() != null ? c.getSerializer().getClass() : null,
+ c.isEnum()
+ )
+ );
+ }
+
+ map.put("typeCfgs", typeCfgsMap);
+ }
+
+ ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION, map);
+ }
+ }
}
}
@@ -294,6 +337,37 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
}
/** {@inheritDoc} */
+ @Override public void onKernalStart() throws IgniteCheckedException {
+ super.onKernalStart();
+
+ if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK) && marsh instanceof BinaryMarshaller) {
+ BinaryConfiguration bcfg = ctx.config().getBinaryConfiguration();
+
+ for (ClusterNode rmtNode : ctx.discovery().remoteNodes()) {
+ if (rmtNode.version().compareTo(BINARY_CFG_CHECK_SINCE) < 0) {
+ if (bcfg == null || bcfg.getNameMapper() == null) {
+ throw new IgniteCheckedException("When BinaryMarshaller is used and topology contains old " +
+ "nodes, then " + BinaryBasicNameMapper.class.getName() + " mapper have to be set " +
+ "explicitely into binary configuration and 'simpleName' property of the mapper " +
+ "have to be set to 'true'.");
+ }
+
+ if (!(bcfg.getNameMapper() instanceof BinaryBasicNameMapper)
+ || !((BinaryBasicNameMapper)bcfg.getNameMapper()).isSimpleName()) {
+ U.quietAndWarn(log, "When BinaryMarshaller is used and topology contains old" +
+ " nodes, it's strongly recommended, to set " + BinaryBasicNameMapper.class.getName() +
+ " mapper into binary configuration explicitely " +
+ " and 'simpleName' property of the mapper set to 'true' (fix configuration or set " +
+ "-D" + IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK + "=true system property).");
+ }
+
+ break;
+ }
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void onKernalStop(boolean cancel) {
super.onKernalStop(cancel);
@@ -578,10 +652,10 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
/** {@inheritDoc} */
@Override public BinaryObject buildEnum(String typeName, int ord) throws IgniteException {
- typeName = BinaryContext.typeName(typeName);
-
int typeId = binaryCtx.typeId(typeName);
+ typeName = binaryCtx.userTypeName(typeName);
+
updateMetadata(typeId, typeName, null, null, true);
return new BinaryEnumObjectImpl(binaryCtx, typeId, null, ord);
@@ -784,6 +858,37 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
return marshalToBinary(obj);
}
+ /** {@inheritDoc} */
+ @Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode rmtNode) {
+ IgniteNodeValidationResult res = super.validateNode(rmtNode);
+
+ if (res != null)
+ return res;
+
+ if (getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK) || !(marsh instanceof BinaryMarshaller))
+ return null;
+
+ Object rmtBinaryCfg = rmtNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
+
+ if (rmtNode.version().compareTo(BINARY_CFG_CHECK_SINCE) < 0)
+ return null;
+
+ ClusterNode locNode = ctx.discovery().localNode();
+
+ Object locBinaryCfg = locNode.attribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION);
+
+ if (!F.eq(locBinaryCfg, rmtBinaryCfg)) {
+ String msg = "Local node's binary configuration is not equal to remote node's binary configuration " +
+ "[locNodeId=%s, rmtNodeId=%s, locBinaryCfg=%s, rmtBinaryCfg=%s]";
+
+ return new IgniteNodeValidationResult(rmtNode.id(),
+ String.format(msg, locNode.id(), rmtNode.id(), locBinaryCfg, rmtBinaryCfg),
+ String.format(msg, rmtNode.id(), locNode.id(), rmtBinaryCfg, locBinaryCfg));
+ }
+
+ return null;
+ }
+
/**
* Processor responsible for metadata update.
*/
[10/16] ignite git commit: 1523
Posted by sb...@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-2407
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
[12/16] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by sb...@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
[05/16] ignite git commit: IGNITE-2191 - Support classes with the
same simple name for Binary marshaller - Fixes #398.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
index 3cfbcaa..2e60025 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/cpp/PlatformCppConfigurationClosure.java
@@ -19,6 +19,10 @@ package org.apache.ignite.internal.processors.platform.cpp;
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.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
@@ -87,8 +91,36 @@ public class PlatformCppConfigurationClosure extends PlatformAbstractConfigurati
bCfg = new BinaryConfiguration();
bCfg.setCompactFooter(false);
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
igniteCfg.setBinaryConfiguration(bCfg);
+
+ cppCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " +
+ "note that binary name mapper is set to " + bCfg.getNameMapper()
+ + " and binary ID mapper is set to " + bCfg.getIdMapper()
+ + " (other nodes must have the same binary name and ID mapper types)."));
+ }
+ else {
+ BinaryNameMapper nameMapper = bCfg.getNameMapper();
+
+ if (nameMapper == null) {
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+ cppCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " +
+ bCfg.getNameMapper()
+ + " (other nodes must have the same binary name mapper type)."));
+ }
+
+ BinaryIdMapper idMapper = bCfg.getIdMapper();
+
+ if (idMapper == null) {
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+ cppCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " +
+ bCfg.getIdMapper()
+ + " (other nodes must have the same binary ID mapper type)."));
+ }
}
if (bCfg.isCompactFooter())
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 c068d59..6b9b441 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,6 +19,10 @@ 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.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.PlatformConfiguration;
@@ -90,7 +94,7 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
igniteCfg.setPlatformConfiguration(dotNetCfg0);
- // Check marshaller
+ // Check marshaller.
Marshaller marsh = igniteCfg.getMarshaller();
if (marsh == null) {
@@ -109,8 +113,36 @@ public class PlatformDotNetConfigurationClosure extends PlatformAbstractConfigur
bCfg = new BinaryConfiguration();
bCfg.setCompactFooter(false);
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
igniteCfg.setBinaryConfiguration(bCfg);
+
+ dotNetCfg0.warnings(Collections.singleton("Binary configuration is automatically initiated, " +
+ "note that binary name mapper is set to " + bCfg.getNameMapper()
+ + " and binary ID mapper is set to " + bCfg.getIdMapper()
+ + " (other nodes must have the same binary name and ID mapper types)."));
+ }
+ else {
+ BinaryNameMapper nameMapper = bCfg.getNameMapper();
+
+ if (nameMapper == null) {
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+ dotNetCfg0.warnings(Collections.singleton("Binary name mapper is automatically set to " +
+ bCfg.getNameMapper()
+ + " (other nodes must have the same binary name mapper type)."));
+ }
+
+ BinaryIdMapper idMapper = bCfg.getIdMapper();
+
+ if (idMapper == null) {
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+
+ dotNetCfg0.warnings(Collections.singleton("Binary ID mapper is automatically set to " +
+ bCfg.getIdMapper()
+ + " (other nodes must have the same binary ID mapper type)."));
+ }
}
if (bCfg.isCompactFooter())
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
new file mode 100644
index 0000000..1d6da2c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicIdMapperSelfTest.java
@@ -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.
+ */
+
+package org.apache.ignite.internal.binary;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class BinaryBasicIdMapperSelfTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLowerCase() throws Exception {
+ BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(true);
+
+ assertEquals(GridBinaryTestClass1.class.getName().toLowerCase().hashCode(),
+ mapper.typeId(GridBinaryTestClass1.class.getName()));
+ assertEquals((GridBinaryTestClass1.class.getName() + "$InnerClass").toLowerCase().hashCode(),
+ mapper.typeId(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDefaultCase() throws Exception {
+ BinaryBasicIdMapper mapper = new BinaryBasicIdMapper(false);
+
+ assertEquals(GridBinaryTestClass1.class.getName().hashCode(),
+ mapper.typeId(GridBinaryTestClass1.class.getName()));
+ assertEquals((GridBinaryTestClass1.class.getName() + "$InnerClass").hashCode(),
+ mapper.typeId(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
new file mode 100644
index 0000000..70fb8e7
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryBasicNameMapperSelfTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class BinaryBasicNameMapperSelfTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSimpleName() throws Exception {
+ BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(true);
+
+ assertEquals("GridBinaryTestClass1", mapper.typeName(GridBinaryTestClass1.class.getName()));
+
+ assertEquals("InnerClass", mapper.typeName(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFullName() throws Exception {
+ BinaryBasicNameMapper mapper = new BinaryBasicNameMapper(false);
+
+ assertEquals(GridBinaryTestClass1.class.getName(), mapper.typeName(GridBinaryTestClass1.class.getName()));
+
+ assertEquals(GridBinaryTestClass1.class.getName() + "$InnerClass",
+ mapper.typeName(GridBinaryTestClass1.class.getName() + "$InnerClass"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
new file mode 100644
index 0000000..7a56d9c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryConfigurationConsistencySelfTest.java
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import java.util.Arrays;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK;
+
+/**
+ * Tests a check of binary configuration consistency.
+ */
+public class BinaryConfigurationConsistencySelfTest extends GridCommonAbstractTest {
+ /** */
+ private BinaryConfiguration binaryCfg;
+
+ /** */
+ private boolean isClient;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClientMode(isClient);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ cfg.setBinaryConfiguration(binaryCfg);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ isClient = false;
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSkipCheckConsistencyFlagEnabled() throws Exception {
+ String backup = System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, "true");
+
+ try {
+ // Wrong usage of Ignite (done only in test purposes).
+ binaryCfg = null;
+
+ startGrid(0);
+
+ binaryCfg = new BinaryConfiguration();
+
+ startGrid(1);
+
+ isClient = true;
+ binaryCfg = customConfig(true);
+
+ startGrid(2);
+ }
+ finally {
+ if (backup != null)
+ System.setProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK, backup);
+ else
+ System.clearProperty(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPositiveNullConfig() throws Exception {
+ binaryCfg = null;
+
+ startGrids(2);
+
+ isClient = true;
+
+ startGrid(2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPositiveEmptyConfig() throws Exception {
+ binaryCfg = new BinaryConfiguration();
+
+ startGrids(2);
+
+ isClient = true;
+
+ startGrid(2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPositiveCustomConfig() throws Exception {
+ binaryCfg = customConfig(false);
+
+ startGrids(2);
+
+ isClient = true;
+
+ startGrid(2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNegativeNullEmptyConfigs() throws Exception {
+ checkNegative(null, new BinaryConfiguration());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNegativeEmptyNullConfigs() throws Exception {
+ checkNegative(new BinaryConfiguration(), null);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNegativeEmptyCustomConfigs() throws Exception {
+ checkNegative(new BinaryConfiguration(), customConfig(false));
+ }
+
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNegativeCustomNullConfigs() throws Exception {
+ checkNegative(customConfig(false), null);
+ }
+
+ /**
+ * @param bCfg1 BinaryConfiguration 1.
+ * @param bCfg2 BinaryConfiguration 2.
+ * @throws Exception If failed.
+ */
+ private void checkNegative(final BinaryConfiguration bCfg1, BinaryConfiguration bCfg2) throws Exception {
+ binaryCfg = bCfg1;
+
+ startGrid(0);
+
+ binaryCfg = bCfg2;
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ startGrid(1);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, "");
+
+ isClient = true;
+
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ startGrid(2);
+
+ return null;
+ }
+ }, IgniteCheckedException.class, "");
+ }
+
+ /**
+ * @return Custom BinaryConfiguration.
+ * @param compactFooter Compact footer.
+ */
+ private BinaryConfiguration customConfig(boolean compactFooter) {
+ BinaryConfiguration c = new BinaryConfiguration();
+
+ c.setIdMapper(new BinaryBasicIdMapper(true));
+ c.setSerializer(new BinarySerializer() {
+ @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+ // No-op.
+ }
+
+ @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+ // No-op.
+ }
+ });
+ c.setCompactFooter(compactFooter);
+
+ BinaryTypeConfiguration btc = new BinaryTypeConfiguration("org.MyClass");
+
+ btc.setIdMapper(BinaryContext.defaultIdMapper());
+ btc.setEnum(false);
+ btc.setSerializer(new BinarySerializer() {
+ @Override public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
+ // No-op.
+ }
+
+ @Override public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
+ // No-op.
+ }
+ });
+
+ c.setTypeConfigurations(Arrays.asList(btc));
+
+ return c;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
index e503e07..6bd9b65 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryEnumsSelfTest.java
@@ -221,10 +221,10 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
private void checkNestedBuilder(boolean registered) throws Exception {
startUp(registered);
- BinaryObject obj = node1.binary().builder("EnumHolder").setField("val", EnumType.ONE).build();
+ BinaryObject obj = node1.binary().builder(EnumHolder.class.getName()).setField("val", EnumType.ONE).build();
- assert node1.binary().type("EnumHolder") != null;
- assert node1.binary().type("EnumType") != null;
+ assert node1.binary().type(EnumHolder.class.getName()) != null;
+ assert node1.binary().type(EnumType.class.getName()) != null;
cacheBinary1.put(1, obj);
@@ -271,7 +271,7 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
public void checkSimpleBuilder(boolean registered) throws Exception {
startUp(registered);
- BinaryObject binary = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal());
+ BinaryObject binary = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.ordinal());
cacheBinary1.put(1, binary);
@@ -337,8 +337,8 @@ public class BinaryEnumsSelfTest extends GridCommonAbstractTest {
public void checkSimpleBuilderArray(boolean registered) throws Exception {
startUp(registered);
- BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.ONE.ordinal());
- BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getSimpleName(), EnumType.TWO.ordinal());
+ BinaryObject binaryOne = node1.binary().buildEnum(EnumType.class.getName(), EnumType.ONE.ordinal());
+ BinaryObject binaryTwo = node1.binary().buildEnum(EnumType.class.getName(), EnumType.TWO.ordinal());
cacheBinary1.put(1, new BinaryObject[] { binaryOne, binaryTwo });
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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 c347b9f..fa0f9a7 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
@@ -17,12 +17,49 @@
package org.apache.ignite.internal.binary;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.sql.Timestamp;
+import java.util.AbstractQueue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Queue;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
import junit.framework.Assert;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.binary.BinaryCollectionFactory;
import org.apache.ignite.binary.BinaryField;
import org.apache.ignite.binary.BinaryIdMapper;
import org.apache.ignite.binary.BinaryMapFactory;
+import org.apache.ignite.binary.BinaryNameMapper;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.binary.BinaryObjectBuilder;
import org.apache.ignite.binary.BinaryObjectException;
@@ -53,43 +90,9 @@ import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import sun.misc.Unsafe;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.sql.Timestamp;
-import java.util.AbstractQueue;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Queue;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListSet;
-
-import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.*;
-import static org.junit.Assert.*;
+import static org.apache.ignite.internal.binary.streams.BinaryMemoryAllocator.INSTANCE;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertNotEquals;
/**
* Binary marshaller tests.
@@ -1047,7 +1050,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return 11111;
}
@@ -1092,6 +1095,63 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testSimpleNameLowerCaseMappers() throws Exception {
+ BinaryTypeConfiguration innerClassType = new BinaryTypeConfiguration(InnerMappedObject.class.getName());
+ BinaryTypeConfiguration publicClassType = new BinaryTypeConfiguration(TestMappedObject.class.getName());
+ BinaryTypeConfiguration typeWithCustomMapper = new BinaryTypeConfiguration(CustomMappedObject2.class.getName());
+
+ typeWithCustomMapper.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 44444;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ assert typeId == 44444;
+
+ if ("val1".equals(fieldName))
+ return 55555;
+ else if ("val2".equals(fieldName))
+ return 66666;
+
+ assert false : "Unknown field: " + fieldName;
+
+ return 0;
+ }
+ });
+
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+ Arrays.asList(innerClassType, publicClassType, typeWithCustomMapper));
+
+ InnerMappedObject innerObj = new InnerMappedObject(10, "str1");
+
+ BinaryObjectExImpl innerBo = marshal(innerObj, marsh);
+
+ assertEquals("InnerMappedObject".toLowerCase().hashCode(), innerBo.type().typeId());
+
+ assertEquals(10, innerBo.<CustomMappedObject1>deserialize().val1);
+ assertEquals("str1", innerBo.<CustomMappedObject1>deserialize().val2);
+
+ TestMappedObject publicObj = new TestMappedObject();
+
+ BinaryObjectExImpl publicBo = marshal(publicObj, marsh);
+
+ assertEquals("TestMappedObject".toLowerCase().hashCode(), publicBo.type().typeId());
+
+ CustomMappedObject2 obj2 = new CustomMappedObject2(20, "str2");
+
+ BinaryObjectExImpl po2 = marshal(obj2, marsh);
+
+ assertEquals(44444, po2.type().typeId());
+ assertEquals((Integer)20, po2.field(55555));
+ assertEquals("str2", po2.field(66666));
+
+ assertEquals(20, po2.<CustomMappedObject2>deserialize().val1);
+ assertEquals("str2", po2.<CustomMappedObject2>deserialize().val2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testDynamicObject() throws Exception {
BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
new BinaryTypeConfiguration(DynamicObject.class.getName())
@@ -1299,7 +1359,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testTypeNames() throws Exception {
+ public void testTypeNamesSimpleNameMapper() throws Exception {
BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
customType1.setIdMapper(new BinaryIdMapper() {
@@ -1336,7 +1396,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass5");
+ BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
customType4.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
@@ -1348,7 +1408,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
}
});
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+ Arrays.asList(
new BinaryTypeConfiguration(Key.class.getName()),
new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
new BinaryTypeConfiguration("NonExistentClass4"),
@@ -1360,14 +1421,296 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
+ // Full name hashCode.
assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
- assertEquals("key".hashCode(), ctx.typeId("Key"));
- assertEquals("nonexistentclass3".hashCode(), ctx.typeId("NonExistentClass3"));
+ assertEquals("key".hashCode(), ctx.typeId(Key.class.getName()));
+ assertEquals("nonexistentclass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
- assertEquals(300, ctx.typeId(getClass().getSimpleName() + "$Value"));
- assertEquals(400, ctx.typeId("NonExistentClass1"));
+ assertEquals(300, ctx.typeId(Value.class.getName()));
+ assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
assertEquals(500, ctx.typeId("NonExistentClass2"));
- assertEquals("nonexistentclass5".hashCode(), ctx.typeId("NonExistentClass5"));
+
+ // BinaryIdMapper.typeId() contract.
+ assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeNamesFullNameMappers() throws Exception {
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 300;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 400;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+ customType3.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+ customType4.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 0;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false),
+ Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+ new BinaryTypeConfiguration("NonExistentClass4"),
+ customType1,
+ customType2,
+ customType3,
+ customType4
+ ));
+
+ BinaryContext ctx = binaryContext(marsh);
+
+ // Full name hashCode.
+ assertEquals("NotConfiguredClass".hashCode(), ctx.typeId("NotConfiguredClass"));
+ assertEquals(Key.class.getName().hashCode(), ctx.typeId(Key.class.getName()));
+ assertEquals("org.gridgain.NonExistentClass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
+ assertEquals("NonExistentClass4".hashCode(), ctx.typeId("NonExistentClass4"));
+ assertEquals(300, ctx.typeId(Value.class.getName()));
+ assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+ assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+ // BinaryIdMapper.typeId() contract.
+ assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeNamesSimpleNameMappers() throws Exception {
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 300;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 400;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+ customType3.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+ customType4.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 0;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType5 = new BinaryTypeConfiguration(DateClass1.class.getName());
+
+ customType5.setNameMapper(new BinaryBasicNameMapper(false));
+ customType5.setIdMapper(new BinaryBasicIdMapper(false));
+
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true),
+ Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+ new BinaryTypeConfiguration("NonExistentClass4"),
+ customType1,
+ customType2,
+ customType3,
+ customType4,
+ customType5
+ ));
+
+ BinaryContext ctx = binaryContext(marsh);
+
+ assertEquals("notconfiguredclass".hashCode(), ctx.typeId("NotConfiguredClass"));
+ assertEquals("notconfiguredclass".hashCode(), ctx.typeId("org.blabla.NotConfiguredClass"));
+ assertEquals("key".hashCode(), ctx.typeId(Key.class.getName()));
+ assertEquals("nonexistentclass3".hashCode(), ctx.typeId("org.gridgain.NonExistentClass3"));
+ assertEquals("nonexistentclass4".hashCode(), ctx.typeId("NonExistentClass4"));
+
+ assertEquals(300, ctx.typeId(Value.class.getName()));
+ assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+ assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+ assertEquals(DateClass1.class.getName().hashCode(), ctx.typeId(DateClass1.class.getName()));
+
+ // BinaryIdMapper.typeId() contract.
+ assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeNamesCustomIdMapper() throws Exception {
+ BinaryTypeConfiguration customType1 = new BinaryTypeConfiguration(Value.class.getName());
+
+ customType1.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 300;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType2 = new BinaryTypeConfiguration("org.gridgain.NonExistentClass1");
+
+ customType2.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 400;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType3 = new BinaryTypeConfiguration("NonExistentClass2");
+
+ customType3.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 500;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType4 = new BinaryTypeConfiguration("NonExistentClass0");
+
+ customType4.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return 0;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ });
+
+ BinaryTypeConfiguration customType5 = new BinaryTypeConfiguration(DateClass1.class.getName());
+
+ customType5.setIdMapper(new BinaryBasicIdMapper(false));
+
+ BinaryTypeConfiguration customType6 = new BinaryTypeConfiguration(MyTestClass.class.getName());
+
+ customType6.setIdMapper(new BinaryBasicIdMapper(true));
+ customType6.setNameMapper(new BinaryBasicNameMapper(true));
+
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ if ("org.blabla.NotConfiguredSpecialClass".equals(clsName))
+ return 0;
+ else if (Key.class.getName().equals(clsName))
+ return 991;
+ else if ("org.gridgain.NonExistentClass3".equals(clsName))
+ return 992;
+ else if ("NonExistentClass4".equals(clsName))
+ return 993;
+
+ return 999;
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return 0;
+ }
+ }, Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.NonExistentClass3"),
+ new BinaryTypeConfiguration("NonExistentClass4"),
+ customType1,
+ customType2,
+ customType3,
+ customType4,
+ customType5,
+ customType6
+ ));
+
+ BinaryContext ctx = binaryContext(marsh);
+
+ assertEquals(999, ctx.typeId("NotConfiguredClass"));
+ assertEquals(999, ctx.typeId("org.blabla.NotConfiguredClass"));
+
+ // BinaryIdMapper.typeId() contract.
+ assertEquals("notconfiguredspecialclass".hashCode(), ctx.typeId("org.blabla.NotConfiguredSpecialClass"));
+
+ assertEquals(991, ctx.typeId(Key.class.getName()));
+ assertEquals(992, ctx.typeId("org.gridgain.NonExistentClass3"));
+ assertEquals(993, ctx.typeId("NonExistentClass4"));
+
+
+ // Custom types.
+ assertEquals(300, ctx.typeId(Value.class.getName()));
+ assertEquals(400, ctx.typeId("org.gridgain.NonExistentClass1"));
+ assertEquals(500, ctx.typeId("NonExistentClass2"));
+
+ // BinaryIdMapper.typeId() contract.
+ assertEquals("nonexistentclass0".hashCode(), ctx.typeId("NonExistentClass0"));
+
+ assertEquals(DateClass1.class.getName().hashCode(), ctx.typeId(DateClass1.class.getName()));
+ assertEquals("mytestclass".hashCode(), ctx.typeId(MyTestClass.class.getName()));
}
/**
@@ -1656,11 +1999,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObject copy = copy(po, F.<String, Object>asMap("bArr", new byte[]{1, 2, 3}));
- assertArrayEquals(new byte[]{1, 2, 3}, copy.<byte[]>field("bArr"));
+ assertArrayEquals(new byte[] {1, 2, 3}, copy.<byte[]>field("bArr"));
SimpleObject obj0 = copy.deserialize();
- assertArrayEquals(new byte[]{1, 2, 3}, obj0.bArr);
+ assertArrayEquals(new byte[] {1, 2, 3}, obj0.bArr);
}
/**
@@ -1819,11 +2162,11 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryObject copy = copy(po, F.<String, Object>asMap("strArr", new String[]{"str1", "str2"}));
- assertArrayEquals(new String[]{"str1", "str2"}, copy.<String[]>field("strArr"));
+ assertArrayEquals(new String[] {"str1", "str2"}, copy.<String[]>field("strArr"));
SimpleObject obj0 = copy.deserialize();
- assertArrayEquals(new String[]{"str1", "str2"}, obj0.strArr);
+ assertArrayEquals(new String[] {"str1", "str2"}, obj0.strArr);
}
/**
@@ -1887,7 +2230,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertEquals("str555", obj0.str);
assertEquals(newObj, obj0.inner);
- assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
+ assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
}
/**
@@ -1912,8 +2255,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
map.put("str", "str555");
map.put("inner", newObj);
map.put("s", (short)2323);
- map.put("bArr", new byte[]{6, 7, 9});
- map.put("b", (byte) 111);
+ map.put("bArr", new byte[] {6, 7, 9});
+ map.put("b", (byte)111);
BinaryObject copy = copy(po, map);
@@ -1930,8 +2273,8 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
assertEquals("str555", obj0.str);
assertEquals(newObj, obj0.inner);
assertEquals((short)2323, obj0.s);
- assertArrayEquals(new byte[]{6, 7, 9}, obj0.bArr);
- assertEquals((byte) 111, obj0.b);
+ assertArrayEquals(new byte[] {6, 7, 9}, obj0.bArr);
+ assertEquals((byte)111, obj0.b);
}
/**
@@ -2190,8 +2533,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testDuplicateName() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller();
+ public void testDuplicateNameSimpleNameMapper() throws Exception {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true),
+ new BinaryBasicIdMapper(true), null, null);
Test1.Job job1 = new Test1().new Job();
Test2.Job job2 = new Test2().new Job();
@@ -2213,6 +2557,21 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testDuplicateNameFullNameMapper() throws Exception {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false),
+ new BinaryBasicIdMapper(false), null, null);
+
+ Test1.Job job1 = new Test1().new Job();
+ Test2.Job job2 = new Test2().new Job();
+
+ marsh.marshal(job1);
+
+ marsh.marshal(job2);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
public void testClass() throws Exception {
BinaryMarshaller marsh = binaryMarshaller();
@@ -2288,13 +2647,13 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
public void testPredefinedTypeIds() throws Exception {
BinaryMarshaller marsh = binaryMarshaller();
- BinaryContext pCtx = binaryContext(marsh);
+ BinaryContext bCtx = binaryContext(marsh);
- Field field = pCtx.getClass().getDeclaredField("predefinedTypeNames");
+ Field field = bCtx.getClass().getDeclaredField("predefinedTypeNames");
field.setAccessible(true);
- Map<String, Integer> map = (Map<String, Integer>)field.get(pCtx);
+ Map<String, Integer> map = (Map<String, Integer>)field.get(bCtx);
assertTrue(map.size() > 0);
@@ -2304,10 +2663,9 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
if (id == GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
continue;
- BinaryClassDescriptor desc = pCtx.descriptorForTypeId(false, entry.getValue(), null, false);
+ BinaryClassDescriptor desc = bCtx.descriptorForTypeId(false, entry.getValue(), null, false);
- assertEquals(desc.typeId(), pCtx.typeId(desc.describedClass().getName()));
- assertEquals(desc.typeId(), pCtx.typeId(pCtx.typeName(desc.describedClass().getName())));
+ assertEquals(desc.typeId(), bCtx.typeId(desc.describedClass().getName()));
}
}
@@ -2714,7 +3072,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*/
protected BinaryMarshaller binaryMarshaller()
throws IgniteCheckedException {
- return binaryMarshaller(null, null, null);
+ return binaryMarshaller(null, null, null, null);
}
/**
@@ -2722,15 +3080,15 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*/
protected BinaryMarshaller binaryMarshaller(Collection<BinaryTypeConfiguration> cfgs)
throws IgniteCheckedException {
- return binaryMarshaller(null, null, cfgs);
+ return binaryMarshaller(null, null, null, cfgs);
}
/**
*
*/
- protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
throws IgniteCheckedException {
- return binaryMarshaller(mapper, null, cfgs);
+ return binaryMarshaller(nameMapper, mapper, null, cfgs);
}
/**
@@ -2738,13 +3096,14 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
*/
protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
throws IgniteCheckedException {
- return binaryMarshaller(null, serializer, cfgs);
+ return binaryMarshaller(null, null, serializer, cfgs);
}
/**
* @return Binary marshaller.
*/
protected BinaryMarshaller binaryMarshaller(
+ BinaryNameMapper nameMapper,
BinaryIdMapper mapper,
BinarySerializer serializer,
Collection<BinaryTypeConfiguration> cfgs
@@ -2753,6 +3112,7 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
BinaryConfiguration bCfg = new BinaryConfiguration();
+ bCfg.setNameMapper(nameMapper);
bCfg.setIdMapper(mapper);
bCfg.setSerializer(serializer);
bCfg.setCompactFooter(compactFooter());
@@ -3657,6 +4017,18 @@ public class BinaryMarshallerSelfTest extends GridCommonAbstractTest {
/**
*/
+ private static class InnerMappedObject extends CustomMappedObject1 {
+ /**
+ * @param val1 Val1
+ * @param val2 Val2
+ */
+ InnerMappedObject(int val1, String val2) {
+ super(val1, val2);
+ }
+ }
+
+ /**
+ */
private static class CustomMappedObject2 {
/** */
private int val1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
index 572df88..06e1e93 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderAdditionalSelfTest.java
@@ -1258,7 +1258,7 @@ public class BinaryObjectBuilderAdditionalSelfTest extends GridCommonAbstractTes
CacheObjectBinaryProcessorImpl processor = (CacheObjectBinaryProcessorImpl)(
(IgniteBinaryImpl)binaries()).processor();
- return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
- aCls.getSimpleName());
+ return new BinaryObjectBuilderImpl(processor.binaryContext(), processor.typeId(aCls.getName()),
+ processor.binaryContext().userTypeName(aCls.getName()));
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/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
new file mode 100644
index 0000000..059703e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderDefaultMappersSelfTest.java
@@ -0,0 +1,1149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import junit.framework.TestCase;
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryType;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
+import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
+import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
+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;
+
+/**
+ * Binary builder test.
+ */
+@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} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
+
+ customTypeCfg.setTypeName(CustomIdMapper.class.getName());
+ customTypeCfg.setIdMapper(new BinaryIdMapper() {
+ @Override public int typeId(String clsName) {
+ return ~BinaryContext.defaultIdMapper().typeId(clsName);
+ }
+
+ @Override public int fieldId(int typeId, String fieldName) {
+ return typeId + ~BinaryContext.defaultIdMapper().fieldId(typeId, fieldName);
+ }
+ });
+
+ BinaryConfiguration bCfg = new BinaryConfiguration();
+
+ bCfg.setCompactFooter(compactFooter());
+
+ bCfg.setTypeConfigurations(Arrays.asList(
+ new BinaryTypeConfiguration(Key.class.getName()),
+ new BinaryTypeConfiguration(Value.class.getName()),
+ new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"),
+ customTypeCfg));
+
+ bCfg.setIdMapper(new BinaryBasicIdMapper(false));
+ bCfg.setNameMapper(new BinaryBasicNameMapper(false));
+
+ cfg.setBinaryConfiguration(bCfg);
+
+ cfg.setMarshaller(new BinaryMarshaller());
+
+ this.cfg = cfg;
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ startGrids(1);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /**
+ * @return Whether to use compact footer.
+ */
+ protected boolean compactFooter() {
+ return true;
+ }
+
+ /**
+ *
+ */
+ public void testAllFieldsSerialization() {
+ GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ GridBinaryTestClasses.TestObjectAllTypes deserialized = builder(toBinary(obj)).build().deserialize();
+
+ GridTestUtils.deepEquals(obj, deserialized);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNullField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(42);
+
+ builder.setField("objField", (Object)null);
+
+ builder.setField("otherField", "value");
+
+ BinaryObject obj = builder.build();
+
+ assertNull(obj.field("objField"));
+ assertEquals("value", obj.field("otherField"));
+ assertEquals(42, obj.hashCode());
+
+ builder = builder(obj);
+
+ builder.setField("objField", "value");
+ builder.setField("otherField", (Object)null);
+
+ obj = builder.build();
+
+ assertNull(obj.field("otherField"));
+ assertEquals("value", obj.field("objField"));
+ assertEquals(42, obj.hashCode());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByteField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("byteField", (byte)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("shortField", (short)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((short)1, po.<Short>field("shortField").shortValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1, po.<Integer>field("intField").intValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("longField", 1L);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1L, po.<Long>field("longField").longValue());
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("floatField", 1.0f);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("doubleField", 1.0d);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("charField", (char)1);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals((char)1, po.<Character>field("charField").charValue());
+ }
+
+ /**
+ * @return Expected hash code.
+ * @param fullName Full name of type.
+ */
+ private int expectedHashCode(String fullName) {
+ BinaryIdMapper idMapper = cfg.getBinaryConfiguration().getIdMapper();
+ BinaryNameMapper nameMapper = cfg.getBinaryConfiguration().getNameMapper();
+
+ if (idMapper == null)
+ idMapper = BinaryContext.defaultIdMapper();
+
+ if (nameMapper == null)
+ nameMapper = BinaryContext.defaultNameMapper();
+
+ return idMapper.typeId(nameMapper.typeName(fullName));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBooleanField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("booleanField", true);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(po.<Boolean>field("booleanField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimalField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("decimalField", BigDecimal.TEN);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStringField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("stringField", "str");
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals("str", po.<String>field("stringField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateField() throws Exception {
+ Date date = new Date();
+
+ assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampField() throws Exception {
+ Timestamp ts = new Timestamp(new Date().getTime());
+ ts.setNanos(1000);
+
+ assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuidField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ UUID uuid = UUID.randomUUID();
+
+ builder.setField("uuidField", uuid);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(uuid, po.<UUID>field("uuidField"));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testByteArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testShortArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("shortArrayField", new short[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIntArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("intArrayField", new int[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testLongArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("longArrayField", new long[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testFloatArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("floatArrayField", new float[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDoubleArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("doubleArrayField", new double[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCharArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("charArrayField", new char[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBooleanArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("booleanArrayField", new boolean[] {true, false});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ boolean[] arr = po.field("booleanArrayField");
+
+ assertEquals(2, arr.length);
+
+ assertTrue(arr[0]);
+ assertFalse(arr[1]);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDecimalArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStringArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDateArrayField() throws Exception {
+ Date date1 = new Date();
+ Date date2 = new Date(date1.getTime() + 1000);
+
+ Date[] dateArr = new Date[] { date1, date2 };
+
+ assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTimestampArrayField() throws Exception {
+ Timestamp ts1 = new Timestamp(new Date().getTime());
+ Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
+
+ ts1.setNanos(1000);
+ ts2.setNanos(2000);
+
+ Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
+
+ assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testUuidArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
+
+ builder.setField("uuidArrayField", arr);
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObjectField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("objectField", new Value(1));
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testObjectArrayField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ Object[] arr = po.field("objectArrayField");
+
+ assertEquals(2, arr.length);
+
+ assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
+ assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCollectionField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ List<BinaryObject> list = po.field("collectionField");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMapField() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ Map<BinaryObject, BinaryObject> map = po.field("mapField");
+
+ assertEquals(2, map.size());
+
+ for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
+ assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSeveralFields() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("i", 111);
+ builder.setField("f", 111.111f);
+ builder.setField("iArr", new int[] {1, 2, 3});
+ builder.setField("obj", new Key(1));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ assertEquals(expectedHashCode("Class"), po.type().typeId());
+ assertEquals(100, po.hashCode());
+
+ assertEquals(111, po.<Integer>field("i").intValue());
+ assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
+ assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
+
+ List<BinaryObject> list = po.field("col");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOffheapBinary() throws Exception {
+ BinaryObjectBuilder builder = builder("Class");
+
+ builder.hashCode(100);
+
+ builder.setField("i", 111);
+ builder.setField("f", 111.111f);
+ builder.setField("iArr", new int[] {1, 2, 3});
+ builder.setField("obj", new Key(1));
+ builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
+
+ BinaryObject po = builder.build();
+
+ byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
+
+ long ptr = UNSAFE.allocateMemory(arr.length + 5);
+
+ try {
+ long ptr0 = ptr;
+
+ UNSAFE.putBoolean(null, ptr0++, false);
+
+ UNSAFE.putInt(ptr0, arr.length);
+
+ UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
+
+ BinaryObject offheapObj = (BinaryObject)
+ ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
+
+ assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
+
+ assertEquals(expectedHashCode("Class"), offheapObj.type().typeId());
+ assertEquals(100, offheapObj.hashCode());
+
+ assertEquals(111, offheapObj.<Integer>field("i").intValue());
+ assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
+ assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
+ assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
+
+ List<BinaryObject> list = offheapObj.field("col");
+
+ assertEquals(2, list.size());
+
+ assertEquals(1, list.get(0).<Value>deserialize().i);
+ assertEquals(2, list.get(1).<Value>deserialize().i);
+
+ assertEquals(po, offheapObj);
+ assertEquals(offheapObj, po);
+ }
+ finally {
+ UNSAFE.freeMemory(ptr);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBuildAndDeserialize() throws Exception {
+ BinaryObjectBuilder builder = builder(Value.class.getName());
+
+ builder.hashCode(100);
+
+ builder.setField("i", 1);
+
+ BinaryObject bo = builder.build();
+
+ assertEquals(expectedHashCode(Value.class.getName()), bo.type().typeId());
+ assertEquals(100, bo.hashCode());
+
+ assertEquals(1, bo.<Value>deserialize().i);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetaData2() throws Exception {
+ BinaryObjectBuilder builder = builder("org.test.MetaTest2");
+
+ builder.setField("objectField", "a", Object.class);
+
+ BinaryObject bo = builder.build();
+
+ BinaryType meta = bo.type();
+
+ assertEquals(expectedTypeName("org.test.MetaTest2"), meta.typeName());
+ assertEquals("Object", meta.fieldTypeName("objectField"));
+ }
+
+ /**
+ * @param fullClsName Class name.
+ * @return Expected type name according to configuration.
+ */
+ private String expectedTypeName(String fullClsName) {
+ BinaryNameMapper mapper = cfg.getBinaryConfiguration().getNameMapper();
+
+ if (mapper == null)
+ mapper = BinaryContext.defaultNameMapper();
+
+ return mapper.typeName(fullClsName);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testMetaData() throws Exception {
+ BinaryObjectBuilder builder = builder("org.test.MetaTest");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 1);
+ builder.setField("byteArrayField", new byte[] {1, 2, 3});
+
+ BinaryObject po = builder.build();
+
+ BinaryType meta = po.type();
+
+ assertEquals(expectedTypeName("org.test.MetaTest"), meta.typeName());
+
+ Collection<String> fields = meta.fieldNames();
+
+ assertEquals(2, fields.size());
+
+ assertTrue(fields.contains("intField"));
+ assertTrue(fields.contains("byteArrayField"));
+
+ assertEquals("int", meta.fieldTypeName("intField"));
+ assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+
+ builder = builder("org.test.MetaTest");
+
+ builder.hashCode(100);
+
+ builder.setField("intField", 2);
+ builder.setField("uuidField", UUID.randomUUID());
+
+ po = builder.build();
+
+ meta = po.type();
+
+ assertEquals(expectedTypeName("org.test.MetaTest"), meta.typeName());
+
+ fields = meta.fieldNames();
+
+ assertEquals(3, fields.size());
+
+ assertTrue(fields.contains("intField"));
+ assertTrue(fields.contains("byteArrayField"));
+ assertTrue(fields.contains("uuidField"));
+
+ assertEquals("int", meta.fieldTypeName("intField"));
+ assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
+ assertEquals("UUID", meta.fieldTypeName("uuidField"));
+ }
+
+ /**
+ *
+ */
+ public void testGetFromCopiedObj() {
+ BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
+
+ BinaryObjectBuilderImpl builder = builder(objStr);
+ assertEquals("aaa", builder.getField("str"));
+
+ builder.setField("str", "bbb");
+ assertEquals("bbb", builder.getField("str"));
+
+ assertNull(builder.getField("i_"));
+ TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("unchecked")
+ public void testCopyFromInnerObjects() {
+ ArrayList<Object> list = new ArrayList<>();
+ list.add(new GridBinaryTestClasses.TestObjectAllTypes());
+ list.add(list.get(0));
+
+ GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(list);
+
+ BinaryObjectBuilderImpl builder = builder(toBinary(c));
+ builder.<List>getField("foo").add("!!!");
+
+ BinaryObject res = builder.build();
+
+ GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();
+
+ List deserializedList = (List)deserialized.foo;
+
+ assertSame(deserializedList.get(0), deserializedList.get(1));
+ assertEquals("!!!", deserializedList.get(2));
+ assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
+ }
+
+ /**
+ *
+ */
+ public void testSetBinaryObject() {
+ // Prepare marshaller context.
+ CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects());
+
+ proc.marshal(new GridBinaryTestClasses.TestObjectContainer());
+ proc.marshal(new GridBinaryTestClasses.TestObjectAllTypes());
+
+ // Actual test.
+ BinaryObject binaryObj = builder(GridBinaryTestClasses.TestObjectContainer.class.getName())
+ .setField("foo", toBinary(new GridBinaryTestClasses.TestObjectAllTypes()))
+ .build();
+
+ assertTrue(binaryObj.<GridBinaryTestClasses.TestObjectContainer>deserialize().foo instanceof
+ GridBinaryTestClasses.TestObjectAllTypes);
+ }
+
+ /**
+ *
+ */
+ public void testPlainBinaryObjectCopyFrom() {
+ GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
+
+ BinaryObjectBuilderImpl builder = builder(toBinary(obj));
+ assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
+
+ GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
+ assertTrue(deserialized.plainBinary != null);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromNewObject() {
+ BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName());
+
+ builder.setField("str", "a");
+
+ builder.removeField("str");
+
+ TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObject() {
+ GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ BinaryObjectBuilder builder = builder(toBinary(obj));
+
+ builder.removeField("str");
+
+ BinaryObject binary = builder.build();
+
+ GridBinaryTestClasses.TestObjectAllTypes deserialzied = binary.deserialize();
+
+ assertNull(deserialzied.str);
+ }
+
+ /**
+ *
+ */
+ public void testRemoveFromExistingObjectAfterGet() {
+ GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
+ obj.setDefaultData();
+ obj.enumArr = null;
+
+ BinaryObjectBuilderImpl builder = builder(toBinary(obj));
+
+ builder.getField("i_");
+
+ builder.removeField("str");
+
+ TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
+ }
+
+ /**
+ * @throws IgniteCheckedException If any error occurs.
+ */
+ public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
+ GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
+ outer.inner = new GridBinaryTestClasses.TestObjectInner();
+ outer.inner.outer = outer;
+ outer.foo = "a";
+
+ BinaryObjectBuilder builder = builder(toBinary(outer));
+
+ builder.setField("foo", "b");
+
+ GridBinaryTestClasses.TestObjectOuter res = builder.build().deserialize();
+
+ assertEquals("b", res.foo);
+ assertSame(res, res.inner.outer);
+ }
+
+ /**
+ * @return Binaries.
+ */
+ private IgniteBinary binaries() {
+ return grid(0).binary();
+ }
+
+ /**
+ * @param obj Object.
+ * @return Binary object.
+ */
+ private BinaryObject toBinary(Object obj) {
+ return binaries().toBinary(obj);
+ }
+
+ /**
+ * @return Builder.
+ */
+ private BinaryObjectBuilder builder(String clsName) {
+ return binaries().builder(clsName);
+ }
+
+ /**
+ * @return Builder.
+ */
+ private BinaryObjectBuilderImpl builder(BinaryObject obj) {
+ return (BinaryObjectBuilderImpl)binaries().builder(obj);
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class CustomIdMapper {
+ /** */
+ private String str = "a";
+
+ /** */
+ private int i = 10;
+ }
+
+ /**
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Key {
+ /** */
+ private int i;
+
+ /**
+ */
+ private Key() {
+ // No-op.
+ }
+
+ /**
+ * @param i Index.
+ */
+ private Key(int i) {
+ this.i = i;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ Key key = (Key)o;
+
+ return i == key.i;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return i;
+ }
+ }
+
+ /**
+ */
+ @SuppressWarnings("UnusedDeclaration")
+ private static class Value {
+ /** */
+ private int i;
+
+ /**
+ */
+ private Value() {
+ // No-op.
+ }
+
+ /**
+ * @param i Index.
+ */
+ private Value(int i) {
+ this.i = i;
+ }
+ }
+}
[15/16] ignite git commit: fixed npe -
https://issues.apache.org/jira/browse/IGNITE-2532
Posted by sb...@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-2407
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
+}
[04/16] ignite git commit: IGNITE-2191 - Support classes with the
same simple name for Binary marshaller - Fixes #398.
Posted by sb...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
deleted file mode 100644
index 3b6d0b0..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSelfTest.java
+++ /dev/null
@@ -1,1108 +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.binary;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import junit.framework.TestCase;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.binary.BinaryIdMapper;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryObjectBuilder;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.binary.mutabletest.GridBinaryTestClasses;
-import org.apache.ignite.internal.binary.builder.BinaryObjectBuilderImpl;
-import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-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;
-
-/**
- * Binary builder test.
- */
-@SuppressWarnings("ResultOfMethodCallIgnored")
-public class BinaryObjectBuilderSelfTest extends GridCommonAbstractTest {
- /** */
- private static final Unsafe UNSAFE = GridUnsafe.unsafe();
-
- /** */
- protected static final long BYTE_ARR_OFF = UNSAFE.arrayBaseOffset(byte[].class);
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- BinaryTypeConfiguration customTypeCfg = new BinaryTypeConfiguration();
-
- customTypeCfg.setTypeName(CustomIdMapper.class.getName());
- customTypeCfg.setIdMapper(new BinaryIdMapper() {
- @Override public int typeId(String clsName) {
- return ~BinaryInternalIdMapper.defaultInstance().typeId(clsName);
- }
-
- @Override public int fieldId(int typeId, String fieldName) {
- return typeId + ~BinaryInternalIdMapper.defaultInstance().fieldId(typeId, fieldName);
- }
- });
-
- BinaryConfiguration bCfg = new BinaryConfiguration();
-
- bCfg.setCompactFooter(compactFooter());
-
- bCfg.setTypeConfigurations(Arrays.asList(
- new BinaryTypeConfiguration(Key.class.getName()),
- new BinaryTypeConfiguration(Value.class.getName()),
- new BinaryTypeConfiguration("org.gridgain.grid.internal.util.binary.mutabletest.*"),
- customTypeCfg));
-
- cfg.setBinaryConfiguration(bCfg);
-
- cfg.setMarshaller(new BinaryMarshaller());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- startGrids(1);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTestsStopped() throws Exception {
- stopAllGrids();
- }
-
- /**
- * @return Whether to use compact footer.
- */
- protected boolean compactFooter() {
- return true;
- }
-
- /**
- *
- */
- public void testAllFieldsSerialization() {
- GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- GridBinaryTestClasses.TestObjectAllTypes deserialized = builder(toBinary(obj)).build().deserialize();
-
- GridTestUtils.deepEquals(obj, deserialized);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNullField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(42);
-
- builder.setField("objField", (Object)null);
-
- builder.setField("otherField", "value");
-
- BinaryObject obj = builder.build();
-
- assertNull(obj.field("objField"));
- assertEquals("value", obj.field("otherField"));
- assertEquals(42, obj.hashCode());
-
- builder = builder(obj);
-
- builder.setField("objField", "value");
- builder.setField("otherField", (Object)null);
-
- obj = builder.build();
-
- assertNull(obj.field("otherField"));
- assertEquals("value", obj.field("objField"));
- assertEquals(42, obj.hashCode());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByteField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("byteField", (byte)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((byte) 1, po.<Byte>field("byteField").byteValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShortField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("shortField", (short)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((short)1, po.<Short>field("shortField").shortValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testIntField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("intField", 1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<Integer>field("intField").intValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLongField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("longField", 1L);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1L, po.<Long>field("longField").longValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloatField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("floatField", 1.0f);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1.0f, po.<Float>field("floatField").floatValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDoubleField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("doubleField", 1.0d);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1.0d, po.<Double>field("doubleField").doubleValue(), 0);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCharField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("charField", (char)1);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals((char)1, po.<Character>field("charField").charValue());
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBooleanField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("booleanField", true);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(po.<Boolean>field("booleanField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimalField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("decimalField", BigDecimal.TEN);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(BigDecimal.TEN, po.<BigDecimal>field("decimalField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testStringField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("stringField", "str");
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals("str", po.<String>field("stringField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateField() throws Exception {
- Date date = new Date();
-
- assertEquals(date, builder("C").setField("d", date).build().<Date>field("d"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTimestampField() throws Exception {
- Timestamp ts = new Timestamp(new Date().getTime());
- ts.setNanos(1000);
-
- assertEquals(ts, builder("C").setField("t", ts).build().<Timestamp>field("t"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuidField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- UUID uuid = UUID.randomUUID();
-
- builder.setField("uuidField", uuid);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(uuid, po.<UUID>field("uuidField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testByteArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new byte[] {1, 2, 3}, po.<byte[]>field("byteArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testShortArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("shortArrayField", new short[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new short[] {1, 2, 3}, po.<short[]>field("shortArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testIntArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("intArrayField", new int[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("intArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testLongArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("longArrayField", new long[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new long[] {1, 2, 3}, po.<long[]>field("longArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testFloatArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("floatArrayField", new float[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new float[] {1, 2, 3}, po.<float[]>field("floatArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDoubleArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("doubleArrayField", new double[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new double[] {1, 2, 3}, po.<double[]>field("doubleArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCharArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("charArrayField", new char[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new char[] {1, 2, 3}, po.<char[]>field("charArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBooleanArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("booleanArrayField", new boolean[] {true, false});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- boolean[] arr = po.field("booleanArrayField");
-
- assertEquals(2, arr.length);
-
- assertTrue(arr[0]);
- assertFalse(arr[1]);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDecimalArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("decimalArrayField", new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new BigDecimal[] {BigDecimal.ONE, BigDecimal.TEN}, po.<String[]>field("decimalArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testStringArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("stringArrayField", new String[] {"str1", "str2", "str3"});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(new String[] {"str1", "str2", "str3"}, po.<String[]>field("stringArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testDateArrayField() throws Exception {
- Date date1 = new Date();
- Date date2 = new Date(date1.getTime() + 1000);
-
- Date[] dateArr = new Date[] { date1, date2 };
-
- assertTrue(Arrays.equals(dateArr, builder("C").setField("da", dateArr).build().<Date[]>field("da")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTimestampArrayField() throws Exception {
- Timestamp ts1 = new Timestamp(new Date().getTime());
- Timestamp ts2 = new Timestamp(new Date().getTime() + 1000);
-
- ts1.setNanos(1000);
- ts2.setNanos(2000);
-
- Timestamp[] tsArr = new Timestamp[] { ts1, ts2 };
-
- assertTrue(Arrays.equals(tsArr, builder("C").setField("ta", tsArr).build().<Timestamp[]>field("ta")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testUuidArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- UUID[] arr = new UUID[] {UUID.randomUUID(), UUID.randomUUID()};
-
- builder.setField("uuidArrayField", arr);
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertTrue(Arrays.equals(arr, po.<UUID[]>field("uuidArrayField")));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testObjectField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("objectField", new Value(1));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<BinaryObject>field("objectField").<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testObjectArrayField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("objectArrayField", new Value[] {new Value(1), new Value(2)});
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- Object[] arr = po.field("objectArrayField");
-
- assertEquals(2, arr.length);
-
- assertEquals(1, ((BinaryObject)arr[0]).<Value>deserialize().i);
- assertEquals(2, ((BinaryObject)arr[1]).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCollectionField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("collectionField", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- List<BinaryObject> list = po.field("collectionField");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMapField() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("mapField", F.asMap(new Key(1), new Value(1), new Key(2), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- Map<BinaryObject, BinaryObject> map = po.field("mapField");
-
- assertEquals(2, map.size());
-
- for (Map.Entry<BinaryObject, BinaryObject> e : map.entrySet())
- assertEquals(e.getKey().<Key>deserialize().i, e.getValue().<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSeveralFields() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("i", 111);
- builder.setField("f", 111.111f);
- builder.setField("iArr", new int[] {1, 2, 3});
- builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- assertEquals("class".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(111, po.<Integer>field("i").intValue());
- assertEquals(111.111f, po.<Float>field("f").floatValue(), 0);
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, po.<int[]>field("iArr")));
- assertEquals(1, po.<BinaryObject>field("obj").<Key>deserialize().i);
-
- List<BinaryObject> list = po.field("col");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testOffheapBinary() throws Exception {
- BinaryObjectBuilder builder = builder("Class");
-
- builder.hashCode(100);
-
- builder.setField("i", 111);
- builder.setField("f", 111.111f);
- builder.setField("iArr", new int[] {1, 2, 3});
- builder.setField("obj", new Key(1));
- builder.setField("col", Arrays.asList(new Value(1), new Value(2)));
-
- BinaryObject po = builder.build();
-
- byte[] arr = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).marshal(po);
-
- long ptr = UNSAFE.allocateMemory(arr.length + 5);
-
- try {
- long ptr0 = ptr;
-
- UNSAFE.putBoolean(null, ptr0++, false);
-
- UNSAFE.putInt(ptr0, arr.length);
-
- UNSAFE.copyMemory(arr, BYTE_ARR_OFF, null, ptr0 + 4, arr.length);
-
- BinaryObject offheapObj = (BinaryObject)
- ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects()).unmarshal(ptr, false);
-
- assertEquals(BinaryObjectOffheapImpl.class, offheapObj.getClass());
-
- assertEquals("class".hashCode(), offheapObj.type().typeId());
- assertEquals(100, offheapObj.hashCode());
-
- assertEquals(111, offheapObj.<Integer>field("i").intValue());
- assertEquals(111.111f, offheapObj.<Float>field("f").floatValue(), 0);
- assertTrue(Arrays.equals(new int[] {1, 2, 3}, offheapObj.<int[]>field("iArr")));
- assertEquals(1, offheapObj.<BinaryObject>field("obj").<Key>deserialize().i);
-
- List<BinaryObject> list = offheapObj.field("col");
-
- assertEquals(2, list.size());
-
- assertEquals(1, list.get(0).<Value>deserialize().i);
- assertEquals(2, list.get(1).<Value>deserialize().i);
-
- assertEquals(po, offheapObj);
- assertEquals(offheapObj, po);
- }
- finally {
- UNSAFE.freeMemory(ptr);
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBuildAndDeserialize() throws Exception {
- BinaryObjectBuilder builder = builder(Value.class.getName());
-
- builder.hashCode(100);
-
- builder.setField("i", 1);
-
- BinaryObject po = builder.build();
-
- assertEquals("value".hashCode(), po.type().typeId());
- assertEquals(100, po.hashCode());
-
- assertEquals(1, po.<Value>deserialize().i);
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMetaData2() throws Exception {
- BinaryObjectBuilder builder = builder("org.test.MetaTest2");
-
- builder.setField("objectField", "a", Object.class);
-
- BinaryObject po = builder.build();
-
- BinaryType meta = po.type();
-
- assertEquals("MetaTest2", meta.typeName());
- assertEquals("Object", meta.fieldTypeName("objectField"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMetaData() throws Exception {
- BinaryObjectBuilder builder = builder("org.test.MetaTest");
-
- builder.hashCode(100);
-
- builder.setField("intField", 1);
- builder.setField("byteArrayField", new byte[] {1, 2, 3});
-
- BinaryObject po = builder.build();
-
- BinaryType meta = po.type();
-
- assertEquals("MetaTest", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(2, fields.size());
-
- assertTrue(fields.contains("intField"));
- assertTrue(fields.contains("byteArrayField"));
-
- assertEquals("int", meta.fieldTypeName("intField"));
- assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
-
- builder = builder("org.test.MetaTest");
-
- builder.hashCode(100);
-
- builder.setField("intField", 2);
- builder.setField("uuidField", UUID.randomUUID());
-
- po = builder.build();
-
- meta = po.type();
-
- assertEquals("MetaTest", meta.typeName());
-
- fields = meta.fieldNames();
-
- assertEquals(3, fields.size());
-
- assertTrue(fields.contains("intField"));
- assertTrue(fields.contains("byteArrayField"));
- assertTrue(fields.contains("uuidField"));
-
- assertEquals("int", meta.fieldTypeName("intField"));
- assertEquals("byte[]", meta.fieldTypeName("byteArrayField"));
- assertEquals("UUID", meta.fieldTypeName("uuidField"));
- }
-
- /**
- *
- */
- public void testGetFromCopiedObj() {
- BinaryObject objStr = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName()).setField("str", "aaa").build();
-
- BinaryObjectBuilderImpl builder = builder(objStr);
- assertEquals("aaa", builder.getField("str"));
-
- builder.setField("str", "bbb");
- assertEquals("bbb", builder.getField("str"));
-
- assertNull(builder.getField("i_"));
- TestCase.assertEquals("bbb", builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- @SuppressWarnings("unchecked")
- public void testCopyFromInnerObjects() {
- ArrayList<Object> list = new ArrayList<>();
- list.add(new GridBinaryTestClasses.TestObjectAllTypes());
- list.add(list.get(0));
-
- GridBinaryTestClasses.TestObjectContainer c = new GridBinaryTestClasses.TestObjectContainer(list);
-
- BinaryObjectBuilderImpl builder = builder(toBinary(c));
- builder.<List>getField("foo").add("!!!");
-
- BinaryObject res = builder.build();
-
- GridBinaryTestClasses.TestObjectContainer deserialized = res.deserialize();
-
- List deserializedList = (List)deserialized.foo;
-
- assertSame(deserializedList.get(0), deserializedList.get(1));
- assertEquals("!!!", deserializedList.get(2));
- assertTrue(deserializedList.get(0) instanceof GridBinaryTestClasses.TestObjectAllTypes);
- }
-
- /**
- *
- */
- public void testSetBinaryObject() {
- // Prepare marshaller context.
- CacheObjectBinaryProcessorImpl proc = ((CacheObjectBinaryProcessorImpl)(grid(0)).context().cacheObjects());
-
- proc.marshal(new GridBinaryTestClasses.TestObjectContainer());
- proc.marshal(new GridBinaryTestClasses.TestObjectAllTypes());
-
- // Actual test.
- BinaryObject binaryObj = builder(GridBinaryTestClasses.TestObjectContainer.class.getName())
- .setField("foo", toBinary(new GridBinaryTestClasses.TestObjectAllTypes()))
- .build();
-
- assertTrue(binaryObj.<GridBinaryTestClasses.TestObjectContainer>deserialize().foo instanceof
- GridBinaryTestClasses.TestObjectAllTypes);
- }
-
- /**
- *
- */
- public void testPlainBinaryObjectCopyFrom() {
- GridBinaryTestClasses.TestObjectPlainBinary obj = new GridBinaryTestClasses.TestObjectPlainBinary(toBinary(new GridBinaryTestClasses.TestObjectAllTypes()));
-
- BinaryObjectBuilderImpl builder = builder(toBinary(obj));
- assertTrue(builder.getField("plainBinary") instanceof BinaryObject);
-
- GridBinaryTestClasses.TestObjectPlainBinary deserialized = builder.build().deserialize();
- assertTrue(deserialized.plainBinary != null);
- }
-
- /**
- *
- */
- public void testRemoveFromNewObject() {
- BinaryObjectBuilder builder = builder(GridBinaryTestClasses.TestObjectAllTypes.class.getName());
-
- builder.setField("str", "a");
-
- builder.removeField("str");
-
- TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
- }
-
- /**
- *
- */
- public void testRemoveFromExistingObject() {
- GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- BinaryObjectBuilder builder = builder(toBinary(obj));
-
- builder.removeField("str");
-
- BinaryObject binary = builder.build();
-
- GridBinaryTestClasses.TestObjectAllTypes deserialzied = binary.deserialize();
-
- assertNull(deserialzied.str);
- }
-
- /**
- *
- */
- public void testRemoveFromExistingObjectAfterGet() {
- GridBinaryTestClasses.TestObjectAllTypes obj = new GridBinaryTestClasses.TestObjectAllTypes();
- obj.setDefaultData();
- obj.enumArr = null;
-
- BinaryObjectBuilderImpl builder = builder(toBinary(obj));
-
- builder.getField("i_");
-
- builder.removeField("str");
-
- TestCase.assertNull(builder.build().<GridBinaryTestClasses.TestObjectAllTypes>deserialize().str);
- }
-
- /**
- * @throws IgniteCheckedException If any error occurs.
- */
- public void testDontBrokeCyclicDependency() throws IgniteCheckedException {
- GridBinaryTestClasses.TestObjectOuter outer = new GridBinaryTestClasses.TestObjectOuter();
- outer.inner = new GridBinaryTestClasses.TestObjectInner();
- outer.inner.outer = outer;
- outer.foo = "a";
-
- BinaryObjectBuilder builder = builder(toBinary(outer));
-
- builder.setField("foo", "b");
-
- GridBinaryTestClasses.TestObjectOuter res = builder.build().deserialize();
-
- assertEquals("b", res.foo);
- assertSame(res, res.inner.outer);
- }
-
- /**
- * @return Binaries.
- */
- private IgniteBinary binaries() {
- return grid(0).binary();
- }
-
- /**
- * @param obj Object.
- * @return Binary object.
- */
- private BinaryObject toBinary(Object obj) {
- return binaries().toBinary(obj);
- }
-
- /**
- * @return Builder.
- */
- private BinaryObjectBuilder builder(String clsName) {
- return binaries().builder(clsName);
- }
-
- /**
- * @return Builder.
- */
- private BinaryObjectBuilderImpl builder(BinaryObject obj) {
- return (BinaryObjectBuilderImpl)binaries().builder(obj);
- }
-
- /**
- *
- */
- @SuppressWarnings("UnusedDeclaration")
- private static class CustomIdMapper {
- /** */
- private String str = "a";
-
- /** */
- private int i = 10;
- }
-
- /**
- */
- @SuppressWarnings("UnusedDeclaration")
- private static class Key {
- /** */
- private int i;
-
- /**
- */
- private Key() {
- // No-op.
- }
-
- /**
- * @param i Index.
- */
- private Key(int i) {
- this.i = i;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (o == null || getClass() != o.getClass())
- return false;
-
- Key key = (Key)o;
-
- return i == key.i;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- return i;
- }
- }
-
- /**
- */
- @SuppressWarnings("UnusedDeclaration")
- private static class Value {
- /** */
- private int i;
-
- /**
- */
- private Value() {
- // No-op.
- }
-
- /**
- * @param i Index.
- */
- private Value(int i) {
- this.i = i;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
new file mode 100644
index 0000000..da87072
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import org.apache.ignite.binary.BinaryBasicIdMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+/**
+ * Binary builder test.
+ */
+@SuppressWarnings("ResultOfMethodCallIgnored")
+public class BinaryObjectBuilderSimpleNameLowerCaseMappersSelfTest extends BinaryObjectBuilderDefaultMappersSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
+
+ bCfg.setIdMapper(new BinaryBasicIdMapper(true));
+ bCfg.setNameMapper(new BinaryBasicNameMapper(true));
+
+ return cfg;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
new file mode 100644
index 0000000..8f2df9e
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/BinarySimpleNameTestPropertySelfTest.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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;
+
+import org.apache.ignite.IgniteBinary;
+import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.binary.BinaryObjectBuilder;
+import org.apache.ignite.testframework.config.GridTestProperties;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER;
+import static org.apache.ignite.testframework.config.GridTestProperties.MARSH_CLASS_NAME;
+
+/**
+ * Tests testing framewrok, epecially BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER test property.
+ */
+public class BinarySimpleNameTestPropertySelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPropertyEnabled() throws Exception {
+ String useSimpleNameBackup = GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER);
+
+ try {
+ GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+
+ checkProperty("TestClass");
+ }
+ finally {
+ if (useSimpleNameBackup != null)
+ GridTestProperties.setProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER, "true");
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testPropertyDisabled() throws Exception {
+ checkProperty("org.ignite.test.TestClass");
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testBinaryDisabled() throws Exception {
+ assertNull(startGrid().binary());
+ }
+
+ /**
+ * @param expTypeName Type name.
+ * @throws Exception If failed.
+ */
+ private void checkProperty(String expTypeName) throws Exception {
+ String marshBackup = GridTestProperties.getProperty(MARSH_CLASS_NAME);
+
+ try {
+ GridTestProperties.setProperty(MARSH_CLASS_NAME, BinaryMarshaller.class.getName());
+
+ IgniteBinary binary = startGrid().binary();
+
+ BinaryObjectBuilder builder = binary.builder("org.ignite.test.TestClass");
+
+ BinaryObject bObj = builder.build();
+
+ assertEquals(expTypeName, bObj.type().typeName());
+ }
+ finally {
+ if (marshBackup != null)
+ GridTestProperties.setProperty(MARSH_CLASS_NAME, marshBackup);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
deleted file mode 100644
index 5c5d6c3..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMetaDataSelfTest.java
+++ /dev/null
@@ -1,371 +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.binary;
-
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.configuration.BinaryConfiguration;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.Binarylizable;
-import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
-import org.apache.ignite.binary.BinaryRawWriter;
-import org.apache.ignite.binary.BinaryReader;
-import org.apache.ignite.binary.BinaryWriter;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Binary meta data test.
- */
-public class GridBinaryMetaDataSelfTest extends GridCommonAbstractTest {
- /** */
- private static int idx;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- BinaryConfiguration bCfg = new BinaryConfiguration();
-
- bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
-
- cfg.setBinaryConfiguration(bCfg);
-
- cfg.setMarshaller(new BinaryMarshaller());
-
- CacheConfiguration ccfg = new CacheConfiguration();
-
- cfg.setCacheConfiguration(ccfg);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- idx = 0;
-
- startGrid();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopGrid();
- }
-
- /**
- * @return Binaries API.
- */
- protected IgniteBinary binaries() {
- return grid().binary();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testGetAll() throws Exception {
- binaries().toBinary(new TestObject2());
-
- Collection<BinaryType> metas = binaries().types();
-
- assertEquals(2, metas.size());
-
- for (BinaryType meta : metas) {
- Collection<String> fields;
-
- switch (meta.typeName()) {
- case "TestObject1":
- fields = meta.fieldNames();
-
- assertEquals(7, fields.size());
-
- assertTrue(fields.contains("intVal"));
- assertTrue(fields.contains("strVal"));
- assertTrue(fields.contains("arrVal"));
- assertTrue(fields.contains("obj1Val"));
- assertTrue(fields.contains("obj2Val"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("int", meta.fieldTypeName("intVal"));
- assertEquals("String", meta.fieldTypeName("strVal"));
- assertEquals("byte[]", meta.fieldTypeName("arrVal"));
- assertEquals("Object", meta.fieldTypeName("obj1Val"));
- assertEquals("Object", meta.fieldTypeName("obj2Val"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-
- break;
-
- case "TestObject2":
- fields = meta.fieldNames();
-
- assertEquals(7, fields.size());
-
- assertTrue(fields.contains("boolVal"));
- assertTrue(fields.contains("dateVal"));
- assertTrue(fields.contains("uuidArrVal"));
- assertTrue(fields.contains("objVal"));
- assertTrue(fields.contains("mapVal"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("boolean", meta.fieldTypeName("boolVal"));
- assertEquals("Date", meta.fieldTypeName("dateVal"));
- assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
- assertEquals("Object", meta.fieldTypeName("objVal"));
- assertEquals("Map", meta.fieldTypeName("mapVal"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
-
- break;
-
- default:
- assert false : meta.typeName();
- }
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNoConfiguration() throws Exception {
- binaries().toBinary(new TestObject3());
-
- assertNotNull(binaries().type(TestObject3.class));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testReflection() throws Exception {
- BinaryType meta = binaries().type(TestObject1.class);
-
- assertNotNull(meta);
-
- assertEquals("TestObject1", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(7, fields.size());
-
- assertTrue(fields.contains("intVal"));
- assertTrue(fields.contains("strVal"));
- assertTrue(fields.contains("arrVal"));
- assertTrue(fields.contains("obj1Val"));
- assertTrue(fields.contains("obj2Val"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("int", meta.fieldTypeName("intVal"));
- assertEquals("String", meta.fieldTypeName("strVal"));
- assertEquals("byte[]", meta.fieldTypeName("arrVal"));
- assertEquals("Object", meta.fieldTypeName("obj1Val"));
- assertEquals("Object", meta.fieldTypeName("obj2Val"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testBinaryMarshalAware() throws Exception {
- binaries().toBinary(new TestObject2());
-
- BinaryType meta = binaries().type(TestObject2.class);
-
- assertNotNull(meta);
-
- assertEquals("TestObject2", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(7, fields.size());
-
- assertTrue(fields.contains("boolVal"));
- assertTrue(fields.contains("dateVal"));
- assertTrue(fields.contains("uuidArrVal"));
- assertTrue(fields.contains("objVal"));
- assertTrue(fields.contains("mapVal"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("boolean", meta.fieldTypeName("boolVal"));
- assertEquals("Date", meta.fieldTypeName("dateVal"));
- assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
- assertEquals("Object", meta.fieldTypeName("objVal"));
- assertEquals("Map", meta.fieldTypeName("mapVal"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testMerge() throws Exception {
- binaries().toBinary(new TestObject2());
-
- idx = 1;
-
- binaries().toBinary(new TestObject2());
-
- BinaryType meta = binaries().type(TestObject2.class);
-
- assertNotNull(meta);
-
- assertEquals("TestObject2", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(9, fields.size());
-
- assertTrue(fields.contains("boolVal"));
- assertTrue(fields.contains("dateVal"));
- assertTrue(fields.contains("uuidArrVal"));
- assertTrue(fields.contains("objVal"));
- assertTrue(fields.contains("mapVal"));
- assertTrue(fields.contains("charVal"));
- assertTrue(fields.contains("colVal"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("boolean", meta.fieldTypeName("boolVal"));
- assertEquals("Date", meta.fieldTypeName("dateVal"));
- assertEquals("UUID[]", meta.fieldTypeName("uuidArrVal"));
- assertEquals("Object", meta.fieldTypeName("objVal"));
- assertEquals("Map", meta.fieldTypeName("mapVal"));
- assertEquals("char", meta.fieldTypeName("charVal"));
- assertEquals("Collection", meta.fieldTypeName("colVal"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testSerializedObject() throws Exception {
- TestObject1 obj = new TestObject1();
-
- obj.intVal = 10;
- obj.strVal = "str";
- obj.arrVal = new byte[] {2, 4, 6};
- obj.obj1Val = null;
- obj.obj2Val = new TestObject2();
- obj.decVal = BigDecimal.ZERO;
- obj.decArrVal = new BigDecimal[] { BigDecimal.ONE };
-
- BinaryObject po = binaries().toBinary(obj);
-
- info(po.toString());
-
- BinaryType meta = po.type();
-
- assertNotNull(meta);
-
- assertEquals("TestObject1", meta.typeName());
-
- Collection<String> fields = meta.fieldNames();
-
- assertEquals(7, fields.size());
-
- assertTrue(fields.contains("intVal"));
- assertTrue(fields.contains("strVal"));
- assertTrue(fields.contains("arrVal"));
- assertTrue(fields.contains("obj1Val"));
- assertTrue(fields.contains("obj2Val"));
- assertTrue(fields.contains("decVal"));
- assertTrue(fields.contains("decArrVal"));
-
- assertEquals("int", meta.fieldTypeName("intVal"));
- assertEquals("String", meta.fieldTypeName("strVal"));
- assertEquals("byte[]", meta.fieldTypeName("arrVal"));
- assertEquals("Object", meta.fieldTypeName("obj1Val"));
- assertEquals("Object", meta.fieldTypeName("obj2Val"));
- assertEquals("decimal", meta.fieldTypeName("decVal"));
- assertEquals("decimal[]", meta.fieldTypeName("decArrVal"));
- }
-
- /**
- */
- @SuppressWarnings("UnusedDeclaration")
- private static class TestObject1 {
- /** */
- private int intVal;
-
- /** */
- private String strVal;
-
- /** */
- private byte[] arrVal;
-
- /** */
- private TestObject1 obj1Val;
-
- /** */
- private TestObject2 obj2Val;
-
- /** */
- private BigDecimal decVal;
-
- /** */
- private BigDecimal[] decArrVal;
- }
-
- /**
- */
- private static class TestObject2 implements Binarylizable {
- /** {@inheritDoc} */
- @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException {
- writer.writeBoolean("boolVal", false);
- writer.writeDate("dateVal", new Date());
- writer.writeUuidArray("uuidArrVal", null);
- writer.writeObject("objVal", null);
- writer.writeMap("mapVal", new HashMap<>());
- writer.writeDecimal("decVal", BigDecimal.ZERO);
- writer.writeDecimalArray("decArrVal", new BigDecimal[] { BigDecimal.ONE });
-
- if (idx == 1) {
- writer.writeChar("charVal", (char)0);
- writer.writeCollection("colVal", null);
- }
-
- BinaryRawWriter raw = writer.rawWriter();
-
- raw.writeChar((char)0);
- raw.writeCollection(null);
- }
-
- /** {@inheritDoc} */
- @Override public void readBinary(BinaryReader reader) throws BinaryObjectException {
- // No-op.
- }
- }
-
- /**
- */
- @SuppressWarnings("UnusedDeclaration")
- private static class TestObject3 {
- /** */
- private int intVal;
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/62502b2c/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
index ae0cfa0..d0d63b3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
@@ -17,31 +17,67 @@
package org.apache.ignite.internal.binary;
+import java.util.Arrays;
import java.util.Collection;
+import java.util.Map;
import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryBasicIdMapper;
import org.apache.ignite.binary.BinaryIdMapper;
+import org.apache.ignite.binary.BinaryNameMapper;
+import org.apache.ignite.binary.BinaryBasicNameMapper;
import org.apache.ignite.binary.BinarySerializer;
import org.apache.ignite.binary.BinaryTypeConfiguration;
import org.apache.ignite.configuration.BinaryConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass1;
+import org.apache.ignite.internal.binary.test.GridBinaryTestClass2;
import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.logger.NullLogger;
import org.apache.ignite.marshaller.MarshallerContextTestImpl;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import java.util.Arrays;
-import java.util.Map;
-
/**
* Wildcards test.
*/
public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
+ /** */
+ public static final String CLASS1_FULL_NAME = GridBinaryTestClass1.class.getName();
+
+ /** */
+ public static final String CLASS2_FULL_NAME = GridBinaryTestClass2.class.getName();
+
+ /** */
+ public static final String INNER_CLASS_FULL_NAME = GridBinaryTestClass1.class.getName() + "$InnerClass";
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesFullNameMapper() throws Exception {
+ checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesSimpleNameMapper() throws Exception {
+ checkClassNames(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesMixedMappers() throws Exception {
+ checkClassNames(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(true));
+ }
+
/**
* @throws Exception If failed.
+ * @param nameMapper Name mapper.
+ * @param mapper ID mapper.
*/
- public void testClassNames() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ private void checkClassNames(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws Exception {
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
@@ -52,16 +88,16 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
- assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
- assertTrue(typeIds.containsKey("innerclass".hashCode()));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
}
/**
* @throws Exception If failed.
*/
- public void testClassNamesWithMapper() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ public void testClassNamesCustomMappers() throws Exception {
+ BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -84,20 +120,37 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
- assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+ assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
- public void testTypeConfigurations() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ public void testTypeConfigurationsSimpleNameIdMapper() throws Exception {
+ checkTypeConfigurations(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurationsFullNameIdMapper() throws Exception {
+ checkTypeConfigurations(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ *
+ * @param nameMapper Name mapper.
+ * @param idMapper ID mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkTypeConfigurations(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
@@ -108,16 +161,31 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
- assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
- assertTrue(typeIds.containsKey("innerclass".hashCode()));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+ assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
+ assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, idMapper)));
+ }
+
+ /**
+ * @param typeName Type name.
+ * @param nameMapper Name mapper.
+ * @param mapper ID mapper. @return Type ID.
+ */
+ private int typeId(String typeName, BinaryNameMapper nameMapper, BinaryIdMapper mapper) {
+ if (mapper == null)
+ mapper = BinaryContext.defaultIdMapper();
+
+ if (nameMapper == null)
+ nameMapper = BinaryContext.defaultNameMapper();
+
+ return mapper.typeId(nameMapper.typeName(typeName));
}
/**
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapper() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -140,20 +208,20 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
- assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+ assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -176,22 +244,39 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
- assertEquals(500, typeMappers.get("InnerClass").typeId("InnerClass"));
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+ assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
- public void testOverride() throws Exception {
+ public void testOverrideIdMapperSimpleNameMapper() throws Exception {
+ checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOverrideIdMapperFullNameMapper() throws Exception {
+ checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ *
+ * @param nameMapper Name mapper.
+ * @param mapper Mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkOverrideIdMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
- typeCfg.setTypeName("GridBinaryTestClass2");
+ typeCfg.setTypeName(CLASS2_FULL_NAME);
typeCfg.setIdMapper(new BinaryIdMapper() {
@Override public int typeId(String clsName) {
return 100;
@@ -202,7 +287,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
typeCfg));
@@ -212,20 +297,90 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
- assertTrue(typeIds.containsKey("innerclass".hashCode()));
- assertFalse(typeIds.containsKey(100));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey(100));
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
- assertEquals(100, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+ assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
- public void testClassNamesJar() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ public void testOverrideNameMapperSimpleNameMapper() throws Exception {
+ checkOverrideNameMapper(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOverrideNameMapperFullNameMapper() throws Exception {
+ checkOverrideNameMapper(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ *
+ * @param nameMapper Name mapper.
+ * @param mapper Mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkOverrideNameMapper(BinaryNameMapper nameMapper, BinaryIdMapper mapper) throws IgniteCheckedException {
+ BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
+
+ typeCfg.setTypeName(CLASS2_FULL_NAME);
+ typeCfg.setNameMapper(new BinaryNameMapper() {
+ @Override public String typeName(String clsName) {
+ return "type2";
+ }
+
+ @Override public String fieldName(String fieldName) {
+ return "field2";
+ }
+ });
+
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, mapper, Arrays.asList(
+ new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
+ typeCfg));
+
+ BinaryContext ctx = binaryContext(marsh);
+
+ Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+
+ assertEquals(3, typeIds.size());
+
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+ assertTrue(typeIds.containsKey("type2".hashCode()));
+
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
+
+ assertEquals("type2", typeMappers.get(CLASS2_FULL_NAME).nameMapper().typeName(CLASS2_FULL_NAME));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesJarFullNameMapper() throws Exception {
+ checkClassNamesJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testClassNamesJarSimpleNameMapper() throws Exception {
+ checkClassNamesJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ *
+ * @param nameMapper Name mapper.
+ * @param idMapper Mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkClassNamesJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
@@ -236,15 +391,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
- assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+ assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
}
/**
* @throws Exception If failed.
*/
- public void testClassNamesWithMapperJar() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ public void testClassNamesWithCustomMapperJar() throws Exception {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -265,19 +420,40 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTypeConfigurationsJarSimpleNameMapper() throws Exception {
+ checkTypeConfigurationJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
}
/**
* @throws Exception If failed.
*/
- public void testTypeConfigurationsJar() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ public void testTypeConfigurationsJarFullNameMapper() throws Exception {
+ checkTypeConfigurationJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ *
+ * @param nameMapper
+ * @param idMapper Mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkTypeConfigurationJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper)
+ throws IgniteCheckedException {
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
new BinaryTypeConfiguration("unknown.*")
));
@@ -288,15 +464,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
- assertTrue(typeIds.containsKey("gridbinarytestclass2".hashCode()));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+ assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
}
/**
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithGlobalMapperJar() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -317,19 +493,22 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
- BinaryMarshaller marsh = binaryMarshaller(new BinaryIdMapper() {
+ BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {
@SuppressWarnings("IfMayBeConditional")
@Override public int typeId(String clsName) {
if (clsName.endsWith("1"))
@@ -350,18 +529,38 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryContext ctx = binaryContext(marsh);
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(300, typeMappers.get("GridBinaryTestClass1").typeId("GridBinaryTestClass1"));
- assertEquals(400, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
+
+ assertFalse(((BinaryBasicNameMapper)typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
+ assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
/**
* @throws Exception If failed.
*/
- public void testOverrideJar() throws Exception {
+ public void testOverrideJarSimpleNameMapper() throws Exception {
+ checkOverrideJar(new BinaryBasicNameMapper(true), new BinaryBasicIdMapper(true));
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOverrideJarFullNameMapper() throws Exception {
+ checkOverrideJar(new BinaryBasicNameMapper(false), new BinaryBasicIdMapper(false));
+ }
+
+ /**
+ *
+ * @param nameMapper Name mapper.
+ * @param idMapper Mapper.
+ * @throws IgniteCheckedException If failed.
+ */
+ private void checkOverrideJar(BinaryNameMapper nameMapper, BinaryIdMapper idMapper) throws IgniteCheckedException {
BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration(
"org.apache.ignite.internal.binary.test.GridBinaryTestClass2");
@@ -375,7 +574,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
}
});
- BinaryMarshaller marsh = binaryMarshaller(Arrays.asList(
+ BinaryMarshaller marsh = binaryMarshaller(nameMapper, idMapper, Arrays.asList(
new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"),
typeCfg));
@@ -385,13 +584,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
assertEquals(3, typeIds.size());
- assertTrue(typeIds.containsKey("gridbinarytestclass1".hashCode()));
+ assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
- Map<String, BinaryIdMapper> typeMappers = U.field(ctx, "typeMappers");
+ Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
assertEquals(3, typeMappers.size());
- assertEquals(100, typeMappers.get("GridBinaryTestClass2").typeId("GridBinaryTestClass2"));
+ assertEquals(nameMapper, typeMappers.get(CLASS2_FULL_NAME).nameMapper());
+ assertEquals(100, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
/**
@@ -423,9 +623,10 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
/**
*
*/
- protected BinaryMarshaller binaryMarshaller(BinaryIdMapper mapper, Collection<BinaryTypeConfiguration> cfgs)
+ protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper,
+ Collection<BinaryTypeConfiguration> cfgs)
throws IgniteCheckedException {
- return binaryMarshaller(mapper, null, cfgs);
+ return binaryMarshaller(nameMapper, mapper, null, cfgs);
}
/**
@@ -433,10 +634,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
*/
protected BinaryMarshaller binaryMarshaller(BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs)
throws IgniteCheckedException {
- return binaryMarshaller(null, serializer, cfgs);
+ return binaryMarshaller(null, null, serializer, cfgs);
}
+ /**
+ *
+ */
protected BinaryMarshaller binaryMarshaller(
+ BinaryNameMapper nameMapper,
BinaryIdMapper mapper,
BinarySerializer serializer,
Collection<BinaryTypeConfiguration> cfgs
@@ -445,6 +650,7 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest {
BinaryConfiguration bCfg = new BinaryConfiguration();
+ bCfg.setNameMapper(nameMapper);
bCfg.setIdMapper(mapper);
bCfg.setSerializer(serializer);
[13/16] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by sb...@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
[14/16] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by sb...@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-2407
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();
[16/16] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-2407
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-2407
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bc388fde
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bc388fde
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bc388fde
Branch: refs/heads/ignite-2407
Commit: bc388fde8dffa062feb039c177a74fee44577ed5
Parents: 4ac9e3f 4035d40
Author: sboikov <sb...@gridgain.com>
Authored: Tue Feb 2 20:16:41 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Feb 2 20:16:41 2016 +0300
----------------------------------------------------------------------
.gitignore | 1 +
.../java/org/apache/ignite/IgniteCache.java | 45 +-
.../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 +-
.../configuration/BinaryConfiguration.java | 28 +
.../configuration/IgniteConfiguration.java | 8 +-
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../internal/binary/BinaryClassDescriptor.java | 23 +-
.../ignite/internal/binary/BinaryContext.java | 347 ++++--
.../internal/binary/BinaryEnumObjectImpl.java | 13 +-
.../internal/binary/BinaryInternalIdMapper.java | 161 ---
.../internal/binary/BinaryInternalMapper.java | 131 ++
.../binary/BinaryMetadataCollector.java | 22 +-
.../internal/binary/BinaryReaderExImpl.java | 14 +-
.../internal/binary/BinaryWriterExImpl.java | 30 +-
.../internal/binary/GridBinaryMarshaller.java | 23 +-
.../binary/builder/BinaryBuilderSerializer.java | 16 +-
.../binary/builder/BinaryObjectBuilderImpl.java | 2 +-
.../processors/cache/CacheEntryImplEx.java | 14 +-
.../processors/cache/GridCacheAdapter.java | 297 ++++-
.../processors/cache/GridCacheContext.java | 33 +-
.../processors/cache/GridCacheMapEntry.java | 2 +-
.../processors/cache/GridCacheProcessor.java | 43 +-
.../processors/cache/GridCacheProxyImpl.java | 51 +
.../processors/cache/IgniteCacheProxy.java | 51 +
.../processors/cache/IgniteInternalCache.java | 85 ++
.../binary/CacheObjectBinaryProcessorImpl.java | 123 +-
.../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 +-
.../processors/platform/PlatformIgnition.java | 6 +-
.../platform/PlatformNoopProcessor.java | 15 +
.../processors/platform/PlatformProcessor.java | 25 +
.../platform/PlatformProcessorImpl.java | 34 +-
.../platform/cache/PlatformCache.java | 16 +-
.../cpp/PlatformCppConfigurationClosure.java | 32 +
.../dotnet/PlatformDotNetCacheStore.java | 39 +-
.../PlatformDotNetConfigurationClosure.java | 80 +-
.../utils/PlatformConfigurationUtils.java | 621 ++++++++++
.../platform/utils/PlatformUtils.java | 52 +-
.../ignite/internal/util/IgniteUtils.java | 7 +
.../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 +-
.../binary/BinaryBasicIdMapperSelfTest.java | 51 +
.../binary/BinaryBasicNameMapperSelfTest.java | 50 +
.../BinaryConfigurationConsistencySelfTest.java | 231 ++++
.../internal/binary/BinaryEnumsSelfTest.java | 12 +-
.../binary/BinaryMarshallerSelfTest.java | 508 ++++++--
.../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 +
...BuilderNonCompactDefaultMappersSelfTest.java | 30 +
.../BinaryObjectBuilderNonCompactSelfTest.java | 30 -
...mpactSimpleNameLowerCaseMappersSelfTest.java | 31 +
.../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 +++
.../GridCacheConditionalDeploymentSelfTest.java | 4 +-
.../GridCacheInterceptorAbstractSelfTest.java | 172 ++-
.../GridCacheBinaryObjectsAbstractSelfTest.java | 17 +-
.../GridCacheBinaryStoreAbstractSelfTest.java | 10 +
...naryStoreBinariesDefaultMappersSelfTest.java | 81 ++
.../GridCacheBinaryStoreBinariesSelfTest.java | 66 -
...yStoreBinariesSimpleNameMappersSelfTest.java | 40 +
...GridCacheDhtEvictionNearReadersSelfTest.java | 2 +-
.../GridCacheReplicatedPreloadSelfTest.java | 108 ++
.../config/GridTestProperties.java | 5 +-
.../testframework/junits/GridAbstractTest.java | 23 +-
.../multijvm/IgniteCacheProcessProxy.java | 59 +-
.../ignite/testsuites/IgniteBasicTestSuite.java | 2 +-
.../testsuites/IgniteBinaryBasicTestSuite.java | 95 ++
...ctsSimpleNameMapperComputeGridTestSuite.java | 38 +
.../IgniteBinaryObjectsTestSuite.java | 34 +-
...iteBinarySimpleNameMapperBasicTestSuite.java | 38 +
...rySimpleNameMapperCacheFullApiTestSuite.java | 39 +
.../testsuites/IgniteCacheTestSuite4.java | 12 +
.../tests/p2p/CacheDeploymentTestEnumValue.java | 47 +
.../p2p/CacheDeploymentTestStoreFactory.java | 113 ++
.../IgniteBinaryCacheQueryTestSuite.java | 186 +--
...narySimpleNameMapperCacheQueryTestSuite.java | 38 +
.../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 +-
.../Config/Compute/compute-grid2.xml | 21 +
.../Config/Compute/compute-grid3.xml | 31 +-
.../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 +-
.../visor/commands/node/VisorNodeCommand.scala | 1 +
.../scala/org/apache/ignite/visor/visor.scala | 3 +-
.../config/benchmark-multicast.properties | 7 +
.../org/apache/ignite/yardstick/IgniteNode.java | 3 +
.../IgniteGetEntriesPutAllTxBenchmark.java | 73 ++
.../cache/IgnitePutGetEntryBenchmark.java | 47 +
.../cache/IgnitePutGetEntryTxBenchmark.java | 73 ++
parent/pom.xml | 1 +
196 files changed, 12542 insertions(+), 2888 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bc388fde/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
[11/16] ignite git commit: IGNITE-1906: .NET: Implemented
programmatic configuration.
Posted by sb...@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>