Package org.pentaho.platform.scheduler2.blockout

Examples of org.pentaho.platform.scheduler2.blockout.BlockoutManagerUtil


  @Test
  public void quartzAvailabilityTest() {

    Date startTime = new Date();
    Date endTime = new Date( startTime.getTime() + 1000 );
    org.quartz.Calendar calendar = new QuartzSchedulerAvailability( startTime, endTime );
    Assert.assertTrue( calendar.isTimeIncluded( startTime.getTime() ) );
    Assert.assertTrue( calendar.isTimeIncluded( endTime.getTime() ) );
    Assert.assertFalse( calendar.isTimeIncluded( startTime.getTime() - 1 ) );
    Assert.assertFalse( calendar.isTimeIncluded( endTime.getTime() + 1 ) );
    Assert.assertEquals( calendar.getNextIncludedTime( startTime.getTime() - 1 ), startTime.getTime() );
    Assert.assertEquals( calendar.getNextIncludedTime( startTime.getTime() ), startTime.getTime() + 1 );
    Assert.assertEquals( calendar.getNextIncludedTime( endTime.getTime() - 1 ), endTime.getTime() );
    Assert.assertEquals( calendar.getNextIncludedTime( endTime.getTime() ), 0 );
    Assert.assertEquals( calendar.getNextIncludedTime( endTime.getTime() + 1 ), 0 );

    calendar = new QuartzSchedulerAvailability( null, endTime );
    Assert.assertTrue( calendar.isTimeIncluded( startTime.getTime() ) );
    Assert.assertTrue( calendar.isTimeIncluded( endTime.getTime() ) );
    Assert.assertFalse( calendar.isTimeIncluded( endTime.getTime() + 1 ) );
    Assert.assertEquals( calendar.getNextIncludedTime( startTime.getTime() ), startTime.getTime() + 1 );
    Assert.assertEquals( calendar.getNextIncludedTime( endTime.getTime() ), 0 );
    Assert.assertEquals( calendar.getNextIncludedTime( endTime.getTime() + 1 ), 0 );

    calendar = new QuartzSchedulerAvailability( startTime, null );
    Assert.assertTrue( calendar.isTimeIncluded( startTime.getTime() ) );
    Assert.assertFalse( calendar.isTimeIncluded( startTime.getTime() - 1 ) );
    Assert.assertTrue( calendar.isTimeIncluded( endTime.getTime() ) );
    Assert.assertEquals( calendar.getNextIncludedTime( startTime.getTime() - 1 ), startTime.getTime() );
    Assert.assertEquals( calendar.getNextIncludedTime( startTime.getTime() ), startTime.getTime() + 1 );
  }
