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

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


     * @param moduleTypeValue
     * @return
     */
    public static Operation createAddModuleOptionTypeOperation(Address address, String attribute,
        List<Value> moduleTypeValue) {
        Operation add = null;
        if ((address != null) & (attribute != null) & (moduleTypeValue != null)) {
            add = new Operation("add", address);
            add.addAdditionalProperty(attribute, moduleTypeValue);
        }
        return add;
    }
View Full Code Here


        }
        /*
         * Now handle the non-grouped properties
         */
        List<PropertyDefinition> nonGroupdedDefs = configurationDefinition.getNonGroupedProperties();
        Operation op = new ReadResource(address);
        if (includeRuntime) {
            op.addAdditionalProperty("include-runtime", "true"); // Include runtime values for attributes
        }
        //        op.addAdditionalProperty("recursive", "true"); // Also get sub-resources
        loadHandleProperties(config, nonGroupdedDefs, op);

        return config;
View Full Code Here

     * @param config Configuration to return
     * @param groupDefinition Definition of this group
     * @throws Exception If anything goes wrong
     */
    private void loadHandleGroup(Configuration config, PropertyGroupDefinition groupDefinition) throws Exception {
        Operation operation = null;
        String groupName = groupDefinition.getName();
        if (groupName.startsWith("attribute:")) {
            String attr = groupName.substring("attribute:".length());
            operation = new ReadAttribute(address, attr);
        } else if (groupName.startsWith("children:")) {
            String type = groupName.substring("children:".length());
            if (type.contains(":")) {

                // If the third part ends with a ?, we fill this config prop with the resource name from the path
                String tmp = type.substring(type.indexOf(":") + 1);
                if (tmp.endsWith("+-")) {
                    nameFromPathProperty = tmp.substring(0, tmp.length() - 2);
                }

                // We need the type for reading
                type = type.substring(0, type.indexOf(":"));

            }
            operation = new ReadChildrenResources(address, type);
            operation.addAdditionalProperty("recursive", "true");
        } else if (groupName.startsWith("child:")) {
            String subPath = groupName.substring("child:".length());
            if (!subPath.contains("="))
                throw new IllegalArgumentException("subPath of 'child:' expression has no =");

            if (subPath.contains(":")) {
                subPath = subPath.substring(0,subPath.indexOf(':'));
            }
            boolean includeRuntime=false;
            if (subPath.endsWith("*")) {
                subPath = subPath.substring(0,subPath.length()-1);
                includeRuntime=true;
            }

            Address address1 = new Address(address);
            address1.addSegment(subPath);
            operation = new ReadResource(address1);
            if (includeRuntime)
                ((ReadResource)operation).includeRuntime(true);
        } else {//no special handling of <c:groups> details required.
            //Just assume normal group operations aggregation semantics, so retrieve entries and load.
            Operation op = new ReadResource(address);
            List<PropertyDefinition> listedDefs = configurationDefinition.getPropertiesInGroup(groupName);
            loadHandleProperties(config, listedDefs, op);
            return;
        }
        List<PropertyDefinition> listedDefs = configurationDefinition.getPropertiesInGroup(groupName);
View Full Code Here

    @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;
View Full Code Here

            if (runtimeNameProperty != null)
                runtimeName = runtimeNameProperty.getStringValue();

            CompositeOperation operation = new CompositeOperation();
            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);
View Full Code Here

    @SuppressWarnings("unchecked")
    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();
View Full Code Here

    private Operation createServerGroupAssignmentStep(String action, String serverGroup, String runtimeName,
        boolean enabled) {
        Address addr = new Address();
        addr.add("server-group", serverGroup);
        addr.add("deployment", getManagementNodeName());
        Operation op = new Operation(action, addr);
        if ("add".equals(action)) {
            if (runtimeName != null && !runtimeName.isEmpty()) {
                op.addAdditionalProperty("runtime-name", runtimeName);
            }
            op.addAdditionalProperty("enabled", enabled);
        }
        return op;
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @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")));
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

        this.path.addSegment("subsystem=jdr");
    }

    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());
View Full Code Here

TOP

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

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.