Package org.apache.helix.manager.zk

Examples of org.apache.helix.manager.zk.ZKHelixManager


    TestHelper.setupEmptyCluster(_gZkClient, clusterName);
    int[] ids = {0,1,2,3, 4, 5};
    setupInstances(clusterName, ids);

    /////////////////////
    ZKHelixManager manager = new ZKHelixManager(clusterName, "localhost_0",
        InstanceType.PARTICIPANT,
        ZK_ADDR);
    manager.connect();
    HelixDataAccessor accessor = manager.getHelixDataAccessor();
   
    LiveInstance liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance("localhost_0"));
    Assert.assertTrue(liveInstance.getRecord().getListFields().size() == 0);
    Assert.assertTrue(liveInstance.getRecord().getMapFields().size() == 0);
    Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 3);
   
    manager = new ZKHelixManager(clusterName, "localhost_1",
        InstanceType.PARTICIPANT,
        ZK_ADDR);
    manager.setLiveInstanceInfoProvider(new provider(false));
   
    manager.connect();
    accessor = manager.getHelixDataAccessor();
   
    liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance("localhost_1"));
    Assert.assertTrue(liveInstance.getRecord().getListFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getMapFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 4);
   
    manager = new ZKHelixManager(clusterName, "localhost_2",
        InstanceType.PARTICIPANT,
        ZK_ADDR);
    manager.setLiveInstanceInfoProvider(new provider(true));
   
    manager.connect();
    accessor = manager.getHelixDataAccessor();
   
    liveInstance = accessor.getProperty(accessor.keyBuilder().liveInstance("localhost_2"));
    Assert.assertTrue(liveInstance.getRecord().getListFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getMapFields().size() == 1);
    Assert.assertTrue(liveInstance.getRecord().getSimpleFields().size() == 5);
View Full Code Here


    if (_gZkClient.exists("/" + clusterName))
    {
      _gZkClient.deleteRecursive("/" + clusterName);
    }

    ZKHelixManager admin = new ZKHelixManager(clusterName, null,
                                              InstanceType.ADMINISTRATOR,
                                              ZK_ADDR);

    TestHelper.setupEmptyCluster(_gZkClient, clusterName);

    admin.connect();
    AssertJUnit.assertTrue(admin.isConnected());

    HelixAdmin adminTool = admin.getClusterManagmentTool();
//    ConfigScope scope = new ConfigScopeBuilder().forCluster(clusterName)
//        .forResource("testResource").forPartition("testPartition").build();
    HelixConfigScope scope = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTITION)
                                      .forCluster(clusterName)
                                      .forResource("testResource")
                                      .forPartition("testPartition")
                                      .build();

    Map<String, String> properties = new HashMap<String, String>();
    properties.put("pKey1", "pValue1");
    properties.put("pKey2", "pValue2");
    adminTool.setConfig(scope, properties);

    properties = adminTool.getConfig(scope, Arrays.asList("pKey1", "pKey2"));
    Assert.assertEquals(properties.size(), 2);
    Assert.assertEquals(properties.get("pKey1"), "pValue1");
    Assert.assertEquals(properties.get("pKey2"), "pValue2");

    admin.disconnect();
    AssertJUnit.assertFalse(admin.isConnected());

    System.out.println("END " + className + ".testAdministrator() at " + new Date(System.currentTimeMillis()));
  }
View Full Code Here

  public static HelixManager getZKHelixManager(String clusterName,
                                               String instanceName,
                                               InstanceType type,
                                               String zkAddr)
  {
    return new ZKHelixManager(clusterName, instanceName, type, zkAddr);
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.manager.zk.ZKHelixManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.