View Full Code Here


              String[] days = token.split( "-" ); //$NON-NLS-1$
              dayOfWeekRecurrence.add( new SequentialRecurrence( Integer.parseInt( days[0] ), Integer
                  .parseInt( days[1] ) ) );
            } else if ( intervalPattern.matcher( token ).matches() ) {
              String[] days = token.split( "/" ); //$NON-NLS-1$
              dayOfWeekRecurrence.add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer
                  .parseInt( days[1] ) ) );
            } else if ( qualifiedDayPattern.matcher( token ).matches() ) {
              String[] days = token.split( "#" ); //$NON-NLS-1$
              dayOfWeekRecurrence
                  .add( new QualifiedDayOfWeek( Integer.parseInt( days[1] ), Integer.parseInt( days[0] ) ) );
View Full Code Here

              timeRecurrence.add( new SequentialRecurrence( Integer.parseInt( days[0] ),
                      Integer.parseInt( days[1] ) ) );
            } else if ( intervalPattern.matcher( token ).matches() ) {
              String[] days = token.split( "/" ); //$NON-NLS-1$
              timeRecurrence
                  .add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer.parseInt( days[1] ) ) );
            } else if ( "L".equalsIgnoreCase( token ) ) {
              timeRecurrence.add( new QualifiedDayOfMonth() );
            } else {
              throw new IllegalArgumentException( Messages.getInstance().getErrorString(
                  "ComplexJobTrigger.ERROR_0001_InvalidCronExpression" ) ); //$NON-NLS-1$
View Full Code Here

        DayOfWeek.SUN );

    trigger = new ComplexJobTrigger();
    trigger.addYearlyRecurrence( 2010, 2013 );
    trigger.addYearlyRecurrence( new SequentialRecurrence( 2015, 2020 ) );
    trigger.addYearlyRecurrence( new IncrementalRecurrence( 2025, 5 ) );
    trigger.addMonthlyRecurrence( ComplexJobTrigger.MARCH, ComplexJobTrigger.MAY );
    trigger.addMonthlyRecurrence( new SequentialRecurrence( ComplexJobTrigger.JULY, ComplexJobTrigger.SEPTEMBER ) );
    trigger.addMonthlyRecurrence( new IncrementalRecurrence( ComplexJobTrigger.JANUARY, 3 ) );
    trigger.addDayOfMonthRecurrence( 3, 10 );
    trigger.addDayOfMonthRecurrence( new SequentialRecurrence( 15, 20 ) );
    trigger.addDayOfMonthRecurrence( new IncrementalRecurrence( 21, 3 ) );
    trigger.addHourlyRecurrence( 12, 15 );
    trigger.addHourlyRecurrence( new SequentialRecurrence( 25, 30 ) );
    trigger.addHourlyRecurrence( new IncrementalRecurrence( 10, 5 ) );
    trigger.addMinuteRecurrence( 30, 45 );
    System.out.println( trigger.toString() );
    Assert.assertEquals( trigger.toString(),
        "0 0,30,45 0,12,15,25-30,10/5 3,10,15-20,21/3 3,5,7-9,1/3 ? 2010,2013,2015-2020,2025/5" );

    trigger = new ComplexJobTrigger();
    trigger.setYearlyRecurrence( 2010, 2013 );
    trigger.addYearlyRecurrence( new SequentialRecurrence( 2015, 2020 ) );
    trigger.addYearlyRecurrence( new IncrementalRecurrence( 2025, 5 ) );
    trigger.setMonthlyRecurrence( ComplexJobTrigger.MARCH, ComplexJobTrigger.MAY );
    trigger.addMonthlyRecurrence( new SequentialRecurrence( ComplexJobTrigger.JULY, ComplexJobTrigger.SEPTEMBER ) );
    trigger.addMonthlyRecurrence( new IncrementalRecurrence( ComplexJobTrigger.JANUARY, 3 ) );
    trigger.setDayOfWeekRecurrence( ComplexJobTrigger.THURSDAY, ComplexJobTrigger.FRIDAY );
    trigger.addDayOfWeekRecurrence( new SequentialRecurrence( ComplexJobTrigger.SUNDAY, ComplexJobTrigger.MONDAY ) );
    trigger.setHourlyRecurrence( 12, 15 );
    trigger.addHourlyRecurrence( new SequentialRecurrence( 25, 30 ) );
    trigger.addHourlyRecurrence( new IncrementalRecurrence( 10, 5 ) );
    trigger.setMinuteRecurrence( 30, 45 );
    System.out.println( trigger.toString() );
    Assert.assertEquals( trigger.toString(),
        "0 30,45 12,15,25-30,10/5 ? 3,5,7-9,1/3 5,6,1-2 2010,2013,2015-2020,2025/5" );
