/** {@inheritDoc} */ @Override public String toString() { return "CacheGroupContext [grp=" + cacheOrGroupName() + ']'; }
/** * @return Topology. */ public GridDhtPartitionTopology topology() { if (top == null) throw new IllegalStateException("Topology is not initialized: " + cacheOrGroupName()); return top; }
/** * String representation of supply routine. * * @param topicId Topic id. * @param demander Demander. * @param demandMsg Demand message. */ private String supplyRoutineInfo(int topicId, UUID demander, GridDhtPartitionDemandMessage demandMsg) { return "grp=" + grp.cacheOrGroupName() + ", demander=" + demander + ", topVer=" + demandMsg.topologyVersion() + ", topic=" + topicId; }
/** * String representation of demand routine. * * @param topicId Topic id. * @param supplier Supplier. * @param supplyMsg Supply message. */ private String demandRoutineInfo(int topicId, UUID supplier, GridDhtPartitionSupplyMessage supplyMsg) { return "grp=" + grp.cacheOrGroupName() + ", topVer=" + supplyMsg.topologyVersion() + ", supplier=" + supplier + ", topic=" + topicId; }
/** {@inheritDoc} */ @Override public AffinityTopologyVersion readyTopologyVersion() { AffinityTopologyVersion topVer = this.readyTopVer; assert topVer.topologyVersion() > 0 : "Invalid topology version [topVer=" + topVer + ", group=" + grp.cacheOrGroupName() + ']'; return topVer; }
/** {@inheritDoc} */ @Override public AffinityTopologyVersion lastTopologyChangeVersion() { AffinityTopologyVersion topVer = this.lastTopChangeVer; assert topVer.topologyVersion() > 0 : "Invalid topology version [topVer=" + topVer + ", group=" + grp.cacheOrGroupName() + ']'; return topVer; }
/** * @param grpCtx Group context. * @param partId Partition ID to destroy. */ private void addDestroyRequest(@Nullable CacheGroupContext grpCtx, int grpId, int partId) { PartitionDestroyRequest req = new PartitionDestroyRequest(grpId, partId); PartitionDestroyRequest old = pendingReqs.putIfAbsent(new T2<>(grpId, partId), req); assert old == null || grpCtx == null : "Must wait for old destroy request to finish before adding a new one " + "[grpId=" + grpId + ", grpName=" + grpCtx.cacheOrGroupName() + ", partId=" + partId + ']'; }
/** * @param cacheId Cache ID. */ public void onCacheStopped(int cacheId) { assert grp.sharedGroup() : grp.cacheOrGroupName(); for (Iterator<RemovedEntryHolder> it = rmvQueue.iterator(); it.hasNext();) { RemovedEntryHolder e = it.next(); if (e.cacheId() == cacheId) it.remove(); } cacheMaps.remove(cacheId); }
/** * @param enabled Local WAL enabled flag. */ public void localWalEnabled(boolean enabled) { if (localWalEnabled != enabled){ log.info("Local WAL state for group=" + cacheOrGroupName() + " changed from " + localWalEnabled + " to " + enabled); persistLocalWalState(enabled); localWalEnabled = enabled; } }
/** * @param enabled Global WAL enabled flag. */ public void globalWalEnabled(boolean enabled) { if (globalWalEnabled != enabled) { log.info("Global WAL state for group=" + cacheOrGroupName() + " changed from " + globalWalEnabled + " to " + enabled); persistGlobalWalState(enabled); globalWalEnabled = enabled; } }
/** * Shows progress group of eviction. */ private void showProgress() { if (log.isInfoEnabled()) log.info("Group eviction in progress [grpName=" + grp.cacheOrGroupName()+ ", grpId=" + grp.groupId() + ", remainingPartsToEvict=" + (totalTasks.get() - taskInProgress) + ", partsEvictInProgress=" + taskInProgress + ", totalParts= " + grp.topology().localPartitions().size() + "]"); } }
/** * @param cctx Cache context. */ public void addCacheWithContinuousQuery(GridCacheContext cctx) { assert sharedGroup() : cacheOrGroupName(); assert cctx.group() == this : cctx.name(); assert !cctx.isLocal() : cctx.name(); synchronized (this) { List<GridCacheContext> contQryCaches = this.contQryCaches; if (contQryCaches == null) contQryCaches = new ArrayList<>(); contQryCaches.add(cctx); this.contQryCaches = contQryCaches; } }
/** * @param cacheGrps All configured cache groups. * @param groupName Name of group to find. * @return Cache configuration. */ private CacheConfiguration findGroupConfig(Map<Integer, CacheGroupContext> cacheGrps, @Nullable String groupName) { if (groupName == null) groupName = DEFAULT_CACHE_NAME; for (CacheGroupContext grpCtx : cacheGrps.values()) { if (groupName.equals(grpCtx.cacheOrGroupName())) return grpCtx.config(); } return null; } }
/** * @param cctx Cache context. */ public void removeCacheWithContinuousQuery(GridCacheContext cctx) { assert sharedGroup() : cacheOrGroupName(); assert cctx.group() == this : cctx.name(); assert !cctx.isLocal() : cctx.name(); synchronized (this) { List<GridCacheContext> contQryCaches = this.contQryCaches; if (contQryCaches == null) return; contQryCaches.remove(cctx); if (contQryCaches.isEmpty()) contQryCaches = null; this.contQryCaches = contQryCaches; } }
/** * @param nodeId Node id. */ private void cancel(UUID nodeId) { synchronized (this) { if (isDone()) return; U.log(log, ("Cancelled rebalancing [grp=" + grp.cacheOrGroupName() + ", supplier=" + nodeId + ", topVer=" + topologyVersion() + ']')); cleanupRemoteContexts(nodeId); remaining.remove(nodeId); onDone(false); // Finishing rebalance future as non completed. checkIsDone(); // But will finish syncFuture only when other nodes are preloaded or rebalancing cancelled. } }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(GridDhtLocalPartition.class, this, "grp", grp.cacheOrGroupName(), "state", state(), "reservations", reservations(), "empty", isEmpty(), "createTime", U.format(createTime)); }
/** * Await evict finish partition. */ private void awaitFinish(Integer part, IgniteInternalFuture<?> fut) { // Wait for last offered partition eviction completion try { log.info("Await partition evict, grpName=" + grp.cacheOrGroupName() + ", grpId=" + grp.groupId() + ", partId=" + part); fut.get(); } catch (IgniteCheckedException e) { if (log.isDebugEnabled()) log.warning("Failed to await partition eviction during stopping.", e); } }
/** {@inheritDoc} */ @Override public void onMarkCheckpointBegin(Context ctx) throws IgniteCheckedException { assert grp.dataRegion().pageMemory() instanceof PageMemoryEx; Executor execSvc = ctx.executor(); boolean needSnapshot = ctx.nextSnapshot() && ctx.needToSnapshot(grp.cacheOrGroupName()); if (needSnapshot) { if (execSvc == null) updateSnapshotTag(ctx); else { execSvc.execute(() -> { try { updateSnapshotTag(ctx); } catch (IgniteCheckedException e) { throw new IgniteException(e); } }); } } syncMetadata(execSvc, ctx, needSnapshot); }
/** * @param grp Cache group. */ private void cleanup(CacheGroupContext grp) { CacheConfiguration cfg = grp.config(); for (Object obj : grp.configuredUserObjects()) cleanup(cfg, obj, false); if (!grp.systemCache() && !U.IGNITE_MBEANS_DISABLED) { try { ctx.config().getMBeanServer().unregisterMBean(U.makeMBeanName(ctx.igniteInstanceName(), CACHE_GRP_METRICS_MBEAN_GRP, grp.cacheOrGroupName())); } catch (Throwable e) { U.error(log, "Failed to unregister MBean for cache group: " + grp.name(), e); } } }
/** {@inheritDoc} */ @Override public boolean rebalanceRequired(AffinityTopologyVersion rebTopVer, GridDhtPartitionsExchangeFuture exchFut) { if (ctx.kernalContext().clientNode() || rebTopVer.equals(AffinityTopologyVersion.NONE)) return false; // No-op. if (exchFut.resetLostPartitionFor(grp.cacheOrGroupName())) return true; if (exchFut.localJoinExchange()) return true; // Required, can have outdated updSeq partition counter if node reconnects. if (!grp.affinity().cachedVersions().contains(rebTopVer)) { assert rebTopVer.compareTo(grp.localStartVersion()) <= 0 : "Empty hisroty allowed only for newly started cache group [rebTopVer=" + rebTopVer + ", localStartTopVer=" + grp.localStartVersion() + ']'; return true; // Required, since no history info available. } final IgniteInternalFuture<Boolean> rebFut = rebalanceFuture(); if (rebFut.isDone() && !rebFut.result()) return true; // Required, previous rebalance cancelled. AffinityTopologyVersion lastAffChangeTopVer = ctx.exchange().lastAffinityChangedTopologyVersion(exchFut.topologyVersion()); return lastAffChangeTopVer.compareTo(rebTopVer) > 0; }