Package org.rhq.core.pluginapi.operation

Examples of org.rhq.core.pluginapi.operation.OperationServicesResult


            error(executionContext, null, "Invalid action specified [" + actionName + "] to be executed on server.",
                TRANSITION_ERROR);
            return;
        }

        OperationServicesResult result = null;
        Throwable operationError = null;
        try {
            switch (action) {
                case START: {
                    result = facade.start();
                    break;
                }

                case STOP: {
                    result = facade.stop();
                    break;
                }

                case STOPIFRUNNING: {
                    if (facade.isRunning()) {
                        result = facade.stop();
                    }

                    break;
                }

                case RESTART: {
                    result = facade.stop();
                    if (result.getResultCode() == OperationServicesResultCode.SUCCESS) {
                        result = facade.start();
                    }

                    break;
                }
            }
        } catch (Throwable e) {
            operationError = e;
        }

        OperationServicesResultCode code;
        if (result != null) {
            code = result.getResultCode();
        } else {
            // If the server is not running, the STOPIFRUNNING case won't execute something and we won't have a result.
            // Assume that's a success and continue.           
            code = (operationError == null) ? OperationServicesResultCode.SUCCESS : OperationServicesResultCode.FAILURE;
        }
View Full Code Here


    private OperationServicesResult makeResult() {
        if (throwError) {
            throw new RuntimeException("Mock exception");
        }

        OperationServicesResult result = new OperationServicesResult(resultCode);

        if (resultCode == OperationServicesResultCode.FAILURE) {
            result.setErrorStackTrace("Fake stack trace");
        }

        return result;
    }
View Full Code Here

            code = OperationServicesResultCode.SUCCESS;
        } else {
            code = OperationServicesResultCode.FAILURE;
        }

        OperationServicesResult result = new OperationServicesResult(code);

        return result;
    }
View Full Code Here

            code = OperationServicesResultCode.SUCCESS;
        } else {
            code = OperationServicesResultCode.FAILURE;
        }

        OperationServicesResult result = new OperationServicesResult(code);

        return result;
    }
View Full Code Here

        OperationManager operationManager = PluginContainer.getInstance().getOperationManager();
        OperationServicesAdapter operationsService = new OperationServicesAdapter(operationManager);

        long timeout = 1000 * 60;
        OperationContextImpl operationContext = new OperationContextImpl(storageNode.getId(), operationManager);
        OperationServicesResult result = operationsService.invokeOperation(operationContext, "shutdown",
            new Configuration(), timeout);

        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The shutdown operation failed");

        File binDir = new File(basedir, "bin");
        File pidFile = new File(binDir, "cassandra.pid");

        assertFalse(pidFile.exists(), pidFile + " should be deleted when the storage node is shutdown.");
View Full Code Here

        OperationManager operationManager = PluginContainer.getInstance().getOperationManager();
        OperationServicesAdapter operationsService = new OperationServicesAdapter(operationManager);

        long timeout = 1000 * 60;
        OperationContextImpl operationContext = new OperationContextImpl(storageNode.getId(), operationManager);
        OperationServicesResult result = operationsService.invokeOperation(operationContext, "start",
            new Configuration(), timeout);

        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The start operation failed.");

        File binDir = new File(basedir, "bin");
        File pidFile = new File(binDir, "cassandra.pid");

        assertTrue(pidFile.exists(), pidFile + " should be created when starting the storage node.");
View Full Code Here

    public void takeSnaphots() throws Exception {
        Configuration params = new Configuration();
        for (int i = 0; i < TAKE_SNAPSHOTS; i++) {
            params = Configuration.builder().addSimple("snapshotName", "" + i).build();

            OperationServicesResult result = takeSnapshot(params);
            assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The takeSnapshot operation try "
                + i + " failed.");
        }
        printSnapshotDirsInfo();
        assertSnaphotCount(getSnaphostDirs(), TAKE_SNAPSHOTS);
    }
View Full Code Here

        Configuration params = Configuration.builder().addSimple("retentionStrategy", "Keep Last N")
            .addSimple("count", keepN)
            .addSimple("snapshotName", TAKE_SNAPSHOTS_DELETE_NAME)
            .build();
        OperationServicesResult result = takeSnapshot(params);
        printSnapshotDirsInfo();
        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The takeSnapshot operation failed.");

        assertSnaphotCount(getSnaphostDirs(), keepN);
        assertSnaphotsContain(getSnaphostDirs(), TAKE_SNAPSHOTS_DELETE_NAME);
    }
View Full Code Here

            .addSimple("count", keepN)
            .addSimple("snapshotName", TAKE_SNAPSHOTS_MOVE_NAME)
            .addSimple("deletionStrategy", "Move")
            .addSimple("location", moveLocation.getAbsolutePath())
            .build();
        OperationServicesResult result = takeSnapshot(params);
        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The takeSnapshot operation failed.");

        printSnapshotDirsInfo();

        assertSnaphotCount(getSnaphostDirs(), keepN);
        assertSnaphotsContain(getSnaphostDirs(), TAKE_SNAPSHOTS_MOVE_NAME);
View Full Code Here

        Configuration params = Configuration.builder()
            .addSimple("retentionStrategy", "Delete Older Than N days")
            .addSimple("count", delOlderThan)
            .build();
        OperationServicesResult result = takeSnapshot(params);
        printSnapshotDirsInfo();
        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The takeSnapshot operation failed.");
        // takeSnapshotsKeepLastNAndMove left 1 snapshot so now there has to be 2 of them
        assertSnaphotCount(getSnaphostDirs(), 2);

        File moveLocation = new File(basedir, "snaphosts-moved-2");
        delOlderThan = 1;
        params = Configuration.builder()
            .addSimple("retentionStrategy", "Delete Older Than N days")
            .addSimple("count", delOlderThan)
            .addSimple("deletionStrategy", "Move")
            .addSimple("location", moveLocation.getAbsolutePath())
            .build();
        result = takeSnapshot(params);
        printSnapshotDirsInfo();
        assertEquals(result.getResultCode(), OperationServicesResultCode.SUCCESS, "The takeSnapshot operation failed.");
        // 2 snapshots left 1 created, but 1 moved
        assertSnaphotCount(getSnaphostDirs(), 2);
        assertSnaphotsContain(getMovedSnapshotDirs(moveLocation), TAKE_SNAPSHOTS_MOVE_NAME);
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.operation.OperationServicesResult

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.