Package org.elasticsearch.common.util.concurrent

Examples of org.elasticsearch.common.util.concurrent.PrioritizedExecutorsTests$Job


    testGetJobsSchduler.createJob( "getJobsTestJob", TestAction.class, jobParams, jobTrigger );

    List<Job> jobs = testGetJobsSchduler.getJobs( null );
    Assert.assertEquals( 1, jobs.size() );

    Job theJob = jobs.get( 0 );
    Assert.assertTrue( theJob.getJobParams().containsKey( PARAM_KEY ) );
    Assert.assertTrue( theJob.getJobName().contains( "getJobsTestJob" ) );
  }
View Full Code Here


  @Test
  public void testGetBlockout() throws Exception {
    IJobTrigger blockOutJobTrigger1 = new SimpleJobTrigger( new Date(), null, -1, 1000000 );
    IJobTrigger blockOutJobTrigger2 = new SimpleJobTrigger( new Date(), null, -1, 1000000 );

    Job blockOutJob1 = addBlockOutJob( blockOutJobTrigger1 );
    Job blockOutJob2 = addBlockOutJob( blockOutJobTrigger2 );

    assertEquals( blockOutManager.getBlockOut( blockOutJob1.getJobId() ).toString(), blockOutJobTrigger1.toString() );
    assertEquals( blockOutManager.getBlockOut( blockOutJob2.getJobId() ).toString(), blockOutJobTrigger2.toString() );
    assertNotSame( blockOutJobTrigger1, blockOutManager.getBlockOut( blockOutJob2.getJobId() ) );
  }
View Full Code Here

        new SimpleJobTrigger( scheduleStartDate.getTime(), null, -1, TIME.DAY.time / 1000 );

    IJobTrigger falseScheduleTrigger =
        new SimpleJobTrigger( scheduleStartDate.getTime(), null, -1, TIME.WEEK.time / 1000 );

    Job blockOutJob = addBlockOutJob( blockOutJobTrigger );
    assertTrue( this.blockOutManager.willFire( trueScheduleTrigger ) );
    assertFalse( this.blockOutManager.willFire( falseScheduleTrigger ) );

    /*
     * Complex Schedule Triggers
     */
    IJobTrigger trueComplexScheduleTrigger = new ComplexJobTrigger();
    trueComplexScheduleTrigger.setStartTime( scheduleStartDate.getTime() );
    trueComplexScheduleTrigger.setCronString( "0 0 1 ? * 2-3 *" ); //$NON-NLS-1$

    IJobTrigger falseComplexScheduleTrigger = new ComplexJobTrigger();
    falseComplexScheduleTrigger.setStartTime( scheduleStartDate.getTime() );
    falseComplexScheduleTrigger.setCronString( "0 0 1 ? * 2 *" ); //$NON-NLS-1$

    assertTrue( this.blockOutManager.willFire( trueComplexScheduleTrigger ) );
    assertFalse( this.blockOutManager.willFire( falseComplexScheduleTrigger ) );

    /*
     * Complex Block out
     */
    deleteJob( blockOutJob.getJobId() );
    blockOutJobTrigger = new ComplexJobTrigger();
    blockOutJobTrigger.setStartTime( blockOutStartDate.getTime() );
    blockOutJobTrigger.setDuration( duration );
    blockOutJobTrigger.setCronString( "0 0 0 ? * 2 *" ); //$NON-NLS-1$

View Full Code Here

    Calendar falseScheduleStartDate1 = new GregorianCalendar( 2013, Calendar.JANUARY, 1, 3, 0, 0 );
    IJobTrigger falseSchedule1 =
        new SimpleJobTrigger( falseScheduleStartDate1.getTime(), null, -1, TIME.WEEK.time / 1000 );

    Job blockOutJob = addBlockOutJob( blockOutTrigger );

    assertTrue( this.blockOutManager.isPartiallyBlocked( trueSchedule1 ) );
    assertTrue( this.blockOutManager.isPartiallyBlocked( trueSchedule2 ) );
    assertFalse( this.blockOutManager.isPartiallyBlocked( falseSchedule1 ) );

    /*
     * Complex Schedule Triggers
     */
    IJobTrigger trueComplexScheduleTrigger = new ComplexJobTrigger();
    trueComplexScheduleTrigger.setStartTime( trueScheduleStartDate1.getTime() );
    trueComplexScheduleTrigger.setCronString( "0 0 1 ? * 2-3 *" ); //$NON-NLS-1$

    IJobTrigger falseComplexScheduleTrigger = new ComplexJobTrigger();
    falseComplexScheduleTrigger.setStartTime( trueScheduleStartDate1.getTime() );
    falseComplexScheduleTrigger.setCronString( "0 0 1 ? * 2 *" ); //$NON-NLS-1$

    assertTrue( this.blockOutManager.isPartiallyBlocked( trueComplexScheduleTrigger ) );
    assertFalse( this.blockOutManager.isPartiallyBlocked( falseComplexScheduleTrigger ) );

    /*
     * Complex Block Out IJobTrigger
     */
    deleteJob( blockOutJob.getJobId() );
    blockOutTrigger = new ComplexJobTrigger();
    blockOutTrigger.setStartTime( blockOutStartDate.getTime() );
    blockOutTrigger.setCronString( "0 0 0 ? * 3 *" ); //$NON-NLS-1$
    blockOutTrigger.setDuration( duration );
    addBlockOutJob( blockOutTrigger );
