• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ClusterSetup类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.apache.helix.tools.ClusterSetup的典型用法代码示例。如果您正苦于以下问题:Java ClusterSetup类的具体用法?Java ClusterSetup怎么用?Java ClusterSetup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ClusterSetup类属于org.apache.helix.tools包,在下文中一共展示了ClusterSetup类的39个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testDisableNode

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Test()
public void testDisableNode() throws Exception {
  String command =
      "-zkSvr " + ZK_ADDR + " -enableInstance " + CLUSTER_NAME + " " + PARTICIPANT_PREFIX
          + "_12918" + " TestDB TestDB_0 false";
  ClusterSetup.processCommandLineArgs(command.split(" "));
  boolean result =
      ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
          ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);

  ZKHelixAdmin tool = new ZKHelixAdmin(_gZkClient);
  tool.enableInstance(CLUSTER_NAME, PARTICIPANT_PREFIX + "_12918", true);

  result =
      ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
          ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);

}
 

开发者ID:apache,
项目名称:helix,
代码行数:21,
代码来源:TestDisableNode.java

示例2: testDropResource

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Test()
public void testDropResource() throws Exception {
  // add a resource to be dropped
  _setupTool.addResourceToCluster(CLUSTER_NAME, "MyDB", 6, STATE_MODEL);
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, "MyDB", 3);

  boolean result =
      ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
          ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);

  String command = "-zkSvr " + ZK_ADDR + " -dropResource " + CLUSTER_NAME + " " + "MyDB";
  ClusterSetup.processCommandLineArgs(command.split(" "));

  TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB",
      TestHelper.<String> setOf("localhost_12918", "localhost_12919", "localhost_12920",
          "localhost_12921", "localhost_12922"), ZK_ADDR);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:19,
代码来源:TestDropResource.java

示例3: beforeClass

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants =  new MockParticipantManager[_numNodes];
  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  createManagers();

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  HelixClusterVerifier clusterVerifier =
      new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkAddr(ZK_ADDR).build();
  Assert.assertTrue(clusterVerifier.verify());

  _zkServerRef.set(_zkServer);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:26,
代码来源:TestZkConnectionLost.java

示例4: setupCluster

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
void setupCluster() throws HelixException {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);
  _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, 20, STATE_MODEL);
  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = "localhost_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, 3);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:19,
代码来源:TestClusterStartsup.java

示例5: setupCluster

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
private static void setupCluster(String clusterName, String ZkAddr, int startPort,
    String participantNamePrefix, String resourceNamePrefix, int resourceNb, int partitionNb,
    int nodesNb, int replica, String stateModelDef, boolean doRebalance) throws Exception {
  if (_gZkClient.exists("/" + clusterName)) {
    LOG.warn("Cluster already exists:" + clusterName + ". Deleting it");
    _gZkClient.deleteRecursive("/" + clusterName);
  }

  ClusterSetup setupTool = new ClusterSetup(ZkAddr);
  setupTool.addCluster(clusterName, true);
  setupTool.addStateModelDef(clusterName, "Bootstrap",
      TestHelper.generateStateModelDefForBootstrap());

  for (int i = 0; i < nodesNb; i++) {
    int port = startPort + i;
    setupTool.addInstanceToCluster(clusterName, participantNamePrefix + "_" + port);
  }

  for (int i = 0; i < resourceNb; i++) {
    String dbName = resourceNamePrefix + i;
    setupTool.addResourceToCluster(clusterName, dbName, partitionNb, stateModelDef);
    if (doRebalance) {
      setupTool.rebalanceStorageCluster(clusterName, dbName, replica);
    }
  }
}
 

开发者ID:apache,
项目名称:helix,
代码行数:27,
代码来源:TestNonOfflineInitState.java

示例6: beforeSuite

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  // TODO: use logging.properties file to config java.util.logging.Logger levels
  java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
  topJavaLogger.setLevel(Level.WARNING);

  // Due to ZOOKEEPER-2693 fix, we need to specify whitelist for execute zk commends
  System.setProperty("zookeeper.4lw.commands.whitelist", "*");

  _zkServer = TestHelper.startZkServer(ZK_ADDR);
  AssertJUnit.assertTrue(_zkServer != null);
  ZKClientPool.reset();

  _gZkClient = new ZkClient(ZK_ADDR);
  _gZkClient.setZkSerializer(new ZNRecordSerializer());
  _gSetupTool = new ClusterSetup(_gZkClient);
  _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:19,
