You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2017/04/12 02:50:46 UTC
[1/7] ignite git commit: IGNITE-4941: Removed old
GridDhtPartitionSupplyMessage.
Repository: ignite
Updated Branches:
refs/heads/ignite-1192 99434116e -> 1cd089699
IGNITE-4941: Removed old GridDhtPartitionSupplyMessage.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/aeacad6b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/aeacad6b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/aeacad6b
Branch: refs/heads/ignite-1192
Commit: aeacad6b87ac95dd2f5da525573d6fa58f4e51db
Parents: edfa353
Author: devozerov <vo...@gridgain.com>
Authored: Tue Apr 11 12:18:52 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Tue Apr 11 12:18:52 2017 +0300
----------------------------------------------------------------------
.../communication/GridIoMessageFactory.java | 8 +-
.../GridCachePartitionExchangeManager.java | 7 +-
.../processors/cache/GridCachePreloader.java | 4 +-
.../cache/GridCachePreloaderAdapter.java | 4 +-
.../dht/preloader/GridDhtPartitionDemander.java | 2 +-
.../dht/preloader/GridDhtPartitionSupplier.java | 310 +--------------
.../GridDhtPartitionSupplyMessage.java | 99 ++---
.../GridDhtPartitionSupplyMessageV2.java | 384 -------------------
.../dht/preloader/GridDhtPreloader.java | 3 +-
.../resources/META-INF/classnames.properties | 1 -
.../CacheLateAffinityAssignmentTest.java | 6 +-
.../IgniteCacheReadFromBackupTest.java | 6 +-
.../atomic/IgniteCacheAtomicProtocolTest.java | 3 +-
13 files changed, 60 insertions(+), 777 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 737d047..8aac56d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -86,7 +86,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleRequest;
@@ -498,11 +497,6 @@ public class GridIoMessageFactory implements MessageFactory {
break;
- case 45:
- msg = new GridDhtPartitionSupplyMessage();
-
- break;
-
case 46:
msg = new GridDhtPartitionsFullMessage();
@@ -824,7 +818,7 @@ public class GridIoMessageFactory implements MessageFactory {
break;
case 114:
- msg = new GridDhtPartitionSupplyMessageV2();
+ msg = new GridDhtPartitionSupplyMessage();
break;
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 231dff8..885106d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -67,8 +67,7 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.Gri
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
@@ -394,9 +393,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
GridCacheContext cacheCtx = cctx.cacheContext(m.cacheId);
if (cacheCtx != null) {
- if (m instanceof GridDhtPartitionSupplyMessageV2)
+ if (m instanceof GridDhtPartitionSupplyMessage)
cacheCtx.preloader().handleSupplyMessage(
- idx, id, (GridDhtPartitionSupplyMessageV2)m);
+ idx, id, (GridDhtPartitionSupplyMessage)m);
else if (m instanceof GridDhtPartitionDemandMessage)
cacheCtx.preloader().handleDemandMessage(
idx, id, (GridDhtPartitionDemandMessage)m);
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
index 0c28691..df0d71d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloader.java
@@ -25,7 +25,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloaderAssignments;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -168,7 +168,7 @@ public interface GridCachePreloader {
* @param id Node Id.
* @param s Supply message.
*/
- public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessageV2 s);
+ public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessage s);
/**
* Handles Demand message.
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
index d7ec288..ac3b6cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePreloaderAdapter.java
@@ -27,7 +27,7 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloaderAssignments;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
@@ -134,7 +134,7 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
}
/** {@inheritDoc} */
- @Override public void handleSupplyMessage(int idx, UUID id, GridDhtPartitionSupplyMessageV2 s) {
+ @Override public void handleSupplyMessage(int idx, UUID id, GridDhtPartitionSupplyMessage s) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index d5f2246..f8114cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -541,7 +541,7 @@ public class GridDhtPartitionDemander {
public void handleSupplyMessage(
int idx,
final UUID id,
- final GridDhtPartitionSupplyMessageV2 supply
+ final GridDhtPartitionSupplyMessage supply
) {
AffinityTopologyVersion topVer = supply.topologyVersion();
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index 9942423..7c2599a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -38,7 +38,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalP
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -87,13 +86,6 @@ class GridDhtPartitionSupplier {
/**
*
*/
- void start() {
- startOldListeners();
- }
-
- /**
- *
- */
void stop() {
synchronized (scMap) {
Iterator<T3<UUID, Integer, AffinityTopologyVersion>> it = scMap.keySet().iterator();
@@ -106,8 +98,6 @@ class GridDhtPartitionSupplier {
it.remove();
}
}
-
- stopOldListeners();
}
/**
@@ -146,6 +136,7 @@ class GridDhtPartitionSupplier {
*
* @param topVer Topology version.
*/
+ @SuppressWarnings("ConstantConditions")
public void onTopologyChanged(AffinityTopologyVersion topVer) {
synchronized (scMap) {
Iterator<T3<UUID, Integer, AffinityTopologyVersion>> it = scMap.keySet().iterator();
@@ -179,6 +170,7 @@ class GridDhtPartitionSupplier {
* @param idx Index.
* @param id Node uuid.
*/
+ @SuppressWarnings("unchecked")
public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d) {
assert d != null;
assert id != null;
@@ -208,7 +200,7 @@ class GridDhtPartitionSupplier {
log.debug("Demand request accepted [current=" + cutTop + ", demanded=" + demTop +
", from=" + id + ", idx=" + idx + "]");
- GridDhtPartitionSupplyMessageV2 s = new GridDhtPartitionSupplyMessageV2(
+ GridDhtPartitionSupplyMessage s = new GridDhtPartitionSupplyMessage(
d.updateSequence(), cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
ClusterNode node = cctx.discovery().node(id);
@@ -338,7 +330,7 @@ class GridDhtPartitionSupplier {
if (!reply(node, d, s, scId))
return;
- s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ s = new GridDhtPartitionSupplyMessage(d.updateSequence(),
cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
}
}
@@ -424,7 +416,7 @@ class GridDhtPartitionSupplier {
if (!reply(node, d, s, scId))
return;
- s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ s = new GridDhtPartitionSupplyMessage(d.updateSequence(),
cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
}
}
@@ -545,7 +537,7 @@ class GridDhtPartitionSupplier {
if (!reply(node, d, s, scId))
return;
- s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ s = new GridDhtPartitionSupplyMessage(d.updateSequence(),
cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
}
}
@@ -605,7 +597,7 @@ class GridDhtPartitionSupplier {
*/
private boolean reply(ClusterNode n,
GridDhtPartitionDemandMessage d,
- GridDhtPartitionSupplyMessageV2 s,
+ GridDhtPartitionSupplyMessage s,
T3<UUID, Integer, AffinityTopologyVersion> scId)
throws IgniteCheckedException {
@@ -744,294 +736,6 @@ class GridDhtPartitionSupplier {
}
}
- @Deprecated//Backward compatibility. To be removed in future.
- public void startOldListeners() {
- if (!cctx.kernalContext().clientNode() && cctx.rebalanceEnabled()) {
- cctx.io().addHandler(cctx.cacheId(), GridDhtPartitionDemandMessage.class, new CI2<UUID, GridDhtPartitionDemandMessage>() {
- @Override public void apply(UUID id, GridDhtPartitionDemandMessage m) {
- processOldDemandMessage(m, id);
- }
- });
- }
- }
-
- @Deprecated//Backward compatibility. To be removed in future.
- public void stopOldListeners() {
- if (!cctx.kernalContext().clientNode() && cctx.rebalanceEnabled())
- cctx.io().removeHandler(cctx.cacheId(), GridDhtPartitionDemandMessage.class);
- }
-
- /**
- * @param d D.
- * @param id Id.
- */
- @Deprecated//Backward compatibility. To be removed in future.
- private void processOldDemandMessage(GridDhtPartitionDemandMessage d, UUID id) {
- GridDhtPartitionSupplyMessage s = new GridDhtPartitionSupplyMessage(d.workerId(),
- d.updateSequence(), cctx.cacheId(), cctx.deploymentEnabled());
-
- ClusterNode node = cctx.node(id);
-
- if (node == null)
- return;
-
- long preloadThrottle = cctx.config().getRebalanceThrottle();
-
- boolean ack = false;
-
- try {
- for (int part : d.partitions()) {
- GridDhtLocalPartition loc = top.localPartition(part, d.topologyVersion(), false);
-
- if (loc == null || loc.state() != OWNING || !loc.reserve()) {
- // Reply with partition of "-1" to let sender know that
- // this node is no longer an owner.
- s.missed(part);
-
- if (log.isDebugEnabled())
- log.debug("Requested partition is not owned by local node [part=" + part +
- ", demander=" + id + ']');
-
- continue;
- }
-
- GridCacheEntryInfoCollectSwapListener swapLsnr = null;
-
- try {
- if (cctx.isSwapOrOffheapEnabled()) {
- swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
-
- cctx.swap().addOffHeapListener(part, swapLsnr);
- cctx.swap().addSwapListener(part, swapLsnr);
- }
-
- boolean partMissing = false;
-
- for (GridCacheEntryEx e : loc.allEntries()) {
- if (!cctx.affinity().partitionBelongs(node, part, d.topologyVersion())) {
- // Demander no longer needs this partition, so we send '-1' partition and move on.
- s.missed(part);
-
- if (log.isDebugEnabled())
- log.debug("Demanding node does not need requested partition [part=" + part +
- ", nodeId=" + id + ']');
-
- partMissing = true;
-
- break;
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!replyOld(node, d, s))
- return;
-
- // Throttle preloading.
- if (preloadThrottle > 0)
- U.sleep(preloadThrottle);
-
- s = new GridDhtPartitionSupplyMessage(d.workerId(), d.updateSequence(),
- cctx.cacheId(), cctx.deploymentEnabled());
- }
-
- GridCacheEntryInfo info = e.info();
-
- if (info != null && !info.isNew()) {
- if (preloadPred == null || preloadPred.apply(info))
- s.addEntry(part, info, cctx);
- else if (log.isDebugEnabled())
- log.debug("Rebalance predicate evaluated to false (will not sender cache entry): " +
- info);
- }
- }
-
- if (partMissing)
- continue;
-
- if (cctx.isSwapOrOffheapEnabled()) {
- GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
- cctx.swap().iterator(part);
-
- // Iterator may be null if space does not exist.
- if (iter != null) {
- try {
- boolean prepared = false;
-
- for (Map.Entry<byte[], GridCacheSwapEntry> e : iter) {
- if (!cctx.affinity().partitionBelongs(node, part, d.topologyVersion())) {
- // Demander no longer needs this partition,
- // so we send '-1' partition and move on.
- s.missed(part);
-
- if (log.isDebugEnabled())
- log.debug("Demanding node does not need requested partition " +
- "[part=" + part + ", nodeId=" + id + ']');
-
- partMissing = true;
-
- break; // For.
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!replyOld(node, d, s))
- return;
-
- // Throttle preloading.
- if (preloadThrottle > 0)
- U.sleep(preloadThrottle);
-
- s = new GridDhtPartitionSupplyMessage(d.workerId(),
- d.updateSequence(), cctx.cacheId(), cctx.deploymentEnabled());
- }
-
- GridCacheSwapEntry swapEntry = e.getValue();
-
- GridCacheEntryInfo info = new GridCacheEntryInfo();
-
- info.keyBytes(e.getKey());
- info.ttl(swapEntry.ttl());
- info.expireTime(swapEntry.expireTime());
- info.version(swapEntry.version());
- info.value(swapEntry.value());
-
- if (preloadPred == null || preloadPred.apply(info))
- s.addEntry0(part, info, cctx);
- else {
- if (log.isDebugEnabled())
- log.debug("Rebalance predicate evaluated to false (will not send " +
- "cache entry): " + info);
-
- continue;
- }
-
- // Need to manually prepare cache message.
- if (depEnabled && !prepared) {
- ClassLoader ldr = swapEntry.keyClassLoaderId() != null ?
- cctx.deploy().getClassLoader(swapEntry.keyClassLoaderId()) :
- swapEntry.valueClassLoaderId() != null ?
- cctx.deploy().getClassLoader(swapEntry.valueClassLoaderId()) :
- null;
-
- if (ldr == null)
- continue;
-
- if (ldr instanceof GridDeploymentInfo) {
- s.prepare((GridDeploymentInfo)ldr);
-
- prepared = true;
- }
- }
- }
-
- if (partMissing)
- continue;
- }
- finally {
- iter.close();
- }
- }
- }
-
- // Stop receiving promote notifications.
- if (swapLsnr != null) {
- cctx.swap().removeOffHeapListener(part, swapLsnr);
- cctx.swap().removeSwapListener(part, swapLsnr);
- }
-
- if (swapLsnr != null) {
- Collection<GridCacheEntryInfo> entries = swapLsnr.entries();
-
- swapLsnr = null;
-
- for (GridCacheEntryInfo info : entries) {
- if (!cctx.affinity().partitionBelongs(node, part, d.topologyVersion())) {
- // Demander no longer needs this partition,
- // so we send '-1' partition and move on.
- s.missed(part);
-
- if (log.isDebugEnabled())
- log.debug("Demanding node does not need requested partition " +
- "[part=" + part + ", nodeId=" + id + ']');
-
- // No need to continue iteration over swap entries.
- break;
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!replyOld(node, d, s))
- return;
-
- s = new GridDhtPartitionSupplyMessage(d.workerId(),
- d.updateSequence(),
- cctx.cacheId(),
- cctx.deploymentEnabled());
- }
-
- if (preloadPred == null || preloadPred.apply(info))
- s.addEntry(part, info, cctx);
- else if (log.isDebugEnabled())
- log.debug("Rebalance predicate evaluated to false (will not sender cache entry): " +
- info);
- }
- }
-
- // Mark as last supply message.
- s.last(part);
-
- if (ack) {
- s.markAck();
-
- break; // Partition for loop.
- }
- }
- finally {
- loc.release();
-
- if (swapLsnr != null) {
- cctx.swap().removeOffHeapListener(part, swapLsnr);
- cctx.swap().removeSwapListener(part, swapLsnr);
- }
- }
- }
-
- replyOld(node, d, s);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to send partition supply message to node: " + node.id(), e);
- }
- }
-
- /**
- * @param n Node.
- * @param d Demand message.
- * @param s Supply message.
- * @return {@code True} if message was sent, {@code false} if recipient left grid.
- * @throws IgniteCheckedException If failed.
- */
- @Deprecated//Backward compatibility. To be removed in future.
- private boolean replyOld(ClusterNode n, GridDhtPartitionDemandMessage d, GridDhtPartitionSupplyMessage s)
- throws IgniteCheckedException {
- try {
- if (log.isDebugEnabled())
- log.debug("Replying to partition demand [node=" + n.id() + ", demand=" + d + ", supply=" + s + ']');
-
- cctx.io().sendOrderedMessage(n, d.topic(), s, cctx.ioPolicy(), d.timeout());
-
- return true;
- }
- catch (ClusterTopologyCheckedException ignore) {
- if (log.isDebugEnabled())
- log.debug("Failed to send partition supply message because node left grid: " + n.id());
-
- return false;
- }
- }
-
/**
* Dumps debug information.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
index cc30321..a01be28 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
@@ -29,6 +29,7 @@ import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectCollection;
import org.apache.ignite.internal.GridDirectMap;
import org.apache.ignite.internal.GridDirectTransient;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheDeployable;
@@ -48,14 +49,11 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
/** */
private static final long serialVersionUID = 0L;
- /** Worker ID. */
- private int workerId = -1;
-
/** Update sequence. */
private long updateSeq;
- /** Acknowledgement flag. */
- private boolean ack;
+ /** Topology version. */
+ private AffinityTopologyVersion topVer;
/** Partitions that have been fully sent. */
@GridDirectCollection(int.class)
@@ -68,27 +66,26 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
/** Entries. */
@GridDirectMap(keyType = int.class, valueType = CacheEntryInfoCollection.class)
- private Map<Integer, CacheEntryInfoCollection> infos = new HashMap<>();
+ private Map<Integer, CacheEntryInfoCollection> infos;
/** Message size. */
@GridDirectTransient
private int msgSize;
/**
- * @param workerId Worker ID.
* @param updateSeq Update sequence for this node.
* @param cacheId Cache ID.
+ * @param topVer Topology version.
* @param addDepInfo Deployment info flag.
*/
- GridDhtPartitionSupplyMessage(int workerId, long updateSeq, int cacheId, boolean addDepInfo) {
- assert workerId >= 0;
- assert updateSeq > 0;
-
+ GridDhtPartitionSupplyMessage(long updateSeq,
+ int cacheId,
+ AffinityTopologyVersion topVer,
+ boolean addDepInfo) {
this.cacheId = cacheId;
this.updateSeq = updateSeq;
- this.workerId = workerId;
- this.addDepInfo = addDepInfo;
- }
+ this.topVer = topVer;
+ this.addDepInfo = addDepInfo; }
/**
* Empty constructor required for {@link Externalizable}.
@@ -103,13 +100,6 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
}
/**
- * @return Worker ID.
- */
- int workerId() {
- return workerId;
- }
-
- /**
* @return Update sequence.
*/
long updateSequence() {
@@ -117,17 +107,10 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
}
/**
- * Marks this message for acknowledgment.
+ * @return Topology version for which demand message is sent.
*/
- void markAck() {
- ack = true;
- }
-
- /**
- * @return Acknowledgement flag.
- */
- boolean ack() {
- return ack;
+ @Override public AffinityTopologyVersion topologyVersion() {
+ return topVer;
}
/**
@@ -148,12 +131,12 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
msgSize += 4;
// If partition is empty, we need to add it.
- if (!infos.containsKey(p)) {
+ if (!infos().containsKey(p)) {
CacheEntryInfoCollection infoCol = new CacheEntryInfoCollection();
infoCol.init();
- infos.put(p, infoCol);
+ infos().put(p, infoCol);
}
}
}
@@ -180,6 +163,9 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
* @return Entries.
*/
Map<Integer, CacheEntryInfoCollection> infos() {
+ if (infos == null)
+ infos = new HashMap<>();
+
return infos;
}
@@ -203,12 +189,12 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
msgSize += info.marshalledSize(ctx);
- CacheEntryInfoCollection infoCol = infos.get(p);
+ CacheEntryInfoCollection infoCol = infos().get(p);
if (infoCol == null) {
msgSize += 4;
- infos.put(p, infoCol = new CacheEntryInfoCollection());
+ infos().put(p, infoCol = new CacheEntryInfoCollection());
infoCol.init();
}
@@ -232,12 +218,12 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
msgSize += info.marshalledSize(ctx);
- CacheEntryInfoCollection infoCol = infos.get(p);
+ CacheEntryInfoCollection infoCol = infos().get(p);
if (infoCol == null) {
msgSize += 4;
- infos.put(p, infoCol = new CacheEntryInfoCollection());
+ infos().put(p, infoCol = new CacheEntryInfoCollection());
infoCol.init();
}
@@ -253,7 +239,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
GridCacheContext cacheCtx = ctx.cacheContext(cacheId);
for (CacheEntryInfoCollection col : infos().values()) {
- List<GridCacheEntryInfo> entries = col.infos();
+ List<GridCacheEntryInfo> entries = col.infos();
for (int i = 0; i < entries.size(); i++)
entries.get(i).unmarshal(cacheCtx, ldr);
@@ -269,7 +255,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
* @return Number of entries in message.
*/
public int size() {
- return infos.size();
+ return infos().size();
}
/** {@inheritDoc} */
@@ -288,25 +274,25 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
switch (writer.state()) {
case 3:
- if (!writer.writeBoolean("ack", ack))
+ if (!writer.writeMap("infos", infos, MessageCollectionItemType.INT, MessageCollectionItemType.MSG))
return false;
writer.incrementState();
case 4:
- if (!writer.writeMap("infos", infos, MessageCollectionItemType.INT, MessageCollectionItemType.MSG))
+ if (!writer.writeCollection("last", last, MessageCollectionItemType.INT))
return false;
writer.incrementState();
case 5:
- if (!writer.writeCollection("last", last, MessageCollectionItemType.INT))
+ if (!writer.writeCollection("missed", missed, MessageCollectionItemType.INT))
return false;
writer.incrementState();
case 6:
- if (!writer.writeCollection("missed", missed, MessageCollectionItemType.INT))
+ if (!writer.writeMessage("topVer", topVer))
return false;
writer.incrementState();
@@ -317,12 +303,6 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
writer.incrementState();
- case 8:
- if (!writer.writeInt("workerId", workerId))
- return false;
-
- writer.incrementState();
-
}
return true;
@@ -340,7 +320,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
switch (reader.state()) {
case 3:
- ack = reader.readBoolean("ack");
+ infos = reader.readMap("infos", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false);
if (!reader.isLastRead())
return false;
@@ -348,7 +328,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
reader.incrementState();
case 4:
- infos = reader.readMap("infos", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false);
+ last = reader.readCollection("last", MessageCollectionItemType.INT);
if (!reader.isLastRead())
return false;
@@ -356,7 +336,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
reader.incrementState();
case 5:
- last = reader.readCollection("last", MessageCollectionItemType.INT);
+ missed = reader.readCollection("missed", MessageCollectionItemType.INT);
if (!reader.isLastRead())
return false;
@@ -364,7 +344,7 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
reader.incrementState();
case 6:
- missed = reader.readCollection("missed", MessageCollectionItemType.INT);
+ topVer = reader.readMessage("topVer");
if (!reader.isLastRead())
return false;
@@ -379,14 +359,6 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
reader.incrementState();
- case 8:
- workerId = reader.readInt("workerId");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
}
return reader.afterMessageRead(GridDhtPartitionSupplyMessage.class);
@@ -394,18 +366,19 @@ public class GridDhtPartitionSupplyMessage extends GridCacheMessage implements G
/** {@inheritDoc} */
@Override public short directType() {
- return 45;
+ return 114;
}
/** {@inheritDoc} */
@Override public byte fieldsCount() {
- return 9;
+ return 8;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridDhtPartitionSupplyMessage.class, this,
"size", size(),
+ "parts", infos().keySet(),
"super", super.toString());
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
deleted file mode 100644
index 2294582..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
+++ /dev/null
@@ -1,384 +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.distributed.dht.preloader;
-
-import java.io.Externalizable;
-import java.nio.ByteBuffer;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridDirectCollection;
-import org.apache.ignite.internal.GridDirectMap;
-import org.apache.ignite.internal.GridDirectTransient;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryInfoCollection;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheDeployable;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
-import org.apache.ignite.internal.processors.cache.GridCacheMessage;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.plugin.extensions.communication.MessageCollectionItemType;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
-
-/**
- * Partition supply message.
- */
-public class GridDhtPartitionSupplyMessageV2 extends GridCacheMessage implements GridCacheDeployable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Update sequence. */
- private long updateSeq;
-
- /** Topology version. */
- private AffinityTopologyVersion topVer;
-
- /** Partitions that have been fully sent. */
- @GridDirectCollection(int.class)
- private Collection<Integer> last;
-
- /** Partitions which were not found. */
- @GridToStringInclude
- @GridDirectCollection(int.class)
- private Collection<Integer> missed;
-
- /** Entries. */
- @GridDirectMap(keyType = int.class, valueType = CacheEntryInfoCollection.class)
- private Map<Integer, CacheEntryInfoCollection> infos;
-
- /** Message size. */
- @GridDirectTransient
- private int msgSize;
-
- /**
- * @param updateSeq Update sequence for this node.
- * @param cacheId Cache ID.
- * @param topVer Topology version.
- * @param addDepInfo Deployment info flag.
- */
- GridDhtPartitionSupplyMessageV2(long updateSeq,
- int cacheId,
- AffinityTopologyVersion topVer,
- boolean addDepInfo) {
- this.cacheId = cacheId;
- this.updateSeq = updateSeq;
- this.topVer = topVer;
- this.addDepInfo = addDepInfo; }
-
- /**
- * Empty constructor required for {@link Externalizable}.
- */
- public GridDhtPartitionSupplyMessageV2() {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public boolean ignoreClassErrors() {
- return true;
- }
-
- /**
- * @return Update sequence.
- */
- long updateSequence() {
- return updateSeq;
- }
-
- /**
- * @return Topology version for which demand message is sent.
- */
- @Override public AffinityTopologyVersion topologyVersion() {
- return topVer;
- }
-
- /**
- * @return Flag to indicate last message for partition.
- */
- Collection<Integer> last() {
- return last == null ? Collections.<Integer>emptySet() : last;
- }
-
- /**
- * @param p Partition which was fully sent.
- */
- void last(int p) {
- if (last == null)
- last = new HashSet<>();
-
- if (last.add(p)) {
- msgSize += 4;
-
- // If partition is empty, we need to add it.
- if (!infos().containsKey(p)) {
- CacheEntryInfoCollection infoCol = new CacheEntryInfoCollection();
-
- infoCol.init();
-
- infos().put(p, infoCol);
- }
- }
- }
-
- /**
- * @param p Missed partition.
- */
- void missed(int p) {
- if (missed == null)
- missed = new HashSet<>();
-
- if (missed.add(p))
- msgSize += 4;
- }
-
- /**
- * @return Missed partitions.
- */
- Collection<Integer> missed() {
- return missed == null ? Collections.<Integer>emptySet() : missed;
- }
-
- /**
- * @return Entries.
- */
- Map<Integer, CacheEntryInfoCollection> infos() {
- if (infos == null)
- infos = new HashMap<>();
-
- return infos;
- }
-
- /**
- * @return Message size.
- */
- int messageSize() {
- return msgSize;
- }
-
- /**
- * @param p Partition.
- * @param info Entry to add.
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- void addEntry(int p, GridCacheEntryInfo info, GridCacheContext ctx) throws IgniteCheckedException {
- assert info != null;
-
- marshalInfo(info, ctx);
-
- msgSize += info.marshalledSize(ctx);
-
- CacheEntryInfoCollection infoCol = infos().get(p);
-
- if (infoCol == null) {
- msgSize += 4;
-
- infos().put(p, infoCol = new CacheEntryInfoCollection());
-
- infoCol.init();
- }
-
- infoCol.add(info);
- }
-
- /**
- * @param p Partition.
- * @param info Entry to add.
- * @param ctx Cache context.
- * @throws IgniteCheckedException If failed.
- */
- void addEntry0(int p, GridCacheEntryInfo info, GridCacheContext ctx) throws IgniteCheckedException {
- assert info != null;
- assert (info.key() != null || info.keyBytes() != null);
- assert info.value() != null;
-
- // Need to call this method to initialize info properly.
- marshalInfo(info, ctx);
-
- msgSize += info.marshalledSize(ctx);
-
- CacheEntryInfoCollection infoCol = infos().get(p);
-
- if (infoCol == null) {
- msgSize += 4;
-
- infos().put(p, infoCol = new CacheEntryInfoCollection());
-
- infoCol.init();
- }
-
- infoCol.add(info);
- }
-
- /** {@inheritDoc} */
- @SuppressWarnings("ForLoopReplaceableByForEach")
- @Override public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) throws IgniteCheckedException {
- super.finishUnmarshal(ctx, ldr);
-
- GridCacheContext cacheCtx = ctx.cacheContext(cacheId);
-
- for (CacheEntryInfoCollection col : infos().values()) {
- List<GridCacheEntryInfo> entries = col.infos();
-
- for (int i = 0; i < entries.size(); i++)
- entries.get(i).unmarshal(cacheCtx, ldr);
- }
- }
-
- /** {@inheritDoc} */
- @Override public boolean addDeploymentInfo() {
- return addDepInfo;
- }
-
- /**
- * @return Number of entries in message.
- */
- public int size() {
- return infos().size();
- }
-
- /** {@inheritDoc} */
- @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
- writer.setBuffer(buf);
-
- if (!super.writeTo(buf, writer))
- return false;
-
- if (!writer.isHeaderWritten()) {
- if (!writer.writeHeader(directType(), fieldsCount()))
- return false;
-
- writer.onHeaderWritten();
- }
-
- switch (writer.state()) {
- case 3:
- if (!writer.writeMap("infos", infos, MessageCollectionItemType.INT, MessageCollectionItemType.MSG))
- return false;
-
- writer.incrementState();
-
- case 4:
- if (!writer.writeCollection("last", last, MessageCollectionItemType.INT))
- return false;
-
- writer.incrementState();
-
- case 5:
- if (!writer.writeCollection("missed", missed, MessageCollectionItemType.INT))
- return false;
-
- writer.incrementState();
-
- case 6:
- if (!writer.writeMessage("topVer", topVer))
- return false;
-
- writer.incrementState();
-
- case 7:
- if (!writer.writeLong("updateSeq", updateSeq))
- return false;
-
- writer.incrementState();
-
- }
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
- reader.setBuffer(buf);
-
- if (!reader.beforeMessageRead())
- return false;
-
- if (!super.readFrom(buf, reader))
- return false;
-
- switch (reader.state()) {
- case 3:
- infos = reader.readMap("infos", MessageCollectionItemType.INT, MessageCollectionItemType.MSG, false);
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 4:
- last = reader.readCollection("last", MessageCollectionItemType.INT);
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 5:
- missed = reader.readCollection("missed", MessageCollectionItemType.INT);
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 6:
- topVer = reader.readMessage("topVer");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- case 7:
- updateSeq = reader.readLong("updateSeq");
-
- if (!reader.isLastRead())
- return false;
-
- reader.incrementState();
-
- }
-
- return reader.afterMessageRead(GridDhtPartitionSupplyMessageV2.class);
- }
-
- /** {@inheritDoc} */
- @Override public short directType() {
- return 114;
- }
-
- /** {@inheritDoc} */
- @Override public byte fieldsCount() {
- return 8;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridDhtPartitionSupplyMessageV2.class, this,
- "size", size(),
- "parts", infos().keySet(),
- "super", super.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index dc988bd..a5dcd8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -187,7 +187,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
supplier = new GridDhtPartitionSupplier(cctx);
demander = new GridDhtPartitionDemander(cctx);
- supplier.start();
demander.start();
cctx.events().addListener(discoLsnr, EVT_NODE_JOINED, EVT_NODE_LEFT, EVT_NODE_FAILED);
@@ -380,7 +379,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
}
/** {@inheritDoc} */
- public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessageV2 s) {
+ public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessage s) {
if (!enterBusy())
return;
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties b/modules/core/src/main/resources/META-INF/classnames.properties
index 9cce826..8c5a72e 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -743,7 +743,6 @@ org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPar
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplier$SupplyContextPhase
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage
-org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$1
org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture$2
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
index e482a93..5582fdd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java
@@ -65,7 +65,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
@@ -2016,10 +2016,10 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest {
private void blockSupplySend(TestRecordingCommunicationSpi spi, final String cacheName) {
spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
@Override public boolean apply(GridIoMessage ioMsg) {
- if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessageV2.class))
+ if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessage.class))
return false;
- GridDhtPartitionSupplyMessageV2 msg = (GridDhtPartitionSupplyMessageV2)ioMsg.message();
+ GridDhtPartitionSupplyMessage msg = (GridDhtPartitionSupplyMessage)ioMsg.message();
return msg.cacheId() == CU.cacheId(cacheName);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
index 89fcf6b..29c2af6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheReadFromBackupTest.java
@@ -38,7 +38,7 @@ import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;
import org.apache.ignite.internal.TestRecordingCommunicationSpi;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest;
import org.apache.ignite.internal.util.typedef.internal.CU;
@@ -197,10 +197,10 @@ public class IgniteCacheReadFromBackupTest extends GridCommonAbstractTest {
spi.blockMessages(new IgnitePredicate<GridIoMessage>() {
@Override public boolean apply(GridIoMessage ioMsg) {
- if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessageV2.class))
+ if (!ioMsg.message().getClass().equals(GridDhtPartitionSupplyMessage.class))
return false;
- GridDhtPartitionSupplyMessageV2 msg = (GridDhtPartitionSupplyMessageV2)ioMsg.message();
+ GridDhtPartitionSupplyMessage msg = (GridDhtPartitionSupplyMessage)ioMsg.message();
return msg.cacheId() == CU.cacheId(ccfg.getName());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/aeacad6b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
index eda030c..dfb3f65 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/IgniteCacheAtomicProtocolTest.java
@@ -37,7 +37,6 @@ import org.apache.ignite.internal.TestRecordingCommunicationSpi;
import org.apache.ignite.internal.managers.communication.GridIoMessage;
import org.apache.ignite.internal.processors.cache.GridCacheMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage;
-import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
import org.apache.ignite.internal.util.lang.GridAbsPredicate;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
@@ -106,7 +105,7 @@ public class IgniteCacheAtomicProtocolTest extends GridCommonAbstractTest {
@Override public boolean apply(GridIoMessage msg) {
Object msg0 = msg.message();
- return (msg0 instanceof GridDhtPartitionSupplyMessage || msg0 instanceof GridDhtPartitionSupplyMessageV2)
+ return (msg0 instanceof GridDhtPartitionSupplyMessage)
&& ((GridCacheMessage)msg0).cacheId() == CU.cacheId(TEST_CACHE);
}
});
[6/7] ignite git commit: IGNITE-4948 - Fix for web session clustering
with security
Posted by dm...@apache.org.
IGNITE-4948 - Fix for web session clustering with security
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55b9b8be
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55b9b8be
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55b9b8be
Branch: refs/heads/ignite-1192
Commit: 55b9b8beb4a3d93ea733b6bc56a566dbf0918fcf
Parents: 55ab10e
Author: Valentin Kulichenko <va...@gmail.com>
Authored: Tue Apr 11 22:50:18 2017 +0200
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Tue Apr 11 22:50:18 2017 +0200
----------------------------------------------------------------------
.../cache/websession/WebSessionFilter.java | 22 +++++++-------------
1 file changed, 8 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/55b9b8be/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
----------------------------------------------------------------------
diff --git a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
index 96c1717..0644c0f 100644
--- a/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
+++ b/modules/web/src/main/java/org/apache/ignite/cache/websession/WebSessionFilter.java
@@ -31,8 +31,9 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
-import javax.servlet.http.*;
-
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteClientDisconnectedException;
@@ -560,18 +561,10 @@ public class WebSessionFilter implements Filter {
chain.doFilter(httpReq, res);
- if (!cached.isValid())
- binaryCache.remove(cached.id());
- // Changed session ID.
- else if (!cached.getId().equals(sesId)) {
- final String oldId = cached.getId();
-
- cached.invalidate();
+ WebSessionV2 cachedNew = (WebSessionV2)httpReq.getSession(false);
- binaryCache.remove(oldId);
- }
- else
- updateAttributesV2(cached.getId(), cached);
+ if (cachedNew != null && cachedNew.isValid())
+ updateAttributesV2(cachedNew.getId(), cachedNew);
return sesId;
}
@@ -762,6 +755,7 @@ public class WebSessionFilter implements Filter {
*/
public void destroySession(String sesId) {
assert sesId != null;
+
for (int i = 0; i < retries; i++) {
try {
if (cache.remove(sesId) && log.isDebugEnabled())
@@ -1016,7 +1010,7 @@ public class WebSessionFilter implements Filter {
}
}
else
- return null;
+ ses = null;
}
return ses;
[2/7] ignite git commit: IGNITE-3584: CPP: BinaryType refactored
Posted by dm...@apache.org.
IGNITE-3584: CPP: BinaryType refactored
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5c4d43c2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5c4d43c2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5c4d43c2
Branch: refs/heads/ignite-1192
Commit: 5c4d43c2b6414159fcf15d811d8ca365e01da4d8
Parents: aeacad6
Author: Igor Sapego <is...@gridgain.com>
Authored: Tue Apr 11 13:48:49 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Tue Apr 11 13:48:49 2017 +0300
----------------------------------------------------------------------
.gitignore | 31 ++++-
.../binary/include/ignite/binary/binary_type.h | 129 ++++++-------------
.../ignite/impl/binary/binary_id_resolver.h | 33 ++---
.../ignite/impl/binary/binary_object_impl.h | 3 +-
.../ignite/impl/binary/binary_reader_impl.h | 80 +++++++++++-
.../ignite/impl/binary/binary_type_impl.h | 12 +-
.../include/ignite/impl/binary/binary_utils.h | 6 +-
.../ignite/impl/binary/binary_writer_impl.h | 15 ++-
.../core-test/include/ignite/binary_test_defs.h | 117 +++++++++--------
.../cpp/core-test/include/ignite/complex_type.h | 30 ++---
.../cpp/core-test/include/ignite/test_type.h | 37 +++---
.../src/binary_identity_resolver_test.cpp | 92 +++++--------
.../cpp/core-test/src/binary_object_test.cpp | 4 +-
.../cpp/core-test/src/binary_test_defs.cpp | 5 +
.../cpp/core-test/src/cache_invoke_test.cpp | 18 +--
.../cpp/core-test/src/cache_query_test.cpp | 12 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 38 +++---
.../cpp/core-test/src/continuous_query_test.cpp | 34 +++--
.../cpp/core/include/ignite/ignite_binding.h | 6 +-
.../impl/cache/cache_entry_processor_holder.h | 33 +++--
.../cpp/odbc-test/include/complex_type.h | 26 ++--
.../platforms/cpp/odbc-test/include/test_type.h | 37 +++---
22 files changed, 393 insertions(+), 405 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e118746..d8dd951 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,4 +59,33 @@ ipch/
[Dd]ebug*/
[Rr]elease*/
packages
-*.nupkg
\ No newline at end of file
+*.nupkg
+
+#Autotools temp files
+/modules/platforms/cpp/**/Makefile
+/modules/platforms/cpp/**/Makefile.in
+/modules/platforms/cpp/**/aclocal.m4
+/modules/platforms/cpp/**/.libs/
+/modules/platforms/cpp/**/.dirstamp
+/modules/platforms/cpp/**/*.la
+/modules/platforms/cpp/ar-lib
+/modules/platforms/cpp/compile
+/modules/platforms/cpp/confdefs.h
+/modules/platforms/cpp/config.guess
+/modules/platforms/cpp/config.h
+/modules/platforms/cpp/config.h.in
+/modules/platforms/cpp/config.status
+/modules/platforms/cpp/config.sub
+/modules/platforms/cpp/configure
+/modules/platforms/cpp/core-test/ignite-tests
+/modules/platforms/cpp/core/ignite.pc
+/modules/platforms/cpp/depcomp
+/modules/platforms/cpp/ignite/ignite
+/modules/platforms/cpp/install-sh
+/modules/platforms/cpp/libtool
+/modules/platforms/cpp/ltmain.sh
+/modules/platforms/cpp/m4/
+/modules/platforms/cpp/missing
+/modules/platforms/cpp/odbc-test/ignite-odbc-tests
+/modules/platforms/cpp/stamp-h1
+
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
index f65c652..6bd95a1 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_type.h
@@ -51,7 +51,7 @@ struct BinaryType<T> \
* Implementation of GetTypeId() which returns predefined constant.
*/
#define IGNITE_BINARY_GET_TYPE_ID_AS_CONST(id) \
-int32_t GetTypeId() \
+static int32_t GetTypeId() \
{ \
return id; \
}
@@ -61,7 +61,7 @@ int32_t GetTypeId() \
* Implementation of GetTypeId() which returns hash of passed type name.
*/
#define IGNITE_BINARY_GET_TYPE_ID_AS_HASH(typeName) \
-int32_t GetTypeId() \
+static int32_t GetTypeId() \
{ \
return GetBinaryStringHashCode(#typeName); \
}
@@ -71,9 +71,9 @@ int32_t GetTypeId() \
* Implementation of GetTypeName() which returns type name as is.
*/
#define IGNITE_BINARY_GET_TYPE_NAME_AS_IS(typeName) \
-std::string GetTypeName() \
+static void GetTypeName(std::string& dst) \
{ \
- return #typeName; \
+ dst = #typeName; \
}
/**
@@ -81,7 +81,7 @@ std::string GetTypeName() \
* Default implementation of GetFieldId() function which returns Java-way hash code of the string.
*/
#define IGNITE_BINARY_GET_FIELD_ID_AS_HASH \
-int32_t GetFieldId(const char* name) \
+static int32_t GetFieldId(const char* name) \
{ \
return GetBinaryStringHashCode(name); \
}
@@ -91,7 +91,7 @@ int32_t GetFieldId(const char* name) \
* Implementation of GetHashCode() function which always returns 0.
*/
#define IGNITE_BINARY_GET_HASH_CODE_ZERO(T) \
-int32_t GetHashCode(const T& obj) \
+static int32_t GetHashCode(const T& obj) \
{ \
return 0; \
}
@@ -101,7 +101,7 @@ int32_t GetHashCode(const T& obj) \
* Implementation of IsNull() function which always returns false.
*/
#define IGNITE_BINARY_IS_NULL_FALSE(T) \
-bool IsNull(const T& obj) \
+static bool IsNull(const T& obj) \
{ \
return false; \
}
@@ -111,7 +111,7 @@ bool IsNull(const T& obj) \
* Implementation of IsNull() function which return true if passed object is null pointer.
*/
#define IGNITE_BINARY_IS_NULL_IF_NULLPTR(T) \
-bool IsNull(const T& obj) \
+static bool IsNull(const T& obj) \
{ \
return obj; \
}
@@ -121,9 +121,9 @@ bool IsNull(const T& obj) \
* Implementation of GetNull() function which returns an instance created with defult constructor.
*/
#define IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(T) \
-T GetNull() \
+static void GetNull(T& dst) \
{ \
- return T(); \
+ dst = T(); \
}
/**
@@ -131,11 +131,12 @@ T GetNull() \
* Implementation of GetNull() function which returns NULL pointer.
*/
#define IGNITE_BINARY_GET_NULL_NULLPTR(T) \
-T GetNull() \
+static void GetNull(T& dst) \
{ \
- return NULL; \
+ dst = 0; \
}
+
namespace ignite
{
namespace binary
@@ -155,26 +156,35 @@ namespace ignite
* Binary type structure. Defines a set of functions required for type to be serialized and deserialized.
*/
template<typename T>
- struct IGNITE_IMPORT_EXPORT BinaryType
+ struct IGNITE_IMPORT_EXPORT BinaryType { };
+
+ /**
+ * Templated binary type specification for pointers.
+ */
+ template <typename T>
+ struct IGNITE_IMPORT_EXPORT BinaryType<T*>
{
+ /** Actual type. */
+ typedef BinaryType<T> BinaryTypeDereferenced;
+
/**
* Get binary object type ID.
*
* @return Type ID.
*/
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetTypeId function is not defined for binary type.");
+ return BinaryTypeDereferenced::GetTypeId();
}
/**
* Get binary object type name.
*
- * @return Type name.
+ * @param dst Output type name.
*/
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetTypeName function is not defined for binary type.");
+ BinaryTypeDereferenced::GetTypeName(dst);
}
/**
@@ -183,9 +193,9 @@ namespace ignite
* @param name Field name.
* @return Field ID.
*/
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
- return GetBinaryStringHashCode(name);
+ return BinaryTypeDereferenced::GetFieldId(name);
}
/**
@@ -194,20 +204,22 @@ namespace ignite
* @param writer Writer.
* @param obj Object.
*/
- void Write(BinaryWriter& writer, const T& obj)
+ static void Write(BinaryWriter& writer, T* const& obj)
{
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Write function is not defined for binary type.");
+ BinaryTypeDereferenced::Write(writer, *obj);
}
/**
* Read binary object.
*
* @param reader Reader.
- * @return Object.
+ * @param dst Output object.
*/
- T Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, T*& dst)
{
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Read function is not defined for binary type.");
+ dst = new T();
+
+ BinaryTypeDereferenced::Read(reader, *dst);
}
/**
@@ -216,76 +228,19 @@ namespace ignite
* @param obj Binary object to test.
* @return True if binary object should be interpreted as NULL.
*/
- bool IsNull(const T& obj)
+ static bool IsNull(T* const& obj)
{
- return false;
+ return !obj || BinaryTypeDereferenced::IsNull(*obj);
}
/**
* Get NULL value for the given binary type.
*
- * @return NULL value.
- */
- T GetNull()
- {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "GetNull function is not defined for binary type.");
- }
- };
-
- /**
- * Templated binary type specification for pointers.
- */
- template <typename T>
- struct IGNITE_IMPORT_EXPORT BinaryType<T*>
- {
- /** Actual type. */
- BinaryType<T> typ;
-
- /**
- * Constructor.
+ * @param dst Null value for the type.
*/
- BinaryType() : typ()
- {
- // No-op.
- }
-
- int32_t GetTypeId()
- {
- return typ.GetTypeId();
- }
-
- std::string GetTypeName()
- {
- return typ.GetTypeName();
- }
-
- int32_t GetFieldId(const char* name)
- {
- return typ.GetFieldId(name);
- }
-
- void Write(BinaryWriter& writer, T* const& obj)
- {
- typ.Write(writer, *obj);
- }
-
- T* Read(BinaryReader& reader)
- {
- T* res = new T();
-
- *res = typ.Read(reader);
-
- return res;
- }
-
- bool IsNull(T* const& obj)
- {
- return !obj || typ.IsNull(*obj);
- }
-
- T* GetNull()
+ static void GetNull(T*& dst)
{
- return 0;
+ dst = 0;
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
index 7d6b12b..123299c 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_id_resolver.h
@@ -78,46 +78,29 @@ namespace ignite
/**
* Constructor.
*/
- TemplatedBinaryIdResolver() :
- type()
- {
- // No-op.
- }
-
- /**
- * Constructor.
- *
- * @param type Binary type.
- */
- TemplatedBinaryIdResolver(ignite::binary::BinaryType<T> type) :
- type(type)
+ TemplatedBinaryIdResolver()
{
// No-op.
}
virtual int32_t GetTypeId()
{
- return type.GetTypeId();
+ return ignite::binary::BinaryType<T>::GetTypeId();
}
- virtual int32_t GetFieldId(const int32_t typeId, const char* name) {
+ virtual int32_t GetFieldId(const int32_t typeId, const char* name)
+ {
if (name)
- return type.GetFieldId(name);
- else
- {
- IGNITE_ERROR_FORMATTED_1(IgniteError::IGNITE_ERR_BINARY,
- "Field name cannot be NULL.", "typeId", typeId);
- }
+ return ignite::binary::BinaryType<T>::GetFieldId(name);
+
+ IGNITE_ERROR_FORMATTED_1(IgniteError::IGNITE_ERR_BINARY,
+ "Field name cannot be NULL.", "typeId", typeId);
}
virtual BinaryIdResolver* Clone() const
{
return new TemplatedBinaryIdResolver<T>(*this);
}
-
- private:
- /** Actual type. */
- ignite::binary::BinaryType<T> type;
};
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
index 880fff2..976ba29 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_object_impl.h
@@ -109,9 +109,8 @@ namespace ignite
template<typename T>
T Deserialize() const
{
- ignite::binary::BinaryType<T> bt;
int32_t actualTypeId = GetTypeId();
- int32_t requestedTypeId = bt.GetTypeId();
+ int32_t requestedTypeId = ignite::binary::BinaryType<T>::GetTypeId();
if (requestedTypeId != actualTypeId)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 8be9172..6d66416 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -916,6 +916,8 @@ namespace ignite
case IGNITE_HDR_FULL:
{
+ typedef ignite::binary::BinaryType<T> BType;
+
int8_t protoVer = stream->ReadInt8();
if (protoVer != IGNITE_PROTO_VER) {
@@ -976,14 +978,14 @@ namespace ignite
bool usrType = (flags & IGNITE_BINARY_FLAG_USER_TYPE) != 0;
- ignite::binary::BinaryType<T> type;
- TemplatedBinaryIdResolver<T> idRslvr(type);
+ TemplatedBinaryIdResolver<T> idRslvr;
BinaryReaderImpl readerImpl(stream, &idRslvr, pos, usrType,
typeId, hashCode, len, rawOff,
footerBegin, footerEnd, schemaType);
ignite::binary::BinaryReader reader(&readerImpl);
- T val = type.Read(reader);
+ T val;
+ BType::Read(reader, val);
stream->Position(pos + len);
@@ -1004,9 +1006,11 @@ namespace ignite
template<typename T>
T GetNull() const
{
- ignite::binary::BinaryType<T> type;
+ T res;
+
+ ignite::binary::BinaryType<T>::GetNull(res);
- return type.GetNull();
+ return res;
}
/**
@@ -1439,6 +1443,72 @@ namespace ignite
template<>
std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>();
+
+ template<>
+ inline int8_t BinaryReaderImpl::GetNull() const
+ {
+ return 0;
+ }
+
+ template<>
+ inline int16_t BinaryReaderImpl::GetNull() const
+ {
+ return 0;
+ }
+
+ template<>
+ inline int32_t BinaryReaderImpl::GetNull() const
+ {
+ return 0;
+ }
+
+ template<>
+ inline int64_t BinaryReaderImpl::GetNull() const
+ {
+ return 0;
+ }
+
+ template<>
+ inline float BinaryReaderImpl::GetNull() const
+ {
+ return 0.0f;
+ }
+
+ template<>
+ inline double BinaryReaderImpl::GetNull() const
+ {
+ return 0.0;
+ }
+
+ template<>
+ inline Guid BinaryReaderImpl::GetNull() const
+ {
+ return Guid();
+ }
+
+ template<>
+ inline Date BinaryReaderImpl::GetNull() const
+ {
+ return Date();
+ }
+
+ template<>
+ inline Timestamp BinaryReaderImpl::GetNull() const
+ {
+ return Timestamp();
+ }
+
+ template<>
+ inline Time BinaryReaderImpl::GetNull() const
+ {
+ return Time();
+ }
+
+ template<>
+ inline std::string BinaryReaderImpl::GetNull() const
+ {
+ return std::string();
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
index 08c60c0..269db61 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
@@ -57,9 +57,9 @@ namespace ignite
{
namespace binary
{
- IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetHashCode, int32_t(ignite::binary::BinaryType<T>::*)(const T&));
+ IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetHashCode, int32_t(*)(const T&));
IGNITE_DECLARE_BINARY_TYPE_METHOD_CHECKER(GetIdentityResolver,
- ignite::Reference<ignite::binary::BinaryIdentityResolver>(ignite::binary::BinaryType<T>::*)());
+ ignite::Reference<ignite::binary::BinaryIdentityResolver>(*)());
/**
* This type is used to get hash code for binary types which have not
@@ -85,9 +85,7 @@ namespace ignite
{
static int32_t Get(const T& obj, const ignite::binary::BinaryObject&)
{
- ignite::binary::BinaryType<T> bt;
-
- return bt.GetHashCode(obj);
+ return ignite::binary::BinaryType<T>::GetHashCode(obj);
}
};
@@ -100,8 +98,8 @@ namespace ignite
{
static int32_t Get(const T&, const ignite::binary::BinaryObject& obj)
{
- ignite::binary::BinaryType<T> bt;
- ignite::Reference<ignite::binary::BinaryIdentityResolver> resolver = bt.GetIdentityResolver();
+ ignite::Reference<ignite::binary::BinaryIdentityResolver> resolver =
+ ignite::binary::BinaryType<T>::GetIdentityResolver();
return resolver.Get()->GetHashCode(obj);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
index 268c2d8..84d7a19 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
@@ -471,9 +471,11 @@ namespace ignite
template<typename T>
static T GetDefaultValue()
{
- ignite::binary::BinaryType<T> binType;
+ T res;
- return binType.GetNull();
+ ignite::binary::BinaryType<T>::GetNull(res);
+
+ return res;
}
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
index 50b2375..e7dafb2 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
@@ -681,17 +681,20 @@ namespace ignite
template<typename T>
void WriteTopObject(const T& obj)
{
- ignite::binary::BinaryType<T> type;
+ typedef ignite::binary::BinaryType<T> BType;
- if (type.IsNull(obj))
+ if (BType::IsNull(obj))
stream->WriteInt8(IGNITE_HDR_NULL);
else
{
- TemplatedBinaryIdResolver<T> idRslvr(type);
- ignite::common::concurrent::SharedPointer<BinaryTypeHandler> metaHnd;
+ TemplatedBinaryIdResolver<T> idRslvr;
+ common::concurrent::SharedPointer<BinaryTypeHandler> metaHnd;
+
+ std::string typeName;
+ BType::GetTypeName(typeName);
if (metaMgr)
- metaHnd = metaMgr->GetHandler(type.GetTypeName(), idRslvr.GetTypeId());
+ metaHnd = metaMgr->GetHandler(typeName, idRslvr.GetTypeId());
int32_t pos = stream->Position();
@@ -708,7 +711,7 @@ namespace ignite
// Reserve space for the Object Lenght, Schema ID and Schema or Raw Offset.
stream->Reserve(12);
- type.Write(writer, obj);
+ BType::Write(writer, obj);
writerImpl.PostWrite();
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
index 196c6d3..0870997 100644
--- a/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_defs.h
@@ -49,6 +49,8 @@ namespace ignite_test
class BinaryOuter
{
public:
+ BinaryOuter();
+
BinaryOuter(int32_t valIn, int32_t valOut);
BinaryInner GetInner() const;
@@ -141,175 +143,175 @@ namespace ignite
template<>
struct BinaryType<gt::BinaryDummy>
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("BinaryDummy");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "BinaryDummy";
+ dst = "BinaryDummy";
}
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryInner& obj)
+ static int32_t GetHashCode(const gt::BinaryDummy& obj)
{
- return obj.GetValue();
+ return 0;
}
- bool IsNull(const gt::BinaryInner& obj)
+ static bool IsNull(const gt::BinaryDummy& obj)
{
- return obj.GetValue() == 0;
+ return false;
}
- gt::BinaryInner GetNull()
+ static void GetNull(gt::BinaryDummy& dst)
{
- return gt::BinaryInner(0);
+ dst = gt::BinaryDummy();
}
- void Write(BinaryWriter& writer, const gt::BinaryDummy& obj)
+ static void Write(BinaryWriter& writer, const gt::BinaryDummy& obj)
{
// No-op.
}
- gt::BinaryDummy Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, gt::BinaryDummy& dst)
{
- return gt::BinaryDummy();
+ dst = gt::BinaryDummy();
}
};
template<>
struct BinaryType<gt::BinaryInner>
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("BinaryInner");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "BinaryInner";
+ dst = "BinaryInner";
}
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryInner& obj)
+ static int32_t GetHashCode(const gt::BinaryInner& obj)
{
return obj.GetValue();
}
- bool IsNull(const gt::BinaryInner& obj)
+ static bool IsNull(const gt::BinaryInner& obj)
{
return obj.GetValue() == 0;
}
- gt::BinaryInner GetNull()
+ static void GetNull(gt::BinaryInner& dst)
{
- return gt::BinaryInner(0);
+ dst = gt::BinaryInner(0);
}
- void Write(BinaryWriter& writer, const gt::BinaryInner& obj)
+ static void Write(BinaryWriter& writer, const gt::BinaryInner& obj)
{
writer.WriteInt32("val", obj.GetValue());
}
- gt::BinaryInner Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, gt::BinaryInner& dst)
{
int val = reader.ReadInt32("val");
- return gt::BinaryInner(val);
+ dst = gt::BinaryInner(val);
}
};
template<>
struct BinaryType<gt::BinaryOuter>
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("BinaryOuter");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "BinaryOuter";
+ dst = "BinaryOuter";
}
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryOuter& obj)
+ static int32_t GetHashCode(const gt::BinaryOuter& obj)
{
return obj.GetValue() + obj.GetInner().GetValue();
}
- bool IsNull(const gt::BinaryOuter& obj)
+ static bool IsNull(const gt::BinaryOuter& obj)
{
return obj.GetValue() == 0 && obj.GetInner().GetValue();
}
- gt::BinaryOuter GetNull()
+ static void GetNull(gt::BinaryOuter& dst)
{
- return gt::BinaryOuter(0, 0);
+ dst = gt::BinaryOuter(0, 0);
}
- void Write(BinaryWriter& writer, const gt::BinaryOuter& obj)
+ static void Write(BinaryWriter& writer, const gt::BinaryOuter& obj)
{
writer.WriteObject("inner", obj.GetInner());
writer.WriteInt32("val", obj.GetValue());
}
- gt::BinaryOuter Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, gt::BinaryOuter& dst)
{
gt::BinaryInner inner = reader.ReadObject<gt::BinaryInner>("inner");
int val = reader.ReadInt32("val");
- return gt::BinaryOuter(inner.GetValue(), val);
+ dst = gt::BinaryOuter(inner.GetValue(), val);
}
};
template<>
struct BinaryType<gt::BinaryFields>
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("BinaryFields");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "BinaryFields";
+ dst = "BinaryFields";
}
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::BinaryFields& obj)
+ static int32_t GetHashCode(const gt::BinaryFields& obj)
{
return obj.val1 + obj.val2 + obj.rawVal1 + obj.rawVal2;
}
- bool IsNull(const gt::BinaryFields& obj)
+ static bool IsNull(const gt::BinaryFields& obj)
{
return false;
}
- gt::BinaryFields GetNull()
+ static void GetNull(gt::BinaryFields&)
{
throw std::runtime_error("Must not be called.");
}
- void Write(BinaryWriter& writer, const gt::BinaryFields& obj)
+ static void Write(BinaryWriter& writer, const gt::BinaryFields& obj)
{
writer.WriteInt32("val1", obj.val1);
writer.WriteInt32("val2", obj.val2);
@@ -320,7 +322,7 @@ namespace ignite
rawWriter.WriteInt32(obj.rawVal2);
}
- gt::BinaryFields Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, gt::BinaryFields& dst)
{
int32_t val1 = reader.ReadInt32("val1");
int32_t val2 = reader.ReadInt32("val2");
@@ -330,44 +332,44 @@ namespace ignite
int32_t rawVal1 = rawReader.ReadInt32();
int32_t rawVal2 = rawReader.ReadInt32();
- return gt::BinaryFields(val1, val2, rawVal1, rawVal2);
+ dst = gt::BinaryFields(val1, val2, rawVal1, rawVal2);
}
};
template<>
struct BinaryType<gt::PureRaw>
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("PureRaw");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "PureRaw";
+ dst = "PureRaw";
}
- int32_t GetFieldId(const char* name)
+ static int32_t GetFieldId(const char* name)
{
return GetBinaryStringHashCode(name);
}
- int32_t GetHashCode(const gt::PureRaw& obj)
+ static int32_t GetHashCode(const gt::PureRaw& obj)
{
return GetBinaryStringHashCode(obj.val1.c_str()) ^ obj.val2;
}
- bool IsNull(const gt::PureRaw& obj)
+ static bool IsNull(const gt::PureRaw& obj)
{
return false;
}
- gt::PureRaw GetNull()
+ static void GetNull(gt::PureRaw&)
{
throw std::runtime_error("Must not be called.");
}
- void Write(BinaryWriter& writer, const gt::PureRaw& obj)
+ static void Write(BinaryWriter& writer, const gt::PureRaw& obj)
{
BinaryRawWriter rawWriter = writer.RawWriter();
@@ -375,15 +377,12 @@ namespace ignite
rawWriter.WriteInt32(obj.val2);
}
- gt::PureRaw Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, gt::PureRaw& dst)
{
BinaryRawReader rawReader = reader.RawReader();
- gt::PureRaw res;
- res.val1 = rawReader.ReadString();
- res.val2 = rawReader.ReadInt32();
-
- return res;
+ dst.val1 = rawReader.ReadString();
+ dst.val2 = rawReader.ReadInt32();
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/include/ignite/complex_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/complex_type.h b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
index cb4a8a1..e1a0351 100644
--- a/modules/platforms/cpp/core-test/include/ignite/complex_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/complex_type.h
@@ -18,11 +18,9 @@
#ifndef _IGNITE_ODBC_TEST_COMPLEX_TYPE
#define _IGNITE_ODBC_TEST_COMPLEX_TYPE
+#include <stdint.h>
#include <string>
-#include "ignite/ignite.h"
-#include "ignite/ignition.h"
-
namespace ignite
{
struct InnerObject
@@ -81,20 +79,16 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(InnerObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(InnerObject)
- void Write(BinaryWriter& writer, InnerObject obj)
+ static void Write(BinaryWriter& writer, const InnerObject& obj)
{
writer.WriteInt32("f1", obj.f1);
writer.WriteString("f2", obj.f2);
}
- InnerObject Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, InnerObject& dst)
{
- InnerObject obj;
-
- obj.f1 = reader.ReadInt32("f1");
- obj.f2 = reader.ReadString("f2");
-
- return obj;
+ dst.f1 = reader.ReadInt32("f1");
+ dst.f2 = reader.ReadString("f2");
}
IGNITE_BINARY_TYPE_END
@@ -110,22 +104,18 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)
- void Write(BinaryWriter& writer, ComplexType obj)
+ static void Write(BinaryWriter& writer, const ComplexType& obj)
{
writer.WriteInt32("i32Field", obj.i32Field);
writer.WriteObject("objField", obj.objField);
writer.WriteString("strField", obj.strField);
}
- ComplexType Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, ComplexType& dst)
{
- ComplexType obj;
-
- obj.i32Field = reader.ReadInt32("i32Field");
- obj.objField = reader.ReadObject<InnerObject>("objField");
- obj.strField = reader.ReadString("strField");
-
- return obj;
+ dst.i32Field = reader.ReadInt32("i32Field");
+ dst.objField = reader.ReadObject<InnerObject>("objField");
+ dst.strField = reader.ReadString("strField");
}
IGNITE_BINARY_TYPE_END
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
index d1dd967..40ada55 100644
--- a/modules/platforms/cpp/core-test/include/ignite/test_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -111,7 +111,7 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(TestType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
- void Write(BinaryWriter& writer, TestType obj)
+ static void Write(BinaryWriter& writer, const TestType& obj)
{
if (!obj.allNulls)
{
@@ -154,32 +154,27 @@ namespace ignite
}
}
- TestType Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, TestType& dst)
{
- int8_t i8Field = reader.ReadInt8("i8Field");
- int16_t i16Field = reader.ReadInt16("i16Field");
- int32_t i32Field = reader.ReadInt32("i32Field");
- int64_t i64Field = reader.ReadInt64("i64Field");
- std::string strField = reader.ReadString("strField");
- float floatField = reader.ReadFloat("floatField");
- double doubleField = reader.ReadDouble("doubleField");
- bool boolField = reader.ReadBool("boolField");
- Guid guidField = reader.ReadGuid("guidField");
- Date dateField = reader.ReadDate("dateField");
- Time timeField = reader.ReadTime("timeField");
- Timestamp timestampField = reader.ReadTimestamp("timestampField");
-
- TestType result(i8Field, i16Field, i32Field, i64Field, strField,
- floatField, doubleField, boolField, guidField, dateField,
- timeField, timestampField);
+ dst.i8Field = reader.ReadInt8("i8Field");
+ dst.i16Field = reader.ReadInt16("i16Field");
+ dst.i32Field = reader.ReadInt32("i32Field");
+ dst.i64Field = reader.ReadInt64("i64Field");
+ dst.strField = reader.ReadString("strField");
+ dst.floatField = reader.ReadFloat("floatField");
+ dst.doubleField = reader.ReadDouble("doubleField");
+ dst.boolField = reader.ReadBool("boolField");
+ dst.guidField = reader.ReadGuid("guidField");
+ dst.dateField = reader.ReadDate("dateField");
+ dst.timeField = reader.ReadTime("timeField");
+ dst.timestampField = reader.ReadTimestamp("timestampField");
int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
if (len > 0)
{
- result.i8ArrayField.resize(len);
- reader.ReadInt8Array("i8ArrayField", &result.i8ArrayField[0], len);
+ dst.i8ArrayField.resize(len);
+ reader.ReadInt8Array("i8ArrayField", &dst.i8ArrayField[0], len);
}
- return result;
}
IGNITE_BINARY_TYPE_END
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp b/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
index 55b77bd..802ec97 100644
--- a/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_identity_resolver_test.cpp
@@ -198,18 +198,14 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(DefaultHashing)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(DefaultHashing)
- void Write(BinaryWriter& writer, const DefaultHashing& obj)
+ static void Write(BinaryWriter& writer, const DefaultHashing& obj)
{
writer.WriteInt32("field", obj.field);
}
- DefaultHashing Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, DefaultHashing& dst)
{
- DefaultHashing val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
+ dst.field = reader.ReadInt32("field");
}
};
@@ -222,23 +218,19 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(GetHashDefined)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(GetHashDefined)
- int32_t GetHashCode(const GetHashDefined& obj)
+ static int32_t GetHashCode(const GetHashDefined& obj)
{
return obj.field * 10;
}
- void Write(BinaryWriter& writer, const GetHashDefined& obj)
+ static void Write(BinaryWriter& writer, const GetHashDefined& obj)
{
writer.WriteInt32("field", obj.field);
}
- GetHashDefined Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, GetHashDefined& dst)
{
- GetHashDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
+ dst.field = reader.ReadInt32("field");
}
};
@@ -251,23 +243,19 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(ResolverDefined)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ResolverDefined)
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
+ static ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
{
return ignite::MakeReferenceFromCopy(CustomIdResolver());
}
- void Write(BinaryWriter& writer, const ResolverDefined& obj)
+ static void Write(BinaryWriter& writer, const ResolverDefined& obj)
{
writer.WriteInt32("field", obj.field);
}
- ResolverDefined Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, ResolverDefined& dst)
{
- ResolverDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
+ dst.field = reader.ReadInt32("field");
}
};
@@ -280,28 +268,24 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(BothDefined)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(BothDefined)
- int32_t GetHashCode(const GetHashDefined& obj)
+ static int32_t GetHashCode(const GetHashDefined& obj)
{
return obj.field * 10;
}
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
+ static ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
{
return ignite::MakeReferenceFromCopy(CustomIdResolver());
}
- void Write(BinaryWriter& writer, const BothDefined& obj)
+ static void Write(BinaryWriter& writer, const BothDefined& obj)
{
writer.WriteInt32("field", obj.field);
}
- BothDefined Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, BothDefined& dst)
{
- BothDefined val;
-
- val.field = reader.ReadInt32("field");
-
- return val;
+ dst.field = reader.ReadInt32("field");
}
};
@@ -318,22 +302,18 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(CompositeKey)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CompositeKey)
- void Write(BinaryWriter& writer, const CompositeKey& obj)
+ static void Write(BinaryWriter& writer, const CompositeKey& obj)
{
writer.WriteString("str", obj.str);
writer.WriteTimestamp("ts", obj.ts);
writer.WriteGuid("guid", obj.guid);
}
- CompositeKey Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, CompositeKey& dst)
{
- CompositeKey val;
-
- val.str = reader.ReadString("str");
- val.ts = reader.ReadTimestamp("ts");
- val.guid = reader.ReadGuid("guid");
-
- return val;
+ dst.str = reader.ReadString("str");
+ dst.ts = reader.ReadTimestamp("ts");
+ dst.guid = reader.ReadGuid("guid");
}
};
@@ -349,22 +329,18 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(CompositeKeySimple)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CompositeKeySimple)
- void Write(BinaryWriter& writer, const CompositeKeySimple& obj)
+ static void Write(BinaryWriter& writer, const CompositeKeySimple& obj)
{
writer.WriteString("str", obj.str);
writer.WriteTimestamp("ts", obj.ts);
writer.WriteInt64("i64", obj.i64);
}
- CompositeKeySimple Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, CompositeKeySimple& dst)
{
- CompositeKeySimple val;
-
- val.str = reader.ReadString("str");
- val.ts = reader.ReadTimestamp("ts");
- val.i64 = reader.ReadInt64("i64");
-
- return val;
+ dst.str = reader.ReadString("str");
+ dst.ts = reader.ReadTimestamp("ts");
+ dst.i64 = reader.ReadInt64("i64");
}
};
@@ -380,27 +356,23 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(ComplexType2)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType2)
- ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
+ static ignite::Reference<ignite::binary::BinaryIdentityResolver> GetIdentityResolver()
{
return ignite::MakeReferenceFromCopy(CustomFieldIdResolver());
}
- void Write(BinaryWriter& writer, ComplexType2 obj)
+ static void Write(BinaryWriter& writer, const ComplexType2& obj)
{
writer.WriteInt32("i32Field", obj.i32Field);
writer.WriteObject("objField", obj.objField);
writer.WriteString("strField", obj.strField);
}
- ComplexType2 Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, ComplexType2& dst)
{
- ComplexType2 obj;
-
- obj.i32Field = reader.ReadInt32("i32Field");
- obj.objField = reader.ReadObject<InnerObject>("objField");
- obj.strField = reader.ReadString("strField");
-
- return obj;
+ dst.i32Field = reader.ReadInt32("i32Field");
+ dst.objField = reader.ReadObject<InnerObject>("objField");
+ dst.strField = reader.ReadString("strField");
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/binary_object_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_object_test.cpp b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
index bc30428..16e8c83 100644
--- a/modules/platforms/cpp/core-test/src/binary_object_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
@@ -86,9 +86,7 @@ void GetObjectData(const T& obj, common::FixedSizeArray<int8_t>& data)
BinaryWriterImpl writerImpl(&stream, &idResolver, 0, 0, 0);
BinaryWriter writer(&writerImpl);
- BinaryType<T> bt;
-
- bt.Write(writer, obj);
+ BinaryType<T>::Write(writer, obj);
data.Assign(mem.Data(), stream.Position());
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_test_defs.cpp b/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
index 500ecd8..932f486 100644
--- a/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_test_defs.cpp
@@ -46,6 +46,11 @@ namespace ignite_test
return val;
}
+ BinaryOuter::BinaryOuter()
+ {
+ // No-op.
+ }
+
BinaryOuter::BinaryOuter(int32_t valIn, int32_t valOut) : inner(valIn), val(valOut)
{
// No-op.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
index 4f1f30a..81261b3 100644
--- a/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_invoke_test.cpp
@@ -133,16 +133,16 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(CacheEntryModifier)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CacheEntryModifier)
- void Write(BinaryWriter& writer, CacheEntryModifier obj)
+ static void Write(BinaryWriter& writer, const CacheEntryModifier& obj)
{
writer.WriteInt32("num", obj.GetNum());
}
- CacheEntryModifier Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, CacheEntryModifier& dst)
{
int num = reader.ReadInt32("num");
- return CacheEntryModifier(num);
+ dst = CacheEntryModifier(num);
}
IGNITE_BINARY_TYPE_END
}
@@ -244,16 +244,16 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(Divisor)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Divisor)
- void Write(BinaryWriter& writer, Divisor obj)
+ static void Write(BinaryWriter& writer, const Divisor& obj)
{
writer.WriteDouble("scale", obj.GetScale());
}
- Divisor Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, Divisor& dst)
{
double scale = reader.ReadDouble("scale");
- return Divisor(scale);
+ dst = Divisor(scale);
}
IGNITE_BINARY_TYPE_END
}
@@ -365,16 +365,16 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(CharRemover)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(CharRemover)
- void Write(BinaryWriter& writer, CharRemover obj)
+ static void Write(BinaryWriter& writer, const CharRemover& obj)
{
writer.WriteInt8("toRemove", obj.GetCharToRemove());
}
- CharRemover Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, CharRemover& dst)
{
char toRemove = static_cast<char>(reader.ReadInt8("toRemove"));
- return CharRemover(toRemove);
+ dst = CharRemover(toRemove);
}
IGNITE_BINARY_TYPE_END
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/cache_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_query_test.cpp b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
index 871f66a..328efd9 100644
--- a/modules/platforms/cpp/core-test/src/cache_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_query_test.cpp
@@ -249,7 +249,7 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(QueryPerson)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryPerson)
- void Write(BinaryWriter& writer, QueryPerson obj)
+ static void Write(BinaryWriter& writer, const QueryPerson& obj)
{
writer.WriteString("name", obj.GetName());
writer.WriteInt32("age", obj.GetAge());
@@ -257,14 +257,14 @@ namespace ignite
writer.WriteTimestamp("recordCreated", obj.GetCreationTime());
}
- QueryPerson Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, QueryPerson& dst)
{
std::string name = reader.ReadString("name");
int age = reader.ReadInt32("age");
Date birthday = reader.ReadDate("birthday");
Timestamp recordCreated = reader.ReadTimestamp("recordCreated");
- return QueryPerson(name, age, birthday, recordCreated);
+ dst = QueryPerson(name, age, birthday, recordCreated);
}
IGNITE_BINARY_TYPE_END
@@ -279,18 +279,18 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(QueryRelation)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(QueryRelation)
- void Write(BinaryWriter& writer, QueryRelation obj)
+ static void Write(BinaryWriter& writer, QueryRelation obj)
{
writer.WriteInt32("personId", obj.GetPersonId());
writer.WriteInt32("someVal", obj.GetHobbyId());
}
- QueryRelation Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, QueryRelation& dst)
{
int32_t personId = reader.ReadInt32("personId");
int32_t someVal = reader.ReadInt32("someVal");
- return QueryRelation(personId, someVal);
+ dst = QueryRelation(personId, someVal);
}
IGNITE_BINARY_TYPE_END
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/cache_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/cache_test.cpp b/modules/platforms/cpp/core-test/src/cache_test.cpp
index fef777a..99e0f1b 100644
--- a/modules/platforms/cpp/core-test/src/cache_test.cpp
+++ b/modules/platforms/cpp/core-test/src/cache_test.cpp
@@ -50,26 +50,24 @@ namespace ignite
namespace binary
{
IGNITE_BINARY_TYPE_START(Person)
- IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
- IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
- IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- IGNITE_BINARY_GET_HASH_CODE_ZERO(Person)
- IGNITE_BINARY_IS_NULL_FALSE(Person)
- IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)
-
- void Write(BinaryWriter& writer, Person obj)
- {
- writer.WriteString("name", obj.name);
- writer.WriteInt32("age", obj.age);
- }
-
- Person Read(BinaryReader& reader)
- {
- std::string name = reader.ReadString("name");
- int age = reader.ReadInt32("age");
-
- return Person(name, age);
- }
+ IGNITE_BINARY_GET_TYPE_ID_AS_HASH(Person)
+ IGNITE_BINARY_GET_TYPE_NAME_AS_IS(Person)
+ IGNITE_BINARY_GET_FIELD_ID_AS_HASH
+ IGNITE_BINARY_GET_HASH_CODE_ZERO(Person)
+ IGNITE_BINARY_IS_NULL_FALSE(Person)
+ IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(Person)
+
+ static void Write(BinaryWriter& writer, const Person& obj)
+ {
+ writer.WriteString("name", obj.name);
+ writer.WriteInt32("age", obj.age);
+ }
+
+ static void Read(BinaryReader& reader, Person& dst)
+ {
+ dst.name = reader.ReadString("name");
+ dst.age = reader.ReadInt32("age");
+ }
IGNITE_BINARY_TYPE_END
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
index f81eb5d..8579c54 100644
--- a/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
+++ b/modules/platforms/cpp/core-test/src/continuous_query_test.cpp
@@ -269,62 +269,58 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(TestEntry)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestEntry)
- void Write(BinaryWriter& writer, const TestEntry& obj)
+ static void Write(BinaryWriter& writer, const TestEntry& obj)
{
writer.WriteInt32("value", obj.value);
}
- TestEntry Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, TestEntry& dst)
{
- TestEntry res;
- res.value = reader.ReadInt32("value");
-
- return res;
+ dst.value = reader.ReadInt32("value");
}
};
template<typename K, typename V>
struct BinaryType< RangeFilter<K,V> >
{
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
return GetBinaryStringHashCode("RangeFilter");
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
- return "RangeFilter";
+ dst = "RangeFilter";
}
+
IGNITE_BINARY_GET_FIELD_ID_AS_HASH
- int32_t GetHashCode(const RangeFilter<K,V>&)
+ static int32_t GetHashCode(const RangeFilter<K,V>&)
{
return 0;
}
- bool IsNull(const RangeFilter<K,V>&)
+ static bool IsNull(const RangeFilter<K,V>&)
{
return false;
}
- RangeFilter<K,V> GetNull()
+ static void GetNull(RangeFilter<K, V>& dst)
{
- return RangeFilter<K,V>();
+ dst = RangeFilter<K,V>();
}
- void Write(BinaryWriter& writer, const RangeFilter<K,V>& obj)
+ static void Write(BinaryWriter& writer, const RangeFilter<K,V>& obj)
{
writer.WriteObject("rangeBegin", obj.rangeBegin);
writer.WriteObject("rangeEnd", obj.rangeEnd);
}
- RangeFilter<K,V> Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, RangeFilter<K, V>& dst)
{
- K begin = reader.ReadObject<K>("rangeBegin");
- K end = reader.ReadObject<K>("rangeEnd");
-
- return RangeFilter<K,V>(begin, end);
+ dst.rangeBegin = reader.ReadObject<K>("rangeBegin");
+ dst.rangeEnd = reader.ReadObject<K>("rangeEnd");
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core/include/ignite/ignite_binding.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/ignite_binding.h b/modules/platforms/cpp/core/include/ignite/ignite_binding.h
index a84a1c1..70bdedb 100644
--- a/modules/platforms/cpp/core/include/ignite/ignite_binding.h
+++ b/modules/platforms/cpp/core/include/ignite/ignite_binding.h
@@ -80,13 +80,12 @@ namespace ignite
template<typename P>
void RegisterCacheEntryProcessor(IgniteError& err)
{
- binary::BinaryType<P> bt;
impl::IgniteBindingImpl *im = impl.Get();
if (im)
{
im->RegisterCallback(impl::IgniteBindingImpl::CACHE_ENTRY_PROCESSOR_APPLY,
- bt.GetTypeId(), impl::binding::ListenerApply<P, typename P::KeyType,
+ binary::BinaryType<P>::GetTypeId(), impl::binding::ListenerApply<P, typename P::KeyType,
typename P::ValueType, typename P::ReturnType, typename P::ArgumentType>, err);
}
else
@@ -105,10 +104,9 @@ namespace ignite
template<typename F>
void RegisterCacheEntryEventFilter()
{
- binary::BinaryType<F> bt;
impl::IgniteBindingImpl *im = impl.Get();
- int32_t typeId = bt.GetTypeId();
+ int32_t typeId = binary::BinaryType<F>::GetTypeId();
if (im)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/core/include/ignite/impl/cache/cache_entry_processor_holder.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_entry_processor_holder.h b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_entry_processor_holder.h
index c979b4a..decbaa9 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/cache/cache_entry_processor_holder.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/cache/cache_entry_processor_holder.h
@@ -191,7 +191,7 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(UnderlyingType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(UnderlyingType)
- int32_t GetTypeId()
+ static int32_t GetTypeId()
{
static bool typeIdInited = false;
static int32_t typeId;
@@ -205,13 +205,16 @@ namespace ignite
if (typeIdInited)
return typeId;
- typeId = GetBinaryStringHashCode(GetTypeName().c_str());
+ std::string typeName;
+ GetTypeName(typeName);
+
+ typeId = GetBinaryStringHashCode(typeName.c_str());
typeIdInited = true;
return typeId;
}
- std::string GetTypeName()
+ static void GetTypeName(std::string& dst)
{
// Using static variable and only initialize it once for better
// performance. Type name can't change in the course of the
@@ -221,17 +224,25 @@ namespace ignite
// Name has been constructed already. Return it.
if (!name.empty())
- return name;
+ {
+ dst = name;
+
+ return;
+ }
common::concurrent::CsLockGuard guard(initLock);
if (!name.empty())
- return name;
+ {
+ dst = name;
+
+ return;
+ }
// Constructing name here.
- BinaryType<P> p;
+ std::string procName;
- std::string procName = p.GetTypeName();
+ BinaryType<P>::GetTypeName(procName);
// -1 is for unnessecary null byte at the end of the C-string.
name.reserve(sizeof("CacheEntryProcessorHolder<>") - 1 + procName.size());
@@ -240,10 +251,10 @@ namespace ignite
// forbidden to register the same processor type several times.
name.append("CacheEntryProcessorHolder<").append(procName).push_back('>');
- return name;
+ dst = name;
}
- void Write(BinaryWriter& writer, UnderlyingType obj)
+ static void Write(BinaryWriter& writer, const UnderlyingType& obj)
{
BinaryRawWriter raw = writer.RawWriter();
@@ -251,14 +262,14 @@ namespace ignite
raw.WriteObject(obj.getArgument());
}
- UnderlyingType Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, UnderlyingType& dst)
{
BinaryRawReader raw = reader.RawReader();
const P& proc = raw.ReadObject<P>();
const A& arg = raw.ReadObject<A>();
- return UnderlyingType(proc, arg);
+ dst = UnderlyingType(proc, arg);
}
};
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/odbc-test/include/complex_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/complex_type.h b/modules/platforms/cpp/odbc-test/include/complex_type.h
index a84b033..dd68c9b 100644
--- a/modules/platforms/cpp/odbc-test/include/complex_type.h
+++ b/modules/platforms/cpp/odbc-test/include/complex_type.h
@@ -68,20 +68,16 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(TestObject)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestObject)
- void Write(BinaryWriter& writer, TestObject obj)
+ static void Write(BinaryWriter& writer, const TestObject& obj)
{
writer.WriteInt32("f1", obj.f1);
writer.WriteString("f2", obj.f2);
}
- TestObject Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, TestObject& dst)
{
- TestObject obj;
-
- obj.f1 = reader.ReadInt32("f1");
- obj.f2 = reader.ReadString("f2");
-
- return obj;
+ dst.f1 = reader.ReadInt32("f1");
+ dst.f2 = reader.ReadString("f2");
}
IGNITE_BINARY_TYPE_END
@@ -97,22 +93,18 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(ComplexType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(ComplexType)
- void Write(BinaryWriter& writer, ComplexType obj)
+ static void Write(BinaryWriter& writer, const ComplexType& obj)
{
writer.WriteInt32("i32Field", obj.i32Field);
writer.WriteObject("objField", obj.objField);
writer.WriteString("strField", obj.strField);
}
- ComplexType Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, ComplexType& dst)
{
- ComplexType obj;
-
- obj.i32Field = reader.ReadInt32("i32Field");
- obj.objField = reader.ReadObject<TestObject>("objField");
- obj.strField = reader.ReadString("strField");
-
- return obj;
+ dst.i32Field = reader.ReadInt32("i32Field");
+ dst.objField = reader.ReadObject<TestObject>("objField");
+ dst.strField = reader.ReadString("strField");
}
IGNITE_BINARY_TYPE_END
http://git-wip-us.apache.org/repos/asf/ignite/blob/5c4d43c2/modules/platforms/cpp/odbc-test/include/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/odbc-test/include/test_type.h b/modules/platforms/cpp/odbc-test/include/test_type.h
index 51271b5..7bc6b3e 100644
--- a/modules/platforms/cpp/odbc-test/include/test_type.h
+++ b/modules/platforms/cpp/odbc-test/include/test_type.h
@@ -111,7 +111,7 @@ namespace ignite
IGNITE_BINARY_IS_NULL_FALSE(TestType)
IGNITE_BINARY_GET_NULL_DEFAULT_CTOR(TestType)
- void Write(BinaryWriter& writer, TestType obj)
+ static void Write(BinaryWriter& writer, const TestType& obj)
{
if (!obj.allNulls)
{
@@ -154,32 +154,27 @@ namespace ignite
}
}
- TestType Read(BinaryReader& reader)
+ static void Read(BinaryReader& reader, TestType& dst)
{
- int8_t i8Field = reader.ReadInt8("i8Field");
- int16_t i16Field = reader.ReadInt16("i16Field");
- int32_t i32Field = reader.ReadInt32("i32Field");
- int64_t i64Field = reader.ReadInt64("i64Field");
- std::string strField = reader.ReadString("strField");
- float floatField = reader.ReadFloat("floatField");
- double doubleField = reader.ReadDouble("doubleField");
- bool boolField = reader.ReadBool("boolField");
- Guid guidField = reader.ReadGuid("guidField");
- Date dateField = reader.ReadDate("dateField");
- Time timeField = reader.ReadTime("timeField");
- Timestamp timestampField = reader.ReadTimestamp("timestampField");
-
- TestType result(i8Field, i16Field, i32Field, i64Field, strField,
- floatField, doubleField, boolField, guidField, dateField,
- timeField, timestampField);
+ dst.i8Field = reader.ReadInt8("i8Field");
+ dst.i16Field = reader.ReadInt16("i16Field");
+ dst.i32Field = reader.ReadInt32("i32Field");
+ dst.i64Field = reader.ReadInt64("i64Field");
+ dst.strField = reader.ReadString("strField");
+ dst.floatField = reader.ReadFloat("floatField");
+ dst.doubleField = reader.ReadDouble("doubleField");
+ dst.boolField = reader.ReadBool("boolField");
+ dst.guidField = reader.ReadGuid("guidField");
+ dst.dateField = reader.ReadDate("dateField");
+ dst.timeField = reader.ReadTime("timeField");
+ dst.timestampField = reader.ReadTimestamp("timestampField");
int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
if (len > 0)
{
- result.i8ArrayField.resize(len);
- reader.ReadInt8Array("i8ArrayField", &result.i8ArrayField[0], len);
+ dst.i8ArrayField.resize(len);
+ reader.ReadInt8Array("i8ArrayField", &dst.i8ArrayField[0], len);
}
- return result;
}
IGNITE_BINARY_TYPE_END
[5/7] ignite git commit: ignite-4828 Improve the distribution of keys
within partitions
Posted by dm...@apache.org.
ignite-4828 Improve the distribution of keys within partitions
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/55ab10ee
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/55ab10ee
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/55ab10ee
Branch: refs/heads/ignite-1192
Commit: 55ab10eee485ef47a1c0794cbc90da0376ecd738
Parents: c9d08d3
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Apr 11 19:47:10 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Apr 11 19:47:10 2017 +0300
----------------------------------------------------------------------
.../rendezvous/RendezvousAffinityFunction.java | 26 ++++++++--
.../GridCachePartitionExchangeManager.java | 2 +-
...inityFunctionFastPowerOfTwoHashSelfTest.java | 50 ++++++++++++++++++++
...ousAffinityFunctionStandardHashSelfTest.java | 50 ++++++++++++++++++++
.../testsuites/IgniteCacheTestSuite2.java | 8 +++-
5 files changed, 129 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/55ab10ee/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 0fee1af..dcac7d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -101,6 +101,9 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
/** Number of partitions. */
private int parts;
+ /** Mask to use in calculation when partitions count is power of 2. */
+ private transient int mask = -1;
+
/** Exclude neighbors flag. */
private boolean exclNeighbors;
@@ -188,7 +191,9 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
A.ensure(parts > 0, "parts > 0");
this.exclNeighbors = exclNeighbors;
- this.parts = parts;
+
+ setPartitions(parts);
+
this.backupFilter = backupFilter;
try {
@@ -216,16 +221,22 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
}
/**
- * Sets total number of partitions.
+ * Sets total number of partitions.If the number of partitions is a power of two,
+ * the PowerOfTwo hashing method will be used. Otherwise the Standard hashing
+ * method will be applied.
*
* @param parts Total number of partitions.
* @return {@code this} for chaining.
*/
public RendezvousAffinityFunction setPartitions(int parts) {
- A.ensure(parts <= CacheConfiguration.MAX_PARTITIONS_COUNT, "parts <= " + CacheConfiguration.MAX_PARTITIONS_COUNT);
+ A.ensure(parts <= CacheConfiguration.MAX_PARTITIONS_COUNT,
+ "parts <= " + CacheConfiguration.MAX_PARTITIONS_COUNT);
+ A.ensure(parts > 0, "parts > 0");
this.parts = parts;
+ mask = (parts & (parts - 1)) == 0 ? parts - 1 : -1;
+
return this;
}
@@ -507,6 +518,12 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
throw new IllegalArgumentException("Null key is passed for a partition calculation. " +
"Make sure that an affinity key that is used is initialized properly.");
+ if (mask >= 0) {
+ int h;
+
+ return ((h = key.hashCode()) ^ (h >>> 16)) & mask;
+ }
+
return U.safeAbs(key.hashCode() % parts);
}
@@ -553,7 +570,8 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- parts = in.readInt();
+ setPartitions(in.readInt());
+
exclNeighbors = in.readBoolean();
hashIdRslvr = (AffinityNodeHashResolver)in.readObject();
backupFilter = (IgniteBiPredicate<ClusterNode, ClusterNode>)in.readObject();
http://git-wip-us.apache.org/repos/asf/ignite/blob/55ab10ee/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 885106d..1297c38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -42,7 +42,6 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.IgniteNeedReconnectException;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.cluster.ClusterNode;
@@ -52,6 +51,7 @@ import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.IgniteNeedReconnectException;
import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.events.DiscoveryCustomEvent;
import org.apache.ignite.internal.managers.discovery.DiscoCache;
http://git-wip-us.apache.org/repos/asf/ignite/blob/55ab10ee/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.java
new file mode 100644
index 0000000..683ffa2
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.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.cache.affinity.rendezvous;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.affinity.AbstractAffinityFunctionSelfTest;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Tests for {@link RendezvousAffinityFunction}.
+ */
+public class RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest extends AbstractAffinityFunctionSelfTest {
+ /** Ignite. */
+ private static Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ ignite = startGrid();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected AffinityFunction affinityFunction() {
+ AffinityFunction aff = new RendezvousAffinityFunction(512, null);
+
+ GridTestUtils.setFieldValue(aff, "ignite", ignite);
+
+ return aff;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55ab10ee/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionStandardHashSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionStandardHashSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionStandardHashSelfTest.java
new file mode 100644
index 0000000..ed47c57
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunctionStandardHashSelfTest.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.cache.affinity.rendezvous;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.affinity.AbstractAffinityFunctionSelfTest;
+import org.apache.ignite.cache.affinity.AffinityFunction;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Tests for {@link RendezvousAffinityFunction}.
+ */
+public class RendezvousAffinityFunctionStandardHashSelfTest extends AbstractAffinityFunctionSelfTest {
+ /** Ignite. */
+ private static Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override protected void beforeTestsStarted() throws Exception {
+ ignite = startGrid();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ stopAllGrids();
+ }
+
+ /** {@inheritDoc} */
+ @Override protected AffinityFunction affinityFunction() {
+ AffinityFunction aff = new RendezvousAffinityFunction(513, null);
+
+ GridTestUtils.setFieldValue(aff, "ignite", ignite);
+
+ return aff;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/55ab10ee/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
index e37a8a1..0db7d06 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite2.java
@@ -22,6 +22,8 @@ import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionBackupFilterSel
import org.apache.ignite.cache.affinity.fair.FairAffinityFunctionExcludeNeighborsSelfTest;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionBackupFilterSelfTest;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionExcludeNeighborsSelfTest;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunctionStandardHashSelfTest;
import org.apache.ignite.internal.processors.cache.CacheConcurrentReadThroughTest;
import org.apache.ignite.internal.processors.cache.CacheConfigurationLeakTest;
import org.apache.ignite.internal.processors.cache.CacheDhtLocalPartitionAfterRemoveSelfTest;
@@ -114,11 +116,11 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePar
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxSingleThreadedSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePartitionedTxTimeoutSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheRendezvousAffinityClientSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridPartitionedBackupLoadSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheStoreUpdateTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridNearOffheapCacheStoreUpdateTest;
+import org.apache.ignite.internal.processors.cache.distributed.near.GridPartitionedBackupLoadSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.NearCacheSyncUpdateTest;
import org.apache.ignite.internal.processors.cache.distributed.near.NoneRebalanceModeSelfTest;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearOffheapCacheStoreUpdateTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedEvictionSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedJobExecutionTest;
import org.apache.ignite.internal.processors.cache.local.GridCacheLocalAtomicBasicStoreSelfTest;
@@ -181,6 +183,8 @@ public class IgniteCacheTestSuite2 extends TestSuite {
suite.addTest(new TestSuite(GridCacheAtomicNearReadersSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedAffinitySelfTest.class));
suite.addTest(new TestSuite(RendezvousAffinityFunctionExcludeNeighborsSelfTest.class));
+ suite.addTest(new TestSuite(RendezvousAffinityFunctionFastPowerOfTwoHashSelfTest.class));
+ suite.addTest(new TestSuite(RendezvousAffinityFunctionStandardHashSelfTest.class));
suite.addTest(new TestSuite(FairAffinityFunctionExcludeNeighborsSelfTest.class));
suite.addTest(new TestSuite(GridCacheRendezvousAffinityClientSelfTest.class));
suite.addTest(new TestSuite(GridCachePartitionedProjectionAffinitySelfTest.class));
[7/7] ignite git commit: Merge remote-tracking branch
'remotes/origin/master' into ignite-1192
Posted by dm...@apache.org.
Merge remote-tracking branch 'remotes/origin/master' into ignite-1192
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1cd08969
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1cd08969
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1cd08969
Branch: refs/heads/ignite-1192
Commit: 1cd0896998bbd211d46fc5b33878243643cfa5a5
Parents: 9943411 55b9b8b
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Apr 11 19:50:27 2017 -0700
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Apr 11 19:50:27 2017 -0700
----------------------------------------------------------------------
.gitignore | 31 +-
.../rendezvous/RendezvousAffinityFunction.java | 26 +-
.../communication/GridIoMessageFactory.java | 8 +-
.../GridCachePartitionExchangeManager.java | 9 +-
.../processors/cache/GridCachePreloader.java | 4 +-
.../cache/GridCachePreloaderAdapter.java | 4 +-
.../dht/preloader/GridDhtPartitionDemander.java | 2 +-
.../dht/preloader/GridDhtPartitionSupplier.java | 310 +--------------
.../GridDhtPartitionSupplyMessage.java | 99 ++---
.../GridDhtPartitionSupplyMessageV2.java | 384 -------------------
.../dht/preloader/GridDhtPreloader.java | 3 +-
.../datastructures/GridCacheSemaphoreImpl.java | 74 +++-
.../datastructures/GridCacheSemaphoreState.java | 22 ++
.../resources/META-INF/classnames.properties | 1 -
...inityFunctionFastPowerOfTwoHashSelfTest.java | 50 +++
...ousAffinityFunctionStandardHashSelfTest.java | 50 +++
...eAbstractDataStructuresFailoverSelfTest.java | 21 +-
.../CacheLateAffinityAssignmentTest.java | 6 +-
.../IgniteCacheReadFromBackupTest.java | 6 +-
.../atomic/IgniteCacheAtomicProtocolTest.java | 3 +-
.../testsuites/IgniteCacheTestSuite2.java | 8 +-
.../binary/include/ignite/binary/binary_type.h | 129 ++-----
.../ignite/impl/binary/binary_id_resolver.h | 33 +-
.../ignite/impl/binary/binary_object_impl.h | 3 +-
.../ignite/impl/binary/binary_reader_impl.h | 80 +++-
.../ignite/impl/binary/binary_type_impl.h | 12 +-
.../include/ignite/impl/binary/binary_utils.h | 6 +-
.../ignite/impl/binary/binary_writer_impl.h | 15 +-
.../core-test/include/ignite/binary_test_defs.h | 117 +++---
.../cpp/core-test/include/ignite/complex_type.h | 30 +-
.../cpp/core-test/include/ignite/test_type.h | 37 +-
.../src/binary_identity_resolver_test.cpp | 92 ++---
.../cpp/core-test/src/binary_object_test.cpp | 4 +-
.../cpp/core-test/src/binary_test_defs.cpp | 5 +
.../cpp/core-test/src/cache_invoke_test.cpp | 18 +-
.../cpp/core-test/src/cache_query_test.cpp | 12 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 38 +-
.../cpp/core-test/src/continuous_query_test.cpp | 34 +-
.../cpp/core/include/ignite/ignite_binding.h | 6 +-
.../impl/cache/cache_entry_processor_holder.h | 33 +-
.../cpp/odbc-test/include/complex_type.h | 26 +-
.../platforms/cpp/odbc-test/include/test_type.h | 37 +-
.../cache/websession/WebSessionFilter.java | 22 +-
43 files changed, 692 insertions(+), 1218 deletions(-)
----------------------------------------------------------------------
[3/7] ignite git commit: ignite-1977 - fixed IgniteSemaphore fault
tolerance.
Posted by dm...@apache.org.
ignite-1977 - fixed IgniteSemaphore fault tolerance.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/902bf42c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/902bf42c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/902bf42c
Branch: refs/heads/ignite-1192
Commit: 902bf42c36f46b0aaa605b779a699eb8e0c0aca3
Parents: aeacad6
Author: Vladisav Jelisavcic <vl...@gmail.com>
Authored: Tue Apr 11 14:09:12 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Apr 11 14:09:12 2017 +0300
----------------------------------------------------------------------
.../datastructures/GridCacheSemaphoreImpl.java | 74 +++++++++++++++++---
.../datastructures/GridCacheSemaphoreState.java | 22 ++++++
...eAbstractDataStructuresFailoverSelfTest.java | 21 ++++--
3 files changed, 102 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/902bf42c/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
index a1c0515..159e735 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreImpl.java
@@ -232,6 +232,10 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
/** {@inheritDoc} */
@Override protected final boolean tryReleaseShared(int releases) {
+ // Fail-fast path.
+ if(broken)
+ return true;
+
// Check if some other node updated the state.
// This method is called with release==0 only when trying to wake through update.
if (releases == 0)
@@ -295,6 +299,13 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
throw new IgniteCheckedException("Failed to find semaphore with given name: " +
name);
+ // Abort if state is already broken.
+ if (val.isBroken()) {
+ tx.rollback();
+
+ return true;
+ }
+
boolean retVal = val.getCount() == expVal;
if (retVal) {
@@ -349,11 +360,13 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
/**
* This method is used for releasing the permits acquired by failing node.
+ * In case the semaphore is broken, no permits are released and semaphore is set (globally) to broken state.
*
* @param nodeId ID of the failing node.
+ * @param broken Flag indicating that this semaphore is broken.
* @return True if this is the call that succeeded to change the global state.
*/
- protected boolean releaseFailedNode(final UUID nodeId) {
+ protected boolean releaseFailedNode(final UUID nodeId, final boolean broken) {
try {
return CU.outTx(
retryTopologySafe(new Callable<Boolean>() {
@@ -369,6 +382,25 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
throw new IgniteCheckedException("Failed to find semaphore with given name: " +
name);
+ // Quit early if semaphore is already broken.
+ if( val.isBroken()) {
+ tx.rollback();
+
+ return false;
+ }
+
+ // Mark semaphore as broken. No permits are released,
+ // since semaphore is useless from now on.
+ if (broken) {
+ val.setBroken(true);
+
+ semView.put(key, val);
+
+ tx.commit();
+
+ return true;
+ }
+
Map<UUID, Integer> map = val.getWaiters();
if (!map.containsKey(nodeId)) {
@@ -473,7 +505,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
tx.commit();
- return new Sync(cnt, waiters, failoverSafe);
+ Sync sync = new Sync(cnt, waiters, failoverSafe);
+
+ sync.setBroken(val.isBroken());
+
+ return sync;
}
}
}),
@@ -520,6 +556,9 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
if (sync == null)
return;
+ // Update broken flag.
+ sync.setBroken(val.isBroken());
+
// Update permission count.
sync.setPermits(val.getCount());
@@ -535,10 +574,13 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
int numPermits = sync.getPermitsForNode(nodeId);
if (numPermits > 0) {
- if (sync.failoverSafe)
- // Release permits acquired by threads on failing node.
- sync.releaseFailedNode(nodeId);
- else {
+ // Semaphore is broken if reaches this point in non-failover safe mode.
+ boolean broken = !sync.failoverSafe;
+
+ // Release permits acquired by threads on failing node.
+ sync.releaseFailedNode(nodeId, broken);
+
+ if (broken) {
// Interrupt every waiting thread if this semaphore is not failover safe.
sync.setBroken(true);
@@ -614,8 +656,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
sync.acquireSharedInterruptibly(permits);
- if (isBroken())
+ if (isBroken()) {
+ Thread.interrupted(); // Clear interrupt flag.
+
throw new InterruptedException();
+ }
}
catch (IgniteCheckedException e) {
throw U.convertException(e);
@@ -731,8 +776,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
boolean result = sync.nonfairTryAcquireShared(1) >= 0;
- if (isBroken())
+ if (isBroken()) {
+ Thread.interrupted(); // Clear interrupt flag.
+
throw new InterruptedException();
+ }
return result;
}
@@ -756,8 +804,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
boolean result = sync.tryAcquireSharedNanos(1, unit.toNanos(timeout));
- if (isBroken())
+ if (isBroken()) {
+ Thread.interrupted(); // Clear interrupt flag.
+
throw new InterruptedException();
+ }
return result;
}
@@ -825,8 +876,11 @@ public final class GridCacheSemaphoreImpl implements GridCacheSemaphoreEx, Exter
boolean result = sync.tryAcquireSharedNanos(permits, unit.toNanos(timeout));
- if (isBroken())
+ if (isBroken()) {
+ Thread.interrupted();
+
throw new InterruptedException();
+ }
return result;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/902bf42c/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreState.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreState.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreState.java
index 50cdf10..cdff9c5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreState.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSemaphoreState.java
@@ -46,6 +46,9 @@ public class GridCacheSemaphoreState implements GridCacheInternal, Externalizabl
/** FailoverSafe flag. */
private boolean failoverSafe;
+ /** Flag indicating that semaphore is no longer safe to use. */
+ private boolean broken;
+
/**
* Constructor.
*
@@ -101,6 +104,21 @@ public class GridCacheSemaphoreState implements GridCacheInternal, Externalizabl
return failoverSafe;
}
+ /**
+ * @return broken flag.
+ */
+ public boolean isBroken() {
+ return broken;
+ }
+
+ /**
+ *
+ * @param broken Flag indicating that this semaphore should be no longer used.
+ */
+ public void setBroken(boolean broken) {
+ this.broken = broken;
+ }
+
/** {@inheritDoc} */
@Override public Object clone() throws CloneNotSupportedException {
return super.clone();
@@ -120,6 +138,8 @@ public class GridCacheSemaphoreState implements GridCacheInternal, Externalizabl
out.writeInt(e.getValue());
}
}
+
+ out.writeBoolean(broken);
}
/** {@inheritDoc} */
@@ -135,6 +155,8 @@ public class GridCacheSemaphoreState implements GridCacheInternal, Externalizabl
for (int i = 0; i < size; i++)
waiters.put(U.readUuid(in), in.readInt());
}
+
+ broken = in.readBoolean();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/902bf42c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
index 285ea6e..f918acd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractDataStructuresFailoverSelfTest.java
@@ -530,8 +530,6 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
* @throws Exception If failed.
*/
private void doTestSemaphore(ConstantTopologyChangeWorker topWorker, final boolean failoverSafe) throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1977");
-
final int permits = topWorker instanceof MultipleTopologyChangeWorker ||
topWorker instanceof PartitionedMultipleTopologyChangeWorker ? TOP_CHANGE_THREAD_CNT * 3 :
TOP_CHANGE_CNT;
@@ -548,9 +546,14 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
break;
}
catch (IgniteInterruptedException e) {
- // Exception may happen in non failover safe mode.
+ // Exception may happen in non failover safe mode.
if (failoverSafe)
throw e;
+ else {
+ // In non-failoverSafe mode semaphore is not safe to be reused,
+ // and should always be discarded after exception is caught.
+ break;
+ }
}
}
@@ -569,6 +572,11 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
// Exception may happen in non failover safe mode.
if (failoverSafe)
throw e;
+ else {
+ // In non-failoverSafe mode semaphore is not safe to be reused,
+ // and should always be discarded after exception is caught.
+ break;
+ }
}
}
@@ -581,8 +589,11 @@ public abstract class GridCacheAbstractDataStructuresFailoverSelfTest extends Ig
fut.get();
- for (Ignite g : G.allGrids())
- assertEquals(permits, g.semaphore(STRUCTURE_NAME, permits, false, false).availablePermits());
+ // Semaphore is left in proper state only if failoverSafe mode is used.
+ if (failoverSafe) {
+ for (Ignite g : G.allGrids())
+ assertEquals(permits, g.semaphore(STRUCTURE_NAME, permits, false, false).availablePermits());
+ }
}
}
[4/7] ignite git commit: Merge remote-tracking branch 'origin/master'
Posted by dm...@apache.org.
Merge remote-tracking branch 'origin/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c9d08d39
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c9d08d39
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c9d08d39
Branch: refs/heads/ignite-1192
Commit: c9d08d39eecc216a788bf023929d74a011ebdd0e
Parents: 902bf42 5c4d43c
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Apr 11 14:09:30 2017 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Apr 11 14:09:30 2017 +0300
----------------------------------------------------------------------
.gitignore | 31 ++++-
.../binary/include/ignite/binary/binary_type.h | 129 ++++++-------------
.../ignite/impl/binary/binary_id_resolver.h | 33 ++---
.../ignite/impl/binary/binary_object_impl.h | 3 +-
.../ignite/impl/binary/binary_reader_impl.h | 80 +++++++++++-
.../ignite/impl/binary/binary_type_impl.h | 12 +-
.../include/ignite/impl/binary/binary_utils.h | 6 +-
.../ignite/impl/binary/binary_writer_impl.h | 15 ++-
.../core-test/include/ignite/binary_test_defs.h | 117 +++++++++--------
.../cpp/core-test/include/ignite/complex_type.h | 30 ++---
.../cpp/core-test/include/ignite/test_type.h | 37 +++---
.../src/binary_identity_resolver_test.cpp | 92 +++++--------
.../cpp/core-test/src/binary_object_test.cpp | 4 +-
.../cpp/core-test/src/binary_test_defs.cpp | 5 +
.../cpp/core-test/src/cache_invoke_test.cpp | 18 +--
.../cpp/core-test/src/cache_query_test.cpp | 12 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 38 +++---
.../cpp/core-test/src/continuous_query_test.cpp | 34 +++--
.../cpp/core/include/ignite/ignite_binding.h | 6 +-
.../impl/cache/cache_entry_processor_holder.h | 33 +++--
.../cpp/odbc-test/include/complex_type.h | 26 ++--
.../platforms/cpp/odbc-test/include/test_type.h | 37 +++---
22 files changed, 393 insertions(+), 405 deletions(-)
----------------------------------------------------------------------