Search in sources :

Example 41 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestPartitionMovementThrottle method testResourceThrottleWithDelayRebalancer.

@Test(dependsOnMethods = { "testResourceThrottle" })
public void testResourceThrottleWithDelayRebalancer() throws Exception {
    // start a few participants
    for (int i = 0; i < NODE_NR - 2; i++) {
        _participants[i].syncStart();
    }
    int partition = 10;
    int replica = 3;
    int minActiveReplica = 2;
    int delay = 100;
    for (int i = 0; i < 5; i++) {
        String dbName = "TestDB-" + i;
        IdealState is = _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, dbName);
        if (is != null) {
            System.err.println(dbName + "exists!");
            is.setReplicas(String.valueOf(replica));
            is.setMinActiveReplicas(minActiveReplica);
            if (delay > 0) {
                is.setRebalanceDelay(delay);
            }
            is.setRebalancerClassName(DelayedAutoRebalancer.class.getName());
            _setupTool.getClusterManagementTool().setResourceIdealState(CLUSTER_NAME, dbName, is);
        } else {
            createResourceWithDelayedRebalance(CLUSTER_NAME, dbName, STATE_MODEL, partition, replica, minActiveReplica, delay);
        }
        _setupTool.rebalanceStorageCluster(CLUSTER_NAME, dbName, _replica);
        _dbs.add(dbName);
    }
    HelixClusterVerifier _clusterVerifier = new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
    Assert.assertTrue(_clusterVerifier.verify());
    DelayedTransition.setDelay(20);
    DelayedTransition.enableThrottleRecord();
    // add 2 nodes
    for (int i = NODE_NR - 2; i < NODE_NR; i++) {
        _participants[i].syncStart();
    }
    Assert.assertTrue(_clusterVerifier.verify());
    for (String db : _dbs) {
        validateThrottle(DelayedTransition.getResourcePatitionTransitionTimes(), db, 2);
    }
}
Also used : HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) IdealState(org.apache.helix.model.IdealState) DelayedAutoRebalancer(org.apache.helix.controller.rebalancer.DelayedAutoRebalancer) Test(org.testng.annotations.Test)

Example 42 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestClusterVerifier method testResourceSubset.

@Test
public void testResourceSubset() throws InterruptedException {
    String testDB = "resource-testDB";
    _setupTool.addResourceToCluster(_clusterName, testDB, 1, BuiltInStateModelDefinitions.MasterSlave.name(), RebalanceMode.SEMI_AUTO.toString());
    IdealState idealState = _admin.getResourceIdealState(_clusterName, testDB);
    idealState.setReplicas(Integer.toString(2));
    idealState.getRecord().setListField(testDB + "_0", Arrays.asList(_participants[1].getInstanceName(), _participants[2].getInstanceName()));
    _admin.setResourceIdealState(_clusterName, testDB, idealState);
    // Ensure that this passes even when one resource is down
    _admin.enableInstance(_clusterName, "localhost_12918", false);
    Thread.sleep(1000);
    _admin.enableCluster(_clusterName, false);
    _admin.enableInstance(_clusterName, "localhost_12918", true);
    HelixClusterVerifier verifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(testDB)).build();
    Assert.assertTrue(verifier.verify());
    verifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).setResources(Sets.newHashSet(testDB)).build();
    Assert.assertTrue(verifier.verify());
    // But the full cluster verification should fail
    verifier = new BestPossibleExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
    Assert.assertFalse(verifier.verify(3000));
    verifier = new StrictMatchExternalViewVerifier.Builder(_clusterName).setZkClient(_gZkClient).build();
    Assert.assertFalse(verifier.verify(3000));
    _admin.enableCluster(_clusterName, true);
}
Also used : StrictMatchExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) BestPossibleExternalViewVerifier(org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier) IdealState(org.apache.helix.model.IdealState) Test(org.testng.annotations.Test)

Example 43 with HelixClusterVerifier

use of org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier in project helix by apache.