代码来源:ZkIntegrationTestBase.java

示例7: beforeClass

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants = new MockParticipantManager[_numNodes];
  _numDbs = 1;
  _numNodes = 1;
  _numParitions = 5;
  _numReplicas = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  startParticipants();
  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();

  HelixClusterVerifier clusterVerifier =
      new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
  Assert.assertTrue(clusterVerifier.verify(10000));
}
 

开发者ID:apache,
项目名称:helix,
代码行数:27,
代码来源:TestJobFailureHighThreshold.java

示例8: beforeClass

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants =  new MockParticipantManager[_numNodes];
  _numNodes = 2;
  _numParitions = 2;
  _numReplicas = 1; // only Master, no Slave
  _numDbs = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  startParticipants();
  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();
}
 

开发者ID:apache,
项目名称:helix,
代码行数:23,
代码来源:TestJobTimeout.java

示例9: beforeClass

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants = new MockParticipantManager[_numNodes];
  _numNodes = 2;
  _numParitions = 2;
  _numReplicas = 1; // only Master, no Slave
  _numDbs = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  startParticipants();
  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();

  Thread.sleep(1000); // Wait for cluster to setup.
}
 

开发者ID:apache,
项目名称:helix,
代码行数:25,
代码来源:TestJobFailure.java

示例10: beforeClass

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants =  new MockParticipantManager[_numNodes];
  _numNodes = 2;
  _numParitions = 2;
  _numReplicas = 1; // only Master, no Slave
  _numDbs = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();

  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();
}
 

开发者ID:apache,
项目名称:helix,
代码行数:23,
代码来源:TestRebalanceRunningTask.java

示例11: setup

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
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();
    }
  }
 

开发者ID:apache,
项目名称:helix,
代码行数:21,
代码来源:MockSpectatorProcess.java

示例12: addConfiguration

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
private static void addConfiguration(ClusterSetup setup, String baseDir, String clusterName,
    String instanceName) throws IOException {
  Map<String, String> properties = new HashMap<String, String>();
  HelixConfigScopeBuilder builder = new HelixConfigScopeBuilder(ConfigScopeProperty.PARTICIPANT);
  HelixConfigScope instanceScope =
      builder.forCluster(clusterName).forParticipant(instanceName).build();
  properties.put("change_log_dir", baseDir + instanceName + "/translog");
  properties.put("file_store_dir", baseDir + instanceName + "/filestore");
  properties.put("check_point_dir", baseDir + instanceName + "/checkpoint");
  setup.getClusterManagementTool().setConfig(instanceScope, properties);
  FileUtils.deleteDirectory(new File(properties.get("change_log_dir")));
  FileUtils.deleteDirectory(new File(properties.get("file_store_dir")));
  FileUtils.deleteDirectory(new File(properties.get("check_point_dir")));
  new File(properties.get("change_log_dir")).mkdirs();
  new File(properties.get("file_store_dir")).mkdirs();
  new File(properties.get("check_point_dir")).mkdirs();
}
 

开发者ID:apache,
项目名称:helix,
代码行数:18,
代码来源:IntegrationTest.java

示例13: createCluster

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@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();
}
 

开发者ID:apache,
项目名称:helix,
代码行数:17,
代码来源:ClusterAccessor.java

示例14: beforeSuite

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  if (!_init) {
    // TODO: use logging.properties file to config java.util.logging.Logger levels
    java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
    topJavaLogger.setLevel(Level.WARNING);

    _gZkClient = new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
        ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
    _gZkClientTestNS = new ZkClient(_zkAddrTestNS, ZkClient.DEFAULT_CONNECTION_TIMEOUT, ZkClient.DEFAULT_SESSION_TIMEOUT,
        new ZNRecordSerializer());
    _gSetupTool = new ClusterSetup(_gZkClient);
    _configAccessor = new ConfigAccessor(_gZkClient);
    _baseAccessor = new ZkBaseDataAccessor<>(_gZkClient);
    _baseAccessorTestNS = new ZkBaseDataAccessor<>(_gZkClientTestNS);

    // wait for the web service to start
    Thread.sleep(100);

    setup();
    _init = true;
  }
}
 

