Search in sources :

Example 16 with ClusterSetup

use of org.apache.helix.tools.ClusterSetup in project helix by apache.

the class TaskSynchronizedTestBase method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    _participants = new MockParticipantManager[_numNodes];
    String namespace = "/" + CLUSTER_NAME;
    if (_gZkClient.exists(namespace)) {
        _gZkClient.deleteRecursively(namespace);
    }
    _setupTool = new ClusterSetup(ZK_ADDR);
    _setupTool.addCluster(CLUSTER_NAME, true);
    setupParticipants();
    setupDBs();
    startParticipants();
    createManagers();
}
Also used : ClusterSetup(org.apache.helix.tools.ClusterSetup) BeforeClass(org.testng.annotations.BeforeClass)

Example 17 with ClusterSetup

use of org.apache.helix.tools.ClusterSetup in project helix by apache.

the class TestJobStateOnCreation method beforeClass.

@BeforeClass
public void beforeClass() throws Exception {
    _cache = new ClusterDataCache();
    _idealState = new IdealState(WORKFLOW_NAME);
    _resource = new Resource(WORKFLOW_NAME);
    _currStateOutput = new CurrentStateOutput();
    _participants = new MockParticipantManager[_numNodes];
    String namespace = "/" + CLUSTER_NAME;
    if (_gZkClient.exists(namespace)) {
        _gZkClient.deleteRecursively(namespace);
    }
    _setupTool = new ClusterSetup(ZK_ADDR);
    _setupTool.addCluster(CLUSTER_NAME, true);
    createManagers();
}
Also used : ClusterDataCache(org.apache.helix.controller.stages.ClusterDataCache) Resource(org.apache.helix.model.Resource) ClusterSetup(org.apache.helix.tools.ClusterSetup) IdealState(org.apache.helix.model.IdealState) CurrentStateOutput(org.apache.helix.controller.stages.CurrentStateOutput) BeforeClass(org.testng.annotations.BeforeClass)

Example 18 with ClusterSetup

use of org.apache.helix.tools.ClusterSetup in project helix by apache.

the class ClusterAccessor method createCluster.

@PUT
@Path("{clusterId}")
public Response createCluster(@PathParam("clusterId") String clusterId, @DefaultValue("false") @QueryParam("recreate") String recreate) {
    boolean recreateIfExists = Boolean.valueOf(recreate);
    ClusterSetup clusterSetup = getClusterSetup();
    try {
        clusterSetup.addCluster(clusterId, recreateIfExists);
    } catch (Exception ex) {
        _logger.error("Failed to create cluster " + clusterId + ", exception: " + ex);
        return serverError(ex);
    }
    return created();
}
Also used : ClusterSetup(org.apache.helix.tools.ClusterSetup) HelixException(org.apache.helix.HelixException) IOException(java.io.IOException) Path(javax.ws.rs.Path) PUT(javax.ws.rs.PUT)

Example 19 with ClusterSetup

use of org.apache.helix.tools.ClusterSetup in project helix by apache.

the class TestDropResourceMetricsReset method testBasic.

@Test
public void testBasic() throws Exception {
    final int NUM_PARTICIPANTS = 4;
    final int NUM_PARTITIONS = 64;
    final int NUM_REPLICAS = 1;
    final String RESOURCE_NAME = "TestDB0";
    String className = TestHelper.getTestClassName();
    String methodName = TestHelper.getTestMethodName();
    String clusterName = className + "_" + methodName;
    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
    ParticipantMonitorListener listener = new ParticipantMonitorListener("ClusterStatus", clusterName, RESOURCE_NAME);
    // 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
    1, // partitions per resource
    NUM_PARTITIONS, // number of nodes
    NUM_PARTICIPANTS, // replicas
    NUM_REPLICAS, // use FULL_AUTO mode to test node tagging
    "MasterSlave", // use FULL_AUTO mode to test node tagging
    RebalanceMode.FULL_AUTO, // do rebalance
    true);
    // Start participants and controller
    ClusterSetup setupTool = new ClusterSetup(_gZkClient);
    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();
    }
    ClusterControllerManager controller = new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
    // Verify that the bean was created
    boolean noTimeout = _registerLatch.await(30000, TimeUnit.MILLISECONDS);
    Assert.assertTrue(noTimeout);
    // Drop the resource
    setupTool.dropResourceFromCluster(clusterName, RESOURCE_NAME);
    // Verify that the bean was removed
    noTimeout = _unregisterLatch.await(30000, TimeUnit.MILLISECONDS);
    Assert.assertTrue(noTimeout);
    // Clean up
    listener.disconnect();
    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) MockParticipantManager(org.apache.helix.integration.manager.MockParticipantManager) ClusterSetup(org.apache.helix.tools.ClusterSetup) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 20 with ClusterSetup

use of org.apache.helix.tools.ClusterSetup in project helix by apache.

the class MockSpectatorProcess method setup.

private static void setup() {
    IDefaultNameSpace defaultNameSpace = new IDefaultNameSpace() {

        @Override
        public void createDefaultNameSpace(org.I0Itec.zkclient.ZkClient client) {
            client.deleteRecursive("/" + clusterName);
        }
    };
    zkServer = new ZkServer(dataDir, logDir, defaultNameSpace, port);
    zkServer.start();
    ClusterSetup clusterSetup = new ClusterSetup(zkConnectString);
    clusterSetup.setupTestCluster(clusterName);
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : IDefaultNameSpace(org.I0Itec.zkclient.IDefaultNameSpace) ClusterSetup(org.apache.helix.tools.ClusterSetup) ZkServer(org.I0Itec.zkclient.ZkServer)

Aggregations

ClusterSetup (org.apache.helix.tools.ClusterSetup)79 ClusterControllerManager (org.apache.helix.integration.manager.ClusterControllerManager)33 BeforeClass (org.testng.annotations.BeforeClass)33 MockParticipantManager (org.apache.helix.integration.manager.MockParticipantManager)28 ZkClient (org.apache.helix.manager.zk.ZkClient)26 Date (java.util.Date)23 IOException (java.io.IOException)14 HelixException (org.apache.helix.HelixException)14 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)11 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)11 Test (org.testng.annotations.Test)11 ConfigAccessor (org.apache.helix.ConfigAccessor)9 ZNRecord (org.apache.helix.ZNRecord)9 HelixDataAccessor (org.apache.helix.HelixDataAccessor)8 IdealState (org.apache.helix.model.IdealState)8 BestPossAndExtViewZkVerifier (org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier)7 HelixAdmin (org.apache.helix.HelixAdmin)6 ZKHelixDataAccessor (org.apache.helix.manager.zk.ZKHelixDataAccessor)6 StringRepresentation (org.restlet.representation.StringRepresentation)6 ClusterDistributedController (org.apache.helix.integration.manager.ClusterDistributedController)5