/** * @return Grid discovery manager. */ public GridDiscoveryManager discovery() { return ctx.discovery(); }
/** * @param grpId Cache group ID. * @param topVer Topology version. * @return Collection of data nodes. */ private Collection<ClusterNode> dataNodes(int grpId, AffinityTopologyVersion topVer) { Collection<ClusterNode> res = ctx.discovery().cacheGroupAffinityNodes(grpId, topVer); return res != null ? res : Collections.<ClusterNode>emptySet(); }
/** * Clean local registered caches and groups */ private void cleanCachesAndGroups() { registeredCaches.clear(); registeredCacheGrps.clear(); ctx.discovery().cleanCachesAndGroups(); }
/** * @param nodeId Node id. * @return Node. */ @Nullable public ClusterNode node(UUID nodeId) { assert nodeId != null; return ctx.discovery().node(nodeId); }
/** * @return Local node. */ public ClusterNode localNode() { return kernalCtx.discovery().localNode(); }
/** * @param nodeId Node ID. * @return Node or {@code null}. */ @Nullable public ClusterNode node(UUID nodeId) { return kernalCtx.discovery().node(nodeId); }
/** {@inheritDoc} */ @Override public Collection<ClusterNode> nodes() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); ClusterNode node = state.node; return node == null ? Collections.<ClusterNode>emptyList() : Collections.singletonList(node); }
/** * * @param sb String builder. * @param ctx Context. */ static void dumpNodeBasicInfo(StringBuilder sb, GridKernalContext ctx) { sb.append("General node info [id=").append(ctx.localNodeId()) .append(", client=").append(ctx.clientNode()) .append(", discoTopVer=").append(ctx.discovery().topologyVersionEx()) .append(", time=").append(formatTime(U.currentTimeMillis())).append(']'); }
/** {@inheritDoc} */ @Override public IgnitePredicate<ClusterNode> predicate() { if (ctx.discovery().topologyVersion() != state.lastTopVer) reset(); return state.p; }
/** * @param val Value. * @return {@code True} if value is obsolete. */ private boolean isObsolete(AtomicDataStructureValue val) { return !(val == null || !(val instanceof VolatileAtomicDataStructureValue)) && ((VolatileAtomicDataStructureValue)val).gridStartTime() != ctx.discovery().gridStartTime(); }
/** * Basically the same as {@link #startWrite(String, byte[])} but for CAS operations. */ private boolean startCas(String key, byte[] expValBytes, byte[] newValBytes) throws IgniteCheckedException { UUID reqId = UUID.randomUUID(); GridFutureAdapter<Boolean> fut = new GridFutureAdapter<>(); updateFuts.put(reqId, fut); DiscoveryCustomMessage msg = new DistributedMetaStorageCasMessage(reqId, key, expValBytes, newValBytes); ctx.discovery().sendCustomEvent(msg); return fut.get(); }
/** * Fails index if any source node is left. */ private void checkSourceNodesAlive() { for (UUID nodeId : sources()) { if (!ctx.discovery().alive(nodeId)) { fail(nodeId, null); return; } } }
/** * Gets next version for cache store load and reload operations. * * @return Next version for cache store operations. */ public GridCacheVersion nextForLoad() { return next(cctx.kernalContext().discovery().topologyVersion(), true, true, dataCenterId); }
/** * @return {@code True} if local node client and discovery SPI supports reconnect. */ public boolean reconnectSupported() { DiscoverySpi spi = getSpi(); ClusterNode clusterNode = ctx.discovery().localNode(); boolean client = (clusterNode instanceof TcpDiscoveryNode) ? (((TcpDiscoveryNode) clusterNode).clientRouterNodeId() != null) : clusterNode.isClient(); return client && (spi instanceof IgniteDiscoverySpi) && ((IgniteDiscoverySpi)spi).clientReconnectSupported(); }
/** {@inheritDoc} */ @Override protected void onKernalStart0() throws IgniteCheckedException { if (igfsCtx.configuration().isFragmentizerEnabled()) { // Check at startup if this node is a fragmentizer coordinator. DiscoveryEvent locJoinEvt = igfsCtx.kernalContext().discovery().localJoinEvent(); checkLaunchCoordinator(locJoinEvt); } }
/** {@inheritDoc} */ @Override public void onActivate(GridKernalContext ctx) { if (log.isDebugEnabled()) log.debug("Activating data structure processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]"); initFailed = false; qryIdMap.clear(); ctx.event().addLocalEventListener(lsnr, EVT_NODE_LEFT, EVT_NODE_FAILED); restoreStructuresState(ctx); onKernalStart0(); }
/** * @param nodeId Node ID to send message to. * @param msg Message to send. * @throws IgniteCheckedException If send failed. */ private void send0(UUID nodeId, Object msg) throws IgniteCheckedException { ClusterNode node = ctx.kernalContext().discovery().node(nodeId); if (msg instanceof Message) ctx.kernalContext().io().sendToGridTopic(node, GridTopic.TOPIC_HADOOP_MSG, (Message)msg, GridIoPolicy.PUBLIC_POOL); else ctx.kernalContext().io().sendUserMessage(F.asList(node), msg, GridTopic.TOPIC_HADOOP, false, 0, false); }
/** {@inheritDoc} */ @Override public void onDeActivate(GridKernalContext kctx) { if (log.isDebugEnabled()) log.debug("DeActivate service processor [nodeId=" + ctx.localNodeId() + " topVer=" + ctx.discovery().topologyVersionEx() + " ]"); cancelFutures(depFuts, new IgniteCheckedException("Failed to deploy service, cluster in active.")); cancelFutures(undepFuts, new IgniteCheckedException("Failed to undeploy service, cluster in active.")); onKernalStop(true); }