Package org.apache.helix.api.id

Examples of org.apache.helix.api.id.ClusterId


    return null;
  }

  @Override
  public Resource readResource(ResourceId resourceId) {
    ClusterId clusterId = clusterId();
    HelixLock lock = _lockProvider.getLock(clusterId, Scope.resource(resourceId));
    boolean locked = lock.lock();
    if (locked) {
      try {
        return _clusterAccessor.readResource(resourceId);
View Full Code Here


    return null;
  }

  @Override
  public ResourceConfig updateResource(ResourceId resourceId, ResourceConfig.Delta resourceDelta) {
    ClusterId clusterId = clusterId();
    HelixLock lock = _lockProvider.getLock(clusterId, Scope.resource(resourceId));
    boolean locked = lock.lock();
    if (locked) {
      try {
        return _clusterAccessor.updateResource(resourceId, resourceDelta);
View Full Code Here

    _serviceName = serviceName;
  }

  @Override
  protected void init() {
    ClusterId clusterId = getClusterId();
    ClusterAccessor clusterAccessor = getConnection().createClusterAccessor(clusterId);
    ResourceId resourceId = ResourceId.from(_serviceName);
    Resource resource = clusterAccessor.readResource(resourceId);
    UserConfig userConfig = resource.getUserConfig();
    ServiceConfig serviceConfig = new ServiceConfig(Scope.resource(resourceId));
View Full Code Here

    try {
      CommandLine cliParser = new GnuParser().parse(opts, args);
      String zkAddress = cliParser.getOptionValue("zkAddress");
      final HelixConnection connection = new ZkHelixConnection(zkAddress);
      connection.connect();
      ClusterId clusterId = ClusterId.from(cliParser.getOptionValue("cluster"));
      ParticipantId participantId = ParticipantId.from(cliParser.getOptionValue("participantId"));
      String participantClass = cliParser.getOptionValue("participantClass");
      @SuppressWarnings("unchecked")
      Class<? extends AbstractParticipantService> clazz =
          (Class<? extends AbstractParticipantService>) Class.forName(participantClass);
View Full Code Here

    // set up a participant
    ParticipantConfig participant = getParticipant();

    // cluster id should be unique
    ClusterId clusterId = ClusterId.from("exampleCluster");

    // a user config is an object that stores arbitrary keys and values for a scope
    // in this case, the scope is the cluster with id clusterId
    // this is optional
    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
View Full Code Here

    final ApplicationSpec appSpec = launcher.getApplicationSpec();

    // Repeatedly print status
    final HelixConnection connection = launcher.pollForConnection();
    final ClusterId clusterId = ClusterId.from(appSpec.getAppName());
    // TODO: this is a hack -- TaskDriver should accept a connection instead of a manager
    HelixManager manager = new ZKHelixManager(new HelixRole() {
      @Override
      public HelixConnection getConnection() {
        return connection;
View Full Code Here

    final String KEY2 = "key2";
    final String VALUE2 = "value2";

    // add the following: key1 straight to user config, key2 to cluster configuration,
    // allow auto join to cluster configuration
    ClusterId clusterId = ClusterId.from("clusterId");
    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
    userConfig.setSimpleField(KEY1, VALUE1);
    ClusterConfiguration clusterConfiguration = new ClusterConfiguration(clusterId);
    clusterConfiguration.addNamespacedConfig(userConfig);
    clusterConfiguration.getRecord().setSimpleField(KEY2, VALUE2);
View Full Code Here

   * cluster.
   */
  @Test
  public void testRecreateCluster() {
    final String MODIFIER = "modifier";
    final ClusterId clusterId = ClusterId.from("TestAccessorRecreate!testCluster");

    // connect
    boolean connected = _zkclient.waitUntilConnected(30000, TimeUnit.MILLISECONDS);
    if (!connected) {
      LOG.warn("Connection not established");
      return;
    }
    HelixDataAccessor helixAccessor = new ZKHelixDataAccessor(clusterId.stringify(), _baseAccessor);
    ClusterAccessor accessor = new ClusterAccessor(clusterId, helixAccessor);

    // create a cluster
    boolean created = createCluster(clusterId, accessor, MODIFIER, 1);
    Assert.assertTrue(created);
View Full Code Here

   * participant.
   */
  @Test
  public void testRecreateParticipant() {
    final String MODIFIER = "modifier";
    final ClusterId clusterId = ClusterId.from("testCluster");
    final ParticipantId participantId = ParticipantId.from("testParticipant");

    // connect
    boolean connected = _zkclient.waitUntilConnected(30000, TimeUnit.MILLISECONDS);
    if (!connected) {
      LOG.warn("Connection not established");
      return;
    }
    BaseDataAccessor<ZNRecord> baseAccessor = new ZkBaseDataAccessor<ZNRecord>(_zkclient);
    HelixDataAccessor helixAccessor = new ZKHelixDataAccessor(clusterId.stringify(), baseAccessor);
    ClusterAccessor accessor = new ClusterAccessor(clusterId, helixAccessor);

    // create the cluster
    boolean clusterCreated = createCluster(clusterId, accessor, MODIFIER, 0);
    Assert.assertTrue(clusterCreated);
View Full Code Here

  private static final long TIMEOUT = 30000L;
  private static final long EXTRA_WAIT = 10000L;

  @Test
  public void testClusterUpdates() {
    final ClusterId clusterId = ClusterId.from("TestAtomicAccessors!testCluster");
    final HelixDataAccessor helixAccessor =
        new ZKHelixDataAccessor(clusterId.stringify(), _baseAccessor);
    final LockProvider lockProvider = new LockProvider();
    final String key1 = "key1";
    final String key2 = "key2";

    // set up the cluster (non-atomically since this concurrency comes later)
View Full Code Here

TOP

Related Classes of org.apache.helix.api.id.ClusterId

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.