Package org.apache.helix.api.config

Examples of org.apache.helix.api.config.ClusterConfig$Builder


    // add a transition constraint (with a resource scope)
    clusterBuilder.addTransitionConstraint(Scope.resource(resource.getId()), lockUnlock.getStateModelDefId(),
        Transition.from(State.from("RELEASED"), State.from("LOCKED")), 1);

    ClusterConfig cluster = clusterBuilder.build();

    // set up a connection to work with ZooKeeper-persisted data
    HelixConnection connection = new ZkHelixConnection(args[0]);
    connection.connect();
View Full Code Here


  private boolean createCluster(ClusterId clusterId, ClusterAccessor accessor, String modifierName,
      int modifierValue) {
    // create a cluster
    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
    userConfig.setIntField(modifierName, modifierValue);
    ClusterConfig cluster = new ClusterConfig.Builder(clusterId).userConfig(userConfig).build();
    return accessor.createCluster(cluster);
  }
View Full Code Here

    final String key1 = "key1";
    final String key2 = "key2";

    // set up the cluster (non-atomically since this concurrency comes later)
    ClusterAccessor accessor = new ClusterAccessor(clusterId, helixAccessor);
    ClusterConfig config = new ClusterConfig.Builder(clusterId).build();
    boolean created = accessor.createCluster(config);
    Assert.assertTrue(created);

    // thread that will update the cluster in one way
    Thread t1 = new Thread() {
View Full Code Here

      final Map<PartitionId, Map<ParticipantId, State>> mapResult =
          new HashMap<PartitionId, Map<ParticipantId, State>>();
      ClusterId clusterId = ClusterId.from("clusterId");
      ClusterConfig.Builder clusterConfigBuilder =
          new ClusterConfig.Builder(clusterId).addStateModelDefinition(_stateModelDef);
      ClusterConfig clusterConfig = clusterConfigBuilder.build();
      for (String partition : _partitions) {
        PartitionId partitionId = PartitionId.from(partition);
        Set<ParticipantId> disabledParticipantsForPartition = Collections.emptySet();
        Map<MessageId, Message> messageMap = Collections.emptyMap();
        Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
View Full Code Here

    private Map<String, Map<String, String>> getMapping(final Map<String, List<String>> listResult) {
      final Map<String, Map<String, String>> mapResult = new HashMap<String, Map<String, String>>();
      for (String partition : _partitions) {
        Map<String, String> rawCurStateMap = _currentMapping.get(partition);
        ClusterConfig cluster =
            new ClusterConfig.Builder(ClusterId.from("cluster")).addStateModelDefinition(
                _stateModelDef).build();
        Set<ParticipantId> liveParticipantSet = Sets.newHashSet();
        for (String node : _liveNodes) {
          liveParticipantSet.add(ParticipantId.from(node));
View Full Code Here

    // add a transition constraint (this time with a resource scope)
    clusterBuilder.addTransitionConstraint(Scope.resource(resource.getId()),
        lockUnlock.getStateModelDefId(),
        Transition.from(State.from("RELEASED"), State.from("LOCKED")), 1);

    ClusterConfig cluster = clusterBuilder.build();

    // set up a connection to work with ZooKeeper-persisted data
    HelixConnection connection = new ZkHelixConnection(args[0]);
    connection.connect();
View Full Code Here

  private boolean createCluster(ClusterId clusterId, ClusterAccessor accessor, String modifierName,
      int modifierValue) {
    // create a cluster
    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
    userConfig.setIntField(modifierName, modifierValue);
    ClusterConfig cluster = new ClusterConfig.Builder(clusterId).userConfig(userConfig).build();
    return accessor.createCluster(cluster);
  }
View Full Code Here

    final String key1 = "key1";
    final String key2 = "key2";

    // set up the cluster (non-atomically since this concurrency comes later)
    ClusterAccessor accessor = new ClusterAccessor(clusterId, helixAccessor);
    ClusterConfig config = new ClusterConfig.Builder(clusterId).build();
    boolean created = accessor.createCluster(config);
    Assert.assertTrue(created);

    // thread that will update the cluster in one way
    Thread t1 = new Thread() {
View Full Code Here

    final State offline = State.from("OFFLINE");

    // start: add a user config, add master and slave constraints
    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
    userConfig.setSimpleField("key1", "value1");
    ClusterConfig config =
        new ClusterConfig.Builder(clusterId)
            .addStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, master, 2)
            .addStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, slave, 3)
            .userConfig(userConfig).autoJoin(true).build();

    // update: overwrite user config, change master constraint, remove slave constraint, add offline
    // constraint, change auto join
    UserConfig newUserConfig = new UserConfig(Scope.cluster(clusterId));
    newUserConfig.setSimpleField("key2", "value2");
    ClusterConfig updated =
        new ClusterConfig.Delta(clusterId)
            .addStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, master, 1)
            .removeStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, slave)
            .addStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, offline, "R")
            .setUserConfig(newUserConfig).setAutoJoin(false).mergeInto(config);
    Assert.assertEquals(
        updated.getStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, master), "1");
    Assert.assertEquals(
        updated.getStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, slave), "-1");
    Assert.assertEquals(
        updated.getStateUpperBoundConstraint(Scope.cluster(clusterId), masterSlave, offline), "R");
    Assert.assertNull(updated.getUserConfig().getSimpleField("key1"));
    Assert.assertEquals(updated.getUserConfig().getSimpleField("key2"), "value2");
    Assert.assertFalse(updated.autoJoinAllowed());
  }
View Full Code Here

    Cluster cluster = readCluster();
    if (cluster == null) {
      LOG.error("Cluster does not exist, cannot be updated");
      return null;
    }
    ClusterConfig config = clusterDelta.mergeInto(cluster.getConfig());
    boolean status = setBasicClusterConfig(config);
    return status ? config : null;
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.api.config.ClusterConfig$Builder

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.