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

Examples of org.rhq.modules.plugins.jbossas7.json.CompositeOperation$OperationHeaders


        Operation step3 = new Operation("remove",serverGroupAddress);

        Operation step4 = new Operation("remove",deploymentsAddress);

        CompositeOperation cop = new CompositeOperation();
        cop.addStep(step1);
        cop.addStep(step2);
        cop.addStep(step3);
        cop.addStep(step4);

        ObjectMapper mapper = new ObjectMapper();

        String result = mapper.writeValueAsString(cop);
        System.out.println(result);
View Full Code Here


        addDeploymentStep.addAdditionalProperty("name", filename);
        addDeploymentStep.addAdditionalProperty("runtime-name", runtimeName);

        Operation deployStep = new Operation("deploy", addDeploymentStep.getAddress());

        CompositeOperation compositeOperation = new CompositeOperation();
        compositeOperation.addStep(addDeploymentStep);
        compositeOperation.addStep(deployStep);

        Result result = getASConnection().execute(compositeOperation, 300);
        if (!result.isSuccess()) {
            return BundleHandoverResponse.failure(EXECUTION, result.getFailureDescription());
        } else {
View Full Code Here

        assertTrue(res.getFailureDescription().endsWith("rolled-back=true"), "Unexpected failure description: " + res);
    }

    public void testCompositeReadAttribute() throws Exception {
        Address a = new Address("profile=default,subsystem=web,connector=http");
        CompositeOperation cop = new CompositeOperation();
        Operation step1 = new ReadAttribute(a, "maxTime");
        cop.addStep(step1);
        Operation step2 = new ReadAttribute(a, "processingTime");
        cop.addStep(step2);

        ComplexResult res = getDomainControllerASConnection().executeComplex(cop);
        assertNotNull(res);
        assertTrue(res.isSuccess(), "Response outcome was failure.");
        Map<String, Object> resResult = res.getResult();
View Full Code Here

            }

            List<String> childrenNamesSubList = childrenNames.subList(0, Math.min(batchSize, childrenNames.size()));

            // Create batch operation to read N query-cache nodes
            CompositeOperation batchOperation = new CompositeOperation();
            for (String childrenName : childrenNamesSubList) {
                Address address = new Address(getAddress());
                address.add("query-cache", childrenName);
                ReadResource readQueryCacheResource = new ReadResource(address);
                readQueryCacheResource.includeRuntime(true);
                batchOperation.addStep(readQueryCacheResource);
            }

            // Execute batch
            Result batchResult = getASConnection().execute(batchOperation, timeoutSec);
            if (!batchResult.isSuccess()) {
View Full Code Here

        step1.addAdditionalProperty("runtime-name", runtimeName);

        String resourceKey;
        Result result;

        CompositeOperation cop = new CompositeOperation();
        cop.addStep(step1);
        /*
         * We need to check here if this is an upload to /deployment only
         * or if this should be deployed to a server group too
         */

        if (!toServerGroup) {

            // if standalone, then :deploy the deployment anyway
            if (context.getResourceType().getName().contains("Standalone")) {
                Operation step2 = new Operation("deploy", step1.getAddress());
                cop.addStep(step2);
            }

            result = connection.execute(cop, 300);
            resourceKey = step1.getAddress().getPath();

        } else {

            Address serverGroupAddress = new Address(context.getResourceKey());
            serverGroupAddress.add("deployment", deploymentName);
            Operation step2 = new Operation("add", serverGroupAddress);

            cop.addStep(step2);

            Operation step3 = new Operation("deploy", serverGroupAddress);
            cop.addStep(step3);

            resourceKey = serverGroupAddress.getPath();

            if (verbose) {
                LOG.info("Deploy operation: " + cop);
View Full Code Here

                + ThrowableUtil.getRootMessage(e));
            return;
        }

        // 2. We will wrap all property-simple and connection properties changes in a composite operation
        CompositeOperation updateOperation = new CompositeOperation();

        // 3. Capture property-simple changes
        Map<String, PropertySimple> newConfigSimpleProperties = newConfig.getSimpleProperties();
        Map<String, PropertySimple> currentConfigSimpleProperties = currentConfig.getSimpleProperties();

        Set<String> allSimplePropertyNames = new HashSet<String>(newConfigSimpleProperties.size()
            + currentConfigSimpleProperties.size());
        allSimplePropertyNames.addAll(newConfigSimpleProperties.keySet());
        allSimplePropertyNames.addAll(currentConfigSimpleProperties.keySet());
        // Read-only
        allSimplePropertyNames.remove(ENABLED_ATTRIBUTE);
        if (getServerComponent().getServerPluginConfiguration().getProductType() == JBossProductType.AS) {
            // Only supported on EAP
            allSimplePropertyNames.remove(ALLOW_MULTIPLE_USERS_ATTRIBUTE);
            allSimplePropertyNames.remove(TRACK_STATEMENTS_ATTRIBUTE);
        }

        for (String simplePropertyName : allSimplePropertyNames) {
            PropertySimple newConfigPropertySimple = newConfigSimpleProperties.get(simplePropertyName);
            String newConfigPropertySimpleValue = newConfigPropertySimple == null ? null : newConfigPropertySimple
                .getStringValue();
            PropertySimple currentConfigPropertySimple = currentConfigSimpleProperties.get(simplePropertyName);
            String currentConfigPropertySimpleValue = currentConfigPropertySimple == null ? null
                : currentConfigPropertySimple.getStringValue();
            boolean canUnset = !UNSET_FORBIDDEN_ATTRIBUTES.contains(simplePropertyName);

            if (newConfigPropertySimpleValue == null) {
                if (currentConfigPropertySimpleValue != null) {
                    String val;
                    if (canUnset) {
                        val = null;
                    } else {
                        val = configDef.getPropertyDefinitionSimple(simplePropertyName).getDefaultValue();
                    }
                    updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName, val));
                }
            } else if (!newConfigPropertySimpleValue.equals(currentConfigPropertySimpleValue)) {
                updateOperation.addStep(new WriteAttribute(getAddress(), simplePropertyName,
                    newConfigPropertySimpleValue));
            }
        }

        // 4. Capture connection property changes
        String connPropAttributeNameOnServer, connPropPluginConfigPropertyName, keyName;
        if (isXADatasourceResource(resourceType)) {
            connPropAttributeNameOnServer = "xa-datasource-properties";
            connPropPluginConfigPropertyName = XA_DATASOURCE_PROPERTIES_ATTRIBUTE;
            keyName = "key";
        } else {
            connPropAttributeNameOnServer = "connection-properties";
            connPropPluginConfigPropertyName = CONNECTION_PROPERTIES_ATTRIBUTE;
            keyName = "pname";
        }

        Map<String, String> newConfigConnectionProperties = getConnectionPropertiesAsMap(
            newConfig.getList(connPropPluginConfigPropertyName), keyName);
        Map<String, String> currentConfigConnectionProperties = getConnectionPropertiesAsMap(
            currentConfig.getList(connPropPluginConfigPropertyName), keyName);
        Set<String> allConnectionPropertyNames = new HashSet<String>(newConfigConnectionProperties.size()
            + currentConfigConnectionProperties.size());
        allConnectionPropertyNames.addAll(newConfigConnectionProperties.keySet());
        allConnectionPropertyNames.addAll(currentConfigConnectionProperties.keySet());

        for (String connectionPropertyName : allConnectionPropertyNames) {
            Address propertyAddress = new Address(getAddress());
            propertyAddress.add(connPropAttributeNameOnServer, connectionPropertyName);

            String newConfigConnectionPropertyValue = newConfigConnectionProperties.get(connectionPropertyName);
            String currentConfigConnectionPropertyValue = currentConfigConnectionProperties.get(connectionPropertyName);

            if (newConfigConnectionPropertyValue == null) {
                updateOperation.addStep(new Operation("remove", propertyAddress));
            } else if (currentConfigConnectionPropertyValue == null) {
                Operation addOperation = new Operation("add", propertyAddress);
                addOperation.addAdditionalProperty("value", newConfigConnectionPropertyValue);
                updateOperation.addStep(addOperation);
            } else if (!newConfigConnectionPropertyValue.equals(currentConfigConnectionPropertyValue)) {
                updateOperation.addStep(new Operation("remove", propertyAddress));
                Operation addOperation = new Operation("add", propertyAddress);
                addOperation.addAdditionalProperty("value", newConfigConnectionPropertyValue);
                updateOperation.addStep(addOperation);
            }
        }

        // 5. Update config if needed
        if (updateOperation.numberOfSteps() > 0) {
            Result res = getASConnection().execute(updateOperation);
            if (res.isSuccess()) {
                configurationUpdateReport.setStatus(SUCCESS);
            } else {
                configurationUpdateReport.setStatus(FAILURE);
View Full Code Here

        }
        PropertyList listPropertyWrapper = config.getList(connPropPluginConfigPropertyName);
        Map<String, String> connectionPropertiesAsMap = getConnectionPropertiesAsMap(listPropertyWrapper, keyName);
        // if no conn or xa props supplied in the create resource request, skip and continue
        if (!connectionPropertiesAsMap.isEmpty()) {
            CompositeOperation cop = new CompositeOperation();
            for (Map.Entry<String, String> connectionProperty : connectionPropertiesAsMap.entrySet()) {
                Address propertyAddress = new Address(datasourceAddress);
                propertyAddress.add(connPropAttributeNameOnServer, connectionProperty.getKey());
                Operation op = new Operation("add", propertyAddress);
                op.addAdditionalProperty("value", connectionProperty.getValue());
                cop.addStep(op);
            }
            Result res = getASConnection().execute(cop);
            if (!res.isSuccess()) {
                report.setErrorMessage("Datasource was added, but setting " + connPropAttributeNameOnServer
                    + " failed: " + res.getFailureDescription());
View Full Code Here

            return "You need to provide either a " + CONNECTOR_ATTRIBUTE + " name OR a discovery-group-name.";
        }

        @Override
        public Operation getBatchOperation() {
            CompositeOperation compositeOperation = new CompositeOperation();
            if (hasDiscoveryGroupName()) {
                compositeOperation.addStep(new UndefineAttribute(address, CONNECTOR_ATTRIBUTE));
                compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration
                    .getSimpleValue(DISCOVERY_GROUP_NAME)));
            } else {
                compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME));
                compositeOperation.addStep(new WriteAttribute(address, CONNECTOR_ATTRIBUTE, Collections.singletonMap(
                    configuration.getMap(CONNECTOR_PROPERTY).getSimpleValue("name:0", EMPTY_STRING), null)));
            }
            return compositeOperation;
        }
