Package org.rhq.core.domain.operation.bean

Examples of org.rhq.core.domain.operation.bean.ResourceOperationSchedule


        // make it a success after 500ms
        simulatedOperation_Error = null;
        simulatedOperation_Timeout = false;
        simulatedOperation_Sleep = 0L;

        ResourceOperationSchedule newSchedule = new ResourceOperationSchedule();

        newSchedule.setJobTrigger(JobTrigger.createNowTrigger());
        newSchedule.setResource(resource);
        newSchedule.setOperationName(PREFIX + "testOp");
        newSchedule.setDescription(PREFIX + "desc");
        newSchedule.setParameters(null);
        newSchedule.setParameters(null);

        int scheduleId = operationManager.scheduleResourceOperation(overlord(), newSchedule);
        List<ResourceOperationSchedule> schedules = operationManager.findScheduledResourceOperations(overlord(),
            resource.getId());

        assert schedules != null;
        assert !schedules.isEmpty();
        ResourceOperationSchedule schedule = schedules.get(0);
        assert schedule != null;
        assert schedule.getId() == scheduleId;
        assert schedule.getDescription().equals(PREFIX + "desc");
        assert schedule.getOperationName().equals(PREFIX + "testOp");
        assert schedule.getParameters() == null;
        assert schedule.getResource().getId() == newResource.getId();

        Thread.sleep(4000L); // wait for it to finish, should be very quick

        PageList<ResourceOperationHistory> results;
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
View Full Code Here


        simulatedOperation_Error = null;
        simulatedOperation_Timeout = false;
        simulatedOperation_Sleep = 0L;

        Trigger trigger = new SimpleTrigger(PREFIX + "triggername", PREFIX + "triggergroup", 1, 750);
        ResourceOperationSchedule schedule = operationManager.scheduleResourceOperation(overlord(), resource.getId(),
            PREFIX + "testOp", null, trigger, PREFIX + "desc");
        assert schedule != null;
        assert schedule.getDescription().equals(PREFIX + "desc");
        assert schedule.getOperationName().equals(PREFIX + "testOp");
        assert schedule.getParameters() == null;
        assert schedule.getResource().getId() == newResource.getId();

        Thread.sleep(4000L); // wait for it to finish, should be very quick

        PageList<ResourceOperationHistory> results;
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
View Full Code Here

        simulatedOperation_Sleep = 0L;

        Trigger trigger = new SimpleTrigger(PREFIX + "triggername", PREFIX + "triggergroup", new Date());
        Configuration params = new Configuration();
        params.put(new PropertySimple("param1", "test-value!"));
        ResourceOperationSchedule schedule = operationManager.scheduleResourceOperation(overlord(), resource.getId(),
            PREFIX + "testOp", params, trigger, PREFIX + "desc");
        assert schedule != null;
        assert schedule.getDescription().equals(PREFIX + "desc");
        assert schedule.getOperationName().equals(PREFIX + "testOp");
        assert schedule.getParameters() != null;
        assert schedule.getParameters().getId() > 0;
        assert schedule.getParameters().getSimple("param1") != null;
        assert schedule.getResource().getId() == newResource.getId();

        int scheduleParamId = schedule.getParameters().getId();

        Thread.sleep(4000L); // wait for it to finish, should be very quick

        PageList<ResourceOperationHistory> results;
        results = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null, null,
View Full Code Here

            Configuration parameters = ConfigurationClassBuilder.translateParametersToConfig(pool,
                definition.getParametersConfigurationDefinition(), args);

            OperationManagerRemote operationManager = remoteClient.getProxy(OperationManagerRemote.class);

            ResourceOperationSchedule schedule = operationManager.scheduleResourceOperation(remoteClient.getSubject(),
                resourceId, definition.getName(), 0, 0, 0, 30000, parameters, "Executed from commandline");

            ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
            criteria.addFilterJobId(schedule.getJobId());
            criteria.addFilterResourceIds(resourceId);
            criteria.addSortStartTime(PageOrdering.DESC); // put most recent at top of results
            criteria.setPaging(0, 1); // only return one result, in effect the latest
            criteria.fetchOperationDefinition(true);
            criteria.fetchParameters(true);
View Full Code Here

    public void testCronResourceScheduling() throws Exception {
        Resource resource = newResource;
        Calendar calendar = new GregorianCalendar();
        calendar.add(Calendar.SECOND, 2);
        Subject overlord = overlord();
        ResourceOperationSchedule schedule = operationManager.scheduleResourceOperationUsingCron(overlord,
            resource.getId(), PREFIX + "testOp", calendar.get(Calendar.SECOND) + " " + calendar.get(Calendar.MINUTE)
                + " * * * ?", 20, null, PREFIX + "desc");

        assert schedule != null;
        assert schedule.getDescription().equals(PREFIX + "desc");
        assert schedule.getOperationName().equals(PREFIX + "testOp");
        assert schedule.getParameters() != null;
        assert schedule.getResource().getId() == resource.getId();

        List<ResourceOperationSchedule> results;
        results = operationManager.findScheduledResourceOperations(overlord, resource.getId());
        assert results != null;
        assert results.size() == 1;
        ResourceOperationSchedule returnedSchedule = results.get(0);
        assert returnedSchedule.getId() > 0 : returnedSchedule;
        assert returnedSchedule.getJobId() != null : returnedSchedule;
        assert returnedSchedule.getJobName() != null : returnedSchedule;
        assert returnedSchedule.getJobGroup() != null : returnedSchedule;
        assert returnedSchedule.getDescription().equals(PREFIX + "desc");
        assert returnedSchedule.getOperationName().equals(PREFIX + "testOp");
        assert returnedSchedule.getParameters() != null;
        assert returnedSchedule.getResource().getId() == resource.getId();

        System.out.println("WAITING FOR 4.5s FOR THE SCHEDULED OPERATION TO FINISH");
        Thread.sleep(4500L);

        PageList<ResourceOperationHistory> resultsHist;
View Full Code Here

        }

        // Now fire off the operation with no delay and no repetition.
        try {
            String description = "Alert operation for " + alert.getAlertDefinition().getName();
            ResourceOperationSchedule schedule = LookupUtil.getOperationManager().scheduleResourceOperation(subject,
                targetResource.getId(), operation.getName(), 0, 0, 0, 0, replacedParameters, description);
            String message = getResultMessage(info, getHyperLinkForOperationSchedule(subject, targetResource.getId(),
                operation.getName(), schedule.getJobId()));
            return SenderResult.getSimpleDeffered(message);
        } catch (Throwable t) {
            String message = getResultMessage(info, "invocation failed with " + t.getMessage());
            return SenderResult.getSimpleFailure(message);
        }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.operation.bean.ResourceOperationSchedule

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.