View Full Code Here

  public void testShouldFireNow() throws Exception {
    Date blockOutStartDate = new Date( System.currentTimeMillis() );
    IJobTrigger blockOutJobTrigger = new SimpleJobTrigger( blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000 );
    blockOutJobTrigger.setDuration( duration );

    Job blockOutJob = addBlockOutJob( blockOutJobTrigger );

    assertFalse( this.blockOutManager.shouldFireNow() );

    deleteJob( blockOutJob.getJobId() );
    blockOutStartDate = new Date( System.currentTimeMillis() + TIME.HOUR.time );
    blockOutJobTrigger = new SimpleJobTrigger( blockOutStartDate, null, -1, TIME.WEEK.time * 2 / 1000 );
    blockOutJobTrigger.setDuration( duration );
    addBlockOutJob( blockOutJobTrigger );

View Full Code Here

    }, new HashMap<String, Serializable>() );
  }

  private Job addJob( IJobTrigger jobTrigger, String jobName, IAction action, Map<String, Serializable> jobParams )
    throws Exception {
    Job job = this.scheduler.createJob( jobName, action.getClass(), jobParams, jobTrigger );
    this.jobIdsToClear.add( job.getJobId() );
    return job;
  }
View Full Code Here

        return job.getJobName().contains( "PentahoSystemVersionCheck" );
      }
    };
    List<Job> matchingJobs = scheduler.getJobs( filter );
    Assert.assertEquals( 1, matchingJobs.size() );
    Job aJob = matchingJobs.get( 0 );
    Assert.assertTrue( aJob.getJobName().startsWith( "PentahoSystemVersionCheck" ) );

    Assert.assertEquals( TEST_USER, aJob.getUserName() );

    Map<String, Serializable> vcJobParms = aJob.getJobParams();
    Assert.assertTrue( vcJobParms.size() > 0 );
    Assert.assertTrue( vcJobParms.containsKey( VersionCheckerAction.VERSION_REQUEST_FLAGS ) );
    Object val = vcJobParms.get( VersionCheckerAction.VERSION_REQUEST_FLAGS );
    Assert.assertNotNull( val );
    Assert.assertTrue( val instanceof Integer );
View Full Code Here

      public boolean accept( Job job ) {
        return job.getJobName().contains( "testGetJobsJob" );
      }
    } );
    Assert.assertEquals( "The scheduler engine does not know about the job.", 1, engineJobs.size() );
    Job engineJob = engineJobs.get( 0 );

    //
    // Now make sure we have the same job available on the webservice client side
    //
    Assert.assertEquals( "The scheduler service does not know about the job.", 1, serviceJobs.length );
    Job serviceJob = schedulerSvc.getJobs()[0];
    Assert.assertEquals( "jobName is wrong", engineJob.getJobName(), serviceJob.getJobName() );

    Map<String, Serializable> params = serviceJob.getJobParams();
    Assert.assertTrue( "string job parameter is wrong", "testStringValue".equals( params.get( "stringParam" ) ) );

    Assert.assertTrue( "list job parameter is missing", params.containsKey( "listParam" ) );
    Assert.assertTrue( "map job parameter is missing", params.containsKey( "mapParam" ) );
View Full Code Here

    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>( jobParams );
    newJobParams.put( "newKey", new StringParamValue( "" ) );
    schedulerSvc.updateJobToUseComplexTrigger( jobId, newJobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (ComplexJobTrigger) job.getJobTrigger();
    Assert.assertEquals( (Integer) startingMinute,
        ( (IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get( 0 ) ).getStartingValue() );
    Assert.assertEquals( (Integer) 5, ( (IncrementalRecurrence) jobTrigger.getMinuteRecurrences().get( 0 ) )
        .getIncrement() );
    Assert.assertTrue( job.getJobParams().containsKey( "newKey" ) );

    Assert.assertEquals( new Date(start), jobTrigger.getStartTime() );

    Assert.assertEquals( new Date(end), jobTrigger.getEndTime() );
  }
View Full Code Here

    HashMap<String, ParamValue> newJobParams = new HashMap<String, ParamValue>( jobParams );
    newJobParams.put( "newKey", new StringParamValue( "" ) );
    schedulerSvc.updateJobToUseSimpleTrigger( jobId, newJobParams, jobTrigger );

    Assert.assertEquals( 1, schedulerSvc.getJobs().length );
    Job job = schedulerSvc.getJobs()[0];
    jobTrigger = (SimpleJobTrigger) job.getJobTrigger();
    Assert.assertEquals( 40, jobTrigger.getRepeatInterval() );
    Assert.assertEquals( 50, jobTrigger.getRepeatCount() );
    Assert.assertTrue( job.getJobParams().containsKey( "newKey" ) );

    jobTrigger.getStartTime() ;
    Assert.assertEquals( new Date(start), jobTrigger.getStartTime());

    Assert.assertEquals( new Date(end), jobTrigger.getEndTime() );
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.util.concurrent.PrioritizedExecutorsTests$Job

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.