开发者ID:apache,
项目名称:helix,
代码行数:24,
代码来源:AbstractTestClass.java

示例15: delete

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
/**
 * Remove a cluster
 * <p>
 * Usage: <code> curl -X DELETE http://{host:port}/clusters/{clusterName}
 */
@Override
public Representation delete() {
  try {
    String clusterName =
        ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
    ZkClient zkClient =
        ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkClient);
    setupTool.deleteCluster(clusterName);
    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
  }
  return null;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:23,
代码来源:ClusterResource.java

示例16: delete

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
/**
 * Remove constraints
 * <p>
 * Usage:
 * <code>curl -X DELETE http://{host:port}/clusters/{cluster}/constraints/MESSAGE_CONSTRAINT/{constraintId}
 */
@Override
public Representation delete() {
  String clusterName =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
  String constraintTypeStr =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CONSTRAINT_TYPE);
  String constraintId =
      ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CONSTRAINT_ID);

  try {
    ZkClient zkClient =
        ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkClient);

    setupTool.removeConstraint(clusterName, constraintTypeStr, constraintId);
  } catch (Exception e) {
    LOG.error("Error in delete constraint", e);
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
  }
  return null;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:30,
代码来源:ConstraintResource.java

示例17: getSchedulerTasksRepresentation

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
StringRepresentation getSchedulerTasksRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  String instanceName = (String) getRequest().getAttributes().get("instanceName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);
  List<String> instances =
      setupTool.getClusterManagementTool().getInstancesInCluster(clusterName);

  HelixDataAccessor accessor =
      ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
  LiveInstance liveInstance =
      accessor.getProperty(accessor.keyBuilder().liveInstance(instanceName));
  String sessionId = liveInstance.getSessionId();

  StringRepresentation representation = new StringRepresentation("");// (ClusterRepresentationUtil.ObjectToJson(instanceConfigs),
                                                                     // MediaType.APPLICATION_JSON);

  return representation;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:21,
代码来源:SchedulerTasksResource.java

示例18: getStateModelsRepresentation

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
StringRepresentation getStateModelsRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  String clusterName = (String) getRequest().getAttributes().get("clusterName");
  ZkClient zkClient = (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
  ClusterSetup setupTool = new ClusterSetup(zkClient);

  List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);

  ZNRecord modelDefinitions = new ZNRecord("modelDefinitions");
  modelDefinitions.setListField("models", models);

  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions),
          MediaType.APPLICATION_JSON);

  return representation;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:18,
代码来源:StateModelsResource.java

示例19: delete

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
public Representation delete() {
  try {
    String clusterName =
        ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
    String resourceName =
        ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.RESOURCE_NAME);
    ZkClient zkclient =
        ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);

    ClusterSetup setupTool = new ClusterSetup(zkclient);
    setupTool.dropResourceFromCluster(clusterName, resourceName);
    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("", e);
  }
  return null;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:22,
代码来源:ResourceGroupResource.java

示例20: delete

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
public Representation delete() {
  try {
    String clusterName =
        ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.CLUSTER_NAME);
    String instanceName =
        ResourceUtil.getAttributeFromRequest(getRequest(), ResourceUtil.RequestKey.INSTANCE_NAME);
    ZkClient zkclient =
        ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkclient);
    setupTool.dropInstanceFromCluster(clusterName, instanceName);
    getResponse().setStatus(Status.SUCCESS_OK);
  } catch (Exception e) {
    getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
        MediaType.APPLICATION_JSON);
    getResponse().setStatus(Status.SUCCESS_OK);
    LOG.error("Error in delete instance", e);
  }
  return null;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:21,
代码来源:InstanceResource.java

