grp -> createRow( ses, grp.groupId(), grp.cacheOrGroupName(), grp.sharedGroup(), grp.caches() == null ? 0 : grp.caches().size(), grp.config().getCacheMode(), grp.config().getAtomicityMode(), grp.config().getAffinity(), grp.config().getAffinity() != null ? grp.config().getAffinity().partitions() : null, grp.config().getNodeFilter(), grp.config().getDataRegionName(), grp.config().getTopologyValidator(), grp.config().getPartitionLossPolicy(), grp.config().getRebalanceMode(), grp.config().getRebalanceDelay(), grp.config().getRebalanceOrder(), grp.config().getBackups() ), true);
CacheGroupData grpData = new CacheGroupData(grpDesc.config(), grpDesc.groupName(), grpDesc.groupId(), grpDesc.receivedFrom(), grpDesc.startTopologyVersion(), grpDesc.deploymentId(), grpDesc.caches(), 0, grpDesc.persistenceEnabled(), grpDesc.walEnabled(), grpDesc.walChangeRequests()); cacheGrps.put(grpDesc.groupId(), grpData);
/** * @param grpDesc Cache group descriptor. */ public void removeCacheGroup(CacheGroupDescriptor grpDesc) { CacheGroupAffinity rmvd = registeredCacheGrps.remove(grpDesc.groupId()); assert rmvd != null : grpDesc.cacheOrGroupName(); }
/** * @param cacheName Cache name. * @return Group descriptor. */ @Nullable private CacheGroupDescriptor nonSharedCacheGroupByCacheName(String cacheName) { assert cacheName != null; for (CacheGroupDescriptor grpDesc : registeredCacheGrps.values()) { if (!grpDesc.sharedGroup() && grpDesc.caches().containsKey(cacheName)) return grpDesc; } return null; }
/** * @param grpDesc Cache group descriptor. * @param filter Node filter. * @param cacheMode Cache mode. */ public void addCacheGroup(CacheGroupDescriptor grpDesc, IgnitePredicate<ClusterNode> filter, CacheMode cacheMode) { CacheGroupAffinity old = registeredCacheGrps.put(grpDesc.groupId(), new CacheGroupAffinity(grpDesc.cacheOrGroupName(), filter, cacheMode, grpDesc.persistenceEnabled())); assert old == null : old; }
/** * @param desc First descriptor. * @param desc0 Second descriptor. */ private void checkGroupDescriptorsData(CacheGroupDescriptor desc, CacheGroupDescriptor desc0) { assertEquals(desc.groupName(), desc0.groupName()); assertEquals(desc.sharedGroup(), desc0.sharedGroup()); assertEquals(desc.deploymentId(), desc0.deploymentId()); assertEquals(desc.receivedFrom(), desc0.receivedFrom()); assertEquals(desc.startTopologyVersion(), desc0.startTopologyVersion()); assertEquals(desc.config().getName(), desc0.config().getName()); assertEquals(desc.config().getGroupName(), desc0.config().getGroupName()); assertEquals(desc.caches(), desc0.caches()); }
else if (!F.eq(grpDesc.deploymentId(), curGrpDesc.deploymentId())) { return errorFuture("Cannot change WAL mode for caches from different cache groups [" + "cache1=" + cacheNames.iterator().next() + ", grp1=" + grpDesc.groupName() + ", cache2=" + cacheName + ", grp2=" + curGrpDesc.groupName() + ']'); HashSet<String> grpCaches = new HashSet<>(grpDesc.caches().keySet()); "provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCaches + ']'); if (grpDesc.config().getCacheMode() == CacheMode.LOCAL) return errorFuture("WAL mode cannot be changed for LOCAL cache(s): " + cacheNames); if (!grpDesc.persistenceEnabled()) return errorFuture("Cannot change WAL mode because persistence is not enabled for cache(s) [" + "caches=" + cacheNames + ", dataRegion=" + grpDesc.config().getDataRegionName() + ']'); WalStateProposeMessage msg = new WalStateProposeMessage(opId, grpDesc.groupId(), grpDesc.deploymentId(), cctx.localNodeId(), caches, enabled);
stoppedCacheGrps.add(e.getValue().groupId()); boolean stopped = true; if (locDesc.sharedGroup()) { desc = cacheGroupByName(locDesc.groupName()); if (desc != null && desc.deploymentId().equals(locDesc.deploymentId())) stopped = false; desc = nonSharedCacheGroupByCacheName(locDesc.config().getName()); (surviveReconnect(locDesc.config().getName()) || desc.deploymentId().equals(locDesc.deploymentId()))) stopped = false; stoppedCacheGrps.add(locDesc.groupId()); else assert locDesc.groupId() == desc.groupId();
/** {@inheritDoc} */ @Override public void beforeCacheGroupStart(CacheGroupDescriptor grpDesc) { if (grpDesc.persistenceEnabled()) { boolean localEnabled = cctx.database().walEnabled(grpDesc.groupId(), true); boolean globalEnabled = cctx.database().walEnabled(grpDesc.groupId(), false); if (!localEnabled || !globalEnabled) { File dir = cacheWorkDir(grpDesc.config()); assert dir.exists(); boolean res = IgniteUtils.delete(dir); assert res; if (!globalEnabled) grpDesc.walEnabled(false); } } }
assert !cctx.kernalContext().clientNode(); CacheConfiguration<?, ?> ccfg = grpDesc.config(); assert !cctx.discovery().cacheGroupAffinityNodes(grpDesc.groupId(), topVer).contains(cctx.localNode()) : grpDesc.cacheOrGroupName(); grpDesc.cacheOrGroupName(), grpDesc.groupId(), affFunc, ccfg.getNodeFilter(), ccfg.getBackups(), ccfg.getCacheMode() == LOCAL, grpDesc.persistenceEnabled());
/** * @param knownKeys Saved keys set. * @return New keys for local cache groups. */ @Nullable private HashMap<Integer, byte[]> newEncryptionKeys(Set<Integer> knownKeys) { Map<Integer, CacheGroupDescriptor> grpDescs = ctx.cache().cacheGroupDescriptors(); HashMap<Integer, byte[]> newKeys = null; for (CacheGroupDescriptor grpDesc : grpDescs.values()) { if (knownKeys.contains(grpDesc.groupId()) || !grpDesc.config().isEncryptionEnabled()) continue; if (newKeys == null) newKeys = new HashMap<>(); newKeys.put(grpDesc.groupId(), getSpi().encryptKey(getSpi().create())); } return newKeys; }
@Override public String apply(CacheGroupActionData data) { return data.desc.cacheOrGroupName(); } });
/** * Collects non local cache group descriptors. * * @return Collection of non local cache group descriptors. */ private List<CacheGroupDescriptor> nonLocalCacheGroupDescriptors() { return cctx.affinity().cacheGroups().values().stream() .filter(grpDesc -> grpDesc.config().getCacheMode() != CacheMode.LOCAL) .collect(Collectors.toList()); }
/** * @param ccfg Cache configuration to start. * @throws IgniteCheckedException If failed. */ void validateStartCacheConfiguration(CacheConfiguration ccfg) throws IgniteCheckedException { if (ccfg.getGroupName() != null) { CacheGroupDescriptor grpDesc = cacheGroupByName(ccfg.getGroupName()); if (grpDesc != null) { assert ccfg.getGroupName().equals(grpDesc.groupName()); validateCacheGroupConfiguration(grpDesc.config(), ccfg); } } }
/** * Validate propose message. * * @param msg Message. * @return Error message or {@code null} if everything is OK. */ @Nullable private String validate(WalStateProposeMessage msg) { // Is group still there? CacheGroupDescriptor grpDesc = cacheProcessor().cacheGroupDescriptors().get(msg.groupId()); if (grpDesc == null) return "Failed to change WAL mode because some caches no longer exist: " + msg.caches().keySet(); // Are specified caches still there? for (Map.Entry<String, IgniteUuid> cache : msg.caches().entrySet()) { String cacheName = cache.getKey(); DynamicCacheDescriptor cacheDesc = cacheProcessor().cacheDescriptor(cacheName); if (cacheDesc == null || !F.eq(cacheDesc.deploymentId(), cache.getValue())) return "Cache doesn't exist: " + cacheName; } // Are there any new caches in the group? HashSet<String> grpCacheNames = new HashSet<>(grpDesc.caches().keySet()); grpCacheNames.removeAll(msg.caches().keySet()); if (!grpCacheNames.isEmpty()) { return "Cannot change WAL mode because not all cache names belonging to the " + "group are provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCacheNames + ']'; } return null; }
return "Cache group ID conflict (change cache group name) [cacheName=" + cfg.getName() + ", groupName=" + cfg.getGroupName() + (desc.sharedGroup() ? ", conflictingGroupName=" : ", conflictingCacheName=") + desc.cacheOrGroupName() + ']'; (desc.sharedGroup() ? ", conflictingGroupName=" : ", conflictingCacheName=") + desc.cacheOrGroupName() + ']';
(fut.cacheGroupAddedOnExchange(desc.groupId(), desc.receivedFrom()) && !enforcedCentralizedAssignment)) return; "Invalid affinity version [last=" + affTopVer + ", futVer=" + topVer + ", grp=" + desc.cacheOrGroupName() + ']'; List<ClusterNode> curNodes = curAssignment.get(p); assert aliveNodes.containsAll(newNodes) : "Invalid new assignment [grp=" + grpHolder.aff.cacheOrGroupName() + ", nodes=" + newNodes + ", topVer=" + fut.context().events().discoveryCache().version() + "grp=" + desc.cacheOrGroupName() + ", node=" + newPrimary + ", topVer=" + topVer + ']'; assert aliveNodes.containsAll(newNodes0) : "Invalid late assignment [grp=" + grpHolder.aff.cacheOrGroupName() + ", nodes=" + newNodes + ", topVer=" + fut.context().events().discoveryCache().version() + assignment.put(grpHolder.groupId(), cacheAssignment); "[grp=" + desc.cacheOrGroupName() + "]");
/** * @param grpName Group name. * @return Group descriptor if group found. */ @Nullable private CacheGroupDescriptor cacheGroupByName(String grpName) { assert grpName != null; for (CacheGroupDescriptor grpDesc : registeredCacheGrps.values()) { if (grpName.equals(grpDesc.groupName())) return grpDesc; } return null; }
/** * @return Cache group ID. */ public int groupId() { assert grpDesc != null : this; return grpDesc.groupId(); }
cacheGrpsInfo.put(grp.groupId(), new CacheClientReconnectDiscoveryData.CacheGroupInfo(desc.config(), desc.deploymentId(), 0));