Search in sources :

Example 1 with IntermediateStateCalcStage

use of org.apache.helix.controller.stages.IntermediateStateCalcStage in project helix by apache.

the class TestP2PStateTransitionMessages method createPipeline.

private Pipeline createPipeline() {
    Pipeline pipeline = new Pipeline("test");
    pipeline.addStage(new ReadClusterDataStage());
    pipeline.addStage(new BestPossibleStateCalcStage());
    pipeline.addStage(new IntermediateStateCalcStage());
    pipeline.addStage(new MessageGenerationPhase());
    pipeline.addStage(new MessageSelectionStage());
    pipeline.addStage(new MessageThrottleStage());
    return pipeline;
}
Also used : ReadClusterDataStage(org.apache.helix.controller.stages.ReadClusterDataStage) BestPossibleStateCalcStage(org.apache.helix.controller.stages.BestPossibleStateCalcStage) IntermediateStateCalcStage(org.apache.helix.controller.stages.IntermediateStateCalcStage) MessageThrottleStage(org.apache.helix.controller.stages.MessageThrottleStage) MessageGenerationPhase(org.apache.helix.controller.stages.MessageGenerationPhase) MessageSelectionStage(org.apache.helix.controller.stages.MessageSelectionStage) Pipeline(org.apache.helix.controller.pipeline.Pipeline)

Example 2 with IntermediateStateCalcStage

use of org.apache.helix.controller.stages.IntermediateStateCalcStage in project helix by apache.

the class TestRebalancerMetrics method testLoadBalanceMetrics.

@Test
public void testLoadBalanceMetrics() {
    System.out.println("START testLoadBalanceMetrics at " + new Date(System.currentTimeMillis()));
    String resource = "testResourceName";
    int numPartition = 100;
    int numReplica = 3;
    int maxPending = 3;
    setupIdealState(5, new String[] { resource }, numPartition, numReplica, IdealState.RebalanceMode.FULL_AUTO, BuiltInStateModelDefinitions.MasterSlave.name());
    setupInstances(5);
    setupLiveInstances(4);
    setupStateModel();
    Map<String, Resource> resourceMap = getResourceMap(new String[] { resource }, numPartition, BuiltInStateModelDefinitions.MasterSlave.name());
    CurrentStateOutput currentStateOutput = new CurrentStateOutput();
    event.addAttribute(AttributeName.RESOURCES.name(), resourceMap);
    event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(), resourceMap);
    event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
    ClusterStatusMonitor monitor = new ClusterStatusMonitor(_clusterName);
    monitor.active();
    event.addAttribute(AttributeName.clusterStatusMonitor.name(), monitor);
    runStage(event, new ReadClusterDataStage());
    runStage(event, new BestPossibleStateCalcStage());
    BestPossibleStateOutput bestPossibleStateOutput = event.getAttribute(AttributeName.BEST_POSSIBLE_STATE.name());
    currentStateOutput = copyCurrentStateFromBestPossible(bestPossibleStateOutput, resource);
    event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
    setupLiveInstances(4);
    runStage(event, new ReadClusterDataStage());
    ClusterDataCache cache = event.getAttribute(AttributeName.ClusterDataCache.name());
    setupThrottleConfig(cache.getClusterConfig(), StateTransitionThrottleConfig.RebalanceType.LOAD_BALANCE, maxPending);
    runStage(event, new BestPossibleStateCalcStage());
    runStage(event, new IntermediateStateCalcStage());
    ClusterStatusMonitor clusterStatusMonitor = event.getAttribute(AttributeName.clusterStatusMonitor.name());
    ResourceMonitor resourceMonitor = clusterStatusMonitor.getResourceMonitor(resource);
    long numPendingLoadBalance = resourceMonitor.getPendingLoadRebalancePartitionGauge();
    Assert.assertTrue(numPendingLoadBalance > 0);
    Assert.assertEquals(resourceMonitor.getLoadRebalanceThrottledPartitionGauge(), numPendingLoadBalance - maxPending);
    System.out.println("END testLoadBalanceMetrics at " + new Date(System.currentTimeMillis()));
}
Also used : BestPossibleStateOutput(org.apache.helix.controller.stages.BestPossibleStateOutput) ClusterDataCache(org.apache.helix.controller.stages.ClusterDataCache) ReadClusterDataStage(org.apache.helix.controller.stages.ReadClusterDataStage) IntermediateStateCalcStage(org.apache.helix.controller.stages.IntermediateStateCalcStage) Resource(org.apache.helix.model.Resource) Date(java.util.Date) CurrentStateOutput(org.apache.helix.controller.stages.CurrentStateOutput) BestPossibleStateCalcStage(org.apache.helix.controller.stages.BestPossibleStateCalcStage) Test(org.testng.annotations.Test) BaseStageTest(org.apache.helix.controller.stages.BaseStageTest)

