Package org.rhq.modules.plugins.jbossas7.json

Examples of org.rhq.modules.plugins.jbossas7.json.Result


    @Override
    public AvailabilityType getAvailability() {
        // Domain deployments have no 'enabled' attribute

        Operation op = new ReadResource(getAddress());
        Result res = getASConnection().execute(op, AVAIL_OP_TIMEOUT_SECONDS);
        // this resource cannot be down, either UP = exists, or MISSING

        if (res != null && res.isSuccess()) {
            return AvailabilityType.UP;
        } else if (res != null && !res.isSuccess() && res.isTimedout()) {
            return AvailabilityType.UNKNOWN;
        }

        return AvailabilityType.MISSING;
    }
View Full Code Here


            for (String theGroup : serverGroups) {
                Operation step = createServerGroupAssignmentStep("add", theGroup, runtimeName, enabled);
                operation.addStep(step);
            }

            Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
            if (res.isSuccess()) {
                operationResult.setSimpleResult("Successfully deployed to server groups " + serverGroups);

                //request the server to discover child resources to allow the discovery of the deployments
                //on server groups immediately
                requestDiscovery();
            } else {
                operationResult.setErrorMessage("Deployment to server groups failed: " + res.getFailureDescription());
            }
        } else if (name.equals("restart")) {
            String serverGroup = parameters.getSimpleValue("server-group", "-not set-");
            List<String> serverGroups = new ArrayList<String>();
            List<String> assignedGroups = findAssignedServerGroups();
            if (serverGroup.equals("__all")) {
                serverGroups.addAll(assignedGroups);
            } else {
                if (!assignedGroups.contains(serverGroup)) {
                    operationResult.setErrorMessage("Deployment could not be restarted in server-group [" + serverGroup
                        + "] because it is not assigned to it.");
                    return operationResult;
                }
                serverGroups.add(serverGroup);
            }
            if (serverGroups.isEmpty()) {
                operationResult
                    .setErrorMessage("Deployment could not be restarted because it is not assigned to any server-group");
                return operationResult;
            }
            CompositeOperation operation = new CompositeOperation();
            for (String theGroup : serverGroups) {
                Operation step = createServerGroupAssignmentStep("redeploy", theGroup, null, false);
                operation.addStep(step);
            }
            Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
            if (res.isSuccess()) {
                operationResult.setSimpleResult("Successfully restarted in server groups " + serverGroups);
            } else {
                operationResult.setErrorMessage("Deployment restart in server groups failed: "
                    + res.getFailureDescription());
            }
        } else {
            operationResult.setErrorMessage("Unknown operation " + name);
        }
        return operationResult;
View Full Code Here

    private void loadAssignedServerGroups(Configuration configuration) {
        String managementNodeName = getManagementNodeName();
        Address theAddress = new Address("/");
        Operation op = new ReadChildrenResources(theAddress, "server-group");
        op.addAdditionalProperty("recursive-depth", "1");
        Result res = getASConnection().execute(op);
        PropertyList propGroups = new PropertyList("*1");
        configuration.put(propGroups);
        if (res.isSuccess()) {
            Map<String, Object> groups = (Map<String, Object>) res.getResult();
            for (Map.Entry<String, Object> entry : groups.entrySet()) {
                Map<String, Object> groupDetails = (Map<String, Object>) entry.getValue();
                Map<String, Object> deployments = (Map<String, Object>) groupDetails.get("deployment");
                if (deployments != null) {
                    Map<String, Object> deployment = (Map<String, Object>) deployments.get(managementNodeName);
View Full Code Here

    @Override
    public Configuration loadResourceConfiguration() throws Exception {
        Configuration configuration = new Configuration();
        // load deployment configuration - we cannot use generic method, it would fail
        Operation op = new Operation("read-resource", getAddress());
        Result res = getASConnection().execute(op);
        if (res.isSuccess()) {
            Map<String, Object> result = (Map<String, Object>) res.getResult();
            configuration.put(new PropertySimple("name", result.get("name")));
            configuration.put(new PropertySimple("runtime-name", result.get("runtime-name")));
            configuration.put(new PropertySimple("content", result.get("content")));
        } else {
            throw new IOException("Operation " + op + " failed: " + res.getFailureDescription());
        }
        includeOOBMessages(res, configuration);
        // list all server-groups, iterate them and find the ones we're deployed in
        loadAssignedServerGroups(configuration);
        return configuration;
View Full Code Here

        }
        if (operation.numberOfSteps() == 0) {
            report.setStatus(ConfigurationUpdateStatus.NOCHANGE);
            return;
        }
        Result res = getASConnection().execute(operation, 120); // wait up to 2 minutes
        if (res.isSuccess()) {
            report.setStatus(ConfigurationUpdateStatus.SUCCESS);
        } else {
            report.setStatus(ConfigurationUpdateStatus.FAILURE);
            report.setErrorMessage(res.getFailureDescription());
            return;
        }
        if (needDiscovery) {
            requestDiscovery();
        }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private Collection<String> getServerGroups() {
        Operation op = new ReadChildrenNames(new Address(), "server-group");
        Result res = getASConnection().execute(op);

        return (Collection<String>) res.getResult();
    }
View Full Code Here

                //handle this ourselves
                //the name of the metric is actually the name of the stat collected for each method. we then provide
                //the calltime data for each method.

                Result result = getASConnection().execute(new ReadAttribute(address, METHODS_ATTRIBUTE));
                Object value = result.getResult();
                if (value instanceof Map) {
                    @SuppressWarnings("unchecked")
                    Map<String, Map<String, Number>> allMethodStats = (Map<String, Map<String, Number>>) value;

                    if (allMethodStats.isEmpty()) {
                        continue;
                    }

                    //first we need to know since when the values were collected
                    result = getASConnection().execute(new ReadAttribute(RUNTIME_MBEAN_ADDRESS, START_TIME_ATTRIBUTE));
                    long serverStartTime = (Long) result.getResult();

                    //now process the calltime value
                    String requestedMetric = request.getName().substring(CALLTIME_METRIC_NAME_PREFIX_LENGTH);

                    Stats lastCollection = getLastCallTimeCollection(requestedMetric, allMethodStats, serverStartTime);
View Full Code Here

        try {
            ejb3StatisticsEnalbed = readAttribute(ejbAddress, "enable-statistics", Boolean.class);
            if (!Boolean.TRUE.equals(ejb3StatisticsEnalbed)) {
                getLog().debug("Enabling global EJB3 statistics");
                WriteAttribute op = new WriteAttribute(ejbAddress, "enable-statistics", true);
                Result result = getASConnection().execute(op);
                if (result.isSuccess()) {
                    getLog()
                        .info(
                            server.context.getResourceDetails()
                                + " Global EJB3 statistics is now enabled, because there is a request to collect EJB Calltime metrics.");
                } else {
                    getLog().error("Failed to enable EJB3 statistics : " + result.getFailureDescription());
                }
            }
        } catch (Exception e) {
            getLog().error("Failed to read and enable EJB3 statistics", e);
        }
View Full Code Here

        String resultString = loadJsonFromFile("extensions.json");

        ConfigurationDefinition definition = loadDescriptor("test4");

        ObjectMapper mapper = new ObjectMapper();
        Result result = mapper.readValue(resultString, Result.class);
        JsonNode json = mapper.valueToTree(result);

        FakeConnection connection = new FakeConnection();
        connection.setContent(json);
View Full Code Here

    }

    public InputStream getReport() throws Exception {
        log.info("Obtaining JDR Report form " + this.path);
        Operation operation = new Operation("generate-jdr-report", this.path);
        Result res = this.connection.execute(operation, false, JDR_OPERATION_TIMEOUT); // 10minutes should be enough
        if (res.isSuccess()) {
            @SuppressWarnings("unchecked")
            Map<String, Object> map = (Map<String, Object>) res.getResult();
            File report = new File(map.get("report-location").toString());
            if (report.exists() && report.canRead()) {
                log.info("JDR Report created in " + report.getAbsolutePath());
                return new FileInputStream(report);
            } else {
                throw new IOException("Failed to read generated JDR Report file " + report.getAbsolutePath());
            }
        }
        log.error("Failed to generate JDR Report : " + res.getFailureDescription());
        return null;
    }
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.Result

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.