the class TestDisableResourceMbean method testDisableResourceMonitoring.

@Test
public void testDisableResourceMonitoring() throws Exception {
    final int NUM_PARTICIPANTS = 2;
    String clusterName = TestHelper.getTestClassName() + "_" + TestHelper.getTestMethodName();
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    // Set up cluster
    // participant port
    TestHelper.setupCluster(// participant port
    clusterName, // participant port
    ZK_ADDR, // participant port
    12918, // participant name prefix
    "localhost", // resource name prefix
    "TestDB", // resources
    3, // partitions per resource
    32, // number of nodes
    4, // replicas
    1, // use FULL_AUTO mode to test node tagging
    "MasterSlave", // use FULL_AUTO mode to test node tagging
    RebalanceMode.FULL_AUTO, // do rebalance
    true);
    MockParticipantManager[] participants = new MockParticipantManager[NUM_PARTICIPANTS];
    for (int i = 0; i < NUM_PARTICIPANTS; i++) {
        participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, "localhost_" + (12918 + i));
        participants[i].syncStart();
    }
    ConfigAccessor configAccessor = new ConfigAccessor(_gZkClient);
    HelixConfigScope resourceScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.RESOURCE).forCluster(clusterName).forResource("TestDB1").build();
    configAccessor.set(resourceScope, ResourceConfig.ResourceConfigProperty.MONITORING_DISABLED.name(), "true");
    resourceScope = new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.RESOURCE).forCluster(clusterName).forResource("TestDB2").build();
    configAccessor.set(resourceScope, ResourceConfig.ResourceConfigProperty.MONITORING_DISABLED.name(), "false");
    ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    HelixClusterVerifier clusterVerifier = new BestPossibleExternalViewVerifier.Builder(clusterName).setZkClient(_gZkClient).build();
    Assert.assertTrue(clusterVerifier.verify());
    // Verify the bean was created for TestDB0, but not for TestDB1.
    Assert.assertTrue(_mbeanServer.isRegistered(getMbeanName("TestDB0", clusterName)));
    Assert.assertFalse(_mbeanServer.isRegistered(getMbeanName("TestDB1", clusterName)));
    Assert.assertTrue(_mbeanServer.isRegistered(getMbeanName("TestDB2", clusterName)));
    controller.syncStop();
    for (MockParticipantManager participant : participants) {
        participant.syncStop();
    }
    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
}
Also used : ClusterControllerManager(org.apache.helix.integration.manager.ClusterControllerManager) HelixClusterVerifier(org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) HelixConfigScopeBuilder(org.apache.helix.model.builder.HelixConfigScopeBuilder) HelixConfigScopeBuilder(org.apache.helix.model.builder.HelixConfigScopeBuilder) ConfigAccessor(org.apache.helix.ConfigAccessor) HelixConfigScope(org.apache.helix.model.HelixConfigScope) Date(java.util.Date) Test(org.testng.annotations.Test)

Aggregations

HelixClusterVerifier (org.apache.helix.tools.ClusterVerifiers.HelixClusterVerifier)43 Test (org.testng.annotations.Test)38 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)19 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)17 Date (java.util.Date)15 BestPossibleExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.BestPossibleExternalViewVerifier)14 IdealState (org.apache.helix.model.IdealState)13 Set (java.util.Set)7 ZNRecord (org.apache.helix.ZNRecord)7 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)7 ExternalView (org.apache.helix.model.ExternalView)7 Map (java.util.Map)6 PropertyKey (org.apache.helix.PropertyKey)6 StrictMatchExternalViewVerifier (org.apache.helix.tools.ClusterVerifiers.StrictMatchExternalViewVerifier)5 HashMap (java.util.HashMap)4 ConfigAccessor (org.apache.helix.ConfigAccessor)4 HashSet (java.util.HashSet)3 ErrTransition (org.apache.helix.mock.participant.ErrTransition)3 ClusterConfig (org.apache.helix.model.ClusterConfig)3 CurrentState (org.apache.helix.model.CurrentState)3