Package org.apache.helix.api.id

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


    final String testSimpleValue = "testValue";
    final List<String> testListValue = ImmutableList.of("testValue");
    final Map<String, String> testMapValue = ImmutableMap.of("testInnerKey", "testValue");

    // first, add Helix configuration to an InstanceConfig
    ParticipantId participantId = ParticipantId.from("testParticipant");
    InstanceConfig instanceConfig = new InstanceConfig(participantId);
    instanceConfig.setHostName("localhost");

    // now, add user configuration
    UserConfig userConfig = new UserConfig(Scope.participant(participantId));
View Full Code Here


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

    // add key1 through user config, key2 through instance config, hostname through user config
    ParticipantId participantId = ParticipantId.from("participantId");
    UserConfig userConfig = new UserConfig(Scope.participant(participantId));
    userConfig.setSimpleField(KEY1, VALUE1);
    InstanceConfig instanceConfig = new InstanceConfig(participantId);
    instanceConfig.setHostName("localhost");
    instanceConfig.addNamespacedConfig(userConfig);
View Full Code Here

   */
  @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);

    // create the participant
    boolean created = createParticipant(participantId, accessor, MODIFIER, 1);
    Assert.assertTrue(created);

    // read the participant
    Participant participantSnapshot = accessor.readParticipant(participantId);
    Assert.assertEquals(participantSnapshot.getUserConfig().getIntField(MODIFIER, -1), 1);

    // create a participant with the same id
    boolean created2 = createParticipant(participantId, accessor, MODIFIER, 2);
    Assert.assertFalse(created2); // should fail since participant exists

    // remove a required property
    helixAccessor.removeProperty(helixAccessor.keyBuilder().messages(participantId.stringify()));

    // try again, should work this time
    created2 = createParticipant(participantId, accessor, MODIFIER, 2);
    Assert.assertTrue(created2);

View Full Code Here

    HelixDataAccessor accessor = _participants[0].getHelixDataAccessor();

    Builder kb = accessor.keyBuilder();
    ExternalView ev = accessor.getProperty(kb.externalView(TEST_DB));
    for (PartitionId p : idealState.getPartitionIdSet()) {
      ParticipantId idealMaster = idealState.getPreferenceList(p).get(0);
      Assert.assertTrue(ev.getStateMap(p).get(idealMaster).equals(State.from("ERROR")));

      TimeOutStateModel model = factories.get(idealMaster.stringify()).getTransitionHandler(p);
      Assert.assertEquals(model._errorCallcount, 1);
      Assert.assertEquals(model._error.getCode(), ErrorCode.TIMEOUT);
    }
  }
View Full Code Here

        Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
        Map<ParticipantId, Participant> liveParticipantMap =
            new HashMap<ParticipantId, Participant>();
        // set up some participants
        for (String nodeName : _liveNodes) {
          ParticipantId participantId = ParticipantId.from(nodeName);
          ParticipantConfig participantConfig =
              new ParticipantConfig.Builder(participantId).hostName("hostname").port(0).build();
          Participant participant =
              new Participant(participantConfig, null, currentStateMap, messageMap, null);
          liveParticipantMap.put(participantId, participant);
View Full Code Here

    System.out.println("START testMasterXfer at " + new Date(System.currentTimeMillis()));

    Map<ParticipantId, Participant> liveParticipants = new HashMap<ParticipantId, Participant>();
    Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
    Map<MessageId, Message> messageMap = Collections.emptyMap();
    ParticipantId participantId0 = ParticipantId.from("localhost_0");
    ParticipantId participantId1 = ParticipantId.from("localhost_1");
    LiveInstance[] liveInstances = new LiveInstance[2];
    for (int i = 0; i < 2; i++) {
      liveInstances[i] = new LiveInstance("localhost_" + i);
      liveInstances[i].setSessionId("session_" + i);
      liveInstances[i].setHelixVersion("1.2.3.4");
View Full Code Here

        + new Date(System.currentTimeMillis()));

    Map<ParticipantId, Participant> liveParticipants = new HashMap<ParticipantId, Participant>();
    Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
    Map<MessageId, Message> messageMap = Collections.emptyMap();
    ParticipantId participantId0 = ParticipantId.from("localhost_0");
    ParticipantId participantId1 = ParticipantId.from("localhost_1");
    LiveInstance[] liveInstances = new LiveInstance[2];
    for (int i = 0; i < 2; i++) {
      liveInstances[i] = new LiveInstance("localhost_" + i);
      liveInstances[i].setSessionId("session_" + i);
      liveInstances[i].setHelixVersion("1.2.3.4");
View Full Code Here

    // start participant
    ClusterId clusterId = ClusterId.from(clusterName);
    HelixParticipant[] participants = new HelixParticipant[n];
    for (int i = 0; i < n; i++) {
      int port = 12918 + i;
      ParticipantId participantId = ParticipantId.from("localhost_" + port);

      participants[i] = connection.createParticipant(clusterId, participantId);
      participants[i].getStateMachineEngine().registerStateModelFactory(
          StateModelDefId.from("MasterSlave"), new TestHelixConnection.MockStateModelFactory());
View Full Code Here

          }

          for (String partitionName : partErrStates.keySet()) {
            String instanceName = partErrStates.get(partitionName);
            PartitionId partitionId = PartitionId.from(partitionName);
            ParticipantId participantId = ParticipantId.from(instanceName);
            raBuilder.addAssignment(partitionId, participantId,
                State.from(HelixDefinedState.ERROR.toString()));
          }
          bestPossOutput.setResourceAssignment(resourceId, raBuilder.build());
View Full Code Here

        final TargetProviderResponse response =
            targetProvider.evaluateExistingContainers(cluster, resourceId, participants);

        // allocate new containers
        for (final ContainerSpec spec : response.getContainersToAcquire()) {
          final ParticipantId participantId = spec.getParticipantId();
          if (!cluster.getParticipantMap().containsKey(participantId)) {
            // create a new Participant, attach the container spec
            InstanceConfig instanceConfig = new InstanceConfig(participantId);
            instanceConfig.setInstanceEnabled(false);
            instanceConfig.setContainerSpec(spec);
View Full Code Here

TOP

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

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.