コード例 #1
0
  @Override
  protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

    logger.debug("Inicio del job para la comprobación del time-out en los envíos");

    try {

      ServicioEntidades servicio = LocalizadorServicios.getServicioEntidades();

      // Procesar los ficheros
      List<Entidad> listaEntidades = servicio.obtenerEntidades();

      logger.debug("Numero Entidades recuperadas:" + listaEntidades.size());

      for (Iterator iterator = listaEntidades.iterator(); iterator.hasNext(); ) {
        Entidad entidad = (Entidad) iterator.next();

        try {
          entidad.getCodigoINE();
          logger.debug("entdidad:" + entidad.getIdentificador());
          MultiEntityContextHolder.setEntity(entidad.getIdentificador());
          getServicioIntercambioRegistral().comprobarTimeOutEnvios();
          context.setResult("Ok");

        } catch (Throwable e) {
          logger.error(
              "Error al lanzar la comprobación del time-out en los envíos para la entidad:"
                  + entidad.getIdentificador(),
              e);
          context.setResult(
              "Error al lanzar la comprobación del time-out en los envíos para la entidad:"
                  + entidad.getIdentificador()
                  + e.toString());
          throw new JobExecutionException(
              "Error al lanzar la comprobación del time-out en los envíospara la entidad:"
                  + entidad.getIdentificador(),
              e);
        } finally {
          logger.info(
              "Fin del job para la comprobación del time-out en los envíos para la entidad:"
                  + entidad.getIdentificador());
        }
      }

    } catch (Throwable e) {
      logger.error("Error al lanzar la comprobación del time-out en los envíos", e);
      context.setResult(
          "Error al lanzar la comprobación del time-out en los envíos: " + e.toString());
      throw new JobExecutionException(
          "Error al lanzar la comprobación del time-out en los envíos", e);
    } finally {
      logger.info("Fin del job para la comprobación del time-out en los envíos");
    }
  }
コード例 #2
0
 @Override
 public void execute(JobExecutionContext context) throws JobExecutionException {
   if (checklistNotificationsUri == null) {
     return;
   }
   boolean started =
       !HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().isActive();
   if (started) {
     HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin();
   }
   try {
     URI researchObjectUri = (URI) context.getMergedJobDataMap().get(RESEARCH_OBJECT_URI);
     SyndFeedInput input = new SyndFeedInput();
     URI requestedUri = createQueryUri(getTheLastFeedDate(researchObjectUri), researchObjectUri);
     try {
       context.setResult(input.build(new XmlReader(requestedUri.toURL())));
     } catch (IllegalArgumentException | FeedException | IOException e) {
       LOGGER.error("Can't get the feed " + requestedUri.toString());
     }
   } finally {
     if (started) {
       HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
     }
   }
 }
コード例 #3
0
  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    String productId = context.getMergedJobDataMap().getString(JobStatus.TARGET_ID);
    Boolean lazy = context.getMergedJobDataMap().getBoolean(LAZY_REGEN);

    List<String> l = new ArrayList<String>();
    l.add(productId);

    Set<Owner> owners = subAdapter.lookupOwnersByProduct(l);

    for (Owner owner : owners) {
      poolManager.refreshPools(owner, lazy);
    }
    context.setResult("Pools refreshed for product " + productId);
  }
コード例 #4
0
  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    BundleManagerLocal bundleManager = LookupUtil.getBundleManager();
    SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();

    Subject overlord = subjectManager.getOverlord();

    PageList<BundleDeployment> deployments =
        bundleManager.findBundleDeploymentsByCriteria(overlord, getCriteriaFromContext(context));

    if (deployments.size() > 0) {
      BundleDeployment bundleDeployment = deployments.get(0);
      SchedulerLocal scheduler = LookupUtil.getSchedulerBean();
      JobDetail jobDetail = context.getJobDetail();

      BundleDeploymentStatus bundleDeploymentStatus =
          bundleManager.determineBundleDeploymentStatus(bundleDeployment.getId());
      if (bundleDeploymentStatus.isTerminal()) {
        // delete this job, we've assigned a final status
        try {
          context.setResult(bundleDeploymentStatus); // Return status to possible listeners
          scheduler.deleteJob(jobDetail.getName(), jobDetail.getGroup());
        } catch (SchedulerException e) {
          throw new JobExecutionException(
              "Could not delete the bundle deployment completion check job for "
                  + bundleDeployment
                  + ".",
              e);
        }
      } else {
        // try again in 10s
        try {
          Trigger trigger = QuartzUtil.getFireOnceOffsetTrigger(jobDetail, 10000L);
          // just need a trigger name unique for this job
          trigger.setName(String.valueOf(System.currentTimeMillis()));
          scheduler.scheduleJob(trigger);
        } catch (SchedulerException e) {
          throw new JobExecutionException(
              "Could not schedule the bundle deployment completion check job for "
                  + bundleDeployment
                  + ".",
              e);
        }
      }
    }
  }
コード例 #5
0
ファイル: ExportJob.java プロジェクト: candlepin/candlepin
  @Override
  public void toExecute(JobExecutionContext context) throws JobExecutionException {
    JobDataMap map = context.getMergedJobDataMap();
    String consumerUuid = map.getString(JobStatus.TARGET_ID);
    String cdnLabel = map.getString(CDN_LABEL);
    String webAppPrefix = map.getString(WEBAPP_PREFIX);
    String apiUrl = map.getString(API_URL);
    Map<String, String> extensionData = (Map<String, String>) map.get(EXTENSION_DATA);

    log.info("Starting async export for {}", consumerUuid);
    try {
      ExportResult result =
          manifestManager.generateAndStoreManifest(
              consumerUuid, cdnLabel, webAppPrefix, apiUrl, extensionData);
      context.setResult(result);
      log.info("Async export complete.");
    } catch (Exception e) {
      throw new JobExecutionException(e.getMessage(), e, false);
    }
  }
コード例 #6
0
ファイル: SimpleJob.java プロジェクト: DarkIdiot/QuartzDemo
  @Override
  public void execute(JobExecutionContext context) throws JobExecutionException {
    jobkey = context.getJobDetail().getKey();

    log.info(
        "Excuting job: "
            + jobkey
            + " executing at "
            + new Date()
            + " fire by: "
            + context.getTrigger().getKey());

    if (context.getMergedJobDataMap().size() > 0) {
      Set<String> keys = context.getMergedJobDataMap().keySet();
      for (String key : keys) {
        String value = context.getMergedJobDataMap().getString(key);
        log.info(" jobdatamap entry: " + key + " = " + value);
      }
      context.setResult("hello");
    }
  }
コード例 #7
0
    /** Invoke the method via the MethodInvoker. */
    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
      MethodInvoker methodInvoker = new MethodInvoker();

      try {
        methodInvoker.setTargetObject(getBean(context, beanName));
        methodInvoker.setTargetMethod(executionMethod);

        methodInvoker.prepare();

        context.setResult(methodInvoker.invoke());
      } catch (InvocationTargetException ex) {
        if (ex.getTargetException() instanceof JobExecutionException) {
          throw (JobExecutionException) ex.getTargetException();
        } else {
          throw new JobMethodInvocationFailedException(methodInvoker, ex.getTargetException());
        }
      } catch (JobExecutionException ex) {
        throw ex;
      } catch (Exception ex) {
        throw new JobExecutionException(ex);
      }
    }