Package com.alibaba.jstorm.task

Examples of com.alibaba.jstorm.task.Assignment


    Map<Integer, LocalAssignment> portLA = new HashMap<Integer, LocalAssignment>();

    for (Entry<String, Assignment> assignEntry : assignments.entrySet()) {
      String topologyId = assignEntry.getKey();
      Assignment assignment = assignEntry.getValue();

      Map<Integer, LocalAssignment> portTasks = readMyTasks(
          stormClusterState, topologyId, supervisorId, assignment);
      if (portTasks == null) {
        continue;
View Full Code Here


      throws Exception {

    Map<String, String> rtn = new HashMap<String, String>();
    for (Entry<String, Assignment> entry : assignments.entrySet()) {
      String topologyid = entry.getKey();
      Assignment assignmenInfo = entry.getValue();

      Set<ResourceWorkerSlot> workers = assignmenInfo.getWorkers();
      for (ResourceWorkerSlot worker : workers) {
        String node = worker.getNodeId();
        if (supervisorId.equals(node)) {
          rtn.put(topologyid, assignmenInfo.getMasterCodeDir());
          break;
        }
      }

    }
View Full Code Here

      // @@@ does lock need?
      // endpoint_socket_lock.writeLock().lock();
      //

      synchronized (this) {
        Assignment assignment = zkCluster.assignment_info(topologyId,
            this);
        if (assignment == null) {
          String errMsg = "Failed to get Assignment of " + topologyId;
          LOG.error(errMsg);
          // throw new RuntimeException(errMsg);
          return;
        }

        Set<ResourceWorkerSlot> workers = assignment.getWorkers();
        if (workers == null) {
          String errMsg = "Failed to get taskToResource of "
              + topologyId;
          LOG.error(errMsg);
          return;
        }
        workerData.getWorkerToResource().addAll(workers);

        Map<Integer, WorkerSlot> my_assignment = new HashMap<Integer, WorkerSlot>();

        Map<String, String> node = assignment.getNodeHost();

        // only reserve outboundTasks
        Set<WorkerSlot> need_connections = new HashSet<WorkerSlot>();

        Set<Integer> localNodeTasks = new HashSet<Integer>();
View Full Code Here

    Set<Integer> canFree = new HashSet<Integer>();
    canFree.addAll(context.getAllTaskIds());
    canFree.removeAll(context.getUnstoppedTaskIds());

    Map<String, SupervisorInfo> cluster = context.getCluster();
    Assignment oldAssigns = context.getOldAssignment();
    for (Integer task : canFree) {
      ResourceWorkerSlot worker = oldAssigns.getWorkerByTaskId(task);
      if (worker == null) {
        LOG.warn("When free rebalance resource, no ResourceAssignment of task "
            + task);
        continue;
      }
View Full Code Here

    Set<ResourceWorkerSlot> keeps = new HashSet<ResourceWorkerSlot>();
    if (keepAssignIds.isEmpty()) {
      return keeps;
    }

    Assignment oldAssignment = defaultContext.getOldAssignment();
    if (oldAssignment == null) {
      return keeps;
    }
    keeps.addAll(defaultContext.getOldWorkers());
    for (ResourceWorkerSlot worker : defaultContext.getOldWorkers()) {
View Full Code Here

      for (Entry<String, StormBase> entry : bases.entrySet()) {

        String topologyId = entry.getKey();
        StormBase base = entry.getValue();

        Assignment assignment = stormClusterState.assignment_info(
            topologyId, null);
        if (assignment == null) {
          LOG.error("Failed to get assignment of " + topologyId);
          continue;
        }
View Full Code Here

      for (Entry<String, StormBase> entry : bases.entrySet()) {

        String topologyId = entry.getKey();
        StormBase base = entry.getValue();

        Assignment assignment = stormClusterState.assignment_info(
            topologyId, null);
        if (assignment == null) {
          LOG.error("Failed to get assignment of " + topologyId);
          continue;
        }
        assignments.put(topologyId, assignment);

      }

      Map<Integer, WorkerSummary> portWorkerSummarys = new TreeMap<Integer, WorkerSummary>();
      Map<String, Integer> supervisorToUsedSlotNum = new HashMap<String, Integer>();
      for (Entry<String, Assignment> entry : assignments.entrySet()) {
        String topologyId = entry.getKey();
        Assignment assignment = entry.getValue();

        Map<Integer, String> taskToComponent = Cluster
            .topology_task_info(stormClusterState, topologyId);
        Map<Integer, String> taskToComponentType = Cluster
            .topology_task_compType(stormClusterState, topologyId);

        Set<ResourceWorkerSlot> workers = assignment.getWorkers();

        for (ResourceWorkerSlot worker : workers) {
          if (supervisorId.equals(worker.getNodeId()) == false) {
            continue;
          }
          Integer slotNum = supervisorToUsedSlotNum
              .get(supervisorId);
          if (slotNum == null) {
            slotNum = 0;
            supervisorToUsedSlotNum.put(supervisorId, slotNum);
          }
          supervisorToUsedSlotNum.put(supervisorId, ++slotNum);

          Integer port = worker.getPort();
          WorkerSummary workerSummary = portWorkerSummarys
              .get(port);
          if (workerSummary == null) {
            workerSummary = new WorkerSummary();
            workerSummary.set_port(port);
            workerSummary.set_topology(topologyId);
            workerSummary
                .set_tasks(new ArrayList<TaskSummary>());

            portWorkerSummarys.put(port, workerSummary);
          }
         
          for (Integer taskId : worker.getTasks()) {

            String componentName = taskToComponent.get(taskId);
            String componentType = taskToComponentType.get(taskId);
            int uptime = TimeUtils.time_delta(assignment
                .getTaskStartTimeSecs().get(taskId));
            List<TaskSummary> tasks = workerSummary.get_tasks();

            TaskSummary taskSummary = NimbusUtils
                .mkSimpleTaskSummary(worker, taskId,
View Full Code Here

      topologyInfo.set_uptime_secs(TimeUtils.time_delta(base
          .getLanchTimeSecs()));
      topologyInfo.set_status(base.getStatusString());

      // get topology's Assignment
      Assignment assignment = stormClusterState.assignment_info(
          topologyId, null);
      if (assignment == null) {
        throw new TException("Failed to get StormBase from ZK of "
            + topologyId);
      }
View Full Code Here

   *
   * @param event
   * @return
   */
  protected boolean doTopologyAssignment(TopologyAssignEvent event) {
    Assignment assignment = null;
    try {
      assignment = mkAssignment(event);
     
      setTopologyStatus(event);
    } catch (Throwable e) {
View Full Code Here

    // unstoppedTasks are tasks which are alive on no supervisor's(dead)
    // machine
    Set<Integer> unstoppedTasks = new HashSet<Integer>();
    Set<Integer> deadTasks = new HashSet<Integer>();

    Assignment existingAssignment = stormClusterState.assignment_info(
        topologyId, null);
    if (existingAssignment != null) {
      aliveTasks = getAliveTasks(topologyId, allTaskIds);
      unstoppedTasks = getUnstoppedSlots(aliveTasks, supInfos,
          existingAssignment);
View Full Code Here

TOP

Related Classes of com.alibaba.jstorm.task.Assignment

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.