use of org.apache.ignite.internal.pagemem.snapshot.StartFullSnapshotAckDiscoveryMessage in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method init.
/**
* Starts activity.
*
* @throws IgniteInterruptedCheckedException If interrupted.
*/
public void init() throws IgniteInterruptedCheckedException {
if (isDone())
return;
initTs = U.currentTimeMillis();
U.await(evtLatch);
assert discoEvt != null : this;
assert exchId.nodeId().equals(discoEvt.eventNode().id()) : this;
assert !dummy && !forcePreload : this;
try {
discoCache.updateAlives(cctx.discovery());
AffinityTopologyVersion topVer = topologyVersion();
srvNodes = new ArrayList<>(discoCache.serverNodes());
remaining.addAll(F.nodeIds(F.view(srvNodes, F.remoteNodes(cctx.localNodeId()))));
crd = srvNodes.isEmpty() ? null : srvNodes.get(0);
boolean crdNode = crd != null && crd.isLocal();
skipPreload = cctx.kernalContext().clientNode();
ExchangeType exchange;
if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
DiscoveryCustomMessage msg = ((DiscoveryCustomEvent) discoEvt).customMessage();
if (msg instanceof DynamicCacheChangeBatch) {
assert exchActions != null && !exchActions.empty();
exchange = onCacheChangeRequest(crdNode);
} else if (msg instanceof StartFullSnapshotAckDiscoveryMessage)
exchange = CU.clientNode(discoEvt.eventNode()) ? onClientNodeEvent(crdNode) : onServerNodeEvent(crdNode);
else {
assert affChangeMsg != null : this;
exchange = onAffinityChangeRequest(crdNode);
}
} else {
if (discoEvt.type() == EVT_NODE_JOINED) {
if (!discoEvt.eventNode().isLocal()) {
Collection<DynamicCacheDescriptor> receivedCaches = cctx.cache().startReceivedCaches(discoEvt.eventNode().id(), topVer);
cctx.affinity().initStartedCaches(crdNode, this, receivedCaches);
} else
cctx.cache().startCachesOnLocalJoin(topVer);
}
exchange = CU.clientNode(discoEvt.eventNode()) ? onClientNodeEvent(crdNode) : onServerNodeEvent(crdNode);
}
updateTopologies(crdNode);
if (exchActions != null && exchActions.hasStop())
cctx.cache().context().database().beforeCachesStop();
switch(exchange) {
case ALL:
{
distributedExchange();
break;
}
case CLIENT:
{
initTopologies();
clientOnlyExchange();
break;
}
case NONE:
{
initTopologies();
onDone(topVer);
break;
}
default:
assert false;
}
} catch (IgniteInterruptedCheckedException e) {
onDone(e);
throw e;
} catch (IgniteNeedReconnectException e) {
onDone(e);
} catch (Throwable e) {
if (reconnectOnError(e))
onDone(new IgniteNeedReconnectException(cctx.localNode(), e));
else {
U.error(log, "Failed to reinitialize local partitions (preloading will be stopped): " + exchId, e);
onDone(e);
}
if (e instanceof Error)
throw (Error) e;
}
}
use of org.apache.ignite.internal.pagemem.snapshot.StartFullSnapshotAckDiscoveryMessage in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method distributedExchange.
/**
* @throws IgniteCheckedException If failed.
*/
private void distributedExchange() throws IgniteCheckedException {
assert crd != null;
assert !cctx.kernalContext().clientNode();
for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
if (cacheCtx.isLocal())
continue;
cacheCtx.preloader().onTopologyChanged(this);
}
waitPartitionRelease();
boolean topChanged = discoEvt.type() != EVT_DISCOVERY_CUSTOM_EVT || affChangeMsg != null;
for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
if (cacheCtx.isLocal() || stopping(cacheCtx.cacheId()))
continue;
if (topChanged) {
// Partition release future is done so we can flush the write-behind store.
cacheCtx.store().forceFlush();
}
cacheCtx.topology().beforeExchange(this, !centralizedAff);
}
cctx.database().beforeExchange(this);
// If a backup request, synchronously wait for backup start.
if (discoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT) {
DiscoveryCustomMessage customMessage = ((DiscoveryCustomEvent) discoEvt).customMessage();
if (customMessage instanceof StartFullSnapshotAckDiscoveryMessage) {
StartFullSnapshotAckDiscoveryMessage backupMsg = (StartFullSnapshotAckDiscoveryMessage) customMessage;
if (!cctx.localNode().isClient() && !cctx.localNode().isDaemon()) {
ClusterNode node = cctx.discovery().node(backupMsg.initiatorNodeId());
assert node != null;
IgniteInternalFuture fut = cctx.database().startLocalSnapshotCreation(backupMsg, node, backupMsg.message());
if (fut != null)
fut.get();
}
}
}
if (crd.isLocal()) {
if (remaining.isEmpty())
onAllReceived();
} else
sendPartitions(crd);
initDone();
}
Aggregations