You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2015/11/08 18:22:57 UTC
[01/50] [abbrv] ignite git commit: Merge remote-tracking branch
'apache/master'
Repository: ignite
Updated Branches:
refs/heads/ignite-1702 a45a788fc -> 2da1cc3cd
Merge remote-tracking branch 'apache/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d24bf49c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d24bf49c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d24bf49c
Branch: refs/heads/ignite-1702
Commit: d24bf49cd87e37b9d16de074ad8c3ceb9024a1dd
Parents: c122dcb 303def3
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 29 14:24:07 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 29 14:24:07 2015 +0300
----------------------------------------------------------------------
.../cache/affinity/fair/FairAffinityDynamicCacheSelfTest.java | 2 ++
.../processors/cache/CacheSerializableTransactionsTest.java | 2 ++
.../processors/cache/CrossCacheTxRandomOperationsTest.java | 2 ++
3 files changed, 6 insertions(+)
----------------------------------------------------------------------
[47/50] [abbrv] ignite git commit: Ignite-1093 "Rebalancing with
default parameters is very slow" fixes.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandPool.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandPool.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandPool.java
deleted file mode 100644
index e993a88..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandPool.java
+++ /dev/null
@@ -1,1192 +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.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.BrokenBarrierException;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.atomic.AtomicLong;
-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.IgniteLogger;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.events.DiscoveryEvent;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-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.GridCacheEntryEx;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
-import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
-import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.apache.ignite.internal.util.future.GridFutureAdapter;
-import org.apache.ignite.internal.util.tostring.GridToStringInclude;
-import org.apache.ignite.internal.util.typedef.CI1;
-import org.apache.ignite.internal.util.typedef.CI2;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.LT;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.internal.util.worker.GridWorker;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteUuid;
-import org.apache.ignite.thread.IgniteThread;
-import org.jetbrains.annotations.Nullable;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_LOADED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STOPPED;
-import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
-import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
-import static org.apache.ignite.internal.processors.dr.GridDrType.DR_PRELOAD;
-
-/**
- * Thread pool for requesting partitions from other nodes
- * and populating local cache.
- */
-@SuppressWarnings("NonConstantFieldWithUpperCaseName")
-public class GridDhtPartitionDemandPool {
- /** Dummy message to wake up a blocking queue if a node leaves. */
- private final SupplyMessage DUMMY_TOP = new SupplyMessage();
-
- /** */
- private final GridCacheContext<?, ?> cctx;
-
- /** */
- private final IgniteLogger log;
-
- /** */
- private final ReadWriteLock busyLock;
-
- /** */
- @GridToStringInclude
- private final Collection<DemandWorker> dmdWorkers;
-
- /** Preload predicate. */
- private IgnitePredicate<GridCacheEntryInfo> preloadPred;
-
- /** Future for preload mode {@link CacheRebalanceMode#SYNC}. */
- @GridToStringInclude
- private SyncFuture syncFut;
-
- /** Preload timeout. */
- private final AtomicLong timeout;
-
- /** Allows demand threads to synchronize their step. */
- private CyclicBarrier barrier;
-
- /** Demand lock. */
- private final ReadWriteLock demandLock = new ReentrantReadWriteLock();
-
- /** */
- private int poolSize;
-
- /** Last timeout object. */
- private AtomicReference<GridTimeoutObject> lastTimeoutObj = new AtomicReference<>();
-
- /** Last exchange future. */
- private volatile GridDhtPartitionsExchangeFuture lastExchangeFut;
-
- /**
- * @param cctx Cache context.
- * @param busyLock Shutdown lock.
- */
- public GridDhtPartitionDemandPool(GridCacheContext<?, ?> cctx, ReadWriteLock busyLock) {
- assert cctx != null;
- assert busyLock != null;
-
- this.cctx = cctx;
- this.busyLock = busyLock;
-
- log = cctx.logger(getClass());
-
- boolean enabled = cctx.rebalanceEnabled() && !cctx.kernalContext().clientNode();
-
- poolSize = enabled ? cctx.config().getRebalanceThreadPoolSize() : 0;
-
- if (enabled) {
- barrier = new CyclicBarrier(poolSize);
-
- dmdWorkers = new ArrayList<>(poolSize);
-
- for (int i = 0; i < poolSize; i++)
- dmdWorkers.add(new DemandWorker(i));
-
- syncFut = new SyncFuture(dmdWorkers);
- }
- else {
- dmdWorkers = Collections.emptyList();
-
- syncFut = new SyncFuture(dmdWorkers);
-
- // Calling onDone() immediately since preloading is disabled.
- syncFut.onDone();
- }
-
- timeout = new AtomicLong(cctx.config().getRebalanceTimeout());
- }
-
- /**
- *
- */
- void start() {
- if (poolSize > 0) {
- for (DemandWorker w : dmdWorkers)
- new IgniteThread(cctx.gridName(), "preloader-demand-worker", w).start();
- }
- }
-
- /**
- *
- */
- void stop() {
- U.cancel(dmdWorkers);
-
- if (log.isDebugEnabled())
- log.debug("Before joining on demand workers: " + dmdWorkers);
-
- U.join(dmdWorkers, log);
-
- if (log.isDebugEnabled())
- log.debug("After joining on demand workers: " + dmdWorkers);
-
- lastExchangeFut = null;
-
- lastTimeoutObj.set(null);
- }
-
- /**
- * @return Future for {@link CacheRebalanceMode#SYNC} mode.
- */
- IgniteInternalFuture<?> syncFuture() {
- return syncFut;
- }
-
- /**
- * Sets preload predicate for demand pool.
- *
- * @param preloadPred Preload predicate.
- */
- void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred) {
- this.preloadPred = preloadPred;
- }
-
- /**
- * @return Size of this thread pool.
- */
- int poolSize() {
- return poolSize;
- }
-
- /**
- * Wakes up demand workers when new exchange future was added.
- */
- void onExchangeFutureAdded() {
- synchronized (dmdWorkers) {
- for (DemandWorker w : dmdWorkers)
- w.addMessage(DUMMY_TOP);
- }
- }
-
- /**
- * Force preload.
- */
- void forcePreload() {
- GridTimeoutObject obj = lastTimeoutObj.getAndSet(null);
-
- if (obj != null)
- cctx.time().removeTimeoutObject(obj);
-
- final GridDhtPartitionsExchangeFuture exchFut = lastExchangeFut;
-
- if (exchFut != null) {
- if (log.isDebugEnabled())
- log.debug("Forcing rebalance event for future: " + exchFut);
-
- exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
- @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
- cctx.shared().exchange().forcePreloadExchange(exchFut);
- }
- });
- }
- else if (log.isDebugEnabled())
- log.debug("Ignoring force rebalance request (no topology event happened yet).");
- }
-
- /**
- * @return {@code true} if entered to busy state.
- */
- private boolean enterBusy() {
- if (busyLock.readLock().tryLock())
- return true;
-
- if (log.isDebugEnabled())
- log.debug("Failed to enter to busy state (demander is stopping): " + cctx.nodeId());
-
- return false;
- }
-
- /**
- *
- */
- private void leaveBusy() {
- busyLock.readLock().unlock();
- }
-
- /**
- * @param type Type.
- * @param discoEvt Discovery event.
- */
- private void preloadEvent(int type, DiscoveryEvent discoEvt) {
- preloadEvent(-1, type, discoEvt);
- }
-
- /**
- * @param part Partition.
- * @param type Type.
- * @param discoEvt Discovery event.
- */
- private void preloadEvent(int part, int type, DiscoveryEvent discoEvt) {
- assert discoEvt != null;
-
- cctx.events().addPreloadEvent(part, type, discoEvt.eventNode(), discoEvt.type(), discoEvt.timestamp());
- }
-
- /**
- * @param msg Message to check.
- * @return {@code True} if dummy message.
- */
- private boolean dummyTopology(SupplyMessage msg) {
- return msg == DUMMY_TOP;
- }
-
- /**
- * @param deque Deque to poll from.
- * @param time Time to wait.
- * @param w Worker.
- * @return Polled item.
- * @throws InterruptedException If interrupted.
- */
- @Nullable private <T> T poll(BlockingQueue<T> deque, long time, GridWorker w) throws InterruptedException {
- assert w != null;
-
- // There is currently a case where {@code interrupted}
- // flag on a thread gets flipped during stop which causes the pool to hang. This check
- // will always make sure that interrupted flag gets reset before going into wait conditions.
- // The true fix should actually make sure that interrupted flag does not get reset or that
- // interrupted exception gets propagated. Until we find a real fix, this method should
- // always work to make sure that there is no hanging during stop.
- if (w.isCancelled())
- Thread.currentThread().interrupt();
-
- return deque.poll(time, MILLISECONDS);
- }
-
- /**
- * @param p Partition.
- * @param topVer Topology version.
- * @return Picked owners.
- */
- private Collection<ClusterNode> pickedOwners(int p, AffinityTopologyVersion topVer) {
- Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
-
- int affCnt = affNodes.size();
-
- Collection<ClusterNode> rmts = remoteOwners(p, topVer);
-
- int rmtCnt = rmts.size();
-
- if (rmtCnt <= affCnt)
- return rmts;
-
- List<ClusterNode> sorted = new ArrayList<>(rmts);
-
- // Sort in descending order, so nodes with higher order will be first.
- Collections.sort(sorted, CU.nodeComparator(false));
-
- // Pick newest nodes.
- return sorted.subList(0, affCnt);
- }
-
- /**
- * @param p Partition.
- * @param topVer Topology version.
- * @return Nodes owning this partition.
- */
- private Collection<ClusterNode> remoteOwners(int p, AffinityTopologyVersion topVer) {
- return F.view(cctx.dht().topology().owners(p, topVer), F.remoteNodes(cctx.nodeId()));
- }
-
- /**
- * @param assigns Assignments.
- * @param force {@code True} if dummy reassign.
- */
- void addAssignments(final GridDhtPreloaderAssignments assigns, boolean force) {
- if (log.isDebugEnabled())
- log.debug("Adding partition assignments: " + assigns);
-
- long delay = cctx.config().getRebalanceDelay();
-
- if (delay == 0 || force) {
- assert assigns != null;
-
- synchronized (dmdWorkers) {
- for (DemandWorker w : dmdWorkers) {
- w.addAssignments(assigns);
-
- w.addMessage(DUMMY_TOP);
- }
- }
- }
- else if (delay > 0) {
- assert !force;
-
- GridTimeoutObject obj = lastTimeoutObj.get();
-
- if (obj != null)
- cctx.time().removeTimeoutObject(obj);
-
- final GridDhtPartitionsExchangeFuture exchFut = lastExchangeFut;
-
- assert exchFut != null : "Delaying rebalance process without topology event.";
-
- obj = new GridTimeoutObjectAdapter(delay) {
- @Override public void onTimeout() {
- exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
- @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> f) {
- cctx.shared().exchange().forcePreloadExchange(exchFut);
- }
- });
- }
- };
-
- lastTimeoutObj.set(obj);
-
- cctx.time().addTimeoutObject(obj);
- }
- }
-
- /**
- *
- */
- void unwindUndeploys() {
- demandLock.writeLock().lock();
-
- try {
- cctx.deploy().unwind(cctx);
- }
- finally {
- demandLock.writeLock().unlock();
- }
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(GridDhtPartitionDemandPool.class, this);
- }
-
- /**
- *
- */
- private class DemandWorker extends GridWorker {
- /** Worker ID. */
- private int id;
-
- /** Partition-to-node assignments. */
- private final LinkedBlockingDeque<GridDhtPreloaderAssignments> assignQ = new LinkedBlockingDeque<>();
-
- /** Message queue. */
- private final LinkedBlockingDeque<SupplyMessage> msgQ =
- new LinkedBlockingDeque<>();
-
- /** Counter. */
- private long cntr;
-
- /** Hide worker logger and use cache logger instead. */
- private IgniteLogger log = GridDhtPartitionDemandPool.this.log;
-
- /**
- * @param id Worker ID.
- */
- private DemandWorker(int id) {
- super(cctx.gridName(), "preloader-demand-worker", GridDhtPartitionDemandPool.this.log);
-
- assert id >= 0;
-
- this.id = id;
- }
-
- /**
- * @param assigns Assignments.
- */
- void addAssignments(GridDhtPreloaderAssignments assigns) {
- assert assigns != null;
-
- assignQ.offer(assigns);
-
- if (log.isDebugEnabled())
- log.debug("Added assignments to worker: " + this);
- }
-
- /**
- * @return {@code True} if topology changed.
- */
- private boolean topologyChanged() {
- return !assignQ.isEmpty() || cctx.shared().exchange().topologyChanged();
- }
-
- /**
- * @param msg Message.
- */
- private void addMessage(SupplyMessage msg) {
- if (!enterBusy())
- return;
-
- try {
- assert dummyTopology(msg) || msg.supply().workerId() == id;
-
- msgQ.offer(msg);
- }
- finally {
- leaveBusy();
- }
- }
-
- /**
- * @param timeout Timed out value.
- */
- private void growTimeout(long timeout) {
- long newTimeout = (long)(timeout * 1.5D);
-
- // Account for overflow.
- if (newTimeout < 0)
- newTimeout = Long.MAX_VALUE;
-
- // Grow by 50% only if another thread didn't do it already.
- if (GridDhtPartitionDemandPool.this.timeout.compareAndSet(timeout, newTimeout))
- U.warn(log, "Increased rebalancing message timeout from " + timeout + "ms to " +
- newTimeout + "ms.");
- }
-
- /**
- * @param pick Node picked for preloading.
- * @param p Partition.
- * @param entry Preloaded entry.
- * @param topVer Topology version.
- * @return {@code False} if partition has become invalid during preloading.
- * @throws IgniteInterruptedCheckedException If interrupted.
- */
- private boolean preloadEntry(
- ClusterNode pick,
- int p,
- GridCacheEntryInfo entry,
- AffinityTopologyVersion topVer
- ) throws IgniteCheckedException {
- try {
- GridCacheEntryEx cached = null;
-
- try {
- cached = cctx.dht().entryEx(entry.key());
-
- if (log.isDebugEnabled())
- log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + pick.id() + ']');
-
- if (cctx.dht().isIgfsDataCache() &&
- cctx.dht().igfsDataSpaceUsed() > cctx.dht().igfsDataSpaceMax()) {
- LT.error(log, null, "Failed to rebalance IGFS data cache (IGFS space size exceeded maximum " +
- "value, will ignore rebalance entries): " + name());
-
- if (cached.markObsoleteIfEmpty(null))
- cached.context().cache().removeIfObsolete(cached.key());
-
- return true;
- }
-
- if (preloadPred == null || preloadPred.apply(entry)) {
- if (cached.initialValue(
- entry.value(),
- entry.version(),
- entry.ttl(),
- entry.expireTime(),
- true,
- topVer,
- cctx.isDrEnabled() ? DR_PRELOAD : DR_NONE
- )) {
- cctx.evicts().touch(cached, topVer); // Start tracking.
-
- if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_LOADED) && !cached.isInternal())
- cctx.events().addEvent(cached.partition(), cached.key(), cctx.localNodeId(),
- (IgniteUuid)null, null, EVT_CACHE_REBALANCE_OBJECT_LOADED, entry.value(), true, null,
- false, null, null, null);
- }
- else if (log.isDebugEnabled())
- log.debug("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() +
- ", part=" + p + ']');
- }
- else if (log.isDebugEnabled())
- log.debug("Rebalance predicate evaluated to false for entry (will ignore): " + entry);
- }
- catch (GridCacheEntryRemovedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Entry has been concurrently removed while rebalancing (will ignore) [key=" +
- cached.key() + ", part=" + p + ']');
- }
- catch (GridDhtInvalidPartitionException ignored) {
- if (log.isDebugEnabled())
- log.debug("Partition became invalid during rebalancing (will ignore): " + p);
-
- return false;
- }
- }
- catch (IgniteInterruptedCheckedException e) {
- throw e;
- }
- catch (IgniteCheckedException e) {
- throw new IgniteCheckedException("Failed to cache rebalanced entry (will stop rebalancing) [local=" +
- cctx.nodeId() + ", node=" + pick.id() + ", key=" + entry.key() + ", part=" + p + ']', e);
- }
-
- return true;
- }
-
- /**
- * @param idx Unique index for this topic.
- * @return Topic for partition.
- */
- public Object topic(long idx) {
- return TOPIC_CACHE.topic(cctx.namexx(), cctx.nodeId(), id, idx);
- }
-
- /**
- * @param node Node to demand from.
- * @param topVer Topology version.
- * @param d Demand message.
- * @param exchFut Exchange future.
- * @return Missed partitions.
- * @throws InterruptedException If interrupted.
- * @throws ClusterTopologyCheckedException If node left.
- * @throws IgniteCheckedException If failed to send message.
- */
- private Set<Integer> demandFromNode(
- ClusterNode node,
- final AffinityTopologyVersion topVer,
- GridDhtPartitionDemandMessage d,
- GridDhtPartitionsExchangeFuture exchFut
- ) throws InterruptedException, IgniteCheckedException {
- GridDhtPartitionTopology top = cctx.dht().topology();
-
- cntr++;
-
- d.topic(topic(cntr));
- d.workerId(id);
-
- Set<Integer> missed = new HashSet<>();
-
- // Get the same collection that will be sent in the message.
- Collection<Integer> remaining = d.partitions();
-
- // Drain queue before processing a new node.
- drainQueue();
-
- if (isCancelled() || topologyChanged())
- return missed;
-
- cctx.io().addOrderedHandler(d.topic(), new CI2<UUID, GridDhtPartitionSupplyMessage>() {
- @Override public void apply(UUID nodeId, GridDhtPartitionSupplyMessage msg) {
- addMessage(new SupplyMessage(nodeId, msg));
- }
- });
-
- try {
- boolean retry;
-
- // DoWhile.
- // =======
- do {
- retry = false;
-
- // Create copy.
- d = new GridDhtPartitionDemandMessage(d, remaining);
-
- long timeout = GridDhtPartitionDemandPool.this.timeout.get();
-
- d.timeout(timeout);
-
- if (log.isDebugEnabled())
- log.debug("Sending demand message [node=" + node.id() + ", demand=" + d + ']');
-
- // Send demand message.
- cctx.io().send(node, d, cctx.ioPolicy());
-
- // While.
- // =====
- while (!isCancelled() && !topologyChanged()) {
- SupplyMessage s = poll(msgQ, timeout, this);
-
- // If timed out.
- if (s == null) {
- if (msgQ.isEmpty()) { // Safety check.
- U.warn(log, "Timed out waiting for partitions to load, will retry in " + timeout +
- " ms (you may need to increase 'networkTimeout' or 'rebalanceBatchSize'" +
- " configuration properties).");
-
- growTimeout(timeout);
-
- // Ordered listener was removed if timeout expired.
- cctx.io().removeOrderedHandler(d.topic());
-
- // Must create copy to be able to work with IO manager thread local caches.
- d = new GridDhtPartitionDemandMessage(d, remaining);
-
- // Create new topic.
- d.topic(topic(++cntr));
-
- // Create new ordered listener.
- cctx.io().addOrderedHandler(d.topic(),
- new CI2<UUID, GridDhtPartitionSupplyMessage>() {
- @Override public void apply(UUID nodeId,
- GridDhtPartitionSupplyMessage msg) {
- addMessage(new SupplyMessage(nodeId, msg));
- }
- });
-
- // Resend message with larger timeout.
- retry = true;
-
- break; // While.
- }
- else
- continue; // While.
- }
-
- // If topology changed.
- if (dummyTopology(s)) {
- if (topologyChanged())
- break; // While.
- else
- continue; // While.
- }
-
- // Check that message was received from expected node.
- if (!s.senderId().equals(node.id())) {
- U.warn(log, "Received supply message from unexpected node [expectedId=" + node.id() +
- ", rcvdId=" + s.senderId() + ", msg=" + s + ']');
-
- continue; // While.
- }
-
- if (log.isDebugEnabled())
- log.debug("Received supply message: " + s);
-
- GridDhtPartitionSupplyMessage supply = s.supply();
-
- // Check whether there were class loading errors on unmarshal
- if (supply.classError() != null) {
- if (log.isDebugEnabled())
- log.debug("Class got undeployed during preloading: " + supply.classError());
-
- retry = true;
-
- // Quit preloading.
- break;
- }
-
- // Preload.
- for (Map.Entry<Integer, CacheEntryInfoCollection> e : supply.infos().entrySet()) {
- int p = e.getKey();
-
- if (cctx.affinity().localNode(p, topVer)) {
- GridDhtLocalPartition part = top.localPartition(p, topVer, true);
-
- assert part != null;
-
- if (part.state() == MOVING) {
- boolean reserved = part.reserve();
-
- assert reserved : "Failed to reserve partition [gridName=" +
- cctx.gridName() + ", cacheName=" + cctx.namex() + ", part=" + part + ']';
-
- part.lock();
-
- try {
- Collection<Integer> invalidParts = new GridLeanSet<>();
-
- // Loop through all received entries and try to preload them.
- for (GridCacheEntryInfo entry : e.getValue().infos()) {
- if (!invalidParts.contains(p)) {
- if (!part.preloadingPermitted(entry.key(), entry.version())) {
- if (log.isDebugEnabled())
- log.debug("Preloading is not permitted for entry due to " +
- "evictions [key=" + entry.key() +
- ", ver=" + entry.version() + ']');
-
- continue;
- }
-
- if (!preloadEntry(node, p, entry, topVer)) {
- invalidParts.add(p);
-
- if (log.isDebugEnabled())
- log.debug("Got entries for invalid partition during " +
- "preloading (will skip) [p=" + p + ", entry=" + entry + ']');
- }
- }
- }
-
- boolean last = supply.last().contains(p);
-
- // If message was last for this partition,
- // then we take ownership.
- if (last) {
- remaining.remove(p);
-
- top.own(part);
-
- if (log.isDebugEnabled())
- log.debug("Finished rebalancing partition: " + part);
-
- if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
- preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
- exchFut.discoveryEvent());
- }
- }
- finally {
- part.unlock();
- part.release();
- }
- }
- else {
- remaining.remove(p);
-
- if (log.isDebugEnabled())
- log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
- }
- }
- else {
- remaining.remove(p);
-
- if (log.isDebugEnabled())
- log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
- }
- }
-
- remaining.removeAll(s.supply().missed());
-
- // Only request partitions based on latest topology version.
- for (Integer miss : s.supply().missed())
- if (cctx.affinity().localNode(miss, topVer))
- missed.add(miss);
-
- if (remaining.isEmpty())
- break; // While.
-
- if (s.supply().ack()) {
- retry = true;
-
- break;
- }
- }
- }
- while (retry && !isCancelled() && !topologyChanged());
-
- return missed;
- }
- finally {
- cctx.io().removeOrderedHandler(d.topic());
- }
- }
-
- /**
- * @throws InterruptedException If interrupted.
- */
- private void drainQueue() throws InterruptedException {
- while (!msgQ.isEmpty()) {
- SupplyMessage msg = msgQ.take();
-
- if (log.isDebugEnabled())
- log.debug("Drained supply message: " + msg);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
- try {
- int rebalanceOrder = cctx.config().getRebalanceOrder();
-
- if (!CU.isMarshallerCache(cctx.name())) {
- if (log.isDebugEnabled())
- log.debug("Waiting for marshaller cache preload [cacheName=" + cctx.name() + ']');
-
- try {
- cctx.kernalContext().cache().marshallerCache().preloader().syncFuture().get();
- }
- catch (IgniteInterruptedCheckedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Failed to wait for marshaller cache preload future (grid is stopping): " +
- "[cacheName=" + cctx.name() + ']');
-
- return;
- }
- catch (IgniteCheckedException e) {
- throw new Error("Ordered preload future should never fail: " + e.getMessage(), e);
- }
- }
-
- if (rebalanceOrder > 0) {
- IgniteInternalFuture<?> fut = cctx.kernalContext().cache().orderedPreloadFuture(rebalanceOrder);
-
- try {
- if (fut != null) {
- if (log.isDebugEnabled())
- log.debug("Waiting for dependant caches rebalance [cacheName=" + cctx.name() +
- ", rebalanceOrder=" + rebalanceOrder + ']');
-
- fut.get();
- }
- }
- catch (IgniteInterruptedCheckedException ignored) {
- if (log.isDebugEnabled())
- log.debug("Failed to wait for ordered rebalance future (grid is stopping): " +
- "[cacheName=" + cctx.name() + ", rebalanceOrder=" + rebalanceOrder + ']');
-
- return;
- }
- catch (IgniteCheckedException e) {
- throw new Error("Ordered rebalance future should never fail: " + e.getMessage(), e);
- }
- }
-
- GridDhtPartitionsExchangeFuture exchFut = null;
-
- boolean stopEvtFired = false;
-
- while (!isCancelled()) {
- try {
- barrier.await();
-
- if (id == 0 && exchFut != null && !exchFut.dummy() &&
- cctx.events().isRecordable(EVT_CACHE_REBALANCE_STOPPED)) {
-
- if (!cctx.isReplicated() || !stopEvtFired) {
- preloadEvent(EVT_CACHE_REBALANCE_STOPPED, exchFut.discoveryEvent());
-
- stopEvtFired = true;
- }
- }
- }
- catch (BrokenBarrierException ignore) {
- throw new InterruptedException("Demand worker stopped.");
- }
-
- // Sync up all demand threads at this step.
- GridDhtPreloaderAssignments assigns = null;
-
- while (assigns == null)
- assigns = poll(assignQ, cctx.gridConfig().getNetworkTimeout(), this);
-
- demandLock.readLock().lock();
-
- try {
- exchFut = assigns.exchangeFuture();
-
- // Assignments are empty if preloading is disabled.
- if (assigns.isEmpty())
- continue;
-
- boolean resync = false;
-
- // While.
- // =====
- while (!isCancelled() && !topologyChanged() && !resync) {
- Collection<Integer> missed = new HashSet<>();
-
- // For.
- // ===
- for (ClusterNode node : assigns.keySet()) {
- if (topologyChanged() || isCancelled())
- break; // For.
-
- GridDhtPartitionDemandMessage d = assigns.remove(node);
-
- // If another thread is already processing this message,
- // move to the next node.
- if (d == null)
- continue; // For.
-
- try {
- Set<Integer> set = demandFromNode(node, assigns.topologyVersion(), d, exchFut);
-
- if (!set.isEmpty()) {
- if (log.isDebugEnabled())
- log.debug("Missed partitions from node [nodeId=" + node.id() + ", missed=" +
- set + ']');
-
- missed.addAll(set);
- }
- }
- catch (IgniteInterruptedCheckedException e) {
- throw e;
- }
- catch (ClusterTopologyCheckedException e) {
- if (log.isDebugEnabled())
- log.debug("Node left during rebalancing (will retry) [node=" + node.id() +
- ", msg=" + e.getMessage() + ']');
-
- resync = true;
-
- break; // For.
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to receive partitions from node (rebalancing will not " +
- "fully finish) [node=" + node.id() + ", msg=" + d + ']', e);
- }
- }
-
- // Processed missed entries.
- if (!missed.isEmpty()) {
- if (log.isDebugEnabled())
- log.debug("Reassigning partitions that were missed: " + missed);
-
- assert exchFut.exchangeId() != null;
-
- cctx.shared().exchange().forceDummyExchange(true, exchFut);
- }
- else
- break; // While.
- }
- }
- finally {
- demandLock.readLock().unlock();
-
- syncFut.onWorkerDone(this);
- }
-
- cctx.shared().exchange().scheduleResendPartitions();
- }
- }
- finally {
- // Safety.
- syncFut.onWorkerDone(this);
- }
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(DemandWorker.class, this, "assignQ", assignQ, "msgQ", msgQ, "super", super.toString());
- }
- }
-
- /**
- * Sets last exchange future.
- *
- * @param lastFut Last future to set.
- */
- void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut) {
- lastExchangeFut = lastFut;
- }
-
- /**
- * @param exchFut Exchange future.
- * @return Assignments of partitions to nodes.
- */
- GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut) {
- // No assignments for disabled preloader.
- GridDhtPartitionTopology top = cctx.dht().topology();
-
- if (!cctx.rebalanceEnabled())
- return new GridDhtPreloaderAssignments(exchFut, top.topologyVersion());
-
- int partCnt = cctx.affinity().partitions();
-
- assert exchFut.forcePreload() || exchFut.dummyReassign() ||
- exchFut.exchangeId().topologyVersion().equals(top.topologyVersion()) :
- "Topology version mismatch [exchId=" + exchFut.exchangeId() +
- ", topVer=" + top.topologyVersion() + ']';
-
- GridDhtPreloaderAssignments assigns = new GridDhtPreloaderAssignments(exchFut, top.topologyVersion());
-
- AffinityTopologyVersion topVer = assigns.topologyVersion();
-
- for (int p = 0; p < partCnt; p++) {
- if (cctx.shared().exchange().hasPendingExchange()) {
- if (log.isDebugEnabled())
- log.debug("Skipping assignments creation, exchange worker has pending assignments: " +
- exchFut.exchangeId());
-
- break;
- }
-
- // If partition belongs to local node.
- if (cctx.affinity().localNode(p, topVer)) {
- GridDhtLocalPartition part = top.localPartition(p, topVer, true);
-
- assert part != null;
- assert part.id() == p;
-
- if (part.state() != MOVING) {
- if (log.isDebugEnabled())
- log.debug("Skipping partition assignment (state is not MOVING): " + part);
-
- continue; // For.
- }
-
- Collection<ClusterNode> picked = pickedOwners(p, topVer);
-
- if (picked.isEmpty()) {
- top.own(part);
-
- if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) {
- DiscoveryEvent discoEvt = exchFut.discoveryEvent();
-
- cctx.events().addPreloadEvent(p,
- EVT_CACHE_REBALANCE_PART_DATA_LOST, discoEvt.eventNode(),
- discoEvt.type(), discoEvt.timestamp());
- }
-
- if (log.isDebugEnabled())
- log.debug("Owning partition as there are no other owners: " + part);
- }
- else {
- ClusterNode n = F.first(picked);
-
- GridDhtPartitionDemandMessage msg = assigns.get(n);
-
- if (msg == null) {
- assigns.put(n, msg = new GridDhtPartitionDemandMessage(
- top.updateSequence(),
- exchFut.exchangeId().topologyVersion(),
- cctx.cacheId()));
- }
-
- msg.addPartition(p);
- }
- }
- }
-
- return assigns;
- }
-
- /**
- *
- */
- private class SyncFuture extends GridFutureAdapter<Object> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Remaining workers. */
- private Collection<DemandWorker> remaining;
-
- /**
- * @param workers List of workers.
- */
- private SyncFuture(Collection<DemandWorker> workers) {
- assert workers.size() == poolSize();
-
- remaining = Collections.synchronizedList(new LinkedList<>(workers));
- }
-
- /**
- * @param w Worker who iterated through all partitions.
- */
- void onWorkerDone(DemandWorker w) {
- if (isDone())
- return;
-
- if (remaining.remove(w))
- if (log.isDebugEnabled())
- log.debug("Completed full partition iteration for worker [worker=" + w + ']');
-
- if (remaining.isEmpty()) {
- if (log.isDebugEnabled())
- log.debug("Completed sync future.");
-
- onDone();
- }
- }
- }
-
- /**
- * Supply message wrapper.
- */
- private static class SupplyMessage {
- /** Sender ID. */
- private UUID sndId;
-
- /** Supply message. */
- private GridDhtPartitionSupplyMessage supply;
-
- /**
- * Dummy constructor.
- */
- private SupplyMessage() {
- // No-op.
- }
-
- /**
- * @param sndId Sender ID.
- * @param supply Supply message.
- */
- SupplyMessage(UUID sndId, GridDhtPartitionSupplyMessage supply) {
- this.sndId = sndId;
- this.supply = supply;
- }
-
- /**
- * @return Sender ID.
- */
- UUID senderId() {
- return sndId;
- }
-
- /**
- * @return Message.
- */
- GridDhtPartitionSupplyMessage supply() {
- return supply;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(SupplyMessage.class, this);
- }
- }
-}
\ No newline at end of file
[20/50] [abbrv] ignite git commit: Test
GridCacheAbstractFullApiSelfTest.testIgniteCacheIterator muted
Posted by ag...@apache.org.
Test GridCacheAbstractFullApiSelfTest.testIgniteCacheIterator muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8e295cc2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8e295cc2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8e295cc2
Branch: refs/heads/ignite-1702
Commit: 8e295cc2542b92c513277375ba4708d099d95f23
Parents: 612f987
Author: agura <ag...@gridgain.com>
Authored: Mon Nov 2 19:45:35 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Nov 2 19:45:35 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAbstractFullApiSelfTest.java | 2 ++
...heAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java | 5 -----
.../GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java | 5 -----
.../GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java | 5 -----
4 files changed, 2 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e295cc2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 530ff61..3a530f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -3997,6 +3997,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testIgniteCacheIterator() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+
IgniteCache<String, Integer> cache = jcache(0);
Iterator<Cache.Entry<String, Integer>> it = cache.iterator();
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e295cc2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
index de4a53d..e4784f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
@@ -38,9 +38,4 @@ public class GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest
@Override public void testWithSkipStore(){
fail("https://issues.apache.org/jira/browse/IGNITE-1582");
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e295cc2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
index e9251b6..5e128ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
@@ -27,9 +27,4 @@ public class GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest extends GridCach
@Override protected NearCacheConfiguration nearConfiguration() {
return new NearCacheConfiguration();
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8e295cc2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
index 608729a..472ad16 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
@@ -30,9 +30,4 @@ public class GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest extends
@Override protected CacheMemoryMode memoryMode() {
return OFFHEAP_TIERED;
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
[29/50] [abbrv] ignite git commit: Test
IgniteCacheTxPeekModesTest.testLocalPeek muted
Posted by ag...@apache.org.
Test IgniteCacheTxPeekModesTest.testLocalPeek muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0cfb32f2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0cfb32f2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0cfb32f2
Branch: refs/heads/ignite-1702
Commit: 0cfb32f2b2c83d1cababb8aa70eb94de6b073168
Parents: 953f76b
Author: agura <ag...@gridgain.com>
Authored: Wed Nov 4 00:42:52 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Wed Nov 4 00:42:52 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/IgniteCacheTxPeekModesTest.java | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0cfb32f2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
index 2f114e2..f399ca2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxPeekModesTest.java
@@ -48,4 +48,9 @@ public class IgniteCacheTxPeekModesTest extends IgniteCachePeekModesAbstractTest
@Override protected CacheAtomicWriteOrderMode atomicWriteOrderMode() {
return PRIMARY;
}
+
+ /** {@inheritDoc} */
+ @Override public void testLocalPeek() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1839");
+ }
}
\ No newline at end of file
[09/50] [abbrv] ignite git commit: ignite-1758 Fixed issues with
client reconnect handling
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
index 1ccbe1f..09b3ef8 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
@@ -17,6 +17,9 @@
package org.apache.ignite.spi.discovery.tcp;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
@@ -24,18 +27,30 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteClientDisconnectedException;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.events.Event;
+import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.client.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import static org.apache.ignite.events.EventType.EVT_JOB_MAPPED;
+import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
+import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.events.EventType.EVT_TASK_FAILED;
import static org.apache.ignite.events.EventType.EVT_TASK_FINISHED;
@@ -53,8 +68,14 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
private static final ThreadLocal<Boolean> clientFlagPerThread = new ThreadLocal<>();
/** */
+ private static final ThreadLocal<UUID> nodeId = new ThreadLocal<>();
+
+ /** */
private static volatile boolean clientFlagGlobal;
+ /** */
+ private static GridConcurrentHashSet<UUID> failedNodes = new GridConcurrentHashSet<>();
+
/**
* @return Client node flag.
*/
@@ -79,10 +100,37 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ UUID id = nodeId.get();
+
+ if (id != null) {
+ cfg.setNodeId(id);
+
+ nodeId.set(null);
+ }
+
if (client())
cfg.setClientMode(true);
- cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().
+ setIpFinder(ipFinder).
+ setJoinTimeout(60_000).
+ setNetworkTimeout(10_000));
+
+ int[] evts = {EVT_NODE_FAILED, EVT_NODE_LEFT};
+
+ Map<IgnitePredicate<? extends Event>, int[]> lsnrs = new HashMap<>();
+
+ lsnrs.put(new IgnitePredicate<Event>() {
+ @Override public boolean apply(Event evt) {
+ DiscoveryEvent discoveryEvt = (DiscoveryEvent)evt;
+
+ failedNodes.add(discoveryEvt.eventNode().id());
+
+ return true;
+ }
+ }, evts);
+
+ cfg.setLocalEventListeners(lsnrs);
cfg.setCacheConfiguration();
@@ -90,6 +138,8 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
cfg.setIncludeProperties();
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
return cfg;
}
@@ -98,6 +148,8 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
stopAllGrids();
super.afterTest();
+
+ failedNodes.clear();
}
/** {@inheritDoc} */
@@ -111,114 +163,215 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
public void testMultiThreadedClientsRestart() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-1123");
- clientFlagGlobal = false;
+ final AtomicBoolean done = new AtomicBoolean();
- info("Test timeout: " + (getTestTimeout() / (60 * 1000)) + " min.");
+ try {
+ clientFlagGlobal = false;
- startGridsMultiThreaded(GRID_CNT);
+ info("Test timeout: " + (getTestTimeout() / (60 * 1000)) + " min.");
- clientFlagGlobal = true;
+ startGridsMultiThreaded(GRID_CNT);
- startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT);
+ clientFlagGlobal = true;
- final AtomicBoolean done = new AtomicBoolean();
+ startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT);
- final AtomicInteger clientIdx = new AtomicInteger(GRID_CNT);
+ final AtomicInteger clientIdx = new AtomicInteger(GRID_CNT);
- IgniteInternalFuture<?> fut1 = multithreadedAsync(
- new Callable<Object>() {
- @Override public Object call() throws Exception {
- clientFlagPerThread.set(true);
+ IgniteInternalFuture<?> fut1 = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ clientFlagPerThread.set(true);
- int idx = clientIdx.getAndIncrement();
+ int idx = clientIdx.getAndIncrement();
- while (!done.get()) {
- stopGrid(idx, true);
- startGrid(idx);
- }
+ while (!done.get()) {
+ stopGrid(idx, true);
+ startGrid(idx);
+ }
- return null;
- }
- },
- CLIENT_GRID_CNT
- );
+ return null;
+ }
+ },
+ CLIENT_GRID_CNT,
+ "client-restart");
- Thread.sleep(getTestTimeout() - 60 * 1000);
+ Thread.sleep(getTestTimeout() - 60 * 1000);
- done.set(true);
+ done.set(true);
- fut1.get();
+ fut1.get();
+ }
+ finally {
+ done.set(true);
+ }
}
/**
* @throws Exception If any error occurs.
*/
- public void testMultiThreadedClientsServersRestart() throws Exception {
+ public void testMultiThreadedClientsServersRestart() throws Throwable {
fail("https://issues.apache.org/jira/browse/IGNITE-1123");
- clientFlagGlobal = false;
+ final AtomicBoolean done = new AtomicBoolean();
+
+ try {
+ clientFlagGlobal = false;
- info("Test timeout: " + (getTestTimeout() / (60 * 1000)) + " min.");
+ info("Test timeout: " + (getTestTimeout() / (60 * 1000)) + " min.");
- startGridsMultiThreaded(GRID_CNT);
+ startGridsMultiThreaded(GRID_CNT);
- clientFlagGlobal = true;
+ clientFlagGlobal = true;
- startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT);
+ startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT);
- final AtomicBoolean done = new AtomicBoolean();
+ final AtomicReference<Throwable> error = new AtomicReference<>();
- final AtomicInteger clientIdx = new AtomicInteger(GRID_CNT);
+ final BlockingQueue<Integer> clientStopIdxs = new LinkedBlockingQueue<>();
- IgniteInternalFuture<?> fut1 = multithreadedAsync(
- new Callable<Object>() {
- @Override public Object call() throws Exception {
- clientFlagPerThread.set(true);
+ for (int i = GRID_CNT; i < GRID_CNT + CLIENT_GRID_CNT; i++)
+ clientStopIdxs.add(i);
- int idx = clientIdx.getAndIncrement();
+ final AtomicInteger clientStartIdx = new AtomicInteger(9000);
- while (!done.get()) {
- stopGrid(idx);
- startGrid(idx);
+ IgniteInternalFuture<?> fut1 = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try {
+ clientFlagPerThread.set(true);
+
+ while (!done.get() && error.get() == null) {
+ Integer stopIdx = clientStopIdxs.take();
+
+ log.info("Stop client: " + stopIdx);
+
+ stopGrid(stopIdx);
+
+ while (!done.get() && error.get() == null) {
+ // Generate unique name to simplify debugging.
+ int startIdx = clientStartIdx.getAndIncrement();
+
+ log.info("Start client: " + startIdx);
+
+ UUID id = UUID.randomUUID();
+
+ nodeId.set(id);
+
+ try {
+ Ignite ignite = startGrid(startIdx);
+
+ assertTrue(ignite.configuration().isClientMode());
+
+ clientStopIdxs.add(startIdx);
+
+ break;
+ }
+ catch (Exception e) {
+ if (X.hasCause(e, IgniteClientDisconnectedCheckedException.class) ||
+ X.hasCause(e, IgniteClientDisconnectedException.class))
+ log.info("Client disconnected: " + e);
+ else {
+ if (failedNodes.contains(id) && X.hasCause(e, IgniteSpiException.class))
+ log.info("Client failed: " + e);
+ else
+ throw e;
+ }
+ }
+ }
+ }
+ }
+ catch (Throwable e) {
+ log.error("Unexpected error: " + e, e);
+
+ error.compareAndSet(null, e);
+
+ return null;
+ }
+
+ return null;
}
+ },
+ CLIENT_GRID_CNT,
+ "client-restart");
- return null;
- }
- },
- CLIENT_GRID_CNT
- );
+ final BlockingQueue<Integer> srvStopIdxs = new LinkedBlockingQueue<>();
- final BlockingQueue<Integer> srvIdx = new LinkedBlockingQueue<>();
+ for (int i = 0; i < GRID_CNT; i++)
+ srvStopIdxs.add(i);
- for (int i = 0; i < GRID_CNT; i++)
- srvIdx.add(i);
+ final AtomicInteger srvStartIdx = new AtomicInteger(GRID_CNT + CLIENT_GRID_CNT);
- IgniteInternalFuture<?> fut2 = multithreadedAsync(
- new Callable<Object>() {
- @Override public Object call() throws Exception {
- clientFlagPerThread.set(false);
+ IgniteInternalFuture<?> fut2 = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ try {
+ clientFlagPerThread.set(false);
+
+ while (!done.get() && error.get() == null) {
+ int stopIdx = srvStopIdxs.take();
- while (!done.get()) {
- int idx = srvIdx.take();
+ log.info("Stop server: " + stopIdx);
- stopGrid(idx);
- startGrid(idx);
+ stopGrid(stopIdx);
- srvIdx.add(idx);
+ // Generate unique name to simplify debugging.
+ int startIdx = srvStartIdx.getAndIncrement();
+
+ log.info("Start server: " + startIdx);
+
+ Ignite ignite = startGrid(startIdx);
+
+ assertFalse(ignite.configuration().isClientMode());
+
+ srvStopIdxs.add(startIdx);
+ }
+ }
+ catch (Throwable e) {
+ log.error("Unexpected error: " + e, e);
+
+ error.compareAndSet(null, e);
+
+ return null;
+ }
+
+ return null;
}
+ },
+ GRID_CNT - 1,
+ "server-restart");
- return null;
+ final long timeToExec = getTestTimeout() - 60_000;
+
+ final long endTime = System.currentTimeMillis() + timeToExec;
+
+ while (System.currentTimeMillis() < endTime) {
+ Thread.sleep(3000);
+
+ if (error.get() != null) {
+ Throwable err = error.get();
+
+ U.error(log, "Test failed: " + err.getMessage());
+
+ done.set(true);
+
+ fut1.cancel();
+ fut2.cancel();
+
+ throw err;
}
- },
- GRID_CNT - 1
- );
+ }
- Thread.sleep(getTestTimeout() - 60 * 1000);
+ log.info("Stop test.");
- done.set(true);
+ done.set(true);
- fut1.get();
- fut2.get();
+ fut1.get();
+ fut2.get();
+ }
+ finally {
+ done.set(true);
+ }
}
/**
[44/50] [abbrv] ignite git commit: Ignite-1093 "Rebalancing with
default parameters is very slow" fixes.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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 998c720..c634ff5 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
@@ -17,15 +17,18 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.preloader;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -47,27 +50,42 @@ 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.GridAtomicLong;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
+import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridPlainRunnable;
import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.GPC;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiInClosure;
import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.lang.IgniteUuid;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import org.jsr166.ConcurrentLinkedDeque8;
+import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_DATA_LOST;
import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_UNLOADED;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.AFFINITY_POOL;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
import static org.apache.ignite.internal.util.GridConcurrentFactory.newMap;
/**
* DHT cache preloader.
*/
public class GridDhtPreloader extends GridCachePreloaderAdapter {
+ /**
+ * Rebalancing was refactored at version 1.5.0, but backward compatibility to previous implementation was saved.
+ * Node automatically chose communication protocol depends on remote node's version.
+ * Backward compatibility may be removed at Ignite 2.x.
+ */
+ public static final IgniteProductVersion REBALANCING_VER_2_SINCE = IgniteProductVersion.fromString("1.5.0");
+
/** Default preload resend timeout. */
public static final long DFLT_PRELOAD_RESEND_TIMEOUT = 1500;
@@ -81,10 +99,10 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
private final ConcurrentMap<IgniteUuid, GridDhtForceKeysFuture<?, ?>> forceKeyFuts = newMap();
/** Partition suppliers. */
- private GridDhtPartitionSupplyPool supplyPool;
+ private GridDhtPartitionSupplier supplier;
/** Partition demanders. */
- private GridDhtPartitionDemandPool demandPool;
+ private GridDhtPartitionDemander demander;
/** Start future. */
private GridFutureAdapter<Object> startFut;
@@ -92,10 +110,19 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
/** Busy lock to prevent activities from accessing exchanger while it's stopping. */
private final ReadWriteLock busyLock = new ReentrantReadWriteLock();
+ /** Demand lock. */
+ private final ReadWriteLock demandLock = new ReentrantReadWriteLock();
+
/** Pending affinity assignment futures. */
private ConcurrentMap<AffinityTopologyVersion, GridDhtAssignmentFetchFuture> pendingAssignmentFetchFuts =
new ConcurrentHashMap8<>();
+ /** */
+ private final ConcurrentLinkedDeque8<GridDhtLocalPartition> partsToEvict = new ConcurrentLinkedDeque8<>();
+
+ /** */
+ private final AtomicInteger partsEvictOwning = new AtomicInteger();
+
/** Discovery listener. */
private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -179,8 +206,11 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
}
});
- supplyPool = new GridDhtPartitionSupplyPool(cctx, busyLock);
- demandPool = new GridDhtPartitionDemandPool(cctx, busyLock);
+ supplier = new GridDhtPartitionSupplier(cctx);
+ demander = new GridDhtPartitionDemander(cctx, busyLock);
+
+ supplier.start();
+ demander.start();
cctx.events().addListener(discoLsnr, EVT_NODE_JOINED, EVT_NODE_LEFT, EVT_NODE_FAILED);
}
@@ -197,19 +227,16 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
final long startTopVer = loc.order();
topVer.setIfGreater(startTopVer);
-
- supplyPool.start();
- demandPool.start();
}
/** {@inheritDoc} */
@Override public void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred) {
super.preloadPredicate(preloadPred);
- assert supplyPool != null && demandPool != null : "preloadPredicate may be called only after start()";
+ assert supplier != null && demander != null : "preloadPredicate may be called only after start()";
- supplyPool.preloadPredicate(preloadPred);
- demandPool.preloadPredicate(preloadPred);
+ supplier.preloadPredicate(preloadPred);
+ demander.preloadPredicate(preloadPred);
}
/** {@inheritDoc} */
@@ -223,37 +250,109 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
// Acquire write busy lock.
busyLock.writeLock().lock();
- if (supplyPool != null)
- supplyPool.stop();
+ if (supplier != null)
+ supplier.stop();
- if (demandPool != null)
- demandPool.stop();
+ if (demander != null)
+ demander.stop();
top = null;
}
/** {@inheritDoc} */
@Override public void onInitialExchangeComplete(@Nullable Throwable err) {
- if (err == null) {
+ if (err == null)
startFut.onDone();
+ else
+ startFut.onDone(err);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut) {
+ demander.updateLastExchangeFuture(lastFut);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onTopologyChanged(AffinityTopologyVersion topVer) {
+ supplier.onTopologyChanged(topVer);
+ }
+
+ /** {@inheritDoc} */
+ @Override public GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut) {
+ // No assignments for disabled preloader.
+ GridDhtPartitionTopology top = cctx.dht().topology();
+
+ if (!cctx.rebalanceEnabled())
+ return new GridDhtPreloaderAssignments(exchFut, top.topologyVersion());
+
+ int partCnt = cctx.affinity().partitions();
- final long start = U.currentTimeMillis();
+ assert exchFut.forcePreload() || exchFut.dummyReassign() ||
+ exchFut.exchangeId().topologyVersion().equals(top.topologyVersion()) :
+ "Topology version mismatch [exchId=" + exchFut.exchangeId() +
+ ", topVer=" + top.topologyVersion() + ']';
- final CacheConfiguration cfg = cctx.config();
+ GridDhtPreloaderAssignments assigns = new GridDhtPreloaderAssignments(exchFut, top.topologyVersion());
- if (cfg.getRebalanceDelay() >= 0 && !cctx.kernalContext().clientNode()) {
- U.log(log, "Starting rebalancing in " + cfg.getRebalanceMode() + " mode: " + cctx.name());
+ AffinityTopologyVersion topVer = assigns.topologyVersion();
- demandPool.syncFuture().listen(new CI1<Object>() {
- @Override public void apply(Object t) {
- U.log(log, "Completed rebalancing in " + cfg.getRebalanceMode() + " mode " +
- "[cache=" + cctx.name() + ", time=" + (U.currentTimeMillis() - start) + " ms]");
+ for (int p = 0; p < partCnt; p++) {
+ if (cctx.shared().exchange().hasPendingExchange()) {
+ if (log.isDebugEnabled())
+ log.debug("Skipping assignments creation, exchange worker has pending assignments: " +
+ exchFut.exchangeId());
+
+ break;
+ }
+
+ // If partition belongs to local node.
+ if (cctx.affinity().localNode(p, topVer)) {
+ GridDhtLocalPartition part = top.localPartition(p, topVer, true);
+
+ assert part != null;
+ assert part.id() == p;
+
+ if (part.state() != MOVING) {
+ if (log.isDebugEnabled())
+ log.debug("Skipping partition assignment (state is not MOVING): " + part);
+
+ continue; // For.
+ }
+
+ Collection<ClusterNode> picked = pickedOwners(p, topVer);
+
+ if (picked.isEmpty()) {
+ top.own(part);
+
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_DATA_LOST)) {
+ DiscoveryEvent discoEvt = exchFut.discoveryEvent();
+
+ cctx.events().addPreloadEvent(p,
+ EVT_CACHE_REBALANCE_PART_DATA_LOST, discoEvt.eventNode(),
+ discoEvt.type(), discoEvt.timestamp());
}
- });
+
+ if (log.isDebugEnabled())
+ log.debug("Owning partition as there are no other owners: " + part);
+ }
+ else {
+ ClusterNode n = F.rand(picked);
+
+ GridDhtPartitionDemandMessage msg = assigns.get(n);
+
+ if (msg == null) {
+ assigns.put(n, msg = new GridDhtPartitionDemandMessage(
+ top.updateSequence(),
+ exchFut.exchangeId().topologyVersion(),
+ cctx.cacheId()));
+ }
+
+ msg.addPartition(p);
+ }
}
}
- else
- startFut.onDone(err);
+
+ return assigns;
}
/** {@inheritDoc} */
@@ -267,24 +366,77 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
topVer.set(topVer0);
}
- /** {@inheritDoc} */
- @Override public void onExchangeFutureAdded() {
- demandPool.onExchangeFutureAdded();
+ /**
+ * @param p Partition.
+ * @param topVer Topology version.
+ * @return Picked owners.
+ */
+ private Collection<ClusterNode> pickedOwners(int p, AffinityTopologyVersion topVer) {
+ Collection<ClusterNode> affNodes = cctx.affinity().nodes(p, topVer);
+
+ int affCnt = affNodes.size();
+
+ Collection<ClusterNode> rmts = remoteOwners(p, topVer);
+
+ int rmtCnt = rmts.size();
+
+ if (rmtCnt <= affCnt)
+ return rmts;
+
+ List<ClusterNode> sorted = new ArrayList<>(rmts);
+
+ // Sort in descending order, so nodes with higher order will be first.
+ Collections.sort(sorted, CU.nodeComparator(false));
+
+ // Pick newest nodes.
+ return sorted.subList(0, affCnt);
+ }
+
+ /**
+ * @param p Partition.
+ * @param topVer Topology version.
+ * @return Nodes owning this partition.
+ */
+ private Collection<ClusterNode> remoteOwners(int p, AffinityTopologyVersion topVer) {
+ return F.view(cctx.dht().topology().owners(p, topVer), F.remoteNodes(cctx.nodeId()));
}
/** {@inheritDoc} */
- @Override public void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut) {
- demandPool.updateLastExchangeFuture(lastFut);
+ public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessageV2 s) {
+ if (!enterBusy())
+ return;
+
+ try {
+ demandLock.readLock().lock();
+ try {
+ demander.handleSupplyMessage(idx, id, s);
+ }
+ finally {
+ demandLock.readLock().unlock();
+ }
+ }
+ finally {
+ leaveBusy();
+ }
}
/** {@inheritDoc} */
- @Override public GridDhtPreloaderAssignments assign(GridDhtPartitionsExchangeFuture exchFut) {
- return demandPool.assign(exchFut);
+ public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d) {
+ if (!enterBusy())
+ return;
+
+ try {
+ supplier.handleDemandMessage(idx, id, d);
+ }
+ finally {
+ leaveBusy();
+ }
}
/** {@inheritDoc} */
- @Override public void addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload) {
- demandPool.addAssignments(assignments, forcePreload);
+ @Override public Callable<Boolean> addAssignments(GridDhtPreloaderAssignments assignments,
+ boolean forcePreload, Collection<String> caches, int cnt) {
+ return demander.addAssignments(assignments, forcePreload, caches, cnt);
}
/**
@@ -296,7 +448,12 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
/** {@inheritDoc} */
@Override public IgniteInternalFuture<?> syncFuture() {
- return cctx.kernalContext().clientNode() ? startFut : demandPool.syncFuture();
+ return cctx.kernalContext().clientNode() ? startFut : demander.syncFuture();
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> rebalanceFuture() {
+ return cctx.kernalContext().clientNode() ? new GridFinishedFuture<>(true) : demander.rebalanceFuture();
}
/**
@@ -580,12 +737,19 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
/** {@inheritDoc} */
@Override public void forcePreload() {
- demandPool.forcePreload();
+ demander.forcePreload();
}
/** {@inheritDoc} */
@Override public void unwindUndeploys() {
- demandPool.unwindUndeploys();
+ demandLock.writeLock().lock();
+
+ try {
+ cctx.deploy().unwind(cctx);
+ }
+ finally {
+ demandLock.writeLock().unlock();
+ }
}
/**
@@ -607,6 +771,44 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
}
/** {@inheritDoc} */
+ @Override public void evictPartitionAsync(GridDhtLocalPartition part) {
+ partsToEvict.add(part);
+
+ if (partsEvictOwning.get() == 0 && partsEvictOwning.compareAndSet(0, 1)) {
+ cctx.closures().callLocalSafe(new GPC<Boolean>() {
+ @Override public Boolean call() {
+ boolean locked = true;
+
+ while (locked || !partsToEvict.isEmptyx()) {
+ if (!locked && !partsEvictOwning.compareAndSet(0, 1))
+ return false;
+
+ try {
+ GridDhtLocalPartition part = partsToEvict.poll();
+
+ if (part != null)
+ part.tryEvict();
+ }
+ finally {
+ if (!partsToEvict.isEmptyx())
+ locked = true;
+ else {
+ boolean res = partsEvictOwning.compareAndSet(1, 0);
+
+ assert res;
+
+ locked = false;
+ }
+ }
+ }
+
+ return true;
+ }
+ }, /*system pool*/ true);
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public void dumpDebugInfo() {
if (!forceKeyFuts.isEmpty()) {
U.warn(log, "Pending force key futures [cache=" + cctx.name() +"]:");
@@ -621,6 +823,8 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
for (GridDhtAssignmentFetchFuture fut : pendingAssignmentFetchFuts.values())
U.warn(log, ">>> " + fut);
}
+
+ supplier.dumpDebugInfo();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
index 7c5e97c..810bd8c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/DataStructuresProcessor.java
@@ -1292,6 +1292,9 @@ public final class DataStructuresProcessor extends GridProcessorAdapter {
catch (IgniteCheckedException e) {
U.error(log, "Failed to remove count down latch: " + latch0.name(), e);
}
+ finally {
+ ctx.cache().context().txContextReset();
+ }
}
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
index 26a41de..9315d7c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskWorker.java
@@ -696,7 +696,9 @@ class GridTaskWorker<T, R> extends GridWorker implements GridTimeoutObject {
if (log.isDebugEnabled())
U.warn(log, "Received response for unknown child job (was job presumed failed?): " + res);
- return;
+ selfOccupied = true;
+
+ continue;
}
// Only process 1st response and ignore following ones. This scenario
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
index 835cdcb..c95a859 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/lang/GridTuple4.java
@@ -239,7 +239,7 @@ public class GridTuple4<V1, V2, V3, V4> implements Iterable<Object>, Externaliza
GridTuple4<?, ?, ?, ?> t = (GridTuple4<?, ?, ?, ?>)o;
- return F.eq(val1, t.val2) && F.eq(val2, t.val2) && F.eq(val3, t.val3) && F.eq(val4, t.val4);
+ return F.eq(val1, t.val1) && F.eq(val2, t.val2) && F.eq(val3, t.val3) && F.eq(val4, t.val4);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 6254605..854ce95 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1956,7 +1956,7 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T
* <p>
* This method is intended for test purposes only.
*/
- void simulateNodeFailure() {
+ protected void simulateNodeFailure() {
impl.simulateNodeFailure();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
index 1b2b84d..f4423f7 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingErrorTest.java
@@ -87,7 +87,7 @@ public class IgniteCacheP2pUnmarshallingErrorTest extends IgniteCacheAbstractTes
}
/** Test key 1. */
- public static class TestKey implements Externalizable {
+ protected static class TestKey implements Externalizable {
/** Field. */
@QuerySqlField(index = true)
private String field;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
index cadd03f..fe0b84e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheTxNodeFailureSelfTest.java
@@ -17,6 +17,11 @@
package org.apache.ignite.internal.processors.cache.distributed.dht;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
+import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.IgniteException;
@@ -46,12 +51,6 @@ import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
import org.apache.ignite.transactions.TransactionRollbackException;
-import javax.cache.CacheException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-
import static org.apache.ignite.transactions.TransactionConcurrency.OPTIMISTIC;
import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
@@ -192,13 +191,13 @@ public class GridCacheTxNodeFailureSelfTest extends GridCommonAbstractTest {
boolean backup,
final boolean commit
) throws Exception {
- startGrids(gridCount());
- awaitPartitionMapExchange();
+ try {
+ startGrids(gridCount());
+ awaitPartitionMapExchange();
- for (int i = 0; i < gridCount(); i++)
- info("Grid " + i + ": " + ignite(i).cluster().localNode().id());
+ for (int i = 0; i < gridCount(); i++)
+ info("Grid " + i + ": " + ignite(i).cluster().localNode().id());
- try {
final Ignite ignite = ignite(0);
final IgniteCache<Object, Object> cache = ignite.cache(null).withNoRetries();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
new file mode 100644
index 0000000..7759c70
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingAsyncSelfTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.rebalancing;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi;
+
+/**
+ *
+ */
+public class GridCacheRebalancingAsyncSelfTest extends GridCacheRebalancingSyncSelfTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+ for (CacheConfiguration cacheCfg : iCfg.getCacheConfiguration()) {
+ cacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
+ }
+
+ return iCfg;
+ }
+
+ /**
+ * @throws Exception Exception.
+ */
+ public void testNodeFailedAtRebalancing() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ generateData(ignite, 0, 0);
+
+ log.info("Preloading started.");
+
+ startGrid(1);
+
+ GridDhtPartitionDemander.RebalanceFuture fut = (GridDhtPartitionDemander.RebalanceFuture)grid(1).context().
+ cache().internalCache(CACHE_NAME_DHT_REPLICATED).preloader().rebalanceFuture();
+
+ fut.get();
+
+ U.sleep(10);
+
+ ((TestTcpDiscoverySpi)grid(1).configuration().getDiscoverySpi()).simulateNodeFailure();
+
+ waitForRebalancing(0, 3);
+
+ checkSupplyContextMapIsEmpty();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
new file mode 100644
index 0000000..8c5cd40
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingSyncSelfTest.java
@@ -0,0 +1,506 @@
+/*
+ * 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.rebalancing;
+
+import java.util.Map;
+import java.util.Random;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemander;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class GridCacheRebalancingSyncSelfTest extends GridCommonAbstractTest {
+ /** */
+ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static int TEST_SIZE = 100_000;
+
+ /** partitioned cache name. */
+ protected static String CACHE_NAME_DHT_PARTITIONED = "cacheP";
+
+ /** partitioned cache 2 name. */
+ protected static String CACHE_NAME_DHT_PARTITIONED_2 = "cacheP2";
+
+ /** replicated cache name. */
+ protected static String CACHE_NAME_DHT_REPLICATED = "cacheR";
+
+ /** replicated cache 2 name. */
+ protected static String CACHE_NAME_DHT_REPLICATED_2 = "cacheR2";
+
+ /** */
+ private volatile boolean concurrentStartFinished;
+
+ /** */
+ private volatile boolean concurrentStartFinished2;
+
+ /** */
+ private volatile boolean concurrentStartFinished3;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpDiscoverySpi)iCfg.getDiscoverySpi()).setForceServerMode(true);
+
+ if (getTestGridName(10).equals(gridName))
+ iCfg.setClientMode(true);
+
+ CacheConfiguration<Integer, Integer> cachePCfg = new CacheConfiguration<>();
+
+ cachePCfg.setName(CACHE_NAME_DHT_PARTITIONED);
+ cachePCfg.setCacheMode(CacheMode.PARTITIONED);
+ cachePCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cachePCfg.setBackups(1);
+ cachePCfg.setRebalanceBatchSize(1);
+ cachePCfg.setRebalanceBatchesPrefetchCount(1);
+ cachePCfg.setRebalanceOrder(2);
+
+ CacheConfiguration<Integer, Integer> cachePCfg2 = new CacheConfiguration<>();
+
+ cachePCfg2.setName(CACHE_NAME_DHT_PARTITIONED_2);
+ cachePCfg2.setCacheMode(CacheMode.PARTITIONED);
+ cachePCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cachePCfg2.setBackups(1);
+ cachePCfg2.setRebalanceOrder(2);
+ //cachePCfg2.setRebalanceDelay(5000);//Known issue, possible deadlock in case of low priority cache rebalancing delayed.
+
+ CacheConfiguration<Integer, Integer> cacheRCfg = new CacheConfiguration<>();
+
+ cacheRCfg.setName(CACHE_NAME_DHT_REPLICATED);
+ cacheRCfg.setCacheMode(CacheMode.REPLICATED);
+ cacheRCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheRCfg.setRebalanceBatchSize(1);
+ cacheRCfg.setRebalanceBatchesPrefetchCount(Integer.MAX_VALUE);
+ ((TcpCommunicationSpi)iCfg.getCommunicationSpi()).setSharedMemoryPort(-1);//Shmem fail fix for Integer.MAX_VALUE.
+
+ CacheConfiguration<Integer, Integer> cacheRCfg2 = new CacheConfiguration<>();
+
+ cacheRCfg2.setName(CACHE_NAME_DHT_REPLICATED_2);
+ cacheRCfg2.setCacheMode(CacheMode.REPLICATED);
+ cacheRCfg2.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cacheRCfg2.setRebalanceOrder(4);
+
+ iCfg.setCacheConfiguration(cachePCfg, cachePCfg2, cacheRCfg, cacheRCfg2);
+
+ iCfg.setRebalanceThreadPoolSize(2);
+
+ return iCfg;
+ }
+
+ /**
+ * @param ignite Ignite.
+ */
+ protected void generateData(Ignite ignite, int from, int iter) {
+ generateData(ignite, CACHE_NAME_DHT_PARTITIONED, from, iter);
+ generateData(ignite, CACHE_NAME_DHT_PARTITIONED_2, from, iter);
+ generateData(ignite, CACHE_NAME_DHT_REPLICATED, from, iter);
+ generateData(ignite, CACHE_NAME_DHT_REPLICATED_2, from, iter);
+ }
+
+ /**
+ * @param ignite Ignite.
+ */
+ protected void generateData(Ignite ignite, String name, int from, int iter) {
+ for (int i = from; i < from + TEST_SIZE; i++) {
+ if (i % (TEST_SIZE / 10) == 0)
+ log.info("Prepared " + i * 100 / (TEST_SIZE) + "% entries (" + TEST_SIZE + ").");
+
+ ignite.cache(name).put(i, i + name.hashCode() + iter);
+ }
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @throws IgniteCheckedException Exception.
+ */
+ protected void checkData(Ignite ignite, int from, int iter) throws IgniteCheckedException {
+ checkData(ignite, CACHE_NAME_DHT_PARTITIONED, from, iter);
+ checkData(ignite, CACHE_NAME_DHT_PARTITIONED_2, from, iter);
+ checkData(ignite, CACHE_NAME_DHT_REPLICATED, from, iter);
+ checkData(ignite, CACHE_NAME_DHT_REPLICATED_2, from, iter);
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param name Cache name.
+ * @throws IgniteCheckedException Exception.
+ */
+ protected void checkData(Ignite ignite, String name, int from, int iter) throws IgniteCheckedException {
+ for (int i = from; i < from + TEST_SIZE; i++) {
+ if (i % (TEST_SIZE / 10) == 0)
+ log.info("<" + name + "> Checked " + i * 100 / (TEST_SIZE) + "% entries (" + TEST_SIZE + ").");
+
+ assert ignite.cache(name).get(i) != null && ignite.cache(name).get(i).equals(i + name.hashCode() + iter) :
+ i + " value " + (i + name.hashCode() + iter) + " does not match (" + ignite.cache(name).get(i) + ")";
+ }
+ }
+
+ /**
+ * @throws Exception Exception
+ */
+ public void testSimpleRebalancing() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ generateData(ignite, 0, 0);
+
+ log.info("Preloading started.");
+
+ long start = System.currentTimeMillis();
+
+ startGrid(1);
+
+ waitForRebalancing(0, 2);
+ waitForRebalancing(1, 2);
+
+ stopGrid(0);
+
+ waitForRebalancing(1, 3);
+
+ startGrid(2);
+
+ waitForRebalancing(1, 4);
+ waitForRebalancing(2, 4);
+
+ stopGrid(2);
+
+ waitForRebalancing(1, 5);
+
+ long spend = (System.currentTimeMillis() - start) / 1000;
+
+ checkData(grid(1), 0, 0);
+
+ log.info("Spend " + spend + " seconds to rebalance entries.");
+ }
+
+ /**
+ * @throws Exception Exception
+ */
+ public void testLoadRebalancing() throws Exception {
+ final Ignite ignite = startGrid(0);
+
+ startGrid(1);
+
+ generateData(ignite, CACHE_NAME_DHT_PARTITIONED, 0, 0);
+
+ log.info("Preloading started.");
+
+ long start = System.currentTimeMillis();
+
+ concurrentStartFinished = false;
+
+ Thread t1 = new Thread() {
+ @Override public void run() {
+ Random rdm = new Random();
+
+ while (!concurrentStartFinished) {
+ for (int i = 0; i < TEST_SIZE; i++) {
+ if (i % (TEST_SIZE / 10) == 0)
+ log.info("Prepared " + i * 100 / (TEST_SIZE) + "% entries (" + TEST_SIZE + ").");
+
+ int ii = rdm.nextInt(TEST_SIZE);
+
+ ignite.cache(CACHE_NAME_DHT_PARTITIONED).put(ii, ii + CACHE_NAME_DHT_PARTITIONED.hashCode());
+ }
+ }
+ }
+ };
+
+ Thread t2 = new Thread() {
+ @Override public void run() {
+ while (!concurrentStartFinished) {
+ try {
+ checkData(ignite, CACHE_NAME_DHT_PARTITIONED, 0, 0);
+ }
+ catch (IgniteCheckedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ };
+
+ t1.start();
+ t2.start();
+
+ startGrid(2);
+ startGrid(3);
+
+ stopGrid(2);
+
+ startGrid(4);
+
+ waitForRebalancing(3, 6);
+ waitForRebalancing(4, 6);
+
+ concurrentStartFinished = true;
+
+ awaitPartitionMapExchange(true);
+
+ checkSupplyContextMapIsEmpty();
+
+ t1.join();
+ t2.join();
+
+ long spend = (System.currentTimeMillis() - start) / 1000;
+
+ info("Time to rebalance entries: " + spend);
+ }
+
+ /**
+ * @param id Node id.
+ * @param major Major ver.
+ * @param minor Minor ver.
+ * @throws IgniteCheckedException Exception.
+ */
+ protected void waitForRebalancing(int id, int major, int minor) throws IgniteCheckedException {
+ waitForRebalancing(id, new AffinityTopologyVersion(major, minor));
+ }
+
+ /**
+ * @param id Node id.
+ * @param major Major ver.
+ * @throws IgniteCheckedException Exception.
+ */
+ protected void waitForRebalancing(int id, int major) throws IgniteCheckedException {
+ waitForRebalancing(id, new AffinityTopologyVersion(major));
+ }
+
+ /**
+ * @param id Node id.
+ * @param top Topology version.
+ * @throws IgniteCheckedException
+ */
+ protected void waitForRebalancing(int id, AffinityTopologyVersion top) throws IgniteCheckedException {
+ boolean finished = false;
+
+ while (!finished) {
+ finished = true;
+
+ for (GridCacheAdapter c : grid(id).context().cache().internalCaches()) {
+ GridDhtPartitionDemander.RebalanceFuture fut = (GridDhtPartitionDemander.RebalanceFuture)c.preloader().rebalanceFuture();
+ if (fut.topologyVersion() == null || !fut.topologyVersion().equals(top)) {
+ finished = false;
+
+ break;
+ }
+ else if (!fut.get()) {
+ finished = false;
+
+ log.warning("Rebalancing finished with missed partitions.");
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ protected void checkSupplyContextMapIsEmpty() {
+ for (Ignite g : G.allGrids()) {
+ for (GridCacheAdapter c : ((IgniteEx)g).context().cache().internalCaches()) {
+
+ Object supplier = U.field(c.preloader(), "supplier");
+
+ Map map = U.field(supplier, "scMap");
+
+ synchronized (map) {
+ assert map.isEmpty();
+ }
+ }
+ }
+ }
+
+ @Override protected long getTestTimeout() {
+ return 5 * 60_000;
+ }
+
+ /**
+ * @throws Exception
+ */
+ public void testComplexRebalancing() throws Exception {
+ final Ignite ignite = startGrid(0);
+
+ generateData(ignite, 0, 0);
+
+ log.info("Preloading started.");
+
+ long start = System.currentTimeMillis();
+
+ concurrentStartFinished = false;
+ concurrentStartFinished2 = false;
+ concurrentStartFinished3 = false;
+
+ Thread t1 = new Thread() {
+ @Override public void run() {
+ try {
+ startGrid(1);
+ startGrid(2);
+
+ while (!concurrentStartFinished2) {
+ U.sleep(10);
+ }
+
+ waitForRebalancing(0, 5, 0);
+ waitForRebalancing(1, 5, 0);
+ waitForRebalancing(2, 5, 0);
+ waitForRebalancing(3, 5, 0);
+ waitForRebalancing(4, 5, 0);
+
+ //New cache should start rebalancing.
+ CacheConfiguration<Integer, Integer> cacheRCfg = new CacheConfiguration<>();
+
+ cacheRCfg.setName(CACHE_NAME_DHT_PARTITIONED + "_NEW");
+ cacheRCfg.setCacheMode(CacheMode.PARTITIONED);
+ cacheRCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+
+ grid(0).getOrCreateCache(cacheRCfg);
+
+ while (!concurrentStartFinished3) {
+ U.sleep(10);
+ }
+
+ concurrentStartFinished = true;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Thread t2 = new Thread() {
+ @Override public void run() {
+ try {
+ startGrid(3);
+ startGrid(4);
+
+ concurrentStartFinished2 = true;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ };
+
+ Thread t3 = new Thread() {
+ @Override public void run() {
+ generateData(ignite, 0, 1);
+
+ concurrentStartFinished3 = true;
+ }
+ };
+
+ t1.start();
+ t2.start();// Should cancel t1 rebalancing.
+ t3.start();
+
+ t1.join();
+ t2.join();
+ t3.join();
+
+ waitForRebalancing(0, 5, 1);
+ waitForRebalancing(1, 5, 1);
+ waitForRebalancing(2, 5, 1);
+ waitForRebalancing(3, 5, 1);
+ waitForRebalancing(4, 5, 1);
+
+ awaitPartitionMapExchange(true);
+
+ checkSupplyContextMapIsEmpty();
+
+ checkData(grid(4), 0, 1);
+
+ final Ignite ignite3 = grid(3);
+
+ Thread t4 = new Thread() {
+ @Override public void run() {
+ generateData(ignite3, 0, 2);
+
+ }
+ };
+
+ t4.start();
+
+ stopGrid(1);
+
+ waitForRebalancing(0, 6);
+ waitForRebalancing(2, 6);
+ waitForRebalancing(3, 6);
+ waitForRebalancing(4, 6);
+
+ awaitPartitionMapExchange(true);
+
+ checkSupplyContextMapIsEmpty();
+
+ stopGrid(0);
+
+ waitForRebalancing(2, 7);
+ waitForRebalancing(3, 7);
+ waitForRebalancing(4, 7);
+
+ awaitPartitionMapExchange(true);
+
+ checkSupplyContextMapIsEmpty();
+
+ stopGrid(2);
+
+ waitForRebalancing(3, 8);
+ waitForRebalancing(4, 8);
+
+ awaitPartitionMapExchange(true);
+
+ checkSupplyContextMapIsEmpty();
+
+ t4.join();
+
+ stopGrid(3);
+
+ waitForRebalancing(4, 9);
+
+ checkSupplyContextMapIsEmpty();
+
+ long spend = (System.currentTimeMillis() - start) / 1000;
+
+ checkData(grid(4), 0, 2);
+
+ log.info("Spend " + spend + " seconds to rebalance entries.");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java
new file mode 100644
index 0000000..831e82d
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/rebalancing/GridCacheRebalancingUnmarshallingFailedSelfTest.java
@@ -0,0 +1,147 @@
+/*
+ * 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.rebalancing;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class GridCacheRebalancingUnmarshallingFailedSelfTest extends GridCommonAbstractTest {
+ /** */
+ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** partitioned cache name. */
+ protected static String CACHE = "cache";
+
+ /** Allows to change behavior of readExternal method. */
+ protected static AtomicInteger readCnt = new AtomicInteger();
+
+ /** Test key 1. */
+ private static class TestKey implements Externalizable {
+ /** Field. */
+ @QuerySqlField(index = true)
+ private String field;
+
+ /**
+ * @param field Test key 1.
+ */
+ public TestKey(String field) {
+ this.field = field;
+ }
+
+ /** Test key 1. */
+ public TestKey() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ TestKey key = (TestKey)o;
+
+ return !(field != null ? !field.equals(key.field) : key.field != null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ return field != null ? field.hashCode() : 0;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(field);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ field = (String)in.readObject();
+
+ if (readCnt.decrementAndGet() <= 0)
+ throw new IOException("Class can not be unmarshalled.");
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration iCfg = super.getConfiguration(gridName);
+
+ CacheConfiguration<TestKey, Integer> cfg = new CacheConfiguration<>();
+
+ cfg.setName(CACHE);
+ cfg.setCacheMode(CacheMode.PARTITIONED);
+ cfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+ cfg.setBackups(0);
+
+ iCfg.setCacheConfiguration(cfg);
+
+ return iCfg;
+ }
+
+ /**
+ * @throws Exception e.
+ */
+ public void test() throws Exception {
+ readCnt.set(Integer.MAX_VALUE);
+
+ startGrid(0);
+
+ for (int i = 0; i < 100; i++) {
+ grid(0).cache(CACHE).put(new TestKey(String.valueOf(i)), i);
+ }
+
+ readCnt.set(1);
+
+ startGrid(1);
+
+ readCnt.set(Integer.MAX_VALUE);
+
+ for (int i = 0; i < 50; i++) {
+ assert grid(1).cache(CACHE).get(new TestKey(String.valueOf(i))) != null;
+ }
+
+ stopGrid(0);
+
+ for (int i = 50; i < 100; i++) {
+ assert grid(1).cache(CACHE).get(new TestKey(String.valueOf(i))) == null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
index c4ad169..64f1495 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadSelfTest.java
@@ -142,26 +142,6 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
}
/**
- * @throws Exception If failed.
- */
- public void testSingleZeroPoolSize() throws Exception {
- preloadMode = SYNC;
- poolSize = 0;
-
- try {
- startGrid(1);
-
- assert false : "Grid should have been failed to start.";
- }
- catch (IgniteCheckedException e) {
- info("Caught expected exception: " + e);
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
* @throws Exception If test failed.
*/
public void testIntegrity() throws Exception {
@@ -602,4 +582,4 @@ public class GridCacheReplicatedPreloadSelfTest extends GridCommonAbstractTest {
// No-op.
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 0280e9c..51d8a2d 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -511,23 +511,6 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
}
/**
- *
- */
- private static class TestTcpDiscoverySpi extends TcpDiscoverySpi {
- /** */
- private boolean ignorePingResponse;
-
- /** {@inheritDoc} */
- protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException,
- IgniteCheckedException {
- if (msg instanceof TcpDiscoveryPingResponse && ignorePingResponse)
- return;
- else
- super.writeToSocket(sock, msg, timeout);
- }
- }
-
- /**
* @throws Exception If any error occurs.
*/
public void testNodeAdded() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
new file mode 100644
index 0000000..dbc54bc
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TestTcpDiscoverySpi.java
@@ -0,0 +1,46 @@
+/*
+ * 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.spi.discovery.tcp;
+
+import java.io.IOException;
+import java.net.Socket;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryAbstractMessage;
+import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryPingResponse;
+
+/**
+ *
+ */
+public class TestTcpDiscoverySpi extends TcpDiscoverySpi {
+ /** */
+ public boolean ignorePingResponse;
+
+ /** {@inheritDoc} */
+ protected void writeToSocket(Socket sock, TcpDiscoveryAbstractMessage msg, long timeout) throws IOException,
+ IgniteCheckedException {
+ if (msg instanceof TcpDiscoveryPingResponse && ignorePingResponse)
+ return;
+ else
+ super.writeToSocket(sock, msg, timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void simulateNodeFailure() {
+ super.simulateNodeFailure();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index d133a84..41d4b4a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -77,6 +77,7 @@ import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.spi.checkpoint.sharedfs.SharedFsCheckpointSpi;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -1228,7 +1229,7 @@ public abstract class GridAbstractTest extends TestCase {
cfg.setCommunicationSpi(commSpi);
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+ TcpDiscoverySpi discoSpi = new TestTcpDiscoverySpi();
if (isDebug()) {
discoSpi.setMaxMissedHeartbeats(Integer.MAX_VALUE);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index 28d5c73..71f3ee3 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -63,6 +63,8 @@ import org.apache.ignite.internal.processors.cache.GridCacheFuture;
import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
import org.apache.ignite.internal.processors.cache.IgniteCacheProxy;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.GridDhtColocatedCache;
@@ -414,6 +416,15 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
*/
@SuppressWarnings("BusyWait")
protected void awaitPartitionMapExchange() throws InterruptedException {
+ awaitPartitionMapExchange(false);
+ }
+
+ /**
+ * @param waitEvicts If {@code true} will wait for evictions finished.
+ * @throws InterruptedException If interrupted.
+ */
+ @SuppressWarnings("BusyWait")
+ protected void awaitPartitionMapExchange(boolean waitEvicts) throws InterruptedException {
for (Ignite g : G.allGrids()) {
IgniteKernal g0 = (IgniteKernal)g;
@@ -451,7 +462,10 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
int actual = owners.size();
- if (affNodes.size() != owners.size() || !affNodes.containsAll(owners)) {
+ GridDhtLocalPartition loc = top.localPartition(p, readyVer, false);
+
+ if (affNodes.size() != owners.size() || !affNodes.containsAll(owners) ||
+ (waitEvicts && loc != null && loc.state() == GridDhtPartitionState.RENTING)) {
LT.warn(log(), null, "Waiting for topology map update [" +
"grid=" + g.name() +
", cache=" + cfg.getName() +
@@ -484,7 +498,9 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
if (i == 0)
start = System.currentTimeMillis();
- if (System.currentTimeMillis() - start > 30_000)
+ if (System.currentTimeMillis() - start > 30_000) {
+ U.dumpThreads(log);
+
throw new IgniteException("Timeout of waiting for topology map update [" +
"grid=" + g.name() +
", cache=" + cfg.getName() +
@@ -493,6 +509,7 @@ public abstract class GridCommonAbstractTest extends GridAbstractTest {
", p=" + p +
", readVer=" + readyVer +
", locNode=" + g.cluster().localNode() + ']');
+ }
Thread.sleep(200); // Busy wait.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
index 796c531..c3c3659 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite3.java
@@ -49,6 +49,8 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNea
import org.apache.ignite.internal.processors.cache.distributed.near.GridCacheNearPartitionedP2PEnabledByteArrayValuesSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridCachePutArrayValueSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.near.IgniteTxReentryNearSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingAsyncSelfTest;
+import org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingSyncSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheDaemonNodeReplicatedSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedAtomicGetAndTransformStoreSelfTest;
import org.apache.ignite.internal.processors.cache.distributed.replicated.GridCacheReplicatedBasicApiTest;
@@ -135,6 +137,8 @@ public class IgniteCacheTestSuite3 extends TestSuite {
suite.addTestSuite(IgniteTxReentryColocatedSelfTest.class);
suite.addTestSuite(GridCacheOrderedPreloadingSelfTest.class);
+ suite.addTestSuite(GridCacheRebalancingSyncSelfTest.class);
+ suite.addTestSuite(GridCacheRebalancingAsyncSelfTest.class);
// Test for byte array value special case.
suite.addTestSuite(GridCacheLocalByteArrayValuesSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
index 0226046..582bfe3 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/spi/communication/tcp/GridOrderedMessageCancelSelfTest.java
@@ -107,25 +107,33 @@ public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTask() throws Exception {
+ Map map = U.field(((IgniteKernal)grid(0)).context().io(), "msgSetMap");
+
+ int initSize = map.size();
+
ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).cluster().forRemotes()), Task.class, null);
- testMessageSet(fut);
+ testMessageSet(fut, initSize, map);
}
/**
* @throws Exception If failed.
*/
public void testTaskException() throws Exception {
+ Map map = U.field(((IgniteKernal)grid(0)).context().io(), "msgSetMap");
+
+ int initSize = map.size();
+
ComputeTaskFuture<?> fut = executeAsync(compute(grid(0).cluster().forRemotes()), FailTask.class, null);
- testMessageSet(fut);
+ testMessageSet(fut, initSize, map);
}
/**
* @param fut Future to cancel.
* @throws Exception If failed.
*/
- private void testMessageSet(IgniteFuture<?> fut) throws Exception {
+ private void testMessageSet(IgniteFuture<?> fut, int initSize, Map map) throws Exception {
cancelLatch.await();
assertTrue(fut.cancel());
@@ -134,11 +142,9 @@ public class GridOrderedMessageCancelSelfTest extends GridCommonAbstractTest {
assertTrue(U.await(finishLatch, 5000, MILLISECONDS));
- Map map = U.field(((IgniteKernal)grid(0)).context().io(), "msgSetMap");
-
info("Map: " + map);
- assertTrue(map.isEmpty());
+ assertEquals(map.size(), initSize);
}
/**
[22/50] [abbrv] ignite git commit: Disabled hanging test
(IGNITE-1685).
Posted by ag...@apache.org.
Disabled hanging test (IGNITE-1685).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1486b5d9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1486b5d9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1486b5d9
Branch: refs/heads/ignite-1702
Commit: 1486b5d9b12d752df7358cb51e16e8676b42f501
Parents: 42a6390
Author: sboikov <sb...@gridgain.com>
Authored: Tue Nov 3 10:03:55 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Nov 3 10:03:55 2015 +0300
----------------------------------------------------------------------
.../distributed/IgniteCacheClientNodeChangingTopologyTest.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1486b5d9/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index cb83798..8f90dbd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1555,6 +1555,8 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testAtomicPrimaryPutAllMultinode() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1685");
+
multinode(PRIMARY, TestType.PUT_ALL);
}
[39/50] [abbrv] ignite git commit: added os and vm info to quiet log
Posted by ag...@apache.org.
added os and vm info to quiet log
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/dca9e572
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/dca9e572
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/dca9e572
Branch: refs/heads/ignite-1702
Commit: dca9e5726130ab3d636d87d556e060b719ebb49e
Parents: 0cfb32f
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Wed Nov 4 16:05:12 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Wed Nov 4 16:05:12 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/internal/IgniteKernal.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/dca9e572/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5a0fe16..9d8fcfb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1691,6 +1691,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
private void ackOsInfo() {
assert log != null;
+ if (log.isQuiet())
+ U.quiet(false, "OS: " + U.osString());
+
if (log.isInfoEnabled()) {
log.info("OS: " + U.osString());
log.info("OS user: " + System.getProperty("user.name"));
@@ -1703,6 +1706,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
private void ackLanguageRuntime() {
assert log != null;
+ if (log.isQuiet())
+ U.quiet(false, "VM information: " + U.jdkString());
+
if (log.isInfoEnabled()) {
log.info("Language runtime: " + getLanguage());
log.info("VM information: " + U.jdkString());
[08/50] [abbrv] ignite git commit: Disabled shmem in test.
Posted by ag...@apache.org.
Disabled shmem in test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/04964b9b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/04964b9b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/04964b9b
Branch: refs/heads/ignite-1702
Commit: 04964b9bc04b3b87547b45a29b8510a463a8fd35
Parents: ec16c77
Author: sboikov <sb...@gridgain.com>
Authored: Fri Oct 30 13:10:10 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Oct 30 13:10:10 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/IgniteCachePutAllRestartTest.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/04964b9b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
index ae99926..3e124f3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePutAllRestartTest.java
@@ -30,6 +30,7 @@ import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -58,6 +59,8 @@ public class IgniteCachePutAllRestartTest extends GridCommonAbstractTest {
cfg.setPeerClassLoadingEnabled(false);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
CacheConfiguration cacheCfg = defaultCacheConfiguration();
[50/50] [abbrv] ignite git commit: Merge branch ignite-1.5 into
ignite-1702
Posted by ag...@apache.org.
Merge branch ignite-1.5 into ignite-1702
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2da1cc3c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2da1cc3c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2da1cc3c
Branch: refs/heads/ignite-1702
Commit: 2da1cc3cd15c0046134dbd31c103d5c32f2e2372
Parents: 2d92ad2
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sun Nov 8 20:12:27 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sun Nov 8 20:12:27 2015 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtTxPrepareFuture.java | 36 +++++++++++++++-----
1 file changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2da1cc3c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 977b269..cb9ff8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -585,13 +585,8 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (tx.markFinalizing(IgniteInternalTx.FinalizationStatus.USER_FINISH)) {
IgniteInternalFuture<IgniteInternalTx> fut = null;
- if (prepErr == null)
- fut = tx.commitAsync();
- else if (!cctx.kernalContext().isStopping())
- fut = tx.rollbackAsync();
-
- if (fut != null) {
- fut.listen(new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
+ CIX1<IgniteInternalFuture<IgniteInternalTx>> responseClo =
+ new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
try {
if (replied.compareAndSet(false, true))
@@ -601,8 +596,33 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
U.error(log, "Failed to send prepare response for transaction: " + tx, e);
}
}
- });
+ };
+
+ if (prepErr == null) {
+ try {
+ fut = tx.commitAsync();
+ }
+ catch (RuntimeException | Error e) {
+ Exception hEx = new IgniteTxHeuristicCheckedException("Commit produced a runtime " +
+ "exception: " + CU.txString(tx), e);
+
+ res.error(hEx);
+
+ tx.systemInvalidate(true);
+
+ fut = tx.rollbackAsync();
+
+ fut.listen(responseClo);
+
+ throw e;
+ }
+
}
+ else if (!cctx.kernalContext().isStopping())
+ fut = tx.rollbackAsync();
+
+ if (fut != null)
+ fut.listen(responseClo);
}
}
else {
[16/50] [abbrv] ignite git commit: IGNITE-1833 Fixed Visor backup
partitions count logic.
Posted by ag...@apache.org.
IGNITE-1833 Fixed Visor backup partitions count logic.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/28e0217f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/28e0217f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/28e0217f
Branch: refs/heads/ignite-1702
Commit: 28e0217f893ed2151092a5e3a9b0b96ee7dec77f
Parents: 747c684
Author: AKuznetsov <ak...@gridgain.com>
Authored: Mon Nov 2 19:34:49 2015 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Mon Nov 2 19:34:49 2015 +0700
----------------------------------------------------------------------
.../cache/GridCacheAffinityManager.java | 18 ++++++++++++++++--
.../distributed/dht/GridDhtLocalPartition.java | 8 ++++++++
.../ignite/internal/visor/cache/VisorCache.java | 5 +++--
3 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 4f99ef5..5c43205 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -262,7 +262,7 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
* @param n Node to check.
* @param part Partition.
* @param topVer Topology version.
- * @return {@code True} if checked node is primary for given key.
+ * @return {@code True} if checked node is primary for given partition.
*/
public boolean primary(ClusterNode n, int part, AffinityTopologyVersion topVer) {
return F.eq(primary(part, topVer), n);
@@ -294,6 +294,20 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
}
/**
+ * @param n Node to check.
+ * @param part Partition.
+ * @param topVer Topology version.
+ * @return {@code True} if checked node is a backup node for given partition.
+ */
+ public boolean backup(ClusterNode n, int part, AffinityTopologyVersion topVer) {
+ List<ClusterNode> nodes = nodes(part, topVer);
+
+ assert !F.isEmpty(nodes);
+
+ return nodes.indexOf(n) > 0;
+ }
+
+ /**
* @param keys keys.
* @param topVer Topology version.
* @return Nodes for the keys.
@@ -370,4 +384,4 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
public AffinityTopologyVersion affinityTopologyVersion() {
return aff.lastVersion();
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 4f124e6..749d06a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -604,6 +604,14 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
}
/**
+ * @param topVer Topology version.
+ * @return {@code True} if local node is backup for this partition.
+ */
+ public boolean backup(AffinityTopologyVersion topVer) {
+ return cctx.affinity().backup(cctx.localNode(), id, topVer);
+ }
+
+ /**
* Clears values for this partition.
*/
private void clearAll() {
http://git-wip-us.apache.org/repos/asf/ignite/blob/28e0217f/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 937121d..111cab8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheAdapter;
@@ -171,7 +172,7 @@ public class VisorCache implements Serializable {
// Pass -1 as topology version in order not to wait for topology version.
if (part.primary(AffinityTopologyVersion.NONE))
primaryPartitions.add(new IgnitePair<>(p, sz));
- else
+ else if (part.state() == GridDhtPartitionState.OWNING && part.backup(AffinityTopologyVersion.NONE))
backupPartitions.add(new IgnitePair<>(p, sz));
}
}
@@ -406,4 +407,4 @@ public class VisorCache implements Serializable {
@Override public String toString() {
return S.toString(VisorCache.class, this);
}
-}
\ No newline at end of file
+}
[43/50] [abbrv] ignite git commit: Tests muted
Posted by ag...@apache.org.
Tests muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7573003f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7573003f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7573003f
Branch: refs/heads/ignite-1702
Commit: 7573003f5471676ed4047c406fa741fad9279e24
Parents: 4010469
Author: agura <ag...@gridgain.com>
Authored: Thu Nov 5 03:52:47 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu Nov 5 03:52:47 2015 +0300
----------------------------------------------------------------------
.../near/GridCacheNearTxExceptionSelfTest.java | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7573003f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
index 270af25..752b897 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
@@ -36,7 +36,18 @@ public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractS
fail("https://issues.apache.org/jira/browse/IGNITE-1601");
}
+ /** {@inheritDoc} */
@Override public void testRemoveBackup() throws Exception {
fail("https://issues.apache.org/jira/browse/IGNITE-1839");
}
+
+ /** {@inheritDoc} */
+ @Override public void testPutBackup() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1839");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void testTransformNear() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1839");
+ }
}
\ No newline at end of file
[33/50] [abbrv] ignite git commit: ignite-1808: Wrong Jetty's thread
pool size settings
Posted by ag...@apache.org.
ignite-1808: Wrong Jetty's thread pool size settings
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/39405aef
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/39405aef
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/39405aef
Branch: refs/heads/ignite-1702
Commit: 39405aef01c2afb88aad4ef44f9dba8a2e8468b5
Parents: 73c2db5
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:48:54 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:50:11 2015 +0300
----------------------------------------------------------------------
.../rest/protocols/http/jetty/GridJettyRestProtocol.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/39405aef/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
----------------------------------------------------------------------
diff --git a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
index 6e201c9..ac49ef6 100644
--- a/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
+++ b/modules/rest-http/src/main/java/org/apache/ignite/internal/processors/rest/protocols/http/jetty/GridJettyRestProtocol.java
@@ -287,7 +287,7 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
"cannot be cast to integer: " + srvPortStr);
}
- httpSrv = new Server(new QueuedThreadPool(20, 200));
+ httpSrv = new Server(new QueuedThreadPool(200, 20));
ServerConnector srvConn = new ServerConnector(httpSrv, new HttpConnectionFactory(httpCfg));
@@ -421,4 +421,4 @@ public class GridJettyRestProtocol extends GridRestProtocolAdapter {
@Override public String toString() {
return S.toString(GridJettyRestProtocol.class, this);
}
-}
\ No newline at end of file
+}
[14/50] [abbrv] ignite git commit: ignite-1820 Deployment service
hangs when node is being stopped
Posted by ag...@apache.org.
ignite-1820 Deployment service hangs when node is being stopped
Signed-off-by: agura <ag...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/195cd57f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/195cd57f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/195cd57f
Branch: refs/heads/ignite-1702
Commit: 195cd57fb6362220d2ea664046bcdd92d024d871
Parents: fff4e45
Author: agura <ag...@gridgain.com>
Authored: Mon Nov 2 13:26:27 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Nov 2 13:26:27 2015 +0300
----------------------------------------------------------------------
.../service/GridServiceProcessor.java | 31 +++---
.../GridServiceProcessorStopSelfTest.java | 103 +++++++++++++++++++
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
3 files changed, 124 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/195cd57f/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 7e8669a..ed54f00 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -242,28 +242,35 @@ public class GridServiceProcessor extends GridProcessorAdapter {
U.shutdownNow(GridServiceProcessor.class, depExe, log);
+ Exception err = new IgniteCheckedException("Operation has been cancelled (node is stopping).");
+
+ cancelFutures(depFuts, err);
+ cancelFutures(undepFuts, err);
+
if (log.isDebugEnabled())
log.debug("Stopped service processor.");
}
/** {@inheritDoc} */
@Override public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException {
- for (Map.Entry<String, GridServiceDeploymentFuture> e : depFuts.entrySet()) {
- GridServiceDeploymentFuture fut = e.getValue();
-
- fut.onDone(new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(),
- "Failed to deploy service, client node disconnected."));
+ cancelFutures(depFuts, new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(),
+ "Failed to deploy service, client node disconnected."));
- depFuts.remove(e.getKey(), fut);
- }
+ cancelFutures(undepFuts, new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(),
+ "Failed to undeploy service, client node disconnected."));
+ }
- for (Map.Entry<String, GridFutureAdapter<?>> e : undepFuts.entrySet()) {
- GridFutureAdapter fut = e.getValue();
+ /**
+ * @param futs Futs.
+ * @param err Exception.
+ */
+ private void cancelFutures(ConcurrentMap<String, ? extends GridFutureAdapter<?>> futs, Exception err) {
+ for (Map.Entry<String, ? extends GridFutureAdapter<?>> entry : futs.entrySet()) {
+ GridFutureAdapter fut = entry.getValue();
- fut.onDone(new IgniteClientDisconnectedCheckedException(ctx.cluster().clientReconnectFuture(),
- "Failed to undeploy service, client node disconnected."));
+ fut.onDone(err);
- undepFuts.remove(e.getKey(), fut);
+ futs.remove(entry.getKey(), fut);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/195cd57f/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
new file mode 100644
index 0000000..16ea5e4
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/GridServiceProcessorStopSelfTest.java
@@ -0,0 +1,103 @@
+/*
+ * 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.service;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteServices;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceContext;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests that {@link GridServiceProcessor} completes deploy/undeploy futures during node stop.
+ */
+public class GridServiceProcessorStopSelfTest extends GridCommonAbstractTest {
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStopDuringDeployment() throws Exception {
+ final CountDownLatch depLatch = new CountDownLatch(1);
+
+ final CountDownLatch finishLatch = new CountDownLatch(1);
+
+ final Ignite ignite = startGrid(0);
+
+ Thread t = new Thread(new Runnable() {
+ @Override public void run() {
+ IgniteServices svcs = ignite.services();
+
+ IgniteServices services = svcs.withAsync();
+
+ services.deployClusterSingleton("myClusterSingletonService", new TestServiceImpl());
+
+ depLatch.countDown();
+
+ try {
+ services.future().get();
+ }
+ catch (IgniteException e) {
+ finishLatch.countDown();
+ }
+ catch (Throwable e) {
+ log.error("Service deployment error: ", e);
+ }
+ }
+ });
+
+ t.start();
+
+ depLatch.await();
+
+ Ignition.stopAll(true);
+
+ assertTrue("Deploy future isn't completed", finishLatch.await(15, TimeUnit.SECONDS));
+ }
+
+ /**
+ * Simple map service.
+ */
+ public interface TestService {
+ }
+
+ /**
+ *
+ */
+ public class TestServiceImpl implements Service, TestService {
+ /** Serial version UID. */
+ private static final long serialVersionUID = 0L;
+
+ /** {@inheritDoc} */
+ @Override public void cancel(ServiceContext ctx) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void init(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void execute(ServiceContext ctx) throws Exception {
+ // No-op.
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/195cd57f/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
index 2a24c66..a41859e 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteKernalSelfTestSuite.java
@@ -50,6 +50,7 @@ import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNo
import org.apache.ignite.internal.processors.service.GridServiceProcessorMultiNodeSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorProxySelfTest;
import org.apache.ignite.internal.processors.service.GridServiceProcessorSingleNodeSelfTest;
+import org.apache.ignite.internal.processors.service.GridServiceProcessorStopSelfTest;
import org.apache.ignite.internal.processors.service.GridServiceReassignmentSelfTest;
import org.apache.ignite.internal.util.GridStartupWithSpecifiedWorkDirectorySelfTest;
import org.apache.ignite.internal.util.GridStartupWithUndefinedIgniteHomeSelfTest;
@@ -115,6 +116,7 @@ public class IgniteKernalSelfTestSuite extends TestSuite {
suite.addTestSuite(GridServiceProcessorProxySelfTest.class);
suite.addTestSuite(GridServiceReassignmentSelfTest.class);
suite.addTestSuite(GridServiceClientNodeTest.class);
+ suite.addTestSuite(GridServiceProcessorStopSelfTest.class);
return suite;
}
[32/50] [abbrv] ignite git commit: ignite-1395: REST HTTP module
prints out unnecessary message
Posted by ag...@apache.org.
ignite-1395: REST HTTP module prints out unnecessary message
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/73c2db5c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/73c2db5c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/73c2db5c
Branch: refs/heads/ignite-1702
Commit: 73c2db5cb55dce46ed98564cbf9a8842f09bb413
Parents: fec2450
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:35:31 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:35:31 2015 +0300
----------------------------------------------------------------------
modules/rest-http/pom.xml | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/73c2db5c/modules/rest-http/pom.xml
----------------------------------------------------------------------
diff --git a/modules/rest-http/pom.xml b/modules/rest-http/pom.xml
index 58eb1ed..730e28a 100644
--- a/modules/rest-http/pom.xml
+++ b/modules/rest-http/pom.xml
@@ -113,5 +113,11 @@
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.7</version>
+ </dependency>
</dependencies>
</project>
[49/50] [abbrv] ignite git commit: Merge branch ignite-1.5 into
ignite-1702
Posted by ag...@apache.org.
Merge branch ignite-1.5 into ignite-1702
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2d92ad22
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2d92ad22
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2d92ad22
Branch: refs/heads/ignite-1702
Commit: 2d92ad22590ef2a43bc581a6133a2111b9bf2015
Parents: a45a788 7dfaa3b
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Sun Nov 8 20:12:21 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sun Nov 8 20:12:21 2015 +0300
----------------------------------------------------------------------
DEVNOTES.txt | 5 +-
assembly/dependencies-fabric-lgpl.xml | 169 +
assembly/dependencies-fabric.xml | 3 +
assembly/release-fabric-base.xml | 107 +
assembly/release-fabric-lgpl.xml | 41 +-
assembly/release-fabric.xml | 85 +-
assembly/release-hadoop-lgpl.xml | 39 -
config/fabric-lgpl/default-config.xml | 29 +
examples-lgpl/README.txt | 27 -
examples-lgpl/config/example-cache.xml | 73 -
examples-lgpl/config/example-ignite.xml | 83 -
examples-lgpl/config/hibernate/README.txt | 8 -
.../hibernate/example-hibernate-L2-cache.xml | 64 -
examples-lgpl/pom-standalone.xml | 186 -
examples-lgpl/pom.xml | 128 -
.../hibernate/HibernateL2CacheExample.java | 245 -
.../examples/datagrid/hibernate/Post.java | 130 -
.../examples/datagrid/hibernate/User.java | 154 -
.../datagrid/hibernate/package-info.java | 22 -
.../hibernate/CacheHibernatePersonStore.java | 122 -
.../hibernate/CacheHibernateStoreExample.java | 151 -
.../datagrid/store/hibernate/Person.hbm.xml | 34 -
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 -
.../datagrid/store/hibernate/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 82 -
.../examples/misc/schedule/package-info.java | 22 -
.../misc/schedule/ComputeScheduleExample.java | 68 -
.../java8/misc/schedule/package-info.java | 22 -
.../ignite/examples/java8/package-info.java | 23 -
.../scalar/examples/ScalarScheduleExample.scala | 66 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 -
.../HibernateL2CacheExampleSelfTest.java | 33 -
.../IgniteLgplExamplesSelfTestSuite.java | 48 -
...ibernateL2CacheExampleMultiNodeSelfTest.java | 29 -
.../HibernateL2CacheExampleSelfTest.java | 37 -
.../IgniteLgplExamplesJ8SelfTestSuite.java | 46 -
.../ScalarLgplExamplesMultiNodeSelfTest.scala | 33 -
.../examples/ScalarLgplExamplesSelfTest.scala | 36 -
.../ScalarLgplExamplesSelfTestSuite.scala | 37 -
examples/README-LGPL.txt | 33 +
examples/README.txt | 21 +-
examples/config/hibernate/README.txt | 8 +
.../hibernate/example-hibernate-L2-cache.xml | 64 +
examples/pom-standalone-lgpl.xml | 217 +
examples/pom-standalone.xml | 156 +-
examples/pom.xml | 157 +-
.../hibernate/HibernateL2CacheExample.java | 245 +
.../examples/datagrid/hibernate/Post.java | 130 +
.../examples/datagrid/hibernate/User.java | 154 +
.../datagrid/hibernate/package-info.java | 22 +
.../hibernate/CacheHibernatePersonStore.java | 122 +
.../hibernate/CacheHibernateStoreExample.java | 151 +
.../datagrid/store/hibernate/Person.hbm.xml | 34 +
.../datagrid/store/hibernate/hibernate.cfg.xml | 41 +
.../datagrid/store/hibernate/package-info.java | 22 +
.../misc/schedule/ComputeScheduleExample.java | 82 +
.../examples/misc/schedule/package-info.java | 22 +
.../java8/messaging/MessagingExample.java | 7 +-
...ibernateL2CacheExampleMultiNodeSelfTest.java | 31 +
.../HibernateL2CacheExampleSelfTest.java | 33 +
.../IgniteLgplExamplesSelfTestSuite.java | 48 +
.../ClientAbstractMultiThreadedSelfTest.java | 3 +-
.../src/main/java/org/apache/ignite/Ignite.java | 12 +-
.../apache/ignite/IgniteSystemProperties.java | 12 +
.../affinity/fair/FairAffinityFunction.java | 497 +-
.../rendezvous/RendezvousAffinityFunction.java | 140 +-
.../configuration/CacheConfiguration.java | 82 +-
.../configuration/IgniteConfiguration.java | 32 +-
.../configuration/TransactionConfiguration.java | 6 +-
.../internal/GridEventConsumeHandler.java | 19 +-
.../apache/ignite/internal/IgniteKernal.java | 137 +-
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../org/apache/ignite/internal/IgnitionEx.java | 3 +
.../communication/GridIoMessageFactory.java | 10 +-
.../deployment/GridDeploymentLocalStore.java | 8 +-
.../GridDeploymentPerLoaderStore.java | 8 +-
.../GridDeploymentPerVersionStore.java | 8 +-
.../internal/portable/PortableContext.java | 103 +-
.../internal/portable/PortableWriterExImpl.java | 66 +-
.../portable/api/PortableMarshaller.java | 5 +
.../affinity/GridAffinityAssignmentCache.java | 13 +
.../processors/cache/CacheMetricsImpl.java | 12 +-
.../processors/cache/CacheObjectContext.java | 17 +-
.../processors/cache/GridCacheAdapter.java | 459 +-
.../cache/GridCacheAffinityManager.java | 28 +-
.../processors/cache/GridCacheContext.java | 10 +-
.../processors/cache/GridCacheEntryEx.java | 62 +-
.../cache/GridCacheEvictionManager.java | 5 +-
.../cache/GridCacheEvictionRequest.java | 18 +-
.../cache/GridCacheEvictionResponse.java | 7 +-
.../processors/cache/GridCacheIoManager.java | 81 +-
.../processors/cache/GridCacheMapEntry.java | 175 +-
.../processors/cache/GridCacheMessage.java | 72 +-
.../processors/cache/GridCacheMvcc.java | 143 +-
.../cache/GridCacheMvccCandidate.java | 26 +-
.../GridCachePartitionExchangeManager.java | 188 +-
.../processors/cache/GridCachePreloader.java | 60 +-
.../cache/GridCachePreloaderAdapter.java | 45 +-
.../processors/cache/GridCacheProcessor.java | 177 +-
.../cache/GridCacheSharedContext.java | 3 +
.../processors/cache/GridCacheUtils.java | 70 +-
.../distributed/GridCacheTtlUpdateRequest.java | 7 +-
.../distributed/GridCacheTxRecoveryFuture.java | 22 +-
.../distributed/GridCacheTxRecoveryRequest.java | 8 +-
.../GridCacheTxRecoveryResponse.java | 10 +-
.../distributed/GridDistributedBaseMessage.java | 16 +-
.../distributed/GridDistributedCacheEntry.java | 12 +-
.../distributed/GridDistributedLockRequest.java | 8 +-
.../GridDistributedLockResponse.java | 20 +-
.../GridDistributedTxFinishRequest.java | 6 +-
.../GridDistributedTxFinishResponse.java | 7 +-
.../GridDistributedTxPrepareRequest.java | 13 +-
.../GridDistributedTxPrepareResponse.java | 12 +-
.../GridDistributedTxRemoteAdapter.java | 61 +-
.../GridDistributedUnlockRequest.java | 7 +-
.../dht/CacheDistributedGetFutureAdapter.java | 158 +
.../dht/GridDhtAffinityAssignmentRequest.java | 7 +-
.../dht/GridDhtAffinityAssignmentResponse.java | 7 +-
.../distributed/dht/GridDhtCacheAdapter.java | 20 +-
.../distributed/dht/GridDhtCacheEntry.java | 34 +-
.../cache/distributed/dht/GridDhtGetFuture.java | 199 +-
.../distributed/dht/GridDhtLocalPartition.java | 71 +-
.../distributed/dht/GridDhtLockFuture.java | 10 +-
.../distributed/dht/GridDhtLockRequest.java | 7 +-
.../distributed/dht/GridDhtLockResponse.java | 14 +-
.../dht/GridDhtPartitionsReservation.java | 2 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 127 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 9 +-
.../distributed/dht/GridDhtTxFinishRequest.java | 7 +-
.../dht/GridDhtTxFinishResponse.java | 2 +-
.../cache/distributed/dht/GridDhtTxLocal.java | 4 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 181 +-
.../dht/GridDhtTxPrepareRequest.java | 28 +-
.../dht/GridDhtTxPrepareResponse.java | 13 +-
.../distributed/dht/GridDhtUnlockRequest.java | 7 +-
.../dht/GridPartitionedGetFuture.java | 182 +-
.../dht/atomic/GridDhtAtomicCache.java | 26 +-
.../GridDhtAtomicDeferredUpdateResponse.java | 12 +-
.../dht/atomic/GridDhtAtomicUpdateFuture.java | 6 +-
.../dht/atomic/GridDhtAtomicUpdateRequest.java | 25 +-
.../dht/atomic/GridDhtAtomicUpdateResponse.java | 11 +-
.../dht/atomic/GridNearAtomicUpdateFuture.java | 12 +-
.../dht/atomic/GridNearAtomicUpdateRequest.java | 33 +-
.../atomic/GridNearAtomicUpdateResponse.java | 11 +-
.../dht/colocated/GridDhtColocatedCache.java | 138 +-
.../colocated/GridDhtColocatedLockFuture.java | 9 +-
.../dht/preloader/GridDhtForceKeysFuture.java | 19 +-
.../dht/preloader/GridDhtForceKeysRequest.java | 35 +-
.../dht/preloader/GridDhtForceKeysResponse.java | 11 +-
.../GridDhtPartitionDemandMessage.java | 19 +-
.../preloader/GridDhtPartitionDemandPool.java | 1192 -----
.../dht/preloader/GridDhtPartitionDemander.java | 1389 ++++++
.../dht/preloader/GridDhtPartitionSupplier.java | 1034 +++++
.../GridDhtPartitionSupplyMessage.java | 9 +-
.../GridDhtPartitionSupplyMessageV2.java | 380 ++
.../preloader/GridDhtPartitionSupplyPool.java | 555 ---
.../GridDhtPartitionsAbstractMessage.java | 7 +-
.../GridDhtPartitionsExchangeFuture.java | 8 +
.../dht/preloader/GridDhtPreloader.java | 306 +-
.../distributed/near/GridNearAtomicCache.java | 2 -
.../distributed/near/GridNearCacheAdapter.java | 32 +-
.../distributed/near/GridNearCacheEntry.java | 81 +-
.../distributed/near/GridNearGetFuture.java | 345 +-
.../distributed/near/GridNearGetRequest.java | 15 +-
.../distributed/near/GridNearGetResponse.java | 12 +-
.../distributed/near/GridNearLockFuture.java | 3 +-
.../distributed/near/GridNearLockRequest.java | 8 +-
.../distributed/near/GridNearLockResponse.java | 8 +-
...arOptimisticSerializableTxPrepareFuture.java | 936 ++++
.../near/GridNearOptimisticTxPrepareFuture.java | 255 +-
...ridNearOptimisticTxPrepareFutureAdapter.java | 222 +
.../GridNearPessimisticTxPrepareFuture.java | 11 +-
.../near/GridNearTransactionalCache.java | 22 +-
.../near/GridNearTxFinishFuture.java | 20 +-
.../near/GridNearTxFinishRequest.java | 7 +-
.../near/GridNearTxFinishResponse.java | 2 +-
.../cache/distributed/near/GridNearTxLocal.java | 157 +-
.../near/GridNearTxPrepareFutureAdapter.java | 13 +-
.../near/GridNearTxPrepareRequest.java | 8 +-
.../near/GridNearTxPrepareResponse.java | 8 +-
.../distributed/near/GridNearUnlockRequest.java | 7 +-
.../cache/local/GridLocalCacheEntry.java | 23 +-
.../cache/local/GridLocalLockFuture.java | 2 +
.../local/atomic/GridLocalAtomicCache.java | 9 -
.../portable/CacheObjectPortableContext.java | 6 +-
.../CacheObjectPortableProcessorImpl.java | 14 +-
.../query/GridCacheDistributedQueryFuture.java | 5 +-
.../query/GridCacheDistributedQueryManager.java | 25 +-
.../cache/query/GridCacheQueryRequest.java | 46 +-
.../cache/query/GridCacheQueryResponse.java | 29 +-
.../continuous/CacheContinuousQueryHandler.java | 8 +-
.../continuous/CacheContinuousQueryManager.java | 6 +-
.../cache/transactions/IgniteInternalTx.java | 8 +-
.../transactions/IgniteTransactionsImpl.java | 6 -
.../cache/transactions/IgniteTxAdapter.java | 128 +-
.../cache/transactions/IgniteTxEntry.java | 59 +-
.../cache/transactions/IgniteTxHandler.java | 18 +-
.../transactions/IgniteTxLocalAdapter.java | 843 ++--
.../cache/transactions/IgniteTxLocalEx.java | 27 +-
.../cache/transactions/IgniteTxManager.java | 331 +-
.../cache/version/GridCacheVersionManager.java | 73 +-
.../IgniteCacheObjectProcessorImpl.java | 7 +-
.../datastreamer/DataStreamerImpl.java | 2 +-
.../datastructures/DataStructuresProcessor.java | 3 +
.../processors/job/GridJobProcessor.java | 96 +-
.../service/GridServiceProcessor.java | 31 +-
.../processors/task/GridTaskWorker.java | 4 +-
.../ignite/internal/util/lang/GridFunc.java | 8 +-
.../ignite/internal/util/lang/GridTuple4.java | 2 +-
.../util/nio/GridNioRecoveryDescriptor.java | 11 +-
.../ignite/internal/util/nio/GridNioServer.java | 2 +-
.../ignite/internal/visor/cache/VisorCache.java | 5 +-
.../ignite/marshaller/AbstractMarshaller.java | 12 +-
.../ignite/marshaller/jdk/JdkMarshaller.java | 7 +-
.../optimized/OptimizedMarshaller.java | 14 +-
.../optimized/OptimizedMarshallerUtils.java | 35 +-
.../communication/tcp/TcpCommunicationSpi.java | 40 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 205 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 272 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +-
.../messages/TcpDiscoveryAbstractMessage.java | 11 +
.../TcpDiscoveryClientReconnectMessage.java | 1 +
.../messages/TcpDiscoveryDiscardMessage.java | 1 +
.../messages/TcpDiscoveryNodeAddedMessage.java | 39 +
.../apache/ignite/transactions/Transaction.java | 2 +-
.../transactions/TransactionIsolation.java | 3 +-
modules/core/src/test/config/tests.properties | 4 +-
.../AbstractAffinityFunctionSelfTest.java | 293 ++
.../affinity/AffinityClientNodeSelfTest.java | 194 +
...ityFunctionBackupFilterAbstractSelfTest.java | 138 +
...unctionExcludeNeighborsAbstractSelfTest.java | 182 +
.../affinity/IgniteClientNodeAffinityTest.java | 194 -
.../fair/FairAffinityDynamicCacheSelfTest.java | 99 +
...airAffinityFunctionBackupFilterSelfTest.java | 35 +
...ffinityFunctionExcludeNeighborsSelfTest.java | 31 +
.../fair/FairAffinityFunctionNodesSelfTest.java | 245 +
.../fair/FairAffinityFunctionSelfTest.java | 31 +
.../GridFairAffinityFunctionNodesSelfTest.java | 245 -
.../fair/GridFairAffinityFunctionSelfTest.java | 270 --
.../IgniteFairAffinityDynamicCacheSelfTest.java | 97 -
...ousAffinityFunctionBackupFilterSelfTest.java | 35 +
...ffinityFunctionExcludeNeighborsSelfTest.java | 32 +
.../RendezvousAffinityFunctionSelfTest.java | 50 +
.../GridTaskFailoverAffinityRunTest.java | 3 +
.../IgniteClientReconnectCacheTest.java | 33 +
.../GridDiscoveryManagerAttributesSelfTest.java | 51 +-
.../processors/cache/CacheNamesSelfTest.java | 69 +
.../cache/CacheNearReaderUpdateTest.java | 390 ++
.../CacheSerializableTransactionsTest.java | 4392 ++++++++++++++++++
.../cache/CrossCacheTxRandomOperationsTest.java | 10 +-
.../GridCacheAbstractFailoverSelfTest.java | 14 +-
.../cache/GridCacheAbstractFullApiSelfTest.java | 9 +-
.../GridCacheAbstractLocalStoreSelfTest.java | 5 +
.../GridCacheAbstractRemoveFailureTest.java | 98 +-
...eAtomicEntryProcessorDeploymentSelfTest.java | 211 +
.../GridCacheConcurrentTxMultiNodeTest.java | 3 -
.../GridCacheConditionalDeploymentSelfTest.java | 190 +
...idCacheConfigurationConsistencySelfTest.java | 17 -
.../GridCacheDeploymentOffHeapSelfTest.java | 17 +-
.../cache/GridCacheDeploymentSelfTest.java | 26 +-
.../cache/GridCacheMvccFlagsTest.java | 6 +-
.../cache/GridCacheMvccPartitionedSelfTest.java | 164 +
.../processors/cache/GridCacheMvccSelfTest.java | 3 +-
.../processors/cache/GridCacheTestEntryEx.java | 53 +-
...ctionalEntryProcessorDeploymentSelfTest.java | 31 +
.../cache/IgniteCacheCreateRestartSelfTest.java | 4 +-
.../IgniteCacheEntryListenerAbstractTest.java | 50 +-
.../IgniteCacheP2pUnmarshallingErrorTest.java | 2 +-
.../cache/IgniteCachePutAllRestartTest.java | 3 +
.../cache/IgniteCacheTxNearPeekModesTest.java | 7 +-
.../cache/IgniteCacheTxPeekModesTest.java | 5 +
.../processors/cache/IgniteTxAbstractTest.java | 42 +-
.../IgniteTxMultiThreadedAbstractTest.java | 106 +-
.../IgniteCountDownLatchAbstractSelfTest.java | 4 +-
...PartitionedQueueCreateMultiNodeSelfTest.java | 5 +-
...IgnitePartitionedCountDownLatchSelfTest.java | 7 +-
.../CacheGetFutureHangsSelfTest.java | 11 +-
...dCachePartitionedAffinityFilterSelfTest.java | 143 -
...onedNearDisabledTxMultiThreadedSelfTest.java | 31 +
...niteCacheClientNodeChangingTopologyTest.java | 176 +-
.../IgniteCacheClientReconnectTest.java | 2 +
.../distributed/IgniteCacheManyClientsTest.java | 14 +-
.../dht/GridCacheDhtPreloadPutGetSelfTest.java | 3 +
.../dht/GridCacheTxNodeFailureSelfTest.java | 21 +-
.../IgniteCacheCrossCacheTxFailoverTest.java | 23 +-
.../dht/IgniteCacheLockFailoverSelfTest.java | 11 +
.../IgniteCachePutRetryAbstractSelfTest.java | 4 +-
...eAtomicInvalidPartitionHandlingSelfTest.java | 6 +-
...unctionExcludeNeighborsAbstractSelfTest.java | 184 -
...omicMultiNodeP2PDisabledFullApiSelfTest.java | 7 +-
...ledFairAffinityMultiNodeFullApiSelfTest.java | 3 +-
...omicNearEnabledMultiNodeFullApiSelfTest.java | 2 +-
...icOffHeapTieredMultiNodeFullApiSelfTest.java | 2 +-
.../near/GridCacheNearTxExceptionSelfTest.java | 16 +
...CachePartitionedTxMultiThreadedSelfTest.java | 15 +-
...ffinityFunctionExcludeNeighborsSelfTest.java | 32 -
.../GridCacheRebalancingAsyncSelfTest.java | 68 +
.../GridCacheRebalancingSyncSelfTest.java | 506 ++
...eRebalancingUnmarshallingFailedSelfTest.java | 147 +
...xcludeNeighborsMultiNodeFullApiSelfTest.java | 36 +
...tedFairAffinityMultiNodeFullApiSelfTest.java | 35 +
...xcludeNeighborsMultiNodeFullApiSelfTest.java | 36 +
...dezvousAffinityMultiNodeFullApiSelfTest.java | 36 +
.../replicated/GridReplicatedTxPreloadTest.java | 7 +-
.../GridCacheReplicatedPreloadSelfTest.java | 22 +-
.../DataStreamerUpdateAfterLoadTest.java | 184 +
.../GridServiceProcessorStopSelfTest.java | 103 +
.../nio/IgniteExceptionInNioWorkerSelfTest.java | 105 +
.../loadtests/hashmap/GridHashMapLoadTest.java | 6 +-
.../communication/GridCacheMessageSelfTest.java | 17 +-
...gniteClientReconnectMassiveShutdownTest.java | 329 ++
.../tcp/TcpClientDiscoverySpiSelfTest.java | 4 +-
.../tcp/TcpDiscoveryMultiThreadedTest.java | 288 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 17 -
.../spi/discovery/tcp/TestTcpDiscoverySpi.java | 46 +
.../inmemory/GridTestSwapSpaceSpi.java | 8 +
.../ignite/testframework/GridTestUtils.java | 23 +-
.../testframework/junits/GridAbstractTest.java | 3 +-
.../ignite/testframework/junits/IgniteMock.java | 5 +
.../junits/common/GridCommonAbstractTest.java | 40 +-
.../junits/multijvm/IgniteProcessProxy.java | 7 +-
.../ignite/testsuites/IgniteBasicTestSuite.java | 7 +-
.../IgniteCacheFullApiSelfTestSuite.java | 8 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 40 +-
.../testsuites/IgniteCacheTestSuite2.java | 14 +-
.../testsuites/IgniteCacheTestSuite3.java | 12 +-
.../testsuites/IgniteCacheTestSuite5.java | 40 +
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
.../testsuites/IgniteP2PSelfTestSuite.java | 16 +-
.../p2p/CacheDeploymentEntryProcessor.java | 35 +
.../CacheDeploymentPortableEntryProcessor.java | 35 +
modules/extdata/uri/pom.xml | 21 +-
.../CacheHibernateBlobStoreSelfTest.java | 6 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../cache/IgniteCacheAbstractQuerySelfTest.java | 4 +
...niteCacheP2pUnmarshallingQueryErrorTest.java | 32 +-
.../cache/SqlFieldsQuerySelfTest.java | 2 -
.../tcp/GridOrderedMessageCancelSelfTest.java | 18 +-
modules/jms11/pom.xml | 9 +-
.../stream/jms11/IgniteJmsStreamerTest.java | 9 +-
.../ignite/logger/log4j2/Log4J2Logger.java~ | 542 ---
.../ignite/logger/log4j2/Log4j2FileAware.java~ | 33 -
.../ignite/logger/log4j2/Log4jFileAware.java~ | 13 -
.../apache/ignite/stream/mqtt/MqttStreamer.java | 386 +-
.../stream/mqtt/IgniteMqttStreamerTest.java | 142 +-
.../mqtt/IgniteMqttStreamerTestSuite.java | 4 +-
modules/rest-http/pom.xml | 6 +
.../http/jetty/GridJettyRestProtocol.java | 4 +-
modules/spark-2.10/pom.xml | 4 +-
modules/spark/pom.xml | 4 +-
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRDDSpec.scala | 249 +
.../org/apache/ignite/spark/IgniteRddSpec.scala | 249 -
.../org/apache/ignite/IgniteSpringBean.java | 10 +-
modules/ssh/pom.xml | 2 +-
.../config/benchmark-client-mode.properties | 4 +-
.../config/benchmark-failover.properties | 107 +
.../config/benchmark-multicast.properties | 68 +-
.../yardstick/config/benchmark-store.properties | 4 +-
modules/yardstick/config/benchmark.properties | 4 +-
.../config/ignite-failover-base-config.xml | 126 +
.../config/ignite-failover-localhost-config.xml | 56 +
modules/yardstick/pom.xml | 3 +-
.../yardstick/IgniteAbstractBenchmark.java | 2 +-
.../yardstick/IgniteBenchmarkArguments.java | 69 +-
.../IgniteAccountSerializableTxBenchmark.java | 81 +
.../cache/IgniteAccountTxAbstractBenchmark.java | 61 +
.../cache/IgniteAccountTxBenchmark.java | 74 +
.../cache/IgniteCacheAbstractBenchmark.java | 76 +-
.../yardstick/cache/IgniteGetBenchmark.java | 4 +-
.../cache/IgniteJdbcSqlQueryBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutAllBenchmark.java | 4 +-
.../IgnitePutAllSerializableTxBenchmark.java | 77 +
.../cache/IgnitePutAllTxBenchmark.java | 10 +-
.../yardstick/cache/IgnitePutBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutGetBenchmark.java | 4 +-
.../cache/IgnitePutGetTxBenchmark.java | 4 +-
.../cache/IgnitePutIndexedValue1Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue2Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue8Benchmark.java | 4 +-
.../yardstick/cache/IgnitePutTxBenchmark.java | 4 +-
.../cache/IgniteSqlQueryBenchmark.java | 4 +-
.../cache/IgniteSqlQueryJoinBenchmark.java | 4 +-
.../cache/IgniteSqlQueryPutBenchmark.java | 4 +-
.../IgniteAtomicInvokeRetryBenchmark.java | 214 +
...IgniteAtomicOffHeapInvokeRetryBenchmark.java | 31 +
.../IgniteAtomicOffHeapRetriesBenchmark.java | 31 +
.../failover/IgniteAtomicRetriesBenchmark.java | 89 +
.../IgniteFailoverAbstractBenchmark.java | 320 ++
.../cache/failover/IgniteFailoverNode.java | 60 +
...IgniteTransactionalInvokeRetryBenchmark.java | 212 +
...ransactionalOffHeapInvokeRetryBenchmark.java | 33 +
...ransactionalOffHeapWriteInvokeBenchmark.java | 37 +
...eTransactionalOffHeapWriteReadBenchmark.java | 32 +
...IgniteTransactionalWriteInvokeBenchmark.java | 182 +
.../IgniteTransactionalWriteReadBenchmark.java | 141 +
.../ignite/yardstick/cache/model/Account.java | 42 +
.../ipfinder/zk/ZookeeperIpFinderTestSuite.java | 32 +
parent/pom.xml | 1 +
pom.xml | 64 -
400 files changed, 23642 insertions(+), 10110 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxFinishFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index 4e946c5,61975d7..977b269
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@@ -57,7 -56,7 +56,8 @@@ import org.apache.ignite.internal.proce
import org.apache.ignite.internal.processors.cache.transactions.IgniteTxKey;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.dr.GridDrType;
+import org.apache.ignite.internal.transactions.IgniteTxHeuristicCheckedException;
+ import org.apache.ignite.internal.transactions.IgniteTxOptimisticCheckedException;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.GridLeanSet;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxLocal.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
----------------------------------------------------------------------
diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
index 35ea25b,d9786a8..61aa1f2
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxHandler.java
@@@ -413,9 -416,10 +416,10 @@@ public class IgniteTxHandler
req.last(),
req.lastBackups());
- if (tx.isRollbackOnly()) {
+ if (tx.isRollbackOnly() && !tx.commitOnPrepare()) {
try {
- tx.rollback();
+ if (tx.state() != TransactionState.ROLLED_BACK && tx.state() != TransactionState.ROLLING_BACK)
+ tx.rollback();
}
catch (IgniteCheckedException e) {
U.error(log, "Failed to rollback transaction: " + tx, e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2d92ad22/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 3e6d335,f6432a7..835030f
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@@ -35,7 -35,7 +35,8 @@@ import org.apache.ignite.cache.store.jd
import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest;
+import org.apache.ignite.internal.processors.cache.CachePutEventListenerErrorSelfTest;
+ import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest;
[17/50] [abbrv] ignite git commit: ignite-1397: Load/consistency
tests.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
new file mode 100644
index 0000000..f8a1689
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteTransactionalInvokeRetryBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** */
+ private final ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<>();
+
+ /** */
+ private final ReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+ /** */
+ private volatile Exception ex;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ final int timeout = args.cacheOperationTimeoutMillis();
+ final int keysCnt = args.keysCount();
+
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.cacheConsistencyCheckingPeriod() * 1000);
+
+ rwl.writeLock().lock();
+
+ try {
+ println("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Long> notEqualsCacheVals = new HashMap<>();
+ Map<String, Long> notEqualsLocMapVals = new HashMap<>();
+
+ for (int k = 0; k < args.range(); k++) {
+ if (k % 10_000 == 0)
+ println("Start validation for keys like 'key-" + k + "-*'");
+
+ for (int i = 0; i < keysCnt; i++) {
+ String key = "key-" + k + "-" + cfg.memberId() + "-" + i;
+
+ asyncCache.get(key);
+ Long cacheVal = asyncCache.<Long>future().get(timeout);
+
+ AtomicLong aVal = map.get(key);
+ Long mapVal = aVal != null ? aVal.get() : null;
+
+ if (!Objects.equals(cacheVal, mapVal)) {
+ notEqualsCacheVals.put(key, cacheVal);
+ notEqualsLocMapVals.put(key, mapVal);
+ }
+ }
+ }
+
+ assert notEqualsCacheVals.size() == notEqualsLocMapVals.size() : "Invalid state " +
+ "[cacheMapVals=" + notEqualsCacheVals + ", mapVals=" + notEqualsLocMapVals + "]";
+
+ if (!notEqualsCacheVals.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Long> eLocMap : notEqualsLocMapVals.entrySet()) {
+ String key = eLocMap.getKey();
+ Long mapVal = eLocMap.getValue();
+ Long cacheVal = notEqualsCacheVals.get(key);
+
+ println(cfg, "Got different values [key='" + key
+ + "', cacheVal=" + cacheVal + ", localMapVal=" + mapVal + "]");
+ }
+
+ println(cfg, "Local driver map contant:\n " + map);
+
+ println(cfg, "Cache content:");
+
+ for (int k2 = 0; k2 < args.range(); k2++) {
+ for (int i2 = 0; i2 < keysCnt; i2++) {
+ String key2 = "key-" + k2 + "-" + cfg.memberId() + "-" + i2;
+
+ asyncCache.get(key2);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key2 + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Cache and local map are in inconsistent state.");
+ }
+
+ println("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+ finally {
+ rwl.writeLock().unlock();
+ }
+ }
+ }
+ catch (Throwable e) {
+ ex = new Exception(e);
+
+ println("Got exception: " + e);
+
+ e.printStackTrace();
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "cache-" + cacheName() + "-validator");
+
+ thread.setDaemon(true);
+
+ thread.start();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ final String[] keys = new String[args.keysCount()];
+
+ assert keys.length > 0 : "Count of keys: " + keys.length;
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + cfg.memberId() + "-" + i;
+
+ for (String key : keys) {
+ rwl.readLock().lock();
+
+ try {
+ if (ex != null)
+ throw ex;
+
+ asyncCache.invoke(key, new IncrementCacheEntryProcessor());
+ asyncCache.future().get(args.cacheOperationTimeoutMillis());
+
+ AtomicLong prevVal = map.putIfAbsent(key, new AtomicLong(0));
+
+ if (prevVal != null)
+ prevVal.incrementAndGet();
+ }
+ finally {
+ rwl.readLock().unlock();
+ }
+ }
+
+ if (ex != null)
+ throw ex;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-invoke-retry";
+ }
+
+ /**
+ */
+ private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Long> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Long process(MutableEntry<String, Long> entry,
+ Object... arguments) throws EntryProcessorException {
+ long newVal = entry.getValue() == null ? 0 : entry.getValue() + 1;
+
+ entry.setValue(newVal);
+
+ return newVal;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
new file mode 100644
index 0000000..4cbcf67
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Invoke retry failover benchmark.
+ * <p>
+ * Each client maintains a local map that it updates together with cache.
+ * Client invokes an increment closure for all generated keys and atomically increments value for corresponding
+ * keys in the local map. To validate cache contents, all writes from the client are stopped, values in
+ * the local map are compared to the values in the cache.
+ */
+public class IgniteTransactionalOffHeapInvokeRetryBenchmark extends IgniteTransactionalInvokeRetryBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-invoke-retry";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
new file mode 100644
index 0000000..7fa2d1a
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Transactional write invoke failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + 'master',
+ * 'key-' + K + '-1', 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction
+ * and randomly chooses between read and write scenarios:
+ * <ul>
+ * <li>Reads value associated with the master key and child keys. Values must be equal.</li>
+ * <li>Reads value associated with the master key, increments it by 1 and puts the value, then invokes increment
+ * closure on child keys. No validation is performed.</li>
+ * </ul>
+ */
+public class IgniteTransactionalOffHeapWriteInvokeBenchmark extends IgniteTransactionalWriteInvokeBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-write-invoke";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
new file mode 100644
index 0000000..bdecca7
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Transactional write read failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + '-1',
+ * 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction, reads value associated with
+ * each key. Values must be equal. Client increments value by 1, commits the transaction.
+ */
+public class IgniteTransactionalOffHeapWriteReadBenchmark extends IgniteTransactionalWriteReadBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-write-read";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
new file mode 100644
index 0000000..1a8ee14
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.cache.CacheException;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Transactional write invoke failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + 'master',
+ * 'key-' + K + '-1', 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction
+ * and randomly chooses between read and write scenarios:
+ * <ul>
+ * <li>Reads value associated with the master key and child keys. Values must be equal.</li>
+ * <li>Reads value associated with the master key, increments it by 1 and puts the value, then invokes increment
+ * closure on child keys. No validation is performed.</li>
+ * </ul>
+ */
+public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ assert args.keysCount() > 0 : "Count of keys: " + args.keysCount();
+
+ final String[] keys = new String[args.keysCount()];
+
+ final String masterKey = "key-" + k + "-master";
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ final int scenario = nextRandom(2);
+
+ return doInTransaction(ignite(), new Callable<Boolean>() {
+ @Override public Boolean call() throws Exception {
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ switch (scenario) {
+ case 0: // Read scenario.
+ Map<String, Long> map = new HashMap<>();
+
+ asyncCache.get(masterKey);
+ Long cacheVal = asyncCache.<Long>future().get(timeout);
+
+ map.put(masterKey, cacheVal);
+
+ for (String key : keys) {
+ asyncCache.get(key);
+ cacheVal = asyncCache.<Long>future().get(timeout);
+
+ map.put(key, cacheVal);
+ }
+
+ Set<Long> values = new HashSet<>(map.values());
+
+ if (values.size() != 1) {
+ // Print all usefull information and finish.
+ println(cfg, "Got different values for keys [map=" + map + "]");
+
+ println(cfg, "Cache content:");
+
+ for (int k = 0; k < args.range(); k++) {
+ for (int i = 0; i < args.keysCount(); i++) {
+ String key = "key-" + k + "-" + i;
+
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Found different values for keys (see above information).");
+ }
+
+ break;
+ case 1: // Invoke scenario.
+ asyncCache.get(masterKey);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ asyncCache.put(masterKey, val == null ? 0 : val + 1);
+ asyncCache.future().get(timeout);
+
+ for (String key : keys) {
+ asyncCache.invoke(key, new IncrementCacheEntryProcessor());
+ asyncCache.future().get(timeout);
+ }
+
+ break;
+ }
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param ignite Ignite instance.
+ * @param clo Closure.
+ * @return Result of closure execution.
+ * @throws Exception
+ */
+ public static <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
+ while (true) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ T res = clo.call();
+
+ tx.commit();
+
+ return res;
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof ClusterTopologyException) {
+ ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
+
+ topEx.retryReadyFuture().get();
+ }
+ else
+ throw e;
+ }
+ catch (ClusterTopologyException e) {
+ e.retryReadyFuture().get();
+ }
+ catch (TransactionRollbackException ignore) {
+ // Safe to retry right away.
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-write-invoke";
+ }
+
+ /**
+ */
+ private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Void> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<String, Long> entry,
+ Object... arguments) throws EntryProcessorException {
+ entry.setValue(entry.getValue() == null ? 0 : entry.getValue() + 1);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
new file mode 100644
index 0000000..c962749
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Transactional write read failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + '-1',
+ * 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction, reads value associated with
+ * each key. Values must be equal. Client increments value by 1, commits the transaction.
+ */
+public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ assert args.keysCount() > 0 : "Count of keys: " + args.keysCount();
+
+ final String[] keys = new String[args.keysCount()];
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ return doInTransaction(ignite(), new Callable<Boolean>() {
+ @Override public Boolean call() throws Exception {
+ Map<String, Long> map = new HashMap<>();
+
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ for (String key : keys) {
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ map.put(key, val);
+ }
+
+ Set<Long> values = new HashSet<>(map.values());
+
+ if (values.size() != 1) {
+ // Print all usefull information and finish.
+ println(cfg, "Got different values for keys [map=" + map + "]");
+
+ println(cfg, "Cache content:");
+
+ for (int k = 0; k < args.range(); k++) {
+ for (int i = 0; i < args.keysCount(); i++) {
+ String key = "key-" + k + "-" + i;
+
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Found different values for keys (see above information).");
+ }
+
+ final Long oldVal = map.get(keys[0]);
+
+ final Long newVal = oldVal == null ? 0 : oldVal + 1;
+
+ for (String key : keys) {
+ asyncCache.put(key, newVal);
+ asyncCache.future().get(timeout);
+ }
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param ignite Ignite instance.
+ * @param clo Closure.
+ * @return Result of closure execution.
+ * @throws Exception
+ */
+ public static <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
+ while (true) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ T res = clo.call();
+
+ tx.commit();
+
+ return res;
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof ClusterTopologyException) {
+ ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
+
+ topEx.retryReadyFuture().get();
+ }
+ else
+ throw e;
+ }
+ catch (ClusterTopologyException e) {
+ e.retryReadyFuture().get();
+ }
+ catch (TransactionRollbackException ignore) {
+ // Safe to retry right away.
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-write-read";
+ }
+}
[04/50] [abbrv] ignite git commit: ignite-1745 GridCacheIoManager
should send correct response in case of cache query error
Posted by ag...@apache.org.
ignite-1745 GridCacheIoManager should send correct response in case of cache query error
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7bedc8ac
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7bedc8ac
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7bedc8ac
Branch: refs/heads/ignite-1702
Commit: 7bedc8aceefb94d1bd87620887a8a44025518abe
Parents: 3ec52f3
Author: agura <ag...@gridgain.com>
Authored: Tue Oct 27 18:22:42 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu Oct 29 15:36:15 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheIoManager.java | 28 +++++++++++++++--
...niteCacheP2pUnmarshallingQueryErrorTest.java | 32 +++++++++++++++++++-
2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7bedc8ac/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index ec34f41..082f330 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -53,6 +53,8 @@ import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLock
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockResponse;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareResponse;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest;
+import org.apache.ignite.internal.processors.cache.query.GridCacheQueryResponse;
import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
@@ -73,6 +75,9 @@ import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE;
* Cache communication manager.
*/
public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
+ /** Communication topic prefix for distributed queries. */
+ private static final String QUERY_TOPIC_PREFIX = "QUERY";
+
/** Message ID generator. */
private static final AtomicLong idGen = new AtomicLong();
@@ -304,8 +309,8 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
/**
* Processes failed messages.
*
- * @param nodeId niode id.
- * @param msg message.
+ * @param nodeId Node ID.
+ * @param msg Message.
* @throws IgniteCheckedException If failed.
*/
private void processFailedMessage(UUID nodeId, GridCacheMessage msg) throws IgniteCheckedException {
@@ -493,6 +498,25 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
break;
+ case 58: {
+ GridCacheQueryRequest req = (GridCacheQueryRequest)msg;
+
+ GridCacheQueryResponse res = new GridCacheQueryResponse(
+ req.cacheId(),
+ req.id(),
+ req.classError(),
+ cctx.deploymentEnabled());
+
+ cctx.io().sendOrderedMessage(
+ ctx.node(nodeId),
+ TOPIC_CACHE.topic(QUERY_TOPIC_PREFIX, nodeId, req.id()),
+ res,
+ ctx.ioPolicy(),
+ Long.MAX_VALUE);
+ }
+
+ break;
+
default:
throw new IgniteCheckedException("Failed to send response to node. Unsupported direct type [message="
+ msg + "]");
http://git-wip-us.apache.org/repos/asf/ignite/blob/7bedc8ac/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
index 6a4ba3a..07fa2bc 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheP2pUnmarshallingQueryErrorTest.java
@@ -17,9 +17,13 @@
package org.apache.ignite.internal.processors.cache;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import javax.cache.CacheException;
+import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.lang.IgniteBiPredicate;
/**
* Checks behavior on exception while unmarshalling key.
@@ -47,10 +51,36 @@ public class IgniteCacheP2pUnmarshallingQueryErrorTest extends IgniteCacheP2pUnm
try {
jcache(0).query(new SqlQuery<TestKey, String>(String.class, "field like '" + key + "'")).getAll();
- assert false : "p2p marshalling failed, but error response was not sent";
+ fail("p2p marshalling failed, but error response was not sent");
}
catch (CacheException e) {
// No-op
}
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testResponseMessageOnRequestUnmarshallingFailed() throws Exception {
+ readCnt.set(Integer.MAX_VALUE);
+
+ jcache(0).put(new TestKey(String.valueOf(++key)), "");
+
+ try {
+ jcache().query(new ScanQuery<>(new IgniteBiPredicate<TestKey, String>() {
+ @Override public boolean apply(TestKey key, String val) {
+ return false;
+ }
+
+ private void readObject(ObjectInputStream is) throws IOException {
+ throw new IOException();
+ }
+ })).getAll();
+
+ fail("Request unmarshalling failed, but error response was not sent.");
+ }
+ catch (Exception e) {
+ // No-op.
+ }
+ }
}
\ No newline at end of file
[27/50] [abbrv] ignite git commit: ignite-1758 Fixed client reconnect
issues
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
index ea9531a..1c258a4 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
@@ -29,7 +29,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs put and query operations.
*/
-public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -81,4 +81,4 @@ public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
new file mode 100644
index 0000000..c0567ef
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenchmark<String, Set> {
+ /** */
+ private final ConcurrentMap<String, AtomicLong> nextValMap = new ConcurrentHashMap<>();
+
+ /** */
+ private final ReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+ /** */
+ private volatile Exception ex;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ final int timeout = args.cacheOperationTimeoutMillis();
+ final int range = args.range();
+
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.cacheConsistencyCheckingPeriod() * 1000);
+
+ rwl.writeLock().lock();
+
+ try {
+ println("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Set> badCacheEntries = new HashMap<>();
+
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet()) {
+ String key = e.getKey();
+
+ asyncCache.get(key);
+ Set set = asyncCache.<Set>future().get(timeout);
+
+ if (set == null || e.getValue() == null || !Objects.equals(e.getValue().get(), (long)set.size()))
+ badCacheEntries.put(key, set);
+ }
+
+ if (!badCacheEntries.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Set> e : badCacheEntries.entrySet()) {
+ String key = e.getKey();
+
+ println("Got unexpected set size [key='" + key + "', expSize=" + nextValMap.get(key)
+ + ", cacheVal=" + e.getValue() + "]");
+ }
+
+ println("Next values map contant:");
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet())
+ println("Map Entry [key=" + e.getKey() + ", val=" + e.getValue() + "]");
+
+ println("Cache content:");
+
+ for (int k2 = 0; k2 < range; k2++) {
+ String key2 = "key-" + k2;
+
+ asyncCache.get(key2);
+ Object val = asyncCache.future().get(timeout);
+
+ if (val != null)
+ println("Cache Entry [key=" + key2 + ", val=" + val + "]");
+
+ }
+
+ throw new IllegalStateException("Cache and local map are in inconsistent state " +
+ "[badKeys=" + badCacheEntries.keySet() + ']');
+ }
+
+ println("Clearing all data.");
+
+ asyncCache.removeAll();
+ asyncCache.future().get(timeout);
+
+ nextValMap.clear();
+
+ println("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+ finally {
+ rwl.writeLock().unlock();
+ }
+ }
+ }
+ catch (Throwable e) {
+ ex = new Exception(e);
+
+ println("Got exception: " + e);
+
+ e.printStackTrace();
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "cache-" + cacheName() + "-validator");
+
+ thread.setDaemon(true);
+
+ thread.start();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ String key = "key-" + k;
+
+ rwl.readLock().lock();
+
+ try {
+ if (ex != null)
+ throw ex;
+
+ AtomicLong nextAtomicVal = nextValMap.putIfAbsent(key, new AtomicLong(1));
+
+ Long nextVal = 1L;
+
+ if (nextAtomicVal != null)
+ nextVal = nextAtomicVal.incrementAndGet();
+
+ asyncCache.invoke(key, new AddInSetEntryProcessor(), nextVal);
+ asyncCache.future().get(args.cacheOperationTimeoutMillis());
+ }
+ finally {
+ rwl.readLock().unlock();
+ }
+
+ if (ex != null)
+ throw ex;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-invoke-retry";
+ }
+
+ /**
+ */
+ private static class AddInSetEntryProcessor implements CacheEntryProcessor<String, Set, Object> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<String, Set> entry,
+ Object... arguments) throws EntryProcessorException {
+ assert !F.isEmpty(arguments);
+
+ Object val = arguments[0];
+
+ Set set;
+
+ if (!entry.exists())
+ set = new HashSet<>();
+ else
+ set = entry.getValue();
+
+ set.add(val);
+
+ entry.setValue(set);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
new file mode 100644
index 0000000..c8b0b1d
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteAtomicOffHeapInvokeRetryBenchmark extends IgniteAtomicInvokeRetryBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-offheap-invoke-retry";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
new file mode 100644
index 0000000..ebb9eac
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Atomic retries failover benchmark.
+ * <p>
+ * Client generates continuous load to the cluster (random get, put, invoke, remove
+ * operations).
+ */
+public class IgniteAtomicOffHeapRetriesBenchmark extends IgniteAtomicRetriesBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-offheap-reties";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
new file mode 100644
index 0000000..4e60698
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.Map;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+
+/**
+ * Atomic retries failover benchmark.
+ * <p>
+ * Client generates continuous load to the cluster (random get, put, invoke, remove
+ * operations).
+ */
+public class IgniteAtomicRetriesBenchmark extends IgniteFailoverAbstractBenchmark<Integer, String> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int key = nextRandom(args.range());
+
+ int opNum = nextRandom(4);
+
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ switch (opNum) {
+ case 0:
+ asyncCache.get(key);
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 1:
+ asyncCache.put(key, String.valueOf(key));
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 2:
+ asyncCache.invoke(key, new TestCacheEntryProcessor());
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 3:
+ asyncCache.remove(key);
+ asyncCache.future().get(timeout);
+
+ break;
+
+ default:
+ throw new IllegalStateException("Got invalid operation number: " + opNum);
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-reties";
+ }
+
+ /**
+ */
+ private static class TestCacheEntryProcessor implements CacheEntryProcessor<Integer, String, String> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<Integer, String> entry,
+ Object... arguments) throws EntryProcessorException {
+ return "key";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
new file mode 100644
index 0000000..83fc58f
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+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.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.mxbean.IgniteMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
+import org.yardstickframework.BenchmarkUtils.ProcessExecutionResult;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Ignite benchmark that performs long running failover tasks.
+ */
+public abstract class IgniteFailoverAbstractBenchmark<K, V> extends IgniteCacheAbstractBenchmark<K, V> {
+ /** */
+ private static final AtomicBoolean restarterStarted = new AtomicBoolean();
+
+ /** Async Cache. */
+ protected IgniteCache<K, V> asyncCache;
+
+ /** */
+ private final AtomicBoolean firtsExProcessed = new AtomicBoolean();
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ asyncCache = cache.withAsync();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onWarmupFinished() {
+ if (cfg.memberId() == 0 && restarterStarted.compareAndSet(false, true)) {
+ Thread restarterThread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ println("Servers restarter started on driver: "
+ + IgniteFailoverAbstractBenchmark.this.getClass().getSimpleName());
+
+ Ignite ignite = ignite();
+
+ // Read servers configs from cache to local map.
+ IgniteCache<Integer, BenchmarkConfiguration> srvsCfgsCache = ignite.
+ getOrCreateCache(new CacheConfiguration<Integer, BenchmarkConfiguration>().
+ setName("serversConfigs"));
+
+ final Map<Integer, BenchmarkConfiguration> srvsCfgs = new HashMap<>();
+
+ for (Cache.Entry<Integer, BenchmarkConfiguration> e : srvsCfgsCache) {
+ println("Read entry from 'serversConfigs' cache : " + e);
+
+ srvsCfgs.put(e.getKey(), e.getValue());
+ }
+
+ assert ignite.cluster().forServers().nodes().size() == srvsCfgs.size();
+
+ final int backupsCnt = args.backups();
+
+ assert backupsCnt >= 1 : "Backups: " + backupsCnt;
+
+ final boolean isDebug = ignite.log().isDebugEnabled();
+
+ // Main logic.
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.restartDelay() * 1000);
+
+ int numNodesToRestart = nextRandom(1, backupsCnt + 1);
+
+ List<Integer> ids = new ArrayList<>();
+
+ ids.addAll(srvsCfgs.keySet());
+
+ Collections.shuffle(ids);
+
+ println("Waiting for partitioned map exchage of all nodes");
+
+ IgniteCompute asyncCompute = ignite.compute().withAsync();
+
+ asyncCompute.broadcast(new AwaitPartitionMapExchangeTask());
+
+ asyncCompute.future().get(args.cacheOperationTimeoutMillis());
+
+ println("Start servers restarting [numNodesToRestart=" + numNodesToRestart
+ + ", shuffledIds=" + ids + "]");
+
+ for (int i = 0; i < numNodesToRestart; i++) {
+ Integer id = ids.get(i);
+
+ BenchmarkConfiguration bc = srvsCfgs.get(id);
+
+ ProcessExecutionResult res = BenchmarkUtils.kill9Server(bc, isDebug);
+
+ println("Server with id " + id + " has been killed."
+ + (isDebug ? " Process execution result:\n" + res : ""));
+ }
+
+ Thread.sleep(args.restartSleep() * 1000);
+
+ for (int i = 0; i < numNodesToRestart; i++) {
+ Integer id = ids.get(i);
+
+ BenchmarkConfiguration bc = srvsCfgs.get(id);
+
+ ProcessExecutionResult res = BenchmarkUtils.startServer(bc, isDebug);
+
+ println("Server with id " + id + " has been started."
+ + (isDebug ? " Process execution result:\n" + res : ""));
+ }
+ }
+ }
+ catch (Throwable e) {
+ println("Got exception: " + e);
+ e.printStackTrace();
+
+ U.dumpThreads(null);
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "servers-restarter");
+
+ restarterThread.setDaemon(true);
+ restarterThread.start();
+ }
+ }
+
+ /**
+ * Awaits for partitiona map exchage.
+ *
+ * @param ignite Ignite.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("BusyWait")
+ protected static void awaitPartitionMapExchange(Ignite ignite) throws Exception {
+ IgniteLogger log = ignite.log();
+
+ log.info("Waiting for finishing of a partition exchange on node: " + ignite);
+
+ IgniteKernal kernal = (IgniteKernal)ignite;
+
+ while (true) {
+ boolean partitionsExchangeFinished = true;
+
+ for (IgniteInternalCache<?, ?> cache : kernal.cachesx(null)) {
+ log.info("Checking cache: " + cache.name());
+
+ GridCacheAdapter<?, ?> c = kernal.internalCache(cache.name());
+
+ if (!(c instanceof GridDhtCacheAdapter))
+ break;
+
+ GridDhtCacheAdapter<?, ?> dht = (GridDhtCacheAdapter<?, ?>)c;
+
+ GridDhtPartitionFullMap partMap = dht.topology().partitionMap(true);
+
+ for (Map.Entry<UUID, GridDhtPartitionMap> e : partMap.entrySet()) {
+ log.info("Checking node: " + e.getKey());
+
+ for (Map.Entry<Integer, GridDhtPartitionState> e1 : e.getValue().entrySet()) {
+ if (e1.getValue() != GridDhtPartitionState.OWNING) {
+ log.info("Undesired state [id=" + e1.getKey() + ", state=" + e1.getValue() + ']');
+
+ partitionsExchangeFinished = false;
+
+ break;
+ }
+ }
+
+ if (!partitionsExchangeFinished)
+ break;
+ }
+
+ if (!partitionsExchangeFinished)
+ break;
+ }
+
+ if (partitionsExchangeFinished)
+ return;
+
+ Thread.sleep(100);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onException(Throwable e) {
+ // Proceess only the first exception to prevent a multiple printing of a full thread dump.
+ if (firtsExProcessed.compareAndSet(false, true)) {
+ // Debug info on current client.
+ println("Full thread dump of the current node below.");
+
+ U.dumpThreads(null);
+
+ println("");
+
+ ((IgniteMXBean)ignite()).dumpDebugInfo();
+
+ // Debug info on servers.
+ Ignite ignite = ignite();
+
+ ClusterGroup srvs = ignite.cluster().forServers();
+
+ IgniteCompute asyncCompute = ignite.compute(srvs).withAsync();
+
+ asyncCompute.broadcast(new ThreadDumpPrinterTask(ignite.cluster().localNode().id(), e));
+ asyncCompute.future().get(10_000);
+ }
+ }
+
+ /**
+ * @return Cache name.
+ */
+ protected abstract String cacheName();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<K, V> cache() {
+ return ignite().cache(cacheName());
+ }
+
+ /**
+ */
+ private static class ThreadDumpPrinterTask implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ private final UUID id;
+
+ /** */
+ private final Throwable e;
+
+ /**
+ * @param id Benchmark node id.
+ * @param e Exception.
+ */
+ ThreadDumpPrinterTask(UUID id, Throwable e) {
+ this.id = id;
+ this.e = e;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ println("Driver finished with exception [driverNodeId=" + id + ", e=" + e + "]");
+ println("Full thread dump of the current server node below.");
+
+ U.dumpThreads(null);
+
+ println("");
+
+ ((IgniteMXBean)ignite).dumpDebugInfo();
+ }
+ }
+
+ /**
+ */
+ private static class AwaitPartitionMapExchangeTask implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ try {
+ awaitPartitionMapExchange(ignite);
+ }
+ catch (Exception e) {
+ throw new IgniteException(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
new file mode 100644
index 0000000..29405de
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.yardstick.IgniteNode;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Ignite failover node.
+ */
+public class IgniteFailoverNode extends IgniteNode {
+ /** {@inheritDoc} */
+ @Override public void start(BenchmarkConfiguration cfg) throws Exception {
+ super.start(cfg);
+
+ // Put server configuration at special cache.
+ RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
+
+ List<String> jvmOpts = mxBean.getInputArguments();
+
+ StringBuilder jvmOptsStr = new StringBuilder();
+
+ for (String opt : jvmOpts)
+ jvmOptsStr.append(opt).append(' ');
+
+ cfg.customProperties().put("JVM_OPTS", jvmOptsStr.toString());
+ cfg.customProperties().put("PROPS_ENV", System.getenv("PROPS_ENV"));
+ cfg.customProperties().put("CLASSPATH", mxBean.getClassPath());
+ cfg.customProperties().put("JAVA", System.getenv("JAVA"));
+
+ IgniteCache<Integer, BenchmarkConfiguration> srvsCfgsCache = ignite().
+ getOrCreateCache(new CacheConfiguration<Integer, BenchmarkConfiguration>().setName("serversConfigs"));
+
+ srvsCfgsCache.put(cfg.memberId(), cfg);
+
+ println("Put at cache [" + cfg.memberId() + "=" + cfg + "]");
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
new file mode 100644
index 0000000..f8a1689
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalInvokeRetryBenchmark.java
@@ -0,0 +1,212 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteTransactionalInvokeRetryBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** */
+ private final ConcurrentMap<String, AtomicLong> map = new ConcurrentHashMap<>();
+
+ /** */
+ private final ReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+ /** */
+ private volatile Exception ex;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ final int timeout = args.cacheOperationTimeoutMillis();
+ final int keysCnt = args.keysCount();
+
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.cacheConsistencyCheckingPeriod() * 1000);
+
+ rwl.writeLock().lock();
+
+ try {
+ println("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Long> notEqualsCacheVals = new HashMap<>();
+ Map<String, Long> notEqualsLocMapVals = new HashMap<>();
+
+ for (int k = 0; k < args.range(); k++) {
+ if (k % 10_000 == 0)
+ println("Start validation for keys like 'key-" + k + "-*'");
+
+ for (int i = 0; i < keysCnt; i++) {
+ String key = "key-" + k + "-" + cfg.memberId() + "-" + i;
+
+ asyncCache.get(key);
+ Long cacheVal = asyncCache.<Long>future().get(timeout);
+
+ AtomicLong aVal = map.get(key);
+ Long mapVal = aVal != null ? aVal.get() : null;
+
+ if (!Objects.equals(cacheVal, mapVal)) {
+ notEqualsCacheVals.put(key, cacheVal);
+ notEqualsLocMapVals.put(key, mapVal);
+ }
+ }
+ }
+
+ assert notEqualsCacheVals.size() == notEqualsLocMapVals.size() : "Invalid state " +
+ "[cacheMapVals=" + notEqualsCacheVals + ", mapVals=" + notEqualsLocMapVals + "]";
+
+ if (!notEqualsCacheVals.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Long> eLocMap : notEqualsLocMapVals.entrySet()) {
+ String key = eLocMap.getKey();
+ Long mapVal = eLocMap.getValue();
+ Long cacheVal = notEqualsCacheVals.get(key);
+
+ println(cfg, "Got different values [key='" + key
+ + "', cacheVal=" + cacheVal + ", localMapVal=" + mapVal + "]");
+ }
+
+ println(cfg, "Local driver map contant:\n " + map);
+
+ println(cfg, "Cache content:");
+
+ for (int k2 = 0; k2 < args.range(); k2++) {
+ for (int i2 = 0; i2 < keysCnt; i2++) {
+ String key2 = "key-" + k2 + "-" + cfg.memberId() + "-" + i2;
+
+ asyncCache.get(key2);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key2 + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Cache and local map are in inconsistent state.");
+ }
+
+ println("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+ finally {
+ rwl.writeLock().unlock();
+ }
+ }
+ }
+ catch (Throwable e) {
+ ex = new Exception(e);
+
+ println("Got exception: " + e);
+
+ e.printStackTrace();
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "cache-" + cacheName() + "-validator");
+
+ thread.setDaemon(true);
+
+ thread.start();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ final String[] keys = new String[args.keysCount()];
+
+ assert keys.length > 0 : "Count of keys: " + keys.length;
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + cfg.memberId() + "-" + i;
+
+ for (String key : keys) {
+ rwl.readLock().lock();
+
+ try {
+ if (ex != null)
+ throw ex;
+
+ asyncCache.invoke(key, new IncrementCacheEntryProcessor());
+ asyncCache.future().get(args.cacheOperationTimeoutMillis());
+
+ AtomicLong prevVal = map.putIfAbsent(key, new AtomicLong(0));
+
+ if (prevVal != null)
+ prevVal.incrementAndGet();
+ }
+ finally {
+ rwl.readLock().unlock();
+ }
+ }
+
+ if (ex != null)
+ throw ex;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-invoke-retry";
+ }
+
+ /**
+ */
+ private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Long> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Long process(MutableEntry<String, Long> entry,
+ Object... arguments) throws EntryProcessorException {
+ long newVal = entry.getValue() == null ? 0 : entry.getValue() + 1;
+
+ entry.setValue(newVal);
+
+ return newVal;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
new file mode 100644
index 0000000..4cbcf67
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapInvokeRetryBenchmark.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Invoke retry failover benchmark.
+ * <p>
+ * Each client maintains a local map that it updates together with cache.
+ * Client invokes an increment closure for all generated keys and atomically increments value for corresponding
+ * keys in the local map. To validate cache contents, all writes from the client are stopped, values in
+ * the local map are compared to the values in the cache.
+ */
+public class IgniteTransactionalOffHeapInvokeRetryBenchmark extends IgniteTransactionalInvokeRetryBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-invoke-retry";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
new file mode 100644
index 0000000..7fa2d1a
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteInvokeBenchmark.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Transactional write invoke failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + 'master',
+ * 'key-' + K + '-1', 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction
+ * and randomly chooses between read and write scenarios:
+ * <ul>
+ * <li>Reads value associated with the master key and child keys. Values must be equal.</li>
+ * <li>Reads value associated with the master key, increments it by 1 and puts the value, then invokes increment
+ * closure on child keys. No validation is performed.</li>
+ * </ul>
+ */
+public class IgniteTransactionalOffHeapWriteInvokeBenchmark extends IgniteTransactionalWriteInvokeBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-write-invoke";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
new file mode 100644
index 0000000..bdecca7
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalOffHeapWriteReadBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Transactional write read failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + '-1',
+ * 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction, reads value associated with
+ * each key. Values must be equal. Client increments value by 1, commits the transaction.
+ */
+public class IgniteTransactionalOffHeapWriteReadBenchmark extends IgniteTransactionalWriteReadBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-offheap-write-read";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
new file mode 100644
index 0000000..1a8ee14
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.cache.CacheException;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Transactional write invoke failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + 'master',
+ * 'key-' + K + '-1', 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction
+ * and randomly chooses between read and write scenarios:
+ * <ul>
+ * <li>Reads value associated with the master key and child keys. Values must be equal.</li>
+ * <li>Reads value associated with the master key, increments it by 1 and puts the value, then invokes increment
+ * closure on child keys. No validation is performed.</li>
+ * </ul>
+ */
+public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ assert args.keysCount() > 0 : "Count of keys: " + args.keysCount();
+
+ final String[] keys = new String[args.keysCount()];
+
+ final String masterKey = "key-" + k + "-master";
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ final int scenario = nextRandom(2);
+
+ return doInTransaction(ignite(), new Callable<Boolean>() {
+ @Override public Boolean call() throws Exception {
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ switch (scenario) {
+ case 0: // Read scenario.
+ Map<String, Long> map = new HashMap<>();
+
+ asyncCache.get(masterKey);
+ Long cacheVal = asyncCache.<Long>future().get(timeout);
+
+ map.put(masterKey, cacheVal);
+
+ for (String key : keys) {
+ asyncCache.get(key);
+ cacheVal = asyncCache.<Long>future().get(timeout);
+
+ map.put(key, cacheVal);
+ }
+
+ Set<Long> values = new HashSet<>(map.values());
+
+ if (values.size() != 1) {
+ // Print all usefull information and finish.
+ println(cfg, "Got different values for keys [map=" + map + "]");
+
+ println(cfg, "Cache content:");
+
+ for (int k = 0; k < args.range(); k++) {
+ for (int i = 0; i < args.keysCount(); i++) {
+ String key = "key-" + k + "-" + i;
+
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Found different values for keys (see above information).");
+ }
+
+ break;
+ case 1: // Invoke scenario.
+ asyncCache.get(masterKey);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ asyncCache.put(masterKey, val == null ? 0 : val + 1);
+ asyncCache.future().get(timeout);
+
+ for (String key : keys) {
+ asyncCache.invoke(key, new IncrementCacheEntryProcessor());
+ asyncCache.future().get(timeout);
+ }
+
+ break;
+ }
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param ignite Ignite instance.
+ * @param clo Closure.
+ * @return Result of closure execution.
+ * @throws Exception
+ */
+ public static <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
+ while (true) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ T res = clo.call();
+
+ tx.commit();
+
+ return res;
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof ClusterTopologyException) {
+ ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
+
+ topEx.retryReadyFuture().get();
+ }
+ else
+ throw e;
+ }
+ catch (ClusterTopologyException e) {
+ e.retryReadyFuture().get();
+ }
+ catch (TransactionRollbackException ignore) {
+ // Safe to retry right away.
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-write-invoke";
+ }
+
+ /**
+ */
+ private static class IncrementCacheEntryProcessor implements CacheEntryProcessor<String, Long, Void> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Void process(MutableEntry<String, Long> entry,
+ Object... arguments) throws EntryProcessorException {
+ entry.setValue(entry.getValue() == null ? 0 : entry.getValue() + 1);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
new file mode 100644
index 0000000..c962749
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.transactions.Transaction;
+import org.apache.ignite.transactions.TransactionRollbackException;
+
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Transactional write read failover benchmark.
+ * <p>
+ * Each client generates a random integer K in a limited range and creates keys in the form 'key-' + K + '-1',
+ * 'key-' + K + '-2', ... Then client starts a pessimistic repeatable read transaction, reads value associated with
+ * each key. Values must be equal. Client increments value by 1, commits the transaction.
+ */
+public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstractBenchmark<String, Long> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ assert args.keysCount() > 0 : "Count of keys: " + args.keysCount();
+
+ final String[] keys = new String[args.keysCount()];
+
+ for (int i = 0; i < keys.length; i++)
+ keys[i] = "key-" + k + "-" + i;
+
+ return doInTransaction(ignite(), new Callable<Boolean>() {
+ @Override public Boolean call() throws Exception {
+ Map<String, Long> map = new HashMap<>();
+
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ for (String key : keys) {
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ map.put(key, val);
+ }
+
+ Set<Long> values = new HashSet<>(map.values());
+
+ if (values.size() != 1) {
+ // Print all usefull information and finish.
+ println(cfg, "Got different values for keys [map=" + map + "]");
+
+ println(cfg, "Cache content:");
+
+ for (int k = 0; k < args.range(); k++) {
+ for (int i = 0; i < args.keysCount(); i++) {
+ String key = "key-" + k + "-" + i;
+
+ asyncCache.get(key);
+ Long val = asyncCache.<Long>future().get(timeout);
+
+ if (val != null)
+ println(cfg, "Entry [key=" + key + ", val=" + val + "]");
+ }
+ }
+
+ throw new IllegalStateException("Found different values for keys (see above information).");
+ }
+
+ final Long oldVal = map.get(keys[0]);
+
+ final Long newVal = oldVal == null ? 0 : oldVal + 1;
+
+ for (String key : keys) {
+ asyncCache.put(key, newVal);
+ asyncCache.future().get(timeout);
+ }
+
+ return true;
+ }
+ });
+ }
+
+ /**
+ * @param ignite Ignite instance.
+ * @param clo Closure.
+ * @return Result of closure execution.
+ * @throws Exception
+ */
+ public static <T> T doInTransaction(Ignite ignite, Callable<T> clo) throws Exception {
+ while (true) {
+ try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ T res = clo.call();
+
+ tx.commit();
+
+ return res;
+ }
+ catch (CacheException e) {
+ if (e.getCause() instanceof ClusterTopologyException) {
+ ClusterTopologyException topEx = (ClusterTopologyException)e.getCause();
+
+ topEx.retryReadyFuture().get();
+ }
+ else
+ throw e;
+ }
+ catch (ClusterTopologyException e) {
+ e.retryReadyFuture().get();
+ }
+ catch (TransactionRollbackException ignore) {
+ // Safe to retry right away.
+ }
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "tx-write-read";
+ }
+}
[06/50] [abbrv] ignite git commit: ignite-1717: NPE during running
ScalarCreditRiskExample with portableMarshaller
Posted by ag...@apache.org.
ignite-1717: NPE during running ScalarCreditRiskExample with portableMarshaller
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/15da54b9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/15da54b9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/15da54b9
Branch: refs/heads/ignite-1702
Commit: 15da54b9e392791818c5419068e0761d7a78f613
Parents: 48de059
Author: Andrey Gura <ag...@gridgain.com>
Authored: Thu Oct 29 16:15:07 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Thu Oct 29 16:15:07 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableWriterExImpl.java | 66 +++++++++++---------
1 file changed, 35 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/15da54b9/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
index 1d5ca60..a43ebc3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableWriterExImpl.java
@@ -77,7 +77,7 @@ import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGIS
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID;
import static org.apache.ignite.internal.portable.GridPortableMarshaller.UUID_ARR;
- /**
+/**
* Portable writer implementation.
*/
public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx, ObjectOutput {
@@ -187,6 +187,16 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
* @throws PortableException In case of error.
*/
void marshal(Object obj, boolean detached) throws PortableException {
+ marshal(obj, detached, true);
+ }
+
+ /**
+ * @param obj Object.
+ * @param detached Detached or not.
+ * @param enableReplace Object replacing enabled flag.
+ * @throws PortableException In case of error.
+ */
+ void marshal(Object obj, boolean detached, boolean enableReplace) throws PortableException {
assert obj != null;
cls = obj.getClass();
@@ -218,11 +228,11 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
return;
}
- if (desc.getWriteReplaceMethod() != null) {
- Object replace;
+ if (enableReplace && desc.getWriteReplaceMethod() != null) {
+ Object replacedObj;
try {
- replace = desc.getWriteReplaceMethod().invoke(obj);
+ replacedObj = desc.getWriteReplaceMethod().invoke(obj);
}
catch (IllegalAccessException e) {
throw new RuntimeException(e);
@@ -234,21 +244,14 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
throw new PortableException("Failed to execute writeReplace() method on " + obj, e);
}
- if (replace == null) {
+ if (replacedObj == null) {
doWriteByte(NULL);
return;
}
- if (cls != replace.getClass()) {
- cls = replace.getClass();
-
- desc = ctx.descriptorForClass(cls);
-
- if (desc == null)
- throw new PortableException("Object is not portable: [class=" + cls + ']');
- }
+ marshal(replacedObj, detached, false);
- obj = replace;
+ return;
}
typeId = desc.typeId();
@@ -301,7 +304,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
wCtx.out.position(pos);
}
- /**
+ /**
* @param bytes Number of bytes to reserve.
* @return Offset.
*/
@@ -1740,7 +1743,7 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
return reserve(LEN_INT);
}
- /** {@inheritDoc} */
+ /** {@inheritDoc} */
@Override public void writeInt(int pos, int val) throws PortableException {
wCtx.out.writeInt(pos, val);
}
@@ -1764,27 +1767,28 @@ public class PortableWriterExImpl implements PortableWriter, PortableRawWriterEx
doWriteInt(id);
}
- /**
- * Attempts to write the object as a handle.
- *
- * @param obj Object to write.
- * @return {@code true} if the object has been written as a handle.
- */
- boolean tryWriteAsHandle(Object obj) {
- int handle = handle(obj);
+ /**
+ * Attempts to write the object as a handle.
+ *
+ * @param obj Object to write.
+ * @return {@code true} if the object has been written as a handle.
+ */
+ boolean tryWriteAsHandle(Object obj) {
+ int handle = handle(obj);
- if (handle >= 0) {
- doWriteByte(GridPortableMarshaller.HANDLE);
- doWriteInt(handle);
+ if (handle >= 0) {
+ doWriteByte(GridPortableMarshaller.HANDLE);
+ doWriteInt(handle);
- return true;
- }
+ return true;
+ }
- return false;
- }
+ return false;
+ }
/**
* Create new writer with same context.
+ *
* @param typeId type
* @return New writer.
*/
[38/50] [abbrv] ignite git commit: ignite-1226: Need to add method
that returns names of all available caches
Posted by ag...@apache.org.
ignite-1226: Need to add method that returns names of all available caches
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/47919078
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/47919078
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/47919078
Branch: refs/heads/ignite-1702
Commit: 47919078df447d7594793f2223649784fe1b8d93
Parents: 7944be8
Author: kcheng.mvp <kc...@gmail.com>
Authored: Wed Nov 4 14:57:05 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 14:57:05 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/Ignite.java | 12 +++-
.../apache/ignite/internal/IgniteKernal.java | 12 ++++
.../processors/cache/GridCacheProcessor.java | 19 ++++++
.../processors/cache/CacheNamesSelfTest.java | 69 ++++++++++++++++++++
.../ignite/testframework/junits/IgniteMock.java | 5 ++
.../junits/multijvm/IgniteProcessProxy.java | 7 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../org/apache/ignite/IgniteSpringBean.java | 10 ++-
8 files changed, 133 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index 0afccd0..fc9cf06 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -315,6 +315,16 @@ public interface Ignite extends AutoCloseable {
public <K, V> IgniteCache<K, V> cache(@Nullable String name);
/**
+ * Gets the collection of names of currently available caches.
+ *
+ * Collection may contain {@code null} as a value for a cache name. Refer to {@link CacheConfiguration#getName()}
+ * for more info.
+ *
+ * @return Collection of names of currently available caches or an empty collection if no caches are available.
+ */
+ public Collection<String> cacheNames();
+
+ /**
* Gets grid transactions facade.
*
* @return Grid transactions facade.
@@ -477,4 +487,4 @@ public interface Ignite extends AutoCloseable {
* @return Affinity.
*/
public <K> Affinity<K> affinity(String cacheName);
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 0277acc..2f80e5e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2645,6 +2645,18 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ guard();
+
+ try {
+ return ctx.cache().publicCacheNames();
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <K extends GridCacheUtilityKey, V> IgniteInternalCache<K, V> utilityCache() {
guard();
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 301e7d3..b2bb6ff 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1522,6 +1522,25 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * Gets a collection of currently started public cache names.
+ *
+ * @return Collection of currently started public cache names
+ */
+ public Collection<String> publicCacheNames() {
+ return F.viewReadOnly(registeredCaches.values(),
+ new IgniteClosure<DynamicCacheDescriptor, String>() {
+ @Override public String apply(DynamicCacheDescriptor desc) {
+ return desc.cacheConfiguration().getName();
+ }
+ },
+ new IgnitePredicate<DynamicCacheDescriptor>() {
+ @Override public boolean apply(DynamicCacheDescriptor desc) {
+ return desc.started() && desc.cacheType().userCache();
+ }
+ }
+ );
+ }
+ /**
* Gets cache mode.
*
* @param cacheName Cache name to check.
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
new file mode 100644
index 0000000..6f65b16
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNamesSelfTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.Collection;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test that validates {@link Ignite#cacheNames()} implementation.
+ */
+public class CacheNamesSelfTest extends GridCommonAbstractTest {
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ CacheConfiguration cacheCfg1 = new CacheConfiguration();
+ cacheCfg1.setCacheMode(CacheMode.REPLICATED);
+ cacheCfg1.setName("replicated");
+
+ CacheConfiguration cacheCfg2 = new CacheConfiguration();
+ cacheCfg2.setCacheMode(CacheMode.PARTITIONED);
+ cacheCfg2.setName("partitioned");
+
+ CacheConfiguration cacheCfg3 = new CacheConfiguration();
+ cacheCfg3.setCacheMode(CacheMode.LOCAL);
+
+ cfg.setCacheConfiguration(cacheCfg1, cacheCfg2, cacheCfg3);
+
+ return cfg;
+ }
+
+ /**
+ * @throws Exception In case of failure.
+ */
+ public void testCacheNames() throws Exception {
+ try {
+ startGridsMultiThreaded(2);
+
+ Collection<String> names = grid(0).cacheNames();
+
+ assertEquals(3, names.size());
+
+ for (String name : names)
+ assertTrue(name == null || name.equals("replicated") || name.equals("partitioned"));
+ }
+ finally {
+ stopAllGrids();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index 964753d..bfeafdf 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -194,6 +194,11 @@ public class IgniteMock implements Ignite {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
return null;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
index aa1d470..3eb9d98 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/multijvm/IgniteProcessProxy.java
@@ -477,6 +477,11 @@ public class IgniteProcessProxy implements IgniteEx {
}
/** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ return locJvmGrid.cacheNames();
+ }
+
+ /** {@inheritDoc} */
@Override public IgniteTransactions transactions() {
throw new UnsupportedOperationException("Transactions can't be supported automatically in multi JVM mode.");
}
@@ -645,4 +650,4 @@ public class IgniteProcessProxy implements IgniteEx {
return ((IgniteEx)ignite).localNode();
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index c62a131..f6432a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -35,6 +35,7 @@ import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreMultithreadedSel
import org.apache.ignite.cache.store.jdbc.GridCacheJdbcBlobStoreSelfTest;
import org.apache.ignite.internal.processors.cache.CacheAffinityCallSelfTest;
import org.apache.ignite.internal.processors.cache.CacheFutureExceptionSelfTest;
+import org.apache.ignite.internal.processors.cache.CacheNamesSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityApiSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityMapperSelfTest;
import org.apache.ignite.internal.processors.cache.GridCacheAffinityRoutingSelfTest;
@@ -196,6 +197,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(GridCacheSwapReloadSelfTest.class);
// Common tests.
+ suite.addTestSuite(CacheNamesSelfTest.class);
suite.addTestSuite(GridCacheConcurrentMapSelfTest.class);
suite.addTestSuite(GridCacheAffinityMapperSelfTest.class);
suite.addTestSuite(CacheAffinityCallSelfTest.class);
http://git-wip-us.apache.org/repos/asf/ignite/blob/47919078/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index 42514e3..7740907 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -240,6 +240,14 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
return g.cache(name);
}
+
+ /** {@inheritDoc} */
+ @Override public Collection<String> cacheNames() {
+ assert g != null;
+
+ return g.cacheNames();
+ }
+
/** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg) {
assert g != null;
@@ -437,4 +445,4 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
cfg = g.configuration();
}
-}
\ No newline at end of file
+}
[15/50] [abbrv] ignite git commit: Merge remote-tracking branch
'apache/master'
Posted by ag...@apache.org.
Merge remote-tracking branch 'apache/master'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/747c6848
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/747c6848
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/747c6848
Branch: refs/heads/ignite-1702
Commit: 747c68488ef71b54d124a54ffdccbe4229f1d899
Parents: 4c1b9d2 195cd57
Author: ashutak <as...@gridgain.com>
Authored: Mon Nov 2 14:56:46 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Nov 2 14:56:46 2015 +0300
----------------------------------------------------------------------
.../distributed/GridCacheTxRecoveryFuture.java | 13 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 44 +--
...arOptimisticSerializableTxPrepareFuture.java | 12 +-
.../cache/transactions/IgniteTxManager.java | 4 +-
.../service/GridServiceProcessor.java | 31 +-
.../CacheSerializableTransactionsTest.java | 313 ++++++++++++-------
.../GridServiceProcessorStopSelfTest.java | 103 ++++++
.../testsuites/IgniteKernalSelfTestSuite.java | 2 +
8 files changed, 376 insertions(+), 146 deletions(-)
----------------------------------------------------------------------
[02/50] [abbrv] ignite git commit: Muted test.
Posted by ag...@apache.org.
Muted test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/9304dce2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/9304dce2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/9304dce2
Branch: refs/heads/ignite-1702
Commit: 9304dce257104c4a599a58b1ecb58acab80db6c1
Parents: d24bf49
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 29 14:31:44 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 29 14:31:44 2015 +0300
----------------------------------------------------------------------
.../GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/9304dce2/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
index 7a8cc49..e9251b6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
@@ -27,4 +27,9 @@ public class GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest extends GridCach
@Override protected NearCacheConfiguration nearConfiguration() {
return new NearCacheConfiguration();
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testIgniteCacheIterator() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+ }
+}
[37/50] [abbrv] ignite git commit: ignite-1843 Reverted forceKey
futures cancel on stop.
Posted by ag...@apache.org.
ignite-1843 Reverted forceKey futures cancel on stop.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7adfd4a5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7adfd4a5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7adfd4a5
Branch: refs/heads/ignite-1702
Commit: 7adfd4a5690c235035b776e2ec6addc92b288030
Parents: 0354db1
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 4 14:16:42 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 4 14:16:42 2015 +0300
----------------------------------------------------------------------
.../dht/preloader/GridDhtPreloader.java | 20 --------------------
1 file changed, 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7adfd4a5/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 fe85968..998c720 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
@@ -96,9 +96,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
private ConcurrentMap<AffinityTopologyVersion, GridDhtAssignmentFetchFuture> pendingAssignmentFetchFuts =
new ConcurrentHashMap8<>();
- /** Stop flag. */
- private volatile boolean stopping;
-
/** Discovery listener. */
private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -221,8 +218,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
if (log.isDebugEnabled())
log.debug("DHT rebalancer onKernalStop callback.");
- stopping = true;
-
cctx.events().removeListener(discoLsnr);
// Acquire write busy lock.
@@ -234,11 +229,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
if (demandPool != null)
demandPool.stop();
- IgniteCheckedException err = stopError();
-
- for (GridDhtForceKeysFuture fut : forceKeyFuts.values())
- fut.onDone(err);
-
top = null;
}
@@ -605,9 +595,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
*/
void addFuture(GridDhtForceKeysFuture<?, ?> fut) {
forceKeyFuts.put(fut.futureId(), fut);
-
- if (stopping)
- fut.onDone(stopError());
}
/**
@@ -619,13 +606,6 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
forceKeyFuts.remove(fut.futureId(), fut);
}
- /**
- * @return Node stop exception.
- */
- private IgniteCheckedException stopError() {
- return new IgniteCheckedException("Operation has been cancelled (cache or node is stopping).");
- }
-
/** {@inheritDoc} */
@Override public void dumpDebugInfo() {
if (!forceKeyFuts.isEmpty()) {
[34/50] [abbrv] ignite git commit: ignite-1843 Avoid discovery thread
blocking in GridJobProcessor.
Posted by ag...@apache.org.
ignite-1843 Avoid discovery thread blocking in GridJobProcessor.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0354db12
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0354db12
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0354db12
Branch: refs/heads/ignite-1702
Commit: 0354db124cbfa356d7b27556cbc53978a322f471
Parents: 2501c3a
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 4 12:52:20 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 4 12:52:20 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../affinity/GridAffinityAssignmentCache.java | 13 +++
.../cache/GridCacheAffinityManager.java | 10 ++
.../GridCachePartitionExchangeManager.java | 24 +++++
.../processors/cache/GridCachePreloader.java | 5 +
.../cache/GridCachePreloaderAdapter.java | 5 +
.../dht/preloader/GridDhtForceKeysFuture.java | 14 +++
.../dht/preloader/GridDhtPreloader.java | 37 ++++++++
.../processors/job/GridJobProcessor.java | 96 +++++++++-----------
.../GridTaskFailoverAffinityRunTest.java | 3 +
...niteCacheClientNodeChangingTopologyTest.java | 4 +-
11 files changed, 158 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5a0fe16..f75f118 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -3168,6 +3168,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
U.warn(log, "Dumping debug info for node [id=" + locNode.id() +
", name=" + ctx.gridName() +
", order=" + locNode.order() +
+ ", topVer=" + ctx.discovery().topologyVersion() +
", client=" + client +
(client && routerId != null ? ", routerId=" + routerId : "") + ']');
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
index 18776a4..8bc40cd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/affinity/GridAffinityAssignmentCache.java
@@ -41,6 +41,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheDefaultAffinityKeyMa
import org.apache.ignite.internal.processors.cache.GridCacheInternal;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
import org.jsr166.ConcurrentLinkedHashMap;
@@ -409,6 +410,18 @@ public class GridAffinityAssignmentCache {
}
/**
+ * Dumps debug information.
+ */
+ public void dumpDebugInfo() {
+ if (!readyFuts.isEmpty()) {
+ U.warn(log, "Pending affinity ready futures [cache=" + cacheName + "]:");
+
+ for (AffinityReadyFuture fut : readyFuts.values())
+ U.warn(log, ">>> " + fut);
+ }
+ }
+
+ /**
* Get cached affinity for specified topology version.
*
* @param topVer Topology version.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 5c43205..eddffea 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -384,4 +384,14 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter {
public AffinityTopologyVersion affinityTopologyVersion() {
return aff.lastVersion();
}
+
+ /**
+ * Dumps debug information.
+ */
+ public void dumpDebugInfo() {
+ GridAffinityAssignmentCache aff0 = aff;
+
+ if (aff0 != null)
+ aff0.dumpDebugInfo();
+ }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/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 adc2174..c8ee6e3 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
@@ -992,6 +992,13 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
for (GridDhtPartitionsExchangeFuture fut : exchWorker.futQ)
U.warn(log, ">>> " + fut);
+ if (!readyFuts.isEmpty()) {
+ U.warn(log, "Pending affinity ready futures:");
+
+ for (AffinityReadyFuture fut : readyFuts.values())
+ U.warn(log, ">>> " + fut);
+ }
+
ExchangeFutureSet exchFuts = this.exchFuts;
if (exchFuts != null) {
@@ -1041,6 +1048,23 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
for (GridCacheFuture<?> fut : mvcc.atomicFutures())
U.warn(log, ">>> " + fut);
}
+
+ for (GridCacheContext ctx : cctx.cacheContexts()) {
+ if (ctx.isLocal())
+ continue;
+
+ GridCacheContext ctx0 = ctx.isNear() ? ctx.near().dht().context() : ctx;
+
+ GridCachePreloader preloader = ctx0.preloader();
+
+ if (preloader != null)
+ preloader.dumpDebugInfo();
+
+ GridCacheAffinityManager affMgr = ctx0.affinity();
+
+ if (affMgr != null)
+ affMgr.dumpDebugInfo();
+ }
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/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 755958e..1edaef2 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
@@ -132,4 +132,9 @@ public interface GridCachePreloader {
* Unwinds undeploys.
*/
public void unwindUndeploys();
+
+ /**
+ * Dumps debug information.
+ */
+ public void dumpDebugInfo();
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/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 5405449..4ec6749 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
@@ -146,4 +146,9 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
@Override public void addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload) {
// No-op.
}
+
+ /** {@inheritDoc} */
+ @Override public void dumpDebugInfo() {
+ // No-op.
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
index bb78748..db0e780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.util.F0;
import org.apache.ignite.internal.util.GridLeanSet;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -394,6 +395,19 @@ public final class GridDhtForceKeysFuture<K, V> extends GridCompoundFuture<Objec
return mappings;
}
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+ @Override public String apply(IgniteInternalFuture<?> f) {
+ return f.toString();
+ }
+ });
+
+ return S.toString(GridDhtForceKeysFuture.class, this,
+ "innerFuts", futs,
+ "super", super.toString());
+ }
+
/**
* Mini-future for get operations. Mini-futures are only waiting on a single
* node as opposed to multiple nodes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/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 356a85b..fe85968 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
@@ -96,6 +96,9 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
private ConcurrentMap<AffinityTopologyVersion, GridDhtAssignmentFetchFuture> pendingAssignmentFetchFuts =
new ConcurrentHashMap8<>();
+ /** Stop flag. */
+ private volatile boolean stopping;
+
/** Discovery listener. */
private final GridLocalEventListener discoLsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -218,6 +221,8 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
if (log.isDebugEnabled())
log.debug("DHT rebalancer onKernalStop callback.");
+ stopping = true;
+
cctx.events().removeListener(discoLsnr);
// Acquire write busy lock.
@@ -229,6 +234,11 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
if (demandPool != null)
demandPool.stop();
+ IgniteCheckedException err = stopError();
+
+ for (GridDhtForceKeysFuture fut : forceKeyFuts.values())
+ fut.onDone(err);
+
top = null;
}
@@ -595,6 +605,9 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
*/
void addFuture(GridDhtForceKeysFuture<?, ?> fut) {
forceKeyFuts.put(fut.futureId(), fut);
+
+ if (stopping)
+ fut.onDone(stopError());
}
/**
@@ -607,6 +620,30 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
}
/**
+ * @return Node stop exception.
+ */
+ private IgniteCheckedException stopError() {
+ return new IgniteCheckedException("Operation has been cancelled (cache or node is stopping).");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void dumpDebugInfo() {
+ if (!forceKeyFuts.isEmpty()) {
+ U.warn(log, "Pending force key futures [cache=" + cctx.name() +"]:");
+
+ for (GridDhtForceKeysFuture fut : forceKeyFuts.values())
+ U.warn(log, ">>> " + fut);
+ }
+
+ if (!pendingAssignmentFetchFuts.isEmpty()) {
+ U.warn(log, "Pending assignment fetch futures [cache=" + cctx.name() +"]:");
+
+ for (GridDhtAssignmentFetchFuture fut : pendingAssignmentFetchFuts.values())
+ U.warn(log, ">>> " + fut);
+ }
+ }
+
+ /**
*
*/
private abstract class MessageHandler<M> implements IgniteBiInClosure<UUID, M> {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
index 4d6d0bf..20bf58c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/job/GridJobProcessor.java
@@ -202,7 +202,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
};
/** Current session. */
- private final ThreadLocal<ComputeTaskSession> currentSess = new ThreadLocal<>();
+ private final ThreadLocal<ComputeTaskSession> currSess = new ThreadLocal<>();
/**
* @param ctx Kernal context.
@@ -448,18 +448,19 @@ public class GridJobProcessor extends GridProcessorAdapter {
else if (!nodeId.equals(taskNodeId))
err = "Received job siblings response from unexpected node [taskNodeId=" + taskNodeId +
", nodeId=" + nodeId + ']';
- else
+ else {
// Sender and message type are fine.
res = (GridJobSiblingsResponse)msg;
- if (res.jobSiblings() == null) {
- try {
- res.unmarshalSiblings(marsh);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to unmarshal job siblings.", e);
+ if (res.jobSiblings() == null) {
+ try {
+ res.unmarshalSiblings(marsh);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to unmarshal job siblings.", e);
- err = e.getMessage();
+ err = e.getMessage();
+ }
}
}
@@ -830,7 +831,8 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (w == null)
throw new NoSuchElementException();
- org.apache.ignite.spi.collision.CollisionJobContext ret = new CollisionJobContext(w, false);
+ org.apache.ignite.spi.collision.CollisionJobContext ret =
+ new CollisionJobContext(w, false);
w = null;
@@ -953,16 +955,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
GridJobWorker job = null;
- rwLock.readLock();
-
- try {
- if (stopping) {
- if (log.isDebugEnabled())
- log.debug("Received job execution request while stopping this node (will ignore): " + req);
+ if (!rwLock.tryReadLock()) {
+ if (log.isDebugEnabled())
+ log.debug("Received job execution request while stopping this node (will ignore): " + req);
- return;
- }
+ return;
+ }
+ try {
long endTime = req.getCreateTime() + req.getTimeout();
// Account for overflow.
@@ -1172,7 +1172,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
* @param ses Session.
*/
public void currentTaskSession(ComputeTaskSession ses) {
- currentSess.set(ses);
+ currSess.set(ses);
}
/**
@@ -1195,7 +1195,7 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (!ctx.security().enabled())
return null;
- ComputeTaskSession ses = currentSess.get();
+ ComputeTaskSession ses = currSess.get();
if (ses == null)
return null;
@@ -1404,16 +1404,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
*/
@SuppressWarnings({"SynchronizationOnLocalVariableOrMethodParameter", "RedundantCast"})
private void processTaskSessionRequest(UUID nodeId, GridTaskSessionRequest req) {
- rwLock.readLock();
-
- try {
- if (stopping) {
- if (log.isDebugEnabled())
- log.debug("Received job session request while stopping grid (will ignore): " + req);
+ if (!rwLock.tryReadLock()) {
+ if (log.isDebugEnabled())
+ log.debug("Received job session request while stopping grid (will ignore): " + req);
- return;
- }
+ return;
+ }
+ try {
GridTaskSessionImpl ses = ctx.session().getSession(req.getSessionId());
if (ses == null) {
@@ -1557,16 +1555,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Received external collision event.");
- rwLock.readLock();
-
- try {
- if (stopping) {
- if (log.isDebugEnabled())
- log.debug("Received external collision notification while stopping grid (will ignore).");
+ if (!rwLock.tryReadLock()) {
+ if (log.isDebugEnabled())
+ log.debug("Received external collision notification while stopping grid (will ignore).");
- return;
- }
+ return;
+ }
+ try {
handleCollisions();
}
finally {
@@ -1653,16 +1649,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
updateJobMetrics();
}
else {
- rwLock.readLock();
-
- try {
- if (stopping) {
- if (log.isDebugEnabled())
- log.debug("Skipping collision handling on job finish (node is stopping).");
+ if (!rwLock.tryReadLock()) {
+ if (log.isDebugEnabled())
+ log.debug("Skipping collision handling on job finish (node is stopping).");
- return;
- }
+ return;
+ }
+ try {
handleCollisions();
}
finally {
@@ -1851,16 +1845,14 @@ public class GridJobProcessor extends GridProcessorAdapter {
}
if (handleCollisions) {
- rwLock.readLock();
-
- try {
- if (stopping) {
- if (log.isDebugEnabled())
- log.debug("Skipped collision handling on discovery event (node is stopping): " + evt);
+ if (!rwLock.tryReadLock()) {
+ if (log.isDebugEnabled())
+ log.debug("Skipped collision handling on discovery event (node is stopping): " + evt);
- return;
- }
+ return;
+ }
+ try {
if (!jobAlwaysActivate)
handleCollisions();
else if (metricsUpdateFreq > -1L)
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
index f1ae478..3b33b83 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridTaskFailoverAffinityRunTest.java
@@ -28,6 +28,7 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.lang.IgniteCallable;
import org.apache.ignite.lang.IgniteFuture;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -54,6 +55,8 @@ public class GridTaskFailoverAffinityRunTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
boolean client = clientMode && gridName.equals(getTestGridName(0));
if (client) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/0354db12/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index 8f90dbd..1e3382d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1761,7 +1761,7 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
log.error("Failed to wait for update.");
for (Ignite ignite : G.allGrids())
- dumpCacheDebugInfo(ignite);
+ ((IgniteKernal)ignite).dumpDebugInfo();
U.dumpThreads(log);
@@ -1801,7 +1801,7 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
log.error("Failed to wait for update.");
for (Ignite ignite : G.allGrids())
- dumpCacheDebugInfo(ignite);
+ ((IgniteKernal)ignite).dumpDebugInfo();
U.dumpThreads(log);
[21/50] [abbrv] ignite git commit: ignite-1698 SqlFieldsQuery works
incorrectly in case of topology changes - Fixes #178.
Posted by ag...@apache.org.
ignite-1698 SqlFieldsQuery works incorrectly in case of topology changes - Fixes #178.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/42a6390e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/42a6390e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/42a6390e
Branch: refs/heads/ignite-1702
Commit: 42a6390ebe1fb4cfa6fc8341e5b93b6bfba711c6
Parents: 8e295cc
Author: agura <ag...@gridgain.com>
Authored: Mon Nov 2 15:08:07 2015 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Tue Nov 3 01:27:17 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/processors/query/h2/IgniteH2Indexing.java | 2 +-
.../ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java | 2 --
2 files changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/42a6390e/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 8595187..4c07132 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1474,7 +1474,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
@Nullable @Override public <K, V> IgniteBiPredicate<K, V> forSpace(String spaceName) {
final GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(spaceName);
- if (cache.context().isReplicated() || (cache.configuration().getBackups() == 0 && parts == null))
+ if (cache.context().isReplicated())
return null;
final GridCacheAffinityManager aff = cache.context().affinity();
http://git-wip-us.apache.org/repos/asf/ignite/blob/42a6390e/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index 26d87a9..a8c8388 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -74,8 +74,6 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
* @throws Exception If error.
*/
public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1698");
-
startGrid(0);
createAndFillCache();
[36/50] [abbrv] ignite git commit: Renamed IgniteRddSpec to
IgniteRDDSpec
Posted by ag...@apache.org.
Renamed IgniteRddSpec to IgniteRDDSpec
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7944be8e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7944be8e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7944be8e
Branch: refs/heads/ignite-1702
Commit: 7944be8e6ad3bcad754d6e3f738ce18e6e0431c6
Parents: c66df66
Author: Stephen Boesch <ja...@gmail.com>
Authored: Wed Nov 4 13:39:09 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 13:39:09 2015 +0300
----------------------------------------------------------------------
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRDDSpec.scala | 249 +++++++++++++++++++
.../apache/ignite/spark/IgniteRddSpec1.scala | 249 -------------------
3 files changed, 250 insertions(+), 250 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
index e56558d..bef87d5 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
@@ -17,7 +17,7 @@
package org.apache.ignite.spark
-import org.apache.ignite.spark.IgniteRddSpec1.ScalarCacheQuerySqlField
+import org.apache.ignite.spark.IgniteRDDSpec.ScalarCacheQuerySqlField
class Entity (
@ScalarCacheQuerySqlField(index = true) val id: Int,
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
new file mode 100644
index 0000000..071897a
--- /dev/null
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRDDSpec.scala
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spark
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.spark.SparkContext
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+import IgniteRDDSpec._
+
+import scala.annotation.meta.field
+
+@RunWith(classOf[JUnitRunner])
+class IgniteRDDSpec extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
+ describe("IgniteRDD") {
+ it("should successfully store data to ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ () ⇒ configuration("client", client = true))
+
+ // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
+ ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ // Check cache contents.
+ val ignite = Ignition.ignite("grid-0")
+
+ for (i ← 0 to 10000) {
+ val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
+
+ assert(res != null, "Value was not put to cache for key: " + i)
+ assert("val" + i == res, "Invalid value stored for key: " + i)
+ }
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully read data from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
+
+ val num = 10000
+
+ for (i ← 0 to num) {
+ cache.put(String.valueOf(i), i)
+ }
+
+ val ic = new IgniteContext[String, Int](sc,
+ () ⇒ configuration("client", client = true))
+
+ val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
+
+ assert(res == (0 to num).sum)
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query objects from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0).id, "Invalid result")
+ assert("name50" == res(0).name, "Invalid result")
+ assert(5000 == res(0).salary)
+
+ assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query fields from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ import ic.sqlContext.implicits._
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
+
+ df.printSchema()
+
+ val res = df.collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0)(0), "Invalid result")
+ assert("name50" == res(0)(1), "Invalid result")
+ assert(5000 == res(0)(2), "Invalid result")
+
+ val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
+
+ val res0 = df0.collect()
+
+ assert(res0.length == 1, "Invalid result length")
+ assert(50 == res0(0)(0), "Invalid result")
+ assert("name50" == res0(0)(1), "Invalid result")
+ assert(5000 == res0(0)(2), "Invalid result")
+
+ assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully start spark context with XML configuration") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ "modules/core/src/test/config/spark/spark-config.xml")
+
+ val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ assert(1000 == cache.count())
+ }
+ finally {
+ sc.stop()
+ }
+ }
+ }
+
+ override protected def beforeEach() = {
+ Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
+ }
+
+ override protected def afterEach() = {
+ Ignition.stop("client", false)
+ }
+
+ override protected def beforeAll() = {
+ for (i ← 0 to 3) {
+ Ignition.start(configuration("grid-" + i, client = false))
+ }
+ }
+
+ override protected def afterAll() = {
+ for (i ← 0 to 3) {
+ Ignition.stop("grid-" + i, false)
+ }
+ }
+}
+
+/**
+ * Constants and utility methods.
+ */
+object IgniteRDDSpec {
+ /** IP finder for the test. */
+ val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
+
+ /** Partitioned cache name. */
+ val PARTITIONED_CACHE_NAME = "partitioned"
+
+ /** Type alias for `QuerySqlField`. */
+ type ScalarCacheQuerySqlField = QuerySqlField @field
+
+ /** Type alias for `QueryTextField`. */
+ type ScalarCacheQueryTextField = QueryTextField @field
+
+ /**
+ * Gets ignite configuration.
+ *
+ * @param gridName Grid name.
+ * @param client Client mode flag.
+ * @return Ignite configuration.
+ */
+ def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ val discoSpi = new TcpDiscoverySpi
+
+ discoSpi.setIpFinder(IgniteRDDSpec.IP_FINDER)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName))
+
+ cfg.setClientMode(client)
+
+ cfg.setGridName(gridName)
+
+ cfg
+ }
+
+ /**
+ * Gets cache configuration for the given grid name.
+ *
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
+ val ccfg = new CacheConfiguration[Object, Object]()
+
+ ccfg.setBackups(1)
+
+ ccfg.setName(PARTITIONED_CACHE_NAME)
+
+ ccfg.setIndexedTypes(classOf[String], classOf[Entity])
+
+ ccfg
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7944be8e/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
deleted file mode 100644
index 3ef3225..0000000
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
+++ /dev/null
@@ -1,249 +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.spark
-
-import org.apache.ignite.Ignition
-import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
-import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
-import org.apache.spark.SparkContext
-import org.junit.runner.RunWith
-import org.scalatest._
-import org.scalatest.junit.JUnitRunner
-
-import IgniteRddSpec1._
-
-import scala.annotation.meta.field
-
-@RunWith(classOf[JUnitRunner])
-class IgniteRddSpec1 extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
- describe("IgniteRDD") {
- it("should successfully store data to ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- () ⇒ configuration("client", client = true))
-
- // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
- ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- // Check cache contents.
- val ignite = Ignition.ignite("grid-0")
-
- for (i ← 0 to 10000) {
- val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
-
- assert(res != null, "Value was not put to cache for key: " + i)
- assert("val" + i == res, "Invalid value stored for key: " + i)
- }
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully read data from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
-
- val num = 10000
-
- for (i ← 0 to num) {
- cache.put(String.valueOf(i), i)
- }
-
- val ic = new IgniteContext[String, Int](sc,
- () ⇒ configuration("client", client = true))
-
- val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
-
- assert(res == (0 to num).sum)
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query objects from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0).id, "Invalid result")
- assert("name50" == res(0).name, "Invalid result")
- assert(5000 == res(0).salary)
-
- assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query fields from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- import ic.sqlContext.implicits._
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
-
- df.printSchema()
-
- val res = df.collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0)(0), "Invalid result")
- assert("name50" == res(0)(1), "Invalid result")
- assert(5000 == res(0)(2), "Invalid result")
-
- val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
-
- val res0 = df0.collect()
-
- assert(res0.length == 1, "Invalid result length")
- assert(50 == res0(0)(0), "Invalid result")
- assert("name50" == res0(0)(1), "Invalid result")
- assert(5000 == res0(0)(2), "Invalid result")
-
- assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully start spark context with XML configuration") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- "modules/core/src/test/config/spark/spark-config.xml")
-
- val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- assert(1000 == cache.count())
- }
- finally {
- sc.stop()
- }
- }
- }
-
- override protected def beforeEach() = {
- Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
- }
-
- override protected def afterEach() = {
- Ignition.stop("client", false)
- }
-
- override protected def beforeAll() = {
- for (i ← 0 to 3) {
- Ignition.start(configuration("grid-" + i, client = false))
- }
- }
-
- override protected def afterAll() = {
- for (i ← 0 to 3) {
- Ignition.stop("grid-" + i, false)
- }
- }
-}
-
-/**
- * Constants and utility methods.
- */
-object IgniteRddSpec1 {
- /** IP finder for the test. */
- val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
-
- /** Partitioned cache name. */
- val PARTITIONED_CACHE_NAME = "partitioned"
-
- /** Type alias for `QuerySqlField`. */
- type ScalarCacheQuerySqlField = QuerySqlField @field
-
- /** Type alias for `QueryTextField`. */
- type ScalarCacheQueryTextField = QueryTextField @field
-
- /**
- * Gets ignite configuration.
- *
- * @param gridName Grid name.
- * @param client Client mode flag.
- * @return Ignite configuration.
- */
- def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
- val cfg = new IgniteConfiguration
-
- val discoSpi = new TcpDiscoverySpi
-
- discoSpi.setIpFinder(IgniteRddSpec1.IP_FINDER)
-
- cfg.setDiscoverySpi(discoSpi)
-
- cfg.setCacheConfiguration(cacheConfiguration(gridName))
-
- cfg.setClientMode(client)
-
- cfg.setGridName(gridName)
-
- cfg
- }
-
- /**
- * Gets cache configuration for the given grid name.
- *
- * @param gridName Grid name.
- * @return Cache configuration.
- */
- def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
- val ccfg = new CacheConfiguration[Object, Object]()
-
- ccfg.setBackups(1)
-
- ccfg.setName(PARTITIONED_CACHE_NAME)
-
- ccfg.setIndexedTypes(classOf[String], classOf[Entity])
-
- ccfg
- }
-}
[30/50] [abbrv] ignite git commit: ignite-1153: improve stop node
message
Posted by ag...@apache.org.
ignite-1153: improve stop node message
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/51c0d805
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/51c0d805
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/51c0d805
Branch: refs/heads/ignite-1702
Commit: 51c0d8055157fedf20a28d206598c7c4c514a7f1
Parents: 2501c3a
Author: kcheng.mvp <kc...@gmail.com>
Authored: Wed Nov 4 12:20:46 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:20:46 2015 +0300
----------------------------------------------------------------------
.../java/org/apache/ignite/internal/IgniteKernal.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/51c0d805/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 5a0fe16..0277acc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -641,7 +641,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Catch generic throwable to secure against user assertions.
catch (Throwable e) {
U.error(log, "Failed to notify lifecycle bean (safely ignored) [evt=" + evt +
- ", gridName=" + gridName + ']', e);
+ (gridName == null ? "" : ", gridName=" + gridName) + ']', e);
if (e instanceof Error)
throw (Error)e;
@@ -1673,7 +1673,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
">>> CPU(s): " + locNode.metrics().getTotalCpus() + NL +
">>> Heap: " + U.heapSize(locNode, 2) + "GB" + NL +
">>> VM name: " + rtBean.getName() + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Local node [" +
"ID=" + locNode.id().toString().toUpperCase() +
", order=" + locNode.order() + ", clientMode=" + ctx.clientNode() +
@@ -1939,11 +1939,13 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
// Ack stop.
if (log.isQuiet()) {
+ String nodeName = gridName == null ? "" : "name=" + gridName + ", ";
+
if (!errOnStop)
- U.quiet(false, "Ignite node stopped OK [uptime=" +
+ U.quiet(false, "Ignite node stopped OK [" + nodeName + "uptime=" +
X.timeSpan2HMSM(U.currentTimeMillis() - startTime) + ']');
else
- U.quiet(true, "Ignite node stopped wih ERRORS [uptime=" +
+ U.quiet(true, "Ignite node stopped wih ERRORS [" + nodeName + "uptime=" +
X.timeSpan2HMSM(U.currentTimeMillis() - startTime) + ']');
}
@@ -1958,7 +1960,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
">>> " + dash + NL +
">>> " + ack + NL +
">>> " + dash + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Grid uptime: " + X.timeSpan2HMSM(U.currentTimeMillis() - startTime) +
NL +
NL);
@@ -1972,7 +1974,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
log.info(NL + NL +
">>> " + ack + NL +
">>> " + dash + NL +
- ">>> Grid name: " + gridName + NL +
+ (gridName == null ? "" : ">>> Grid name: " + gridName + NL) +
">>> Grid uptime: " + X.timeSpan2HMSM(U.currentTimeMillis() - startTime) +
NL +
">>> See log above for detailed error message." + NL +
[45/50] [abbrv] ignite git commit: Ignite-1093 "Rebalancing with
default parameters is very slow" fixes.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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
new file mode 100644
index 0000000..865bad8
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -0,0 +1,1034 @@
+/*
+ * 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.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryInfoCollectSwapListener;
+import org.apache.ignite.internal.processors.cache.GridCacheSwapEntry;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
+import org.apache.ignite.internal.util.lang.GridCloseableIterator;
+import org.apache.ignite.internal.util.typedef.CI2;
+import org.apache.ignite.internal.util.typedef.T3;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.spi.IgniteSpiException;
+
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
+
+/**
+ * Thread pool for supplying partitions to demanding nodes.
+ */
+class GridDhtPartitionSupplier {
+ /** */
+ private final GridCacheContext<?, ?> cctx;
+
+ /** */
+ private final IgniteLogger log;
+
+ /** */
+ private GridDhtPartitionTopology top;
+
+ /** */
+ private final boolean depEnabled;
+
+ /** Preload predicate. */
+ private IgnitePredicate<GridCacheEntryInfo> preloadPred;
+
+ /** Supply context map. T2: nodeId, idx, topVer. */
+ private final Map<T3<UUID, Integer, AffinityTopologyVersion>, SupplyContext> scMap = new HashMap<>();
+
+ /**
+ * @param cctx Cache context.
+ */
+ GridDhtPartitionSupplier(GridCacheContext<?, ?> cctx) {
+ assert cctx != null;
+
+ this.cctx = cctx;
+
+ log = cctx.logger(getClass());
+
+ top = cctx.dht().topology();
+
+ depEnabled = cctx.gridDeploy().enabled();
+ }
+
+ /**
+ *
+ */
+ void start() {
+ startOldListeners();
+ }
+
+ /**
+ *
+ */
+ void stop() {
+ synchronized (scMap) {
+ Iterator<T3<UUID, Integer, AffinityTopologyVersion>> it = scMap.keySet().iterator();
+
+ while (it.hasNext()) {
+ T3<UUID, Integer, AffinityTopologyVersion> t = it.next();
+
+ clearContext(scMap.get(t), log);
+
+ it.remove();
+ }
+ }
+
+ stopOldListeners();
+ }
+
+ /**
+ * Clear context.
+ *
+ * @param sc Supply context.
+ * @param log Logger.
+ * @return true in case context was removed.
+ */
+ private static void clearContext(
+ final SupplyContext sc,
+ final IgniteLogger log) {
+ if (sc != null) {
+ final Iterator it = sc.entryIt;
+
+ if (it != null && it instanceof GridCloseableIterator && !((GridCloseableIterator)it).isClosed()) {
+ try {
+ ((GridCloseableIterator)it).close();
+ }
+ catch (IgniteCheckedException e) {
+ log.error("Iterator close failed.", e);
+ }
+ }
+
+ final GridDhtLocalPartition loc = sc.loc;
+
+ if (loc != null) {
+ assert loc.reservations() > 0;
+
+ loc.release();
+ }
+ }
+ }
+
+ /**
+ * Handles new topology.
+ *
+ * @param topVer Topology version.
+ */
+ public void onTopologyChanged(AffinityTopologyVersion topVer) {
+ synchronized (scMap) {
+ Iterator<T3<UUID, Integer, AffinityTopologyVersion>> it = scMap.keySet().iterator();
+
+ while (it.hasNext()) {
+ T3<UUID, Integer, AffinityTopologyVersion> t = it.next();
+
+ if (topVer.compareTo(t.get3()) > 0) {// Clear all obsolete contexts.
+ clearContext(scMap.get(t), log);
+
+ it.remove();
+
+ if (log.isDebugEnabled())
+ log.debug("Supply context removed [node=" + t.get1() + "]");
+ }
+ }
+ }
+ }
+
+ /**
+ * Sets preload predicate for supply pool.
+ *
+ * @param preloadPred Preload predicate.
+ */
+ void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred) {
+ this.preloadPred = preloadPred;
+ }
+
+ /**
+ * @param d Demand message.
+ * @param idx Index.
+ * @param id Node uuid.
+ */
+ public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d) {
+ assert d != null;
+ assert id != null;
+
+ AffinityTopologyVersion cutTop = cctx.affinity().affinityTopologyVersion();
+ AffinityTopologyVersion demTop = d.topologyVersion();
+
+ T3<UUID, Integer, AffinityTopologyVersion> scId = new T3<>(id, idx, demTop);
+
+ if (d.updateSequence() == -1) {//Demand node requested context cleanup.
+ synchronized (scMap) {
+ clearContext(scMap.remove(scId), log);
+
+ return;
+ }
+ }
+
+ if (cutTop.compareTo(demTop) > 0) {
+ if (log.isDebugEnabled())
+ log.debug("Demand request cancelled [current=" + cutTop + ", demanded=" + demTop +
+ ", from=" + id + ", idx=" + idx + "]");
+
+ return;
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Demand request accepted [current=" + cutTop + ", demanded=" + demTop +
+ ", from=" + id + ", idx=" + idx + "]");
+
+ GridDhtPartitionSupplyMessageV2 s = new GridDhtPartitionSupplyMessageV2(
+ d.updateSequence(), cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
+
+ ClusterNode node = cctx.discovery().node(id);
+
+ if (node == null)
+ return; //Context will be cleaned at topology change.
+
+ try {
+ SupplyContext sctx;
+
+ synchronized (scMap) {
+ sctx = scMap.remove(scId);
+
+ assert sctx == null || d.updateSequence() == sctx.updateSeq;
+ }
+
+ // Initial demand request should contain partitions list.
+ if (sctx == null && d.partitions() == null)
+ return;
+
+ assert !(sctx != null && d.partitions() != null);
+
+ long bCnt = 0;
+
+ SupplyContextPhase phase = SupplyContextPhase.NEW;
+
+ boolean newReq = true;
+
+ long maxBatchesCnt = cctx.config().getRebalanceBatchesPrefetchCount();
+
+ if (sctx != null) {
+ phase = sctx.phase;
+
+ maxBatchesCnt = 1;
+ }
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Starting supplying rebalancing [cache=" + cctx.name() +
+ ", fromNode=" + node.id() + ", partitionsCount=" + d.partitions().size() +
+ ", topology=" + d.topologyVersion() + ", updateSeq=" + d.updateSequence() +
+ ", idx=" + idx + "]");
+ }
+
+ Iterator<Integer> partIt = sctx != null ? sctx.partIt : d.partitions().iterator();
+
+ while ((sctx != null && newReq) || partIt.hasNext()) {
+ int part = sctx != null && newReq ? sctx.part : partIt.next();
+
+ newReq = false;
+
+ GridDhtLocalPartition loc;
+
+ if (sctx != null && sctx.loc != null) {
+ loc = sctx.loc;
+
+ assert loc.reservations() > 0;
+ }
+ else {
+ 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 (phase == SupplyContextPhase.NEW && cctx.isSwapOrOffheapEnabled()) {
+ swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
+
+ cctx.swap().addOffHeapListener(part, swapLsnr);
+ cctx.swap().addSwapListener(part, swapLsnr);
+ }
+
+ boolean partMissing = false;
+
+ if (phase == SupplyContextPhase.NEW)
+ phase = SupplyContextPhase.ONHEAP;
+
+ if (phase == SupplyContextPhase.ONHEAP) {
+ Iterator<GridDhtCacheEntry> entIt = sctx != null ?
+ (Iterator<GridDhtCacheEntry>)sctx.entryIt : loc.entries().iterator();
+
+ while (entIt.hasNext()) {
+ if (!cctx.affinity().belongs(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()) {
+ if (++bCnt >= maxBatchesCnt) {
+ saveSupplyContext(scId,
+ phase,
+ partIt,
+ part,
+ entIt,
+ swapLsnr,
+ loc,
+ d.topologyVersion(),
+ d.updateSequence());
+
+ swapLsnr = null;
+ loc = null;
+
+ reply(node, d, s, scId);
+
+ return;
+ }
+ else {
+ if (!reply(node, d, s, scId))
+ return;
+
+ s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
+ }
+ }
+
+ GridCacheEntryEx e = entIt.next();
+
+ 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 (phase == SupplyContextPhase.ONHEAP) {
+ phase = SupplyContextPhase.SWAP;
+
+ if (sctx != null) {
+ sctx = new SupplyContext(
+ phase,
+ partIt,
+ null,
+ swapLsnr,
+ part,
+ loc,
+ d.updateSequence());
+ }
+ }
+
+ if (phase == SupplyContextPhase.SWAP && cctx.isSwapOrOffheapEnabled()) {
+ GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
+ sctx != null && sctx.entryIt != null ?
+ (GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>>)sctx.entryIt :
+ cctx.swap().iterator(part);
+
+ // Iterator may be null if space does not exist.
+ if (iter != null) {
+ boolean prepared = false;
+
+ while (iter.hasNext()) {
+ if (!cctx.affinity().belongs(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()) {
+ if (++bCnt >= maxBatchesCnt) {
+ saveSupplyContext(scId,
+ phase,
+ partIt,
+ part,
+ iter,
+ swapLsnr,
+ loc,
+ d.topologyVersion(),
+ d.updateSequence());
+
+ swapLsnr = null;
+ loc = null;
+
+ reply(node, d, s, scId);
+
+ return;
+ }
+ else {
+ if (!reply(node, d, s, scId))
+ return;
+
+ s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
+ }
+ }
+
+ Map.Entry<byte[], GridCacheSwapEntry> e = iter.next();
+
+ 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;
+ }
+ }
+ }
+
+ iter.close();
+
+ if (partMissing)
+ continue;
+ }
+ }
+
+ if (swapLsnr == null && sctx != null)
+ swapLsnr = sctx.swapLsnr;
+
+ // Stop receiving promote notifications.
+ if (swapLsnr != null) {
+ cctx.swap().removeOffHeapListener(part, swapLsnr);
+ cctx.swap().removeSwapListener(part, swapLsnr);
+ }
+
+ if (phase == SupplyContextPhase.SWAP) {
+ phase = SupplyContextPhase.EVICTED;
+
+ if (sctx != null) {
+ sctx = new SupplyContext(
+ phase,
+ partIt,
+ null,
+ null,
+ part,
+ loc,
+ d.updateSequence());
+ }
+ }
+
+ if (phase == SupplyContextPhase.EVICTED && swapLsnr != null) {
+ Collection<GridCacheEntryInfo> entries = swapLsnr.entries();
+
+ swapLsnr = null;
+
+ Iterator<GridCacheEntryInfo> lsnrIt = sctx != null && sctx.entryIt != null ?
+ (Iterator<GridCacheEntryInfo>)sctx.entryIt : entries.iterator();
+
+ while (lsnrIt.hasNext()) {
+ if (!cctx.affinity().belongs(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()) {
+ if (++bCnt >= maxBatchesCnt) {
+ saveSupplyContext(scId,
+ phase,
+ partIt,
+ part,
+ lsnrIt,
+ swapLsnr,
+ loc,
+ d.topologyVersion(),
+ d.updateSequence());
+
+ loc = null;
+
+ reply(node, d, s, scId);
+
+ return;
+ }
+ else {
+ if (!reply(node, d, s, scId))
+ return;
+
+ s = new GridDhtPartitionSupplyMessageV2(d.updateSequence(),
+ cctx.cacheId(), d.topologyVersion(), cctx.deploymentEnabled());
+ }
+ }
+
+ GridCacheEntryInfo info = lsnrIt.next();
+
+ 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);
+
+ phase = SupplyContextPhase.NEW;
+
+ sctx = null;
+ }
+ finally {
+ if (loc != null)
+ loc.release();
+
+ if (swapLsnr != null) {
+ cctx.swap().removeOffHeapListener(part, swapLsnr);
+ cctx.swap().removeSwapListener(part, swapLsnr);
+ }
+ }
+ }
+
+ reply(node, d, s, scId);
+
+ if (log.isDebugEnabled())
+ log.debug("Finished supplying rebalancing [cache=" + cctx.name() +
+ ", fromNode=" + node.id() +
+ ", topology=" + d.topologyVersion() + ", updateSeq=" + d.updateSequence() +
+ ", idx=" + idx + "]");
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to send partition supply message to node: " + id, e);
+ }
+ catch (IgniteSpiException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send message to node (current node is stopping?) [node=" + node.id() +
+ ", msg=" + e.getMessage() + ']');
+ }
+ }
+
+ /**
+ * @param n Node.
+ * @param d DemandMessage
+ * @param s Supply message.
+ * @return {@code True} if message was sent, {@code false} if recipient left grid.
+ * @throws IgniteCheckedException If failed.
+ */
+ private boolean reply(ClusterNode n,
+ GridDhtPartitionDemandMessage d,
+ GridDhtPartitionSupplyMessageV2 s,
+ T3<UUID, Integer, AffinityTopologyVersion> scId)
+ 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());
+
+ // Throttle preloading.
+ if (cctx.config().getRebalanceThrottle() > 0)
+ U.sleep(cctx.config().getRebalanceThrottle());
+
+ return true;
+ }
+ catch (ClusterTopologyCheckedException ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send partition supply message because node left grid: " + n.id());
+
+ synchronized (scMap) {
+ clearContext(scMap.remove(scId), log);
+ }
+
+ return false;
+ }
+ }
+
+ /**
+ * @param t Tuple.
+ * @param phase Phase.
+ * @param partIt Partition it.
+ * @param part Partition.
+ * @param entryIt Entry it.
+ * @param swapLsnr Swap listener.
+ */
+ private void saveSupplyContext(
+ T3<UUID, Integer, AffinityTopologyVersion> t,
+ SupplyContextPhase phase,
+ Iterator<Integer> partIt,
+ int part,
+ Iterator<?> entryIt, GridCacheEntryInfoCollectSwapListener swapLsnr,
+ GridDhtLocalPartition loc,
+ AffinityTopologyVersion topVer,
+ long updateSeq) {
+ synchronized (scMap) {
+ if (cctx.affinity().affinityTopologyVersion().equals(topVer)) {
+ assert scMap.get(t) == null;
+
+ scMap.put(t,
+ new SupplyContext(phase,
+ partIt,
+ entryIt,
+ swapLsnr,
+ part,
+ loc,
+ updateSeq));
+ }
+ else if (loc != null) {
+ assert loc.reservations() > 0;
+
+ loc.release();
+ }
+ }
+ }
+
+ /**
+ * Supply context phase.
+ */
+ private enum SupplyContextPhase {
+ NEW,
+ ONHEAP,
+ SWAP,
+ EVICTED
+ }
+
+ /**
+ * Supply context.
+ */
+ private static class SupplyContext {
+ /** Phase. */
+ private final SupplyContextPhase phase;
+
+ /** Partition iterator. */
+ private final Iterator<Integer> partIt;
+
+ /** Entry iterator. */
+ private final Iterator<?> entryIt;
+
+ /** Swap listener. */
+ private final GridCacheEntryInfoCollectSwapListener swapLsnr;
+
+ /** Partition. */
+ private final int part;
+
+ /** Local partition. */
+ private final GridDhtLocalPartition loc;
+
+ /** Update seq. */
+ private final long updateSeq;
+
+ /**
+ * @param phase Phase.
+ * @param partIt Partition iterator.
+ * @param entryIt Entry iterator.
+ * @param swapLsnr Swap listener.
+ * @param part Partition.
+ */
+ public SupplyContext(SupplyContextPhase phase,
+ Iterator<Integer> partIt,
+ Iterator<?> entryIt,
+ GridCacheEntryInfoCollectSwapListener swapLsnr,
+ int part,
+ GridDhtLocalPartition loc,
+ long updateSeq) {
+ this.phase = phase;
+ this.partIt = partIt;
+ this.entryIt = entryIt;
+ this.swapLsnr = swapLsnr;
+ this.part = part;
+ this.loc = loc;
+ this.updateSeq = updateSeq;
+ }
+ }
+
+ @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);
+
+ 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.entries()) {
+ if (!cctx.affinity().belongs(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().belongs(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().belongs(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.
+ */
+ public void dumpDebugInfo() {
+ synchronized (scMap) {
+ if (!scMap.isEmpty()) {
+ U.warn(log, "Rebalancing supplier reserved following partitions:");
+
+ for (SupplyContext sc : scMap.values()) {
+ if (sc.loc != null)
+ U.warn(log, ">>> " + sc.loc);
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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
new file mode 100644
index 0000000..41454f9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessageV2.java
@@ -0,0 +1,380 @@
+/*
+ * 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 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 byte 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/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
deleted file mode 100644
index 28a73b1..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
+++ /dev/null
@@ -1,555 +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.util.Collection;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingDeque;
-import java.util.concurrent.locks.ReadWriteLock;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cluster.ClusterNode;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
-import org.apache.ignite.internal.managers.deployment.GridDeploymentInfo;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
-import org.apache.ignite.internal.processors.cache.GridCacheEntryInfoCollectSwapListener;
-import org.apache.ignite.internal.processors.cache.GridCacheSwapEntry;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
-import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
-import org.apache.ignite.internal.util.lang.GridCloseableIterator;
-import org.apache.ignite.internal.util.typedef.CI2;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.internal.util.worker.GridWorker;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.thread.IgniteThread;
-import org.jetbrains.annotations.Nullable;
-
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.OWNING;
-
-/**
- * Thread pool for supplying partitions to demanding nodes.
- */
-class GridDhtPartitionSupplyPool {
- /** */
- private final GridCacheContext<?, ?> cctx;
-
- /** */
- private final IgniteLogger log;
-
- /** */
- private final ReadWriteLock busyLock;
-
- /** */
- private GridDhtPartitionTopology top;
-
- /** */
- private final Collection<SupplyWorker> workers = new LinkedList<>();
-
- /** */
- private final BlockingQueue<DemandMessage> queue = new LinkedBlockingDeque<>();
-
- /** */
- private final boolean depEnabled;
-
- /** Preload predicate. */
- private IgnitePredicate<GridCacheEntryInfo> preloadPred;
-
- /**
- * @param cctx Cache context.
- * @param busyLock Shutdown lock.
- */
- GridDhtPartitionSupplyPool(GridCacheContext<?, ?> cctx, ReadWriteLock busyLock) {
- assert cctx != null;
- assert busyLock != null;
-
- this.cctx = cctx;
- this.busyLock = busyLock;
-
- log = cctx.logger(getClass());
-
- top = cctx.dht().topology();
-
- if (!cctx.kernalContext().clientNode()) {
- int poolSize = cctx.rebalanceEnabled() ? cctx.config().getRebalanceThreadPoolSize() : 0;
-
- for (int i = 0; i < poolSize; i++)
- workers.add(new SupplyWorker());
-
- cctx.io().addHandler(cctx.cacheId(), GridDhtPartitionDemandMessage.class, new CI2<UUID, GridDhtPartitionDemandMessage>() {
- @Override public void apply(UUID id, GridDhtPartitionDemandMessage m) {
- processDemandMessage(id, m);
- }
- });
- }
-
- depEnabled = cctx.gridDeploy().enabled();
- }
-
- /**
- *
- */
- void start() {
- for (SupplyWorker w : workers)
- new IgniteThread(cctx.gridName(), "preloader-supply-worker", w).start();
- }
-
- /**
- *
- */
- void stop() {
- U.cancel(workers);
- U.join(workers, log);
-
- top = null;
- }
-
- /**
- * Sets preload predicate for supply pool.
- *
- * @param preloadPred Preload predicate.
- */
- void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred) {
- this.preloadPred = preloadPred;
- }
-
- /**
- * @return Size of this thread pool.
- */
- int poolSize() {
- return cctx.config().getRebalanceThreadPoolSize();
- }
-
- /**
- * @return {@code true} if entered to busy state.
- */
- private boolean enterBusy() {
- if (busyLock.readLock().tryLock())
- return true;
-
- if (log.isDebugEnabled())
- log.debug("Failed to enter to busy state (supplier is stopping): " + cctx.nodeId());
-
- return false;
- }
-
- /**
- * @param nodeId Sender node ID.
- * @param d Message.
- */
- private void processDemandMessage(UUID nodeId, GridDhtPartitionDemandMessage d) {
- if (!enterBusy())
- return;
-
- try {
- if (cctx.rebalanceEnabled()) {
- if (log.isDebugEnabled())
- log.debug("Received partition demand [node=" + nodeId + ", demand=" + d + ']');
-
- queue.offer(new DemandMessage(nodeId, d));
- }
- else
- U.warn(log, "Received partition demand message when rebalancing is disabled (will ignore): " + d);
- }
- finally {
- leaveBusy();
- }
- }
-
- /**
- *
- */
- private void leaveBusy() {
- busyLock.readLock().unlock();
- }
-
- /**
- * @param deque Deque to poll from.
- * @param w Worker.
- * @return Polled item.
- * @throws InterruptedException If interrupted.
- */
- @Nullable private <T> T poll(BlockingQueue<T> deque, GridWorker w) throws InterruptedException {
- assert w != null;
-
- // There is currently a case where {@code interrupted}
- // flag on a thread gets flipped during stop which causes the pool to hang. This check
- // will always make sure that interrupted flag gets reset before going into wait conditions.
- // The true fix should actually make sure that interrupted flag does not get reset or that
- // interrupted exception gets propagated. Until we find a real fix, this method should
- // always work to make sure that there is no hanging during stop.
- if (w.isCancelled())
- Thread.currentThread().interrupt();
-
- return deque.poll(2000, MILLISECONDS);
- }
-
- /**
- * Supply work.
- */
- private class SupplyWorker extends GridWorker {
- /** Hide worker logger and use cache logger. */
- private IgniteLogger log = GridDhtPartitionSupplyPool.this.log;
-
- /**
- * Default constructor.
- */
- private SupplyWorker() {
- super(cctx.gridName(), "preloader-supply-worker", GridDhtPartitionSupplyPool.this.log);
- }
-
- /** {@inheritDoc} */
- @Override protected void body() throws InterruptedException, IgniteInterruptedCheckedException {
- while (!isCancelled()) {
- DemandMessage msg = poll(queue, this);
-
- if (msg == null)
- continue;
-
- ClusterNode node = cctx.discovery().node(msg.senderId());
-
- if (node == null) {
- if (log.isDebugEnabled())
- log.debug("Received message from non-existing node (will ignore): " + msg);
-
- continue;
- }
-
- processMessage(msg, node);
- }
- }
-
- /**
- * @param msg Message.
- * @param node Demander.
- */
- private void processMessage(DemandMessage msg, ClusterNode node) {
- assert msg != null;
- assert node != null;
-
- GridDhtPartitionDemandMessage d = msg.message();
-
- GridDhtPartitionSupplyMessage s = new GridDhtPartitionSupplyMessage(d.workerId(),
- d.updateSequence(), cctx.cacheId(), cctx.deploymentEnabled());
-
- 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=" + msg.senderId() + ']');
-
- 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.entries()) {
- if (!cctx.affinity().belongs(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=" + msg.senderId() + ']');
-
- partMissing = true;
-
- break;
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!reply(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().belongs(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=" + msg.senderId() + ']');
-
- partMissing = true;
-
- break; // For.
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!reply(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().belongs(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=" + msg.senderId() + ']');
-
- // No need to continue iteration over swap entries.
- break;
- }
-
- if (s.messageSize() >= cctx.config().getRebalanceBatchSize()) {
- ack = true;
-
- if (!reply(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);
- }
- }
- }
-
- reply(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.
- */
- private boolean reply(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;
- }
- }
- }
-
- /**
- * Demand message wrapper.
- */
- private static class DemandMessage extends IgniteBiTuple<UUID, GridDhtPartitionDemandMessage> {
- /** */
- private static final long serialVersionUID = 0L;
-
- /**
- * @param sndId Sender ID.
- * @param msg Message.
- */
- DemandMessage(UUID sndId, GridDhtPartitionDemandMessage msg) {
- super(sndId, msg);
- }
-
- /**
- * Empty constructor required for {@link Externalizable}.
- */
- public DemandMessage() {
- // No-op.
- }
-
- /**
- * @return Sender ID.
- */
- UUID senderId() {
- return get1();
- }
-
- /**
- * @return Message.
- */
- public GridDhtPartitionDemandMessage message() {
- return get2();
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "DemandMessage [senderId=" + senderId() + ", msg=" + message() + ']';
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index cef38e8..2f2944d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -742,6 +742,8 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
// Must initialize topology after we get discovery event.
initTopology(cacheCtx);
+ cacheCtx.preloader().onTopologyChanged(exchId.topologyVersion());
+
cacheCtx.preloader().updateLastExchangeFuture(this);
}
[40/50] [abbrv] ignite git commit: Merge branch 'ignite-1.5' of
https://git-wip-us.apache.org/repos/asf/ignite into ignite-1.5
Posted by ag...@apache.org.
Merge branch 'ignite-1.5' of https://git-wip-us.apache.org/repos/asf/ignite into ignite-1.5
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2a8ff1cf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2a8ff1cf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2a8ff1cf
Branch: refs/heads/ignite-1702
Commit: 2a8ff1cf688b6efa9e2bdbfa2b6de9ab977160d7
Parents: 4791907 7adfd4a
Author: Denis Magda <dm...@gridgain.com>
Authored: Wed Nov 4 17:44:25 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 17:44:25 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 1 +
.../affinity/GridAffinityAssignmentCache.java | 13 +++
.../cache/GridCacheAffinityManager.java | 10 ++
.../GridCachePartitionExchangeManager.java | 24 +++++
.../processors/cache/GridCachePreloader.java | 5 +
.../cache/GridCachePreloaderAdapter.java | 5 +
.../dht/preloader/GridDhtForceKeysFuture.java | 14 +++
.../dht/preloader/GridDhtPreloader.java | 17 ++++
.../processors/job/GridJobProcessor.java | 96 +++++++++-----------
.../GridTaskFailoverAffinityRunTest.java | 3 +
...niteCacheClientNodeChangingTopologyTest.java | 4 +-
11 files changed, 138 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2a8ff1cf/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
[46/50] [abbrv] ignite git commit: Ignite-1093 "Rebalancing with
default parameters is very slow" fixes.
Posted by ag...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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
new file mode 100644
index 0000000..35cedf9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -0,0 +1,1389 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.locks.ReadWriteLock;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.events.DiscoveryEvent;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
+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.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryInfo;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
+import org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtInvalidPartitionException;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
+import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
+import org.apache.ignite.internal.processors.timeout.GridTimeoutObjectAdapter;
+import org.apache.ignite.internal.util.GridLeanSet;
+import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.tostring.GridToStringExclude;
+import org.apache.ignite.internal.util.tostring.GridToStringInclude;
+import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.CI2;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.LT;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgnitePredicate;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.jetbrains.annotations.Nullable;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_LOADED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_PART_LOADED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STOPPED;
+import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE;
+import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.MOVING;
+import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
+import static org.apache.ignite.internal.processors.dr.GridDrType.DR_PRELOAD;
+
+/**
+ * Thread pool for requesting partitions from other nodes and populating local cache.
+ */
+@SuppressWarnings("NonConstantFieldWithUpperCaseName")
+public class GridDhtPartitionDemander {
+ /** */
+ private final GridCacheContext<?, ?> cctx;
+
+ /** */
+ private final IgniteLogger log;
+
+ /** Preload predicate. */
+ private IgnitePredicate<GridCacheEntryInfo> preloadPred;
+
+ /** Future for preload mode {@link CacheRebalanceMode#SYNC}. */
+ @GridToStringInclude
+ private final GridFutureAdapter syncFut = new GridFutureAdapter();
+
+ /** Rebalance future. */
+ @GridToStringInclude
+ private volatile RebalanceFuture rebalanceFut;
+
+ /** Last timeout object. */
+ private AtomicReference<GridTimeoutObject> lastTimeoutObj = new AtomicReference<>();
+
+ /** Last exchange future. */
+ private volatile GridDhtPartitionsExchangeFuture lastExchangeFut;
+
+ /** Demand lock. */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private final ReadWriteLock demandLock;
+
+ /** DemandWorker index. */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private final AtomicInteger dmIdx = new AtomicInteger();
+
+ /** Cached rebalance topics. */
+ private final Map<Integer, Object> rebalanceTopics;
+
+ /**
+ * @param cctx Cctx.
+ * @param demandLock Demand lock.
+ */
+ public GridDhtPartitionDemander(GridCacheContext<?, ?> cctx, ReadWriteLock demandLock) {
+ assert cctx != null;
+
+ this.cctx = cctx;
+ this.demandLock = demandLock;
+
+ log = cctx.logger(getClass());
+
+ boolean enabled = cctx.rebalanceEnabled() && !cctx.kernalContext().clientNode();
+
+ rebalanceFut = new RebalanceFuture();//Dummy.
+
+ if (!enabled) {
+ // Calling onDone() immediately since preloading is disabled.
+ rebalanceFut.onDone(true);
+ syncFut.onDone();
+ }
+
+ Map<Integer, Object> tops = new HashMap<>();
+
+ for (int idx = 0; idx < cctx.gridConfig().getRebalanceThreadPoolSize(); idx++) {
+ tops.put(idx, GridCachePartitionExchangeManager.rebalanceTopic(idx));
+ }
+
+ rebalanceTopics = tops;
+ }
+
+ /**
+ * Start.
+ */
+ void start() {
+ // No-op.
+ }
+
+ /**
+ * Stop.
+ */
+ void stop() {
+ try {
+ rebalanceFut.cancel();
+ }
+ catch (Exception ex) {
+ rebalanceFut.onDone(false);
+ }
+
+ lastExchangeFut = null;
+
+ lastTimeoutObj.set(null);
+ }
+
+ /**
+ * @return Future for {@link CacheRebalanceMode#SYNC} mode.
+ */
+ IgniteInternalFuture<?> syncFuture() {
+ return syncFut;
+ }
+
+ /**
+ * @return Rebalance future.
+ */
+ IgniteInternalFuture<Boolean> rebalanceFuture() {
+ return rebalanceFut;
+ }
+
+ /**
+ * Sets preload predicate for demand pool.
+ *
+ * @param preloadPred Preload predicate.
+ */
+ void preloadPredicate(IgnitePredicate<GridCacheEntryInfo> preloadPred) {
+ this.preloadPred = preloadPred;
+ }
+
+ /**
+ * Force preload.
+ */
+ void forcePreload() {
+ GridTimeoutObject obj = lastTimeoutObj.getAndSet(null);
+
+ if (obj != null)
+ cctx.time().removeTimeoutObject(obj);
+
+ final GridDhtPartitionsExchangeFuture exchFut = lastExchangeFut;
+
+ if (exchFut != null) {
+ if (log.isDebugEnabled())
+ log.debug("Forcing rebalance event for future: " + exchFut);
+
+ exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+ @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> t) {
+ cctx.shared().exchange().forcePreloadExchange(exchFut);
+ }
+ });
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Ignoring force rebalance request (no topology event happened yet).");
+ }
+
+ /**
+ * @param fut Future.
+ * @return {@code True} if topology changed.
+ */
+ private boolean topologyChanged(RebalanceFuture fut) {
+ return
+ !cctx.affinity().affinityTopologyVersion().equals(fut.topologyVersion()) || // Topology already changed.
+ fut != rebalanceFut; // Same topology, but dummy exchange forced because of missing partitions.
+ }
+
+ /**
+ * @param part Partition.
+ * @param type Type.
+ * @param discoEvt Discovery event.
+ */
+ private void preloadEvent(int part, int type, DiscoveryEvent discoEvt) {
+ assert discoEvt != null;
+
+ cctx.events().addPreloadEvent(part, type, discoEvt.eventNode(), discoEvt.type(), discoEvt.timestamp());
+ }
+
+ /**
+ * @param name Cache name.
+ * @param fut Future.
+ */
+ private boolean waitForCacheRebalancing(String name, RebalanceFuture fut) throws IgniteCheckedException {
+ if (log.isDebugEnabled())
+ log.debug("Waiting for another cache to start rebalancing [cacheName=" + cctx.name() +
+ ", waitCache=" + name + ']');
+
+ RebalanceFuture wFut = (RebalanceFuture)cctx.kernalContext().cache().internalCache(name)
+ .preloader().rebalanceFuture();
+
+ if (!topologyChanged(fut) && wFut.updateSeq == fut.updateSeq) {
+ if (!wFut.get()) {
+ U.log(log, "Skipping waiting of " + name + " cache [top=" + fut.topologyVersion() +
+ "] (cache rebalanced with missed partitions)");
+
+ return false;
+ }
+
+ return true;
+ }
+ else {
+ U.log(log, "Skipping waiting of " + name + " cache [top=" + fut.topologyVersion() +
+ "] (topology already changed)");
+
+ return false;
+ }
+ }
+
+ /**
+ * @param assigns Assignments.
+ * @param force {@code True} if dummy reassign.
+ * @param caches Rebalancing of these caches will be finished before this started.
+ * @param cnt Counter.
+ * @throws IgniteCheckedException Exception
+ */
+ Callable<Boolean> addAssignments(final GridDhtPreloaderAssignments assigns, boolean force,
+ final Collection<String> caches, int cnt) {
+ if (log.isDebugEnabled())
+ log.debug("Adding partition assignments: " + assigns);
+
+ long delay = cctx.config().getRebalanceDelay();
+
+ if (delay == 0 || force) {
+ assert assigns != null;
+
+ final RebalanceFuture oldFut = rebalanceFut;
+
+ final RebalanceFuture fut = new RebalanceFuture(assigns, cctx, log, oldFut.isInitial(), cnt);
+
+ if (!oldFut.isInitial())
+ oldFut.cancel();
+ else
+ fut.listen(new CI1<IgniteInternalFuture<Boolean>>() {
+ @Override public void apply(IgniteInternalFuture<Boolean> future) {
+ oldFut.onDone(fut.result());
+ }
+ });
+
+ rebalanceFut = fut;
+
+ if (assigns.isEmpty()) {
+ fut.doneIfEmpty();
+
+ return null;
+ }
+
+ return new Callable<Boolean>() {
+ @Override public Boolean call() throws Exception {
+ for (String c : caches) {
+ if (!waitForCacheRebalancing(c, fut))
+ return false;
+ }
+
+ return requestPartitions(fut, assigns);
+ }
+ };
+ }
+ else if (delay > 0) {
+ GridTimeoutObject obj = lastTimeoutObj.get();
+
+ if (obj != null)
+ cctx.time().removeTimeoutObject(obj);
+
+ final GridDhtPartitionsExchangeFuture exchFut = lastExchangeFut;
+
+ assert exchFut != null : "Delaying rebalance process without topology event.";
+
+ obj = new GridTimeoutObjectAdapter(delay) {
+ @Override public void onTimeout() {
+ exchFut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>() {
+ @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion> f) {
+ cctx.shared().exchange().forcePreloadExchange(exchFut);
+ }
+ });
+ }
+ };
+
+ lastTimeoutObj.set(obj);
+
+ cctx.time().addTimeoutObject(obj);
+ }
+
+ return null;
+ }
+
+ /**
+ * @param fut Future.
+ */
+ private boolean requestPartitions(
+ RebalanceFuture fut,
+ GridDhtPreloaderAssignments assigns
+ ) throws IgniteCheckedException {
+ for (Map.Entry<ClusterNode, GridDhtPartitionDemandMessage> e : assigns.entrySet()) {
+ if (topologyChanged(fut))
+ return false;
+
+ final ClusterNode node = e.getKey();
+
+ GridDhtPartitionDemandMessage d = e.getValue();
+
+ fut.appendPartitions(node.id(), d.partitions());//Future preparation.
+ }
+
+ for (Map.Entry<ClusterNode, GridDhtPartitionDemandMessage> e : assigns.entrySet()) {
+ final ClusterNode node = e.getKey();
+
+ final CacheConfiguration cfg = cctx.config();
+
+ final Collection<Integer> parts = fut.remaining.get(node.id()).get2();
+
+ GridDhtPartitionDemandMessage d = e.getValue();
+
+ //Check remote node rebalancing API version.
+ if (node.version().compareTo(GridDhtPreloader.REBALANCING_VER_2_SINCE) >= 0) {
+ U.log(log, "Starting rebalancing [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
+ ", fromNode=" + node.id() + ", partitionsCount=" + parts.size() +
+ ", topology=" + fut.topologyVersion() + ", updateSeq=" + fut.updateSeq + "]");
+
+ int lsnrCnt = cctx.gridConfig().getRebalanceThreadPoolSize();
+
+ List<Set<Integer>> sParts = new ArrayList<>(lsnrCnt);
+
+ for (int cnt = 0; cnt < lsnrCnt; cnt++)
+ sParts.add(new HashSet<Integer>());
+
+ Iterator<Integer> it = parts.iterator();
+
+ int cnt = 0;
+
+ while (it.hasNext())
+ sParts.get(cnt++ % lsnrCnt).add(it.next());
+
+ for (cnt = 0; cnt < lsnrCnt; cnt++) {
+ if (!sParts.get(cnt).isEmpty()) {
+
+ // Create copy.
+ GridDhtPartitionDemandMessage initD = new GridDhtPartitionDemandMessage(d, sParts.get(cnt));
+
+ initD.topic(rebalanceTopics.get(cnt));
+ initD.updateSequence(fut.updateSeq);
+ initD.timeout(cctx.config().getRebalanceTimeout());
+
+ synchronized (fut) {
+ if (!fut.isDone())// Future can be already cancelled at this moment and all failovers happened.
+ // New requests will not be covered by failovers.
+ cctx.io().sendOrderedMessage(node,
+ rebalanceTopics.get(cnt), initD, cctx.ioPolicy(), initD.timeout());
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Requested rebalancing [from node=" + node.id() + ", listener index=" +
+ cnt + ", partitions count=" + sParts.get(cnt).size() +
+ " (" + partitionsList(sParts.get(cnt)) + ")]");
+ }
+ }
+ }
+ else {
+ U.log(log, "Starting rebalancing (old api) [cache=" + cctx.name() + ", mode=" + cfg.getRebalanceMode() +
+ ", fromNode=" + node.id() + ", partitionsCount=" + parts.size() +
+ ", topology=" + fut.topologyVersion() + ", updateSeq=" + fut.updateSeq + "]");
+
+ d.timeout(cctx.config().getRebalanceTimeout());
+ d.workerId(0);//old api support.
+
+ DemandWorker dw = new DemandWorker(dmIdx.incrementAndGet(), fut);
+
+ dw.run(node, d);
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * @param c Partitions.
+ * @return String representation of partitions list.
+ */
+ private String partitionsList(Collection<Integer> c) {
+ List<Integer> s = new ArrayList<>(c);
+
+ Collections.sort(s);
+
+ StringBuilder sb = new StringBuilder();
+
+ int start = -1;
+
+ int prev = -1;
+
+ Iterator<Integer> sit = s.iterator();
+
+ while (sit.hasNext()) {
+ int p = sit.next();
+
+ if (start == -1) {
+ start = p;
+ prev = p;
+ }
+
+ if (prev < p - 1) {
+ sb.append(start);
+
+ if (start != prev)
+ sb.append("-").append(prev);
+
+ sb.append(", ");
+
+ start = p;
+ }
+
+ if (!sit.hasNext()) {
+ sb.append(start);
+
+ if (start != p)
+ sb.append("-").append(p);
+ }
+
+ prev = p;
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * @param idx Index.
+ * @param id Node id.
+ * @param supply Supply.
+ */
+ public void handleSupplyMessage(
+ int idx,
+ final UUID id,
+ final GridDhtPartitionSupplyMessageV2 supply
+ ) {
+ AffinityTopologyVersion topVer = supply.topologyVersion();
+
+ final RebalanceFuture fut = rebalanceFut;
+
+ ClusterNode node = cctx.node(id);
+
+ if (node == null)
+ return;
+
+ if (!fut.isActual(supply.updateSequence())) // Current future have another update sequence.
+ return; // Supple message based on another future.
+
+ if (topologyChanged(fut)) // Topology already changed (for the future that supply message based on).
+ return;
+
+ if (log.isDebugEnabled())
+ log.debug("Received supply message: " + supply);
+
+ // Check whether there were class loading errors on unmarshal
+ if (supply.classError() != null) {
+ U.warn(log, "Rebalancing from node cancelled [node=" + id +
+ "]. Class got undeployed during preloading: " + supply.classError());
+
+ fut.cancel(id);
+
+ return;
+ }
+
+ final GridDhtPartitionTopology top = cctx.dht().topology();
+
+ try {
+ // Preload.
+ for (Map.Entry<Integer, CacheEntryInfoCollection> e : supply.infos().entrySet()) {
+ int p = e.getKey();
+
+ if (cctx.affinity().localNode(p, topVer)) {
+ GridDhtLocalPartition part = top.localPartition(p, topVer, true);
+
+ assert part != null;
+
+ if (part.state() == MOVING) {
+ boolean reserved = part.reserve();
+
+ assert reserved : "Failed to reserve partition [gridName=" +
+ cctx.gridName() + ", cacheName=" + cctx.namex() + ", part=" + part + ']';
+
+ part.lock();
+
+ try {
+ // Loop through all received entries and try to preload them.
+ for (GridCacheEntryInfo entry : e.getValue().infos()) {
+ if (!part.preloadingPermitted(entry.key(), entry.version())) {
+ if (log.isDebugEnabled())
+ log.debug("Preloading is not permitted for entry due to " +
+ "evictions [key=" + entry.key() +
+ ", ver=" + entry.version() + ']');
+
+ continue;
+ }
+
+ if (!preloadEntry(node, p, entry, topVer)) {
+ if (log.isDebugEnabled())
+ log.debug("Got entries for invalid partition during " +
+ "preloading (will skip) [p=" + p + ", entry=" + entry + ']');
+
+ break;
+ }
+ }
+
+ boolean last = supply.last().contains(p);
+
+ // If message was last for this partition,
+ // then we take ownership.
+ if (last) {
+ top.own(part);
+
+ fut.partitionDone(id, p);
+
+ if (log.isDebugEnabled())
+ log.debug("Finished rebalancing partition: " + part);
+ }
+ }
+ finally {
+ part.unlock();
+ part.release();
+ }
+ }
+ else {
+ fut.partitionDone(id, p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
+ }
+ }
+ else {
+ fut.partitionDone(id, p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
+ }
+ }
+
+ // Only request partitions based on latest topology version.
+ for (Integer miss : supply.missed()) {
+ if (cctx.affinity().localNode(miss, topVer))
+ fut.partitionMissed(id, miss);
+ }
+
+ for (Integer miss : supply.missed())
+ fut.partitionDone(id, miss);
+
+ GridDhtPartitionDemandMessage d = new GridDhtPartitionDemandMessage(
+ supply.updateSequence(), supply.topologyVersion(), cctx.cacheId());
+
+ d.timeout(cctx.config().getRebalanceTimeout());
+
+ d.topic(rebalanceTopics.get(idx));
+
+ if (!topologyChanged(fut) && !fut.isDone()) {
+ // Send demand message.
+ cctx.io().sendOrderedMessage(node, rebalanceTopics.get(idx),
+ d, cctx.ioPolicy(), cctx.config().getRebalanceTimeout());
+ }
+ }
+ catch (IgniteCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Node left during rebalancing [node=" + node.id() +
+ ", msg=" + e.getMessage() + ']');
+ }
+ catch (IgniteSpiException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send message to node (current node is stopping?) [node=" + node.id() +
+ ", msg=" + e.getMessage() + ']');
+ }
+ }
+
+ /**
+ * @param pick Node picked for preloading.
+ * @param p Partition.
+ * @param entry Preloaded entry.
+ * @param topVer Topology version.
+ * @return {@code False} if partition has become invalid during preloading.
+ * @throws IgniteInterruptedCheckedException If interrupted.
+ */
+ private boolean preloadEntry(
+ ClusterNode pick,
+ int p,
+ GridCacheEntryInfo entry,
+ AffinityTopologyVersion topVer
+ ) throws IgniteCheckedException {
+ try {
+ GridCacheEntryEx cached = null;
+
+ try {
+ cached = cctx.dht().entryEx(entry.key());
+
+ if (log.isDebugEnabled())
+ log.debug("Rebalancing key [key=" + entry.key() + ", part=" + p + ", node=" + pick.id() + ']');
+
+ if (cctx.dht().isIgfsDataCache() &&
+ cctx.dht().igfsDataSpaceUsed() > cctx.dht().igfsDataSpaceMax()) {
+ LT.error(log, null, "Failed to rebalance IGFS data cache (IGFS space size exceeded maximum " +
+ "value, will ignore rebalance entries)");
+
+ if (cached.markObsoleteIfEmpty(null))
+ cached.context().cache().removeIfObsolete(cached.key());
+
+ return true;
+ }
+
+ if (preloadPred == null || preloadPred.apply(entry)) {
+ if (cached.initialValue(
+ entry.value(),
+ entry.version(),
+ entry.ttl(),
+ entry.expireTime(),
+ true,
+ topVer,
+ cctx.isDrEnabled() ? DR_PRELOAD : DR_NONE
+ )) {
+ cctx.evicts().touch(cached, topVer); // Start tracking.
+
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_LOADED) && !cached.isInternal())
+ cctx.events().addEvent(cached.partition(), cached.key(), cctx.localNodeId(),
+ (IgniteUuid)null, null, EVT_CACHE_REBALANCE_OBJECT_LOADED, entry.value(), true, null,
+ false, null, null, null);
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Rebalancing entry is already in cache (will ignore) [key=" + cached.key() +
+ ", part=" + p + ']');
+ }
+ else if (log.isDebugEnabled())
+ log.debug("Rebalance predicate evaluated to false for entry (will ignore): " + entry);
+ }
+ catch (GridCacheEntryRemovedException ignored) {
+ if (log.isDebugEnabled())
+ log.debug("Entry has been concurrently removed while rebalancing (will ignore) [key=" +
+ cached.key() + ", part=" + p + ']');
+ }
+ catch (GridDhtInvalidPartitionException ignored) {
+ if (log.isDebugEnabled())
+ log.debug("Partition became invalid during rebalancing (will ignore): " + p);
+
+ return false;
+ }
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw e;
+ }
+ catch (IgniteCheckedException e) {
+ throw new IgniteCheckedException("Failed to cache rebalanced entry (will stop rebalancing) [local=" +
+ cctx.nodeId() + ", node=" + pick.id() + ", key=" + entry.key() + ", part=" + p + ']', e);
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(GridDhtPartitionDemander.class, this);
+ }
+
+ /**
+ * Sets last exchange future.
+ *
+ * @param lastFut Last future to set.
+ */
+ void updateLastExchangeFuture(GridDhtPartitionsExchangeFuture lastFut) {
+ lastExchangeFut = lastFut;
+ }
+
+ /**
+ *
+ */
+ public static class RebalanceFuture extends GridFutureAdapter<Boolean> {
+ /** */
+ private static final long serialVersionUID = 1L;
+
+ /** Should EVT_CACHE_REBALANCE_STOPPED event be sent of not. */
+ private final boolean sendStoppedEvnt;
+
+ /** */
+ private final GridCacheContext<?, ?> cctx;
+
+ /** */
+ private final IgniteLogger log;
+
+ /** Remaining. T2: startTime, partitions */
+ private final Map<UUID, T2<Long, Collection<Integer>>> remaining = new HashMap<>();
+
+ /** Missed. */
+ private final Map<UUID, Collection<Integer>> missed = new HashMap<>();
+
+ /** Exchange future. */
+ @GridToStringExclude
+ private final GridDhtPartitionsExchangeFuture exchFut;
+
+ /** Topology version. */
+ private final AffinityTopologyVersion topVer;
+
+ /** Unique (per demander) sequence id. */
+ private final long updateSeq;
+
+ /**
+ * @param assigns Assigns.
+ * @param cctx Context.
+ * @param log Logger.
+ * @param sentStopEvnt Stop event flag.
+ */
+ RebalanceFuture(GridDhtPreloaderAssignments assigns,
+ GridCacheContext<?, ?> cctx,
+ IgniteLogger log,
+ boolean sentStopEvnt,
+ long updateSeq) {
+ assert assigns != null;
+
+ this.exchFut = assigns.exchangeFuture();
+ this.topVer = assigns.topologyVersion();
+ this.cctx = cctx;
+ this.log = log;
+ this.sendStoppedEvnt = sentStopEvnt;
+ this.updateSeq = updateSeq;
+ }
+
+ /**
+ * Dummy future. Will be done by real one.
+ */
+ public RebalanceFuture() {
+ this.exchFut = null;
+ this.topVer = null;
+ this.cctx = null;
+ this.log = null;
+ this.sendStoppedEvnt = false;
+ this.updateSeq = -1;
+ }
+
+ /**
+ * @return Topology version.
+ */
+ public AffinityTopologyVersion topologyVersion() {
+ return topVer;
+ }
+
+ /**
+ * @param updateSeq Update sequence.
+ * @return true in case future created for specified updateSeq, false in other case.
+ */
+ private boolean isActual(long updateSeq) {
+ return this.updateSeq == updateSeq;
+ }
+
+ /**
+ * @return Is initial (created at demander creation).
+ */
+ private boolean isInitial() {
+ return topVer == null;
+ }
+
+ /**
+ * @param nodeId Node id.
+ * @param parts Parts.
+ */
+ private void appendPartitions(UUID nodeId, Collection<Integer> parts) {
+ synchronized (this) {
+ remaining.put(nodeId, new T2<>(U.currentTimeMillis(), parts));
+ }
+ }
+
+ /**
+ *
+ */
+ private void doneIfEmpty() {
+ synchronized (this) {
+ if (isDone())
+ return;
+
+ assert remaining.isEmpty();
+
+ if (log.isDebugEnabled())
+ log.debug("Rebalancing is not required [cache=" + cctx.name() +
+ ", topology=" + topVer + "]");
+
+ checkIsDone();
+ }
+ }
+
+ /**
+ * Cancels this future.
+ *
+ * @return {@code true}.
+ */
+ @Override public boolean cancel() {
+ synchronized (this) {
+ if (isDone())
+ return true;
+
+ U.log(log, "Cancelled rebalancing from all nodes [cache=" + cctx.name()
+ + ", topology=" + topologyVersion());
+
+ for (UUID nodeId : remaining.keySet()) {
+ cleanupRemoteContexts(nodeId);
+ }
+
+ remaining.clear();
+
+ checkIsDone(true /* cancelled */);
+ }
+
+ return true;
+ }
+
+ /**
+ * @param nodeId Node id.
+ */
+ private void cancel(UUID nodeId) {
+ synchronized (this) {
+ if (isDone())
+ return;
+
+ U.log(log, ("Cancelled rebalancing [cache=" + cctx.name() +
+ ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
+ ", time=" + (U.currentTimeMillis() - remaining.get(nodeId).get1()) + " ms]"));
+
+ cleanupRemoteContexts(nodeId);
+
+ remaining.remove(nodeId);
+
+ checkIsDone();
+ }
+
+ }
+
+ /**
+ * @param nodeId Node id.
+ * @param p P.
+ */
+ private void partitionMissed(UUID nodeId, int p) {
+ synchronized (this) {
+ if (isDone())
+ return;
+
+ if (missed.get(nodeId) == null)
+ missed.put(nodeId, new HashSet<Integer>());
+
+ missed.get(nodeId).add(p);
+ }
+ }
+
+ /**
+ * @param nodeId Node id.
+ */
+ private void cleanupRemoteContexts(UUID nodeId) {
+ ClusterNode node = cctx.discovery().node(nodeId);
+
+ if (node == null)
+ return;
+
+ //Check remote node rebalancing API version.
+ if (node.version().compareTo(GridDhtPreloader.REBALANCING_VER_2_SINCE) >= 0) {
+
+ GridDhtPartitionDemandMessage d = new GridDhtPartitionDemandMessage(
+ -1/* remove supply context signal */, this.topologyVersion(), cctx.cacheId());
+
+ d.timeout(cctx.config().getRebalanceTimeout());
+
+ try {
+ for (int idx = 0; idx < cctx.gridConfig().getRebalanceThreadPoolSize(); idx++) {
+ d.topic(GridCachePartitionExchangeManager.rebalanceTopic(idx));
+
+ cctx.io().sendOrderedMessage(node, GridCachePartitionExchangeManager.rebalanceTopic(idx),
+ d, cctx.ioPolicy(), cctx.config().getRebalanceTimeout());
+ }
+ }
+ catch (IgniteCheckedException e) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send failover context cleanup request to node");
+ }
+ }
+ }
+
+ /**
+ * @param nodeId Node id.
+ * @param p P.
+ */
+ private void partitionDone(UUID nodeId, int p) {
+ synchronized (this) {
+ if (isDone())
+ return;
+
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
+ preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
+ exchFut.discoveryEvent());
+
+ Collection<Integer> parts = remaining.get(nodeId).get2();
+
+ if (parts != null) {
+ boolean removed = parts.remove(p);
+
+ assert removed;
+
+ if (parts.isEmpty()) {
+ U.log(log, "Completed " + ((remaining.size() == 1 ? "(final) " : "") +
+ "rebalancing [cache=" + cctx.name() +
+ ", fromNode=" + nodeId + ", topology=" + topologyVersion() +
+ ", time=" + (U.currentTimeMillis() - remaining.get(nodeId).get1()) + " ms]"));
+
+ remaining.remove(nodeId);
+ }
+ }
+
+ checkIsDone();
+ }
+ }
+
+ /**
+ * @param part Partition.
+ * @param type Type.
+ * @param discoEvt Discovery event.
+ */
+ private void preloadEvent(int part, int type, DiscoveryEvent discoEvt) {
+ assert discoEvt != null;
+
+ cctx.events().addPreloadEvent(part, type, discoEvt.eventNode(), discoEvt.type(), discoEvt.timestamp());
+ }
+
+ /**
+ * @param type Type.
+ * @param discoEvt Discovery event.
+ */
+ private void preloadEvent(int type, DiscoveryEvent discoEvt) {
+ preloadEvent(-1, type, discoEvt);
+ }
+
+ /**
+ *
+ */
+ private void checkIsDone() {
+ checkIsDone(false);
+ }
+
+ /**
+ * @param cancelled Is cancelled.
+ */
+ private void checkIsDone(boolean cancelled) {
+ if (remaining.isEmpty()) {
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_STOPPED) && (!cctx.isReplicated() || sendStoppedEvnt))
+ preloadEvent(EVT_CACHE_REBALANCE_STOPPED, exchFut.discoveryEvent());
+
+ if (log.isDebugEnabled())
+ log.debug("Completed rebalance future.");
+
+ cctx.shared().exchange().scheduleResendPartitions();
+
+ Collection<Integer> m = new HashSet<>();
+
+ for (Map.Entry<UUID, Collection<Integer>> e : missed.entrySet()) {
+ if (e.getValue() != null && !e.getValue().isEmpty())
+ m.addAll(e.getValue());
+ }
+
+ if (!m.isEmpty()) {
+ U.log(log, ("Reassigning partitions that were missed: " + m));
+
+ onDone(false); //Finished but has missed partitions, will force dummy exchange
+
+ cctx.shared().exchange().forceDummyExchange(true, exchFut);
+
+ return;
+ }
+
+ if (!cancelled && !cctx.preloader().syncFuture().isDone())
+ ((GridFutureAdapter)cctx.preloader().syncFuture()).onDone();
+
+ onDone(!cancelled);
+ }
+ }
+ }
+
+ /**
+ * Supply message wrapper.
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private static class SupplyMessage {
+ /** Sender ID. */
+ private UUID sndId;
+
+ /** Supply message. */
+ private GridDhtPartitionSupplyMessage supply;
+
+ /**
+ * Dummy constructor.
+ */
+ private SupplyMessage() {
+ // No-op.
+ }
+
+ /**
+ * @param sndId Sender ID.
+ * @param supply Supply message.
+ */
+ SupplyMessage(UUID sndId, GridDhtPartitionSupplyMessage supply) {
+ this.sndId = sndId;
+ this.supply = supply;
+ }
+
+ /**
+ * @return Sender ID.
+ */
+ UUID senderId() {
+ return sndId;
+ }
+
+ /**
+ * @return Message.
+ */
+ GridDhtPartitionSupplyMessage supply() {
+ return supply;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(SupplyMessage.class, this);
+ }
+ }
+
+ /**
+ *
+ */
+ @Deprecated//Backward compatibility. To be removed in future.
+ private class DemandWorker {
+ /** Worker ID. */
+ private int id;
+
+ /** Partition-to-node assignments. */
+ private final LinkedBlockingDeque<GridDhtPreloaderAssignments> assignQ = new LinkedBlockingDeque<>();
+
+ /** Message queue. */
+ private final LinkedBlockingDeque<SupplyMessage> msgQ =
+ new LinkedBlockingDeque<>();
+
+ /** Counter. */
+ private long cntr;
+
+ /** Hide worker logger and use cache logger instead. */
+ private IgniteLogger log = GridDhtPartitionDemander.this.log;
+
+ private volatile RebalanceFuture fut;
+
+ /**
+ * @param id Worker ID.
+ */
+ private DemandWorker(int id, RebalanceFuture fut) {
+ assert id >= 0;
+
+ this.id = id;
+ this.fut = fut;
+ }
+
+ /**
+ * @param msg Message.
+ */
+ private void addMessage(SupplyMessage msg) {
+ msgQ.offer(msg);
+ }
+
+ /**
+ * @param deque Deque to poll from.
+ * @param time Time to wait.
+ * @return Polled item.
+ * @throws InterruptedException If interrupted.
+ */
+ @Nullable private <T> T poll(BlockingQueue<T> deque, long time) throws InterruptedException {
+ return deque.poll(time, MILLISECONDS);
+ }
+
+ /**
+ * @param idx Unique index for this topic.
+ * @return Topic for partition.
+ */
+ public Object topic(long idx) {
+ return TOPIC_CACHE.topic(cctx.namexx(), cctx.nodeId(), id, idx);
+ }
+
+ /**
+ * @param node Node to demand from.
+ * @param topVer Topology version.
+ * @param d Demand message.
+ * @param exchFut Exchange future.
+ * @throws InterruptedException If interrupted.
+ * @throws ClusterTopologyCheckedException If node left.
+ * @throws IgniteCheckedException If failed to send message.
+ */
+ private void demandFromNode(
+ ClusterNode node,
+ final AffinityTopologyVersion topVer,
+ GridDhtPartitionDemandMessage d,
+ GridDhtPartitionsExchangeFuture exchFut
+ ) throws InterruptedException, IgniteCheckedException {
+ GridDhtPartitionTopology top = cctx.dht().topology();
+
+ cntr++;
+
+ d.topic(topic(cntr));
+ d.workerId(id);
+
+ if (topologyChanged(fut))
+ return;
+
+ cctx.io().addOrderedHandler(d.topic(), new CI2<UUID, GridDhtPartitionSupplyMessage>() {
+ @Override public void apply(UUID nodeId, GridDhtPartitionSupplyMessage msg) {
+ addMessage(new SupplyMessage(nodeId, msg));
+ }
+ });
+
+ try {
+ boolean retry;
+
+ // DoWhile.
+ // =======
+ do {
+ retry = false;
+
+ // Create copy.
+ d = new GridDhtPartitionDemandMessage(d, fut.remaining.get(node.id()).get2());
+
+ long timeout = cctx.config().getRebalanceTimeout();
+
+ d.timeout(timeout);
+
+ if (log.isDebugEnabled())
+ log.debug("Sending demand message [node=" + node.id() + ", demand=" + d + ']');
+
+ // Send demand message.
+ cctx.io().send(node, d, cctx.ioPolicy());
+
+ // While.
+ // =====
+ while (!topologyChanged(fut)) {
+ SupplyMessage s = poll(msgQ, timeout);
+
+ // If timed out.
+ if (s == null) {
+ if (msgQ.isEmpty()) { // Safety check.
+ U.warn(log, "Timed out waiting for partitions to load, will retry in " + timeout +
+ " ms (you may need to increase 'networkTimeout' or 'rebalanceBatchSize'" +
+ " configuration properties).");
+
+ // Ordered listener was removed if timeout expired.
+ cctx.io().removeOrderedHandler(d.topic());
+
+ // Must create copy to be able to work with IO manager thread local caches.
+ d = new GridDhtPartitionDemandMessage(d, fut.remaining.get(node.id()).get2());
+
+ // Create new topic.
+ d.topic(topic(++cntr));
+
+ // Create new ordered listener.
+ cctx.io().addOrderedHandler(d.topic(),
+ new CI2<UUID, GridDhtPartitionSupplyMessage>() {
+ @Override public void apply(UUID nodeId,
+ GridDhtPartitionSupplyMessage msg) {
+ addMessage(new SupplyMessage(nodeId, msg));
+ }
+ });
+
+ // Resend message with larger timeout.
+ retry = true;
+
+ break; // While.
+ }
+ else
+ continue; // While.
+ }
+
+ // Check that message was received from expected node.
+ if (!s.senderId().equals(node.id())) {
+ U.warn(log, "Received supply message from unexpected node [expectedId=" + node.id() +
+ ", rcvdId=" + s.senderId() + ", msg=" + s + ']');
+
+ continue; // While.
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Received supply message: " + s);
+
+ GridDhtPartitionSupplyMessage supply = s.supply();
+
+ // Check whether there were class loading errors on unmarshal
+ if (supply.classError() != null) {
+ if (log.isDebugEnabled())
+ log.debug("Class got undeployed during preloading: " + supply.classError());
+
+ retry = true;
+
+ // Quit preloading.
+ break;
+ }
+
+ // Preload.
+ for (Map.Entry<Integer, CacheEntryInfoCollection> e : supply.infos().entrySet()) {
+ int p = e.getKey();
+
+ if (cctx.affinity().localNode(p, topVer)) {
+ GridDhtLocalPartition part = top.localPartition(p, topVer, true);
+
+ assert part != null;
+
+ if (part.state() == MOVING) {
+ boolean reserved = part.reserve();
+
+ assert reserved : "Failed to reserve partition [gridName=" +
+ cctx.gridName() + ", cacheName=" + cctx.namex() + ", part=" + part + ']';
+
+ part.lock();
+
+ try {
+ Collection<Integer> invalidParts = new GridLeanSet<>();
+
+ // Loop through all received entries and try to preload them.
+ for (GridCacheEntryInfo entry : e.getValue().infos()) {
+ if (!invalidParts.contains(p)) {
+ if (!part.preloadingPermitted(entry.key(), entry.version())) {
+ if (log.isDebugEnabled())
+ log.debug("Preloading is not permitted for entry due to " +
+ "evictions [key=" + entry.key() +
+ ", ver=" + entry.version() + ']');
+
+ continue;
+ }
+
+ if (!preloadEntry(node, p, entry, topVer)) {
+ invalidParts.add(p);
+
+ if (log.isDebugEnabled())
+ log.debug("Got entries for invalid partition during " +
+ "preloading (will skip) [p=" + p + ", entry=" + entry + ']');
+ }
+ }
+ }
+
+ boolean last = supply.last().contains(p);
+
+ // If message was last for this partition,
+ // then we take ownership.
+ if (last) {
+ fut.partitionDone(node.id(), p);
+
+ top.own(part);
+
+ if (log.isDebugEnabled())
+ log.debug("Finished rebalancing partition: " + part);
+
+ if (cctx.events().isRecordable(EVT_CACHE_REBALANCE_PART_LOADED))
+ preloadEvent(p, EVT_CACHE_REBALANCE_PART_LOADED,
+ exchFut.discoveryEvent());
+ }
+ }
+ finally {
+ part.unlock();
+ part.release();
+ }
+ }
+ else {
+ fut.partitionDone(node.id(), p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (state is not MOVING): " + part);
+ }
+ }
+ else {
+ fut.partitionDone(node.id(), p);
+
+ if (log.isDebugEnabled())
+ log.debug("Skipping rebalancing partition (it does not belong on current node): " + p);
+ }
+ }
+
+ // Only request partitions based on latest topology version.
+ for (Integer miss : s.supply().missed()) {
+ if (cctx.affinity().localNode(miss, topVer))
+ fut.partitionMissed(node.id(), miss);
+ }
+
+ for (Integer miss : s.supply().missed())
+ fut.partitionDone(node.id(), miss);
+
+ if (fut.remaining.get(node.id()) == null)
+ break; // While.
+
+ if (s.supply().ack()) {
+ retry = true;
+
+ break;
+ }
+ }
+ }
+ while (retry && !topologyChanged(fut));
+ }
+ finally {
+ cctx.io().removeOrderedHandler(d.topic());
+ }
+ }
+
+ /**
+ * @param node Node.
+ * @param d D.
+ */
+ public void run(ClusterNode node, GridDhtPartitionDemandMessage d) throws IgniteCheckedException {
+ demandLock.readLock().lock();
+
+ try {
+ GridDhtPartitionsExchangeFuture exchFut = fut.exchFut;
+
+ AffinityTopologyVersion topVer = fut.topVer;
+
+ try {
+ demandFromNode(node, topVer, d, exchFut);
+ }
+ catch (InterruptedException e) {
+ throw new IgniteCheckedException(e);
+ }
+ }
+ finally {
+ demandLock.readLock().unlock();
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(DemandWorker.class, this, "assignQ", assignQ, "msgQ", msgQ, "super", super.toString());
+ }
+ }
+}
[24/50] [abbrv] ignite git commit: Use GridTestSwapSpaceSpi in tests.
Posted by ag...@apache.org.
Use GridTestSwapSpaceSpi in tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6a221934
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6a221934
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6a221934
Branch: refs/heads/ignite-1702
Commit: 6a221934239220e74b683cf485fa90086130b4c0
Parents: b65fde4
Author: sboikov <sb...@gridgain.com>
Authored: Tue Nov 3 10:42:24 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Nov 3 10:42:24 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheAbstractRemoveFailureTest.java | 4 ++--
.../distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java | 4 ++--
.../distributed/dht/IgniteCachePutRetryAbstractSelfTest.java | 4 ++--
.../test/java/org/apache/ignite/testframework/GridTestUtils.java | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6a221934/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
index 5044516..6572d31 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
@@ -49,7 +49,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
@@ -102,7 +102,7 @@ public abstract class GridCacheAbstractRemoveFailureTest extends GridCommonAbstr
if (testClientNode() && getTestGridName(0).equals(gridName))
cfg.setClientMode(true);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6a221934/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
index 7fe0138..e46761b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
@@ -42,7 +42,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -92,7 +92,7 @@ public class IgniteCacheCrossCacheTxFailoverTest extends GridCommonAbstractTest
if (gridName.equals(getTestGridName(GRID_CNT - 1)))
cfg.setClientMode(true);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/6a221934/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index 76f12c4..ee28cf9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -49,7 +49,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -120,7 +120,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
cfg.setAtomicConfiguration(acfg);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6a221934/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index ea3bbe0..d1c3d9f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -88,7 +88,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.ssl.SslContextFactory;
import org.apache.ignite.testframework.config.GridTestProperties;
import org.jetbrains.annotations.NotNull;
@@ -1698,7 +1698,7 @@ public final class GridTestUtils {
ccfg.setSwapEnabled(swap);
if (swap && cfg != null)
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
if (evictionPlc) {
LruEvictionPolicy plc = new LruEvictionPolicy();
[07/50] [abbrv] ignite git commit: Muted test (IGNITE-627).
Posted by ag...@apache.org.
Muted test (IGNITE-627).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ec16c77f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ec16c77f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ec16c77f
Branch: refs/heads/ignite-1702
Commit: ec16c77f8d95e9ff58ca831d2f2115a07cce4a8b
Parents: 15da54b
Author: sboikov <sb...@gridgain.com>
Authored: Fri Oct 30 13:05:55 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Oct 30 13:05:55 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/CacheNearReaderUpdateTest.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ec16c77f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
index c2f9fab..e267620 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearReaderUpdateTest.java
@@ -122,6 +122,8 @@ public class CacheNearReaderUpdateTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testGetUpdateMultithreaded() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-627");
+
List<CacheConfiguration<Integer, Integer>> cfgs = new ArrayList<>();
cfgs.add(cacheConfiguration(PARTITIONED, FULL_SYNC, 0, false, false));
[48/50] [abbrv] ignite git commit: Ignite-1093 "Rebalancing with
default parameters is very slow" fixes.
Posted by ag...@apache.org.
Ignite-1093 "Rebalancing with default parameters is very slow" fixes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7dfaa3b0
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7dfaa3b0
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7dfaa3b0
Branch: refs/heads/ignite-1702
Commit: 7dfaa3b062d5020debb5e716395f9b5603ec07ed
Parents: 7573003
Author: Anton Vinogradov <av...@apache.org>
Authored: Thu Nov 5 16:15:34 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Thu Nov 5 20:41:17 2015 +0300
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 54 +-
.../configuration/IgniteConfiguration.java | 32 +-
.../apache/ignite/internal/IgniteKernal.java | 21 +
.../org/apache/ignite/internal/IgnitionEx.java | 3 +
.../communication/GridIoMessageFactory.java | 10 +-
.../processors/cache/GridCacheIoManager.java | 19 +-
.../processors/cache/GridCacheMapEntry.java | 38 +-
.../GridCachePartitionExchangeManager.java | 164 ++-
.../processors/cache/GridCachePreloader.java | 55 +-
.../cache/GridCachePreloaderAdapter.java | 40 +-
.../processors/cache/GridCacheProcessor.java | 55 +-
.../distributed/dht/GridDhtCacheEntry.java | 11 +-
.../distributed/dht/GridDhtLocalPartition.java | 63 +-
.../dht/GridDhtPartitionsReservation.java | 2 +-
.../GridDhtPartitionDemandMessage.java | 14 +-
.../preloader/GridDhtPartitionDemandPool.java | 1192 ---------------
.../dht/preloader/GridDhtPartitionDemander.java | 1389 ++++++++++++++++++
.../dht/preloader/GridDhtPartitionSupplier.java | 1034 +++++++++++++
.../GridDhtPartitionSupplyMessageV2.java | 380 +++++
.../preloader/GridDhtPartitionSupplyPool.java | 555 -------
.../GridDhtPartitionsExchangeFuture.java | 2 +
.../dht/preloader/GridDhtPreloader.java | 282 +++-
.../datastructures/DataStructuresProcessor.java | 3 +
.../processors/task/GridTaskWorker.java | 4 +-
.../ignite/internal/util/lang/GridTuple4.java | 2 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 2 +-
.../IgniteCacheP2pUnmarshallingErrorTest.java | 2 +-
.../dht/GridCacheTxNodeFailureSelfTest.java | 21 +-
.../GridCacheRebalancingAsyncSelfTest.java | 68 +
.../GridCacheRebalancingSyncSelfTest.java | 506 +++++++
...eRebalancingUnmarshallingFailedSelfTest.java | 147 ++
.../GridCacheReplicatedPreloadSelfTest.java | 22 +-
.../spi/discovery/tcp/TcpDiscoverySelfTest.java | 17 -
.../spi/discovery/tcp/TestTcpDiscoverySpi.java | 46 +
.../testframework/junits/GridAbstractTest.java | 3 +-
.../junits/common/GridCommonAbstractTest.java | 21 +-
.../testsuites/IgniteCacheTestSuite3.java | 4 +
.../tcp/GridOrderedMessageCancelSelfTest.java | 18 +-
38 files changed, 4309 insertions(+), 1992 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 374743f..b7276c9 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -69,11 +69,15 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private static final long serialVersionUID = 0L;
/** Default size of rebalance thread pool. */
+ @Deprecated
public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 2;
/** Default rebalance timeout (ms).*/
public static final long DFLT_REBALANCE_TIMEOUT = 10000;
+ /** Default rebalance batches prefetch count. */
+ public static final long DFLT_REBALANCE_BATCHES_PREFETCH_COUNT = 2;
+
/** Time in milliseconds to wait between rebalance messages to avoid overloading CPU. */
public static final long DFLT_REBALANCE_THROTTLE = 0;
@@ -174,6 +178,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
private String name;
/** Rebalance thread pool size. */
+ @Deprecated
private int rebalancePoolSize = DFLT_REBALANCE_THREAD_POOL_SIZE;
/** Rebalance timeout. */
@@ -254,6 +259,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Rebalance batch size. */
private int rebalanceBatchSize = DFLT_REBALANCE_BATCH_SIZE;
+ /** Rebalance batches prefetch count. */
+ private long rebalanceBatchesPrefetchCount = DFLT_REBALANCE_BATCHES_PREFETCH_COUNT;
+
/** Off-heap memory size. */
private long offHeapMaxMem = DFLT_OFFHEAP_MEMORY;
@@ -394,9 +402,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
name = cc.getName();
nearCfg = cc.getNearConfiguration();
nodeFilter = cc.getNodeFilter();
- rebalanceMode = cc.getRebalanceMode();
+ rebalanceBatchesPrefetchCount = cc.getRebalanceBatchesPrefetchCount();
rebalanceBatchSize = cc.getRebalanceBatchSize();
rebalanceDelay = cc.getRebalanceDelay();
+ rebalanceMode = cc.getRebalanceMode();
rebalanceOrder = cc.getRebalanceOrder();
rebalancePoolSize = cc.getRebalanceThreadPoolSize();
rebalanceTimeout = cc.getRebalanceTimeout();
@@ -1036,10 +1045,10 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
* {@link CacheRebalanceMode#SYNC SYNC} or {@link CacheRebalanceMode#ASYNC ASYNC} rebalance modes only.
* <p/>
* If cache rebalance order is positive, rebalancing for this cache will be started only when rebalancing for
- * all caches with smaller rebalance order (except caches with rebalance order {@code 0}) will be completed.
+ * all caches with smaller rebalance order will be completed.
* <p/>
* Note that cache with order {@code 0} does not participate in ordering. This means that cache with
- * rebalance order {@code 1} will never wait for any other caches. All caches with order {@code 0} will
+ * rebalance order {@code 0} will never wait for any other caches. All caches with order {@code 0} will
* be rebalanced right away concurrently with each other and ordered rebalance processes.
* <p/>
* If not set, cache order is 0, i.e. rebalancing is not ordered.
@@ -1088,6 +1097,35 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/**
+ * To gain better rebalancing performance supplier node can provide more than one batch at rebalancing start and
+ * provide one new to each next demand request.
+ *
+ * Gets number of batches generated by supply node at rebalancing start.
+ * Minimum is 1.
+ *
+ * @return batches count
+ */
+ public long getRebalanceBatchesPrefetchCount() {
+ return rebalanceBatchesPrefetchCount;
+ }
+
+ /**
+ * To gain better rebalancing performance supplier node can provide more than one batch at rebalancing start and
+ * provide one new to each next demand request.
+ *
+ * Sets number of batches generated by supply node at rebalancing start.
+ * Minimum is 1.
+ *
+ * @param rebalanceBatchesCnt batches count.
+ * @return {@code this} for chaining.
+ */
+ public CacheConfiguration<K, V> setRebalanceBatchesPrefetchCount(long rebalanceBatchesCnt) {
+ this.rebalanceBatchesPrefetchCount = rebalanceBatchesCnt;
+
+ return this;
+ }
+
+ /**
* Flag indicating whether Ignite should use swap storage by default. By default
* swap is disabled which is defined via {@link #DFLT_SWAP_ENABLED} constant.
*
@@ -1273,24 +1311,22 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/**
- * Gets size of rebalancing thread pool. Note that size serves as a hint and implementation
- * may create more threads for rebalancing than specified here (but never less threads).
- * <p>
- * Default value is {@link #DFLT_REBALANCE_THREAD_POOL_SIZE}.
+ * Use {@link IgniteConfiguration#getRebalanceThreadPoolSize()} instead.
*
* @return Size of rebalancing thread pool.
*/
+ @Deprecated
public int getRebalanceThreadPoolSize() {
return rebalancePoolSize;
}
/**
- * Sets size of rebalancing thread pool. Note that size serves as a hint and implementation may create more threads
- * for rebalancing than specified here (but never less threads).
+ * Use {@link IgniteConfiguration#getRebalanceThreadPoolSize()} instead.
*
* @param rebalancePoolSize Size of rebalancing thread pool.
* @return {@code this} for chaining.
*/
+ @Deprecated
public CacheConfiguration<K, V> setRebalanceThreadPoolSize(int rebalancePoolSize) {
this.rebalancePoolSize = rebalancePoolSize;
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index ecae356..9298c6d 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -149,6 +149,9 @@ public class IgniteConfiguration {
/** Default keep alive time for public thread pool. */
public static final long DFLT_PUBLIC_KEEP_ALIVE_TIME = 0;
+ /** Default limit of threads used for rebalance. */
+ public static final int DFLT_REBALANCE_THREAD_POOL_SIZE = 1;
+
/** Default max queue capacity of public thread pool. */
public static final int DFLT_PUBLIC_THREADPOOL_QUEUE_CAP = Integer.MAX_VALUE;
@@ -354,6 +357,9 @@ public class IgniteConfiguration {
/** Client mode flag. */
private Boolean clientMode;
+ /** Rebalance thread pool size. */
+ private int rebalanceThreadPoolSize = DFLT_REBALANCE_THREAD_POOL_SIZE;
+
/** Transactions configuration. */
private TransactionConfiguration txCfg = new TransactionConfiguration();
@@ -500,6 +506,7 @@ public class IgniteConfiguration {
p2pPoolSize = cfg.getPeerClassLoadingThreadPoolSize();
pluginCfgs = cfg.getPluginConfigurations();
pubPoolSize = cfg.getPublicThreadPoolSize();
+ rebalanceThreadPoolSize = cfg.getRebalanceThreadPoolSize();
segChkFreq = cfg.getSegmentCheckFrequency();
segPlc = cfg.getSegmentationPolicy();
segResolveAttempts = cfg.getSegmentationResolveAttempts();
@@ -1331,6 +1338,29 @@ public class IgniteConfiguration {
}
/**
+ * Gets Max count of threads can be used at rebalancing.
+ * Minimum is 1.
+ * @return count.
+ */
+ public int getRebalanceThreadPoolSize() {
+ return rebalanceThreadPoolSize;
+ }
+
+ /**
+ * Sets Max count of threads can be used at rebalancing.
+ *
+ * Default is {@code 1} which has minimal impact on the operation of the grid.
+ *
+ * @param size Size.
+ * @return {@code this} for chaining.
+ */
+ public IgniteConfiguration setRebalanceThreadPoolSize(int size) {
+ this.rebalanceThreadPoolSize = size;
+
+ return this;
+ }
+
+ /**
* Returns a collection of life-cycle beans. These beans will be automatically
* notified of grid life-cycle events. Use life-cycle beans whenever you
* want to perform certain logic before and after grid startup and stopping
@@ -2383,4 +2413,4 @@ public class IgniteConfiguration {
@Override public String toString() {
return S.toString(IgniteConfiguration.class, this);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 8603055..dd129da 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -735,6 +735,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
ackEnvironmentVariables();
ackCacheConfiguration();
ackP2pConfiguration();
+ ackRebalanceConfiguration();
// Run background network diagnostics.
GridDiagnostic.runBackgroundCheck(gridName, execSvc, log);
@@ -2147,6 +2148,26 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
/**
*
*/
+ private void ackRebalanceConfiguration() throws IgniteCheckedException {
+ if (cfg.getSystemThreadPoolSize() <= cfg.getRebalanceThreadPoolSize())
+ throw new IgniteCheckedException("Rebalance thread pool size exceed or equals System thread pool size. " +
+ "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start.");
+
+ if (cfg.getRebalanceThreadPoolSize() < 1)
+ throw new IgniteCheckedException("Rebalance thread pool size minimal allowed value is 1. " +
+ "Change IgniteConfiguration.rebalanceThreadPoolSize property before next start.");
+
+ for (CacheConfiguration ccfg : cfg.getCacheConfiguration()){
+ if (ccfg.getRebalanceBatchesPrefetchCount() < 1)
+ throw new IgniteCheckedException("Rebalance batches prefetch count minimal allowed value is 1. " +
+ "Change CacheConfiguration.rebalanceBatchesPrefetchCount property before next start. " +
+ "[cache="+ccfg.getName()+"]");
+ }
+ }
+
+ /**
+ *
+ */
private void ackCacheConfiguration() {
CacheConfiguration[] cacheCfgs = cfg.getCacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 02b28c5..7d2b2dc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -2035,6 +2035,7 @@ public class IgnitionEx {
cache.setAffinity(new RendezvousAffinityFunction(false, 20));
cache.setNodeFilter(CacheConfiguration.ALL_NODES);
cache.setStartSize(300);
+ cache.setRebalanceOrder(-2);//Prior to other system caches.
return cache;
}
@@ -2055,6 +2056,7 @@ public class IgnitionEx {
cache.setWriteSynchronizationMode(FULL_SYNC);
cache.setAffinity(new RendezvousAffinityFunction(false, 100));
cache.setNodeFilter(CacheConfiguration.ALL_NODES);
+ cache.setRebalanceOrder(-1);//Prior to user caches.
return cache;
}
@@ -2075,6 +2077,7 @@ public class IgnitionEx {
ccfg.setWriteSynchronizationMode(FULL_SYNC);
ccfg.setCacheMode(cfg.getCacheMode());
ccfg.setNodeFilter(CacheConfiguration.ALL_NODES);
+ ccfg.setRebalanceOrder(-1);//Prior to user caches.
if (cfg.getCacheMode() == PARTITIONED)
ccfg.setBackups(cfg.getBackups());
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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 079015c..ae8c753 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
@@ -74,6 +74,7 @@ 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;
@@ -684,7 +685,12 @@ public class GridIoMessageFactory implements MessageFactory {
break;
- // [-3..112] - this
+ case 114:
+ msg = new GridDhtPartitionSupplyMessageV2();
+
+ break;
+
+ // [-3..114] - this
// [120..123] - DR
// [-4..-22] - SQL
default:
@@ -722,4 +728,4 @@ public class GridIoMessageFactory implements MessageFactory {
CUSTOM.put(type, c);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
index 082f330..2334780 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheIoManager.java
@@ -45,7 +45,6 @@ import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNe
import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse;
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.GridDhtPartitionSupplyMessage;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetFuture;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest;
import org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse;
@@ -269,7 +268,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
unmarshall(nodeId, cacheMsg);
if (cacheMsg.classError() != null)
- processFailedMessage(nodeId, cacheMsg);
+ processFailedMessage(nodeId, cacheMsg, c);
else
processMessage(nodeId, cacheMsg, c);
}
@@ -313,7 +312,8 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
* @param msg Message.
* @throws IgniteCheckedException If failed.
*/
- private void processFailedMessage(UUID nodeId, GridCacheMessage msg) throws IgniteCheckedException {
+ private void processFailedMessage(UUID nodeId, GridCacheMessage msg, IgniteBiInClosure<UUID, GridCacheMessage> c)
+ throws IgniteCheckedException {
GridCacheContext ctx = cctx.cacheContext(msg.cacheId());
switch (msg.directType()) {
@@ -412,9 +412,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
break;
case 45: {
- GridDhtPartitionSupplyMessage req = (GridDhtPartitionSupplyMessage)msg;
-
- U.error(log, "Supply message cannot be unmarshalled.", req.classError());
+ processMessage(nodeId,msg,c);// Will be handled by Rebalance Demander.
}
break;
@@ -517,6 +515,12 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
break;
+ case 114: {
+ processMessage(nodeId,msg,c);// Will be handled by Rebalance Demander.
+ }
+
+ break;
+
default:
throw new IgniteCheckedException("Failed to send response to node. Unsupported direct type [message="
+ msg + "]");
@@ -528,8 +532,7 @@ public class GridCacheIoManager extends GridCacheSharedManagerAdapter {
* @param msg Message.
* @param c Closure.
*/
- private void processMessage(UUID nodeId, GridCacheMessage msg,
- IgniteBiInClosure<UUID, GridCacheMessage> c) {
+ private void processMessage(UUID nodeId, GridCacheMessage msg, IgniteBiInClosure<UUID, GridCacheMessage> c) {
try {
// We will not end up with storing a bunch of new UUIDs
// in each cache entry, since node ID is stored in NIO session
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 2111594..ca0995a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -456,7 +456,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (cctx.swap().offheapSwapEvict(key, entry, partition(), evictVer)) {
assert !hasValueUnlocked() : this;
- obsolete = markObsolete0(obsoleteVer, false);
+ obsolete = markObsolete0(obsoleteVer, false, null);
assert obsolete : this;
}
@@ -1364,7 +1364,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
synchronized (this) {
// If entry is still removed.
if (newVer == ver) {
- if (obsoleteVer == null || !(marked = markObsolete0(obsoleteVer, true))) {
+ if (obsoleteVer == null || !(marked = markObsolete0(obsoleteVer, true, null))) {
if (log.isDebugEnabled())
log.debug("Entry could not be marked obsolete (it is still used): " + this);
}
@@ -2481,7 +2481,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
try {
if ((!hasReaders() || readers)) {
// markObsolete will clear the value.
- if (!(marked = markObsolete0(ver, true))) {
+ if (!(marked = markObsolete0(ver, true, null))) {
if (log.isDebugEnabled())
log.debug("Entry could not be marked obsolete (it is still used): " + this);
@@ -2539,7 +2539,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
boolean obsolete;
synchronized (this) {
- obsolete = markObsolete0(ver, true);
+ obsolete = markObsolete0(ver, true, null);
}
if (obsolete)
@@ -2572,7 +2572,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
}
else
- obsolete = markObsolete0(ver, true);
+ obsolete = markObsolete0(ver, true, null);
}
}
}
@@ -2600,7 +2600,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (!this.ver.equals(ver))
return false;
- marked = markObsolete0(ver, true);
+ marked = markObsolete0(ver, true, null);
}
if (marked)
@@ -2623,9 +2623,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
*
* @param ver Version.
* @param clear {@code True} to clear.
+ * @param extras Predefined extras.
* @return {@code True} if entry is obsolete, {@code false} if entry is still used by other threads or nodes.
*/
- protected final boolean markObsolete0(GridCacheVersion ver, boolean clear) {
+ protected final boolean markObsolete0(GridCacheVersion ver, boolean clear, GridCacheObsoleteEntryExtras extras) {
assert Thread.holdsLock(this);
if (evictionDisabled()) {
@@ -2646,7 +2647,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
if (mvcc == null || mvcc.isEmpty(ver)) {
obsoleteVer = ver;
- obsoleteVersionExtras(obsoleteVer);
+ obsoleteVersionExtras(obsoleteVer, extras);
if (clear)
value(null);
@@ -2989,7 +2990,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
synchronized (this) {
if (checkExpired()) {
- rmv = markObsolete0(cctx.versions().next(this.ver), true);
+ rmv = markObsolete0(cctx.versions().next(this.ver), true, null);
return null;
}
@@ -3465,7 +3466,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
}
}
else {
- if (markObsolete0(obsoleteVer, true))
+ if (markObsolete0(obsoleteVer, true, null))
obsolete = true; // Success, will return "true".
}
}
@@ -3793,7 +3794,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
CacheObject prev = saveOldValueUnlocked(false);
- if (!hasReaders() && markObsolete0(obsoleteVer, false)) {
+ if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
if (swap) {
if (!isStartVersion()) {
try {
@@ -3847,7 +3848,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
CacheObject prevVal = saveValueForIndexUnlocked();
- if (!hasReaders() && markObsolete0(obsoleteVer, false)) {
+ if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
if (swap) {
if (!isStartVersion()) {
try {
@@ -3923,7 +3924,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
GridCacheBatchSwapEntry ret = null;
try {
- if (!hasReaders() && markObsolete0(obsoleteVer, false)) {
+ if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
if (!isStartVersion() && hasValueUnlocked()) {
if (cctx.offheapTiered() && hasOffHeapPointer()) {
if (cctx.swap().offheapEvictionEnabled())
@@ -3982,7 +3983,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
return false;
if (checkExpired()) {
- rmv = markObsolete0(cctx.versions().next(this.ver), true);
+ rmv = markObsolete0(cctx.versions().next(this.ver), true, null);
return false;
}
@@ -4095,9 +4096,12 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
/**
* @param obsoleteVer Obsolete version.
*/
- protected void obsoleteVersionExtras(@Nullable GridCacheVersion obsoleteVer) {
- extras = (extras != null) ? extras.obsoleteVersion(obsoleteVer) : obsoleteVer != null ?
- new GridCacheObsoleteEntryExtras(obsoleteVer) : null;
+ protected void obsoleteVersionExtras(@Nullable GridCacheVersion obsoleteVer, GridCacheObsoleteEntryExtras ext) {
+ extras = (extras != null) ?
+ extras.obsoleteVersion(obsoleteVer) :
+ obsoleteVer != null ?
+ (ext != null) ? ext : new GridCacheObsoleteEntryExtras(obsoleteVer) :
+ null;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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 c8ee6e3..479a0b6 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
@@ -23,10 +23,12 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.NavigableMap;
import java.util.Queue;
+import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -49,9 +51,11 @@ import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridClientPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionTopology;
import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtTopologyFuture;
+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.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.GridDhtPartitionsExchangeFuture;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage;
@@ -65,8 +69,10 @@ import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.CI2;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.GPC;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.internal.util.worker.GridWorker;
@@ -75,6 +81,7 @@ import org.apache.ignite.lang.IgniteUuid;
import org.apache.ignite.thread.IgniteThread;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import org.jsr166.ConcurrentLinkedDeque8;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_AFFINITY_HISTORY_SIZE;
@@ -85,6 +92,7 @@ import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_STARTED;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
+import static org.apache.ignite.internal.GridTopic.TOPIC_CACHE;
import static org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT;
import static org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL;
import static org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader.DFLT_PRELOAD_RESEND_TIMEOUT;
@@ -132,6 +140,9 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
/** */
private GridFutureAdapter<?> reconnectExchangeFut;
+ /** */
+ private final Queue<Callable<Boolean>> rebalanceQ = new ConcurrentLinkedDeque8<>();
+
/**
* Partition map futures.
* This set also contains already completed exchange futures to address race conditions when coordinator
@@ -309,6 +320,33 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
exchWorker.futQ.addFirst(fut);
+ if (!cctx.kernalContext().clientNode()) {
+ for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++) {
+ final int idx = cnt;
+
+ cctx.io().addOrderedHandler(rebalanceTopic(cnt), new CI2<UUID, GridCacheMessage>() {
+ @Override public void apply(final UUID id, final GridCacheMessage m) {
+ if (!enterBusy())
+ return;
+
+ try {
+ if (m instanceof GridDhtPartitionSupplyMessageV2)
+ cctx.cacheContext(m.cacheId).preloader().handleSupplyMessage(
+ idx, id, (GridDhtPartitionSupplyMessageV2)m);
+ else if (m instanceof GridDhtPartitionDemandMessage)
+ cctx.cacheContext(m.cacheId).preloader().handleDemandMessage(
+ idx, id, (GridDhtPartitionDemandMessage)m);
+ else
+ log.error("Unsupported message type: " + m.getClass().getName());
+ }
+ finally {
+ leaveBusy();
+ }
+ }
+ });
+ }
+ }
+
new IgniteThread(cctx.gridName(), "exchange-worker", exchWorker).start();
if (reconnect) {
@@ -368,6 +406,14 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
}
+ /**
+ * @param idx Index.
+ * @return Topic for index.
+ */
+ public static Object rebalanceTopic(int idx) {
+ return TOPIC_CACHE.topic("Rebalance", idx);
+ }
+
/** {@inheritDoc} */
@Override protected void onKernalStop0(boolean cancel) {
cctx.gridEvents().removeLocalEventListener(discoLsnr);
@@ -392,6 +438,11 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
for (AffinityReadyFuture f : readyFuts.values())
f.onDone(stopErr);
+ if (!cctx.kernalContext().clientNode()) {
+ for (int cnt = 0; cnt < cctx.gridConfig().getRebalanceThreadPoolSize(); cnt++)
+ cctx.io().removeOrderedHandler(rebalanceTopic(cnt));
+ }
+
U.cancel(exchWorker);
if (log.isDebugEnabled())
@@ -1015,6 +1066,10 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
dumpPendingObjects();
+
+ for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
+ cacheCtx.preloader().dumpDebugInfo();
+ }
}
/**
@@ -1127,9 +1182,15 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
boolean startEvtFired = false;
+ int cnt = 0;
+
+ IgniteInternalFuture asyncStartFut = null;
+
while (!isCancelled()) {
GridDhtPartitionsExchangeFuture exchFut = null;
+ cnt++;
+
try {
boolean preloadFinished = true;
@@ -1244,12 +1305,111 @@ public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedMana
}
if (assignsMap != null) {
+ int size = assignsMap.size();
+
+ rebalanceQ.clear();
+
+ NavigableMap<Integer, List<Integer>> orderMap = new TreeMap<>();
+
for (Map.Entry<Integer, GridDhtPreloaderAssignments> e : assignsMap.entrySet()) {
int cacheId = e.getKey();
GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
- cacheCtx.preloader().addAssignments(e.getValue(), forcePreload);
+ int order = cacheCtx.config().getRebalanceOrder();
+
+ if (orderMap.get(order) == null)
+ orderMap.put(order, new ArrayList<Integer>(size));
+
+ orderMap.get(order).add(cacheId);
+ }
+
+ Callable<Boolean> marshR = null;
+ List<Callable<Boolean>> orderedRs = new ArrayList<>(size);
+
+ //Ordered rebalance scheduling.
+ for (Integer order : orderMap.keySet()) {
+ for (Integer cacheId : orderMap.get(order)) {
+ GridCacheContext<K, V> cacheCtx = cctx.cacheContext(cacheId);
+
+ List<String> waitList = new ArrayList<>(size - 1);
+
+ for (List<Integer> cIds : orderMap.headMap(order).values()) {
+ for (Integer cId : cIds) {
+ waitList.add(cctx.cacheContext(cId).name());
+ }
+ }
+
+ Callable<Boolean> r = cacheCtx.preloader().addAssignments(
+ assignsMap.get(cacheId), forcePreload, waitList, cnt);
+
+ if (r != null) {
+ U.log(log, "Cache rebalancing scheduled: [cache=" + cacheCtx.name() +
+ ", waitList=" + waitList.toString() + "]");
+
+ if (cacheId == CU.cacheId(GridCacheUtils.MARSH_CACHE_NAME))
+ marshR = r;
+ else
+ orderedRs.add(r);
+ }
+ }
+ }
+
+ if (asyncStartFut != null)
+ asyncStartFut.get(); // Wait for thread stop.
+
+ rebalanceQ.addAll(orderedRs);
+
+ if (marshR != null || !rebalanceQ.isEmpty()) {
+ if (futQ.isEmpty()) {
+ U.log(log, "Starting caches rebalancing [top=" + exchFut.topologyVersion() + "]");
+
+ if (marshR != null)
+ try {
+ marshR.call(); //Marshaller cache rebalancing launches in sync way.
+ }
+ catch (Exception ex) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send initial demand request to node");
+
+ continue;
+ }
+
+ final GridFutureAdapter fut = new GridFutureAdapter();
+
+ asyncStartFut = fut;
+
+ cctx.kernalContext().closure().callLocalSafe(new GPC<Boolean>() {
+ @Override public Boolean call() {
+ try {
+ while (true) {
+ Callable<Boolean> r = rebalanceQ.poll();
+
+ if (r == null)
+ return false;
+
+ if (!r.call())
+ return false;
+ }
+ }
+ catch (Exception ex) {
+ if (log.isDebugEnabled())
+ log.debug("Failed to send initial demand request to node");
+
+ return false;
+ }
+ finally {
+ fut.onDone();
+ }
+ }
+ }, /*system pool*/ true);
+ }
+ else {
+ U.log(log, "Obsolete exchange, skipping rebalancing [top=" + exchFut.topologyVersion() + "]");
+ }
+ }
+ else {
+ U.log(log, "Nothing scheduled, skipping rebalancing [top=" + exchFut.topologyVersion() + "]");
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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 1edaef2..1658a89 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
@@ -18,9 +18,14 @@
package org.apache.ignite.internal.processors.cache;
import java.util.Collection;
+import java.util.UUID;
+import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
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.preloader.GridDhtPartitionDemandMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
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.lang.IgnitePredicate;
@@ -90,8 +95,11 @@ public interface GridCachePreloader {
*
* @param assignments Assignments to add.
* @param forcePreload Force preload flag.
+ * @param caches Rebalancing of these caches will be finished before this started.
+ * @param cnt Counter.
*/
- public void addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload);
+ public Callable<Boolean> addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload,
+ Collection<String> caches, int cnt);
/**
* @param p Preload predicate.
@@ -115,6 +123,17 @@ public interface GridCachePreloader {
public IgniteInternalFuture<?> syncFuture();
/**
+ * @return Future which will complete when preloading finishes on current topology.
+ *
+ * Future result is {@code true} in case rebalancing successfully finished at current topology.
+ * Future result is {@code false} in case rebalancing cancelled or finished with missed partitions and will be
+ * restarted at current or pending topology.
+ *
+ * Note that topology change creates new futures and finishes previous.
+ */
+ public IgniteInternalFuture<Boolean> rebalanceFuture();
+
+ /**
* Requests that preloader sends the request for the key.
*
* @param keys Keys to request.
@@ -134,7 +153,39 @@ public interface GridCachePreloader {
public void unwindUndeploys();
/**
+ * Handles Supply message.
+ *
+ * @param idx Index.
+ * @param id Node Id.
+ * @param s Supply message.
+ */
+ public void handleSupplyMessage(int idx, UUID id, final GridDhtPartitionSupplyMessageV2 s);
+
+ /**
+ * Handles Demand message.
+ *
+ * @param idx Index.
+ * @param id Node Id.
+ * @param d Demand message.
+ */
+ public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d);
+
+ /**
+ * Evicts partition asynchronously.
+ *
+ * @param part Partition.
+ */
+ public void evictPartitionAsync(GridDhtLocalPartition part);
+
+ /**
+ * Handles new topology.
+ *
+ * @param topVer Topology version.
+ */
+ public void onTopologyChanged(AffinityTopologyVersion topVer);
+
+ /**
* Dumps debug information.
*/
public void dumpDebugInfo();
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/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 4ec6749..9c0e9f7 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
@@ -18,11 +18,16 @@
package org.apache.ignite.internal.processors.cache;
import java.util.Collection;
+import java.util.UUID;
+import java.util.concurrent.Callable;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.affinity.AffinityFunction;
import org.apache.ignite.internal.IgniteInternalFuture;
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.preloader.GridDhtPartitionDemandMessage;
+import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessageV2;
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;
@@ -36,7 +41,7 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
/** Cache context. */
protected final GridCacheContext<?, ?> cctx;
- /** Logger.*/
+ /** Logger. */
protected final IgniteLogger log;
/** Affinity. */
@@ -113,12 +118,28 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
}
/** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Boolean> rebalanceFuture() {
+ return new GridFinishedFuture<>(true);
+ }
+
+ /** {@inheritDoc} */
@Override public void unwindUndeploys() {
cctx.deploy().unwind(cctx);
}
/** {@inheritDoc} */
- @Override public IgniteInternalFuture<Object> request(Collection<KeyCacheObject> keys, AffinityTopologyVersion topVer) {
+ @Override public void handleSupplyMessage(int idx, UUID id, GridDhtPartitionSupplyMessageV2 s) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void handleDemandMessage(int idx, UUID id, GridDhtPartitionDemandMessage d) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public IgniteInternalFuture<Object> request(Collection<KeyCacheObject> keys,
+ AffinityTopologyVersion topVer) {
return new GridFinishedFuture<>();
}
@@ -143,7 +164,18 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
}
/** {@inheritDoc} */
- @Override public void addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload) {
+ @Override public Callable<Boolean> addAssignments(GridDhtPreloaderAssignments assignments, boolean forcePreload,
+ Collection<String> caches, int cnt) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictPartitionAsync(GridDhtLocalPartition part) {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onTopologyChanged(AffinityTopologyVersion topVer) {
// No-op.
}
@@ -151,4 +183,4 @@ public class GridCachePreloaderAdapter implements GridCachePreloader {
@Override public void dumpDebugInfo() {
// No-op.
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index b2bb6ff..f54f63e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -31,9 +31,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
-import java.util.NavigableMap;
import java.util.Set;
-import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -98,7 +96,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersionManag
import org.apache.ignite.internal.processors.plugin.CachePluginManager;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.F0;
-import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
@@ -160,12 +157,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** Map of proxies. */
private final Map<String, IgniteCacheProxy<?, ?>> jCacheProxies;
- /** Map of preload finish futures grouped by preload order. */
- private final NavigableMap<Integer, IgniteInternalFuture<?>> preloadFuts;
-
- /** Maximum detected rebalance order. */
- private int maxRebalanceOrder;
-
/** Caches stop sequence. */
private final Deque<String> stopSeq;
@@ -207,8 +198,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
caches = new ConcurrentHashMap<>();
jCacheProxies = new ConcurrentHashMap<>();
- preloadFuts = new TreeMap<>();
-
stopSeq = new LinkedList<>();
}
@@ -378,10 +367,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
U.warn(log, "AffinityFunction configuration parameter will be ignored for local cache [cacheName=" +
U.maskName(cc.getName()) + ']');
- if (cc.getRebalanceMode() != CacheRebalanceMode.NONE) {
- assertParameter(cc.getRebalanceThreadPoolSize() > 0, "rebalanceThreadPoolSize > 0");
+ if (cc.getRebalanceMode() != CacheRebalanceMode.NONE)
assertParameter(cc.getRebalanceBatchSize() > 0, "rebalanceBatchSize > 0");
- }
if (cc.getCacheMode() == PARTITIONED || cc.getCacheMode() == REPLICATED) {
if (cc.getAtomicityMode() == ATOMIC && cc.getWriteSynchronizationMode() == FULL_ASYNC)
@@ -591,8 +578,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
"Deployment mode for cache is not CONTINUOUS or SHARED.");
}
- maxRebalanceOrder = validatePreloadOrder(ctx.config().getCacheConfiguration());
-
ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class,
new CustomEventListener<DynamicCacheChangeBatch>() {
@Override public void onCustomEvent(ClusterNode snd,
@@ -820,31 +805,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
for (GridCacheSharedManager<?, ?> mgr : sharedCtx.managers())
mgr.onKernalStart(false);
- for (Map.Entry<String, GridCacheAdapter<?, ?>> e : caches.entrySet()) {
- GridCacheAdapter cache = e.getValue();
-
- if (maxRebalanceOrder > 0) {
- CacheConfiguration cfg = cache.configuration();
-
- int order = cfg.getRebalanceOrder();
-
- if (order > 0 && order != maxRebalanceOrder && cfg.getCacheMode() != LOCAL) {
- GridCompoundFuture fut = (GridCompoundFuture)preloadFuts.get(order);
-
- if (fut == null) {
- fut = new GridCompoundFuture<>();
-
- preloadFuts.put(order, fut);
- }
-
- fut.add(cache.preloader().syncFuture());
- }
- }
- }
-
- for (IgniteInternalFuture<?> fut : preloadFuts.values())
- ((GridCompoundFuture<Object, Object>)fut).markInitialized();
-
for (GridCacheAdapter<?, ?> cache : caches.values())
onKernalStart(cache);
@@ -2791,19 +2751,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
- * Gets preload finish future for preload-ordered cache with given order. I.e. will get compound preload future
- * with maximum order less than {@code order}.
- *
- * @param order Cache order.
- * @return Compound preload future or {@code null} if order is minimal order found.
- */
- @Nullable public IgniteInternalFuture<?> orderedPreloadFuture(int order) {
- Map.Entry<Integer, IgniteInternalFuture<?>> entry = preloadFuts.lowerEntry(order);
-
- return entry == null ? null : entry.getValue();
- }
-
- /**
* @param spaceName Space name.
* @param keyBytes Key bytes.
* @param valBytes Value bytes.
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
index 1b2d834..392ad6a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedCacheEntry;
import org.apache.ignite.internal.processors.cache.distributed.GridDistributedLockCancelledException;
+import org.apache.ignite.internal.processors.cache.extras.GridCacheObsoleteEntryExtras;
import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.lang.GridPlainRunnable;
@@ -554,7 +555,11 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
* @return {@code True} if entry was not being used, passed the filter and could be removed.
* @throws IgniteCheckedException If failed to remove from swap.
*/
- public boolean clearInternal(GridCacheVersion ver, boolean swap) throws IgniteCheckedException {
+ public boolean clearInternal(
+ GridCacheVersion ver,
+ boolean swap,
+ GridCacheObsoleteEntryExtras extras
+ ) throws IgniteCheckedException {
boolean rmv = false;
try {
@@ -563,7 +568,7 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
// Call markObsolete0 to avoid recursive calls to clear if
// we are clearing dht local partition (onMarkedObsolete should not be called).
- if (!markObsolete0(ver, false)) {
+ if (!markObsolete0(ver, false, extras)) {
if (log.isDebugEnabled())
log.debug("Entry could not be marked obsolete (it is still used or has readers): " + this);
@@ -819,4 +824,4 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
return S.toString(ReaderId.class, this);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 749d06a..1516ee4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -17,6 +17,17 @@
package org.apache.ignite.internal.processors.cache.distributed.dht;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.concurrent.atomic.AtomicStampedReference;
+import java.util.concurrent.locks.ReentrantLock;
+import javax.cache.CacheException;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteLogger;
import org.apache.ignite.internal.IgniteInternalFuture;
@@ -27,10 +38,10 @@ import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedExceptio
import org.apache.ignite.internal.processors.cache.GridCacheSwapEntry;
import org.apache.ignite.internal.processors.cache.KeyCacheObject;
import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader;
+import org.apache.ignite.internal.processors.cache.extras.GridCacheObsoleteEntryExtras;
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.processors.query.GridQueryProcessor;
import org.apache.ignite.internal.util.GridCircularBuffer;
-import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
@@ -38,7 +49,6 @@ import org.apache.ignite.internal.util.typedef.CI1;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.GPC;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteUuid;
@@ -46,18 +56,6 @@ import org.jetbrains.annotations.NotNull;
import org.jsr166.ConcurrentHashMap8;
import org.jsr166.LongAdder8;
-import javax.cache.CacheException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.atomic.AtomicStampedReference;
-import java.util.concurrent.locks.ReentrantLock;
-
import static org.apache.ignite.IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE;
import static org.apache.ignite.events.EventType.EVT_CACHE_REBALANCE_OBJECT_UNLOADED;
import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState.EVICTED;
@@ -286,7 +284,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
}
// Attempt to evict.
- tryEvict(true);
+ tryEvict();
}
/**
@@ -411,7 +409,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
// Decrement reservations.
if (state.compareAndSet(s, s, reservations, --reservations)) {
- tryEvict(true);
+ tryEvict();
break;
}
@@ -477,10 +475,10 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
/**
* @param updateSeq Update sequence.
- * @return Future for evict attempt.
*/
- IgniteInternalFuture<Boolean> tryEvictAsync(boolean updateSeq) {
+ void tryEvictAsync(boolean updateSeq) {
if (map.isEmpty() && !GridQueryProcessor.isEnabled(cctx.config()) &&
+ state.getReference() == RENTING && state.getStamp() == 0 &&
state.compareAndSet(RENTING, EVICTED, 0, 0)) {
if (log.isDebugEnabled())
log.debug("Evicted partition: " + this);
@@ -497,15 +495,9 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
((GridDhtPreloader)cctx.preloader()).onPartitionEvicted(this, updateSeq);
clearDeferredDeletes();
-
- return new GridFinishedFuture<>(true);
}
-
- return cctx.closures().callLocalSafe(new GPC<Boolean>() {
- @Override public Boolean call() {
- return tryEvict(true);
- }
- }, /*system pool*/ true);
+ else
+ cctx.preloader().evictPartitionAsync(this);
}
/**
@@ -521,12 +513,11 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
}
/**
- * @param updateSeq Update sequence.
- * @return {@code True} if entry has been transitioned to state EVICTED.
+ *
*/
- boolean tryEvict(boolean updateSeq) {
+ public void tryEvict() {
if (state.getReference() != RENTING || state.getStamp() != 0 || groupReserved())
- return false;
+ return;
// Attempt to evict partition entries from cache.
clearAll();
@@ -545,14 +536,10 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
rent.onDone();
- ((GridDhtPreloader)cctx.preloader()).onPartitionEvicted(this, updateSeq);
+ ((GridDhtPreloader)cctx.preloader()).onPartitionEvicted(this, true);
clearDeferredDeletes();
-
- return true;
}
-
- return false;
}
/**
@@ -592,7 +579,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
*
*/
void onUnlock() {
- tryEvict(true);
+ tryEvict();
}
/**
@@ -640,6 +627,8 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
it = F.concat(it, unswapIt);
}
+ GridCacheObsoleteEntryExtras extras = new GridCacheObsoleteEntryExtras(clearVer);
+
try {
while (it.hasNext()) {
GridDhtCacheEntry cached = null;
@@ -647,7 +636,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
try {
cached = it.next();
- if (cached.clearInternal(clearVer, swap)) {
+ if (cached.clearInternal(clearVer, swap, extras)) {
map.remove(cached.key(), cached);
if (!cached.isInternal()) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java
index 756326e..d12247e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionsReservation.java
@@ -239,7 +239,7 @@ public class GridDhtPartitionsReservation implements GridReservable {
}
/**
- * Must be checked in {@link GridDhtLocalPartition#tryEvict(boolean)}.
+ * Must be checked in {@link GridDhtLocalPartition#tryEvict()}.
* If returns {@code true} this reservation object becomes invalid and partitions
* can be evicted or at least cleared.
* Also this means that after returning {@code true} here method {@link #reserve()} can not
http://git-wip-us.apache.org/repos/asf/ignite/blob/7dfaa3b0/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
index 7609d98..53c3d90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemandMessage.java
@@ -68,8 +68,6 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
* @param topVer Topology version.
*/
GridDhtPartitionDemandMessage(long updateSeq, @NotNull AffinityTopologyVersion topVer, int cacheId) {
- assert updateSeq > 0;
-
this.cacheId = cacheId;
this.updateSeq = updateSeq;
this.topVer = topVer;
@@ -116,6 +114,13 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
}
/**
+ * @param updateSeq Update sequence.
+ */
+ void updateSequence(long updateSeq) {
+ this.updateSeq = updateSeq;
+ }
+
+ /**
* @return Update sequence.
*/
long updateSequence() {
@@ -325,7 +330,8 @@ public class GridDhtPartitionDemandMessage extends GridCacheMessage {
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(GridDhtPartitionDemandMessage.class, this, "partCnt", parts.size(), "super",
- super.toString());
+ return S.toString(GridDhtPartitionDemandMessage.class, this,
+ "partCnt", parts != null ? parts.size() : 0,
+ "super", super.toString());
}
}
[35/50] [abbrv] ignite git commit: Renamed IgniteRddSpec to
IgniteRDDSpec
Posted by ag...@apache.org.
Renamed IgniteRddSpec to IgniteRDDSpec
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c66df66c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c66df66c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c66df66c
Branch: refs/heads/ignite-1702
Commit: c66df66c24a9e9dbee5caca459555fae7c2b2eb8
Parents: 39405ae
Author: Stephen Boesch <ja...@gmail.com>
Authored: Wed Nov 4 13:38:13 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 13:38:13 2015 +0300
----------------------------------------------------------------------
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRddSpec.scala | 249 -------------------
.../apache/ignite/spark/IgniteRddSpec1.scala | 249 +++++++++++++++++++
3 files changed, 250 insertions(+), 250 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
index 00beac6..e56558d 100644
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/Entity.scala
@@ -17,7 +17,7 @@
package org.apache.ignite.spark
-import org.apache.ignite.spark.IgniteRddSpec.ScalarCacheQuerySqlField
+import org.apache.ignite.spark.IgniteRddSpec1.ScalarCacheQuerySqlField
class Entity (
@ScalarCacheQuerySqlField(index = true) val id: Int,
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
deleted file mode 100644
index 8fa6949..0000000
--- a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec.scala
+++ /dev/null
@@ -1,249 +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.spark
-
-import org.apache.ignite.Ignition
-import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
-import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
-import org.apache.spark.SparkContext
-import org.junit.runner.RunWith
-import org.scalatest._
-import org.scalatest.junit.JUnitRunner
-
-import IgniteRddSpec._
-
-import scala.annotation.meta.field
-
-@RunWith(classOf[JUnitRunner])
-class IgniteRddSpec extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
- describe("IgniteRDD") {
- it("should successfully store data to ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- () ⇒ configuration("client", client = true))
-
- // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
- ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- // Check cache contents.
- val ignite = Ignition.ignite("grid-0")
-
- for (i ← 0 to 10000) {
- val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
-
- assert(res != null, "Value was not put to cache for key: " + i)
- assert("val" + i == res, "Invalid value stored for key: " + i)
- }
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully read data from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
-
- val num = 10000
-
- for (i ← 0 to num) {
- cache.put(String.valueOf(i), i)
- }
-
- val ic = new IgniteContext[String, Int](sc,
- () ⇒ configuration("client", client = true))
-
- val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
-
- assert(res == (0 to num).sum)
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query objects from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0).id, "Invalid result")
- assert("name50" == res(0).name, "Invalid result")
- assert(5000 == res(0).salary)
-
- assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully query fields from ignite") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, Entity](sc,
- () ⇒ configuration("client", client = true))
-
- val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- import ic.sqlContext.implicits._
-
- cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
-
- val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
-
- df.printSchema()
-
- val res = df.collect()
-
- assert(res.length == 1, "Invalid result length")
- assert(50 == res(0)(0), "Invalid result")
- assert("name50" == res(0)(1), "Invalid result")
- assert(5000 == res(0)(2), "Invalid result")
-
- val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
-
- val res0 = df0.collect()
-
- assert(res0.length == 1, "Invalid result length")
- assert(50 == res0(0)(0), "Invalid result")
- assert("name50" == res0(0)(1), "Invalid result")
- assert(5000 == res0(0)(2), "Invalid result")
-
- assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
- }
- finally {
- sc.stop()
- }
- }
-
- it("should successfully start spark context with XML configuration") {
- val sc = new SparkContext("local[*]", "test")
-
- try {
- val ic = new IgniteContext[String, String](sc,
- "modules/core/src/test/config/spark/spark-config.xml")
-
- val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
-
- cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
-
- assert(1000 == cache.count())
- }
- finally {
- sc.stop()
- }
- }
- }
-
- override protected def beforeEach() = {
- Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
- }
-
- override protected def afterEach() = {
- Ignition.stop("client", false)
- }
-
- override protected def beforeAll() = {
- for (i ← 0 to 3) {
- Ignition.start(configuration("grid-" + i, client = false))
- }
- }
-
- override protected def afterAll() = {
- for (i ← 0 to 3) {
- Ignition.stop("grid-" + i, false)
- }
- }
-}
-
-/**
- * Constants and utility methods.
- */
-object IgniteRddSpec {
- /** IP finder for the test. */
- val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
-
- /** Partitioned cache name. */
- val PARTITIONED_CACHE_NAME = "partitioned"
-
- /** Type alias for `QuerySqlField`. */
- type ScalarCacheQuerySqlField = QuerySqlField @field
-
- /** Type alias for `QueryTextField`. */
- type ScalarCacheQueryTextField = QueryTextField @field
-
- /**
- * Gets ignite configuration.
- *
- * @param gridName Grid name.
- * @param client Client mode flag.
- * @return Ignite configuration.
- */
- def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
- val cfg = new IgniteConfiguration
-
- val discoSpi = new TcpDiscoverySpi
-
- discoSpi.setIpFinder(IgniteRddSpec.IP_FINDER)
-
- cfg.setDiscoverySpi(discoSpi)
-
- cfg.setCacheConfiguration(cacheConfiguration(gridName))
-
- cfg.setClientMode(client)
-
- cfg.setGridName(gridName)
-
- cfg
- }
-
- /**
- * Gets cache configuration for the given grid name.
- *
- * @param gridName Grid name.
- * @return Cache configuration.
- */
- def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
- val ccfg = new CacheConfiguration[Object, Object]()
-
- ccfg.setBackups(1)
-
- ccfg.setName(PARTITIONED_CACHE_NAME)
-
- ccfg.setIndexedTypes(classOf[String], classOf[Entity])
-
- ccfg
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c66df66c/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
----------------------------------------------------------------------
diff --git a/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
new file mode 100644
index 0000000..3ef3225
--- /dev/null
+++ b/modules/spark/src/test/scala/org/apache/ignite/spark/IgniteRddSpec1.scala
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spark
+
+import org.apache.ignite.Ignition
+import org.apache.ignite.cache.query.annotations.{QueryTextField, QuerySqlField}
+import org.apache.ignite.configuration.{CacheConfiguration, IgniteConfiguration}
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder
+import org.apache.spark.SparkContext
+import org.junit.runner.RunWith
+import org.scalatest._
+import org.scalatest.junit.JUnitRunner
+
+import IgniteRddSpec1._
+
+import scala.annotation.meta.field
+
+@RunWith(classOf[JUnitRunner])
+class IgniteRddSpec1 extends FunSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach {
+ describe("IgniteRDD") {
+ it("should successfully store data to ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ () ⇒ configuration("client", client = true))
+
+ // Save pairs ("0", "val0"), ("1", "val1"), ... to Ignite cache.
+ ic.fromCache(PARTITIONED_CACHE_NAME).savePairs(sc.parallelize(0 to 10000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ // Check cache contents.
+ val ignite = Ignition.ignite("grid-0")
+
+ for (i ← 0 to 10000) {
+ val res = ignite.cache[String, String](PARTITIONED_CACHE_NAME).get(String.valueOf(i))
+
+ assert(res != null, "Value was not put to cache for key: " + i)
+ assert("val" + i == res, "Invalid value stored for key: " + i)
+ }
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully read data from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val cache = Ignition.ignite("grid-0").cache[String, Int](PARTITIONED_CACHE_NAME)
+
+ val num = 10000
+
+ for (i ← 0 to num) {
+ cache.put(String.valueOf(i), i)
+ }
+
+ val ic = new IgniteContext[String, Int](sc,
+ () ⇒ configuration("client", client = true))
+
+ val res = ic.fromCache(PARTITIONED_CACHE_NAME).map(_._2).sum()
+
+ assert(res == (0 to num).sum)
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query objects from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val res: Array[Entity] = cache.objectSql("Entity", "name = ? and salary = ?", "name50", 5000).map(_._2).collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0).id, "Invalid result")
+ assert("name50" == res(0).name, "Invalid result")
+ assert(5000 == res(0).salary)
+
+ assert(500 == cache.objectSql("Entity", "id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully query fields from ignite") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, Entity](sc,
+ () ⇒ configuration("client", client = true))
+
+ val cache: IgniteRDD[String, Entity] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ import ic.sqlContext.implicits._
+
+ cache.savePairs(sc.parallelize(0 to 1000, 2).map(i ⇒ (String.valueOf(i), new Entity(i, "name" + i, i * 100))))
+
+ val df = cache.sql("select id, name, salary from Entity where name = ? and salary = ?", "name50", 5000)
+
+ df.printSchema()
+
+ val res = df.collect()
+
+ assert(res.length == 1, "Invalid result length")
+ assert(50 == res(0)(0), "Invalid result")
+ assert("name50" == res(0)(1), "Invalid result")
+ assert(5000 == res(0)(2), "Invalid result")
+
+ val df0 = cache.sql("select id, name, salary from Entity").where('NAME === "name50" and 'SALARY === 5000)
+
+ val res0 = df0.collect()
+
+ assert(res0.length == 1, "Invalid result length")
+ assert(50 == res0(0)(0), "Invalid result")
+ assert("name50" == res0(0)(1), "Invalid result")
+ assert(5000 == res0(0)(2), "Invalid result")
+
+ assert(500 == cache.sql("select id from Entity where id > 500").count(), "Invalid count")
+ }
+ finally {
+ sc.stop()
+ }
+ }
+
+ it("should successfully start spark context with XML configuration") {
+ val sc = new SparkContext("local[*]", "test")
+
+ try {
+ val ic = new IgniteContext[String, String](sc,
+ "modules/core/src/test/config/spark/spark-config.xml")
+
+ val cache: IgniteRDD[String, String] = ic.fromCache(PARTITIONED_CACHE_NAME)
+
+ cache.savePairs(sc.parallelize(1 to 1000, 2).map(i ⇒ (String.valueOf(i), "val" + i)))
+
+ assert(1000 == cache.count())
+ }
+ finally {
+ sc.stop()
+ }
+ }
+ }
+
+ override protected def beforeEach() = {
+ Ignition.ignite("grid-0").cache(PARTITIONED_CACHE_NAME).removeAll()
+ }
+
+ override protected def afterEach() = {
+ Ignition.stop("client", false)
+ }
+
+ override protected def beforeAll() = {
+ for (i ← 0 to 3) {
+ Ignition.start(configuration("grid-" + i, client = false))
+ }
+ }
+
+ override protected def afterAll() = {
+ for (i ← 0 to 3) {
+ Ignition.stop("grid-" + i, false)
+ }
+ }
+}
+
+/**
+ * Constants and utility methods.
+ */
+object IgniteRddSpec1 {
+ /** IP finder for the test. */
+ val IP_FINDER = new TcpDiscoveryVmIpFinder(true)
+
+ /** Partitioned cache name. */
+ val PARTITIONED_CACHE_NAME = "partitioned"
+
+ /** Type alias for `QuerySqlField`. */
+ type ScalarCacheQuerySqlField = QuerySqlField @field
+
+ /** Type alias for `QueryTextField`. */
+ type ScalarCacheQueryTextField = QueryTextField @field
+
+ /**
+ * Gets ignite configuration.
+ *
+ * @param gridName Grid name.
+ * @param client Client mode flag.
+ * @return Ignite configuration.
+ */
+ def configuration(gridName: String, client: Boolean): IgniteConfiguration = {
+ val cfg = new IgniteConfiguration
+
+ val discoSpi = new TcpDiscoverySpi
+
+ discoSpi.setIpFinder(IgniteRddSpec1.IP_FINDER)
+
+ cfg.setDiscoverySpi(discoSpi)
+
+ cfg.setCacheConfiguration(cacheConfiguration(gridName))
+
+ cfg.setClientMode(client)
+
+ cfg.setGridName(gridName)
+
+ cfg
+ }
+
+ /**
+ * Gets cache configuration for the given grid name.
+ *
+ * @param gridName Grid name.
+ * @return Cache configuration.
+ */
+ def cacheConfiguration(gridName: String): CacheConfiguration[Object, Object] = {
+ val ccfg = new CacheConfiguration[Object, Object]()
+
+ ccfg.setBackups(1)
+
+ ccfg.setName(PARTITIONED_CACHE_NAME)
+
+ ccfg.setIndexedTypes(classOf[String], classOf[Entity])
+
+ ccfg
+ }
+}
[31/50] [abbrv] ignite git commit: IGNITE-1545: Java8
MessagingExample should be optimized
Posted by ag...@apache.org.
IGNITE-1545: Java8 MessagingExample should be optimized
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fec2450f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fec2450f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fec2450f
Branch: refs/heads/ignite-1702
Commit: fec2450fd1f024696ae60ba3c67e6c7de4dbeca6
Parents: 51c0d80
Author: Roman Shtykh <ap...@gmail.com>
Authored: Wed Nov 4 12:25:55 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 12:28:49 2015 +0300
----------------------------------------------------------------------
.../ignite/examples/java8/messaging/MessagingExample.java | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fec2450f/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
index 97ec58e..de060a7 100644
--- a/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
+++ b/examples/src/main/java8/org/apache/ignite/examples/java8/messaging/MessagingExample.java
@@ -54,13 +54,8 @@ public final class MessagingExample {
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
- if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2)) {
- System.out.println();
- System.out.println(">>> Please start at least 2 cluster nodes to run example.");
- System.out.println();
-
+ if (!ExamplesUtils.checkMinTopologySize(ignite.cluster(), 2))
return;
- }
System.out.println();
System.out.println(">>> Messaging example started.");
[25/50] [abbrv] ignite git commit: Redundant files deleted from log4j2
Posted by ag...@apache.org.
Redundant files deleted from log4j2
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/be6e4398
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/be6e4398
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/be6e4398
Branch: refs/heads/ignite-1702
Commit: be6e4398f8610c48d4e64ad37bbae8d3962bbac8
Parents: 28e0217
Author: Artem Shutak <as...@gridgain.com>
Authored: Tue Nov 3 12:58:56 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Nov 3 12:58:56 2015 +0300
----------------------------------------------------------------------
.../ignite/logger/log4j2/Log4J2Logger.java~ | 542 -------------------
.../ignite/logger/log4j2/Log4j2FileAware.java~ | 33 --
.../ignite/logger/log4j2/Log4jFileAware.java~ | 13 -
3 files changed, 588 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/be6e4398/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java~
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java~ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java~
deleted file mode 100644
index 2ac3307..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4J2Logger.java~
+++ /dev/null
@@ -1,542 +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.logger.log4j2;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.UUID;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.util.GridConcurrentHashSet;
-import org.apache.ignite.internal.util.tostring.GridToStringExclude;
-import org.apache.ignite.internal.util.typedef.C1;
-import org.apache.ignite.internal.util.typedef.internal.A;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteClosure;
-import org.apache.ignite.logger.LoggerNodeIdAware;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.config.AppenderRef;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Log4j2-based implementation for logging. This logger should be used by
- * loaders that have prefer <a target=_new
- * href="http://logging.apache.org/log4j/2.x/">log4j2</a>-based logging.
- * <p>
- * Here is a typical example of configuring log4j logger in Ignite configuration
- * file:
- *
- * <pre name="code" class="xml">
- * <property name="gridLogger">
- * <bean class="org.apache.ignite.grid.logger.log4j.GridLog4J2Logger">
- * <constructor-arg type="java.lang.String" value="config/ignite-log4j2.xml"/>
- * </bean>
- * </property>
- * </pre>
- *
- * and from your code:
- *
- * <pre name="code" class="java">
- * IgniteConfiguration cfg = new IgniteConfiguration();
- * ...
- * URL xml = U.resolveIgniteUrl("config/custom-log4j.xml");
- * IgniteLogger log = new Log4J2Logger(xml);
- * ...
- * cfg.setGridLogger(log);
- * </pre>
- *
- * Please take a look at <a target=_new
- * href="http://logging.apache.org/log4j/2.x/">Apache Log4j 2.7</a> for
- * additional information.
- * <p>
- * It's recommended to use Ignite logger injection instead of
- * using/instantiating logger apacin your task/job code. See
- * {@link org.apache.ignite.resources.LoggerResource} annotation about logger
- * injection.
- *
- * Porting for the Log4j2
- *
- * @author Gianfranco Murador
- */
-public class Log4J2Logger implements IgniteLogger, LoggerNodeIdAware,
- Log4j2FileAware {
-
- /** custom message */
- private static String LOG_MESSAGE = ">>> Local Node [ID: ";
-
- /** Appenders. */
- private static Collection<FileAppender> fileAppenders = new GridConcurrentHashSet<>();
-
- /** */
- private static volatile boolean inited;
-
- /** */
- private static volatile boolean quiet0;
-
- /** */
- private static final Object mux = new Object();
-
- /** Logger implementation. */
- @GridToStringExclude
- private Logger impl;
-
- /** Path to configuration file. */
- private final String path;
-
- /** Quiet flag. */
- private final boolean quiet;
-
- /** Node ID. */
- private UUID nodeId;
-
- /**
- * Creates new logger and automatically detects if root logger already has
- * appenders configured. If it does not, the root logger will be configured
- * with default appender (analogous to calling {@link #Log4J2Logger(boolean)
- * Log4J2Logger(boolean)} with parameter {@code true}, otherwise, existing
- * appenders will be used (analogous to calling
- * {@link #Log4J2Logger(boolean) Log4J2Logger(boolean)} with parameter
- */
- public Log4J2Logger() {
- this(!isConfigured());
- }
-
- /**
- * Creates new logger with given implementation.
- * @param impl Log4j implementation to use.
- */
- public Log4J2Logger(final Logger impl) {
- assert impl != null;
-
- path = null;
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override
- public Logger apply(Boolean init) {
- return impl;
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger. If initialize parameter is {@code true} the Log4j
- * logger will be initialized with default console appender and {@code INFO}
- * log level.
- *
- * @param init If {@code true}, then a default console appender with
- * following pattern layout will be created: {@code %d{ABSOLUTE} %-5p [%c{1}] %m%n}.
- * If {@code false}, then no implicit initialization will take place,
- * and {@code Log4j} should be configured prior to calling this
- * constructor.
- */
- public Log4J2Logger(boolean init) {
- impl = LogManager.getRootLogger();
-
- if (init) {
- // Implementation has already been inited, passing NULL.
- addConsoleAppenderIfNeeded(Level.INFO, null);
- quiet = quiet0;
- } else
- quiet = true;
- path = null;
- }
-
- /**
- * Creates new logger with given configuration {@code cfgFile}.
- *
- * @param cfgFile Log4j configuration XML file.
- * @throws IgniteCheckedException Thrown in case logger can't be created.
- */
- public Log4J2Logger(File cfgFile) throws IgniteCheckedException {
-
- final String uri;
-
- if (cfgFile == null)
- throw new IgniteCheckedException(
- "Configuration XML file for Log4j must be specified.");
-
- if (!cfgFile.exists() || cfgFile.isDirectory())
- throw new IgniteCheckedException(
- "Log4j configuration path was not found or is a directory: "
- + cfgFile);
- try {
- uri = cfgFile.toURI().toURL().toString();
- } catch (MalformedURLException e) {
- throw new IgniteCheckedException(e.toString());
- }
- path = cfgFile.getAbsolutePath();
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override
- public Logger apply(Boolean init) {
- if (init) {
- Configurator.initialize("Log4J2Logger", uri);
- }
- return LogManager.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger with given configuration {@code path}.
- *
- * @param path Path to log4j configuration XML file.
- * @throws IgniteCheckedException Thrown in case logger can't be created.
- */
- public Log4J2Logger(String path) throws IgniteCheckedException {
- if (path == null)
- throw new IgniteCheckedException(
- "Configuration XML file for Log4j must be specified.");
-
- this.path = path;
-
- final URL cfgUrl = U.resolveIgniteUrl(path);
-
- if (cfgUrl == null)
- throw new IgniteCheckedException(
- "Log4j configuration path was not found: " + path);
-
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override
- public Logger apply(Boolean init) {
-
- if (init) {
- Configurator.initialize("Log4J2Logger", cfgUrl.toString());
- }
- return LogManager.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Creates new logger with given configuration {@code cfgUrl}.
- *
- * @param cfgUrl URL for Log4j configuration XML file.
- * @throws IgniteCheckedException Thrown in case logger can't be created.
- */
- public Log4J2Logger(final URL cfgUrl) throws IgniteCheckedException {
- if (cfgUrl == null)
- throw new IgniteCheckedException(
- "Configuration XML file for Log4j must be specified.");
- path = null;
- addConsoleAppenderIfNeeded(null, new C1<Boolean, Logger>() {
- @Override
- public Logger apply(Boolean init) {
- if (init) {
- Configurator.initialize("Log4J2Logger", cfgUrl.toString());
- }
- return LogManager.getRootLogger();
- }
- });
-
- quiet = quiet0;
- }
-
- /**
- * Checks if Log4j is already configured within this VM or not
- *
- * @return {@code True} if log4j was already configured, {@code false}
- * otherwise.
- */
- public static boolean isConfigured() {
- return !(LogManager.getLogger("Log4J2Logger") != null);
- }
-
- /**
- * Sets level for internal log4j implementation.
- *
- * @param level Log level to set.
- */
- public void setLevel(Level level) {
- LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
- Configuration conf = ctx.getConfiguration();
- conf.getLoggerConfig(LogManager.ROOT_LOGGER_NAME).setLevel(level);
- ctx.updateLoggers(conf);
- }
-
- /** {@inheritDoc} */
- @Nullable
- @Override
- public String fileName() {
- org.apache.logging.log4j.core.Logger loggerImpl = (org.apache.logging.log4j.core.Logger) impl;
- Collection<Appender> appenders = loggerImpl.getAppenders().values();
- for (Appender a : appenders) {
- if (a instanceof FileAppender) {
- return ((FileAppender) a).getFileName();
- }
- if (a instanceof RollingFileAppender) {
- return ((RollingFileAppender) a).getFileName();
- }
- }
- return null;
- }
-
- /**
- * Adds console appender when needed with some default logging settings.
- *
- * @param logLevel Optional log level.
- * @param implInitC Optional log implementation init closure.
- */
- private void addConsoleAppenderIfNeeded(@Nullable Level logLevel,
- @Nullable IgniteClosure<Boolean, Logger> implInitC) {
- if (inited) {
- if (implInitC != null)
- // Do not init.
- impl = implInitC.apply(false);
-
- return;
- }
- synchronized (mux) {
- if (inited) {
- if (implInitC != null)
- // Do not init.
- impl = implInitC.apply(false);
-
- return;
- }
-
- if (implInitC != null)
- // Init logger impl.
- impl = implInitC.apply(true);
-
- // use the local quite instead of this
- boolean quiet = isQuiet();
-
- // here added a console logger if not exists, programmatically
- // the implementations is more easy with new API
- // Log4j2 has always a console logger by default
- Logger clog = LogManager.getLogger("CONSOLE");
- if (clog == null) {
-
- ConsoleAppender console = ConsoleAppender.createAppender(
- PatternLayout.createDefaultLayout(), null, "CONSOLE",
- "console", null, null);
- final LoggerContext ctx = (LoggerContext) new org.apache.logging.log4j.core.LoggerContext(
- "console");
-
- final Configuration config = ((org.apache.logging.log4j.core.LoggerContext) ctx)
- .getConfiguration();
- config.addAppender(console);
- AppenderRef ref = AppenderRef.createAppenderRef("console",
- logLevel, null);
- AppenderRef[] refs = new AppenderRef[] { ref };
- LoggerConfig loggerConfig = LoggerConfig.createLogger("false",
- logLevel, "org.apache.logging.log4j", "true", refs,
- null, config, null);
- loggerConfig.addAppender(console, null, null);
-
- config.addLogger("org.apache.logging.log4j", loggerConfig);
- ((org.apache.logging.log4j.core.LoggerContext) ctx)
- .updateLoggers();
-
- }
-
- quiet0 = quiet;
- inited = true;
- }
- }
-
- /**
- * With the new Log4j2 API when can choose the filename in the ThreadContext
- * instead of do some hack to setup the file in according to the nodeid.
- * So this method is deprecated
- */
- @Override
- @Deprecated
- public void updateFilePath(IgniteClosure<String, String> filePathClos) {
- A.notNull(filePathClos, "filePathClos");
- for (FileAppender a : fileAppenders) {
-
- }
- }
-
- /**
- * Adds file appender.
- *
- * @param a Appender.
- */
- public static void addAppender(FileAppender a) {
- A.notNull(a, "a");
- fileAppenders.add(a);
- }
-
- /**
- * Removes file appender.
- *
- * @param a Appender.
- */
- public static void removeAppender(FileAppender a) {
- A.notNull(a, "a");
- fileAppenders.remove(a);
- }
-
- /** {@inheritDoc} */
- @Override
- public UUID getNodeId() {
- return nodeId;
- }
-
- /** {@inheritDoc} */
- @Override
- public void setNodeId(UUID nodeid) {
- A.notNull(nodeid, "nodeId");
- String uid = U.id8(nodeid);
-
- // set up the new thread context
- ThreadContext.put("nodeidmsg", LOG_MESSAGE + uid + "]");
- ThreadContext.put("ROUTINGKEY", uid);
-
- ((org.apache.logging.log4j.core.LoggerContext) LogManager
- .getContext(false)).reconfigure();
- this.nodeId = nodeid;
- }
-
- /** {@inheritDoc} */
- @Override
- public void debug(String msg) {
- if (!impl.isDebugEnabled())
- warning("Logging at DEBUG level without checking if DEBUG level is enabled: "
- + msg);
- impl.debug(msg);
- }
-
- /** {@inheritDoc} */
- @Override
- public void warning(String msg) {
- impl.warn(msg);
- }
-
- /** {@inheritDoc} */
- @Override
- public void warning(String msg, @Nullable Throwable e) {
- impl.warn(msg, e);
- }
-
- /** {@inheritDoc} */
- @Override
- public void error(String msg) {
- impl.error(msg);
- }
-
- /** {@inheritDoc} */
- @Override
- public void error(String msg, @Nullable Throwable e) {
- impl.error(msg, e);
- }
-
- /** {@inheritDoc} */
- @Override
- public void info(String msg) {
- if (!impl.isInfoEnabled())
- warning("Logging at INFO level without checking if INFO level is enabled: "
- + msg);
-
- impl.info(msg);
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isTraceEnabled() {
- return impl.isTraceEnabled();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isDebugEnabled() {
- return impl.isDebugEnabled();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isInfoEnabled() {
- return impl.isInfoEnabled();
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isQuiet() {
- return !isInfoEnabled() && !isDebugEnabled();
- }
-
- /** {@inheritDoc} */
- @Override
- public String toString() {
- return S.toString(Log4J2Logger.class, this);
- }
-
- /**
- * Gets files for all registered file appenders.
- *
- * @return List of files.
- */
- public static Collection<String> logFiles() {
- Collection<String> res = new ArrayList<String>(fileAppenders.size());
- for (FileAppender a : fileAppenders)
- res.add(a.getFileName());
- return res;
- }
-
- /**
- * Gets {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger for the given
- * category. If category is {@code null}, then root logger is returned. If
- * category is an instance of {@link Class} then {@code (Class)ctgr).getName()}
- * is used as category name.
- *
- * @param ctgr {@inheritDoc}
- * @return {@link org.apache.ignite.IgniteLogger} wrapper around log4j logger.
- */
- @Override
- public Log4J2Logger getLogger(Object ctgr) {
- return new Log4J2Logger(
- ctgr == null ? LogManager.getRootLogger()
- : ctgr instanceof Class ? LogManager
- .getLogger(((Class<?>) ctgr).getName())
- : LogManager.getLogger(ctgr.toString()));
- }
-
- /** {@inheritDoc} */
- @Override
- public void trace(String msg) {
- if (!impl.isTraceEnabled())
- warning("Logging at TRACE level without checking if TRACE level is enabled: "
- + msg);
- impl.trace(msg);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/be6e4398/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java~
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java~ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java~
deleted file mode 100644
index 53b3803..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4j2FileAware.java~
+++ /dev/null
@@ -1,33 +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.logger.log4j2;
-
-import org.apache.ignite.lang.IgniteClosure;
-/**
- * Porting for the Log4j2, the interface is useless with the new implementation
- * of the module
- * @author Gianfranco Murador
- */
-public interface Log4j2FileAware {
-
- /**
- * Sets closure that later evaluate file path.
- *
- * @param filePathClos Closure that generates actual file path.
- */
- void updateFilePath(IgniteClosure<String, String> filePathClos);
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/be6e4398/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4jFileAware.java~
----------------------------------------------------------------------
diff --git a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4jFileAware.java~ b/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4jFileAware.java~
deleted file mode 100644
index 4405f36..0000000
--- a/modules/log4j2/src/main/java/org/apache/ignite/logger/log4j2/Log4jFileAware.java~
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.ignite.logger.log4j2;
-
-import org.apache.ignite.lang.IgniteClosure;
-
-public interface Log4jFileAware {
-
- /**
- * Sets closure that later evaluate file path.
- *
- * @param filePathClos Closure that generates actual file path.
- */
- void updateFilePath(IgniteClosure<String, String> filePathClos);
-}
[23/50] [abbrv] ignite git commit: Increased test timeout.
Posted by ag...@apache.org.
Increased test timeout.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b65fde44
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b65fde44
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b65fde44
Branch: refs/heads/ignite-1702
Commit: b65fde441756b926732773a793b0be998a3c76af
Parents: 1486b5d
Author: sboikov <sb...@gridgain.com>
Authored: Tue Nov 3 10:16:45 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Nov 3 10:16:45 2015 +0300
----------------------------------------------------------------------
.../processors/cache/distributed/CacheGetFutureHangsSelfTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b65fde44/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
index 659520b..53ac648 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
@@ -91,7 +91,7 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected long getTestTimeout() {
- return 5 * 60_000;
+ return 10 * 60_000;
}
/**
@@ -114,6 +114,7 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
/**
* Executes one test iteration.
+ *
* @throws Exception If failed.
*/
private void doTestFailover() throws Exception {
[12/50] [abbrv] ignite git commit: ignite-1607 Fixes for serializable
txs on changing topology
Posted by ag...@apache.org.
ignite-1607 Fixes for serializable txs on changing topology
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/11d177f5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/11d177f5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/11d177f5
Branch: refs/heads/ignite-1702
Commit: 11d177f5d5d2c2066c2d1fa6e28c9b1a4052d6c6
Parents: 6ea3b56
Author: sboikov <sb...@gridgain.com>
Authored: Mon Nov 2 09:02:29 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Nov 2 09:02:29 2015 +0300
----------------------------------------------------------------------
.../distributed/dht/GridDhtTxPrepareFuture.java | 44 +--
...arOptimisticSerializableTxPrepareFuture.java | 12 +-
.../cache/transactions/IgniteTxManager.java | 4 +-
.../CacheSerializableTransactionsTest.java | 313 ++++++++++++-------
4 files changed, 240 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/11d177f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index d806801..61975d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -573,27 +573,35 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (tx.onePhaseCommit() && tx.commitOnPrepare()) {
assert last;
+ Throwable prepErr = this.err.get();
+
// Must create prepare response before transaction is committed to grab correct return value.
- final GridNearTxPrepareResponse res = createPrepareResponse();
+ final GridNearTxPrepareResponse res = createPrepareResponse(prepErr);
onComplete(res);
if (tx.commitOnPrepare()) {
if (tx.markFinalizing(IgniteInternalTx.FinalizationStatus.USER_FINISH)) {
- IgniteInternalFuture<IgniteInternalTx> fut = this.err.get() == null ?
- tx.commitAsync() : tx.rollbackAsync();
+ IgniteInternalFuture<IgniteInternalTx> fut = null;
- fut.listen(new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
- @Override public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
- try {
- if (replied.compareAndSet(false, true))
- sendPrepareResponse(res);
- }
- catch (IgniteCheckedException e) {
- U.error(log, "Failed to send prepare response for transaction: " + tx, e);
+ if (prepErr == null)
+ fut = tx.commitAsync();
+ else if (!cctx.kernalContext().isStopping())
+ fut = tx.rollbackAsync();
+
+ if (fut != null) {
+ fut.listen(new CIX1<IgniteInternalFuture<IgniteInternalTx>>() {
+ @Override public void applyx(IgniteInternalFuture<IgniteInternalTx> fut) {
+ try {
+ if (replied.compareAndSet(false, true))
+ sendPrepareResponse(res);
+ }
+ catch (IgniteCheckedException e) {
+ U.error(log, "Failed to send prepare response for transaction: " + tx, e);
+ }
}
- }
- });
+ });
+ }
}
}
else {
@@ -610,7 +618,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
else {
if (replied.compareAndSet(false, true)) {
- GridNearTxPrepareResponse res = createPrepareResponse();
+ GridNearTxPrepareResponse res = createPrepareResponse(this.err.get());
try {
sendPrepareResponse(res);
@@ -659,12 +667,10 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
}
/**
+ * @param prepErr Error.
* @return Prepare response.
*/
- private GridNearTxPrepareResponse createPrepareResponse() {
- // Send reply back to originating near node.
- Throwable prepErr = err.get();
-
+ private GridNearTxPrepareResponse createPrepareResponse(@Nullable Throwable prepErr) {
assert F.isEmpty(tx.invalidPartitions());
GridNearTxPrepareResponse res = new GridNearTxPrepareResponse(
@@ -981,7 +987,7 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
if (err0 != null) {
err.compareAndSet(null, err0);
- final GridNearTxPrepareResponse res = createPrepareResponse();
+ final GridNearTxPrepareResponse res = createPrepareResponse(err.get());
tx.rollbackAsync().listen(new CI1<IgniteInternalFuture<IgniteInternalTx>>() {
@Override public void apply(IgniteInternalFuture<IgniteInternalTx> fut) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/11d177f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
index 47c1d21..5488bb1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticSerializableTxPrepareFuture.java
@@ -809,18 +809,22 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
remap(res);
}
catch (IgniteCheckedException e) {
+ err.compareAndSet(null, e);
+
onDone(e);
}
}
});
}
else {
- ClusterTopologyCheckedException err = new ClusterTopologyCheckedException(
+ ClusterTopologyCheckedException err0 = new ClusterTopologyCheckedException(
"Cluster topology changed while client transaction is preparing.");
- err.retryReadyFuture(affFut);
+ err0.retryReadyFuture(affFut);
+
+ err.compareAndSet(null, err0);
- onDone(err);
+ onDone(err0);
}
}
catch (IgniteCheckedException e) {
@@ -829,6 +833,8 @@ public class GridNearOptimisticSerializableTxPrepareFuture extends GridNearOptim
GridNearOptimisticSerializableTxPrepareFuture.this);
}
+ err.compareAndSet(null, e);
+
onDone(e);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/11d177f5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index c1e9202..1f51b8a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1617,8 +1617,6 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
{
for (final IgniteInternalTx tx : txs()) {
if (nearVer.equals(tx.nearXidVersion())) {
- TransactionState state = tx.state();
-
IgniteInternalFuture<?> prepFut = tx.currentPrepareFuture();
if (prepFut != null && !prepFut.isDone()) {
@@ -1648,6 +1646,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
return fut0;
}
+ TransactionState state = tx.state();
+
if (state == PREPARED || state == COMMITTING || state == COMMITTED) {
if (--txNum == 0) {
if (fut != null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/11d177f5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 8c135ad..ae64bb4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ThreadLocalRandom;
@@ -60,6 +61,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteClosure;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
@@ -115,6 +117,8 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
cfg.setClientMode(client);
cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
@@ -187,7 +191,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
txStreamerLoad(ignite(SRVS), 10_000, cache.getName(), allowOverwrite);
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -290,7 +294,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -348,7 +352,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -414,7 +418,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -495,7 +499,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -562,7 +566,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -609,7 +613,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, null, cache.getName());
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -640,7 +644,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -718,7 +722,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -821,7 +825,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -914,7 +918,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1007,7 +1011,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1101,7 +1105,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1187,7 +1191,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1273,7 +1277,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1398,7 +1402,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1523,7 +1527,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1660,7 +1664,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1797,7 +1801,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -1968,7 +1972,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2118,7 +2122,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(i, rmv ? null : i, cache.getName());
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2208,7 +2212,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2267,7 +2271,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2340,7 +2344,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key2, 2, cache.getName());
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2389,7 +2393,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- ignite0.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -2475,7 +2479,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key3, key3, cacheName);
}
finally {
- ignite0.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -2555,7 +2559,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key3, key3, cacheName);
}
finally {
- ignite0.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -2817,8 +2821,8 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- ignite0.destroyCache(CACHE1);
- ignite0.destroyCache(CACHE2);
+ destroyCache(CACHE1);
+ destroyCache(CACHE2);
}
}
@@ -2876,7 +2880,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(ignite0, ccfg.getName());
+ destroyCache(ccfg.getName());
}
}
}
@@ -2975,30 +2979,118 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
caches.add(client.<Integer, Integer>cache(cacheName));
}
- IgniteInternalFuture<?> restartFut = null;
+ IgniteInternalFuture<?> restartFut = restart ? restartFuture(stop, null) : null;
+
+ for (int i = 0; i < 30; i++) {
+ final AtomicInteger cntr = new AtomicInteger();
+
+ final Integer key = i;
+
+ final AtomicInteger threadIdx = new AtomicInteger();
+
+ final int THREADS = 10;
+
+ final CyclicBarrier barrier = new CyclicBarrier(THREADS);
+
+ GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ int idx = threadIdx.getAndIncrement() % caches.size();
+
+ IgniteCache<Integer, Integer> cache = caches.get(idx);
+
+ Ignite ignite = cache.unwrap(Ignite.class);
- if (restart) {
- restartFut = GridTestUtils.runAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- while (!stop.get()) {
- stopGrid(0);
+ IgniteTransactions txs = ignite.transactions();
- U.sleep(300);
+ log.info("Started update thread: " + ignite.name());
+
+ barrier.await();
- Ignite ignite = startGrid(0);
+ for (int i = 0; i < 1000; i++) {
+ try {
+ try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+ Integer val = cache.get(key);
- assertFalse(ignite.configuration().isClientMode());
+ cache.put(key, val == null ? 1 : val + 1);
+
+ tx.commit();
+ }
+
+ cntr.incrementAndGet();
+ }
+ catch (TransactionOptimisticException ignore) {
+ // Retry.
+ }
+ catch (IgniteException | CacheException e) {
+ assertTrue("Unexpected exception [err=" + e + ", cause=" + e.getCause() + ']',
+ restart && X.hasCause(e, ClusterTopologyCheckedException.class));
+ }
}
return null;
}
- });
+ }, THREADS, "update-thread").get();
+
+ log.info("Iteration [iter=" + i + ", val=" + cntr.get() + ']');
+
+ assertTrue(cntr.get() > 0);
+
+ checkValue(key, cntr.get(), cacheName, restart);
}
- for (int i = 0; i < 30; i++) {
+ stop.set(true);
+
+ if (restartFut != null)
+ restartFut.get();
+ }
+ finally {
+ stop.set(true);
+
+ destroyCache(cacheName);
+ }
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testIncrementTxMultipleNodeRestart() throws Exception {
+ incrementTxMultiple(false, false, true);
+ }
+
+ /**
+ * @param nearCache If {@code true} near cache is enabled.
+ * @param store If {@code true} cache store is enabled.
+ * @param restart If {@code true} restarts one node.
+ * @throws Exception If failed.
+ */
+ private void incrementTxMultiple(boolean nearCache, boolean store, final boolean restart) throws Exception {
+ final Ignite srv = ignite(1);
+
+ CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(PARTITIONED, FULL_SYNC, 1, store, false);
+
+ final List<Ignite> clients = clients();
+
+ final String cacheName = srv.createCache(ccfg).getName();
+
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ try {
+ final List<IgniteCache<Integer, Integer>> caches = new ArrayList<>();
+
+ for (Ignite client : clients) {
+ if (nearCache)
+ caches.add(client.createNearCache(cacheName, new NearCacheConfiguration<Integer, Integer>()));
+ else
+ caches.add(client.<Integer, Integer>cache(cacheName));
+ }
+
+ IgniteInternalFuture<?> restartFut = restart ? restartFuture(stop, null) : null;
+
+ for (int i = 0; i < 20; i += 2) {
final AtomicInteger cntr = new AtomicInteger();
- final Integer key = i;
+ final Integer key1 = i;
+ final Integer key2 = i + 1;
final AtomicInteger threadIdx = new AtomicInteger();
@@ -3006,6 +3098,9 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
final CyclicBarrier barrier = new CyclicBarrier(THREADS);
+ final ConcurrentSkipListSet<Integer> vals1 = new ConcurrentSkipListSet<>();
+ final ConcurrentSkipListSet<Integer> vals2 = new ConcurrentSkipListSet<>();
+
GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override public Void call() throws Exception {
int idx = threadIdx.getAndIncrement() % caches.size();
@@ -3023,11 +3118,19 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
for (int i = 0; i < 1000; i++) {
try {
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ Integer val1 = cache.get(key1);
+ Integer val2 = cache.get(key2);
- cache.put(key, val == null ? 1 : val + 1);
+ Integer newVal1 = val1 == null ? 1 : val1 + 1;
+ Integer newVal2 = val2 == null ? 1 : val2 + 1;
+
+ cache.put(key1, newVal1);
+ cache.put(key2, newVal2);
tx.commit();
+
+ assertTrue(vals1.add(newVal1));
+ assertTrue(vals2.add(newVal2));
}
cntr.incrementAndGet();
@@ -3049,7 +3152,8 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
assertTrue(cntr.get() > 0);
- checkValue(key, cntr.get(), cacheName, restart);
+ checkValue(key1, cntr.get(), cacheName, restart);
+ checkValue(key2, cntr.get(), cacheName, restart);
}
stop.set(true);
@@ -3060,7 +3164,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
finally {
stop.set(true);
- destroyCache(srv, cacheName);
+ destroyCache(cacheName);
}
}
@@ -3189,7 +3293,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- ignite0.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -3229,6 +3333,13 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
/**
+ * @throws Exception If failed.
+ */
+ public void testAccountTxNodeRestart() throws Exception {
+ accountTx(false, false, false, true, TestMemoryMode.HEAP);
+ }
+
+ /**
* @param getAll If {@code true} uses getAll/putAll in transaction.
* @param nearCache If {@code true} near cache is enabled.
* @param nonSer If {@code true} starts threads executing non-serializable transactions.
@@ -3421,25 +3532,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}, THREADS, "tx-thread");
- IgniteInternalFuture<?> restartFut = null;
-
- if (restart) {
- restartFut = GridTestUtils.runAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- while (!fut.isDone()) {
- stopGrid(0);
-
- U.sleep(300);
-
- Ignite ignite = startGrid(0);
-
- assertFalse(ignite.configuration().isClientMode());
- }
-
- return null;
- }
- });
- }
+ IgniteInternalFuture<?> restartFut = restart ? restartFuture(null, fut) : null;
fut.get(testTime + 30_000);
@@ -3506,7 +3599,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- srv.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -3558,21 +3651,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
cacheNames.add(ccfg.getName());
}
- IgniteInternalFuture<?> restartFut = GridTestUtils.runAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- while (!finished.get()) {
- stopGrid(0);
-
- U.sleep(300);
-
- Ignite ignite = startGrid(0);
-
- assertFalse(ignite.configuration().isClientMode());
- }
-
- return null;
- }
- });
+ IgniteInternalFuture<?> restartFut = restartFuture(finished, null);
List<IgniteInternalFuture<?>> futs = new ArrayList<>();
@@ -3653,7 +3732,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
finished.set(true);
for (String cacheName : cacheNames)
- srv.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -3710,7 +3789,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- ignite.destroyCache(cacheName);
+ destroyCache(cacheName);
}
}
@@ -3785,27 +3864,9 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
final AtomicBoolean finished = new AtomicBoolean();
- IgniteInternalFuture<Object> fut = null;
+ IgniteInternalFuture<?> fut = restart ? restartFuture(finished, null) : null;
try {
- if (restart) {
- fut = GridTestUtils.runAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- while (!finished.get()) {
- stopGrid(0);
-
- U.sleep(300);
-
- Ignite ignite = startGrid(0);
-
- assertFalse(ignite.configuration().isClientMode());
- }
-
- return null;
- }
- });
- }
-
for (int i = 0; i < 10; i++) {
log.info("Iteration: " + i);
@@ -3957,7 +4018,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
}
finally {
- destroyCache(srv, cacheName);
+ destroyCache(cacheName);
}
}
@@ -4152,16 +4213,20 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
/**
- * @param ignite Node.
* @param cacheName Cache name.
*/
- private void destroyCache(Ignite ignite, String cacheName) {
+ private void destroyCache(String cacheName) {
storeMap.clear();
- ignite.destroyCache(cacheName);
+ for (Ignite ignite : G.allGrids()) {
+ try {
+ ignite.destroyCache(cacheName);
+ }
+ catch (IgniteException ignore) {
+ // No-op.
+ }
- for (Ignite ignite0 : G.allGrids()) {
- GridTestSwapSpaceSpi spi = (GridTestSwapSpaceSpi)ignite0.configuration().getSwapSpaceSpi();
+ GridTestSwapSpaceSpi spi = (GridTestSwapSpaceSpi)ignite.configuration().getSwapSpaceSpi();
spi.clearAll();
}
@@ -4220,6 +4285,36 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
}
/**
+ * @param stop Stop flag.
+ * @param fut Future.
+ * @return Restart thread future.
+ */
+ private IgniteInternalFuture<?> restartFuture(final AtomicBoolean stop, final IgniteInternalFuture<?> fut) {
+ return GridTestUtils.runAsync(new Callable<Object>() {
+ private boolean stop() {
+ if (stop != null)
+ return stop.get();
+
+ return fut.isDone();
+ }
+
+ @Override public Object call() throws Exception {
+ while (!stop()) {
+ Ignite ignite = startGrid(SRVS + CLIENTS);
+
+ assertFalse(ignite.configuration().isClientMode());
+
+ U.sleep(300);
+
+ stopGrid(SRVS + CLIENTS);
+ }
+
+ return null;
+ }
+ }, "restart-thread");
+ }
+
+ /**
*
*/
private static class TestStoreFactory implements Factory<CacheStore<Integer, Integer>> {
[13/50] [abbrv] ignite git commit: Minor: improved toString for
GridCacheTxRecoveryFuture.
Posted by ag...@apache.org.
Minor: improved toString for GridCacheTxRecoveryFuture.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fff4e453
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fff4e453
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fff4e453
Branch: refs/heads/ignite-1702
Commit: fff4e4533ba187ddb4e24bec7effd691ff46c5d4
Parents: 11d177f
Author: sboikov <sb...@gridgain.com>
Authored: Mon Nov 2 10:09:29 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Nov 2 10:09:29 2015 +0300
----------------------------------------------------------------------
.../cache/distributed/GridCacheTxRecoveryFuture.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/fff4e453/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
index 4d75403..b266c4d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheTxRecoveryFuture.java
@@ -33,7 +33,9 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
import org.apache.ignite.internal.util.GridLeanMap;
import org.apache.ignite.internal.util.future.GridCompoundIdentityFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
+import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.CI1;
+import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -434,7 +436,16 @@ public class GridCacheTxRecoveryFuture extends GridCompoundIdentityFuture<Boolea
/** {@inheritDoc} */
@Override public String toString() {
- return S.toString(GridCacheTxRecoveryFuture.class, this, "super", super.toString());
+ Collection<String> futs = F.viewReadOnly(futures(), new C1<IgniteInternalFuture<?>, String>() {
+ @Override public String apply(IgniteInternalFuture<?> f) {
+ return "[node=" + ((MiniFuture)f).nodeId +
+ ", done=" + f.isDone() + "]";
+ }
+ });
+
+ return S.toString(GridCacheTxRecoveryFuture.class, this,
+ "innerFuts", futs,
+ "super", super.toString());
}
/**
[19/50] [abbrv] ignite git commit:
GridCacheNearTxExceptionSelfTest.testRemoveBackup test muted
Posted by ag...@apache.org.
GridCacheNearTxExceptionSelfTest.testRemoveBackup test muted
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/612f9876
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/612f9876
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/612f9876
Branch: refs/heads/ignite-1702
Commit: 612f9876b7efb3040237f5bc1477a44f18f261bb
Parents: 5b0a18d
Author: agura <ag...@gridgain.com>
Authored: Mon Nov 2 19:38:06 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Mon Nov 2 19:38:06 2015 +0300
----------------------------------------------------------------------
.../cache/distributed/near/GridCacheNearTxExceptionSelfTest.java | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/612f9876/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
index 02aa824..270af25 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
@@ -35,4 +35,8 @@ public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractS
@Override public void testTransformBackup(){
fail("https://issues.apache.org/jira/browse/IGNITE-1601");
}
+
+ @Override public void testRemoveBackup() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1839");
+ }
}
\ No newline at end of file
[26/50] [abbrv] ignite git commit: Merge remote-tracking branch
'remotes/apache-main/ignite-1.5' into master-main
Posted by ag...@apache.org.
Merge remote-tracking branch 'remotes/apache-main/ignite-1.5' into master-main
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/953f76b1
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/953f76b1
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/953f76b1
Branch: refs/heads/ignite-1702
Commit: 953f76b14a0cf0c4367ffd4cb002fb955bd82eaf
Parents: 6a22193 be6e439
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Nov 3 13:02:24 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Nov 3 13:02:24 2015 +0300
----------------------------------------------------------------------
.../ignite/logger/log4j2/Log4J2Logger.java~ | 542 -------------------
.../ignite/logger/log4j2/Log4j2FileAware.java~ | 33 --
.../ignite/logger/log4j2/Log4jFileAware.java~ | 13 -
3 files changed, 588 deletions(-)
----------------------------------------------------------------------
[42/50] [abbrv] ignite git commit: PR 201
Posted by ag...@apache.org.
PR 201
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/40104693
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/40104693
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/40104693
Branch: refs/heads/ignite-1702
Commit: 40104693f2fdb9d3c1cb548b69e2600baf05057f
Parents: ad60979
Author: Anton Vinogradov <av...@apache.org>
Authored: Wed Nov 4 18:46:14 2015 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Wed Nov 4 18:46:14 2015 +0300
----------------------------------------------------------------------
modules/ssh/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/40104693/modules/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/modules/ssh/pom.xml b/modules/ssh/pom.xml
index ff3e70d..5028322 100644
--- a/modules/ssh/pom.xml
+++ b/modules/ssh/pom.xml
@@ -44,7 +44,7 @@
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
- <version>0.1.50</version>
+ <version>0.1.53</version>
</dependency>
<dependency>
[41/50] [abbrv] ignite git commit: Merge remote-tracking branch
'remotes/apache-main/ignite-1.5' into master-main
Posted by ag...@apache.org.
Merge remote-tracking branch 'remotes/apache-main/ignite-1.5' into master-main
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ad60979f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ad60979f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ad60979f
Branch: refs/heads/ignite-1702
Commit: ad60979f111c9786f9da225f7c790214857d6f00
Parents: dca9e57 2a8ff1c
Author: Denis Magda <dm...@gridgain.com>
Authored: Wed Nov 4 18:02:59 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Wed Nov 4 18:02:59 2015 +0300
----------------------------------------------------------------------
.../java8/messaging/MessagingExample.java | 7 +-
.../src/main/java/org/apache/ignite/Ignite.java | 12 +-
.../apache/ignite/internal/IgniteKernal.java | 27 +-
.../affinity/GridAffinityAssignmentCache.java | 13 +
.../cache/GridCacheAffinityManager.java | 10 +
.../GridCachePartitionExchangeManager.java | 24 ++
.../processors/cache/GridCachePreloader.java | 5 +
.../cache/GridCachePreloaderAdapter.java | 5 +
.../processors/cache/GridCacheProcessor.java | 19 ++
.../dht/preloader/GridDhtForceKeysFuture.java | 14 ++
.../GridDhtPartitionsExchangeFuture.java | 6 +
.../dht/preloader/GridDhtPreloader.java | 17 ++
.../processors/job/GridJobProcessor.java | 96 ++++---
.../ignite/spi/discovery/tcp/ServerImpl.java | 21 +-
.../TcpDiscoveryClientReconnectMessage.java | 1 +
.../messages/TcpDiscoveryDiscardMessage.java | 1 +
.../GridTaskFailoverAffinityRunTest.java | 3 +
.../processors/cache/CacheNamesSelfTest.java | 69 +++++
...niteCacheClientNodeChangingTopologyTest.java | 4 +-
...gniteClientReconnectMassiveShutdownTest.java | 84 ++++---
.../tcp/TcpDiscoveryMultiThreadedTest.java | 5 +-
.../ignite/testframework/junits/IgniteMock.java | 5 +
.../junits/multijvm/IgniteProcessProxy.java | 7 +-
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
modules/rest-http/pom.xml | 6 +
.../http/jetty/GridJettyRestProtocol.java | 4 +-
.../scala/org/apache/ignite/spark/Entity.scala | 2 +-
.../org/apache/ignite/spark/IgniteRDDSpec.scala | 249 +++++++++++++++++++
.../org/apache/ignite/spark/IgniteRddSpec.scala | 249 -------------------
.../org/apache/ignite/IgniteSpringBean.java | 10 +-
30 files changed, 617 insertions(+), 360 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ad60979f/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
[10/50] [abbrv] ignite git commit: ignite-1758 Fixed issues with
client reconnect handling
Posted by ag...@apache.org.
ignite-1758 Fixed issues with client reconnect handling
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/6ea3b562
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/6ea3b562
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/6ea3b562
Branch: refs/heads/ignite-1702
Commit: 6ea3b56205de19ceac89762d9c20c3fe62ab13b9
Parents: 04964b9
Author: sboikov <sb...@gridgain.com>
Authored: Fri Oct 30 16:33:40 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Oct 30 16:33:40 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 +
.../apache/ignite/internal/IgniteKernal.java | 14 +-
.../processors/cache/GridCacheProcessor.java | 77 +++--
.../dht/preloader/GridDhtPreloader.java | 4 +-
.../CacheObjectPortableProcessorImpl.java | 9 +
.../util/nio/GridNioRecoveryDescriptor.java | 11 +-
.../communication/tcp/TcpCommunicationSpi.java | 40 ++-
.../ignite/spi/discovery/tcp/ClientImpl.java | 205 ++++++++-----
.../ignite/spi/discovery/tcp/ServerImpl.java | 213 +++++++++----
.../messages/TcpDiscoveryAbstractMessage.java | 11 +
.../messages/TcpDiscoveryNodeAddedMessage.java | 39 +++
.../IgniteClientReconnectCacheTest.java | 33 ++
.../cache/GridCacheAbstractFullApiSelfTest.java | 3 +
.../CacheGetFutureHangsSelfTest.java | 8 +
.../IgniteCacheClientReconnectTest.java | 2 +
.../distributed/IgniteCacheManyClientsTest.java | 14 +-
...gniteClientReconnectMassiveShutdownTest.java | 303 +++++++++++++++++++
.../tcp/TcpDiscoveryMultiThreadedTest.java | 285 +++++++++++++----
18 files changed, 1021 insertions(+), 253 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index 1e7d002..de7c10b 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -355,6 +355,9 @@ public final class IgniteSystemProperties {
/** Maximum size for affinity assignment history. */
public static final String IGNITE_AFFINITY_HISTORY_SIZE = "IGNITE_AFFINITY_HISTORY_SIZE";
+ /** Maximum size for discovery messages history. */
+ public static final String IGNITE_DISCOVERY_HISTORY_SIZE = "IGNITE_DISCOVERY_HISTORY_SIZE";
+
/** Number of cache operation retries in case of topology exceptions. */
public static final String IGNITE_CACHE_RETRIES_COUNT = "IGNITE_CACHE_RETRIES_COUNT";
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 4820a93..5a0fe16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -165,6 +165,7 @@ import org.apache.ignite.plugin.PluginNotFoundException;
import org.apache.ignite.plugin.PluginProvider;
import org.apache.ignite.spi.IgniteSpi;
import org.apache.ignite.spi.IgniteSpiVersionCheckException;
+import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_CONFIG_URL;
@@ -3158,10 +3159,17 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
/** {@inheritDoc} */
public void dumpDebugInfo() {
- U.warn(log, "Dumping debug info for node [id=" + ctx.localNodeId() +
+ boolean client = ctx.clientNode();
+
+ ClusterNode locNode = ctx.discovery().localNode();
+
+ UUID routerId = locNode instanceof TcpDiscoveryNode ? ((TcpDiscoveryNode)locNode).clientRouterNodeId() : null;
+
+ U.warn(log, "Dumping debug info for node [id=" + locNode.id() +
", name=" + ctx.gridName() +
- ", order=" + ctx.discovery().localNode().order() +
- ", client=" + ctx.clientNode() + ']');
+ ", order=" + locNode.order() +
+ ", client=" + client +
+ (client && routerId != null ? ", routerId=" + routerId : "") + ']');
ctx.cache().context().exchange().dumpDebugInfo();
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 5bf4ac7..301e7d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -1803,61 +1803,80 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Nullable @Override public Serializable collectDiscoveryData(UUID nodeId) {
+ boolean reconnect = ctx.localNodeId().equals(nodeId) && cachesOnDisconnect != null;
+
// Collect dynamically started caches to a single object.
- Collection<DynamicCacheChangeRequest> reqs =
- new ArrayList<>(registeredCaches.size() + registeredTemplates.size());
+ Collection<DynamicCacheChangeRequest> reqs;
- boolean reconnect = ctx.localNodeId().equals(nodeId) && cachesOnDisconnect != null;
+ Map<String, Map<UUID, Boolean>> clientNodesMap;
- Map<String, DynamicCacheDescriptor> descs = reconnect ? cachesOnDisconnect : registeredCaches;
+ if (reconnect) {
+ reqs = new ArrayList<>(caches.size());
- for (DynamicCacheDescriptor desc : descs.values()) {
- DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(), null);
+ clientNodesMap = U.newHashMap(caches.size());
- req.startCacheConfiguration(desc.cacheConfiguration());
+ for (GridCacheAdapter<?, ?> cache : caches.values()) {
+ DynamicCacheDescriptor desc = cachesOnDisconnect.get(maskNull(cache.name()));
- req.cacheType(desc.cacheType());
+ if (desc == null)
+ continue;
- req.deploymentId(desc.deploymentId());
+ DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(cache.name(), null);
- reqs.add(req);
- }
+ req.startCacheConfiguration(desc.cacheConfiguration());
- for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
- DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(), null);
+ req.cacheType(desc.cacheType());
- req.startCacheConfiguration(desc.cacheConfiguration());
+ req.deploymentId(desc.deploymentId());
- req.template(true);
+ reqs.add(req);
- req.deploymentId(desc.deploymentId());
+ Boolean nearEnabled = cache.isNear();
+
+ Map<UUID, Boolean> map = U.newHashMap(1);
+
+ map.put(nodeId, nearEnabled);
- reqs.add(req);
+ clientNodesMap.put(cache.name(), map);
+ }
}
+ else {
+ reqs = new ArrayList<>(registeredCaches.size() + registeredTemplates.size());
- DynamicCacheChangeBatch req = new DynamicCacheChangeBatch(reqs);
+ for (DynamicCacheDescriptor desc : registeredCaches.values()) {
+ DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(), null);
- Map<String, Map<UUID, Boolean>> clientNodesMap = ctx.discovery().clientNodesMap();
+ req.startCacheConfiguration(desc.cacheConfiguration());
- if (reconnect) {
- clientNodesMap = U.newHashMap(caches.size());
+ req.cacheType(desc.cacheType());
- for (GridCacheAdapter<?, ?> cache : caches.values()) {
- Boolean nearEnabled = cache.isNear();
+ req.deploymentId(desc.deploymentId());
- Map<UUID, Boolean> map = U.newHashMap(1);
+ reqs.add(req);
+ }
- map.put(nodeId, nearEnabled);
+ for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
+ DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(desc.cacheConfiguration().getName(), null);
- clientNodesMap.put(cache.name(), map);
+ req.startCacheConfiguration(desc.cacheConfiguration());
+
+ req.template(true);
+
+ req.deploymentId(desc.deploymentId());
+
+ reqs.add(req);
}
+
+ clientNodesMap = ctx.discovery().clientNodesMap();
}
- req.clientNodes(clientNodesMap);
+ DynamicCacheChangeBatch batch = new DynamicCacheChangeBatch(reqs);
+
+ batch.clientNodes(clientNodesMap);
- req.clientReconnect(reconnect);
+ batch.clientReconnect(reconnect);
- return req;
+ return batch;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/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 83867f4..356a85b 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
@@ -192,9 +192,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
ClusterNode loc = cctx.localNode();
- long startTime = loc.metrics().getStartTime();
-
- assert startTime > 0;
+ assert loc.metrics().getStartTime() > 0;
final long startTopVer = loc.order();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
index 2de9d84..f0319aa 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java
@@ -39,6 +39,8 @@ import javax.cache.processor.EntryProcessor;
import javax.cache.processor.MutableEntry;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.portable.api.IgnitePortables;
import org.apache.ignite.cache.CacheEntryEventSerializableFilter;
import org.apache.ignite.cluster.ClusterNode;
@@ -75,6 +77,7 @@ import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.tostring.GridToStringExclude;
import org.apache.ignite.internal.util.typedef.C1;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.CU;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -371,6 +374,12 @@ public class CacheObjectPortableProcessorImpl extends IgniteCacheObjectProcessor
else
throw e;
}
+ catch (CacheException e) {
+ if (X.hasCause(e, ClusterTopologyCheckedException.class, ClusterTopologyException.class))
+ continue;
+ else
+ throw e;
+ }
break;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
index 88837de..5647239 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/nio/GridNioRecoveryDescriptor.java
@@ -193,14 +193,19 @@ public class GridNioRecoveryDescriptor {
/**
* Node left callback.
+ *
+ * @return {@code False} if descriptor is reserved.
*/
- public void onNodeLeft() {
+ public boolean onNodeLeft() {
GridNioFuture<?>[] futs = null;
synchronized (this) {
nodeLeft = true;
- if (!reserved && !msgFuts.isEmpty()) {
+ if (reserved)
+ return false;
+
+ if (!msgFuts.isEmpty()) {
futs = msgFuts.toArray(new GridNioFuture<?>[msgFuts.size()]);
msgFuts.clear();
@@ -209,6 +214,8 @@ public class GridNioRecoveryDescriptor {
if (futs != null)
completeOnNodeLeft(futs);
+
+ return true;
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 5ea2c02..e8bd8a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -61,6 +61,7 @@ import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteInterruptedCheckedException;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
import org.apache.ignite.internal.util.GridConcurrentFactory;
import org.apache.ignite.internal.util.GridSpinReadWriteLock;
@@ -1358,7 +1359,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
/** {@inheritDoc} */
@Override public int getOutboundMessagesQueueSize() {
- return nioSrvr.outboundMessagesQueueSize();
+ GridNioServer<Message> srv = nioSrvr;
+
+ return srv != null ? srv.outboundMessagesQueueSize() : 0;
}
/** {@inheritDoc} */
@@ -1870,25 +1873,25 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
*
* @param node Destination node.
* @param msg Message to send.
- * @param ackClosure Ack closure.
+ * @param ackC Ack closure.
* @throws org.apache.ignite.spi.IgniteSpiException Thrown in case of any error during sending the message.
* Note that this is not guaranteed that failed communication will result
* in thrown exception as this is dependant on SPI implementation.
*/
- public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC)
throws IgniteSpiException {
- sendMessage0(node, msg, ackClosure);
+ sendMessage0(node, msg, ackC);
}
/**
* @param node Destination node.
* @param msg Message to send.
- * @param ackClosure Ack closure.
+ * @param ackC Ack closure.
* @throws org.apache.ignite.spi.IgniteSpiException Thrown in case of any error during sending the message.
* Note that this is not guaranteed that failed communication will result
* in thrown exception as this is dependant on SPI implementation.
*/
- private void sendMessage0(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackClosure)
+ private void sendMessage0(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC)
throws IgniteSpiException {
assert node != null;
assert msg != null;
@@ -1896,13 +1899,13 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
if (log.isTraceEnabled())
log.trace("Sending message with ack to node [node=" + node + ", msg=" + msg + ']');
- ClusterNode localNode = getLocalNode();
+ ClusterNode locNode = getLocalNode();
- if (localNode == null)
+ if (locNode == null)
throw new IgniteSpiException("Local node has not been started or fully initialized " +
"[isStopping=" + getSpiContext().isStopping() + ']');
- if (node.id().equals(localNode.id()))
+ if (node.id().equals(locNode.id()))
notifyListener(node.id(), msg, NOOP);
else {
GridCommunicationClient client = null;
@@ -1915,10 +1918,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
UUID nodeId = null;
- if (!client.async() && !localNode.version().equals(node.version()))
+ if (!client.async() && !locNode.version().equals(node.version()))
nodeId = node.id();
- retry = client.sendMessage(nodeId, msg, ackClosure);
+ retry = client.sendMessage(nodeId, msg, ackC);
client.release();
@@ -2292,6 +2295,15 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
return null;
}
+ if (getSpiContext().node(node.id()) == null) {
+ recoveryDesc.release();
+
+ U.closeQuiet(ch);
+
+ throw new ClusterTopologyCheckedException("Failed to send message, " +
+ "node left cluster: " + node);
+ }
+
long rcvCnt = -1;
SSLEngine sslEngine = null;
@@ -3100,10 +3112,10 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter
assert !left.isEmpty();
for (ClientKey id : left) {
- GridNioRecoveryDescriptor recoverySnd = recoveryDescs.remove(id);
+ GridNioRecoveryDescriptor recoverySnd = recoveryDescs.get(id);
- if (recoverySnd != null)
- recoverySnd.onNodeLeft();
+ if (recoverySnd != null && recoverySnd.onNodeLeft())
+ recoveryDescs.remove(id);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index e4c29db..a4619c6 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -270,8 +270,6 @@ class ClientImpl extends TcpDiscoveryImpl {
/** {@inheritDoc} */
@Override public void spiStop() throws IgniteSpiException {
- timer.cancel();
-
if (msgWorker != null && msgWorker.isAlive()) { // Should always be alive
msgWorker.addMessage(SPI_STOP);
@@ -297,6 +295,8 @@ class ClientImpl extends TcpDiscoveryImpl {
U.join(sockWriter, log);
U.join(sockReader, log);
+ timer.cancel();
+
spi.printStopInfo();
}
@@ -461,7 +461,8 @@ class ClientImpl extends TcpDiscoveryImpl {
* @see TcpDiscoverySpi#joinTimeout
*/
@SuppressWarnings("BusyWait")
- @Nullable private T2<Socket, Boolean> joinTopology(boolean recon, long timeout) throws IgniteSpiException, InterruptedException {
+ @Nullable private T2<SocketStream, Boolean> joinTopology(boolean recon, long timeout)
+ throws IgniteSpiException, InterruptedException {
Collection<InetSocketAddress> addrs = null;
long startTime = U.currentTimeMillis();
@@ -501,7 +502,7 @@ class ClientImpl extends TcpDiscoveryImpl {
InetSocketAddress addr = it.next();
- T3<Socket, Integer, Boolean> sockAndRes = sendJoinRequest(recon, addr);
+ T3<SocketStream, Integer, Boolean> sockAndRes = sendJoinRequest(recon, addr);
if (sockAndRes == null) {
it.remove();
@@ -511,11 +512,11 @@ class ClientImpl extends TcpDiscoveryImpl {
assert sockAndRes.get1() != null && sockAndRes.get2() != null : sockAndRes;
- Socket sock = sockAndRes.get1();
+ Socket sock = sockAndRes.get1().socket();
switch (sockAndRes.get2()) {
case RES_OK:
- return new T2<>(sock, sockAndRes.get3());
+ return new T2<>(sockAndRes.get1(), sockAndRes.get3());
case RES_CONTINUE_JOIN:
case RES_WAIT:
@@ -548,7 +549,7 @@ class ClientImpl extends TcpDiscoveryImpl {
* @param addr Address.
* @return Socket, connect response and client acknowledge support flag.
*/
- @Nullable private T3<Socket, Integer, Boolean> sendJoinRequest(boolean recon, InetSocketAddress addr) {
+ @Nullable private T3<SocketStream, Integer, Boolean> sendJoinRequest(boolean recon, InetSocketAddress addr) {
assert addr != null;
if (log.isDebugEnabled())
@@ -621,7 +622,8 @@ class ClientImpl extends TcpDiscoveryImpl {
log.debug("Message has been sent to address [msg=" + msg + ", addr=" + addr +
", rmtNodeId=" + rmtNodeId + ']');
- return new T3<>(sock, spi.readReceipt(sock, timeoutHelper.nextTimeoutChunk(ackTimeout0)),
+ return new T3<>(new SocketStream(sock),
+ spi.readReceipt(sock, timeoutHelper.nextTimeoutChunk(ackTimeout0)),
res.clientAck());
}
catch (IOException | IgniteCheckedException e) {
@@ -708,7 +710,7 @@ class ClientImpl extends TcpDiscoveryImpl {
Collection<ClusterNode> top = topHist.get(topVer);
- assert top != null : msg;
+ assert top != null : "Failed to find topology history [msg=" + msg + ", hist=" + topHist + ']';
return top;
}
@@ -765,7 +767,10 @@ class ClientImpl extends TcpDiscoveryImpl {
/** {@inheritDoc} */
@Override public void brakeConnection() {
- U.closeQuiet(msgWorker.currSock);
+ SocketStream sockStream = msgWorker.currSock;
+
+ if (sockStream != null)
+ U.closeQuiet(sockStream.socket());
}
/** {@inheritDoc} */
@@ -826,7 +831,7 @@ class ClientImpl extends TcpDiscoveryImpl {
private final Object mux = new Object();
/** */
- private Socket sock;
+ private SocketStream sockStream;
/** */
private UUID rmtNodeId;
@@ -838,12 +843,12 @@ class ClientImpl extends TcpDiscoveryImpl {
}
/**
- * @param sock Socket.
+ * @param sockStream Socket.
* @param rmtNodeId Rmt node id.
*/
- public void setSocket(Socket sock, UUID rmtNodeId) {
+ public void setSocket(SocketStream sockStream, UUID rmtNodeId) {
synchronized (mux) {
- this.sock = sock;
+ this.sockStream = sockStream;
this.rmtNodeId = rmtNodeId;
@@ -854,22 +859,24 @@ class ClientImpl extends TcpDiscoveryImpl {
/** {@inheritDoc} */
@Override protected void body() throws InterruptedException {
while (!isInterrupted()) {
- Socket sock;
+ SocketStream sockStream;
UUID rmtNodeId;
synchronized (mux) {
- if (this.sock == null) {
+ if (this.sockStream == null) {
mux.wait();
continue;
}
- sock = this.sock;
+ sockStream = this.sockStream;
rmtNodeId = this.rmtNodeId;
}
+ Socket sock = sockStream.socket();
+
try {
- InputStream in = new BufferedInputStream(sock.getInputStream());
+ InputStream in = sockStream.stream();
sock.setKeepAlive(true);
sock.setTcpNoDelay(true);
@@ -912,18 +919,14 @@ class ClientImpl extends TcpDiscoveryImpl {
boolean ack = msg instanceof TcpDiscoveryClientAckResponse;
- if (!ack) {
- if (spi.ensured(msg) && joinLatch.getCount() == 0L)
- lastMsgId = msg.id();
-
+ if (!ack)
msgWorker.addMessage(msg);
- }
else
sockWriter.ackReceived((TcpDiscoveryClientAckResponse)msg);
}
}
catch (IOException e) {
- msgWorker.addMessage(new SocketClosedMessage(sock));
+ msgWorker.addMessage(new SocketClosedMessage(sockStream));
if (log.isDebugEnabled())
U.error(log, "Connection failed [sock=" + sock + ", locNodeId=" + getLocalNodeId() + ']', e);
@@ -932,8 +935,8 @@ class ClientImpl extends TcpDiscoveryImpl {
U.closeQuiet(sock);
synchronized (mux) {
- if (this.sock == sock) {
- this.sock = null;
+ if (this.sockStream == sockStream) {
+ this.sockStream = null;
this.rmtNodeId = null;
}
}
@@ -1125,7 +1128,7 @@ class ClientImpl extends TcpDiscoveryImpl {
*/
private class Reconnector extends IgniteSpiThread {
/** */
- private volatile Socket sock;
+ private volatile SocketStream sockStream;
/** */
private boolean clientAck;
@@ -1148,7 +1151,10 @@ class ClientImpl extends TcpDiscoveryImpl {
public void cancel() {
interrupt();
- U.closeQuiet(sock);
+ SocketStream sockStream = this.sockStream;
+
+ if (sockStream != null)
+ U.closeQuiet(sockStream.socket());
}
/** {@inheritDoc} */
@@ -1166,24 +1172,26 @@ class ClientImpl extends TcpDiscoveryImpl {
try {
while (true) {
- T2<Socket, Boolean> joinRes = joinTopology(true, timeout);
+ T2<SocketStream, Boolean> joinRes = joinTopology(true, timeout);
if (joinRes == null) {
if (join) {
joinError(new IgniteSpiException("Join process timed out, connection failed and " +
"failed to reconnect (consider increasing 'joinTimeout' configuration property) " +
- "[joinTimeout=" + spi.joinTimeout + ", sock=" + sock + ']'));
+ "[joinTimeout=" + spi.joinTimeout + ']'));
}
else
U.error(log, "Failed to reconnect to cluster (consider increasing 'networkTimeout'" +
- " configuration property) [networkTimeout=" + spi.netTimeout + ", sock=" + sock + ']');
+ " configuration property) [networkTimeout=" + spi.netTimeout + ']');
return;
}
- sock = joinRes.get1();
+ sockStream = joinRes.get1();
clientAck = joinRes.get2();
+ Socket sock = sockStream.socket();
+
if (isInterrupted())
throw new InterruptedException();
@@ -1194,7 +1202,7 @@ class ClientImpl extends TcpDiscoveryImpl {
sock.setSoTimeout((int)spi.netTimeout);
- InputStream in = new BufferedInputStream(sock.getInputStream());
+ InputStream in = sockStream.stream();
sock.setKeepAlive(true);
sock.setTcpNoDelay(true);
@@ -1264,11 +1272,16 @@ class ClientImpl extends TcpDiscoveryImpl {
catch (IOException | IgniteCheckedException e) {
err = e;
+ success = false;
+
U.error(log, "Failed to reconnect", e);
}
finally {
if (!success) {
- U.closeQuiet(sock);
+ SocketStream sockStream = this.sockStream;
+
+ if (sockStream != null)
+ U.closeQuiet(sockStream.socket());
if (join)
joinError(new IgniteSpiException("Failed to connect to cluster, connection failed and failed " +
@@ -1288,10 +1301,7 @@ class ClientImpl extends TcpDiscoveryImpl {
private final BlockingDeque<Object> queue = new LinkedBlockingDeque<>();
/** */
- private Socket currSock;
-
- /** Indicates that pending messages are currently processed. */
- private boolean pending;
+ private SocketStream currSock;
/** */
private Reconnector reconnector;
@@ -1338,11 +1348,13 @@ class ClientImpl extends TcpDiscoveryImpl {
}
}
else if (msg == SPI_STOP) {
+ boolean connected = state == CONNECTED;
+
state = STOPPED;
assert spi.getSpiContext().isStopping();
- if (currSock != null) {
+ if (connected && currSock != null) {
TcpDiscoveryAbstractMessage leftMsg = new TcpDiscoveryNodeLeftMessage(getLocalNodeId());
leftMsg.client(true);
@@ -1467,7 +1479,10 @@ class ClientImpl extends TcpDiscoveryImpl {
}
}
finally {
- U.closeQuiet(currSock);
+ SocketStream currSock = this.currSock;
+
+ if (currSock != null)
+ U.closeQuiet(currSock.socket());
if (joinLatch.getCount() > 0)
joinError(new IgniteSpiException("Some error in join process.")); // This should not occur.
@@ -1490,7 +1505,7 @@ class ClientImpl extends TcpDiscoveryImpl {
joinCnt++;
- T2<Socket, Boolean> joinRes = joinTopology(false, spi.joinTimeout);
+ T2<SocketStream, Boolean> joinRes = joinTopology(false, spi.joinTimeout);
if (joinRes == null) {
if (join)
@@ -1506,7 +1521,7 @@ class ClientImpl extends TcpDiscoveryImpl {
currSock = joinRes.get1();
- sockWriter.setSocket(joinRes.get1(), joinRes.get2());
+ sockWriter.setSocket(joinRes.get1().socket(), joinRes.get2());
if (spi.joinTimeout > 0) {
final int joinCnt0 = joinCnt;
@@ -1551,6 +1566,9 @@ class ClientImpl extends TcpDiscoveryImpl {
processPingRequest();
spi.stats.onMessageProcessingFinished(msg);
+
+ if (spi.ensured(msg) && state == CONNECTED)
+ lastMsgId = msg.id();
}
/**
@@ -1604,8 +1622,10 @@ class ClientImpl extends TcpDiscoveryImpl {
if (msg.topologyHistory() != null)
topHist.putAll(msg.topologyHistory());
}
- else if (log.isDebugEnabled())
- log.debug("Discarding node added message with empty topology: " + msg);
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Discarding node added message with empty topology: " + msg);
+ }
}
else if (log.isDebugEnabled())
log.debug("Discarding node added message (this message has already been processed) " +
@@ -1625,8 +1645,10 @@ class ClientImpl extends TcpDiscoveryImpl {
spi.onExchange(newNodeId, newNodeId, data, null);
}
}
- else if (log.isDebugEnabled())
- log.debug("Ignore topology message, local node not added to topology: " + msg);
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Ignore topology message, local node not added to topology: " + msg);
+ }
}
}
@@ -1653,6 +1675,11 @@ class ClientImpl extends TcpDiscoveryImpl {
locNode.order(topVer);
+ for (Iterator<Long> it = topHist.keySet().iterator(); it.hasNext();) {
+ if (it.next() >= topVer)
+ it.remove();
+ }
+
Collection<ClusterNode> nodes = updateTopologyHistory(topVer, msg);
notifyDiscovery(EVT_NODE_JOINED, topVer, locNode, nodes);
@@ -1712,7 +1739,7 @@ class ClientImpl extends TcpDiscoveryImpl {
assert top != null && top.contains(node) : "Topology does not contain node [msg=" + msg +
", node=" + node + ", top=" + top + ']';
- if (!pending && joinLatch.getCount() > 0) {
+ if (state != CONNECTED) {
if (log.isDebugEnabled())
log.debug("Discarding node add finished message (join process is not finished): " + msg);
@@ -1725,8 +1752,10 @@ class ClientImpl extends TcpDiscoveryImpl {
spi.stats.onNodeJoined();
}
}
- else if (log.isDebugEnabled())
- log.debug("Ignore topology message, local node not added to topology: " + msg);
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Ignore topology message, local node not added to topology: " + msg);
+ }
}
}
@@ -1756,7 +1785,7 @@ class ClientImpl extends TcpDiscoveryImpl {
Collection<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
- if (!pending && joinLatch.getCount() > 0) {
+ if (state != CONNECTED) {
if (log.isDebugEnabled())
log.debug("Discarding node left message (join process is not finished): " + msg);
@@ -1767,8 +1796,10 @@ class ClientImpl extends TcpDiscoveryImpl {
spi.stats.onNodeLeft();
}
- else if (log.isDebugEnabled())
- log.debug("Ignore topology message, local node not added to topology: " + msg);
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Ignore topology message, local node not added to topology: " + msg);
+ }
}
}
@@ -1809,7 +1840,7 @@ class ClientImpl extends TcpDiscoveryImpl {
Collection<ClusterNode> top = updateTopologyHistory(msg.topologyVersion(), msg);
- if (!pending && joinLatch.getCount() > 0) {
+ if (state != CONNECTED) {
if (log.isDebugEnabled())
log.debug("Discarding node failed message (join process is not finished): " + msg);
@@ -1875,25 +1906,18 @@ class ClientImpl extends TcpDiscoveryImpl {
if (reconnector != null) {
assert msg.success() : msg;
- currSock = reconnector.sock;
+ currSock = reconnector.sockStream;
- sockWriter.setSocket(currSock, reconnector.clientAck);
+ sockWriter.setSocket(currSock.socket(), reconnector.clientAck);
sockReader.setSocket(currSock, locNode.clientRouterNodeId());
reconnector = null;
- pending = true;
-
- try {
- for (TcpDiscoveryAbstractMessage pendingMsg : msg.pendingMessages()) {
- if (log.isDebugEnabled())
- log.debug("Process pending message on reconnect [msg=" + pendingMsg + ']');
+ for (TcpDiscoveryAbstractMessage pendingMsg : msg.pendingMessages()) {
+ if (log.isDebugEnabled())
+ log.debug("Process pending message on reconnect [msg=" + pendingMsg + ']');
- processDiscoveryMessage(pendingMsg);
- }
- }
- finally {
- pending = false;
+ processDiscoveryMessage(pendingMsg);
}
}
else {
@@ -1921,7 +1945,7 @@ class ClientImpl extends TcpDiscoveryImpl {
* @param msg Message.
*/
private void processCustomMessage(TcpDiscoveryCustomEventMessage msg) {
- if (msg.verified() && state == CONNECTED) {
+ if (state == CONNECTED) {
DiscoverySpiListener lsnr = spi.lsnr;
if (lsnr != null) {
@@ -2048,13 +2072,56 @@ class ClientImpl extends TcpDiscoveryImpl {
*/
private static class SocketClosedMessage {
/** */
+ private final SocketStream sock;
+
+ /**
+ * @param sock Socket.
+ */
+ private SocketClosedMessage(SocketStream sock) {
+ this.sock = sock;
+ }
+ }
+
+ /**
+ *
+ */
+ private static class SocketStream {
+ /** */
private final Socket sock;
+ /** */
+ private final InputStream in;
+
/**
* @param sock Socket.
+ * @throws IOException If failed to create stream.
*/
- private SocketClosedMessage(Socket sock) {
+ public SocketStream(Socket sock) throws IOException {
+ assert sock != null;
+
this.sock = sock;
+
+ this.in = new BufferedInputStream(sock.getInputStream());
+ }
+
+ /**
+ * @return Socket.
+ */
+ Socket socket() {
+ return sock;
+
+ }
+
+ /**
+ * @return Socket input stream.
+ */
+ InputStream stream() {
+ return in;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ return sock.toString();
}
}
@@ -2077,4 +2144,4 @@ class ClientImpl extends TcpDiscoveryImpl {
/** */
STOPPED
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index b8df846..ee9f818 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -126,7 +126,9 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusCheckMessa
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
+import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCOVERY_HISTORY_SIZE;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID;
+import static org.apache.ignite.IgniteSystemProperties.getInteger;
import static org.apache.ignite.events.EventType.EVT_NODE_FAILED;
import static org.apache.ignite.events.EventType.EVT_NODE_JOINED;
import static org.apache.ignite.events.EventType.EVT_NODE_LEFT;
@@ -154,6 +156,9 @@ import static org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryStatusChe
@SuppressWarnings("All")
class ServerImpl extends TcpDiscoveryImpl {
/** */
+ private static final int ENSURED_MSG_HIST_SIZE = getInteger(IGNITE_DISCOVERY_HISTORY_SIZE, 1024 * 10);
+
+ /** */
private final ThreadPoolExecutor utilityPool = new ThreadPoolExecutor(0, 1, 2000, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>());
@@ -1250,9 +1255,11 @@ class ServerImpl extends TcpDiscoveryImpl {
lsnr.onDiscovery(type, topVer, node, top, hist, null);
}
- else if (log.isDebugEnabled())
- log.debug("Skipped discovery notification [node=" + node + ", spiState=" + spiState +
- ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
+ else {
+ if (log.isDebugEnabled())
+ log.debug("Skipped discovery notification [node=" + node + ", spiState=" + spiState +
+ ", type=" + U.gridEventName(type) + ", topVer=" + topVer + ']');
+ }
}
/**
@@ -1447,6 +1454,12 @@ class ServerImpl extends TcpDiscoveryImpl {
tmp = U.arrayList(readers);
}
+ for (ClientMessageWorker msgWorker : clientMsgWorkers.values()) {
+ U.interrupt(msgWorker);
+
+ U.join(msgWorker, log);
+ }
+
U.interrupt(tmp);
U.joinThreads(tmp, log);
@@ -1744,22 +1757,36 @@ class ServerImpl extends TcpDiscoveryImpl {
* Discovery messages history used for client reconnect.
*/
private class EnsuredMessageHistory {
- /** */
- private static final int MAX = 1024;
-
/** Pending messages. */
- private final ArrayDeque<TcpDiscoveryAbstractMessage> msgs = new ArrayDeque<>(MAX * 2);
+ private final GridBoundedLinkedHashSet<TcpDiscoveryAbstractMessage>
+ msgs = new GridBoundedLinkedHashSet<>(ENSURED_MSG_HIST_SIZE);
/**
* @param msg Adds message.
*/
void add(TcpDiscoveryAbstractMessage msg) {
- assert spi.ensured(msg) : msg;
+ assert spi.ensured(msg) && msg.verified() : msg;
+
+ if (msg instanceof TcpDiscoveryNodeAddedMessage) {
+ TcpDiscoveryNodeAddedMessage addedMsg = (TcpDiscoveryNodeAddedMessage)msg;
- msgs.addLast(msg);
+ TcpDiscoveryNode node = addedMsg.node();
- while (msgs.size() > MAX)
- msgs.pollFirst();
+ if (node.isClient() && !msgs.contains(msg)) {
+ Collection<TcpDiscoveryNode> allNodes = ring.allNodes();
+
+ Collection<TcpDiscoveryNode> top = new ArrayList<>(allNodes.size());
+
+ for (TcpDiscoveryNode n0 : allNodes) {
+ if (n0.internalOrder() != 0 && n0.internalOrder() < node.internalOrder())
+ top.add(n0);
+ }
+
+ addedMsg.clientTopology(top);
+ }
+ }
+
+ msgs.add(msg);
}
/**
@@ -1782,11 +1809,11 @@ class ServerImpl extends TcpDiscoveryImpl {
for (TcpDiscoveryAbstractMessage msg : msgs) {
if (msg instanceof TcpDiscoveryNodeAddedMessage) {
- if (node.id().equals(((TcpDiscoveryNodeAddedMessage) msg).node().id()))
+ if (node.id().equals(((TcpDiscoveryNodeAddedMessage)msg).node().id()))
res = new ArrayList<>(msgs.size());
}
- if (res != null && msg.verified())
+ if (res != null)
res.add(prepare(msg, node.id()));
}
@@ -1812,7 +1839,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (msg.id().equals(lastMsgId))
skip = false;
}
- else if (msg.verified())
+ else
cp.add(prepare(msg, node.id()));
}
@@ -1820,7 +1847,7 @@ class ServerImpl extends TcpDiscoveryImpl {
if (log.isDebugEnabled()) {
if (cp == null)
- log.debug("Failed to find messages history [node=" + node + ", lastMsgId" + lastMsgId + ']');
+ log.debug("Failed to find messages history [node=" + node + ", lastMsgId=" + lastMsgId + ']');
else
log.debug("Found messages history [node=" + node + ", hist=" + cp + ']');
}
@@ -1835,8 +1862,21 @@ class ServerImpl extends TcpDiscoveryImpl {
* @return Prepared message.
*/
private TcpDiscoveryAbstractMessage prepare(TcpDiscoveryAbstractMessage msg, UUID destNodeId) {
- if (msg instanceof TcpDiscoveryNodeAddedMessage)
- prepareNodeAddedMessage(msg, destNodeId, null, null, null);
+ if (msg instanceof TcpDiscoveryNodeAddedMessage) {
+ TcpDiscoveryNodeAddedMessage addedMsg = (TcpDiscoveryNodeAddedMessage)msg;
+
+ if (addedMsg.node().id().equals(destNodeId)) {
+ assert addedMsg.clientTopology() != null : addedMsg;
+
+ TcpDiscoveryNodeAddedMessage msg0 = new TcpDiscoveryNodeAddedMessage(addedMsg);
+
+ prepareNodeAddedMessage(msg0, destNodeId, null, null, null);
+
+ msg0.topology(addedMsg.clientTopology());
+
+ return msg0;
+ }
+ }
return msg;
}
@@ -2132,7 +2172,7 @@ class ServerImpl extends TcpDiscoveryImpl {
else
assert false : "Unknown message type: " + msg.getClass().getSimpleName();
- if (spi.ensured(msg))
+ if (spi.ensured(msg) && redirectToClients(msg))
msgHist.add(msg);
if (msg.senderNodeId() != null && !msg.senderNodeId().equals(getLocalNodeId())) {
@@ -2161,19 +2201,9 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
- * Sends message across the ring.
- *
- * @param msg Message to send
+ * @param msg Message.
*/
- @SuppressWarnings({"BreakStatementWithLabel", "LabeledStatement", "ContinueStatementWithLabel"})
- private void sendMessageAcrossRing(TcpDiscoveryAbstractMessage msg) {
- assert msg != null;
-
- assert ring.hasRemoteNodes();
-
- for (IgniteInClosure<TcpDiscoveryAbstractMessage> msgLsnr : spi.sendMsgLsnrs)
- msgLsnr.apply(msg);
-
+ private void sendMessageToClients(TcpDiscoveryAbstractMessage msg) {
if (redirectToClients(msg)) {
byte[] marshalledMsg = null;
@@ -2193,9 +2223,28 @@ class ServerImpl extends TcpDiscoveryImpl {
msgClone = msg;
}
+ prepareNodeAddedMessage(msgClone, clientMsgWorker.clientNodeId, null, null, null);
+
clientMsgWorker.addMessage(msgClone);
}
}
+ }
+
+ /**
+ * Sends message across the ring.
+ *
+ * @param msg Message to send
+ */
+ @SuppressWarnings({"BreakStatementWithLabel", "LabeledStatement", "ContinueStatementWithLabel"})
+ private void sendMessageAcrossRing(TcpDiscoveryAbstractMessage msg) {
+ assert msg != null;
+
+ assert ring.hasRemoteNodes();
+
+ for (IgniteInClosure<TcpDiscoveryAbstractMessage> msgLsnr : spi.sendMsgLsnrs)
+ msgLsnr.apply(msg);
+
+ sendMessageToClients(msg);
Collection<TcpDiscoveryNode> failedNodes;
@@ -2810,7 +2859,7 @@ class ServerImpl extends TcpDiscoveryImpl {
"[clientNode=" + existingNode + ", msg=" + reconMsg + ']');
}
else {
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(reconMsg))
sendMessageAcrossRing(reconMsg);
}
}
@@ -3052,8 +3101,11 @@ class ServerImpl extends TcpDiscoveryImpl {
nodeAddedMsg.client(msg.client());
processNodeAddedMessage(nodeAddedMsg);
+
+ if (nodeAddedMsg.verified())
+ msgHist.add(nodeAddedMsg);
}
- else if (ring.hasRemoteNodes())
+ else if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
@@ -3155,8 +3207,13 @@ class ServerImpl extends TcpDiscoveryImpl {
log.debug("Failing reconnecting client node because failed to restore pending " +
"messages [locNodeId=" + locNodeId + ", clientNodeId=" + nodeId + ']');
- processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
- node.id(), node.internalOrder()));
+ TcpDiscoveryNodeFailedMessage nodeFailedMsg = new TcpDiscoveryNodeFailedMessage(locNodeId,
+ node.id(), node.internalOrder());
+
+ processNodeFailedMessage(nodeFailedMsg);
+
+ if (nodeFailedMsg.verified())
+ msgHist.add(nodeFailedMsg);
}
}
else if (log.isDebugEnabled())
@@ -3172,12 +3229,12 @@ class ServerImpl extends TcpDiscoveryImpl {
locNodeId + ", clientNodeId=" + nodeId + ']');
}
else {
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
}
else {
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
}
@@ -3239,6 +3296,9 @@ class ServerImpl extends TcpDiscoveryImpl {
processNodeAddFinishedMessage(addFinishMsg);
+ if (addFinishMsg.verified())
+ msgHist.add(addFinishMsg);
+
addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
return;
@@ -3249,7 +3309,7 @@ class ServerImpl extends TcpDiscoveryImpl {
else if (!locNodeId.equals(node.id()) && ring.node(node.id()) != null) {
// Local node already has node from message in local topology.
// Just pass it to coordinator via the ring.
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
if (log.isDebugEnabled())
@@ -3437,7 +3497,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
@@ -3572,7 +3632,7 @@ class ServerImpl extends TcpDiscoveryImpl {
notifyDiscovery(EVT_NODE_JOINED, topVer, locNode);
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
checkPendingCustomMessages();
@@ -3740,7 +3800,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- if (ring.hasRemoteNodes()) {
+ if (sendMessageToRemotes(msg)) {
try {
sendMessageAcrossRing(msg);
}
@@ -3761,6 +3821,19 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
+ * @param msg Message to send.
+ * @return {@code True} if message should be send across the ring.
+ */
+ private boolean sendMessageToRemotes(TcpDiscoveryAbstractMessage msg) {
+ if (ring.hasRemoteNodes())
+ return true;
+
+ sendMessageToClients(msg);
+
+ return false;
+ }
+
+ /**
* Processes node failed message.
*
* @param msg Node failed message.
@@ -3892,7 +3965,7 @@ class ServerImpl extends TcpDiscoveryImpl {
spi.stats.onNodeFailed();
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
else {
if (log.isDebugEnabled())
@@ -4032,7 +4105,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
@@ -4098,7 +4171,7 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
- if (ring.hasRemoteNodes()) {
+ if (sendMessageToRemotes(msg)) {
if ((locNodeId.equals(msg.creatorNodeId()) && msg.senderNodeId() == null ||
!hasMetrics(msg, locNodeId)) && spiStateCopy() == CONNECTED) {
// Message is on its first ring or just created on coordinator.
@@ -4135,16 +4208,22 @@ class ServerImpl extends TcpDiscoveryImpl {
failedNode = failedNodes.contains(clientNode);
}
- if (!failedNode)
- processNodeFailedMessage(new TcpDiscoveryNodeFailedMessage(locNodeId,
- clientNode.id(), clientNode.internalOrder()));
+ if (!failedNode) {
+ TcpDiscoveryNodeFailedMessage nodeFailedMsg = new TcpDiscoveryNodeFailedMessage(
+ locNodeId, clientNode.id(), clientNode.internalOrder());
+
+ processNodeFailedMessage(nodeFailedMsg);
+
+ if (nodeFailedMsg.verified())
+ msgHist.add(nodeFailedMsg);
+ }
}
}
}
}
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
else {
@@ -4351,7 +4430,7 @@ class ServerImpl extends TcpDiscoveryImpl {
notifyDiscoveryListener(msg);
}
- if (ring.hasRemoteNodes())
+ if (sendMessageToRemotes(msg))
sendMessageAcrossRing(msg);
}
}
@@ -4363,8 +4442,12 @@ class ServerImpl extends TcpDiscoveryImpl {
if (joiningNodes.isEmpty() && isLocalNodeCoordinator()) {
TcpDiscoveryCustomEventMessage msg;
- while ((msg = pendingCustomMsgs.poll()) != null)
+ while ((msg = pendingCustomMsgs.poll()) != null) {
processCustomMessage(msg);
+
+ if (msg.verified())
+ msgHist.add(msg);
+ }
}
}
@@ -5293,19 +5376,14 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
else {
- try {
- if (log.isDebugEnabled())
- log.debug("Redirecting message to client [sock=" + sock + ", locNodeId="
- + getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
+ if (log.isDebugEnabled())
+ log.debug("Redirecting message to client [sock=" + sock + ", locNodeId="
+ + getLocalNodeId() + ", rmtNodeId=" + clientNodeId + ", msg=" + msg + ']');
- prepareNodeAddedMessage(msg, clientNodeId, null, null, null);
+ assert topologyInitialized(msg) : msg;
- writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
- spi.failureDetectionTimeout() : spi.getSocketTimeout());
- }
- finally {
- clearNodeAddedMessage(msg);
- }
+ writeToSocket(sock, msg, spi.failureDetectionTimeoutEnabled() ?
+ spi.failureDetectionTimeout() : spi.getSocketTimeout());
}
}
catch (IgniteCheckedException | IOException e) {
@@ -5325,6 +5403,21 @@ class ServerImpl extends TcpDiscoveryImpl {
}
/**
+ * @param msg Message.
+ * @return {@code True} if topology initialized.
+ */
+ private boolean topologyInitialized(TcpDiscoveryAbstractMessage msg) {
+ if (msg instanceof TcpDiscoveryNodeAddedMessage) {
+ TcpDiscoveryNodeAddedMessage addedMsg = (TcpDiscoveryNodeAddedMessage)msg;
+
+ if (clientNodeId.equals(addedMsg.node().id()))
+ return addedMsg.topology() != null;
+ }
+
+ return true;
+ }
+
+ /**
* @param res Ping result.
*/
public void pingResult(boolean res) {
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
index c50f791..875d18e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryAbstractMessage.java
@@ -79,6 +79,17 @@ public abstract class TcpDiscoveryAbstractMessage implements Serializable {
}
/**
+ * @param msg Message.
+ */
+ protected TcpDiscoveryAbstractMessage(TcpDiscoveryAbstractMessage msg) {
+ this.id = msg.id;
+ this.verifierNodeId = msg.verifierNodeId;
+ this.topVer = msg.topVer;
+ this.flags = msg.flags;
+ this.pendingIdx = msg.pendingIdx;
+ }
+
+ /**
* Gets creator node.
*
* @return Creator node ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
index 5a7146d..6f8e14e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryNodeAddedMessage.java
@@ -55,6 +55,10 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
@GridToStringInclude
private Collection<TcpDiscoveryNode> top;
+ /** */
+ @GridToStringInclude
+ private transient Collection<TcpDiscoveryNode> clientTop;
+
/** Topology snapshots history. */
private Map<Long, Collection<ClusterNode>> topHist;
@@ -93,6 +97,24 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * @param msg Message.
+ */
+ public TcpDiscoveryNodeAddedMessage(TcpDiscoveryNodeAddedMessage msg) {
+ super(msg);
+
+ this.node = msg.node;
+ this.msgs = msg.msgs;
+ this.discardMsgId = msg.discardMsgId;
+ this.discardCustomMsgId = msg.discardCustomMsgId;
+ this.top = msg.top;
+ this.clientTop = msg.clientTop;
+ this.topHist = msg.topHist;
+ this.newNodeDiscoData = msg.newNodeDiscoData;
+ this.oldNodesDiscoData = msg.oldNodesDiscoData;
+ this.gridStartTime = msg.gridStartTime;
+ }
+
+ /**
* Gets newly added node.
*
* @return New node.
@@ -133,6 +155,7 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
*
* @param msgs Pending messages to send to new node.
* @param discardMsgId Discarded message ID.
+ * @param discardCustomMsgId Discarded custom message ID.
*/
public void messages(
@Nullable Collection<TcpDiscoveryAbstractMessage> msgs,
@@ -163,6 +186,22 @@ public class TcpDiscoveryNodeAddedMessage extends TcpDiscoveryAbstractMessage {
}
/**
+ * @param top Topology at the moment when client joined.
+ */
+ public void clientTopology(Collection<TcpDiscoveryNode> top) {
+ assert top != null && !top.isEmpty() : top;
+
+ this.clientTop = top;
+ }
+
+ /**
+ * @return Topology at the moment when client joined.
+ */
+ public Collection<TcpDiscoveryNode> clientTopology() {
+ return clientTop;
+ }
+
+ /**
* Gets topology snapshots history.
*
* @return Map with topology snapshots history.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
index edd95e9..6131f54 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteClientReconnectCacheTest.java
@@ -1128,6 +1128,39 @@ public class IgniteClientReconnectCacheTest extends IgniteClientReconnectAbstrac
}
/**
+ * @throws Exception If failed.
+ */
+ public void testReconnectDestroyCache() throws Exception {
+ clientMode = true;
+
+ Ignite client = startGrid(SRV_CNT);
+
+ CacheConfiguration<Integer, Integer> ccfg1 = new CacheConfiguration<>();
+ ccfg1.setName("cache1");
+
+ CacheConfiguration<Integer, Integer> ccfg2 = new CacheConfiguration<>();
+ ccfg2.setName("cache2");
+
+ final Ignite srv = grid(0);
+
+ srv.createCache(ccfg1);
+ srv.createCache(ccfg2).put(1, 1);
+
+ IgniteCache<Integer, Integer> cache = client.cache("cache2");
+
+ reconnectClientNode(client, srv, new Runnable() {
+ @Override public void run() {
+ srv.destroyCache("cache1");
+ }
+ });
+
+ cache.put(2, 2);
+
+ assertEquals(1, (Object)cache.get(1));
+ assertEquals(2, (Object)cache.get(2));
+ }
+
+ /**
* @param client Client.
* @param disconnectLatch Disconnect event latch.
* @param reconnectLatch Reconnect event latch.
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index a6b5535..530ff61 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -78,6 +78,7 @@ import org.apache.ignite.lang.IgniteClosure;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
import org.apache.ignite.resources.LoggerResource;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
@@ -183,6 +184,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
if (memoryMode() == OFFHEAP_TIERED || memoryMode() == OFFHEAP_VALUES)
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
index 51e76f6..659520b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
@@ -32,6 +32,9 @@ import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.jetbrains.annotations.Nullable;
@@ -41,6 +44,9 @@ import static org.apache.ignite.cache.CacheWriteSynchronizationMode.PRIMARY_SYNC
* Test for reproducing problems during simultaneously Ignite instances stopping and cache requests executing.
*/
public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
/** Grid count. */
private static final int GRID_CNT = 8;
@@ -55,6 +61,8 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
@Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
OptimizedMarshaller marsh = new OptimizedMarshaller();
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
index 2aa4280..37c5a6b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientReconnectTest.java
@@ -94,6 +94,8 @@ public class IgniteCacheClientReconnectTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected void afterTestsStopped() throws Exception {
super.afterTestsStopped();
+
+ stopAllGrids();
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
index 78fc590..242b12d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheManyClientsTest.java
@@ -113,13 +113,6 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
- public void testManyClients() throws Throwable {
- manyClientsPutGet();
- }
-
- /**
- * @throws Exception If failed.
- */
public void testManyClientsClientDiscovery() throws Throwable {
clientDiscovery = true;
@@ -138,6 +131,13 @@ public class IgniteCacheManyClientsTest extends GridCommonAbstractTest {
/**
* @throws Exception If failed.
*/
+ public void testManyClientsForceServerMode() throws Throwable {
+ manyClientsPutGet();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
private void manyClientsSequentially() throws Exception {
client = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/6ea3b562/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
new file mode 100644
index 0000000..6f0e887
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
@@ -0,0 +1,303 @@
+/*
+ * 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.spi.discovery.tcp;
+
+import java.util.HashMap;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Callable;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.CacheException;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteClientDisconnectedException;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteTransactions;
+import org.apache.ignite.cluster.ClusterTopologyException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
+import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
+import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
+
+/**
+ * Client reconnect test in multi threaded mode while cache operations are in progress.
+ */
+public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstractTest {
+ /** */
+ private static final int GRID_CNT = 14;
+
+ /** */
+ private static final int CLIENT_GRID_CNT = 14;
+
+ /** */
+ private static volatile boolean clientMode;
+
+ /** */
+ private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setClientMode(clientMode);
+
+ cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
+
+ ((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ stopAllGrids();
+
+ super.afterTest();
+
+ Thread.sleep(5000);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected long getTestTimeout() {
+ return 5 * 60 * 1000;
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void _testMassiveServersShutdown1() throws Exception {
+ massiveServersShutdown(StopType.FAIL_EVENT);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void testMassiveServersShutdown2() throws Exception {
+ massiveServersShutdown(StopType.SIMULATE_FAIL);
+ }
+
+ /**
+ * @throws Exception If any error occurs.
+ */
+ public void _testMassiveServersShutdown3() throws Exception {
+ massiveServersShutdown(StopType.CLOSE);
+ }
+
+ /**
+ * @param stopType How tp stop node.
+ * @throws Exception If any error occurs.
+ */
+ private void massiveServersShutdown(final StopType stopType) throws Exception {
+ clientMode = false;
+
+ startGridsMultiThreaded(GRID_CNT);
+
+ clientMode = true;
+
+ startGridsMultiThreaded(GRID_CNT, CLIENT_GRID_CNT);
+
+ final AtomicBoolean done = new AtomicBoolean();
+
+ // Starting a cache dynamically.
+ Ignite client = grid(GRID_CNT);
+
+ assertTrue(client.configuration().isClientMode());
+
+ CacheConfiguration<String, Integer> cfg = new CacheConfiguration<>();
+
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(TRANSACTIONAL);
+ cfg.setBackups(2);
+ cfg.setOffHeapMaxMemory(0);
+ cfg.setMemoryMode(OFFHEAP_TIERED);
+
+ IgniteCache<String, Integer> cache = client.getOrCreateCache(cfg);
+
+ HashMap<String, Integer> put = new HashMap<>();
+
+ // Load some data.
+ for (int i = 0; i < 10_000; i++)
+ put.put(String.valueOf(i), i);
+
+ cache.putAll(put);
+
+ // Preparing client nodes and starting cache operations from them.
+ final BlockingQueue<Integer> clientIdx = new LinkedBlockingQueue<>();
+
+ for (int i = GRID_CNT; i < GRID_CNT + CLIENT_GRID_CNT; i++)
+ clientIdx.add(i);
+
+ IgniteInternalFuture<?> clientsFut = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ int idx = clientIdx.take();
+
+ Ignite ignite = grid(idx);
+
+ Thread.currentThread().setName("client-thread-" + ignite.name());
+
+ assertTrue(ignite.configuration().isClientMode());
+
+ IgniteCache<String, Integer> cache = ignite.cache(null);
+
+ IgniteTransactions txs = ignite.transactions();
+
+ Random rand = new Random();
+
+ while (!done.get()) {
+ try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ cache.put(String.valueOf(rand.nextInt(10_000)), rand.nextInt(50_000));
+
+ tx.commit();
+ }
+ catch (ClusterTopologyException ex) {
+ ex.retryReadyFuture().get();
+ }
+ catch (IgniteException | CacheException e) {
+ if (X.hasCause(e, IgniteClientDisconnectedException.class)) {
+ IgniteClientDisconnectedException cause = X.cause(e,
+ IgniteClientDisconnectedException.class);
+
+ assert cause != null;
+
+ cause.reconnectFuture().get();
+ }
+ else if (X.hasCause(e, ClusterTopologyException.class)) {
+ ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class);
+
+ assert cause != null;
+
+ cause.retryReadyFuture().get();
+ }
+ else
+ throw e;
+ }
+ }
+
+ return null;
+ }
+ },
+ CLIENT_GRID_CNT, "client-thread");
+
+ try {
+ // Killing a half of server nodes.
+ final int srvsToKill = GRID_CNT / 2;
+
+ final BlockingQueue<Integer> victims = new LinkedBlockingQueue<>();
+
+ for (int i = 0; i < srvsToKill; i++)
+ victims.add(i);
+
+ final BlockingQueue<Integer> assassins = new LinkedBlockingQueue<>();
+
+ for (int i = srvsToKill; i < GRID_CNT; i++)
+ assassins.add(i);
+
+ IgniteInternalFuture<?> srvsShutdownFut = multithreadedAsync(
+ new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ Thread.sleep(5_000);
+
+ Ignite assassin = grid(assassins.take());
+
+ assertFalse(assassin.configuration().isClientMode());
+
+ Ignite victim = grid(victims.take());
+
+ assertFalse(victim.configuration().isClientMode());
+
+ log.info("Kill node [node=" + victim.name() + ", from=" + assassin.name() + ']');
+
+ switch (stopType) {
+ case CLOSE:
+ victim.close();
+
+ break;
+
+ case FAIL_EVENT:
+ UUID nodeId = victim.cluster().localNode().id();
+
+ assassin.configuration().getDiscoverySpi().failNode(nodeId, null);
+
+ break;
+
+ case SIMULATE_FAIL:
+ ((TcpDiscoverySpi)victim.configuration().getDiscoverySpi()).simulateNodeFailure();
+
+ break;
+
+ default:
+ fail();
+ }
+
+ return null;
+ }
+ },
+ assassins.size(), "kill-thread");
+
+ srvsShutdownFut.get();
+
+ Thread.sleep(15_000);
+
+ done.set(true);
+
+ clientsFut.get();
+
+ awaitPartitionMapExchange();
+
+ for (int k = 0; k < 10_000; k++) {
+ String key = String.valueOf(k);
+
+ Object val = cache.get(key);
+
+ for (int i = srvsToKill; i < GRID_CNT; i++)
+ assertEquals(val, ignite(i).cache(null).get(key));
+ }
+ }
+ finally {
+ done.set(true);
+ }
+ }
+
+ /**
+ *
+ */
+ enum StopType {
+ /** */
+ CLOSE,
+
+ /** */
+ SIMULATE_FAIL,
+
+ /** */
+ FAIL_EVENT
+ }
+}
[03/50] [abbrv] ignite git commit: Muted test.
Posted by ag...@apache.org.
Muted test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91059ba8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91059ba8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91059ba8
Branch: refs/heads/ignite-1702
Commit: 91059ba8422e0caf5df2125e19fa2dd165f1b91a
Parents: 9304dce
Author: ashutak <as...@gridgain.com>
Authored: Thu Oct 29 15:14:55 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Thu Oct 29 15:14:55 2015 +0300
----------------------------------------------------------------------
.../GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/91059ba8/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java
index f8151f4..c468cc2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest.java
@@ -65,4 +65,9 @@ public class GridCacheAtomicMultiNodeP2PDisabledFullApiSelfTest
return ccfg;
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testWithSkipStore() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1809");
+ }
+}
[28/50] [abbrv] ignite git commit: ignite-1758 Fixed client reconnect
issues
Posted by ag...@apache.org.
ignite-1758 Fixed client reconnect issues
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2501c3a5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2501c3a5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2501c3a5
Branch: refs/heads/ignite-1702
Commit: 2501c3a52034a7e8d419eb335eab1fe7f2efb2f1
Parents: be6e439
Author: sboikov <sb...@gridgain.com>
Authored: Tue Nov 3 17:42:01 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Nov 3 17:42:01 2015 +0300
----------------------------------------------------------------------
.../GridDhtPartitionsExchangeFuture.java | 6 +
.../ignite/spi/discovery/tcp/ServerImpl.java | 21 +-
.../TcpDiscoveryClientReconnectMessage.java | 1 +
.../messages/TcpDiscoveryDiscardMessage.java | 1 +
.../cache/GridCacheAbstractFullApiSelfTest.java | 2 +
.../GridCacheAbstractRemoveFailureTest.java | 4 +-
.../CacheGetFutureHangsSelfTest.java | 3 +-
...niteCacheClientNodeChangingTopologyTest.java | 2 +
.../IgniteCacheCrossCacheTxFailoverTest.java | 4 +-
.../IgniteCachePutRetryAbstractSelfTest.java | 4 +-
...ledFairAffinityMultiNodeFullApiSelfTest.java | 5 -
...omicNearEnabledMultiNodeFullApiSelfTest.java | 5 -
...icOffHeapTieredMultiNodeFullApiSelfTest.java | 5 -
.../near/GridCacheNearTxExceptionSelfTest.java | 4 +
...gniteClientReconnectMassiveShutdownTest.java | 84 +++--
.../tcp/TcpDiscoveryMultiThreadedTest.java | 5 +-
.../ignite/testframework/GridTestUtils.java | 4 +-
.../processors/query/h2/IgniteH2Indexing.java | 2 +-
.../cache/SqlFieldsQuerySelfTest.java | 2 -
.../config/benchmark-client-mode.properties | 4 +-
.../config/benchmark-failover.properties | 107 +++++++
.../config/benchmark-multicast.properties | 71 ++--
.../yardstick/config/benchmark-store.properties | 4 +-
modules/yardstick/config/benchmark.properties | 4 +-
.../config/ignite-failover-base-config.xml | 126 ++++++++
.../config/ignite-failover-localhost-config.xml | 56 ++++
modules/yardstick/pom.xml | 3 +-
.../yardstick/IgniteAbstractBenchmark.java | 2 +-
.../yardstick/IgniteBenchmarkArguments.java | 66 +++-
.../cache/IgniteCacheAbstractBenchmark.java | 8 +-
.../yardstick/cache/IgniteGetBenchmark.java | 4 +-
.../cache/IgniteJdbcSqlQueryBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutAllBenchmark.java | 4 +-
.../cache/IgnitePutAllTxBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutGetBenchmark.java | 4 +-
.../cache/IgnitePutGetTxBenchmark.java | 4 +-
.../cache/IgnitePutIndexedValue1Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue2Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue8Benchmark.java | 4 +-
.../yardstick/cache/IgnitePutTxBenchmark.java | 4 +-
.../cache/IgniteSqlQueryBenchmark.java | 4 +-
.../cache/IgniteSqlQueryJoinBenchmark.java | 4 +-
.../cache/IgniteSqlQueryPutBenchmark.java | 4 +-
.../IgniteAtomicInvokeRetryBenchmark.java | 214 +++++++++++++
...IgniteAtomicOffHeapInvokeRetryBenchmark.java | 31 ++
.../IgniteAtomicOffHeapRetriesBenchmark.java | 31 ++
.../failover/IgniteAtomicRetriesBenchmark.java | 89 ++++++
.../IgniteFailoverAbstractBenchmark.java | 320 +++++++++++++++++++
.../cache/failover/IgniteFailoverNode.java | 60 ++++
...IgniteTransactionalInvokeRetryBenchmark.java | 212 ++++++++++++
...ransactionalOffHeapInvokeRetryBenchmark.java | 33 ++
...ransactionalOffHeapWriteInvokeBenchmark.java | 37 +++
...eTransactionalOffHeapWriteReadBenchmark.java | 32 ++
...IgniteTransactionalWriteInvokeBenchmark.java | 182 +++++++++++
.../IgniteTransactionalWriteReadBenchmark.java | 141 ++++++++
56 files changed, 1919 insertions(+), 134 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index 77e47a7..cef38e8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -1447,6 +1447,12 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
", old=" + oldest.id() + ", new=" + newOldest.id() + ']');
}
}
+ else {
+ ClusterTopologyCheckedException err = new ClusterTopologyCheckedException("Failed to " +
+ "wait for exchange future, all server nodes left.");
+
+ onDone(err);
+ }
if (set) {
// If received any messages, process them.
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index ee9f818..0fe2881 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -1454,18 +1454,18 @@ class ServerImpl extends TcpDiscoveryImpl {
tmp = U.arrayList(readers);
}
- for (ClientMessageWorker msgWorker : clientMsgWorkers.values()) {
- U.interrupt(msgWorker);
-
- U.join(msgWorker, log);
- }
-
U.interrupt(tmp);
U.joinThreads(tmp, log);
U.interrupt(msgWorker);
U.join(msgWorker, log);
+ for (ClientMessageWorker msgWorker : clientMsgWorkers.values()) {
+ U.interrupt(msgWorker);
+
+ U.join(msgWorker, log);
+ }
+
U.interrupt(statsPrinter);
U.join(statsPrinter, log);
}
@@ -1778,7 +1778,9 @@ class ServerImpl extends TcpDiscoveryImpl {
Collection<TcpDiscoveryNode> top = new ArrayList<>(allNodes.size());
for (TcpDiscoveryNode n0 : allNodes) {
- if (n0.internalOrder() != 0 && n0.internalOrder() < node.internalOrder())
+ assert n0.internalOrder() > 0 : n0;
+
+ if (n0.internalOrder() < node.internalOrder())
top.add(n0);
}
@@ -3239,6 +3241,9 @@ class ServerImpl extends TcpDiscoveryImpl {
}
}
else {
+ if (isLocalNodeCoordinator())
+ addMessage(new TcpDiscoveryDiscardMessage(locNodeId, msg.id(), false));
+
if (isLocNodeRouter) {
ClientMessageWorker wrk = clientMsgWorkers.get(nodeId);
@@ -3249,7 +3254,7 @@ class ServerImpl extends TcpDiscoveryImpl {
locNodeId + ", clientNodeId=" + nodeId + ']');
}
else {
- if (ring.hasRemoteNodes() && !locNodeId.equals(msg.verifierNodeId()))
+ if (ring.hasRemoteNodes() && !isLocalNodeCoordinator())
sendMessageAcrossRing(msg);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
index c232e6c..7c0cd5d 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryClientReconnectMessage.java
@@ -26,6 +26,7 @@ import org.apache.ignite.lang.IgniteUuid;
/**
* Message telling that client node is reconnecting to topology.
*/
+@TcpDiscoveryEnsureDelivery
public class TcpDiscoveryClientReconnectMessage extends TcpDiscoveryAbstractMessage {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
index 145f19e..4b4eb9c 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryDiscardMessage.java
@@ -40,6 +40,7 @@ public class TcpDiscoveryDiscardMessage extends TcpDiscoveryAbstractMessage {
*
* @param creatorNodeId Creator node ID.
* @param msgId Message ID.
+ * @param customMsgDiscard Flag indicating whether the ID to discard is for a custom message or not.
*/
public TcpDiscoveryDiscardMessage(UUID creatorNodeId, IgniteUuid msgId, boolean customMsgDiscard) {
super(creatorNodeId);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 530ff61..3a530f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -3997,6 +3997,8 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
* @throws Exception If failed.
*/
public void testIgniteCacheIterator() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1756");
+
IgniteCache<String, Integer> cache = jcache(0);
Iterator<Cache.Entry<String, Integer>> it = cache.iterator();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
index 5044516..6572d31 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractRemoveFailureTest.java
@@ -49,7 +49,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
@@ -102,7 +102,7 @@ public abstract class GridCacheAbstractRemoveFailureTest extends GridCommonAbstr
if (testClientNode() && getTestGridName(0).equals(gridName))
cfg.setClientMode(true);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
index 659520b..53ac648 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheGetFutureHangsSelfTest.java
@@ -91,7 +91,7 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
@Override protected long getTestTimeout() {
- return 5 * 60_000;
+ return 10 * 60_000;
}
/**
@@ -114,6 +114,7 @@ public class CacheGetFutureHangsSelfTest extends GridCommonAbstractTest {
/**
* Executes one test iteration.
+ *
* @throws Exception If failed.
*/
private void doTestFailover() throws Exception {
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
index cb83798..8f90dbd 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheClientNodeChangingTopologyTest.java
@@ -1555,6 +1555,8 @@ public class IgniteCacheClientNodeChangingTopologyTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testAtomicPrimaryPutAllMultinode() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1685");
+
multinode(PRIMARY, TestType.PUT_ALL);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
index 7fe0138..e46761b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCacheCrossCacheTxFailoverTest.java
@@ -42,7 +42,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
import org.apache.ignite.transactions.TransactionConcurrency;
@@ -92,7 +92,7 @@ public class IgniteCacheCrossCacheTxFailoverTest extends GridCommonAbstractTest
if (gridName.equals(getTestGridName(GRID_CNT - 1)))
cfg.setClientMode(true);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
((TcpCommunicationSpi)cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
index 76f12c4..ee28cf9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/IgniteCachePutRetryAbstractSelfTest.java
@@ -49,7 +49,7 @@ import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
@@ -120,7 +120,7 @@ public abstract class IgniteCachePutRetryAbstractSelfTest extends GridCommonAbst
cfg.setAtomicConfiguration(acfg);
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
return cfg;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
index de4a53d..e4784f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest.java
@@ -38,9 +38,4 @@ public class GridCacheAtomicNearEnabledFairAffinityMultiNodeFullApiSelfTest
@Override public void testWithSkipStore(){
fail("https://issues.apache.org/jira/browse/IGNITE-1582");
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
index e9251b6..5e128ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest.java
@@ -27,9 +27,4 @@ public class GridCacheAtomicNearEnabledMultiNodeFullApiSelfTest extends GridCach
@Override protected NearCacheConfiguration nearConfiguration() {
return new NearCacheConfiguration();
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
index 608729a..472ad16 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest.java
@@ -30,9 +30,4 @@ public class GridCacheAtomicOffHeapTieredMultiNodeFullApiSelfTest extends
@Override protected CacheMemoryMode memoryMode() {
return OFFHEAP_TIERED;
}
-
- /** {@inheritDoc} */
- @Override public void testIgniteCacheIterator() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1756");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
index 02aa824..270af25 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearTxExceptionSelfTest.java
@@ -35,4 +35,8 @@ public class GridCacheNearTxExceptionSelfTest extends IgniteTxExceptionAbstractS
@Override public void testTransformBackup(){
fail("https://issues.apache.org/jira/browse/IGNITE-1601");
}
+
+ @Override public void testRemoveBackup() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1839");
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
index 6f0e887..5282cf2 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/IgniteClientReconnectMassiveShutdownTest.java
@@ -22,6 +22,7 @@ import java.util.Random;
import java.util.UUID;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.cache.CacheException;
@@ -35,12 +36,14 @@ import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.util.typedef.X;
+import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.apache.ignite.transactions.Transaction;
+import static java.util.concurrent.TimeUnit.SECONDS;
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMemoryMode.OFFHEAP_TIERED;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
@@ -131,7 +134,7 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract
assertTrue(client.configuration().isClientMode());
- CacheConfiguration<String, Integer> cfg = new CacheConfiguration<>();
+ final CacheConfiguration<String, Integer> cfg = new CacheConfiguration<>();
cfg.setCacheMode(PARTITIONED);
cfg.setAtomicityMode(TRANSACTIONAL);
@@ -141,6 +144,8 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract
IgniteCache<String, Integer> cache = client.getOrCreateCache(cfg);
+ assertNotNull(cache);
+
HashMap<String, Integer> put = new HashMap<>();
// Load some data.
@@ -155,59 +160,80 @@ public class IgniteClientReconnectMassiveShutdownTest extends GridCommonAbstract
for (int i = GRID_CNT; i < GRID_CNT + CLIENT_GRID_CNT; i++)
clientIdx.add(i);
+ final CountDownLatch latch = new CountDownLatch(CLIENT_GRID_CNT);
+
IgniteInternalFuture<?> clientsFut = multithreadedAsync(
new Callable<Object>() {
@Override public Object call() throws Exception {
- int idx = clientIdx.take();
+ try {
+ int idx = clientIdx.take();
- Ignite ignite = grid(idx);
+ Ignite ignite = grid(idx);
- Thread.currentThread().setName("client-thread-" + ignite.name());
+ Thread.currentThread().setName("client-thread-" + ignite.name());
- assertTrue(ignite.configuration().isClientMode());
+ assertTrue(ignite.configuration().isClientMode());
- IgniteCache<String, Integer> cache = ignite.cache(null);
+ IgniteCache<String, Integer> cache = ignite.getOrCreateCache(cfg);
- IgniteTransactions txs = ignite.transactions();
+ assertNotNull(cache);
- Random rand = new Random();
+ IgniteTransactions txs = ignite.transactions();
- while (!done.get()) {
- try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
- cache.put(String.valueOf(rand.nextInt(10_000)), rand.nextInt(50_000));
+ Random rand = new Random();
- tx.commit();
- }
- catch (ClusterTopologyException ex) {
- ex.retryReadyFuture().get();
- }
- catch (IgniteException | CacheException e) {
- if (X.hasCause(e, IgniteClientDisconnectedException.class)) {
- IgniteClientDisconnectedException cause = X.cause(e,
- IgniteClientDisconnectedException.class);
+ latch.countDown();
- assert cause != null;
+ while (!done.get()) {
+ try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
+ cache.put(String.valueOf(rand.nextInt(10_000)), rand.nextInt(50_000));
- cause.reconnectFuture().get();
+ tx.commit();
}
- else if (X.hasCause(e, ClusterTopologyException.class)) {
- ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class);
+ catch (ClusterTopologyException ex) {
+ ex.retryReadyFuture().get();
+ }
+ catch (IgniteException | CacheException e) {
+ if (X.hasCause(e, IgniteClientDisconnectedException.class)) {
+ IgniteClientDisconnectedException cause = X.cause(e,
+ IgniteClientDisconnectedException.class);
+
+ assert cause != null;
+
+ cause.reconnectFuture().get();
+ }
+ else if (X.hasCause(e, ClusterTopologyException.class)) {
+ ClusterTopologyException cause = X.cause(e, ClusterTopologyException.class);
- assert cause != null;
+ assert cause != null;
- cause.retryReadyFuture().get();
+ cause.retryReadyFuture().get();
+ }
+ else
+ throw e;
}
- else
- throw e;
}
+
+ return null;
}
+ catch (Throwable e) {
+ log.error("Unexpected error: " + e, e);
- return null;
+ throw e;
+ }
}
},
CLIENT_GRID_CNT, "client-thread");
try {
+ if (!latch.await(30, SECONDS)) {
+ log.warning("Failed to wait for for clients start.");
+
+ U.dumpThreads(log);
+
+ fail("Failed to wait for for clients start.");
+ }
+
// Killing a half of server nodes.
final int srvsToKill = GRID_CNT / 2;
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
index 09b3ef8..55474dc 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
@@ -37,6 +37,7 @@ import org.apache.ignite.internal.IgniteClientDisconnectedCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.client.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.cluster.ClusterTopologyCheckedException;
import org.apache.ignite.internal.util.typedef.G;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.U;
@@ -161,8 +162,6 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
* @throws Exception If any error occurs.
*/
public void testMultiThreadedClientsRestart() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1123");
-
final AtomicBoolean done = new AtomicBoolean();
try {
@@ -271,6 +270,8 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
if (X.hasCause(e, IgniteClientDisconnectedCheckedException.class) ||
X.hasCause(e, IgniteClientDisconnectedException.class))
log.info("Client disconnected: " + e);
+ else if (X.hasCause(e, ClusterTopologyCheckedException.class))
+ log.info("Client failed to start: " + e);
else {
if (failedNodes.contains(id) && X.hasCause(e, IgniteSpiException.class))
log.info("Client failed: " + e);
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index ea3bbe0..d1c3d9f 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -88,7 +88,7 @@ import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.LT;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.spi.swapspace.file.FileSwapSpaceSpi;
+import org.apache.ignite.spi.swapspace.inmemory.GridTestSwapSpaceSpi;
import org.apache.ignite.ssl.SslContextFactory;
import org.apache.ignite.testframework.config.GridTestProperties;
import org.jetbrains.annotations.NotNull;
@@ -1698,7 +1698,7 @@ public final class GridTestUtils {
ccfg.setSwapEnabled(swap);
if (swap && cfg != null)
- cfg.setSwapSpaceSpi(new FileSwapSpaceSpi());
+ cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());
if (evictionPlc) {
LruEvictionPolicy plc = new LruEvictionPolicy();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 8595187..4c07132 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -1474,7 +1474,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
@Nullable @Override public <K, V> IgniteBiPredicate<K, V> forSpace(String spaceName) {
final GridCacheAdapter<Object, Object> cache = ctx.cache().internalCache(spaceName);
- if (cache.context().isReplicated() || (cache.configuration().getBackups() == 0 && parts == null))
+ if (cache.context().isReplicated())
return null;
final GridCacheAffinityManager aff = cache.context().affinity();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
index 26d87a9..a8c8388 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/SqlFieldsQuerySelfTest.java
@@ -74,8 +74,6 @@ public class SqlFieldsQuerySelfTest extends GridCommonAbstractTest {
* @throws Exception If error.
*/
public void testSqlFieldsQueryWithTopologyChanges() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1698");
-
startGrid(0);
createAndFillCache();
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/benchmark-client-mode.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-client-mode.properties b/modules/yardstick/config/benchmark-client-mode.properties
index 8941417..ba5525f 100644
--- a/modules/yardstick/config/benchmark-client-mode.properties
+++ b/modules/yardstick/config/benchmark-client-mode.properties
@@ -17,12 +17,14 @@
# Contains all multicast benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
--Xloggc:./gc.log \
+-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/benchmark-failover.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-failover.properties b/modules/yardstick/config/benchmark-failover.properties
new file mode 100644
index 0000000..7ed464c
--- /dev/null
+++ b/modules/yardstick/config/benchmark-failover.properties
@@ -0,0 +1,107 @@
+#
+# 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.
+#
+
+#
+# Contains failover benchmarks.
+#
+
+now0=`date +'%H%M%S'`
+
+# JVM options.
+#JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -Xms15g -Xmx15g"
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -ea"
+
+# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
+JVM_OPTS=${JVM_OPTS}" \
+ -Xloggc:./gc${now0}.log \
+ -XX:+PrintGCDetails \
+ -verbose:gc \
+ -XX:+UseParNewGC \
+ -XX:+UseConcMarkSweepGC \
+ -XX:+UseTLAB \
+ -XX:NewSize=128m \
+ -XX:MaxNewSize=128m \
+ -XX:MaxTenuringThreshold=0 \
+ -XX:SurvivorRatio=1024 \
+ -XX:+UseCMSInitiatingOccupancyOnly \
+ -XX:CMSInitiatingOccupancyFraction=60 \
+"
+
+#Ignite version
+ver="RELEASE-"
+
+# List of default probes.
+# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
+BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe
+
+# Packages where the specified benchmark is searched by reflection mechanism.
+BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
+
+RESTART_SERVERS=true
+
+# Probe point writer class name.
+# BENCHMARK_WRITER=
+
+# Comma-separated list of the hosts to run BenchmarkServers on.
+SERVER_HOSTS=localhost,localhost
+
+# Comma-separated list of the hosts to run BenchmarkDrivers on.
+DRIVER_HOSTS=localhost
+
+# Remote username.
+# REMOTE_USER=
+
+# Number of nodes, used to wait for the specified number of nodes to start.
+nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+
+# Space-separated list of Benchmark driver names (required)
+dn="\
+ IgniteAtomicRetriesBenchmark \
+ IgniteAtomicInvokeRetryBenchmark \
+ IgniteTransactionalWriteReadBenchmark \
+ IgniteTransactionalWriteInvokeBenchmark \
+ IgniteTransactionalInvokeRetryBenchmark \
+ IgniteAtomicOffHeapRetriesBenchmark \
+ IgniteAtomicOffHeapInvokeRetryBenchmark \
+ IgniteTransactionalOffHeapWriteReadBenchmark \
+ IgniteTransactionalOffHeapWriteInvokeBenchmark \
+ IgniteTransactionalOffHeapInvokeRetryBenchmark \
+"
+
+# Warmup 1 min.
+w=60
+
+# Duration 2h = 2*60*60 = 7200 sec.
+d=7200
+
+# Restart delay 10 min = 10 * 60 sec = 600 sec.
+rd=600
+
+# Restart sleep 2 min = 120 sec.
+rs=120
+
+# Keys rang.
+r=100000
+
+# Thread count.
+t=128
+
+# Run configuration which contains all benchmarks.
+CONFIGS="\
+-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 1 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds failover-1b,\
+-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 2 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds failover-2b,\
+"
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/benchmark-multicast.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties
index 82fc3f8..536ccf4 100644
--- a/modules/yardstick/config/benchmark-multicast.properties
+++ b/modules/yardstick/config/benchmark-multicast.properties
@@ -17,12 +17,14 @@
# Contains all multicast benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
--Xloggc:./gc.log \
+-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
@@ -35,6 +37,7 @@ JVM_OPTS=${JVM_OPTS}" \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSInitiatingOccupancyFraction=60 \
"
+
#Ignite version
ver="RELEASE-"
@@ -63,31 +66,49 @@ DRIVER_HOSTS=localhost
# Number of nodes, used to wait for the specified number of nodes to start.
nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+# Backups count.
+b=1
+
+# Warmup.
+w=60
+
+# Duration.
+d=300
+
+# Threads count.
+t=64
+
+# Sync mode.
+sm=PRIMARY_SYNC
+
+# Jobs.
+j=10
+
# Run configuration which contains all benchmarks.
# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute).
CONFIGS="\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxBenchmark -sn IgniteNode -ds ${ver}tx-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-put-get-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteAffinityCallBenchmark -sn IgniteNode -ds ${ver}affcall-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteApplyBenchmark -sn IgniteNode -ds ${ver}apply-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteBroadcastBenchmark -sn IgniteNode -ds ${ver}broad-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteExecuteBenchmark -sn IgniteNode -ds ${ver}exec-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteRunBenchmark -sn IgniteNode -ds ${ver}run-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxBenchmark -sn IgniteNode -ds ${ver}tx-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteAffinityCallBenchmark -sn IgniteNode -ds ${ver}affcall-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteApplyBenchmark -sn IgniteNode -ds ${ver}apply-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteBroadcastBenchmark -sn IgniteNode -ds ${ver}broad-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteExecuteBenchmark -sn IgniteNode -ds ${ver}exec-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteRunBenchmark -sn IgniteNode -ds ${ver}run-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxOffHeapBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup\
"
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/benchmark-store.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-store.properties b/modules/yardstick/config/benchmark-store.properties
index cb9e507..bda136e 100644
--- a/modules/yardstick/config/benchmark-store.properties
+++ b/modules/yardstick/config/benchmark-store.properties
@@ -21,12 +21,14 @@
# - TRANSACTIONAL cache
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
- -Xloggc:./gc.log \
+ -Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/benchmark.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark.properties b/modules/yardstick/config/benchmark.properties
index d691f1e..67ef5ef 100644
--- a/modules/yardstick/config/benchmark.properties
+++ b/modules/yardstick/config/benchmark.properties
@@ -17,12 +17,14 @@
# Contains all benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
- -Xloggc:./gc.log \
+ -Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/ignite-failover-base-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-failover-base-config.xml b/modules/yardstick/config/ignite-failover-base-config.xml
new file mode 100644
index 0000000..1e1dcff
--- /dev/null
+++ b/modules/yardstick/config/ignite-failover-base-config.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite Spring configuration file to startup grid.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ <bean id="base-ignite-failover.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" abstract="true">
+ <property name="peerClassLoadingEnabled" value="false"/>
+
+ <property name="metricsLogFrequency" value="5000"/>
+
+ <property name="failureDetectionTimeout" value="2000"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic">
+ <property name="name" value="atomic-reties"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic-offheap">
+ <property name="name" value="atomic-offheap-reties"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic">
+ <property name="name" value="atomic-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic-offheap">
+ <property name="name" value="atomic-offheap-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-write-read"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-write-read"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-write-invoke"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-write-invoke"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="includeEventTypes">
+ <list/>
+ </property>
+
+ <property name="loadBalancingSpi">
+ <bean class="org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi">
+ <property name="perTask" value="false"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="atomic" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="ATOMIC"/>
+
+ <property name="swapEnabled" value="false"/>
+ </bean>
+
+ <bean id="atomic-offheap" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="name" value="atomic-offheap"/>
+
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="ATOMIC"/>
+
+ <property name="swapEnabled" value="false"/>
+
+ <property name="memoryMode" value="OFFHEAP_TIERED"/>
+ </bean>
+
+ <bean id="tx" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+
+ <property name="swapEnabled" value="false"/>
+ </bean>
+
+ <bean id="tx-offheap" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+
+ <property name="swapEnabled" value="false"/>
+
+ <property name="memoryMode" value="OFFHEAP_TIERED"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/config/ignite-failover-localhost-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-failover-localhost-config.xml b/modules/yardstick/config/ignite-failover-localhost-config.xml
new file mode 100644
index 0000000..a7c7ff8
--- /dev/null
+++ b/modules/yardstick/config/ignite-failover-localhost-config.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite Spring configuration file to startup grid.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ <import resource="ignite-base-config.xml"/>
+ <import resource="ignite-failover-base-config.xml"/>
+
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" parent="base-ignite-failover.cfg">
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500</value>
+ <value>127.0.0.1:47501</value>
+ <value>127.0.0.1:47502</value>
+ <value>127.0.0.1:47503</value>
+ <value>127.0.0.1:47504</value>
+ <value>127.0.0.1:47505</value>
+ <value>127.0.0.1:47506</value>
+ <value>127.0.0.1:47507</value>
+ <value>127.0.0.1:47508</value>
+ <value>127.0.0.1:47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index c87ecbc..5bb41b3 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -37,10 +37,9 @@
<url>http://ignite.apache.org</url>
<properties>
- <yardstick.version>0.7.0</yardstick.version>
+ <yardstick.version>0.8.0</yardstick.version>
</properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
index c9d4b85..fa93f00 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
@@ -131,4 +131,4 @@ public abstract class IgniteAbstractBenchmark extends BenchmarkDriverAdapter {
protected int nextRandom(int min, int max) {
return ThreadLocalRandom.current().nextInt(max - min) + min;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index 792d366..74b1da9 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -113,6 +113,26 @@ public class IgniteBenchmarkArguments {
private String jdbcUrl;
/** */
+ @Parameter(names = {"-rd", "--restartdelay"}, description = "Restart delay in seconds")
+ private int restartDelay = 20;
+
+ /** */
+ @Parameter(names = {"-rs", "--restartsleep"}, description = "Restart sleep in seconds")
+ private int restartSleep = 2;
+
+ /** */
+ @Parameter(names = {"-checkingPeriod", "--checkingPeriod"}, description = "Period to check cache consistency in seconds")
+ private int cacheConsistencyCheckingPeriod = 2 * 60;
+
+ /** */
+ @Parameter(names = {"-kc", "--keysCount"}, description = "Count of keys")
+ private int keysCnt = 5;
+
+ /** */
+ @Parameter(names = {"-cot", "--cacheOperationTimeout"}, description = "Max timeout for cache operations in seconds")
+ private int cacheOpTimeout = 30;
+
+ /** */
@Parameter(names = {"-kpt", "--keysPerThread"}, description = "Use not intersecting keys in putAll benchmark")
private boolean keysPerThread;
@@ -271,18 +291,54 @@ public class IgniteBenchmarkArguments {
}
/**
- * @return Description.
+ * @return Delay in second which used in nodes restart algorithm.
*/
- public String description() {
- return "-nn=" + nodes + "-b=" + backups + "-sm=" + syncMode + "-cl=" + clientOnly + "-nc=" + nearCacheFlag +
- (orderMode == null ? "" : "-wom=" + orderMode) + "-txc=" + txConcurrency;
+ public int restartDelay() {
+ return restartDelay;
+ }
+
+ /**
+ * @return Sleep in second which used in nodes restart algorithm.
+ */
+ public int restartSleep() {
+ return restartSleep;
+ }
+
+ /**
+ * @return Keys count.
+ */
+ public int keysCount() {
+ return keysCnt;
+ }
+
+ /**
+ * @return Period in seconds to check cache consistency.
+ */
+ public int cacheConsistencyCheckingPeriod() {
+ return cacheConsistencyCheckingPeriod;
+ }
+
+ /**
+ * @return Cache operation timeout in milliseconds.
+ */
+ public int cacheOperationTimeoutMillis() {
+ return cacheOpTimeout * 1000;
}
/**
* @return {@code True} if use not intersecting keys in putAll benchmark.
*/
public boolean keysPerThread() {
- return keysPerThread;
+ return keysPerThread;
+ }
+
+ /**
+ * @return Description.
+ */
+ public String description() {
+ return "-nn=" + nodes + "-b=" + backups + "-sm=" + syncMode + "-cl=" + clientOnly + "-nc=" + nearCacheFlag +
+ (orderMode == null ? "" : "-wom=" + orderMode) + "-txc=" + txConcurrency + "-rd=" + restartDelay +
+ "-rs=" + restartSleep;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index 22a9eac..3efa4a5 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -27,9 +27,9 @@ import org.yardstickframework.BenchmarkUtils;
/**
* Abstract class for Ignite benchmarks which use cache.
*/
-public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchmark {
+public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractBenchmark {
/** Cache. */
- protected IgniteCache<Integer, Object> cache;
+ protected IgniteCache<K, V> cache;
/** */
private ThreadLocal<ThreadRange> threadRange = new ThreadLocal<>();
@@ -77,7 +77,7 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma
*
* @return IgniteCache Cache to use.
*/
- protected abstract IgniteCache<Integer, Object> cache();
+ protected abstract IgniteCache<K, V> cache();
/**
*
@@ -109,4 +109,4 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma
return rnd.nextInt(min, max);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
index e023c1d..8a86e2f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
@@ -23,7 +23,7 @@ import org.apache.ignite.IgniteCache;
/**
* Ignite benchmark that performs get operations.
*/
-public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -37,4 +37,4 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
index 63c274f..bbdd760 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
@@ -37,7 +37,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations.
*/
-public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Statements for closing. */
Set<PreparedStatement> stms = Collections.synchronizedSet(new HashSet<PreparedStatement>());
@@ -136,4 +136,4 @@ public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
index 2ce707c..8cd2347 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
@@ -28,7 +28,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs putAll operations.
*/
-public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Affinity mapper. */
private Affinity<Integer> aff;
@@ -65,4 +65,4 @@ public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
index 32d5b02..63faa2f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
@@ -28,7 +28,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs transactional putAll operations.
*/
-public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Affinity mapper. */
private Affinity<Integer> aff;
@@ -68,4 +68,4 @@ public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
index ba2d959..69db87f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs put operations.
*/
-public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
index a92a35e..42f308c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs put and get operations.
*/
-public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -43,4 +43,4 @@ public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
index 07b80cc..5afe0b2 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
@@ -25,7 +25,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs transactional put and get operations.
*/
-public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(0, args.range() / 2);
@@ -48,4 +48,4 @@ public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
index 47b6922..6f06015 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person1;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
index 69d603c..0112163 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person2;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
index fb5dd68..dae32b4 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person8;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
index 53bd60c..ead3a63 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs transactional put operations.
*/
-public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -39,4 +39,4 @@ public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
index fa16cf2..8e31455 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
@@ -32,7 +32,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations.
*/
-public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -90,4 +90,4 @@ public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/2501c3a5/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
index ad863b8..1f8006d 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
@@ -33,7 +33,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations with joins.
*/
-public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -116,4 +116,4 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
[18/50] [abbrv] ignite git commit: ignite-1397: Load/consistency
tests.
Posted by ag...@apache.org.
ignite-1397: Load/consistency tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5b0a18dd
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5b0a18dd
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5b0a18dd
Branch: refs/heads/ignite-1702
Commit: 5b0a18dde8a060428fb9616f0ee39f85cfc34297
Parents: 28e0217
Author: ashutak <as...@gridgain.com>
Authored: Mon Nov 2 17:14:04 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Mon Nov 2 17:14:04 2015 +0300
----------------------------------------------------------------------
.../config/benchmark-client-mode.properties | 4 +-
.../config/benchmark-failover.properties | 107 +++++++
.../config/benchmark-multicast.properties | 71 ++--
.../yardstick/config/benchmark-store.properties | 4 +-
modules/yardstick/config/benchmark.properties | 4 +-
.../config/ignite-failover-base-config.xml | 126 ++++++++
.../config/ignite-failover-localhost-config.xml | 56 ++++
modules/yardstick/pom.xml | 3 +-
.../yardstick/IgniteAbstractBenchmark.java | 2 +-
.../yardstick/IgniteBenchmarkArguments.java | 66 +++-
.../cache/IgniteCacheAbstractBenchmark.java | 8 +-
.../yardstick/cache/IgniteGetBenchmark.java | 4 +-
.../cache/IgniteJdbcSqlQueryBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutAllBenchmark.java | 4 +-
.../cache/IgnitePutAllTxBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutBenchmark.java | 4 +-
.../yardstick/cache/IgnitePutGetBenchmark.java | 4 +-
.../cache/IgnitePutGetTxBenchmark.java | 4 +-
.../cache/IgnitePutIndexedValue1Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue2Benchmark.java | 4 +-
.../cache/IgnitePutIndexedValue8Benchmark.java | 4 +-
.../yardstick/cache/IgnitePutTxBenchmark.java | 4 +-
.../cache/IgniteSqlQueryBenchmark.java | 4 +-
.../cache/IgniteSqlQueryJoinBenchmark.java | 4 +-
.../cache/IgniteSqlQueryPutBenchmark.java | 4 +-
.../IgniteAtomicInvokeRetryBenchmark.java | 214 +++++++++++++
...IgniteAtomicOffHeapInvokeRetryBenchmark.java | 31 ++
.../IgniteAtomicOffHeapRetriesBenchmark.java | 31 ++
.../failover/IgniteAtomicRetriesBenchmark.java | 89 ++++++
.../IgniteFailoverAbstractBenchmark.java | 320 +++++++++++++++++++
.../cache/failover/IgniteFailoverNode.java | 60 ++++
...IgniteTransactionalInvokeRetryBenchmark.java | 212 ++++++++++++
...ransactionalOffHeapInvokeRetryBenchmark.java | 33 ++
...ransactionalOffHeapWriteInvokeBenchmark.java | 37 +++
...eTransactionalOffHeapWriteReadBenchmark.java | 32 ++
...IgniteTransactionalWriteInvokeBenchmark.java | 182 +++++++++++
.../IgniteTransactionalWriteReadBenchmark.java | 141 ++++++++
37 files changed, 1821 insertions(+), 68 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/benchmark-client-mode.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-client-mode.properties b/modules/yardstick/config/benchmark-client-mode.properties
index 8941417..ba5525f 100644
--- a/modules/yardstick/config/benchmark-client-mode.properties
+++ b/modules/yardstick/config/benchmark-client-mode.properties
@@ -17,12 +17,14 @@
# Contains all multicast benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
--Xloggc:./gc.log \
+-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/benchmark-failover.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-failover.properties b/modules/yardstick/config/benchmark-failover.properties
new file mode 100644
index 0000000..7ed464c
--- /dev/null
+++ b/modules/yardstick/config/benchmark-failover.properties
@@ -0,0 +1,107 @@
+#
+# 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.
+#
+
+#
+# Contains failover benchmarks.
+#
+
+now0=`date +'%H%M%S'`
+
+# JVM options.
+#JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -Xms15g -Xmx15g"
+JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false -ea"
+
+# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
+JVM_OPTS=${JVM_OPTS}" \
+ -Xloggc:./gc${now0}.log \
+ -XX:+PrintGCDetails \
+ -verbose:gc \
+ -XX:+UseParNewGC \
+ -XX:+UseConcMarkSweepGC \
+ -XX:+UseTLAB \
+ -XX:NewSize=128m \
+ -XX:MaxNewSize=128m \
+ -XX:MaxTenuringThreshold=0 \
+ -XX:SurvivorRatio=1024 \
+ -XX:+UseCMSInitiatingOccupancyOnly \
+ -XX:CMSInitiatingOccupancyFraction=60 \
+"
+
+#Ignite version
+ver="RELEASE-"
+
+# List of default probes.
+# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux).
+BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe
+
+# Packages where the specified benchmark is searched by reflection mechanism.
+BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick
+
+RESTART_SERVERS=true
+
+# Probe point writer class name.
+# BENCHMARK_WRITER=
+
+# Comma-separated list of the hosts to run BenchmarkServers on.
+SERVER_HOSTS=localhost,localhost
+
+# Comma-separated list of the hosts to run BenchmarkDrivers on.
+DRIVER_HOSTS=localhost
+
+# Remote username.
+# REMOTE_USER=
+
+# Number of nodes, used to wait for the specified number of nodes to start.
+nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+
+# Space-separated list of Benchmark driver names (required)
+dn="\
+ IgniteAtomicRetriesBenchmark \
+ IgniteAtomicInvokeRetryBenchmark \
+ IgniteTransactionalWriteReadBenchmark \
+ IgniteTransactionalWriteInvokeBenchmark \
+ IgniteTransactionalInvokeRetryBenchmark \
+ IgniteAtomicOffHeapRetriesBenchmark \
+ IgniteAtomicOffHeapInvokeRetryBenchmark \
+ IgniteTransactionalOffHeapWriteReadBenchmark \
+ IgniteTransactionalOffHeapWriteInvokeBenchmark \
+ IgniteTransactionalOffHeapInvokeRetryBenchmark \
+"
+
+# Warmup 1 min.
+w=60
+
+# Duration 2h = 2*60*60 = 7200 sec.
+d=7200
+
+# Restart delay 10 min = 10 * 60 sec = 600 sec.
+rd=600
+
+# Restart sleep 2 min = 120 sec.
+rs=120
+
+# Keys rang.
+r=100000
+
+# Thread count.
+t=128
+
+# Run configuration which contains all benchmarks.
+CONFIGS="\
+-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 1 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds failover-1b,\
+-cfg ${SCRIPT_DIR}/../config/ignite-failover-localhost-config.xml -nn ${nodesNum} -b 2 -w ${w} -d ${d} -rd ${rd} -rs ${rs} -r ${r} -t ${t} --client -sm PRIMARY_SYNC -dn ${dn} -sn IgniteFailoverNode -ds failover-2b,\
+"
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/benchmark-multicast.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties
index 82fc3f8..536ccf4 100644
--- a/modules/yardstick/config/benchmark-multicast.properties
+++ b/modules/yardstick/config/benchmark-multicast.properties
@@ -17,12 +17,14 @@
# Contains all multicast benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
--Xloggc:./gc.log \
+-Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
@@ -35,6 +37,7 @@ JVM_OPTS=${JVM_OPTS}" \
-XX:+UseCMSInitiatingOccupancyOnly \
-XX:CMSInitiatingOccupancyFraction=60 \
"
+
#Ignite version
ver="RELEASE-"
@@ -63,31 +66,49 @@ DRIVER_HOSTS=localhost
# Number of nodes, used to wait for the specified number of nodes to start.
nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`))
+# Backups count.
+b=1
+
+# Warmup.
+w=60
+
+# Duration.
+d=300
+
+# Threads count.
+t=64
+
+# Sync mode.
+sm=PRIMARY_SYNC
+
+# Jobs.
+j=10
+
# Run configuration which contains all benchmarks.
# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute).
CONFIGS="\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxBenchmark -sn IgniteNode -ds ${ver}tx-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-put-get-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteAffinityCallBenchmark -sn IgniteNode -ds ${ver}affcall-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteApplyBenchmark -sn IgniteNode -ds ${ver}apply-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteBroadcastBenchmark -sn IgniteNode -ds ${ver}broad-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteExecuteBenchmark -sn IgniteNode -ds ${ver}exec-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -j 10 -dn IgniteRunBenchmark -sn IgniteNode -ds ${ver}run-compute-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutGetOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
--cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutBenchmark -sn IgniteNode -ds ${ver}atomic-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxBenchmark -sn IgniteNode -ds ${ver}tx-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetTxBenchmark -sn IgniteNode -ds ${ver}tx-put-get-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryBenchmark -sn IgniteNode -ds ${ver}sql-query-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds ${ver}sql-query-join-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds ${ver}sql-query-put-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteAffinityCallBenchmark -sn IgniteNode -ds ${ver}affcall-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteApplyBenchmark -sn IgniteNode -ds ${ver}apply-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteBroadcastBenchmark -sn IgniteNode -ds ${ver}broad-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteExecuteBenchmark -sn IgniteNode -ds ${ver}exec-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -j ${j} -dn IgniteRunBenchmark -sn IgniteNode -ds ${ver}run-compute-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutGetOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-get-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutOffHeapBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}atomic-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxOffHeapBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\
+-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup\
"
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/benchmark-store.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark-store.properties b/modules/yardstick/config/benchmark-store.properties
index cb9e507..bda136e 100644
--- a/modules/yardstick/config/benchmark-store.properties
+++ b/modules/yardstick/config/benchmark-store.properties
@@ -21,12 +21,14 @@
# - TRANSACTIONAL cache
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
- -Xloggc:./gc.log \
+ -Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/benchmark.properties
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/benchmark.properties b/modules/yardstick/config/benchmark.properties
index d691f1e..67ef5ef 100644
--- a/modules/yardstick/config/benchmark.properties
+++ b/modules/yardstick/config/benchmark.properties
@@ -17,12 +17,14 @@
# Contains all benchmarks
#
+now0=`date +'%H%M%S'`
+
# JVM options.
JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false"
# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses.
JVM_OPTS=${JVM_OPTS}" \
- -Xloggc:./gc.log \
+ -Xloggc:./gc${now0}.log \
-XX:+PrintGCDetails \
-verbose:gc \
-XX:+UseParNewGC \
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/ignite-failover-base-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-failover-base-config.xml b/modules/yardstick/config/ignite-failover-base-config.xml
new file mode 100644
index 0000000..1e1dcff
--- /dev/null
+++ b/modules/yardstick/config/ignite-failover-base-config.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite Spring configuration file to startup grid.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ <bean id="base-ignite-failover.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" abstract="true">
+ <property name="peerClassLoadingEnabled" value="false"/>
+
+ <property name="metricsLogFrequency" value="5000"/>
+
+ <property name="failureDetectionTimeout" value="2000"/>
+
+ <property name="cacheConfiguration">
+ <list>
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic">
+ <property name="name" value="atomic-reties"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic-offheap">
+ <property name="name" value="atomic-offheap-reties"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic">
+ <property name="name" value="atomic-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="atomic-offheap">
+ <property name="name" value="atomic-offheap-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-invoke-retry"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-write-read"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-write-read"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx">
+ <property name="name" value="tx-write-invoke"/>
+ </bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration" parent="tx-offheap">
+ <property name="name" value="tx-offheap-write-invoke"/>
+ </bean>
+ </list>
+ </property>
+
+ <property name="includeEventTypes">
+ <list/>
+ </property>
+
+ <property name="loadBalancingSpi">
+ <bean class="org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi">
+ <property name="perTask" value="false"/>
+ </bean>
+ </property>
+ </bean>
+
+ <bean id="atomic" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="ATOMIC"/>
+
+ <property name="swapEnabled" value="false"/>
+ </bean>
+
+ <bean id="atomic-offheap" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="name" value="atomic-offheap"/>
+
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="ATOMIC"/>
+
+ <property name="swapEnabled" value="false"/>
+
+ <property name="memoryMode" value="OFFHEAP_TIERED"/>
+ </bean>
+
+ <bean id="tx" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+
+ <property name="swapEnabled" value="false"/>
+ </bean>
+
+ <bean id="tx-offheap" class="org.apache.ignite.configuration.CacheConfiguration" abstract="true">
+ <property name="cacheMode" value="PARTITIONED"/>
+
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+
+ <property name="swapEnabled" value="false"/>
+
+ <property name="memoryMode" value="OFFHEAP_TIERED"/>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/config/ignite-failover-localhost-config.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/config/ignite-failover-localhost-config.xml b/modules/yardstick/config/ignite-failover-localhost-config.xml
new file mode 100644
index 0000000..a7c7ff8
--- /dev/null
+++ b/modules/yardstick/config/ignite-failover-localhost-config.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!--
+ Ignite Spring configuration file to startup grid.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+ <import resource="ignite-base-config.xml"/>
+ <import resource="ignite-failover-base-config.xml"/>
+
+ <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" parent="base-ignite-failover.cfg">
+ <property name="localHost" value="127.0.0.1"/>
+
+ <property name="discoverySpi">
+ <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
+ <property name="ipFinder">
+ <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
+ <property name="addresses">
+ <list>
+ <value>127.0.0.1:47500</value>
+ <value>127.0.0.1:47501</value>
+ <value>127.0.0.1:47502</value>
+ <value>127.0.0.1:47503</value>
+ <value>127.0.0.1:47504</value>
+ <value>127.0.0.1:47505</value>
+ <value>127.0.0.1:47506</value>
+ <value>127.0.0.1:47507</value>
+ <value>127.0.0.1:47508</value>
+ <value>127.0.0.1:47509</value>
+ </list>
+ </property>
+ </bean>
+ </property>
+ </bean>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/pom.xml
----------------------------------------------------------------------
diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml
index c87ecbc..5bb41b3 100644
--- a/modules/yardstick/pom.xml
+++ b/modules/yardstick/pom.xml
@@ -37,10 +37,9 @@
<url>http://ignite.apache.org</url>
<properties>
- <yardstick.version>0.7.0</yardstick.version>
+ <yardstick.version>0.8.0</yardstick.version>
</properties>
-
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
index c9d4b85..fa93f00 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
@@ -131,4 +131,4 @@ public abstract class IgniteAbstractBenchmark extends BenchmarkDriverAdapter {
protected int nextRandom(int min, int max) {
return ThreadLocalRandom.current().nextInt(max - min) + min;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index 792d366..74b1da9 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -113,6 +113,26 @@ public class IgniteBenchmarkArguments {
private String jdbcUrl;
/** */
+ @Parameter(names = {"-rd", "--restartdelay"}, description = "Restart delay in seconds")
+ private int restartDelay = 20;
+
+ /** */
+ @Parameter(names = {"-rs", "--restartsleep"}, description = "Restart sleep in seconds")
+ private int restartSleep = 2;
+
+ /** */
+ @Parameter(names = {"-checkingPeriod", "--checkingPeriod"}, description = "Period to check cache consistency in seconds")
+ private int cacheConsistencyCheckingPeriod = 2 * 60;
+
+ /** */
+ @Parameter(names = {"-kc", "--keysCount"}, description = "Count of keys")
+ private int keysCnt = 5;
+
+ /** */
+ @Parameter(names = {"-cot", "--cacheOperationTimeout"}, description = "Max timeout for cache operations in seconds")
+ private int cacheOpTimeout = 30;
+
+ /** */
@Parameter(names = {"-kpt", "--keysPerThread"}, description = "Use not intersecting keys in putAll benchmark")
private boolean keysPerThread;
@@ -271,18 +291,54 @@ public class IgniteBenchmarkArguments {
}
/**
- * @return Description.
+ * @return Delay in second which used in nodes restart algorithm.
*/
- public String description() {
- return "-nn=" + nodes + "-b=" + backups + "-sm=" + syncMode + "-cl=" + clientOnly + "-nc=" + nearCacheFlag +
- (orderMode == null ? "" : "-wom=" + orderMode) + "-txc=" + txConcurrency;
+ public int restartDelay() {
+ return restartDelay;
+ }
+
+ /**
+ * @return Sleep in second which used in nodes restart algorithm.
+ */
+ public int restartSleep() {
+ return restartSleep;
+ }
+
+ /**
+ * @return Keys count.
+ */
+ public int keysCount() {
+ return keysCnt;
+ }
+
+ /**
+ * @return Period in seconds to check cache consistency.
+ */
+ public int cacheConsistencyCheckingPeriod() {
+ return cacheConsistencyCheckingPeriod;
+ }
+
+ /**
+ * @return Cache operation timeout in milliseconds.
+ */
+ public int cacheOperationTimeoutMillis() {
+ return cacheOpTimeout * 1000;
}
/**
* @return {@code True} if use not intersecting keys in putAll benchmark.
*/
public boolean keysPerThread() {
- return keysPerThread;
+ return keysPerThread;
+ }
+
+ /**
+ * @return Description.
+ */
+ public String description() {
+ return "-nn=" + nodes + "-b=" + backups + "-sm=" + syncMode + "-cl=" + clientOnly + "-nc=" + nearCacheFlag +
+ (orderMode == null ? "" : "-wom=" + orderMode) + "-txc=" + txConcurrency + "-rd=" + restartDelay +
+ "-rs=" + restartSleep;
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index 22a9eac..3efa4a5 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -27,9 +27,9 @@ import org.yardstickframework.BenchmarkUtils;
/**
* Abstract class for Ignite benchmarks which use cache.
*/
-public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchmark {
+public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractBenchmark {
/** Cache. */
- protected IgniteCache<Integer, Object> cache;
+ protected IgniteCache<K, V> cache;
/** */
private ThreadLocal<ThreadRange> threadRange = new ThreadLocal<>();
@@ -77,7 +77,7 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma
*
* @return IgniteCache Cache to use.
*/
- protected abstract IgniteCache<Integer, Object> cache();
+ protected abstract IgniteCache<K, V> cache();
/**
*
@@ -109,4 +109,4 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma
return rnd.nextInt(min, max);
}
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
index e023c1d..8a86e2f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
@@ -23,7 +23,7 @@ import org.apache.ignite.IgniteCache;
/**
* Ignite benchmark that performs get operations.
*/
-public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -37,4 +37,4 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
index 63c274f..bbdd760 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java
@@ -37,7 +37,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations.
*/
-public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Statements for closing. */
Set<PreparedStatement> stms = Collections.synchronizedSet(new HashSet<PreparedStatement>());
@@ -136,4 +136,4 @@ public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
index 2ce707c..8cd2347 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
@@ -28,7 +28,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs putAll operations.
*/
-public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Affinity mapper. */
private Affinity<Integer> aff;
@@ -65,4 +65,4 @@ public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
index 32d5b02..63faa2f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
@@ -28,7 +28,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs transactional putAll operations.
*/
-public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** Affinity mapper. */
private Affinity<Integer> aff;
@@ -68,4 +68,4 @@ public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
index ba2d959..69db87f 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs put operations.
*/
-public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
index a92a35e..42f308c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs put and get operations.
*/
-public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -43,4 +43,4 @@ public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
index 07b80cc..5afe0b2 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java
@@ -25,7 +25,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs transactional put and get operations.
*/
-public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(0, args.range() / 2);
@@ -48,4 +48,4 @@ public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
index 47b6922..6f06015 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person1;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
index 69d603c..0112163 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person2;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
index fb5dd68..dae32b4 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.Person8;
/**
* Ignite benchmark that performs put operations for entity with indexed fields.
*/
-public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -38,4 +38,4 @@ public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmar
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("atomic-index");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
index 53bd60c..ead3a63 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java
@@ -24,7 +24,7 @@ import org.apache.ignite.yardstick.cache.model.SampleValue;
/**
* Ignite benchmark that performs transactional put operations.
*/
-public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public boolean test(Map<Object, Object> ctx) throws Exception {
int key = nextRandom(args.range());
@@ -39,4 +39,4 @@ public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("tx");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
index fa16cf2..8e31455 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java
@@ -32,7 +32,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations.
*/
-public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -90,4 +90,4 @@ public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
index ad863b8..1f8006d 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java
@@ -33,7 +33,7 @@ import static org.yardstickframework.BenchmarkUtils.println;
/**
* Ignite benchmark that performs query operations with joins.
*/
-public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -116,4 +116,4 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
index ea9531a..1c258a4 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java
@@ -29,7 +29,7 @@ import org.yardstickframework.BenchmarkConfiguration;
/**
* Ignite benchmark that performs put and query operations.
*/
-public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark {
+public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> {
/** {@inheritDoc} */
@Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
@@ -81,4 +81,4 @@ public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark {
@Override protected IgniteCache<Integer, Object> cache() {
return ignite().cache("query");
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
new file mode 100644
index 0000000..c0567ef
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicInvokeRetryBenchmark.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteAtomicInvokeRetryBenchmark extends IgniteFailoverAbstractBenchmark<String, Set> {
+ /** */
+ private final ConcurrentMap<String, AtomicLong> nextValMap = new ConcurrentHashMap<>();
+
+ /** */
+ private final ReadWriteLock rwl = new ReentrantReadWriteLock(true);
+
+ /** */
+ private volatile Exception ex;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ Thread thread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ final int timeout = args.cacheOperationTimeoutMillis();
+ final int range = args.range();
+
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.cacheConsistencyCheckingPeriod() * 1000);
+
+ rwl.writeLock().lock();
+
+ try {
+ println("Start cache validation.");
+
+ long startTime = U.currentTimeMillis();
+
+ Map<String, Set> badCacheEntries = new HashMap<>();
+
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet()) {
+ String key = e.getKey();
+
+ asyncCache.get(key);
+ Set set = asyncCache.<Set>future().get(timeout);
+
+ if (set == null || e.getValue() == null || !Objects.equals(e.getValue().get(), (long)set.size()))
+ badCacheEntries.put(key, set);
+ }
+
+ if (!badCacheEntries.isEmpty()) {
+ // Print all usefull information and finish.
+ for (Map.Entry<String, Set> e : badCacheEntries.entrySet()) {
+ String key = e.getKey();
+
+ println("Got unexpected set size [key='" + key + "', expSize=" + nextValMap.get(key)
+ + ", cacheVal=" + e.getValue() + "]");
+ }
+
+ println("Next values map contant:");
+ for (Map.Entry<String, AtomicLong> e : nextValMap.entrySet())
+ println("Map Entry [key=" + e.getKey() + ", val=" + e.getValue() + "]");
+
+ println("Cache content:");
+
+ for (int k2 = 0; k2 < range; k2++) {
+ String key2 = "key-" + k2;
+
+ asyncCache.get(key2);
+ Object val = asyncCache.future().get(timeout);
+
+ if (val != null)
+ println("Cache Entry [key=" + key2 + ", val=" + val + "]");
+
+ }
+
+ throw new IllegalStateException("Cache and local map are in inconsistent state " +
+ "[badKeys=" + badCacheEntries.keySet() + ']');
+ }
+
+ println("Clearing all data.");
+
+ asyncCache.removeAll();
+ asyncCache.future().get(timeout);
+
+ nextValMap.clear();
+
+ println("Cache validation successfully finished in "
+ + (U.currentTimeMillis() - startTime) / 1000 + " sec.");
+ }
+ finally {
+ rwl.writeLock().unlock();
+ }
+ }
+ }
+ catch (Throwable e) {
+ ex = new Exception(e);
+
+ println("Got exception: " + e);
+
+ e.printStackTrace();
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "cache-" + cacheName() + "-validator");
+
+ thread.setDaemon(true);
+
+ thread.start();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int k = nextRandom(args.range());
+
+ String key = "key-" + k;
+
+ rwl.readLock().lock();
+
+ try {
+ if (ex != null)
+ throw ex;
+
+ AtomicLong nextAtomicVal = nextValMap.putIfAbsent(key, new AtomicLong(1));
+
+ Long nextVal = 1L;
+
+ if (nextAtomicVal != null)
+ nextVal = nextAtomicVal.incrementAndGet();
+
+ asyncCache.invoke(key, new AddInSetEntryProcessor(), nextVal);
+ asyncCache.future().get(args.cacheOperationTimeoutMillis());
+ }
+ finally {
+ rwl.readLock().unlock();
+ }
+
+ if (ex != null)
+ throw ex;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-invoke-retry";
+ }
+
+ /**
+ */
+ private static class AddInSetEntryProcessor implements CacheEntryProcessor<String, Set, Object> {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public Object process(MutableEntry<String, Set> entry,
+ Object... arguments) throws EntryProcessorException {
+ assert !F.isEmpty(arguments);
+
+ Object val = arguments[0];
+
+ Set set;
+
+ if (!entry.exists())
+ set = new HashSet<>();
+ else
+ set = entry.getValue();
+
+ set.add(val);
+
+ entry.setValue(set);
+
+ return null;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
new file mode 100644
index 0000000..c8b0b1d
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapInvokeRetryBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Invoke retry failover benchmark. <p> Each client maintains a local map that it updates together with cache. Client
+ * invokes an increment closure for all generated keys and atomically increments value for corresponding keys in the
+ * local map. To validate cache contents, all writes from the client are stopped, values in the local map are compared
+ * to the values in the cache.
+ */
+public class IgniteAtomicOffHeapInvokeRetryBenchmark extends IgniteAtomicInvokeRetryBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-offheap-invoke-retry";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
new file mode 100644
index 0000000..ebb9eac
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicOffHeapRetriesBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+/**
+ * Atomic retries failover benchmark.
+ * <p>
+ * Client generates continuous load to the cluster (random get, put, invoke, remove
+ * operations).
+ */
+public class IgniteAtomicOffHeapRetriesBenchmark extends IgniteAtomicRetriesBenchmark {
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-offheap-reties";
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
new file mode 100644
index 0000000..4e60698
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteAtomicRetriesBenchmark.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.Map;
+import javax.cache.processor.EntryProcessorException;
+import javax.cache.processor.MutableEntry;
+import org.apache.ignite.cache.CacheEntryProcessor;
+
+/**
+ * Atomic retries failover benchmark.
+ * <p>
+ * Client generates continuous load to the cluster (random get, put, invoke, remove
+ * operations).
+ */
+public class IgniteAtomicRetriesBenchmark extends IgniteFailoverAbstractBenchmark<Integer, String> {
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final int key = nextRandom(args.range());
+
+ int opNum = nextRandom(4);
+
+ final int timeout = args.cacheOperationTimeoutMillis();
+
+ switch (opNum) {
+ case 0:
+ asyncCache.get(key);
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 1:
+ asyncCache.put(key, String.valueOf(key));
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 2:
+ asyncCache.invoke(key, new TestCacheEntryProcessor());
+ asyncCache.future().get(timeout);
+
+ break;
+
+ case 3:
+ asyncCache.remove(key);
+ asyncCache.future().get(timeout);
+
+ break;
+
+ default:
+ throw new IllegalStateException("Got invalid operation number: " + opNum);
+ }
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected String cacheName() {
+ return "atomic-reties";
+ }
+
+ /**
+ */
+ private static class TestCacheEntryProcessor implements CacheEntryProcessor<Integer, String, String> {
+ /** Serial version uid. */
+ private static final long serialVersionUID = 0;
+
+ /** {@inheritDoc} */
+ @Override public String process(MutableEntry<Integer, String> entry,
+ Object... arguments) throws EntryProcessorException {
+ return "key";
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
new file mode 100644
index 0000000..83fc58f
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverAbstractBenchmark.java
@@ -0,0 +1,320 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import javax.cache.Cache;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteCompute;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.IgniteLogger;
+import org.apache.ignite.cluster.ClusterGroup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtPartitionState;
+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.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteRunnable;
+import org.apache.ignite.mxbean.IgniteMXBean;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.yardstick.cache.IgniteCacheAbstractBenchmark;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
+import org.yardstickframework.BenchmarkUtils.ProcessExecutionResult;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Ignite benchmark that performs long running failover tasks.
+ */
+public abstract class IgniteFailoverAbstractBenchmark<K, V> extends IgniteCacheAbstractBenchmark<K, V> {
+ /** */
+ private static final AtomicBoolean restarterStarted = new AtomicBoolean();
+
+ /** Async Cache. */
+ protected IgniteCache<K, V> asyncCache;
+
+ /** */
+ private final AtomicBoolean firtsExProcessed = new AtomicBoolean();
+
+ /** {@inheritDoc} */
+ @Override public void setUp(final BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ asyncCache = cache.withAsync();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onWarmupFinished() {
+ if (cfg.memberId() == 0 && restarterStarted.compareAndSet(false, true)) {
+ Thread restarterThread = new Thread(new Runnable() {
+ @Override public void run() {
+ try {
+ println("Servers restarter started on driver: "
+ + IgniteFailoverAbstractBenchmark.this.getClass().getSimpleName());
+
+ Ignite ignite = ignite();
+
+ // Read servers configs from cache to local map.
+ IgniteCache<Integer, BenchmarkConfiguration> srvsCfgsCache = ignite.
+ getOrCreateCache(new CacheConfiguration<Integer, BenchmarkConfiguration>().
+ setName("serversConfigs"));
+
+ final Map<Integer, BenchmarkConfiguration> srvsCfgs = new HashMap<>();
+
+ for (Cache.Entry<Integer, BenchmarkConfiguration> e : srvsCfgsCache) {
+ println("Read entry from 'serversConfigs' cache : " + e);
+
+ srvsCfgs.put(e.getKey(), e.getValue());
+ }
+
+ assert ignite.cluster().forServers().nodes().size() == srvsCfgs.size();
+
+ final int backupsCnt = args.backups();
+
+ assert backupsCnt >= 1 : "Backups: " + backupsCnt;
+
+ final boolean isDebug = ignite.log().isDebugEnabled();
+
+ // Main logic.
+ while (!Thread.currentThread().isInterrupted()) {
+ Thread.sleep(args.restartDelay() * 1000);
+
+ int numNodesToRestart = nextRandom(1, backupsCnt + 1);
+
+ List<Integer> ids = new ArrayList<>();
+
+ ids.addAll(srvsCfgs.keySet());
+
+ Collections.shuffle(ids);
+
+ println("Waiting for partitioned map exchage of all nodes");
+
+ IgniteCompute asyncCompute = ignite.compute().withAsync();
+
+ asyncCompute.broadcast(new AwaitPartitionMapExchangeTask());
+
+ asyncCompute.future().get(args.cacheOperationTimeoutMillis());
+
+ println("Start servers restarting [numNodesToRestart=" + numNodesToRestart
+ + ", shuffledIds=" + ids + "]");
+
+ for (int i = 0; i < numNodesToRestart; i++) {
+ Integer id = ids.get(i);
+
+ BenchmarkConfiguration bc = srvsCfgs.get(id);
+
+ ProcessExecutionResult res = BenchmarkUtils.kill9Server(bc, isDebug);
+
+ println("Server with id " + id + " has been killed."
+ + (isDebug ? " Process execution result:\n" + res : ""));
+ }
+
+ Thread.sleep(args.restartSleep() * 1000);
+
+ for (int i = 0; i < numNodesToRestart; i++) {
+ Integer id = ids.get(i);
+
+ BenchmarkConfiguration bc = srvsCfgs.get(id);
+
+ ProcessExecutionResult res = BenchmarkUtils.startServer(bc, isDebug);
+
+ println("Server with id " + id + " has been started."
+ + (isDebug ? " Process execution result:\n" + res : ""));
+ }
+ }
+ }
+ catch (Throwable e) {
+ println("Got exception: " + e);
+ e.printStackTrace();
+
+ U.dumpThreads(null);
+
+ if (e instanceof Error)
+ throw (Error)e;
+ }
+ }
+ }, "servers-restarter");
+
+ restarterThread.setDaemon(true);
+ restarterThread.start();
+ }
+ }
+
+ /**
+ * Awaits for partitiona map exchage.
+ *
+ * @param ignite Ignite.
+ * @throws Exception If failed.
+ */
+ @SuppressWarnings("BusyWait")
+ protected static void awaitPartitionMapExchange(Ignite ignite) throws Exception {
+ IgniteLogger log = ignite.log();
+
+ log.info("Waiting for finishing of a partition exchange on node: " + ignite);
+
+ IgniteKernal kernal = (IgniteKernal)ignite;
+
+ while (true) {
+ boolean partitionsExchangeFinished = true;
+
+ for (IgniteInternalCache<?, ?> cache : kernal.cachesx(null)) {
+ log.info("Checking cache: " + cache.name());
+
+ GridCacheAdapter<?, ?> c = kernal.internalCache(cache.name());
+
+ if (!(c instanceof GridDhtCacheAdapter))
+ break;
+
+ GridDhtCacheAdapter<?, ?> dht = (GridDhtCacheAdapter<?, ?>)c;
+
+ GridDhtPartitionFullMap partMap = dht.topology().partitionMap(true);
+
+ for (Map.Entry<UUID, GridDhtPartitionMap> e : partMap.entrySet()) {
+ log.info("Checking node: " + e.getKey());
+
+ for (Map.Entry<Integer, GridDhtPartitionState> e1 : e.getValue().entrySet()) {
+ if (e1.getValue() != GridDhtPartitionState.OWNING) {
+ log.info("Undesired state [id=" + e1.getKey() + ", state=" + e1.getValue() + ']');
+
+ partitionsExchangeFinished = false;
+
+ break;
+ }
+ }
+
+ if (!partitionsExchangeFinished)
+ break;
+ }
+
+ if (!partitionsExchangeFinished)
+ break;
+ }
+
+ if (partitionsExchangeFinished)
+ return;
+
+ Thread.sleep(100);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onException(Throwable e) {
+ // Proceess only the first exception to prevent a multiple printing of a full thread dump.
+ if (firtsExProcessed.compareAndSet(false, true)) {
+ // Debug info on current client.
+ println("Full thread dump of the current node below.");
+
+ U.dumpThreads(null);
+
+ println("");
+
+ ((IgniteMXBean)ignite()).dumpDebugInfo();
+
+ // Debug info on servers.
+ Ignite ignite = ignite();
+
+ ClusterGroup srvs = ignite.cluster().forServers();
+
+ IgniteCompute asyncCompute = ignite.compute(srvs).withAsync();
+
+ asyncCompute.broadcast(new ThreadDumpPrinterTask(ignite.cluster().localNode().id(), e));
+ asyncCompute.future().get(10_000);
+ }
+ }
+
+ /**
+ * @return Cache name.
+ */
+ protected abstract String cacheName();
+
+ /** {@inheritDoc} */
+ @Override protected IgniteCache<K, V> cache() {
+ return ignite().cache(cacheName());
+ }
+
+ /**
+ */
+ private static class ThreadDumpPrinterTask implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** */
+ private final UUID id;
+
+ /** */
+ private final Throwable e;
+
+ /**
+ * @param id Benchmark node id.
+ * @param e Exception.
+ */
+ ThreadDumpPrinterTask(UUID id, Throwable e) {
+ this.id = id;
+ this.e = e;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ println("Driver finished with exception [driverNodeId=" + id + ", e=" + e + "]");
+ println("Full thread dump of the current server node below.");
+
+ U.dumpThreads(null);
+
+ println("");
+
+ ((IgniteMXBean)ignite).dumpDebugInfo();
+ }
+ }
+
+ /**
+ */
+ private static class AwaitPartitionMapExchangeTask implements IgniteRunnable {
+ /** */
+ private static final long serialVersionUID = 0;
+
+ /** */
+ @IgniteInstanceResource
+ private Ignite ignite;
+
+ /** {@inheritDoc} */
+ @Override public void run() {
+ try {
+ awaitPartitionMapExchange(ignite);
+ }
+ catch (Exception e) {
+ throw new IgniteException(e);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/5b0a18dd/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
new file mode 100644
index 0000000..29405de
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteFailoverNode.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache.failover;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.List;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.yardstick.IgniteNode;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Ignite failover node.
+ */
+public class IgniteFailoverNode extends IgniteNode {
+ /** {@inheritDoc} */
+ @Override public void start(BenchmarkConfiguration cfg) throws Exception {
+ super.start(cfg);
+
+ // Put server configuration at special cache.
+ RuntimeMXBean mxBean = ManagementFactory.getRuntimeMXBean();
+
+ List<String> jvmOpts = mxBean.getInputArguments();
+
+ StringBuilder jvmOptsStr = new StringBuilder();
+
+ for (String opt : jvmOpts)
+ jvmOptsStr.append(opt).append(' ');
+
+ cfg.customProperties().put("JVM_OPTS", jvmOptsStr.toString());
+ cfg.customProperties().put("PROPS_ENV", System.getenv("PROPS_ENV"));
+ cfg.customProperties().put("CLASSPATH", mxBean.getClassPath());
+ cfg.customProperties().put("JAVA", System.getenv("JAVA"));
+
+ IgniteCache<Integer, BenchmarkConfiguration> srvsCfgsCache = ignite().
+ getOrCreateCache(new CacheConfiguration<Integer, BenchmarkConfiguration>().setName("serversConfigs"));
+
+ srvsCfgsCache.put(cfg.memberId(), cfg);
+
+ println("Put at cache [" + cfg.memberId() + "=" + cfg + "]");
+ }
+}
[11/50] [abbrv] ignite git commit: Muted test (IGNITE-1824).
Posted by ag...@apache.org.
Muted test (IGNITE-1824).
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4c1b9d2d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4c1b9d2d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4c1b9d2d
Branch: refs/heads/ignite-1702
Commit: 4c1b9d2d78381f59ce0a52b8c7b4e77a50731ecd
Parents: 6ea3b56
Author: ashutak <as...@gridgain.com>
Authored: Fri Oct 30 20:31:54 2015 +0300
Committer: ashutak <as...@gridgain.com>
Committed: Fri Oct 30 20:31:54 2015 +0300
----------------------------------------------------------------------
.../processors/cache/IgniteCacheTxNearPeekModesTest.java | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/4c1b9d2d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java
index 599a2e8..c32052b 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheTxNearPeekModesTest.java
@@ -25,4 +25,9 @@ public class IgniteCacheTxNearPeekModesTest extends IgniteCacheTxPeekModesTest {
@Override protected boolean hasNearCache() {
return true;
}
-}
\ No newline at end of file
+
+ /** {@inheritDoc} */
+ @Override public void testLocalPeek() throws Exception {
+ fail("https://issues.apache.org/jira/browse/IGNITE-1824");
+ }
+}
[05/50] [abbrv] ignite git commit: Merge branch 'ignite-1745'
Posted by ag...@apache.org.
Merge branch 'ignite-1745'
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/48de0598
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/48de0598
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/48de0598
Branch: refs/heads/ignite-1702
Commit: 48de05989c858e8776a0947761486eed950bd8ce
Parents: 91059ba 7bedc8a
Author: agura <ag...@gridgain.com>
Authored: Thu Oct 29 15:36:59 2015 +0300
Committer: agura <ag...@gridgain.com>
Committed: Thu Oct 29 15:36:59 2015 +0300
----------------------------------------------------------------------
.../processors/cache/GridCacheIoManager.java | 28 +++++++++++++++--
...niteCacheP2pUnmarshallingQueryErrorTest.java | 32 +++++++++++++++++++-
2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------