Skip to content

Commit

Permalink
IGNITE-22999 Fixed NPE in the cache distribution command (#11490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sw24sX authored Sep 20, 2024
1 parent 6810cdb commit 2fff615
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,9 @@ public void testCacheDistribution() {

createCacheAndPreload(ignite, 100);

createCacheAndPreload(client, "with-node-filter-cache", 1, 3,
node -> node.consistentId().toString().endsWith("0"));

injectTestSystemOut();

// Run distribution for all node and all cache
Expand All @@ -2068,6 +2071,9 @@ public void testCacheDistribution() {
// Result include info by cache "ignite-sys-cache"
assertContains(log, out, "[next group: id=-2100569601, name=ignite-sys-cache]");

// Result include info by cache "with-node-filter-cache"
assertContains(log, out, "[next group: id=-1695684207, name=with-node-filter-cache]");

// Run distribution for all node and all cache and include additional user attribute
assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null", "--user-attributes", "ZONE,CELL,DC"));

Expand All @@ -2088,6 +2094,17 @@ public void testCacheDistribution() {

// Check that number of columns increased by 3
assertEquals(3, userArrtCommaNum - commaNum);

// Run distribution for all node and "with-node-filter-cache" cache
assertEquals(EXIT_CODE_OK, execute("--cache", "distribution", "null", "with-node-filter-cache"));

out = testOut.toString();

// Result include info by cache "with-node-filter-cache"
assertContains(log, out, "[next group: id=-1695684207, name=with-node-filter-cache]");

// Result not include error
assertNotContains(log, out, "Cache distrubution task failed on nodes");
}

/** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,19 @@ public CacheDistributionJob(@Nullable CacheDistributionCommandArg arg, boolean d
return info;

for (Integer id : grpIds) {
final DynamicCacheDescriptor desc = ignite.context().cache().cacheDescriptor(id);

final CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(desc == null ? id : desc.groupId());

if (grpCtx == null)
continue;

final CacheDistributionGroup grp = new CacheDistributionGroup();

info.getGroups().add(grp);

grp.setGroupId(id);

final DynamicCacheDescriptor desc = ignite.context().cache().cacheDescriptor(id);

final CacheGroupContext grpCtx = ignite.context().cache().cacheGroup(desc == null ? id : desc.groupId());

grp.setGroupName(grpCtx.cacheOrGroupName());

grp.setPartitions(new ArrayList<>());
Expand Down

0 comments on commit 2fff615

Please sign in to comment.