View Full Code Here

            return "You need to provide either static connectors name OR a discovery-group-name.";
        }

        @Override
        public Operation getBatchOperation() {
            CompositeOperation compositeOperation = new CompositeOperation();
            if (hasDiscoveryGroupName()) {
                compositeOperation.addStep(new UndefineAttribute(address, STATIC_CONNECTORS_ATTRIBUTE));
                compositeOperation.addStep(new WriteAttribute(address, DISCOVERY_GROUP_NAME, configuration
                    .getSimpleValue(DISCOVERY_GROUP_NAME)));
            } else {
                compositeOperation.addStep(new UndefineAttribute(address, DISCOVERY_GROUP_NAME));
                List<Property> propertyList = configuration.getList(STATIC_CONNECTORS_PROPERTY).getList();
                List<String> staticConnectors = new ArrayList<String>(propertyList.size());
                for (Property property : propertyList) {
                    if (property instanceof PropertySimple) {
                        PropertySimple propertySimple = (PropertySimple) property;
                        staticConnectors.add(propertySimple.getStringValue());
                    } else {
                        getLog().warn(property.getName() + " property has unexpected type: " + property.getClass());
                    }
                }
                compositeOperation.addStep(new WriteAttribute(address, STATIC_CONNECTORS_ATTRIBUTE, staticConnectors));
            }
            return compositeOperation;
        }
View Full Code Here

            PropertySimple runtimeNameProperty = parameters.getSimple("runtime-name");
            String runtimeName = null;
            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);
            } else {
View Full Code Here

TOP

Related Classes of org.rhq.modules.plugins.jbossas7.json.CompositeOperation$OperationHeaders

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.