Examples of RunningInstance


Examples of org.apache.helix.api.RunningInstance

    Map<ParticipantId, Participant> liveInstances = new HashMap<ParticipantId, Participant>();
    Set<PartitionId> disabledPartitions = Collections.emptySet();
    Set<String> tags = Collections.emptySet();
    Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
    Map<MessageId, Message> messageMap = Collections.emptyMap();
    RunningInstance runningInstance0 =
        new RunningInstance(SessionId.from("session_0"), HelixVersion.from("1.2.3.4"),
            ProcId.from("0"));
    RunningInstance runningInstance1 =
        new RunningInstance(SessionId.from("session_1"), HelixVersion.from("1.2.3.4"),
            ProcId.from("1"));
    liveInstances.put(ParticipantId.from("localhost_0"),
        new Participant(ParticipantId.from("localhost_0"), "localhost", 0, true,
            disabledPartitions, tags, runningInstance0, currentStateMap, messageMap,
            new UserConfig(Scope.participant(ParticipantId.from("localhost_0")))));
View Full Code Here

Examples of org.apache.helix.api.RunningInstance

    Map<ParticipantId, Participant> liveInstances = new HashMap<ParticipantId, Participant>();
    Set<PartitionId> disabledPartitions = Collections.emptySet();
    Set<String> tags = Collections.emptySet();
    Map<ResourceId, CurrentState> currentStateMap = Collections.emptyMap();
    Map<MessageId, Message> messageMap = Collections.emptyMap();
    RunningInstance runningInstance0 =
        new RunningInstance(SessionId.from("session_0"), HelixVersion.from("1.2.3.4"),
            ProcId.from("0"));
    RunningInstance runningInstance1 =
        new RunningInstance(SessionId.from("session_1"), HelixVersion.from("1.2.3.4"),
            ProcId.from("1"));
    liveInstances.put(ParticipantId.from("localhost_0"),
        new Participant(ParticipantId.from("localhost_0"), "localhost", 0, true,
            disabledPartitions, tags, runningInstance0, currentStateMap, messageMap,
            new UserConfig(Scope.participant(ParticipantId.from("localhost_0")))));
View Full Code Here

Examples of org.apache.helix.api.RunningInstance

            .append(", messages: ").append(participant.getMessageMap().toString())
            .append(participant.getCurrentStateMap().toString()).append(", alive: ")
            .append(participant.isAlive()).append(", userConfig: ")
            .append(participant.getUserConfig().toString());
    if (participant.isAlive()) {
      RunningInstance runningInstance = participant.getRunningInstance();
      sb.append(", sessionId: ").append(runningInstance.getSessionId().stringify())
          .append(", processId: ").append(runningInstance.getPid().stringify())
          .append(", helixVersion: ").append(runningInstance.getVersion().toString());
    }
    System.out.println(sb.toString());
  }
View Full Code Here

