Package org.apache.uima.ducc.transport.event.common

Examples of org.apache.uima.ducc.transport.event.common.DuccWorkReservation


  }
 
  private void updateReservations(IDuccWork duccWork) {
    String location = "updateReservations";
    DuccId duccId = duccWork.getDuccId();
    DuccWorkReservation reservation = (DuccWorkReservation)duccWork;
    if(keyMapReservations.containsKey(duccId)) {
      sortedReservations.remove(keyMapReservations.get(duccId));
      keyMapReservations.remove(duccId);
    }
    ReservationInfo reservationInfo = new ReservationInfo(reservation);
View Full Code Here


  public boolean equals(Object object) {
    boolean retVal = false;
    try {
      ReservationInfo i1 = this;
      ReservationInfo i2 = (ReservationInfo)object;
      DuccWorkReservation j1 = i1.getReservation();
      DuccWorkReservation j2 = i2.getReservation();
      String s1 = j1.getDuccId().toString();
      String s2 = j2.getDuccId().toString();
      retVal = s1.equals(s2);
    }
    catch(Throwable t) { 
    }
    return retVal;
View Full Code Here

  }
 
  
  public int hashCode() {
    ReservationInfo i1 = this;
    DuccWorkReservation j1 = i1.getReservation();
    String s1 = j1.getDuccId().toString();
    return s1.hashCode();
  }
View Full Code Here

            logger.debug(methodName, duccId, messages.fetch("processes active"));
          }
        }
        break;
      case Reservation:
        DuccWorkReservation duccWorkReservation = (DuccWorkReservation)duccWork;
        if(duccWorkReservation != null) {
          if(duccWorkReservation.isCompleted() && isSaved(duccWorkReservation) && isAgedOut(duccWorkReservation)) {
            workMap.removeDuccWork(duccId);
            logger.info(methodName, duccId, messages.fetch("removed reservation"));
            changes ++;
          }
        }
