/** * @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; }
/** {@inheritDoc} */ @Override protected VisorCacheNamesCollectorTaskResult run(Void arg) { GridCacheProcessor cacheProc = ignite.context().cache(); Map<String, IgniteUuid> caches = new HashMap<>(); Set<String> groups = new HashSet<>(); for (Map.Entry<String, DynamicCacheDescriptor> item : cacheProc.cacheDescriptors().entrySet()) { DynamicCacheDescriptor cd = item.getValue(); caches.put(item.getKey(), cd.deploymentId()); String grp = cd.groupDescriptor().groupName(); if (!F.isEmpty(grp)) groups.add(grp); } return new VisorCacheNamesCollectorTaskResult(caches, groups); }
/** * 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; }
/** * @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); } } }
desc = cacheGroupByName(locDesc.groupName());
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() + ']'); "provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCaches + ']');
grpDesc.groupName(), grpDesc.groupId(), grpDesc.receivedFrom(),
ci.setGrpName(desc.groupDescriptor().groupName()); ci.setGrpId(desc.groupDescriptor().groupId()); ci.setPartitions(desc.cacheConfiguration().getAffinity().partitions());
assertEquals(cacheGrp, cacheDesc.groupDescriptor().groupName());
/** * @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()); }
/** * Tests that ignite can start when caches' configurations with same name in different groups stored. * * @throws Exception If fails. */ @Test public void testStartDuplicatedCacheConfigurations() throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(NODES); ig0.cluster().active(true); startCaches(ig0); DynamicCacheDescriptor desc = ig0.context().cache().cacheDescriptor(cacheName(3)); storeInvalidCacheData(desc); stopAllGrids(); startGrids(NODES); desc = ig0.context().cache().cacheDescriptor(cacheName(3)); assertEquals("expected that group of " + cacheName(3) + " is " + EVEN_GROUP_NAME, EVEN_GROUP_NAME, desc.groupDescriptor().groupName()); }
/** * @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; }
/** {@inheritDoc} */ @Override protected VisorCacheNamesCollectorTaskResult run(Void arg) { GridCacheProcessor cacheProc = ignite.context().cache(); Map<String, IgniteUuid> caches = new HashMap<>(); Set<String> groups = new HashSet<>(); for (Map.Entry<String, DynamicCacheDescriptor> item : cacheProc.cacheDescriptors().entrySet()) { DynamicCacheDescriptor cd = item.getValue(); caches.put(item.getKey(), cd.deploymentId()); String grp = cd.groupDescriptor().groupName(); if (!F.isEmpty(grp)) groups.add(grp); } return new VisorCacheNamesCollectorTaskResult(caches, groups); }
/** * 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; }
/** * @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); } } }
desc = cacheGroupByName(locDesc.groupName());
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() + ']'); "provided [group=" + grpDesc.groupName() + ", missingCaches=" + grpCaches + ']');
grpDesc.groupName(), grpDesc.groupId(), grpDesc.receivedFrom(),
ci.setGrpName(desc.groupDescriptor().groupName()); ci.setGrpId(desc.groupDescriptor().groupId()); ci.setPartitions(desc.cacheConfiguration().getAffinity().partitions());