@Override public void onEvent(Event evt) { assert evt != null; final DiscoveryEvent e = (DiscoveryEvent)evt; assert e.type() == EVT_NODE_LEFT || e.type() == EVT_NODE_FAILED : this; final GridChangeGlobalStateFuture f = stateChangeFut.get(); if (f != null) { f.initFut.listen(new CI1<IgniteInternalFuture<?>>() { @Override public void apply(IgniteInternalFuture<?> fut) { f.onNodeLeft(e); } }); } } };
/** * @param evt Event. * @return {@code True} if given event is {@link EventType#EVT_NODE_FAILED} or {@link EventType#EVT_NODE_LEFT}. */ public static boolean serverLeftEvent(DiscoveryEvent evt) { return ((evt.type() == EVT_NODE_FAILED || evt.type() == EVT_NODE_LEFT) && !evt.eventNode().isClient()); }
/** * @param nodeId Node ID. * @param discoEvt Event. * @param topVer Topology version. */ public GridDhtPartitionExchangeId(UUID nodeId, DiscoveryEvent discoEvt, AffinityTopologyVersion topVer) { assert nodeId != null; assert topVer != null && topVer.topologyVersion() > 0 : topVer; assert discoEvt != null; this.nodeId = nodeId; this.evt = discoEvt.type(); this.topVer = topVer; this.discoEvt = discoEvt; assert evt == EVT_NODE_LEFT || evt == EVT_NODE_FAILED || evt == EVT_NODE_JOINED || evt == EVT_DISCOVERY_CUSTOM_EVT; }
/** * @param nodeId Node ID. * @return {@code True} if has join event for give node. */ public boolean nodeJoined(UUID nodeId) { for (int i = 0; i < evts.size(); i++) { DiscoveryEvent evt = evts.get(i); if (evt.type() == EVT_NODE_JOINED && nodeId.equals(evt.eventNode().id())) return true; } return false; }
@Override public boolean apply(DiscoveryEvent evt) { info("Node1 event: " + evt); if (evt.type() == EVT_NODE_JOINED) joinLatch.countDown(); return true; } }, EVT_NODE_JOINED);
@Override public boolean apply(DiscoveryEvent evt) { info("Node1 event: " + evt); if (evt.type() == EVT_NODE_JOINED) joinLatch.countDown(); return true; } }, EVT_NODE_JOINED);
/** * @return {@code true} if the given {@code discoEvt} supports the rollback procedure. */ private boolean isRollbackSupported() { if (!firstEvtDiscoCache.checkAttribute(ATTR_DYNAMIC_CACHE_START_ROLLBACK_SUPPORTED, Boolean.TRUE)) return false; // Currently the rollback process is supported for dynamically started caches only. return firstDiscoEvt.type() == EVT_DISCOVERY_CUSTOM_EVT && dynamicCacheStartExchange(); }
@Override public void onEvent(Event evt) { DiscoveryEvent e = (DiscoveryEvent)evt; ClusterNode loc = ctx.localNode(); assert e.type() == EVT_NODE_LEFT || e.type() == EVT_NODE_FAILED : e; final ClusterNode n = e.eventNode(); assert !loc.id().equals(n.id()); for (GridDhtForceKeysFuture<?, ?> f : forceKeyFuts.values()) f.onDiscoveryEvent(e); } };
/** * @return {@code True} if exchange for local node join. */ public boolean localJoinExchange() { return firstDiscoEvt.type() == EVT_NODE_JOINED && firstDiscoEvt.eventNode().isLocal(); }
/** * @param evt Event. * @return {@code True} if given event is {@link EventType#EVT_NODE_JOINED}. */ public static boolean serverJoinEvent(DiscoveryEvent evt) { return (evt.type() == EVT_NODE_JOINED && !evt.eventNode().isClient()); }
/** * @param evt Event. */ private void notifyNodeFail(DiscoveryEvent evt) { if (evt.type() == EVT_NODE_LEFT || evt.type() == EVT_NODE_FAILED) { final ClusterNode n = evt.eventNode(); assert cctx.discovery().node(n.id()) == null; for (GridDhtPartitionsExchangeFuture f : exchFuts.values()) f.onNodeLeft(n); } }
/** * @param evt Discovery event. * @return Affinity topology version. */ private AffinityTopologyVersion affinityTopologyVersion(DiscoveryEvent evt) { if (evt.type() == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) return ((DiscoveryCustomEvent)evt).affinityTopologyVersion(); return new AffinityTopologyVersion(evt.topologyVersion()); }
/** * @param part Partition. * @param type Type. * @param discoEvt Discovery event. */ private void rebalanceEvent(int part, int type, DiscoveryEvent discoEvt) { assert discoEvt != null; grp.addRebalanceEvent(part, type, discoEvt.eventNode(), discoEvt.type(), discoEvt.timestamp()); }
/** {@inheritDoc} */ @Override public boolean changedAffinity() { DiscoveryEvent firstDiscoEvt0 = firstDiscoEvt; assert firstDiscoEvt0 != null; return firstDiscoEvt0.type() == DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT || !firstDiscoEvt0.eventNode().isClient() || firstDiscoEvt0.eventNode().isLocal(); }
/** * @return Short information string. */ public String shortInfo() { return "GridDhtPartitionsExchangeFuture [topVer=" + initialVersion() + ", evt=" + (firstDiscoEvt != null ? IgniteUtils.gridEventName(firstDiscoEvt.type()) : -1) + ", evtNode=" + (firstDiscoEvt != null ? firstDiscoEvt.eventNode() : null) + ", done=" + isDone() + ']'; }
/** * @param crd Coordinator flag. * @throws IgniteCheckedException If failed. * @return Exchange type. */ private ExchangeType onServerNodeEvent(boolean crd) throws IgniteCheckedException { assert !firstDiscoEvt.eventNode().isClient() : this; if (firstDiscoEvt.type() == EVT_NODE_LEFT || firstDiscoEvt.type() == EVT_NODE_FAILED) { onLeft(); exchCtx.events().warnNoAffinityNodes(cctx); centralizedAff = cctx.affinity().onCentralizedAffinityChange(this, crd); } else cctx.affinity().onServerJoin(this, crd); return cctx.kernalContext().clientNode() ? ExchangeType.CLIENT : ExchangeType.ALL; }
/** {@inheritDoc} */ @Override public void onLocalJoin(DiscoveryEvent evt, DiscoCache discoCache) { assert evt.type() == EVT_NODE_JOINED && evt.eventNode().isLocal(); checkMvccSupported(discoCache.allNodes()); onCoordinatorChanged(discoCache.version(), discoCache.allNodes(), false); }
/** * @throws Exception If failed. */ @Params(atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testStartServerTransactionalReplicated() throws Exception { startNodesInClientMode(false); doTest( asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_JOINED), () -> startGrid(UUID.randomUUID().toString()) ); }
/** * @throws Exception If failed. */ @Params(servers = 4, atomicityMode = TRANSACTIONAL, cacheMode = REPLICATED) @Test public void testStopServerTransactionalReplicated() throws Exception { doTest( asMessagePredicate(discoEvt -> discoEvt.type() == EventType.EVT_NODE_LEFT), () -> stopGrid(srvs.remove(srvs.size() - 1).name()) ); }