Package org.apache.uima.ducc.common.utils.id

Examples of org.apache.uima.ducc.common.utils.id.DuccId


  protected String getCode(Map<DuccId, IDuccProcess> map) {
    String code = "?";
    if(map != null) {
      Iterator<DuccId> iterator = map.keySet().iterator();
      while(iterator.hasNext()) {
        DuccId key = iterator.next();
        IDuccProcess process = map.get(key);
        code = ""+process.getProcessExitCode();
        break;
      }
    }
View Full Code Here


    }
    return code;
  }
 
  protected DuccId getKey(String jobId) {
    DuccId retVal = null;
    Enumeration<DuccId> keys = mMap.keys();
    while(keys.hasMoreElements()) {
      DuccId duccId = keys.nextElement();
      String mapId = ""+duccId.getFriendly();
      if(mapId.equals(jobId)) {
        retVal = duccId;
        break;
      }
    }
View Full Code Here

   
    int countAtArrival = updateCounter.get();
    int countAtPresent = countAtArrival;
    int sleepSecondsMax = 3*60;
   
    DuccId duccId = getKey(jobId);
   
    if(duccId == null) {
      int sleepSeconds = 0;
      duccLogger.info(location, duccId, "Waiting for update...");
      while(duccId == null) {
        try {
          duccLogger.debug(location, duccId, "Waiting continues...");
          Thread.sleep(1000);
          sleepSeconds += 1;
          if(sleepSeconds > sleepSecondsMax) {
            break;
          }
          countAtPresent = updateCounter.get();
          if((countAtPresent-countAtArrival) > 2) {
            break;
          }
          duccId = getKey(jobId);
        }
        catch(Exception e) {
        }
      }
      duccLogger.info(location, duccId, "Waiting complete.");
      duccId = getKey(jobId);
    }
   
    if(duccId != null) {
      monitorInfo = mMap.get(duccId);
      if(tMap.containsKey(duccId)) {
        long expiryMillis = System.currentTimeMillis()+timeoutMillis+1;
        TrackingInfo ti = tMap.get(duccId);
        ti.time = expiryMillis;
        duccLogger.info(location, duccId, "auto-cancel expiry extended");
      }
    }
    else {
      try {
        int iJobId = Integer.parseInt(jobId);
        duccId = new DuccId(iJobId);
        duccLogger.info(location, duccId, "not found");
      }
      catch(Exception e) {
        duccLogger.error(location, jobid, e);
      }
View Full Code Here

    long nowMillis = System.currentTimeMillis();
   
    Enumeration<DuccId> keys = tMap.keys();
    while(keys.hasMoreElements()) {
      long minutesLeft = 0;
      DuccId duccId = keys.nextElement();
      TrackingInfo ti = tMap.get(duccId);
      long expiryMillis = ti.time;
      if(nowMillis < expiryMillis) {
        minutesLeft = (expiryMillis - nowMillis) / millisPerMinute;
      }
View Full Code Here

    String location = "canceler";
    duccLogger.trace(location, jobid, "enter");

    Enumeration<DuccId> keys = tMap.keys();
    while(keys.hasMoreElements()) {
      DuccId duccId = keys.nextElement();
      TrackingInfo ti = tMap.get(duccId);
      long expiryMillis = ti.time;
      if(nowMillis > expiryMillis) {
        if(isCancelable(duccId)) {
          cancel(duccId);
View Full Code Here

 
  private JsonArray buildJobRow(HttpServletRequest request, IDuccWorkJob job, DuccData duccData, long now, ServicesRegistry servicesRegistry) {
    String type="Job";
    JsonArray row = new JsonArray();
    StringBuffer sb;
    DuccId duccId = job.getDuccId();
    // Terminate
    sb = new StringBuffer();
    String id = normalize(duccId);
    sb.append("<span class=\"ducc-col-terminate\">");
    if(terminateEnabled) {
View Full Code Here

    String reservationType = "Unmanaged";
    if(duccwork instanceof DuccWorkJob) {
      reservationType = "Managed";
    }
    StringBuffer sb;
    DuccId duccId = duccwork.getDuccId();
    // Terminate
    sb = new StringBuffer();
    String id = normalize(duccId);
    sb.append("<span class=\"ducc-col-terminate\">");
    if(terminateEnabled) {
      if(!duccwork.isCompleted()) {
        String disabled = getDisabledWithHover(request,duccwork);
        String user = duccwork.getStandardInfo().getUser();
        if(user != null) {
          DuccPropertiesResolver dpr = DuccPropertiesResolver.getInstance();
          String jdHostUser = dpr.getCachedProperty(DuccPropertiesResolver.ducc_jd_host_user);
          // We presume that user is sufficient to identify JD shares
          if(user.equals(jdHostUser)) {
            disabled = "disabled=\"disabled\"";
          }
        }
        sb.append("<input type=\"button\" onclick=\"ducc_confirm_terminate_reservation("+id+")\" value=\"Terminate\" "+disabled+"/>");
      }
    }
    sb.append("</span>");
    row.add(new JsonPrimitive(sb.toString()));
    // Id
    sb = new StringBuffer();
    if(reservationType.equals("Managed")) {
      sb.append("<span>");
      sb.append("<a href=\"reservation.details.html?id="+id+"\">"+id+"</a>");
      sb.append("</span>");
    }
    else {
      sb.append("<span>");
      sb.append(id);
      sb.append("</span>");
    }
    row.add(new JsonPrimitive(sb.toString()));
    // Start
    sb = new StringBuffer();
    sb.append("<span title=\""+DuccConstants.hintPreferencesDateStyle+"\">");
    sb.append(getTimeStamp(request,duccwork.getDuccId(), duccwork.getStandardInfo().getDateOfSubmission()));
    sb.append("</span>");
    row.add(new JsonPrimitive(sb.toString()));
    // Duration
    sb = new StringBuffer();
    if(duccwork instanceof DuccWorkReservation) {
      DuccWorkReservation reservation = (DuccWorkReservation) duccwork;
      switch(reservation.getReservationState()) {
      case Completed:
        sb.append("<span>");
        String duration = getDuration(request,reservation);
        String decoratedDuration = decorateDuration(request,reservation, duration);
        sb.append(decoratedDuration);
        sb.append("</span>");
        break;
      default:
        sb.append("<span class=\"health_green\""+">");
        duration = getDuration(request,reservation,now);
        decoratedDuration = decorateDuration(request,reservation, duration);
        sb.append(decoratedDuration);
        sb.append("</span>");
        break;
      }
    }
    else if(duccwork instanceof DuccWorkJob) {
      DuccWorkJob job = (DuccWorkJob) duccwork;
      switch(job.getJobState()) {
      case Completed:
        sb.append("<span>");
        String duration = getDuration(request,job);
        String decoratedDuration = decorateDuration(request,job, duration);
        sb.append(decoratedDuration);
        sb.append("</span>");
        break;
      default:
        sb.append("<span class=\"health_green\""+">");
        duration = getDuration(request,job,now);
        decoratedDuration = decorateDuration(request,job, duration);
        sb.append(decoratedDuration);
        sb.append("</span>");
        break;
      }
    }
    row.add(new JsonPrimitive(sb.toString()));
    // User
    sb = new StringBuffer();
    String title = "";
    String submitter = duccwork.getStandardInfo().getSubmitter();
    if(submitter != null) {
      title = "title=\"submitter PID@host: "+submitter+"\"";
    }
    sb.append("<span "+title+">");
    UserId userId = new UserId(duccwork.getStandardInfo().getUser());
    sb.append(userId.toString());
    sb.append("</span>");
    row.add(new JsonPrimitive(sb.toString()));
    // Class
    row.add(new JsonPrimitive(stringNormalize(duccwork.getSchedulingInfo().getSchedulingClass(),messages.fetch("default"))));
    // Type
    sb = new StringBuffer();
    sb.append(reservationType);
    row.add(new JsonPrimitive(sb.toString()));
    // State
    sb = new StringBuffer();
    String state = duccwork.getStateObject().toString();
    sb.append("<span>");
    if(duccData.isLive(duccId)) {
      if(duccwork.isOperational()) {
        sb.append("<span class=\"active_state\">");
      }
      else {
        sb.append("<span class=\"completed_state\">");
      }
      sb.append(state);
      sb.append("</span>");
    }
    else {
      sb.append("<span class=\"historic_state\">");
      sb.append(state);
      sb.append("</span>");
    }
    sb.append("</span>");
    row.add(new JsonPrimitive(sb.toString()));
    // Reason
    sb = new StringBuffer();
    if(duccwork instanceof DuccWorkReservation) {
      DuccWorkReservation reservation = (DuccWorkReservation) duccwork;
      switch(reservation.getCompletionType()) {
      case Undefined:
        break;
      case CanceledByUser:
      case CanceledByAdmin:
        try {
          String cancelUser = duccwork.getStandardInfo().getCancelUser();
          if(cancelUser != null) {
            sb.append("<span title=\"canceled by "+cancelUser+"\">");
            sb.append(duccwork.getCompletionTypeObject().toString());
            sb.append("</span>");
          }
          else {             
            IRationale rationale = reservation.getCompletionRationale();
            if(rationale != null) {
              sb.append("<span title=\""+rationale+"\">");
              sb.append(duccwork.getCompletionTypeObject().toString());
              sb.append("</span>");
            }
            else {
              sb.append(duccwork.getCompletionTypeObject().toString());
            }
           
          }
        }
        catch(Exception e) {
          IRationale rationale = reservation.getCompletionRationale();
          if(rationale != null) {
            sb.append("<span title=\""+rationale+"\">");
            sb.append(duccwork.getCompletionTypeObject().toString());
            sb.append("</span>");
          }
          else {
            sb.append(duccwork.getCompletionTypeObject().toString());
          }
        }
        break;
      default:
        IRationale rationale = reservation.getCompletionRationale();
        if(rationale != null) {
          sb.append("<span title=\""+rationale+"\">");
          sb.append(duccwork.getCompletionTypeObject().toString());
          sb.append("</span>");
        }
        else {
          sb.append(duccwork.getCompletionTypeObject().toString());
        }
        break;
      }
    }
    else if(duccwork instanceof DuccWorkJob) {
      // Reason
      DuccWorkJob job = (DuccWorkJob) duccwork;
      sb = getReason(job,DuccType.Reservation);
    }
    row.add(new JsonPrimitive(sb.toString()));
    // Allocation
    sb = new StringBuffer();
    sb.append("<span>");
    sb.append(duccwork.getSchedulingInfo().getInstancesCount());
    sb.append("</span>");
    row.add(new JsonPrimitive(sb.toString()));
    // User Processes
    sb = new StringBuffer();
    TreeMap<String,Integer> nodeMap = new TreeMap<String,Integer>();
    if(duccwork instanceof DuccWorkReservation) {
      DuccWorkReservation reservation = (DuccWorkReservation) duccwork;
      if(!reservation.getReservationMap().isEmpty()) {
        IDuccReservationMap map = reservation.getReservationMap();
        for (DuccId key : map.keySet()) {
          IDuccReservation value = reservation.getReservationMap().get(key);
          String node = value.getNodeIdentity().getName();
          if(!nodeMap.containsKey(node)) {
            nodeMap.put(node,new Integer(0));
          }
          Integer count = nodeMap.get(node);
          count++;
          nodeMap.put(node,count);
        }
      }
     
      boolean qualify = false;
      if(!nodeMap.isEmpty()) {
        if(nodeMap.keySet().size() > 1) {
          qualify = true;
        }
      }
      ArrayList<String> qualifiedPids = new ArrayList<String>();
      if(duccwork.isOperational()) {
        DuccMachinesData machinesData = DuccMachinesData.getInstance();
        for (String node: nodeMap.keySet()) {
          NodeId nodeId = new NodeId(node);
          List<String> nodePids = machinesData.getPids(nodeId, userId);
          for( String pid : nodePids ) {
            if(qualify) {
              qualifiedPids.add(node+":"+pid);
            }
            else {
              qualifiedPids.add(pid);
            }
          }
        }
      }
      if(qualifiedPids.size() > 0) {
        String list = "";
        for( String entry : qualifiedPids ) {
          list += entry+" ";
        }
        sb.append("<span title=\""+list.trim()+"\">");
        sb.append(""+qualifiedPids.size());
        sb.append("</span>");
      }
      else {
        sb.append(""+qualifiedPids.size());
      }
    }
    else {
      DuccWorkJob job = (DuccWorkJob) duccwork;
      if(job.isOperational()) {
        sb.append(duccwork.getSchedulingInfo().getInstancesCount());
      }
      else {
        sb.append("0");
      }
      Iterator<DuccId> iterator = job.getProcessMap().keySet().iterator();
      while(iterator.hasNext()) {
        DuccId processId = iterator.next();
        IDuccProcess process = job.getProcessMap().get(processId);
        String node = process.getNodeIdentity().getName();
        nodeMap.put(node, 1);
      }
    }
View Full Code Here

 
  public Set<DuccId> getJobKeySet() {
    Set<DuccId> retVal = new HashSet<DuccId>();
    Iterator<DuccId> iterator = keySet().iterator();
    while(iterator.hasNext()) {
      DuccId duccId = iterator.next();
      switch(concurrentWorkMap.get(duccId).getDuccType()) {
      case Job:
        retVal.add(duccId);
        break;
      default:
View Full Code Here

 
  public Set<DuccId> getServiceKeySet() {
    Set<DuccId> retVal = new HashSet<DuccId>();
    Iterator<DuccId> iterator = keySet().iterator();
    while(iterator.hasNext()) {
      DuccId duccId = iterator.next();
      switch(concurrentWorkMap.get(duccId).getDuccType()) {
      case Service:
        retVal.add(duccId);
        break;
      default:
View Full Code Here

 
  public Set<DuccId> getManagedReservationKeySet() {
    Set<DuccId> retVal = new HashSet<DuccId>();
    Iterator<DuccId> iterator = keySet().iterator();
    while(iterator.hasNext()) {
      DuccId duccId = iterator.next();
      IDuccWork duccWork = concurrentWorkMap.get(duccId);
      if(duccWork != null) {
        switch(duccWork.getDuccType()) {
        case Service:
          DuccWorkJob service = (DuccWorkJob)duccWork;
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.common.utils.id.DuccId

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.