Package org.apache.helix.api.accessor

Examples of org.apache.helix.api.accessor.ClusterAccessor


      cache = new ClusterDataCache();
    }
    _cache = cache;

    ClusterId clusterId = ClusterId.from(manager.getClusterName());
    ClusterAccessor clusterAccessor = new ClusterAccessor(clusterId, accessor, _cache);

    Cluster cluster = clusterAccessor.readCluster();

    // Update the cluster status gauges
    ClusterStatusMonitor clusterStatusMonitor =
        (ClusterStatusMonitor) event.getAttribute("clusterStatusMonitor");
    if (clusterStatusMonitor != null) {
View Full Code Here


    ZkHelixConnection connection = new ZkHelixConnection(zkAddress);
    connection.connect();

    // create the cluster
    ClusterId clusterId = ClusterId.from(clusterName);
    ClusterAccessor clusterAccessor = connection.createClusterAccessor(clusterId);
    StateModelDefinition statelessService =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForStatelessService());
    StateModelDefinition taskStateModel =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForTaskStateModel());
    clusterAccessor.createCluster(new ClusterConfig.Builder(clusterId)
        .addStateModelDefinition(statelessService).addStateModelDefinition(taskStateModel).build());
    for (String service : applicationSpec.getServices()) {
      String resourceName = service;
      // add the resource with the local provisioner
      ResourceId resourceId = ResourceId.from(resourceName);

      ServiceConfig serviceConfig = applicationSpec.getServiceConfig(resourceName);
      serviceConfig.setSimpleField("service_name", service);
      int numContainers = serviceConfig.getIntField("num_containers", 1);

      YarnProvisionerConfig provisionerConfig = new YarnProvisionerConfig(resourceId);
      provisionerConfig.setNumContainers(numContainers);

      AutoRebalanceModeISBuilder idealStateBuilder = new AutoRebalanceModeISBuilder(resourceId);
      idealStateBuilder.setStateModelDefId(statelessService.getStateModelDefId());
      idealStateBuilder.add(PartitionId.from(resourceId, "0"));
      idealStateBuilder.setNumReplica(1);
      ResourceConfig.Builder resourceConfigBuilder =
          new ResourceConfig.Builder(ResourceId.from(resourceName));
      ResourceConfig resourceConfig =
          resourceConfigBuilder.provisionerConfig(provisionerConfig)
              .idealState(idealStateBuilder.build()) //
              .build();
      clusterAccessor.addResource(resourceConfig);
    }
    // start controller
    ControllerId controllerId = ControllerId.from("controller1");
    HelixController controller = connection.createController(clusterId, controllerId);
    controller.start();
View Full Code Here

    connection = new ZkHelixConnection(_zkaddr);
    connection.connect();

    // create the cluster
    ClusterId clusterId = ClusterId.from(clusterName);
    ClusterAccessor clusterAccessor = connection.createClusterAccessor(clusterId);
    StateModelDefinition masterSlave =
        new StateModelDefinition(StateModelConfigGenerator.generateConfigForMasterSlave());
    clusterAccessor.createCluster(new ClusterConfig.Builder(clusterId).addStateModelDefinition(
        masterSlave).build());

    // add the resource with the local provisioner
    ResourceId resourceId = ResourceId.from(resourceName);
    ProvisionerConfig provisionerConfig = new LocalProvisionerConfig(resourceId);
    AutoRebalanceModeISBuilder idealStateBuilder = new AutoRebalanceModeISBuilder(resourceId);
    for (int i = 0; i < NUM_PARTITIONS; i++) {
      idealStateBuilder.add(PartitionId.from(resourceId, String.valueOf(i)));
    }
    idealStateBuilder.setNumReplica(NUM_REPLICAS).setStateModelDefId(
        masterSlave.getStateModelDefId());
    clusterAccessor.addResource(new ResourceConfig.Builder(ResourceId.from(resourceName))
        .provisionerConfig(provisionerConfig).idealState(idealStateBuilder.build()).build());

    // start controller
    ControllerId controllerId = ControllerId.from("controller1");
    HelixController controller = connection.createController(clusterId, controllerId);
View Full Code Here

    dropCluster(clusterId, connection);
    connection.disconnect();
  }

  private static void dropCluster(ClusterId clusterId, HelixConnection connection) {
    ClusterAccessor accessor = connection.createClusterAccessor(clusterId);
    accessor.dropCluster();
  }
View Full Code Here

        new ResourceConfig.Delta(resource.getId()).setUserConfig(userConfig);
    accessor.updateResource(resource.getId(), delta);
  }

  private static void createCluster(ClusterConfig cluster, HelixConnection connection) {
    ClusterAccessor accessor = connection.createClusterAccessor(cluster.getId());
    accessor.createCluster(cluster);
  }
View Full Code Here

    setupLiveInstances(clusterName, new int[] {
        0, 1
    });
    setupStateModel(clusterName);

    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(clusterName), accessor);
    clusterAccessor.initClusterStructure();

    // cluster data cache refresh pipeline
    Pipeline dataRefresh = new Pipeline();
    dataRefresh.addStage(new ReadClusterDataStage());
View Full Code Here

    });
    setupLiveInstances(clusterName, new int[] {
        0, 1
    });

    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(clusterName), accessor);
    clusterAccessor.initClusterStructure();


    ClusterControllerManager controller =
        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
    controller.syncStart();
View Full Code Here

    setupLiveInstances(clusterName, new int[] {
        0, 1
    });
    setupStateModel(clusterName);

    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(clusterName), accessor);
    clusterAccessor.initClusterStructure();

    // cluster data cache refresh pipeline
    Pipeline dataRefresh = new Pipeline();
    dataRefresh.addStage(new ReadClusterDataStage());
View Full Code Here

    setupLiveInstances(clusterName, new int[] {
      1
    });
    setupStateModel(clusterName);

    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(clusterName), accessor);
    clusterAccessor.initClusterStructure();

    // cluster data cache refresh pipeline
    Pipeline dataRefresh = new Pipeline();
    dataRefresh.addStage(new ReadClusterDataStage());
View Full Code Here

    setupLiveInstances(clusterName, new int[] {
        0, 1
    });
    setupStateModel(clusterName);

    ClusterAccessor clusterAccessor = new ClusterAccessor(ClusterId.from(clusterName), accessor);
    clusterAccessor.initClusterStructure();

    ClusterEvent event = new ClusterEvent("testEvent");
    event.addAttribute("helixmanager", manager);

    // get an empty best possible output for the partitions
View Full Code Here

TOP

Related Classes of org.apache.helix.api.accessor.ClusterAccessor

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.