Package com.alipay.bluewhale.core.task.common

Examples of com.alipay.bluewhale.core.task.common.Assignment


    Set<Entry<String, StormBase>> basesEntry = bases.entrySet();
    for (Iterator<Entry<String, StormBase>> it = basesEntry.iterator(); it.hasNext();) {
      Entry<String, StormBase> entry = it.next();
      String stormId = entry.getKey();
      StormBase base = entry.getValue();
      Assignment assignment = stormClusterState.assignment_info(stormId,null);
      if (assignment != null) {
        HashSet<NodePort> workers = new HashSet<NodePort>();
        Collection<NodePort> entryColl = assignment.getTaskToNodeport().values();
        workers.addAll(entryColl);
        topologySummaries.add(new TopologySummary(stormId, base.getStormName(), assignment.getTaskToNodeport().size(),
            workers.size(), TimeUtils.time_delta(base
                .getLanchTimeSecs()), extractStatusStr(base)));
      }
    }
    return new ClusterSummary(supervisorSummaries, uptime,topologySummaries);
View Full Code Here


   
    //���topology��name������ʱ���״̬
    StormBase base = stormClusterState.storm_base(topologyId, null);
   
    //���topology�����������Ϣ
    Assignment assignment = stormClusterState.assignment_info(topologyId,null);
   
    if (base != null && assignment != null) {
      List<TaskSummary> taskSummarys = new ArrayList<TaskSummary>();
      Set<Entry<Integer, String>> taskInfoSet = taskInfo.entrySet();
      for (Iterator<Entry<Integer, String>> it = taskInfoSet.iterator(); it.hasNext();) {
        Entry<Integer, String> entry =  it.next();
        Integer taskId =  entry.getKey();
        String componentId =  entry.getValue();
        NodePort np = (NodePort) assignment.getTaskToNodeport().get(taskId);
        //���ָ��task��������Ϣ
        TaskHeartbeat heartbeat = stormClusterState.task_heartbeat(topologyId, taskId);
        if (np == null || heartbeat == null) {
          continue;
        }
        String host = (String) assignment.getNodeHost().get(np.getNode());
        List<TaskError> errors = stormClusterState.task_errors(topologyId, taskId);
        List<ErrorInfo> newErrors = new ArrayList<ErrorInfo>();

        if (errors != null) {
          int size = errors.size();
View Full Code Here

  }
  public static List<String> getStatus(String stormId) throws Exception
  {
    StormClusterState stat=GetShards.getCluster();
   
    Assignment ass=stat.assignment_info(stormId, null);
    Map<String, String> nodeHost=(ass==null)?(new HashMap<String, String>()):ass.getNodeHost();
    Map<Integer, Integer> taskStartTimeSecs=(ass==null)?(new HashMap<Integer, Integer>()):ass.getTaskStartTimeSecs();
    Map<Integer, NodePort> taskToNodeport=(ass==null)?(new HashMap<Integer, NodePort>()):ass.getTaskToNodeport();
   
   
   
    List<String> rtn=new ArrayList<String>();
    List<Integer> taskids=stat.task_ids(stormId);
View Full Code Here

      //��ȡ���е�supervisor�ڵ���Ϣ��
      Map<String, SupervisorInfo> supInfos = allSupervisorInfo(stormClusterState, callback);
      //��ȡ<supervisorid,hostname>map���ϣ����磺node->host {"4b83cd41-e863-4bd6-b26d-3e27e5ff7799" "dw-perf-3.alipay.net","b8f1664d-5555-4950-8139-5098fb109a81" "dw-perf-2.alipay.net"}
      Map<String, String> nodeHost = getNodeHost(supInfos);
      //��ȡָ��topologyid��assignment��Ϣ��
      Assignment existingAssignment = stormClusterState.assignment_info(topologyid, null);
      //�����ȡtopology�����Ӧ�µ�NodePort
 
     
      Map<Integer, NodePort> taskNodePort = computeNewTaskToNodePort(data,
          topologyid, existingAssignment, stormClusterState, callback,
          supInfos, isScratch);
 
   
      Map<String, String> allNodeHost = new HashMap<String, String>();
     
      if (existingAssignment != null){
          allNodeHost = existingAssignment.getNodeHost();//�����Ƿ�ֹsupervisor���ˣ�task������Ȼ������
      }
     
      if (nodeHost != null){
          allNodeHost.putAll(nodeHost);
      }
      Set<Integer> reassignIds = null;
      if (existingAssignment != null && existingAssignment.getTaskToNodeport() != null){
          reassignIds = changeIds(existingAssignment.getTaskToNodeport(),taskNodePort);
      }else{
          //FIXME changeIds����ִ�У�����startTimes->taskid�п���Ϊnull
          reassignIds = changeIds(new HashMap<Integer, NodePort>(),taskNodePort);
      }
 
 
      //��ʼ����ʼʱ��
      Map<Integer, Integer> startTimes = new HashMap<Integer, Integer>();
      if (existingAssignment != null){
          Map<Integer, Integer> taskStartTimeSecs = existingAssignment.getTaskStartTimeSecs();
          if (taskStartTimeSecs!= null){
              startTimes.putAll(taskStartTimeSecs);
          }
      }
      //������·����ˣ���Ҫ���ó�ʼ��ʱ��
      if (reassignIds != null){
        int nowSecs = TimeUtils.current_time_secs();
          for (Integer reassignid:reassignIds) {
            startTimes.put(reassignid, nowSecs);
          }
      }
     
     
      //select-keys all-node->host (map first (vals task->node+port))
      Map<String, String> storeNodeHosts = new HashMap<String, String>();
 
      if (taskNodePort != null){
        HashSet<String> toSaveHosts=new HashSet<String>();
          for (Entry<Integer, NodePort> entry:taskNodePort.entrySet()) {
            toSaveHosts.add((entry.getValue()).getNode());
          }
         
          for(String node:toSaveHosts)
          {
            String host=allNodeHost.get(node);
            storeNodeHosts.put(node, host);
          }
      }else{
        storeNodeHosts.putAll(allNodeHost);
      }
      Assignment assignment = new Assignment(StormConfig.masterStormdistRoot(
          conf, topologyid), taskNodePort, storeNodeHosts, startTimes);
      if (assignment.equals(existingAssignment)) {
        LOG.debug("Assignment for " + topologyid + " hasn't changed");
      } else {
        LOG.info("Setting new assignment for storm id " + topologyid + ": "
            + assignment);
        stormClusterState.set_assignment(topologyid, assignment);
View Full Code Here

    Map<String, Set<Integer>> rtn = null;

    if (assignments != null) {
      rtn = new HashMap<String, Set<Integer>>();
      for (String topologyid:assignments) {
        Assignment assignment = stormClusterState.assignment_info(topologyid,null);
        if (assignment == null) {
          continue;
        }
        //����:task->node+port {1 ["b8f1664d-5555-4950-8139-5098fb109a81" 6702], 2 ["4b83cd41-e863-4bd6-b26d-3e27e5ff7799" 6701]}
        Map<Integer, NodePort> taskNodePort = assignment.getTaskToNodeport();
        if(taskNodePort!=null){
          for (Entry<Integer, NodePort> entry:taskNodePort.entrySet()) {
            NodePort np =entry.getValue();
            Set<Integer> ports = rtn.get(np.getNode());
            if(ports==null)
View Full Code Here

  /**
   * ��zk�ж�ȡ��ǰwork�����task
   */
  public static java.util.Set<Integer> readWorkerTaskids(StormClusterState zkCluster, String topologyid,String supervisorId, int port) {
    Set<Integer> tasks = null;
    Assignment assignmentInfo = zkCluster.assignment_info(topologyid, null);
    if (assignmentInfo != null) {
      tasks = new HashSet<Integer>();
      Map<Integer, NodePort> taskToNodeport = assignmentInfo.getTaskToNodeport();
      for (Entry<Integer, NodePort> taskNode : taskToNodeport.entrySet()) {
        NodePort loc = taskNode.getValue();
        if (loc != null && loc.getNode().equals(supervisorId)&& loc.getPort() == port) {
          tasks.add(taskNode.getKey());
        }
      }
      LOG.info("readWorkerTaskids topologyid=" + topologyid + ",port="
          + port + ",supervisorId=" + supervisorId + ",tasks.size="
          + tasks.size() + "," + assignmentInfo.toString());

    }
    return tasks;
  }
View Full Code Here

    try {
      //
      //
      // endpoint_socket_lock.writeLock().lock();
      // TODO �Ƿ��б�Ҫ�������ֲ������̰߳�ȫ,taskNodeport�����Ѿ��̰߳�ȫ
      Assignment assignment = zkCluster.assignment_info(topologyId, this);
      Map<Integer, NodePort> my_assignment = new HashMap<Integer, NodePort>();
      Map<Integer, NodePort> taskNodeportAll = null;
      Map<String, String> node = null;
      if (assignment != null) {
        taskNodeportAll = assignment.getTaskToNodeport();
        node = assignment.getNodeHost();
      }

      // ��������outbound_tasks�е�task(�к������յ�)
      Set<NodePort> need_connections = new HashSet<NodePort>();
      if (taskNodeportAll != null && outboundTasks != null) {
View Full Code Here

    List<String> topologyids = stormClusterState.assignments(callback);

    if (topologyids != null) {
      rtn = new HashMap<String, String>();
      for (String topologyid : topologyids) {
        Assignment assignmenInfo = stormClusterState.assignment_info(
            topologyid, callback);

        rtn.put(topologyid, assignmenInfo.getMasterCodeDir());
      }
    }
    return rtn;
  }
View Full Code Here

      StormClusterState stormClusterState, String topologyId,
      String supervisorId, RunnableCallback callback) {

    Map<Integer, LocalAssignment> portTasks = null;

    Assignment assignmenInfo = stormClusterState.assignment_info(
        topologyId, callback);

    if (assignmenInfo != null) {
      Map<Integer, NodePort> taskToNodeport = assignmenInfo
          .getTaskToNodeport();

      if (taskToNodeport != null) {

        portTasks = new HashMap<Integer, LocalAssignment>();
View Full Code Here

    public static String LS_APPROVED_WORKERS = "approved-workers";

    public static Integer[] storm_task_ids(StormClusterState stat,
            String storm_id) {
        HashSet<Integer> rtn = new HashSet<Integer>();
        Assignment ass = stat.assignment_info(storm_id, null);
        if (ass != null) {
            for (Integer task : ass.getTaskToNodeport().keySet()) {
                rtn.add(task);
            }
        }

        Integer[] rtnarr = new Integer[rtn.size()];
View Full Code Here

TOP

Related Classes of com.alipay.bluewhale.core.task.common.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.