View Full Code Here

              break;
            }
            break;
          case Reservation:
            logger.debug(methodName, duccId, messages.fetch("processing reservation..."));
            DuccWorkReservation duccWorkReservation = (DuccWorkReservation) duccWork;
            changes += reservationMapResourcesAdd(duccWorkReservation,rmResourceState.getPendingAdditions());
            changes += reservationMapResourcesDel(duccWorkReservation,rmResourceState.getPendingRemovals());
            ReservationState reservationState = duccWorkReservation.getReservationState();
            switch(reservationState) {
            case Received:
              logger.warn(methodName, duccId, messages.fetchLabel("unexpected state")+reservationState);
              break;
            case WaitingForResources:
              if(rmResourceState.isRefused()) {
                String schedulingClass = duccWorkReservation.getSchedulingInfo().getSchedulingClass().trim();
                if(schedulingClass.equals(DuccSchedulerClasses.JobDriver)) {
                  if(!refusedLogged.get()) {
                    logger.warn(methodName, duccId, messages.fetchLabel("refusal ignored")+rmResourceState.getReason());
                    refusedLogged.set(true);
                  }
                }
                else {
                  duccWorkReservation.getStandardInfo().setDateOfCompletion(TimeStamp.getCurrentMillis());
                  duccWorkReservation.setCompletionType(ReservationCompletionType.ResourcesUnavailable);
                  duccWorkReservation.setCompletionRationale(new Rationale("resource manager refused allocation: "+rmResourceState.getReason()));
                  changes += stateChange(duccWorkReservation,ReservationState.Completed);
                  logger.warn(methodName, duccId, messages.fetchLabel("refused")+rmResourceState.getReason());
                }
              }
              else {
View Full Code Here

        String error_message = messages.fetch("Request was not accepted: System is configured to refuse reservations.");
        logger.error(methodName, null, error_message);
        submitError(properties, error_message);
      }
      else if(Validate.request(duccEvent)) {
        DuccWorkReservation duccWorkReservation = reservationFactory.create(common,(ReservationRequestProperties)properties);
        long t0 = System.currentTimeMillis();
        workMap.addDuccWork(duccWorkReservation);
        long t1 = System.currentTimeMillis();
        long elapsed = t1 - t0;
        if(elapsed > Constants.SYNC_LIMIT) {
          logger.debug(methodName, null, "elapsed msecs: "+elapsed);
        }
        // state: Received
        duccWorkReservation.stateChange(ReservationState.Received);
        OrchestratorCheckpoint.getInstance().saveState();
        // state: WaitingForResources
        duccWorkReservation.stateChange(ReservationState.WaitingForResources);
        OrchestratorCheckpoint.getInstance().saveState();
        int counter = 0;
        while(duccWorkReservation.isPending()) {
          counter++;
          if(counter > 5) {
            counter = 0;
            logger.info(methodName, duccWorkReservation.getDuccId(), "waiting for allocation...");
          }
          Thread.sleep(1000);
        }
        // prepare for reply to submitter
        try {
          properties.put(ReservationReplyProperties.key_message, duccWorkReservation.getCompletionRationale().getText());
        }
        catch(Throwable t) {
        }
        properties.put(ReservationRequestProperties.key_id, duccWorkReservation.getId());
        // node list
        properties.put(ReservationRequestProperties.key_node_list, "");
        if(!duccWorkReservation.getReservationMap().isEmpty()) {
          StringBuffer sb = new StringBuffer();
          IDuccReservationMap map = duccWorkReservation.getReservationMap();
          for (DuccId key : map.keySet()) {
            IDuccReservation value = duccWorkReservation.getReservationMap().get(key);
            String node = value.getNodeIdentity().getName();
            sb.append(node);
            sb.append(" ");
          }
          properties.put(ReservationRequestProperties.key_node_list,sb.toString().trim());
View Full Code Here

      submitError(properties, error_message);
    }
    else {
      String id = properties.getProperty(ReservationRequestProperties.key_id);
      long t0 = System.currentTimeMillis();
      DuccWorkReservation duccWorkReservation = (DuccWorkReservation) workMap.findDuccWork(DuccType.Reservation,id);
      long t1 = System.currentTimeMillis();
      long elapsed = t1 - t0;
      if(elapsed > Constants.SYNC_LIMIT) {
        logger.debug(methodName, dwid, "elapsed msecs: "+elapsed);
      }
      if(duccWorkReservation != null) {
        if(Validate.request(duccEvent,duccWorkReservation)) {
          dwid = duccWorkReservation.getDuccId();
          String reqUser = properties.getProperty(JobRequestProperties.key_user).trim();
          String reqRole = getRole(properties);
          String tgtUser = duccWorkReservation.getStandardInfo().getUser().trim();
          if(isAuthorized(dwid, reqUser, tgtUser, reqRole)) {
            logger.debug(methodName, dwid, "reqUser:"+reqUser+" "+"reqRole:"+reqRole+" "+"tgtUser:"+tgtUser);
            duccWorkReservation.getStandardInfo().setCancelUser(reqUser);
            duccWorkReservation.getStandardInfo().setDateOfCompletion(TimeStamp.getCurrentMillis());
            duccWorkReservation.stateChange(ReservationState.Completed);
            duccWorkReservation.complete(ReservationCompletionType.CanceledByUser);
            String u1 = duccWorkReservation.getStandardInfo().getUser();
            String u2 = duccWorkReservation.getStandardInfo().getCancelUser();
            if(u1 != null) {
              if(u2 != null) {
                if(!u1.equals(u2)) {
                  duccWorkReservation.complete(ReservationCompletionType.CanceledByAdmin);
                }
              }
            }
            OrchestratorCheckpoint.getInstance().saveState();
            // prepare for reply to canceler
            properties.put(ReservationReplyProperties.key_message, ReservationReplyProperties.msg_canceled);
            duccEvent.setProperties(properties);
            logger.info(methodName, dwid, messages.fetchLabel("reservation state")+duccWorkReservation.getReservationState());
          }
          else {
            // prepare not authorized reply
            properties.put(ReservationReplyProperties.key_message, ReservationReplyProperties.msg_user_not_authorized);
            duccEvent.setProperties(properties);
View Full Code Here

    }
    return retVal;
  }
 
  public DuccWorkReservation getReservation() {
    DuccWorkReservation retVal = null;
    if(_dw instanceof DuccWorkReservation) {
      retVal = (DuccWorkReservation) _dw;
    }
    return retVal;
  }
View Full Code Here

  private IDuccIdFactory duccIdFactory = orchestratorCommonArea.getDuccIdFactory();
 
  public DuccWorkReservation create(CommonConfiguration common, ReservationRequestProperties reservationRequestProperties) {
    String methodName = "create";
    logger.trace(methodName, null, messages.fetch("enter"));
    DuccWorkReservation duccWorkReservation = new DuccWorkReservation();
    // id, type
    duccWorkReservation.setDuccId(duccIdFactory.next());
    duccWorkReservation.setDuccType(DuccType.Reservation);
    // standard info
    DuccStandardInfo standardInfo = new DuccStandardInfo();
    duccWorkReservation.setStandardInfo(standardInfo);
    standardInfo.setUser(reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_user));
    standardInfo.setSubmitter(reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_submitter_pid_at_host));
    standardInfo.setDateOfSubmission(TimeStamp.getCurrentMillis());
    standardInfo.setDateOfCompletion(null);
    standardInfo.setDescription(reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_description));
    // scheduling info
    DuccSchedulingInfo schedulingInfo = new DuccSchedulingInfo();
    duccWorkReservation.setSchedulingInfo(schedulingInfo);
    schedulingInfo.setSchedulingClass(reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_scheduling_class));
    String memorySize = reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_instance_memory_size);
    MemorySpecification memorySpecification = new MemorySpecification(memorySize);
    schedulingInfo.setShareMemorySize(memorySpecification.getSize());
    schedulingInfo.setShareMemoryUnits(memorySpecification.getMemoryUnits());
    schedulingInfo.setInstancesCount(reservationRequestProperties.getProperty(ReservationSpecificationProperties.key_number_of_instances));
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("user")+standardInfo.getUser());
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("description")+standardInfo.getDescription());
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("class")+schedulingInfo.getSchedulingClass());
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("priority")+schedulingInfo.getSchedulingPriority());
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("memory")+schedulingInfo.getShareMemorySize()+schedulingInfo.getShareMemoryUnits());
    logger.info(methodName, duccWorkReservation.getDuccId(), messages.fetchLabel("instances")+schedulingInfo.getInstancesCount());
    logger.trace(methodName, null, messages.fetch("exit"));
    return duccWorkReservation;
  }