View Full Code Here

    int startingMinute = calendar.get( Calendar.MINUTE );

    RecurrenceList recurrenceList = new RecurrenceList( 40, 45 );
    SequentialRecurrence sequentialRecurrence = new SequentialRecurrence( 40, 45 );
    IncrementalRecurrence incrementalRecurrence = new IncrementalRecurrence( 40, 5 );

    if ( calendar.get( Calendar.SECOND ) > 30 ) {
      recurrenceList = new RecurrenceList( 10, 15 );
      sequentialRecurrence = new SequentialRecurrence( 10, 15 );
      incrementalRecurrence = new IncrementalRecurrence( 10, 5 );
      startingMinute++;
    }
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    jobTrigger.setMinuteRecurrence( startingMinute );
View Full Code Here

    startJobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    endJobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    startEndJobTrigger.setMinuteRecurrence( (ITimeRecurrence) null );
    startJobTrigger.setMinuteRecurrence( (ITimeRecurrence) null );
    endJobTrigger.setMinuteRecurrence( (ITimeRecurrence) null );
    startEndJobTrigger.setSecondRecurrence( new IncrementalRecurrence( 0, 5 ) );
    startJobTrigger.setSecondRecurrence( new IncrementalRecurrence( 0, 5 ) );
    endJobTrigger.setSecondRecurrence( new IncrementalRecurrence( 0, 5 ) );

    Calendar calendar = Calendar.getInstance();
    int startingMin = calendar.get( Calendar.MINUTE );
    int startingSec = calendar.get( Calendar.SECOND ) + 20;
    if ( startingSec > 59 ) {
View Full Code Here

  @Test
  public void testCreateComplexJob() throws SchedulerException {
    int startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) ) % 60;
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 1 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    schedulerSvc.createComplexJob( "test job", jobParams, jobTrigger );
View Full Code Here

  long end = System.currentTimeMillis() + 1000 + 5*60*60*100;
    int startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) + 10 ) % 60;
    ComplexJobTrigger jobTrigger = new ComplexJobTrigger();
    jobTrigger.setStartTime( new Date(start) );
    jobTrigger.setEndTime( new Date(end) );
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 1 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    String jobId = schedulerSvc.createComplexJob( "test job", jobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );

    jobTrigger = new ComplexJobTrigger();

  start  = System.currentTimeMillis() + 2*1000;
  end = System.currentTimeMillis() + 1000 + 7*60*60*100;

    jobTrigger.setStartTime( new Date(start) );
    jobTrigger.setEndTime( new Date(end) );

    startingMinute = ( Calendar.getInstance().get( Calendar.MINUTE ) + 20 ) % 60;
    jobTrigger.setMinuteRecurrence( new IncrementalRecurrence( startingMinute, 5 ) );
    jobTrigger.setHourlyRecurrence( (ITimeRecurrence) null );
    System.out.println( jobTrigger.toString() );

    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>( jobParams );
    newJobParams.put( "newKey", new StringParamValue( "" ) );
View Full Code Here

  private void assertRecurrencesCorrect( String dimension, int expectedCount, ITimeWrapper recurrences ) {
    int count = 0;
    for ( ITimeRecurrence rec : recurrences.getRecurrences() ) {
      if ( rec instanceof IncrementalRecurrence ) {
        count++;
        IncrementalRecurrence i = (IncrementalRecurrence) rec;
        Assert.assertEquals( "Wrong starting value for dimension " + dimension, inc.getStartingValue(), i
            .getStartingValue() );
        Assert.assertEquals( "Wrong increment for dimension " + dimension, inc.getIncrement(), i.getIncrement() );
      }
      if ( rec instanceof SequentialRecurrence ) {
        count++;
        SequentialRecurrence s = (SequentialRecurrence) rec;
        Assert.assertEquals( "Wrong first value for dimension " + dimension, seq.getFirstValue(), s.getFirstValue() );
View Full Code Here

            } else if ( intervalPattern.matcher( token ).matches() ) {
              String[] days = token.split( "/" ); //$NON-NLS-1$
              timeRecurrence
                  .add( new IncrementalRecurrence( Integer.parseInt( days[0] ), Integer.parseInt( days[1] ) ) );
            } else if ( "L".equalsIgnoreCase( token ) ) {
              timeRecurrence.add( new QualifiedDayOfMonth() );
            } else {
              throw new IllegalArgumentException( Messages.getInstance().getErrorString(
                  "ComplexJobTrigger.ERROR_0001_InvalidCronExpression" ) ); //$NON-NLS-1$
            }
          }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.scheduler2.blockout.BlockoutManagerUtil

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.