示例21: getClustersRepresentation

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
StringRepresentation getClustersRepresentation() throws JsonGenerationException,
    JsonMappingException, IOException {
  ZkClient zkClient =
      ResourceUtil.getAttributeFromCtx(getContext(), ResourceUtil.ContextKey.ZKCLIENT);

  ClusterSetup setupTool = new ClusterSetup(zkClient);
  List<String> clusters = setupTool.getClusterManagementTool().getClusters();

  ZNRecord clustersRecord = new ZNRecord("Clusters Summary");
  clustersRecord.setListField("clusters", clusters);
  StringRepresentation representation =
      new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clustersRecord),
          MediaType.APPLICATION_JSON);

  return representation;
}
 

开发者ID:apache,
项目名称:helix,
代码行数:17,
代码来源:ClustersResource.java

示例22: beforeSuite

点赞 3

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeSuite
public void beforeSuite() throws Exception {
  // TODO: use logging.properties file to config java.util.logging.Logger levels
  java.util.logging.Logger topJavaLogger = java.util.logging.Logger.getLogger("");
  topJavaLogger.setLevel(Level.WARNING);

  // start zk
  _zkServer = TestHelper.startZkServer(ZK_ADDR);
  AssertJUnit.assertTrue(_zkServer != null);
  ZKClientPool.reset();

  _gZkClient =
      new ZkClient(ZK_ADDR, ZkClient.DEFAULT_CONNECTION_TIMEOUT,
          ZkClient.DEFAULT_SESSION_TIMEOUT, new ZNRecordSerializer());
  _gSetupTool = new ClusterSetup(_gZkClient);

  // start admin
  _adminThread = new AdminThread(ZK_ADDR, ADMIN_PORT);
  _adminThread.start();

  // create a client
  _gClient = new Client(Protocol.HTTP);

  // wait for the web service to start
  Thread.sleep(100);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:27,
代码来源:AdminTestBase.java

示例23: createGobblinYarnHelixCluster

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
/**
 * Create a Helix cluster with the cluster name specified using
 * {@link GobblinYarnConfigurationKeys#HELIX_CLUSTER_NAME_KEY} if it does not exist.
 */
private void createGobblinYarnHelixCluster() {
  ClusterSetup clusterSetup =
      new ClusterSetup(this.config.getString(GobblinYarnConfigurationKeys.ZK_CONNECTION_STRING_KEY));
  String clusterName = this.config.getString(GobblinYarnConfigurationKeys.HELIX_CLUSTER_NAME_KEY);
  // Create the cluster and overwrite if it already exists
  clusterSetup.addCluster(clusterName, true);
  // Helix 0.6.x requires a configuration property to have the form key=value.
  String autoJoinConfig = ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN + "=true";
  clusterSetup.setConfig(HelixConfigScope.ConfigScopeProperty.CLUSTER, clusterName, autoJoinConfig);
  LOGGER.info("Created Helix cluster " + clusterName);
}
 

开发者ID:Hanmourang,
项目名称:Gobblin,
代码行数:16,
代码来源:GobblinYarnAppLauncher.java

示例24: setUpHelixCluster

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
private void setUpHelixCluster(String zookeeperQuorum, String clusterName) {
  ZkClient zkClient = ZKClientPool.getZkClient(zookeeperQuorum);
  HelixAdmin helixAdmin = new ZKHelixAdmin(zkClient);
  try {
    if(!ImmutableSet.copyOf(helixAdmin.getClusters()).contains(clusterName)) {
      ClusterSetup helixClusterSetUp = new ClusterSetup(zkClient);
      helixClusterSetUp.addCluster(clusterName, false);
      helixClusterSetUp.setConfig(HelixConfigScope.ConfigScopeProperty.CLUSTER, clusterName,
          "allowParticipantAutoJoin=true");
    }
  } finally {
    zkClient.close();
  }
}
 

开发者ID:pinterest-attic,
项目名称:terrapin,
代码行数:15,
代码来源:TerrapinControllerHandler.java

示例25: beforeMethod

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeMethod
public void beforeMethod() throws Exception {
  // Set up helix cluster
  ClusterSetup clusterSetup = new ClusterSetup(zkAddress);
  clusterSetup.addCluster(clusterName, true);

  // Start Helix controller
  helixController = HelixControllerMain.startHelixController(zkAddress, clusterName, "CONTROLLER", "STANDALONE");

  // Service discoverer
  serviceDiscoverer = new HelixServiceDiscoverer(zkAddress, clusterName);
  serviceDiscoverer.start();
}
 

开发者ID:brandtg,
项目名称:dropwizard-helix,
代码行数:14,
代码来源:TestHelixServiceDiscoveryBundle.java

示例26: createGobblinHelixCluster

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
/**
 * Create a Helix cluster for the Gobblin Cluster application.
 *
 * @param zkConnectionString the ZooKeeper connection string
 * @param clusterName the Helix cluster name
 * @param overwrite true to overwrite exiting cluster, false to reuse existing cluster
 */
public static void createGobblinHelixCluster(String zkConnectionString, String clusterName, boolean overwrite) {
  ClusterSetup clusterSetup = new ClusterSetup(zkConnectionString);
  // Create the cluster and overwrite if it already exists
  clusterSetup.addCluster(clusterName, overwrite);
  // Helix 0.6.x requires a configuration property to have the form key=value.
  String autoJoinConfig = ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN + "=true";
  clusterSetup.setConfig(HelixConfigScope.ConfigScopeProperty.CLUSTER, clusterName, autoJoinConfig);
}
 

开发者ID:apache,
项目名称:incubator-gobblin,
代码行数:16,
代码来源:HelixUtils.java

示例27: beforeMethod

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeMethod
public void beforeMethod() {
  _instanceList = Lists.newLinkedList();
  _clusterSetup = new ClusterSetup(ZK_ADDR);
  _admin = _clusterSetup.getClusterManagementTool();
  _prefListHistory = Lists.newLinkedList();

  // Create cluster
  String className = TestHelper.getTestClassName();
  String methodName = TestHelper.getTestMethodName();
  _clusterName = className + "_" + methodName;
  _clusterSetup.addCluster(_clusterName, true);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:14,
代码来源:TestPreferenceListAsQueue.java

示例28: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(_gZkClient);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  // add dummy participants
  for (int i = 0; i < NODE_NR; i++) {
    String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    MockParticipantManager participant =
        new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
    participant.setTransition(new DelayedTransition());
    _participants[i] = participant;
  }

  _configAccessor = new ConfigAccessor(_gZkClient);

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  setupThrottleConfig();
}
 

开发者ID:apache,
项目名称:helix,
代码行数:38,
代码来源:TestPartitionMovementThrottle.java

示例29: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  // Logger.getRootLogger().setLevel(Level.INFO);
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);
  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  // start dummy participants
  for (int i = 0; i < NODE_NR; i++) {
    String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _instanceNames.add(instanceName);
    _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
    _participants[i].syncStart();
  }
}
 

