Package org.rhq.modules.plugins.jbossas7

Examples of org.rhq.modules.plugins.jbossas7.WebRuntimeComponent


    private boolean waitForServerToStart() throws InterruptedException {
        boolean up = false;
        while (!up) {
            Operation op = new ReadAttribute(new Address(), "release-version");
            try {
                Result res = getASConnection().execute(op);
                if (res.isSuccess()) { // If op succeeds, server is not down
                    up = true;
                }
            } catch (Exception e) {
                //do absolutely nothing
                //if an exception is thrown that means the server is still down, so consider this
View Full Code Here


     * @return name current host within EAP domain or null if we failed to read it
     */
    public static String findASDomainHostName(ASConnection connection) {
        ReadAttribute op = new ReadAttribute(new Address(), "local-host-name");
        op.includeDefaults(true);
        Result result = connection.execute(op);
        if (result.isSuccess()) {
            return result.getResult().toString();
        }
        return null;
    }
View Full Code Here

        } else {
            String json = results.getCapturedOutput();

            ObjectMapper mapper = new ObjectMapper();

            Result result;
            try {
                result = mapper.readValue(json, Result.class);
            } catch (IOException e) {
                LOG.warn("Failed to parse the output of the 'patch info' command with message '" + e.getMessage() +
                    "'.", e);
                return null;
            }

            if (!result.isSuccess()) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("'patch info' command didn't succeed: " + result);
                }

                return null;
            }

            if (!(result.getResult() instanceof Map)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Unexpected patch info results. Expected map but found " +
                        (result.getResult() == null ? "null" : result.getResult().getClass().toString()));
                }

                return null;
            }

            @SuppressWarnings("unchecked")
            Map<String, Object> info = (Map<String, Object>) result.getResult();

            if (info.isEmpty()) {
                return null;
            }
View Full Code Here

            path = path.replace("server-config","server");
            Address address = new Address(path);
            address.add("core-service","platform-mbean");
            address.add("type","runtime");
            Operation op = new ReadAttribute(address,"start-time");
            Result res = getASConnection().execute(op);

            if (res.isSuccess()) {
               Long startTime= (Long) res.getResult();
               MeasurementDataTrait data = new MeasurementDataTrait(request,new Date(startTime).toString());
               report.addData(data);
            }
         }
         else {
View Full Code Here

    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
        Set<MeasurementScheduleRequest> leftovers = new HashSet<MeasurementScheduleRequest>(metrics.size());
        for (MeasurementScheduleRequest request : metrics) {
            if (request.getName().equals("_aliases")) {
                ReadAttribute op = new ReadAttribute(getAddress(), "alias");
                Result res = getASConnection().execute(op);
                if (res.isSuccess()) {
                    List<String> aliases = (List<String>) res.getResult();
                    MeasurementDataTrait data;
                    if (aliases != null) {
                        Collections.sort(aliases);
                        String trait = aliases.toString();
                        data = new MeasurementDataTrait(request, trait);
                    } else {
                        data = new MeasurementDataTrait(request, "-none-");
                    }
                    report.addData(data);
                } else
                    getLog().warn("Could not get aliases for " + getAddress() + ": " + res.getFailureDescription());
            } else {
                leftovers.add(request);
            }
        }
        super.getValues(report, leftovers);
View Full Code Here

            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationWriteDelegate);

        ASConnection mockASConnection = mock(ASConnection.class);
        when(mockASConnection.execute(any(ReadResource.class))).thenReturn(new Result());


        //create object to test and inject required dependencies
        TemplatedComponent objectUnderTest = new TemplatedComponent();
View Full Code Here

            .withParameterTypes(ConfigurationDefinition.class, ASConnection.class, Address.class)
            .withArguments(any(ConfigurationDefinition.class), any(ASConnection.class), any(Address.class))
            .thenReturn(mockConfigurationWriteDelegate);

        ASConnection mockASConnection = mock(ASConnection.class);
        when(mockASConnection.execute(any(ReadResource.class))).thenReturn(new Result());

        //create object to test and inject required dependencies
        TemplatedComponent objectUnderTest = new TemplatedComponent();

        objectUnderTest.context = mockResourceContext;
View Full Code Here

        if (verbose) {
            log.info("total path: [" + path + "]");
        }

        Address addr = new Address(parentPath);
        Result result = connection.execute(new ReadChildrenNames(addr, confPath));

        if (result.isSuccess()) {

            @SuppressWarnings("unchecked")
            List<String> deployments = (List<String>) result.getResult();

            // There may be multiple children of the given type
            for (String val : deployments) {

                String newPath = confPath + "=" + val;
View Full Code Here

                subTypes.add(confPath);

            for (String cpath : subTypes) {

                Address addr = new Address(parentPath);
                Result result = connection.execute(new ReadChildrenNames(addr, cpath));

                if (result.isSuccess()) {

                    @SuppressWarnings("unchecked")
                    List<String> subsystems = (List<String>) result.getResult();

                    // There may be multiple children of the given type
                    for (String val : subsystems) {

                        String newPath = cpath + "=" + val;
                        Configuration config2 = context.getDefaultPluginConfiguration();

                        String resKey;

                        if (path == null || path.isEmpty())
                            resKey = newPath;
                        else {
                            if (path.startsWith(","))
                                path = path.substring(1);
                            resKey = path + "," + cpath + "=" + val;
                        }

                        PropertySimple pathProp = new PropertySimple("path", resKey);
                        config2.put(pathProp);

                        DiscoveredResourceDetails detail = new DiscoveredResourceDetails(context.getResourceType(), // DataType
                            resKey, // Key
                            val, // Name
                            null, // Version
                            context.getResourceType().getDescription(), // subsystem.description
                            config2, null);
                        details.add(detail);
                    }
                }
            }
        } else {
            // Single subsystem
            path += "," + confPath;
            if (path.startsWith(","))
                path = path.substring(1);
            Result result = connection.execute(new ReadResource(new Address(path)));
            if (result.isSuccess()) {

                String resKey = path;
                String name = resKey.substring(resKey.lastIndexOf("=") + 1);
                Configuration config2 = context.getDefaultPluginConfiguration();
                PropertySimple pathProp = new PropertySimple("path", path);
View Full Code Here

    public OperationResult invokeOperation(String name,
                                           Configuration parameters) throws  Exception {

        if (name.equals("get-all-thread-ids")) {
            Operation op = new ReadAttribute(getAddress(), "all-thread-ids");
            Result res = getASConnection().execute(op);
            OperationResult operationResult;
            if (res.isSuccess()) {
                List<Long> ids = (List<Long>) res.getResult();
                operationResult = new OperationResult(ids.toString());
            } else {
                operationResult = new OperationResult();
                String errorMessage = "Got no result back";
                if (!res.isSuccess()) {
                    errorMessage += ": " + res.getFailureDescription();
                }
                operationResult.setErrorMessage(errorMessage);
            }
            return operationResult;
        }
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.WebRuntimeComponent

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.