View Full Code Here

    sb.append("</span>");
    sb.append("</td>");
    // Duration
    sb.append("<td align=\"right\">");
    if(duccwork instanceof DuccWorkReservation) {
      DuccWorkReservation reservation = (DuccWorkReservation) duccwork;
      String duration;
      String decoratedDuration;
      switch(reservation.getReservationState()) {
      case Completed:
        sb.append("<span>");
        duration = getDuration(request,reservation);
        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;
      }
    }
    sb.append("</td>");
    // User
    String title = "";
    String submitter = duccwork.getStandardInfo().getSubmitter();
    if(submitter != null) {
      title = "title=\"submitter PID@host: "+submitter+"\"";
    }
    sb.append("<td "+title+">");
    UserId userId = new UserId(duccwork.getStandardInfo().getUser());
    sb.append(userId.toString());
    sb.append("</td>");
    // Class
    sb.append("<td>");
    sb.append(stringNormalize(duccwork.getSchedulingInfo().getSchedulingClass(),messages.fetch("default")));
    sb.append("</td>");
    // Type
    sb.append("<td>");
    sb.append(reservationType);
    sb.append("</td>");
    // State
    sb.append("<td>");
    if(duccData.isLive(duccId)) {
      if(duccwork.isOperational()) {
        sb.append("<span class=\"active_state\">");
      }
      else {
        sb.append("<span class=\"completed_state\">");
      }
    }
    else {
      sb.append("<span class=\"historic_state\">");
    }
    sb.append(duccwork.getStateObject().toString());
    if(duccData.isLive(duccId)) {
      sb.append("</span>");
    }
    sb.append("</td>");
    // Reason
    if(duccwork instanceof DuccWorkReservation) {
      sb.append("<td>");
      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;
      }
      sb.append("</td>");
    }
    else if(duccwork instanceof DuccWorkJob) {
      DuccWorkJob job = (DuccWorkJob) duccwork;
      String reason = getReason(job, DuccType.Reservation).toString();
      sb.append("<td>");
      sb.append(reason);
      sb.append("</td>");
    }
    // Allocation
    sb.append("<td align=\"right\">");
    sb.append(duccwork.getSchedulingInfo().getInstancesCount());
    sb.append("</td>");
    // User Processes
    sb.append("<td align=\"right\">");
    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);
View Full Code Here

TOP

Related Classes of org.apache.uima.ducc.transport.event.common.DuccWorkReservation

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.