Package com.alipay.bluewhale.core.daemon

Examples of com.alipay.bluewhale.core.daemon.NodePort


    for (Integer tid : jobids) {
      if(index>=nodes.length)
      {
        break;
      }
      NodePort np = nodes[index];
      rtn.put(tid, np);
      LOG.info("higolog random assign:" + tid + "==>" + np.getPort());
      index++;
    }
   
    for (Entry<Integer, NodePort> e : rtn.entrySet()) {
      jobids.remove(e.getKey());
View Full Code Here


          continue;
        }
        hostslot.fixd=true;
        List<NodePort> list = hostslot.ports;
        if (hostslot.index < list.size()) {
          NodePort np = list.get(hostslot.index);
          rtn.put(tid, np);
          LOG.info("higolog assign:" + tid + "==>" + hostslot.host + ","  + hostslot.index + "," + np.getPort());
          hostslot.index++;
        }
      }
     
      ArrayList<HostSlots> hslist=new ArrayList<HostSlots>();
      for(HostSlots hs:hostFreeResource)
      {
        if(hs.fixd)
        {
          for(int i=hs.index;i<hs.ports.size();i++)
          {
            freeResource.remove(hs.ports.get(i));
          }
          hs.index=hs.ports.size();
        }else{
          hslist.add(hs);
        }
      }
     
      if(hslist.size()>0)
      {
        for (Integer tid : jobids) {
          Integer tindex=this.index2host.taskId2Index.get(index).get(tid);
 
          if(tindex!=null&&fixassgin.containsKey(tindex))
          {
            continue;
          }
         
          Integer index2 = tid % hslist.size();
          HostSlots hostslot = hslist.get(index2);
          List<NodePort> list = hostslot.ports;
          if (hostslot.index < list.size()) {
            NodePort np = list.get(hostslot.index);
            rtn.put(tid, np);
            LOG.info("higolog assign:" + tid + "==>" + hostslot.host + ","  + hostslot.index + "," + np.getPort());
            hostslot.index++;
          }
        }
      }
    }else{
View Full Code Here

    rtn.putAll(assignByHost.assignment(freeResource,taskNeedassign));

    AssignmentByRandom assignByRandom=new AssignmentByRandom();
    rtn.putAll(assignByRandom.assign(freeResource, taskNeedassign));

    NodePort tmp=null;
    for(Entry<Integer, NodePort> e:rtn.entrySet())
    {
      tmp=e.getValue();
      break;
    }
View Full Code Here

        continue;
      }
      boolean isbreak=false;
      for(HostPort hp:taskAssignList)
      {
        NodePort np=host2node.get(hp);
        if(np!=null)
        {
          UsedNodePort.add(np);
          LOG.info("assign:task:"+componname+"@"+task+"@"+index+",HostPort:"+hp.toString()+","+",NodePort:"+np.toString());
          rtn.put(task, np);
          isbreak=true;
          break;
        }
      }
View Full Code Here

    if(allSlots!=null){
      Map<String, List<NodePort>> tmp = new HashMap<String, List<NodePort>>();

      // group by first,按照node来分类
      for (Iterator<NodePort> it = allSlots.iterator(); it.hasNext();) {
        NodePort np =it.next();
        if (tmp.containsKey(np.getNode())) {
          List<NodePort> lst = tmp.get(np.getNode());
          lst.add(np);
          tmp.put(np.getNode(), lst);
        } else {
          List<NodePort> lst = new ArrayList<NodePort>();
          lst.add(np);
          tmp.put(np.getNode(), lst);
        }
      }

      // interleave
      List<List<NodePort>> splitup=new ArrayList<List<NodePort>>(tmp.values());
View Full Code Here

  private Map<Integer, NodePort> randAssign(ArrayList<NodePort> randomNP,ArrayList<Integer> nonassign,Map<Integer, NodePort> assignRef)
  {
    Map<NodePort,ArrayList<Integer>> reref = new HashMap<NodePort,ArrayList<Integer>>();
    for(Entry<Integer, NodePort> e:assignRef.entrySet())
    {
      NodePort np=e.getValue();
      ArrayList<Integer> tlis=reref.get(np);
      if(tlis==null)
      {
        tlis=new ArrayList<Integer>();
        reref.put(np, tlis);
      }
      tlis.add(e.getKey());
    }

   
    Map<Integer, NodePort> rtn = new HashMap<Integer, NodePort>();
    int index = 0;
    if (nonassign != null && randomNP != null && randomNP.size() != 0) {
      for (Integer task : nonassign) {
        while(true)
        {
          if (index >= randomNP.size()) {
            index = 0;
          }
         
          NodePort np=randomNP.get(index);
          ArrayList<Integer> tlis=reref.get(np);
          if(tlis!=null&&tlis.size()>0)
          {
            tlis.remove(0);
            index++;
View Full Code Here

TOP

Related Classes of com.alipay.bluewhale.core.daemon.NodePort

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.