public static InternalResourceManager getInternalResourceManager(Cache cache) { return (InternalResourceManager) cache.getResourceManager(); }
/** * Causes a rebalance operation to occur on the given Cache. * * @param cache the reference to the Cache to rebalance. * @see org.apache.geode.cache.control.ResourceManager#createRebalanceFactory() */ private void rebalance(final Cache cache) { if (isRebalancing()) { cache.getResourceManager().createRebalanceFactory().start(); } }
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(); }
int chp = (int) this.cache.getResourceManager().getCriticalHeapPercentage(); if (generateDefaults() || chp != MemoryThresholds.DEFAULT_CRITICAL_PERCENTAGE) int ehp = (int) this.cache.getResourceManager().getEvictionHeapPercentage(); if (generateDefaults() || ehp != MemoryThresholds.DEFAULT_EVICTION_PERCENTAGE) atts.addAttribute("", "", EVICTION_HEAP_PERCENTAGE, "", String.valueOf(ehp)); int chp = (int) this.cache.getResourceManager().getCriticalOffHeapPercentage(); if (generateDefaults() || chp != MemoryThresholds.DEFAULT_CRITICAL_PERCENTAGE) int ehp = (int) this.cache.getResourceManager().getEvictionOffHeapPercentage(); if (generateDefaults() || ehp != MemoryThresholds.DEFAULT_EVICTION_PERCENTAGE) atts.addAttribute("", "", EVICTION_OFF_HEAP_PERCENTAGE, "", String.valueOf(ehp));
ResourceManager manager = cache.getResourceManager(); Object[] args = (Object[]) context.getArguments(); String simulate = ((String) args[0]);
getResourceManager().sameAs(other.getResourceManager());
this.cache.getResourceManager().setCriticalHeapPercentage(getCriticalHeapPercentage()); this.cache.getResourceManager().setEvictionHeapPercentage(getEvictionHeapPercentage()); this.cache.getResourceManager() .setCriticalOffHeapPercentage(getCriticalOffHeapPercentage()); this.cache.getResourceManager() .setEvictionOffHeapPercentage(getEvictionOffHeapPercentage());
/** * Do a rebalance and verify balance was improved. If evictionPercentage > 0 (the default) then we * have heapLRU and this can cause simulate and rebalance results to differ if eviction kicks in * between. (See BUG 44899). */ public static void doRebalance() { ResourceManager resMan = cache.getResourceManager(); boolean heapEviction = (resMan.getEvictionHeapPercentage() > 0); RebalanceFactory factory = resMan.createRebalanceFactory(); try { RebalanceResults simulateResults = null; if (!heapEviction) { LogWriterUtils.getLogWriter().info("Calling rebalance simulate"); RebalanceOperation simulateOp = factory.simulate(); simulateResults = simulateOp.getResults(); } LogWriterUtils.getLogWriter().info("Starting rebalancing"); RebalanceOperation rebalanceOp = factory.start(); RebalanceResults rebalanceResults = rebalanceOp.getResults(); } catch (InterruptedException e) { Assert.fail("Interrupted", e); } }
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(); }