public static RebalanceResults rebalanceRegion(Region region) throws CancellationException, InterruptedException { String regionName = region.getName(); // FilterByName only looks at name and not full path if (!PartitionRegionHelper.isPartitionedRegion(region)) { StringBuilder builder = new StringBuilder(); builder.append("Region ").append(regionName).append(" is not partitioned. Instead, it is ") .append(region.getAttributes().getDataPolicy()).append(". It can't be rebalanced."); throw new IllegalArgumentException(builder.toString()); } // Rebalance the region ResourceManager resourceManager = region.getCache().getResourceManager(); RebalanceFactory rebalanceFactory = resourceManager.createRebalanceFactory(); Set<String> regionsToRebalance = new HashSet<String>(); regionsToRebalance.add(regionName); rebalanceFactory.includeRegions(regionsToRebalance); RebalanceOperation rebalanceOperation = rebalanceFactory.start(); // Return the results return rebalanceOperation.getResults(); }
RebalanceFactory rbFactory = manager.createRebalanceFactory(); rbFactory.excludeRegions(excludeRegionNames); rbFactory.includeRegions(includeRegionNames); RebalanceResults results = null;
Set<String> includeRegionSet = new HashSet<>(); includeRegionSet.add(regionName); rbFactory.includeRegions(includeRegionSet);
public static RebalanceResults rebalanceRegion(Region region) throws CancellationException, InterruptedException { String regionName = region.getName(); // FilterByName only looks at name and not full path if (!PartitionRegionHelper.isPartitionedRegion(region)) { StringBuilder builder = new StringBuilder(); builder.append("Region ").append(regionName).append(" is not partitioned. Instead, it is ") .append(region.getAttributes().getDataPolicy()).append(". It can't be rebalanced."); throw new IllegalArgumentException(builder.toString()); } // Rebalance the region ResourceManager resourceManager = region.getCache().getResourceManager(); RebalanceFactory rebalanceFactory = resourceManager.createRebalanceFactory(); Set<String> regionsToRebalance = new HashSet<String>(); regionsToRebalance.add(regionName); rebalanceFactory.includeRegions(regionsToRebalance); RebalanceOperation rebalanceOperation = rebalanceFactory.start(); // Return the results return rebalanceOperation.getResults(); }