Package com.linkedin.helix.tools

Examples of com.linkedin.helix.tools.ClusterSetup


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

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


    try
    {
      String clusterName = (String) getRequest().getAttributes().get("clusterName");
      ZkClient zkClient =
          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
      ClusterSetup setupTool = new ClusterSetup(zkClient);
      setupTool.deleteCluster(clusterName);
      getResponse().setStatus(Status.SUCCESS_OK);
    }
    catch (Exception e)
    {
      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
View Full Code Here

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

    // setup storage cluster
    _setupTool.addCluster(CLUSTER_NAME, true);
    _setupTool.addResourceToCluster(CLUSTER_NAME, TEST_DB, _PARTITIONS, "LeaderStandby", IdealStateModeProperty.AUTO_REBALANCE+"");
    for (int i = 0; i < NODE_NR; i++)
View Full Code Here

      JsonParameters jsonParameters = new JsonParameters(entity);
      String command = jsonParameters.getCommand();

      ZkClient zkClient =
          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
      ClusterSetup setupTool = new ClusterSetup(zkClient);

      if (command.equalsIgnoreCase(ClusterSetup.addInstance)
          || JsonParameters.CLUSTERSETUP_COMMAND_ALIASES.get(ClusterSetup.addInstance)
                                                        .contains(command))
      {
        if (jsonParameters.getParameter(JsonParameters.INSTANCE_NAME) != null)
        {
          setupTool.addInstanceToCluster(clusterName,
                                         jsonParameters.getParameter(JsonParameters.INSTANCE_NAME));
        }
        else if (jsonParameters.getParameter(JsonParameters.INSTANCE_NAMES) != null)
        {
          setupTool.addInstancesToCluster(clusterName,
                                          jsonParameters.getParameter(JsonParameters.INSTANCE_NAMES)
                                                        .split(";"));
        }
        else
        {
          throw new HelixException("Missing Json paramaters: '"
              + JsonParameters.INSTANCE_NAME + "' or '" + JsonParameters.INSTANCE_NAMES
              + "' ");
        }
      }
      else if (command.equalsIgnoreCase(ClusterSetup.swapInstance))
      {
        if (jsonParameters.getParameter(JsonParameters.NEW_INSTANCE) == null
            || jsonParameters.getParameter(JsonParameters.OLD_INSTANCE) == null)
        {
          throw new HelixException("Missing Json paramaters: '"
              + JsonParameters.NEW_INSTANCE + "' or '" + JsonParameters.OLD_INSTANCE
              + "' ");
        }
        setupTool.swapInstance(clusterName,
                               jsonParameters.getParameter(JsonParameters.OLD_INSTANCE),
                               jsonParameters.getParameter(JsonParameters.NEW_INSTANCE));
      }
      else
      {
View Full Code Here

      String resourceGroupName =
          (String) getRequest().getAttributes().get("resourceName");
      ZkClient zkClient =
          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
     
      ClusterSetup setupTool = new ClusterSetup(zkClient);
      setupTool.dropResourceFromCluster(clusterName, resourceGroupName);
      getResponse().setStatus(Status.SUCCESS_OK);
    }
    catch (Exception e)
    {
      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
View Full Code Here

      String command = jsonParameters.getCommand();
      if (command.equalsIgnoreCase(ClusterSetup.resetResource))
      {
        ZkClient zkClient =
            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
        ClusterSetup setupTool = new ClusterSetup(zkClient);
        setupTool.getClusterManagementTool().resetResource(clusterName, Arrays.asList(resourceName));
      }
      else
      {
        throw new HelixException("Unsupported command: " + command
                                 + ". Should be one of [" + ClusterSetup.resetResource + "]");
View Full Code Here

 
  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);
View Full Code Here

    {
      LOG.warn("Cluster already exists:" + clusterName + ". Deleting it");
      zkClient.deleteRecursive("/" + clusterName);
    }

    ClusterSetup setupTool = new ClusterSetup(ZkAddr);
    setupTool.addCluster(clusterName, true);

    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, mode.toString());
      if (doRebalance)
      {
        setupTool.rebalanceStorageCluster(clusterName, dbName, replica);
      }
    }
    zkClient.close();
  }
View Full Code Here

        boolean enabled =
            Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));

        ZkClient zkClient =
            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
        ClusterSetup setupTool = new ClusterSetup(zkClient);
        setupTool.getClusterManagementTool().enableInstance(clusterName,
                                                            instanceName,
                                                            enabled);
      }
      else if (command.equalsIgnoreCase(ClusterSetup.enablePartition))
      {
        jsonParameters.verifyCommand(ClusterSetup.enablePartition);
        boolean enabled =
             Boolean.parseBoolean(jsonParameters.getParameter(JsonParameters.ENABLED));

        String[] partitions =
            jsonParameters.getParameter(JsonParameters.PARTITION).split(";");
        String resource =
            jsonParameters.getParameter(JsonParameters.RESOURCE);

        ZkClient zkClient =
            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
        ClusterSetup setupTool = new ClusterSetup(zkClient);
        setupTool.getClusterManagementTool().enablePartition(enabled,
                                                             clusterName,
                                                             instanceName,
                                                             resource,
                                                             Arrays.asList(partitions));
      }
      else if (command.equalsIgnoreCase(ClusterSetup.resetPartition))
      {
        jsonParameters.verifyCommand(ClusterSetup.resetPartition);

        String resource =
            jsonParameters.getParameter(JsonParameters.RESOURCE);

        ZkClient zkClient =
            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
        ClusterSetup setupTool = new ClusterSetup(zkClient);
        String[] partitionNames =
            jsonParameters.getParameter(JsonParameters.PARTITION).split("\\s+");
        setupTool.getClusterManagementTool()
                 .resetPartition(clusterName,
                                 instanceName,
                                 resource,
                                 Arrays.asList(partitionNames));
      }
      else if (command.equalsIgnoreCase(ClusterSetup.resetInstance))
      {
        jsonParameters.verifyCommand(ClusterSetup.resetInstance);

        ZkClient zkClient =
            (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
        ClusterSetup setupTool = new ClusterSetup(zkClient);
        setupTool.getClusterManagementTool().resetInstance(clusterName,
                                                           Arrays.asList(instanceName));
      }
      else
      {
        throw new HelixException("Unsupported command: " + command
View Full Code Here

      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);
      setupTool.dropInstanceFromCluster(clusterName, instanceName);
      getResponse().setStatus(Status.SUCCESS_OK);
    }
    catch (Exception e)
    {
      getResponse().setEntity(ClusterRepresentationUtil.getErrorAsJsonStringFromException(e),
View Full Code Here

TOP

Related Classes of com.linkedin.helix.tools.ClusterSetup

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.