Search in sources :

Example 6 with RebalanceFactory

use of org.apache.geode.cache.control.RebalanceFactory in project geode by apache.

the class TestFunction method executeWithLastResult.

private void executeWithLastResult(FunctionContext context) {
    RegionFunctionContext rfContext = (RegionFunctionContext) context;
    final PartitionedRegion pr = (PartitionedRegion) rfContext.getDataSet();
    ResourceManager resMan = pr.getCache().getResourceManager();
    RebalanceFactory factory = resMan.createRebalanceFactory();
    RebalanceOperation rebalanceOp = factory.start();
    try {
        RebalanceResults rebalanceResults = rebalanceOp.getResults();
    } catch (CancellationException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    context.getResultSender().lastResult((Serializable) context.getArguments());
}
Also used : RebalanceFactory(org.apache.geode.cache.control.RebalanceFactory) RebalanceOperation(org.apache.geode.cache.control.RebalanceOperation) CancellationException(java.util.concurrent.CancellationException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) RegionFunctionContext(org.apache.geode.cache.execute.RegionFunctionContext) ResourceManager(org.apache.geode.cache.control.ResourceManager) RebalanceResults(org.apache.geode.cache.control.RebalanceResults)

Aggregations

RebalanceFactory (org.apache.geode.cache.control.RebalanceFactory)6 RebalanceOperation (org.apache.geode.cache.control.RebalanceOperation)6 ResourceManager (org.apache.geode.cache.control.ResourceManager)5 RebalanceResults (org.apache.geode.cache.control.RebalanceResults)4 CancellationException (java.util.concurrent.CancellationException)2 InternalResourceManager (org.apache.geode.internal.cache.control.InternalResourceManager)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 Set (java.util.Set)1 Cache (org.apache.geode.cache.Cache)1 RegionFunctionContext (org.apache.geode.cache.execute.RegionFunctionContext)1 PartitionRebalanceInfo (org.apache.geode.cache.partition.PartitionRebalanceInfo)1 GeodeCacheFacade (org.apache.geode.cache.util.AutoBalancer.GeodeCacheFacade)1 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 Expectations (org.jmock.Expectations)1