开发者ID:apache,
项目名称:helix,
代码行数:33,
代码来源:TestRebalancerPersistAssignments.java

示例30: testDropResourceWhileNodeDead

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Test()
public void testDropResourceWhileNodeDead() throws Exception {
  // add a resource to be dropped
  _setupTool.addResourceToCluster(CLUSTER_NAME, "MyDB2", 16, STATE_MODEL);
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, "MyDB2", 3);

  boolean verifyResult =
      ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
          ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(verifyResult);

  String hostToKill = "localhost_12920";

  _participants[2].syncStop();
  Thread.sleep(1000);

  String command = "-zkSvr " + ZK_ADDR + " -dropResource " + CLUSTER_NAME + " " + "MyDB2";
  ClusterSetup.processCommandLineArgs(command.split(" "));

  TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB2",
      TestHelper.<String> setOf("localhost_12918", "localhost_12919",
      /* "localhost_12920", */"localhost_12921", "localhost_12922"), ZK_ADDR);

  _participants[2] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, hostToKill);
  _participants[2].syncStart();

  TestHelper.verifyWithTimeout("verifyEmptyCurStateAndExtView", 30 * 1000, CLUSTER_NAME, "MyDB2",
      TestHelper.<String> setOf("localhost_12918", "localhost_12919", "localhost_12920",
          "localhost_12921", "localhost_12922"), ZK_ADDR);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:31,
代码来源:TestDropResource.java

示例31: setupStorageCluster

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
protected void setupStorageCluster(ClusterSetup setupTool, String clusterName, String dbName,
    int partitionNr, String prefix, int startPort, String stateModel, int replica,
    boolean rebalance) {
  setupTool.addResourceToCluster(clusterName, dbName, partitionNr, stateModel);
  for (int i = 0; i < NODE_NR; i++) {
    String instanceName = prefix + "_" + (startPort + i);
    setupTool.addInstanceToCluster(clusterName, instanceName);
  }
  if (rebalance) {
    setupTool.rebalanceStorageCluster(clusterName, dbName, replica);
  }
}
 

开发者ID:apache,
项目名称:helix,
代码行数:13,
代码来源:TestAddClusterV2.java

示例32: doTransition

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
public void doTransition(Message message, NotificationContext context) {
  HelixManager manager = context.getManager();
  String clusterName = manager.getClusterName();

  String instance = message.getTgtName();
  String partitionName = message.getPartitionName();
  String fromState = message.getFromState();
  String toState = message.getToState();
  if (instance.equals("localhost_12919") && partitionName.equals("TestDB0_0")) {
    if (fromState.equals("SLAVE") && toState.equals("OFFLINE")) {
      slaveToOfflineCnt++;

      try {
        String command =
            "--zkSvr " + ZK_ADDR + " --enablePartition true " + clusterName
                + " localhost_12919 TestDB0 TestDB0_0";

        ClusterSetup.processCommandLineArgs(command.split("\\s+"));
      } catch (Exception e) {
        LOG.error("Exception in cluster setup", e);
      }

    } else if (slaveToOfflineCnt > 0 && fromState.equals("OFFLINE") && toState.equals("SLAVE")) {
      offlineToSlave++;
    }
  }
}
 

开发者ID:apache,
项目名称:helix,
代码行数:29,
代码来源:TestEnablePartitionDuringDisable.java

示例33: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants = new MockParticipantManager[_numNodes];
  _numDbs = 1;
  _numParitions = 20;
  _numNodes = 2;
  _numReplicas = 2;
  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();

  registerParticipants(_participants, _numNodes, _startPort, 0, -3000000L);

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  createManagers();
  _configAccessor = new ConfigAccessor(_gZkClient);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:28,
代码来源:TestStateTransitionCancellation.java

示例34: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  _manager = HelixManagerFactory
      .getZKHelixManager(CLUSTER_NAME, "Admin", InstanceType.ADMINISTRATOR, ZK_ADDR);
  _manager.connect();
  _configAccessor = new ConfigAccessor(_gZkClient);

  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller =
      new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  boolean result =
      ClusterStateVerifier
          .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, CLUSTER_NAME));
  Assert.assertTrue(result);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:35,
代码来源:TestStateTransitionTimeoutWithResource.java

示例35: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);

  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);
  _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, _PARTITIONS, STATE_MODEL);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }
  _setupTool.rebalanceStorageCluster(CLUSTER_NAME, TEST_DB, 3);

  // Set the timeout values
  IdealState idealState =
      _setupTool.getClusterManagementTool().getResourceIdealState(CLUSTER_NAME, TEST_DB);
  String stateTransition = "SLAVE" + "-" + "MASTER" + "_" + Message.Attributes.TIMEOUT;
  idealState.getRecord().setSimpleField(stateTransition, "300");

  String command =
      "-zkSvr " + ZK_ADDR + " -addResourceProperty " + CLUSTER_NAME + " " + TEST_DB + " "
          + stateTransition + " 200";
  ClusterSetup.processCommandLineArgs(command.split(" "));
}
 

开发者ID:apache,
项目名称:helix,
代码行数:33,
代码来源:TestStateTransitionTimeout.java

