Skip to content

Instantly share code, notes, and snippets.

@boglesby
Created September 12, 2021 01:31
public void execute(FunctionContext<Object[]> context) {
// Get the region name
Object[] arguments = context.getArguments();
String regionName = (String) arguments[0];
context.getCache().getLogger().info("GetBucketIdsFunction getting bucket ids for regionName=" + regionName);
// Get the region
PartitionedRegion region = (PartitionedRegion) context.getCache().getRegion(regionName);
// Create the data structure
String redundancyZone = ((InternalDistributedSystem) context.getCache().getDistributedSystem()).getConfig().getRedundancyZone();
int configuredNumberOfBuckets = region.getTotalNumberOfBuckets();
List<Integer> allBucketIds = new ArrayList<>(region.getDataStore().getAllLocalBucketIds());
List<Integer> primaryBucketIds = new ArrayList<>(region.getDataStore().getAllLocalPrimaryBucketIds());
ServerBucketIds ids = new ServerBucketIds(regionName, redundancyZone, configuredNumberOfBuckets, allBucketIds, primaryBucketIds);
// Return result
context.getResultSender().lastResult(ids);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment