Package org.torquebox.jobs

Examples of org.torquebox.jobs.ScheduledJobMetaData


        List<ScheduledJobMetaData> allJobMetaData = unit.getAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY );

        assertNotNull( allJobMetaData );
        assertEquals( 4, allJobMetaData.size() );

        ScheduledJobMetaData jobOne = getJobMetaData( allJobMetaData, "job.one" );
        assertNotNull( jobOne );
        assertEquals( "job.one", jobOne.getName() );
        assertEquals( "My Job is routine", jobOne.getDescription() );
        assertEquals( "01 * * * * ?", jobOne.getCronExpression() );
        assertEquals( "MyJobClass", jobOne.getRubyClassName() );
        assertEquals( "bar", jobOne.getParameters().get( "foo" ) );
        assertTrue( jobOne.isSingleton() );
        assertNotNull( jobOne.getGroup() );
        assertFalse( jobOne.isStopped() );

        ScheduledJobMetaData jobTwo = getJobMetaData( allJobMetaData, "job.two" );
        assertNotNull( jobTwo );
        assertEquals( "job.two", jobTwo.getName() );
        assertEquals( "My other Job is extraodinary", jobTwo.getDescription() );
        assertEquals( "01 01 01 15 * ?", jobTwo.getCronExpression() );
        assertEquals( "MyOtherJobClass", jobTwo.getRubyClassName() );
        assertTrue( jobTwo.isSingleton() );
        assertNotNull( jobTwo.getGroup() );
        assertFalse( jobTwo.isStopped() );

        ScheduledJobMetaData jobThree = getJobMetaData( allJobMetaData, "job.three" );
        assertNotNull( jobThree );
        assertEquals( "job.three", jobThree.getName() );
        assertEquals( "My non-singleton job class", jobThree.getDescription() );
        assertEquals( "01 01 01 15 * ?", jobThree.getCronExpression() );
        assertEquals( "NonSingletonJobClass", jobThree.getRubyClassName() );
        assertFalse( jobThree.isSingleton() );
        assertNotNull( jobThree.getGroup() );
        assertFalse( jobThree.isStopped() );

        ScheduledJobMetaData jobFour = getJobMetaData( allJobMetaData, "job.four" );
        assertNotNull( jobFour );
        assertEquals( "job.four", jobFour.getName() );
        assertEquals( "My long running job has timeout", jobFour.getDescription() );
        assertEquals( "01 01 01 15 * ?", jobFour.getCronExpression() );
        assertEquals( "MyLongRunningJob", jobFour.getRubyClassName() );
        assertEquals( new TimeInterval( 5000, TimeUnit.MILLISECONDS ), jobFour.getTimeout() );
        assertTrue( jobFour.isSingleton() );
        assertNotNull( jobFour.getGroup() );
        assertTrue( jobFour.isStopped() );

        assertEquals( jobOne.getGroup(), jobTwo.getGroup() );
        assertEquals( jobOne.getGroup(), jobThree.getGroup() );
    }
View Full Code Here


        List<ScheduledJobMetaData> allJobMetaData = unit.getAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY );

        assertNotNull( allJobMetaData );
        assertEquals( 1, allJobMetaData.size() );

        ScheduledJobMetaData jobOne = getJobMetaData( allJobMetaData, "job.one" );
        assertNotNull( jobOne );
        assertEquals( "job.one", jobOne.getName() );
        assertEquals( "My Job is routine", jobOne.getDescription() );
        assertEquals( "01 * * * * ?", jobOne.getCronExpression() );
        assertEquals( "MyNoUnitJobClass", jobOne.getRubyClassName() );
        assertEquals( new TimeInterval( 60, TimeUnit.SECONDS ), jobOne.getTimeout() );
        assertTrue( jobOne.isSingleton() );
        assertNotNull( jobOne.getGroup() );

    }
View Full Code Here

                if (stopped != null && !(stopped instanceof Boolean)) {
                    throw new DeploymentUnitProcessingException(" Attribute 'stopped' must be either true or false." );
                }

                ScheduledJobMetaData jobMetaData = new ScheduledJobMetaData();

                jobMetaData.setName( jobName.toString() );
                jobMetaData.setGroup( unit.getName() );
                if (description != null) {
                    jobMetaData.setDescription( description.toString() );
                }
                jobMetaData.setRubyClassName( job.trim() );
                jobMetaData.setCronExpression( cron.trim() );
                jobMetaData.setParameters( params );
                jobMetaData.setRubyRequirePath( StringUtils.underscore( job.trim() ) );
                jobMetaData.setSingleton( singleton == null ? true : (Boolean) singleton );

                if (stopped != null) {
                    jobMetaData.setStopped( (Boolean) stopped );
                }

                unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, jobMetaData );

                String timeoutStr = jobSpec.containsKey( "timeout" ) ?
                        jobSpec.get( "timeout" ).toString() : null;

                jobMetaData.setTimeout( TimeInterval.parseInterval( timeoutStr, TimeUnit.SECONDS ) );
               
            }
        }
    }
View Full Code Here

    }

    /** Ensure that given at least one job, a scheduler is deployed. */
    @Test
    public void testSchedulerDeployment() throws Exception {
        ScheduledJobMetaData jobMeta = new ScheduledJobMetaData();
        unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, jobMeta );
       
        deploy( phaseContext );

        ServiceName schedulerServiceName = JobsServices.scheduler(unit, false);
View Full Code Here

    @Test
    public void testSingletonSchedulerDeployment() throws Throwable {
        // Prepare a special 'clustered' phase context
        init(new ClusteredMockServiceRegistry());

        ScheduledJobMetaData jobMeta = new ScheduledJobMetaData();
        jobMeta.setSingleton( true );
        unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, jobMeta );
       
        deploy( phaseContext );

        ServiceName schedulerServiceName = JobsServices.scheduler(unit, true);
View Full Code Here

   
    /** Ensure that a thread count is passed through. */
    @Test
    public void testWithAThreadCount() throws Exception {
        this.unit.getAttachment( JobSchedulerMetaData.ATTACHMENT_KEY ).setThreadCount( 55 );
        ScheduledJobMetaData jobMeta = new ScheduledJobMetaData();
        unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, jobMeta );
       
        deploy( phaseContext );

        ServiceName schedulerServiceName = JobsServices.scheduler(unit, false);
View Full Code Here

       
        PoolMetaData jobsPoolMetaData = new PoolMetaData( "jobs" );
        jobsPoolMetaData.setShared();
       
        unit.addToAttachmentList( PoolMetaData.ATTACHMENTS_KEY, jobsPoolMetaData );
        unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, new ScheduledJobMetaData() );
       
        deploy( phaseContext );
       
        List<PoolMetaData> allPools = unit.getAttachmentList( PoolMetaData.ATTACHMENTS_KEY );
        assertEquals( 1, allPools.size() );
View Full Code Here

    public void testDefaultNonClusteredPool() throws Exception {
        DeploymentPhaseContext phaseContext = createPhaseContext();
        DeploymentUnit unit = phaseContext.getDeploymentUnit();
       
       
        unit.addToAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY, new ScheduledJobMetaData() );
       
        deploy( phaseContext );
       
        List<PoolMetaData> allPools = unit.getAttachmentList( PoolMetaData.ATTACHMENTS_KEY );
        assertEquals( 1, allPools.size() );
View Full Code Here

TOP

Related Classes of org.torquebox.jobs.ScheduledJobMetaData

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.