/** * Adds cache to registry. * * @param desc Cache description. * @return Previously registered cache or {@code null} otherwise. */ private DynamicCacheDescriptor registerCache(DynamicCacheDescriptor desc) { return registeredCaches.put(desc.cacheId(), desc); }
/** * @param cacheId Cache ID. * @return {@code True} if cache stop was requested. */ public boolean cacheStopped(int cacheId) { if (cachesToStop != null) { for (CacheActionData cache : cachesToStop.values()) { if (cache.desc.cacheId() == cacheId) return true; } } return false; }
/** * @param cacheId Cache ID. * @return {@code True} if cache start was requested. */ public boolean cacheStarted(int cacheId) { if (cachesToStart != null) { for (CacheActionData cache : cachesToStart.values()) { if (cache.desc.cacheId() == cacheId) return true; } } return false; }
/** * Adds cache and caches groups that is not registered yet to registry. * * @param descs Cache and cache group descriptors. * @return Future that will be completed when all unregistered cache configurations will be persisted. */ public IgniteInternalFuture<?> addUnregistered(Collection<DynamicCacheDescriptor> descs) { Collection<CacheGroupDescriptor> groups = descs.stream() .map(DynamicCacheDescriptor::groupDescriptor) .filter(grpDesc -> !registeredGrps.containsKey(grpDesc.groupId())) .collect(Collectors.toList()); Collection<DynamicCacheDescriptor> caches = descs.stream() .filter(cacheDesc -> !registeredCaches.containsKey(cacheDesc.cacheId())) .collect(Collectors.toList()); return registerAllCachesAndGroups(groups, caches); }
/** {@inheritDoc} */ @Override public void afterBinaryMemoryRestore( IgniteCacheDatabaseSharedManager mgr, GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException { for (DynamicCacheDescriptor cacheDescriptor : persistentCaches()) { startCacheInRecoveryMode(cacheDescriptor); querySchemas.put(cacheDescriptor.cacheId(), cacheDescriptor.schema().copy()); } }
/** * @param msg Message. * @param node Node sent message. */ public void onClientCacheChange(ClientCacheChangeDiscoveryMessage msg, ClusterNode node) { Map<Integer, Boolean> startedCaches = msg.startedCaches(); if (startedCaches != null) { for (Map.Entry<Integer, Boolean> e : startedCaches.entrySet()) { for (DynamicCacheDescriptor desc : registeredCaches.values()) { if (e.getKey().equals(desc.cacheId())) { ctx.discovery().addClientNode(desc.cacheName(), node.id(), e.getValue()); break; } } } } Set<Integer> closedCaches = msg.closedCaches(); if (closedCaches != null) { for (Integer cacheId : closedCaches) { for (DynamicCacheDescriptor desc : registeredCaches.values()) { if (cacheId.equals(desc.cacheId())) { ctx.discovery().onClientCacheClose(desc.cacheName(), node.id()); break; } } } } }
/** * @param reqId Request ID. * @param startReqs Client cache start request. * @return Descriptors for caches to start. */ @Nullable private List<DynamicCacheDescriptor> clientCachesToStart(UUID reqId, Map<String, DynamicCacheChangeRequest> startReqs) { List<DynamicCacheDescriptor> startDescs = new ArrayList<>(startReqs.size()); for (DynamicCacheChangeRequest startReq : startReqs.values()) { DynamicCacheDescriptor desc = cachesRegistry.cache(CU.cacheId(startReq.cacheName())); if (desc == null) { CacheException err = new CacheException("Failed to start client cache " + "(a cache with the given name is not started): " + startReq.cacheName()); cctx.cache().completeClientCacheChangeFuture(reqId, err); return null; } if (cctx.cacheContext(desc.cacheId()) != null) continue; startDescs.add(desc); } return startDescs; }
/** * Adds caches and cache groups to start from {@code exchActions}. * Removes caches and caches groups to stop from {@code exchActions}. * * @param exchActions Exchange actions. * @return Future that will be completed when all unregistered cache configurations will be persisted. */ public IgniteInternalFuture<?> update(ExchangeActions exchActions) { for (ExchangeActions.CacheGroupActionData stopAction : exchActions.cacheGroupsToStop()) { CacheGroupDescriptor rmvd = unregisterGroup(stopAction.descriptor().groupId()); assert rmvd != null : stopAction.descriptor().cacheOrGroupName(); } for (ExchangeActions.CacheActionData req : exchActions.cacheStopRequests()) unregisterCache(req.descriptor().cacheId()); Collection<CacheGroupDescriptor> grpDescs = exchActions.cacheGroupsToStart().stream() .map(ExchangeActions.CacheGroupActionData::descriptor) .collect(Collectors.toList()); Collection<DynamicCacheDescriptor> cacheDescs = exchActions.cacheStartRequests().stream() .map(ExchangeActions.CacheActionData::descriptor) .collect(Collectors.toList()); return registerAllCachesAndGroups(grpDescs, cacheDescs); }
desc.cacheId(), desc.groupId(), desc.cacheType(),
assert cctx.cacheContext(cacheDesc.cacheId()) == null : "Starting cache has not null context: " + cacheDesc.cacheName(); if (fut.cacheAddedOnExchange(info.getCacheDescriptor().cacheId(), info.getCacheDescriptor().receivedFrom())) { if (fut.events().discoveryCache().cacheGroupAffinityNodes(info.getCacheDescriptor().groupId()).isEmpty()) U.quietAndWarn(log, "No server nodes found for cache client: " + info.getCacheDescriptor().cacheName());
QuerySchema localSchema = recovery.querySchemas.get(desc.cacheId());
if (desc.cacheId() == cacheId) return "Cache ID conflict (change cache name) [cacheName=" + cfg.getName() + ", conflictingCacheName=" + desc.cacheName() + ']';
ci.setCacheId(desc.cacheId()); ci.setGrpName(desc.groupDescriptor().groupName()); ci.setGrpId(desc.groupDescriptor().groupId());
desc.cacheId(), grpDesc.groupId(), cfg.getName(),
grpDesc.onCacheStopped(desc.cacheName(), desc.cacheId());
startDesc.cacheId(), grpDesc.groupId(), ccfg.getName(),
prepareIndexRebuildFuture(tup.get1().cacheId());
ses, cache.cacheName(), cache.cacheId(), cache.cacheType(), cache.groupId(),