Package org.apache.helix.controller.provisioner

Examples of org.apache.helix.controller.provisioner.ContainerId


    // set up the container config if it exists
    ContainerConfig containerConfig = null;
    ContainerSpec containerSpec = instanceConfig.getContainerSpec();
    ContainerState containerState = instanceConfig.getContainerState();
    ContainerId containerId = instanceConfig.getContainerId();
    if (containerSpec != null || containerState != null || containerId != null) {
      containerConfig = new ContainerConfig(containerId, containerSpec, containerState);
    }

    // Populate the logical class
View Full Code Here


          safeAddCallback(future, callback);
        }

        // start new containers
        for (final Participant participant : response.getContainersToStart()) {
          final ContainerId containerId = participant.getInstanceConfig().getContainerId();
          updateContainerState(cache, accessor, keyBuilder, cluster, null, participant.getId(),
              ContainerState.CONNECTING);
          // create the helix participant and add it to cluster
          LOG.info("Starting container " + containerId + " for " + participant.getId());
          ListenableFuture<Boolean> future =
              containerProvider.startContainer(containerId, participant);
          FutureCallback<Boolean> callback = new FutureCallback<Boolean>() {
            @Override
            public void onSuccess(Boolean result) {
              // Do nothing yet, need to wait for live instance
              LOG.info("Container " + containerId + " started for " + participant.getId());
            }

            @Override
            public void onFailure(Throwable t) {
              LOG.error("Could not start container" + containerId + "for participant "
                  + participant.getId(), t);
              updateContainerState(cache, accessor, keyBuilder, cluster, null, participant.getId(),
                  ContainerState.FAILED);
            }
          };
          safeAddCallback(future, callback);
        }

        // release containers
        for (final Participant participant : response.getContainersToRelease()) {
          // mark it as finalizing
          final ContainerId containerId = participant.getInstanceConfig().getContainerId();
          updateContainerState(cache, accessor, keyBuilder, cluster, null, participant.getId(),
              ContainerState.FINALIZING);
          // remove the participant
          LOG.info("Deallocating container " + containerId + " for " + participant.getId());
          ListenableFuture<Boolean> future = containerProvider.deallocateContainer(containerId);
          FutureCallback<Boolean> callback = new FutureCallback<Boolean>() {
            @Override
            public void onSuccess(Boolean result) {
              LOG.info("Container " + containerId + " deallocated. Dropping " + participant.getId());
              InstanceConfig existingInstance =
                  helixAdmin.getInstanceConfig(cluster.getId().toString(), participant.getId()
                      .toString());
              helixAdmin.dropInstance(cluster.getId().toString(), existingInstance);
              cache.requireFullRefresh();
            }

            @Override
            public void onFailure(Throwable t) {
              LOG.error("Could not deallocate container" + containerId + "for participant "
                  + participant.getId(), t);
              updateContainerState(cache, accessor, keyBuilder, cluster, null, participant.getId(),
                  ContainerState.FAILED);
            }
          };
          safeAddCallback(future, callback);
        }

        // stop but don't remove
        for (final Participant participant : response.getContainersToStop()) {
          // switch to halting
          final ContainerId containerId = participant.getInstanceConfig().getContainerId();
          updateContainerState(cache, accessor, keyBuilder, cluster, null, participant.getId(),
              ContainerState.HALTING);
          // stop the container
          LOG.info("Stopping container " + containerId + " for " + participant.getId());
          ListenableFuture<Boolean> future = containerProvider.stopContainer(containerId);
View Full Code Here

        applicationMaster.acquireContainer(containerAsk);
    return Futures.transform(requestNewContainer,
        new Function<ContainerAskResponse, ContainerId>() {
          @Override
          public ContainerId apply(ContainerAskResponse containerAskResponse) {
            ContainerId helixContainerId =
                ContainerId.from(containerAskResponse.getContainer().getId().toString());
            allocatedContainersMap.put(helixContainerId, containerAskResponse.getContainer());
            return helixContainerId;
          }
        });
View Full Code Here

        if (!participant.getId().stringify().startsWith(resource.getId().stringify())) {
          continue;
        }
        ContainerConfig containerConfig = participant.getContainerConfig();
        ContainerState containerState = ContainerState.UNDEFINED;
        ContainerId containerId = ContainerId.from("N/A");

        if (containerConfig != null) {
          containerId = containerConfig.getId();
          containerState = containerConfig.getState();
        }
View Full Code Here

    }

    @Override
    public ListenableFuture<ContainerId> allocateContainer(ContainerSpec spec) {
      // allocation is a no-op
      ContainerId containerId = ContainerId.from(spec.getParticipantId().toString());
      _states.put(containerId, ContainerState.ACQUIRED);
      _containerParticipants.put(containerId, spec.getParticipantId());
      allocated++;
      LOG.info(String.format("ALLOC: %d %d %d %d", allocated, started, stopped, deallocated));
      SettableFuture<ContainerId> future = SettableFuture.create();
View Full Code Here

            containersToRelease.add(participant);
            break;
          default:
            break;
          }
          ContainerId containerId = containerConfig.getId();
          if (containerId != null) {
            _containerParticipants.put(containerId, participant.getId());
            _states.put(containerId, state);
          }
        }
View Full Code Here

TOP

Related Classes of org.apache.helix.controller.provisioner.ContainerId

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.