Package com.alibaba.jstorm.task

Examples of com.alibaba.jstorm.task.LocalAssignment


      // a port must be assigned one storm
      for (Entry<Integer, LocalAssignment> entry : portTasks.entrySet()) {

        Integer port = entry.getKey();

        LocalAssignment la = entry.getValue();

        if (!portLA.containsKey(port)) {
          portLA.put(port, la);
        } else {
          throw new RuntimeException(
View Full Code Here


    for (ResourceWorkerSlot worker : workers) {
      if (!supervisorId.equals(worker.getNodeId()))
        continue;
      portTasks.put(worker.getPort(),
          new LocalAssignment(topologyId, worker.getTasks(),
              stormBase.getStormName(), worker.getMemSize(),
              worker.getCpu(), worker.getJvm()));
    }

    return portTasks;
View Full Code Here

   */
  public boolean matchesAssignment(WorkerHeartbeat whb,
      Map<Integer, LocalAssignment> assignedTasks) {

    boolean isMatch = true;
    LocalAssignment localAssignment = assignedTasks.get(whb.getPort());

    if (localAssignment == null) {
      isMatch = false;
    } else if (!whb.getTopologyId().equals(localAssignment.getTopologyId())) {
      // topology id not equal
      LOG.info("topology id not equal whb=" + whb.getTopologyId()
          + ",localAssignment=" + localAssignment.getTopologyId());
      isMatch = false;
    } else if (!(whb.getTaskIds().equals(localAssignment.getTaskIds()))) {
      // task-id isn't equal
      LOG.info("task-id isn't equal whb=" + whb.getTaskIds()
          + ",localAssignment=" + localAssignment.getTaskIds());
      isMatch = false;
    }

    return isMatch;
  }
View Full Code Here

     */
    Map<Integer, String> newWorkerIds = new HashMap<Integer, String>();

    for (Entry<Integer, LocalAssignment> entry : newWorkers.entrySet()) {
      Integer port = entry.getKey();
      LocalAssignment assignment = entry.getValue();

      String workerId = UUID.randomUUID().toString();

      newWorkerIds.put(port, workerId);

      // create new worker Id directory
      // LOCALDIR/workers/newworkid/pids
      try {
        StormConfig.worker_pids_root(conf, workerId);
      } catch (IOException e1) {
        LOG.error("Failed to create " + workerId + " localdir", e1);
        throw e1;
      }

      StringBuilder sb = new StringBuilder();
      sb.append("Launching worker with assiangment ");
      sb.append(assignment.toString());
      sb.append(" for the supervisor ");
      sb.append(supervisorId);
      sb.append(" on port ");
      sb.append(port);
      sb.append(" with id ");
      sb.append(workerId);
      LOG.info(sb);

      try {
        String clusterMode = StormConfig.cluster_mode(conf);

        if (clusterMode.equals("distributed")) {
          launchWorker(conf, sharedContext,
              assignment.getTopologyId(), supervisorId, port,
              workerId, assignment);
        } else if (clusterMode.equals("local")) {
          launchWorker(conf, sharedContext,
              assignment.getTopologyId(), supervisorId, port,
              workerId, workerThreadPids);
        }
      } catch (Exception e) {
        String errorMsg = "Failed to launchWorker workerId:" + workerId
            + ":" + port;
View Full Code Here

TOP

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

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.