Package org.pentaho.platform.api.scheduler2

Examples of org.pentaho.platform.api.scheduler2.IScheduler


   */
  public static QuartzJobKey parse( String jobId ) throws SchedulerException {
    String delimiter = jobId.contains( "\t" ) || jobId.isEmpty() ? "\t" : ":";
    String[] elements = jobId.split( delimiter ); //$NON-NLS-1$
    if ( elements == null || elements.length < 3 ) {
      throw new SchedulerException( MessageFormat.format( Messages.getInstance().getErrorString(
          "QuartzJobKey.ERROR_0002" ), jobId ) ); //$NON-NLS-1$
    }
    QuartzJobKey key = new QuartzJobKey();
    key.userName = elements[0];
    key.jobName = elements[1];
    try {
      key.timeInMillis = Long.parseLong( elements[2] );
    } catch ( NumberFormatException ex ) {
      throw new SchedulerException( MessageFormat.format( Messages.getInstance().getErrorString(
          "QuartzJobKey.ERROR_0002" ), jobId ) ); //$NON-NLS-1$
    }
    return key;
  }
View Full Code Here


  /** {@inheritDoc} */
  public Job createJob( String jobName, Class<? extends IAction> action, Map<String, Serializable> jobParams,
      IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider ) throws SchedulerException {

    if ( action == null ) {
      throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0003_ACTION_IS_NULL" ) ); //$NON-NLS-1$
    }

    if ( jobParams == null ) {
      jobParams = new HashMap<String, Serializable>();
    }
View Full Code Here

  /** {@inheritDoc} */
  public Job createJob( String jobName, String actionId, Map<String, Serializable> jobParams, IJobTrigger trigger,
      IBackgroundExecutionStreamProvider outputStreamProvider ) throws SchedulerException {
    if ( StringUtils.isEmpty( actionId ) ) {
      throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0003_ACTION_IS_NULL" ) ); //$NON-NLS-1$
    }

    if ( jobParams == null ) {
      jobParams = new HashMap<String, Serializable>();
    }
View Full Code Here

      try {
        quartzTrigger =
            new CronTrigger( jobId.toString(), jobId.getUserName(), jobTrigger.getCronString() != null ? jobTrigger
                .getCronString() : QuartzCronStringFactory.createCronString( (ComplexJobTrigger) jobTrigger ) );
      } catch ( ParseException e ) {
        throw new SchedulerException( Messages.getInstance().getString(
            "QuartzScheduler.ERROR_0001_FAILED_TO_SCHEDULE_JOB", jobId.getJobName() ), e ); //$NON-NLS-1$
      }
    } else if ( jobTrigger instanceof SimpleJobTrigger ) {
      SimpleJobTrigger simpleTrigger = (SimpleJobTrigger) jobTrigger;
      long interval = simpleTrigger.getRepeatInterval();
      if ( interval > 0 ) {
        interval *= 1000;
      }
      int repeatCount =
          simpleTrigger.getRepeatCount() < 0 ? SimpleTrigger.REPEAT_INDEFINITELY : simpleTrigger.getRepeatCount();
      quartzTrigger =
          new SimpleTrigger( jobId.toString(), jobId.getUserName(), simpleTrigger.getStartTime(), simpleTrigger
              .getEndTime(), repeatCount, interval );
    } else {
      throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0002_TRIGGER_WRONG_TYPE" ) ); //$NON-NLS-1$
    }
    if ( quartzTrigger instanceof SimpleTrigger ) {
      quartzTrigger.setMisfireInstruction( SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT );
    } else {
      quartzTrigger.setMisfireInstruction( SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW );
View Full Code Here

        scheduleRequest.getSimpleJobTrigger() == null && scheduleRequest.getComplexJobTrigger() == null
            && scheduleRequest.getCronJobTrigger() == null;

    // add 10 seconds to the RIB to ensure execution (see PPP-3264)
    IJobTrigger jobTrigger =
        runInBackground ? new SimpleJobTrigger( new Date( System.currentTimeMillis() + 10000 ), null, 0, 0 ) : scheduleRequest.getSimpleJobTrigger();

    if ( scheduleRequest.getSimpleJobTrigger() != null ) {
      SimpleJobTrigger simpleJobTrigger = scheduleRequest.getSimpleJobTrigger();

      if ( simpleJobTrigger.getStartTime() == null ) {
        simpleJobTrigger.setStartTime( new Date() );
      }

      jobTrigger = simpleJobTrigger;

    } else if ( scheduleRequest.getComplexJobTrigger() != null ) {
View Full Code Here

  }

  private void scheduleJob( int intervalInSeconds ) throws Exception {

    IScheduler scheduler = PentahoSystem.get( IScheduler.class, "IScheduler2", null ); //$NON-NLS-1$
    JobTrigger trigger = new SimpleJobTrigger( new Date(), null, -1, intervalInSeconds );

    jobMap.put( "transFileName", getTransFileName() );
    scheduler.createJob( GatherStatsListener.JOB_NAME, GatherStatsAction.class, jobMap, trigger );
    logger.info( "Statistics gathering jop has been scheduled." );
  }
View Full Code Here

      } catch ( ParseException e ) {
        throw new SchedulerException( Messages.getInstance().getString(
            "QuartzScheduler.ERROR_0001_FAILED_TO_SCHEDULE_JOB", jobId.getJobName() ), e ); //$NON-NLS-1$
      }
    } else if ( jobTrigger instanceof SimpleJobTrigger ) {
      SimpleJobTrigger simpleTrigger = (SimpleJobTrigger) jobTrigger;
      long interval = simpleTrigger.getRepeatInterval();
      if ( interval > 0 ) {
        interval *= 1000;
      }
      int repeatCount =
          simpleTrigger.getRepeatCount() < 0 ? SimpleTrigger.REPEAT_INDEFINITELY : simpleTrigger.getRepeatCount();
      quartzTrigger =
          new SimpleTrigger( jobId.toString(), jobId.getUserName(), simpleTrigger.getStartTime(), simpleTrigger
              .getEndTime(), repeatCount, interval );
    } else {
      throw new SchedulerException( Messages.getInstance().getString( "QuartzScheduler.ERROR_0002_TRIGGER_WRONG_TYPE" ) ); //$NON-NLS-1$
    }
    if ( quartzTrigger instanceof SimpleTrigger ) {
View Full Code Here

    QuartzJobKey jobKey = QuartzJobKey.parse( job.getJobId() );
    String groupName = jobKey.getUserName();

    if ( trigger instanceof SimpleTrigger ) {
      SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
      SimpleJobTrigger simpleJobTrigger = new SimpleJobTrigger();
      simpleJobTrigger.setStartTime( simpleTrigger.getStartTime() );
      simpleJobTrigger.setEndTime( simpleTrigger.getEndTime() );
      simpleJobTrigger.setUiPassParam( (String) job.getJobParams().get( RESERVEDMAPKEY_UIPASSPARAM ) );
      long interval = simpleTrigger.getRepeatInterval();
      if ( interval > 0 ) {
        interval /= 1000;
      }
      simpleJobTrigger.setRepeatInterval( interval );
      simpleJobTrigger.setRepeatCount( simpleTrigger.getRepeatCount() );
      job.setJobTrigger( simpleJobTrigger );
    } else if ( trigger instanceof CronTrigger ) {
      CronTrigger cronTrigger = (CronTrigger) trigger;
      ComplexJobTrigger complexJobTrigger = createComplexTrigger( cronTrigger.getCronExpression() );
      complexJobTrigger.setUiPassParam( (String) job.getJobParams().get( RESERVEDMAPKEY_UIPASSPARAM ) );
View Full Code Here

    deleteJobIfNecessary();

    Map<String, Serializable> parms = new HashMap<String, Serializable>();
    parms.put( VersionCheckerAction.VERSION_REQUEST_FLAGS, new Integer( versionRequestFlags ) );
    JobTrigger trigger = new SimpleJobTrigger( new Date(), null, -1, repeatSeconds );
    scheduler.createJob( EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME, VersionCheckerAction.class, parms,
        trigger );
  }
View Full Code Here

      try {
        requiresUpdate = SecurityHelper.getInstance().runAsUser( actionUser, actionBeanRunner );
      } catch ( Throwable t ) {
        Object restartFlag = jobParams.get( QuartzScheduler.RESERVEDMAPKEY_RESTART_FLAG );
        if ( restartFlag == null ) {
          final SimpleJobTrigger trigger = new SimpleJobTrigger( new Date(), null, 0, 0 );
          final Class<IAction> iaction = (Class<IAction>) actionBean.getClass();
          // recreate the job in the context of the original creator
          SecurityHelper.getInstance().runAsUser( actionUser, new Callable<Void>() {
            @Override
            public Void call() throws Exception {
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.scheduler2.IScheduler

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.