Example 3 with IntermediateStateCalcStage

use of org.apache.helix.controller.stages.IntermediateStateCalcStage in project helix by apache.

the class TestRebalancerMetrics method testRecoveryRebalanceMetrics.

@Test
public void testRecoveryRebalanceMetrics() {
    System.out.println("START testRecoveryRebalanceMetrics at " + new Date(System.currentTimeMillis()));
    String resource = "testResourceName";
    int numPartition = 100;
    int numReplica = 3;
    int maxPending = 3;
    setupIdealState(5, new String[] { resource }, numPartition, numReplica, IdealState.RebalanceMode.FULL_AUTO, BuiltInStateModelDefinitions.MasterSlave.name());
    setupInstances(5);
    setupLiveInstances(5);
    setupStateModel();
    Map<String, Resource> resourceMap = getResourceMap(new String[] { resource }, numPartition, BuiltInStateModelDefinitions.MasterSlave.name());
    CurrentStateOutput currentStateOutput = new CurrentStateOutput();
    event.addAttribute(AttributeName.RESOURCES.name(), resourceMap);
    event.addAttribute(AttributeName.RESOURCES_TO_REBALANCE.name(), resourceMap);
    event.addAttribute(AttributeName.CURRENT_STATE.name(), currentStateOutput);
    ClusterStatusMonitor monitor = new ClusterStatusMonitor(_clusterName);
    monitor.active();
    event.addAttribute(AttributeName.clusterStatusMonitor.name(), monitor);
    runStage(event, new ReadClusterDataStage());
    ClusterDataCache cache = event.getAttribute(AttributeName.ClusterDataCache.name());
    setupThrottleConfig(cache.getClusterConfig(), StateTransitionThrottleConfig.RebalanceType.RECOVERY_BALANCE, maxPending);
    runStage(event, new BestPossibleStateCalcStage());
    runStage(event, new IntermediateStateCalcStage());
    ClusterStatusMonitor clusterStatusMonitor = event.getAttribute(AttributeName.clusterStatusMonitor.name());
    ResourceMonitor resourceMonitor = clusterStatusMonitor.getResourceMonitor(resource);
    Assert.assertEquals(resourceMonitor.getPendingRecoveryRebalancePartitionGauge(), numPartition);
    Assert.assertEquals(resourceMonitor.getRecoveryRebalanceThrottledPartitionGauge(), numPartition - maxPending);
    System.out.println("END testRecoveryRebalanceMetrics at " + new Date(System.currentTimeMillis()));
}
Also used : ClusterDataCache(org.apache.helix.controller.stages.ClusterDataCache) ReadClusterDataStage(org.apache.helix.controller.stages.ReadClusterDataStage) BestPossibleStateCalcStage(org.apache.helix.controller.stages.BestPossibleStateCalcStage) IntermediateStateCalcStage(org.apache.helix.controller.stages.IntermediateStateCalcStage) Resource(org.apache.helix.model.Resource) Date(java.util.Date) CurrentStateOutput(org.apache.helix.controller.stages.CurrentStateOutput) Test(org.testng.annotations.Test) BaseStageTest(org.apache.helix.controller.stages.BaseStageTest)

Aggregations

BestPossibleStateCalcStage (org.apache.helix.controller.stages.BestPossibleStateCalcStage)3 IntermediateStateCalcStage (org.apache.helix.controller.stages.IntermediateStateCalcStage)3 ReadClusterDataStage (org.apache.helix.controller.stages.ReadClusterDataStage)3 Date (java.util.Date)2 BaseStageTest (org.apache.helix.controller.stages.BaseStageTest)2 ClusterDataCache (org.apache.helix.controller.stages.ClusterDataCache)2 CurrentStateOutput (org.apache.helix.controller.stages.CurrentStateOutput)2 Resource (org.apache.helix.model.Resource)2 Test (org.testng.annotations.Test)2 Pipeline (org.apache.helix.controller.pipeline.Pipeline)1 BestPossibleStateOutput (org.apache.helix.controller.stages.BestPossibleStateOutput)1 MessageGenerationPhase (org.apache.helix.controller.stages.MessageGenerationPhase)1 MessageSelectionStage (org.apache.helix.controller.stages.MessageSelectionStage)1 MessageThrottleStage (org.apache.helix.controller.stages.MessageThrottleStage)1