Examples of JobSchedulerMetaData


Examples of org.torquebox.jobs.JobSchedulerMetaData

    /** Ensure that a valid jobs.yml attaches metadata. */
    @Test
    public void testValidJobsYml() throws Exception {
        MockDeploymentUnit unit = deployResourceAsTorqueboxYml( "valid-jobs.yml" );

        JobSchedulerMetaData schedulerMetaData = unit.getAttachment( JobSchedulerMetaData.ATTACHMENT_KEY );
       
        assertNotNull( schedulerMetaData );
        assertEquals( 5, schedulerMetaData.getThreadCount() );
       
        List<ScheduledJobMetaData> allJobMetaData = unit.getAttachmentList( ScheduledJobMetaData.ATTACHMENTS_KEY );

        assertNotNull( allJobMetaData );
        assertEquals( 4, allJobMetaData.size() );
View Full Code Here

Examples of org.torquebox.jobs.JobSchedulerMetaData

    }

    private void installScheduler(DeploymentPhaseContext phaseContext, boolean singleton) {
        DeploymentUnit unit = phaseContext.getDeploymentUnit();
        ServiceName serviceName = JobsServices.scheduler(unit, singleton);
        JobSchedulerMetaData schedulerMetaData = unit.getAttachment(JobSchedulerMetaData.ATTACHMENT_KEY);

        if (schedulerMetaData == null) {
            // It seems that there are no jobs defined at the deployment time
            // (in deployment descriptors) or no jobs subsystem configuration
            // is provided, let's create a default one.
            log.debug("No jobs subsystem configuration is found, using defaults");

            schedulerMetaData = new JobSchedulerMetaData();
            unit.putAttachment(JobSchedulerMetaData.ATTACHMENT_KEY, schedulerMetaData);
        }

        log.debugf("Setting job scheduler concurrency to %s", schedulerMetaData.getThreadCount());

        JobScheduler scheduler = new JobScheduler(serviceName.getCanonicalName(), schedulerMetaData.getThreadCount());

        ServiceBuilder<BaseJobScheduler> builder = phaseContext.getServiceTarget().addService(serviceName, scheduler);

        // Add dependency to the jobs pool
        builder.addDependency(CoreServices.runtimePoolName(unit, "jobs"), RubyRuntimePool.class, scheduler.getRubyRuntimePoolInjector());
View Full Code Here

Examples of org.torquebox.jobs.JobSchedulerMetaData

    @SuppressWarnings("unchecked")
    public void parse(DeploymentUnit unit, Object dataObject) throws DeploymentUnitProcessingException {
        Map<String, ?> data = (Map<String, ?>) dataObject;
       
        JobSchedulerMetaData schedulerMetaData = new JobSchedulerMetaData();
        unit.putAttachment( JobSchedulerMetaData.ATTACHMENT_KEY, schedulerMetaData );
       
        for (String jobName : data.keySet()) {
            Object datum = data.get( jobName );
            if ("concurrency".equals( jobName ) &&
                    !(datum instanceof Map)) {
               
                if (!(datum instanceof Integer)) {
                    throw new DeploymentUnitProcessingException( "Attribute 'concurrency' must be an integer." );
                }
                schedulerMetaData.setThreadCount( (Integer)datum );
                               
            } else {
               
                Map<String, ?> jobSpec = (Map<String, ?>)datum;
                String description = (String) jobSpec.get( "description" );
View Full Code Here

Examples of org.torquebox.jobs.JobSchedulerMetaData

    private void init(MockServiceRegistry serviceRegistry) throws Exception {
        this.phaseContext = createPhaseContext(serviceRegistry, "test-unit");
        this.unit = this.phaseContext.getMockDeploymentUnit();

        this.unit.putAttachment( JobSchedulerMetaData.ATTACHMENT_KEY, new JobSchedulerMetaData());
        this.unit.putAttachment( RubyAppMetaData.ATTACHMENT_KEY, new RubyAppMetaData("test-app"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.