Examples of org.apache.helix.api.RunningInstance

    Participant participant = readParticipant(participantId);
    if (!participant.isAlive()) {
      LOG.error("Cannot reset partitions because the participant is not running");
      return false;
    }
    RunningInstance runningInstance = participant.getRunningInstance();

    // check that the resource exists
    ResourceAccessor resourceAccessor = resourceAccessor();
    Resource resource = resourceAccessor.readResource(resourceId);
    if (resource == null || resource.getRebalancerConfig() == null) {
      LOG.error("Cannot reset partitions because the resource is not present");
      return false;
    }

    // need the rebalancer context for the resource
    RebalancerContext context =
        resource.getRebalancerConfig().getRebalancerContext(RebalancerContext.class);
    if (context == null) {
      LOG.error("Rebalancer context for resource does not exist");
      return false;
    }

    // ensure that all partitions to reset exist
    Set<PartitionId> partitionSet = ImmutableSet.copyOf(context.getSubUnitIdSet());
    if (!partitionSet.containsAll(resetPartitionIdSet)) {
      LOG.error("Not all of the specified partitions to reset exist for the resource");
      return false;
    }

    // check for a valid current state that has all specified partitions in ERROR state
    CurrentState currentState = participant.getCurrentStateMap().get(resourceId);
    if (currentState == null) {
      LOG.error("The participant does not have a current state for the resource");
      return false;
    }
    for (PartitionId partitionId : resetPartitionIdSet) {
      if (!currentState.getState(partitionId).equals(State.from(HelixDefinedState.ERROR))) {
        LOG.error("Partition " + partitionId + " is not in error state, aborting reset");
        return false;
      }
    }

    // make sure that there are no pending transition messages
    for (Message message : participant.getMessageMap().values()) {
      if (!MessageType.STATE_TRANSITION.toString().equalsIgnoreCase(message.getMsgType())
          || !runningInstance.getSessionId().equals(message.getTypedTgtSessionId())
          || !resourceId.equals(message.getResourceId())
          || !resetPartitionIdSet.contains(message.getPartitionId())) {
        continue;
      }
      LOG.error("Cannot reset partitions because of the following pending message: " + message);
      return false;
    }

    // set up the source id
    String adminName = null;
    try {
      adminName = InetAddress.getLocalHost().getCanonicalHostName() + "-ADMIN";
    } catch (UnknownHostException e) {
      // can ignore it
      if (LOG.isInfoEnabled()) {
        LOG.info("Unable to get host name. Will set it to UNKNOWN, mostly ignorable", e);
      }
      adminName = "UNKNOWN";
    }

    // build messages to signal the transition
    StateModelDefId stateModelDefId = context.getStateModelDefId();
    StateModelDefinition stateModelDef =
        _accessor.getProperty(_keyBuilder.stateModelDef(stateModelDefId.stringify()));
    Map<MessageId, Message> messageMap = Maps.newHashMap();
    for (PartitionId partitionId : resetPartitionIdSet) {
      // send ERROR to initialState message
      MessageId msgId = MessageId.from(UUID.randomUUID().toString());
      Message message = new Message(MessageType.STATE_TRANSITION, msgId);
      message.setSrcName(adminName);
      message.setTgtName(participantId.stringify());
      message.setMsgState(MessageState.NEW);
      message.setPartitionId(partitionId);
      message.setResourceId(resourceId);
      message.setTgtSessionId(runningInstance.getSessionId());
      message.setStateModelDef(stateModelDefId);
      message.setFromState(State.from(HelixDefinedState.ERROR.toString()));
      message.setToState(stateModelDef.getTypedInitialState());
      message.setStateModelFactoryId(context.getStateModelFactoryId());
View Full Code Here

Examples of org.apache.helix.api.RunningInstance

      }
    }

    Set<String> tags = new HashSet<String>(instanceConfig.getTags());

    RunningInstance runningInstance = null;
    if (liveInstance != null) {
      runningInstance =
          new RunningInstance(liveInstance.getTypedSessionId(),
              liveInstance.getTypedHelixVersion(), liveInstance.getProcessId());
    }

    Map<MessageId, Message> msgMap = new HashMap<MessageId, Message>();
    if (instanceMsgMap != null) {
View Full Code Here

Examples of org.jclouds.ec2.domain.RunningInstance

      checkNotNull(id, "id");
      String[] parts = AWSUtils.parseHandle(id);
      String region = parts[0];
      String instanceId = parts[1];
      try {
         RunningInstance runningInstance = getRunningInstanceInRegion(region, instanceId);
         return runningInstanceToNodeMetadata.apply(runningInstance);
      } catch (NoSuchElementException e) {
         return null;
      }
   }
View Full Code Here