示例36: createDBInSemiAuto

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
protected void createDBInSemiAuto(ClusterSetup clusterSetup, String clusterName, String dbName,
    List<String> preferenceList, String stateModelDef, int numPartition, int replica) {
  clusterSetup.addResourceToCluster(clusterName, dbName, numPartition, stateModelDef,
      IdealState.RebalanceMode.SEMI_AUTO.toString());
  clusterSetup.rebalanceStorageCluster(clusterName, dbName, replica);

  IdealState is =
      _gSetupTool.getClusterManagementTool().getResourceIdealState(clusterName, dbName);
  for (String p : is.getPartitionSet()) {
    is.setPreferenceList(p, preferenceList);
  }
  clusterSetup.getClusterManagementTool().setResourceIdealState(clusterName, dbName, is);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:14,
代码来源:ZkIntegrationTestBase.java

示例37: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants =  new MockParticipantManager[_numNodes];
  _numDbs = 1;
  _numNodes = 2;
  _numParitions = 2;
  _numReplicas = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  startParticipantsWithStuckTaskStateModelFactory();
  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();

  // Enable cancellation
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
  clusterConfig.stateTransitionCancelEnabled(true);
  _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);
}
 

开发者ID:apache,
项目名称:helix,
代码行数:29,
代码来源:TestJobFailureTaskNotStarted.java

示例38: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@BeforeClass
public void beforeClass() throws Exception {
  _participants =  new MockParticipantManager[_numNodes];
  _numDbs = 1;
  _numNodes = 1;
  _numParitions = 50;
  _numReplicas = 1;

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }

  _setupTool = new ClusterSetup(ZK_ADDR);
  _setupTool.addCluster(CLUSTER_NAME, true);
  setupParticipants();
  setupDBs();
  startParticipantsWithStuckTaskStateModelFactory();
  createManagers();
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, CONTROLLER_PREFIX);
  _controller.syncStart();

  // Enable cancellation
  ConfigAccessor _configAccessor = new ConfigAccessor(_gZkClient);
  ClusterConfig clusterConfig = _configAccessor.getClusterConfig(CLUSTER_NAME);
  clusterConfig.stateTransitionCancelEnabled(true);
  clusterConfig.setMaxConcurrentTaskPerInstance(_numParitions);
  _configAccessor.setClusterConfig(CLUSTER_NAME, clusterConfig);

  HelixClusterVerifier clusterVerifier =
      new BestPossibleExternalViewVerifier.Builder(CLUSTER_NAME).setZkClient(_gZkClient).build();
  Assert.assertTrue(clusterVerifier.verify(10000));
}
 

开发者ID:apache,
项目名称:helix,
代码行数:34,
代码来源:TestJobTimeoutTaskNotStarted.java

示例39: beforeClass

点赞 2

import org.apache.helix.tools.ClusterSetup; //导入依赖的package包/类
@Override
@BeforeClass
public void beforeClass() throws Exception {
  System.out.println("START " + CLASS_NAME + " at " + new Date(System.currentTimeMillis()));

  String namespace = "/" + CLUSTER_NAME;
  if (_gZkClient.exists(namespace)) {
    _gZkClient.deleteRecursive(namespace);
  }
  _setupTool = new ClusterSetup(ZK_ADDR);
  // setup storage cluster
  _setupTool.addCluster(CLUSTER_NAME, true);

  for (int i = 0; i < NODE_NR; i++) {
    String storageNodeName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _setupTool.addInstanceToCluster(CLUSTER_NAME, storageNodeName);
  }

  // start controller
  String controllerName = CONTROLLER_PREFIX + "_0";
  _controller = new ClusterControllerManager(ZK_ADDR, CLUSTER_NAME, controllerName);
  _controller.syncStart();

  // start dummy participants
  for (int i = 0; i < NODE_NR; i++) {
    String instanceName = PARTICIPANT_PREFIX + "_" + (START_PORT + i);
    _instanceNames.add(instanceName);
    _participants[i] = new MockParticipantManager(ZK_ADDR, CLUSTER_NAME, instanceName);
    _participants[i].syncStart();
  }

  enablePersistBestPossibleAssignment(_gZkClient, CLUSTER_NAME, true);

  accessor = new ZKHelixDataAccessor(CLUSTER_NAME, _baseAccessor);
  errorNodeKey = accessor.keyBuilder().controllerTaskError(RebalanceResourceFailure.name());
}
 

开发者ID:apache,
项目名称:helix,
代码行数:37,
代码来源:TestAlertingRebalancerFailure.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)