Пример #1
0
  @Override
  public void processPool() throws InternalErrorException {

    try {
      perunSession =
          perun.getPerunSession(
              new PerunPrincipal(
                  propertiesBean.getProperty("perun.principal.name"),
                  propertiesBean.getProperty("perun.principal.extSourceName"),
                  propertiesBean.getProperty("perun.principal.extSourceType")));
    } catch (InternalErrorException e1) {
      log.error("Error establishing perun session to check tasks propagation status: ", e1);
      return;
    }

    /*
     * for (Pair<ExecService, Facility> pair : schedulingPool.emptyPool()) {
     * log.debug("Propagating ExecService:Facility : " +
     * pair.getLeft().getId() + ":" + pair.getRight().getId());
     * propagateService(pair.getLeft(), new
     * Date(System.currentTimeMillis()), pair.getRight()); }
     */
    for (Task task : schedulingPool.getNewTasks()) {
      log.debug(
          "Propagating ExecService:Facility : "
              + task.getExecServiceId()
              + ":"
              + task.getFacilityId());
      propagateService(task, new Date(System.currentTimeMillis()));
    }
  }
Пример #2
0
  @Override
  public void propagateService(Task task, Date time) throws InternalErrorException {
    log.debug("   Is the execService ID:" + task.getExecServiceId() + " enabled globally?");
    if (!task.getExecService().isEnabled()) {
      schedulingPool.setTaskStatus(task, TaskStatus.DONE);
      log.info("Exec service for task {} is globally disabled, setting as done.", task.getId());
      return;
    } else {
      log.debug("   Yes, it is globally enabled.");
    }

    // Is the ExecService denied on this Facility?
    // If it is, we drop it and do nothing.
    log.debug(
        "   Is the execService ID:"
            + task.getExecServiceId()
            + " denied on facility ID:"
            + task.getFacilityId()
            + "?");
    if (denialsResolver.isExecServiceDeniedOnFacility(task.getExecService(), task.getFacility())) {
      schedulingPool.setTaskStatus(task, TaskStatus.DONE);
      log.info(
          "Exec service "
              + task.getExecServiceId()
              + " for task "
              + task.getId()
              + " is denied for facility "
              + task.getFacilityId()
              + ", setting as done.");
      return;
    } else {
      log.debug("   No, it is not.");
    }

    // check if we have destinations for this task
    List<Destination> destinations = task.getDestinations();
    if (destinations == null || destinations.isEmpty()) {
      // refetch the destination list from central database
      log.debug(
          "No destinations for task " + task.toString() + ", trying to query the database...");
      try {
        destinations =
            perun
                .getServicesManager()
                .getDestinations(
                    perunSession, task.getExecService().getService(), task.getFacility());
      } catch (ServiceNotExistsException e) {
        log.error("No destinations found for task " + task.toString());
        // TODO: remove the task?
        return;
      } catch (FacilityNotExistsException e) {
        log.error("Facility for task does not exist..." + task.toString());
        // TODO: remove the task?
        return;
      } catch (PrivilegeException e) {
        log.error("Privilege error accessing the database: " + e.getMessage());
        return;
      } catch (InternalErrorException e) {
        log.error("Internal error: " + e.getMessage());
        return;
      }
      task.setDestinations(destinations);
    }
    if (task.getExecService().getExecServiceType().equals(ExecServiceType.SEND)
        && (destinations == null || destinations.isEmpty())) {
      log.info("No destinations found for SEND task {}, marking as DONE", task.getId());
      schedulingPool.setTaskStatus(task, TaskStatus.DONE);
    } else {
      schedulingPool.setTaskStatus(task, TaskStatus.PLANNED);
      taskStatusManager.clearTaskStatus(task);
      task.setSchedule(time);
    }
  }