Examples of org.jclouds.ec2.domain.RunningInstance

   private void blockUntilRunningAndAssignElasticIpsToInstancesOrPutIntoBadMap(Set<RunningInstance> input,
         Map<NodeMetadata, Exception> badNodes) {
      Map<RegionAndName, RunningInstance> instancesById = Maps.uniqueIndex(input, instanceToRegionAndName);
      for (Map.Entry<RegionAndName, RunningInstance> entry : instancesById.entrySet()) {
         RegionAndName id = entry.getKey();
         RunningInstance instance = entry.getValue();
         try {
            logger.debug("<< allocating elastic IP instance(%s)", id);
            String ip = client.getElasticIPAddressServices().allocateAddressInRegion(id.getRegion());
            // block until instance is running
            logger.debug(">> awaiting status running instance(%s)", id);
View Full Code Here

Examples of org.jclouds.ec2.domain.RunningInstance

      Set<? extends Reservation<? extends RunningInstance>> response = client.describeInstancesInRegion("nova");
     
      assertEquals(response.size(), 3);

      Reservation<? extends RunningInstance> target = Iterables.get(response, 2);
      RunningInstance runningInstance = Iterables.getOnlyElement(target);
      BlockDevice bd = Iterables.getOnlyElement(runningInstance.getEbsBlockDevices().values());
     
      // this is a '-' in the nova_ec2_describe_instances.xml
      assertNull(bd.getAttachTime());

      // double-check the other fields
View Full Code Here

Examples of org.jclouds.ec2.domain.RunningInstance

   // terminates the instance.
   private Snapshot createSnapshot() throws RunNodesException {

      String instanceId = null;
      try {
         RunningInstance instance = getOnlyElement(concat(ec2Client.getInstanceServices().runInstancesInRegion(
               regionId, null, imageId, 1, 1)));
         instanceId = instance.getId();
        
         assertTrue(runningTester.apply(instance), instanceId + "didn't achieve the state running!");

         instance = getOnlyElement(concat(ec2Client.getInstanceServices().describeInstancesInRegion(regionId,
               instanceId)));
         BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1");
         assertNotNull(device, "device: /dev/sda1 not present on: " + instance);
         Snapshot snapshot = ec2Client.getElasticBlockStoreServices().createSnapshotInRegion(regionId,
               device.getVolumeId());
         snapshotsToDelete.add(snapshot.getId());
         return snapshot;
View Full Code Here

Examples of org.jclouds.ec2.domain.RunningInstance

      String script = new ScriptBuilder() // lamp install script
            .addStatement(exec("runurl run.alestic.com/apt/upgrade"))//
            .addStatement(exec("runurl run.alestic.com/install/lamp"))//
            .render(OsFamily.UNIX);

      RunningInstance instance = null;
      while (instance == null) {
         try {

            System.out.printf("%d: running instance%n", System.currentTimeMillis());
            Reservation<? extends RunningInstance> reservation = client.getInstanceServices().runInstancesInRegion(
                  null, null, // allow
                  // ec2
                  // to
                  // chose
                  // an
                  // availability
                  // zone
                  "ami-ccf615a5", // alestic ami allows auto-invoke of
                  // user data scripts
                  1, // minimum instances
                  1, // maximum instances
                  asType(InstanceType.M1_SMALL) // smallest instance size
                        .withKeyName(keyPair.getKeyName()) // key I
                        // created
                        // above
                        .withSecurityGroup(securityGroupName) // group I
                        // created
                        // above
                        .withUserData(script.getBytes())); // script to
            // run as root

            instance = Iterables.getOnlyElement(reservation);

         } catch (HttpResponseException htpe) {
            if (htpe.getResponse().getStatusCode() == 400)
               continue;
            throw htpe;
         }
      }
      assertNotNull(instance.getId());
      instanceId = instance.getId();
      assertEquals(instance.getInstanceState(), InstanceState.PENDING);
      instance = blockUntilWeCanSshIntoInstance(instance);

      verifyInstanceProperties(script);
      tryToChangeStuff();
      sshPing(instance);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.