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

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


    public void start(ResourceContext<T> context) throws Exception {
        this.context = context;
        pluginConfiguration = context.getPluginConfiguration();
        serverComponent = findServerComponent();
        path = pluginConfiguration.getSimpleValue("path");
        address = new Address(path);
        key = context.getResourceKey();
        myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/") + 1);
        includeRuntime = Boolean.parseBoolean(pluginConfiguration.getSimpleValue("includeRuntime", null));
    }
View Full Code Here


            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

            what = ""; // dummy value
            op = name;
        }
        Operation operation;

        Address theAddress = new Address();

        if (what.equals("server-group")) {
            String groupName = parameters.getSimpleValue("name", "");
            String profile = parameters.getSimpleValue("profile", "default");

            theAddress.add("server-group", groupName);

            operation = new Operation(op, theAddress);
            operation.addAdditionalProperty("profile", profile);
        } else if (what.equals("destination")) {
            theAddress.add(address);
            String newName = parameters.getSimpleValue("name", "");
            String type = parameters.getSimpleValue("type", "jms-queue").toLowerCase();
            theAddress.add(type, newName);
            PropertyList jndiNamesProp = parameters.getList("entries");
            if (jndiNamesProp == null || jndiNamesProp.getList().isEmpty()) {
                OperationResult fail = new OperationResult();
                fail.setErrorMessage("No jndi bindings given");
                return fail;
            }
            List<String> jndiNames = new ArrayList<String>();
            for (Property p : jndiNamesProp.getList()) {
                PropertySimple ps = (PropertySimple) p;
                jndiNames.add(ps.getStringValue());
            }

            operation = new Operation(op, theAddress);
            operation.addAdditionalProperty("entries", jndiNames);
            if (type.equals("jms-queue")) {
                PropertySimple ps = (PropertySimple) parameters.get("durable");
                if (ps != null) {
                    boolean durable = Boolean.parseBoolean(ps.getStringValue());
                    operation.addAdditionalProperty("durable", durable);
                }
                String selector = parameters.getSimpleValue("selector", "");
                if (!selector.isEmpty())
                    operation.addAdditionalProperty("selector", selector);
            }

        } else if (what.equals("domain")) {
            operation = new Operation(op, new Address());
        } else if (what.equals("subsystem")) {
            operation = new Operation(op, new Address(this.path));
        } else {
            // We have a generic operation so we pass it literally
            // with the parameters it has.
            operation = new Operation(op, new Address((path)));
            for (Property prop : parameters.getProperties()) {
                if (prop instanceof PropertySimple) {
                    PropertySimple ps = (PropertySimple) prop;
                    if (ps.getStringValue() != null) {
                        Object val = getObjectForProperty(ps, op);
View Full Code Here

        this.testConnection = connection;
    }

    public void setPath(String path) {
        this.path = path;
        this.address = new Address(path);
    }
View Full Code Here

    protected String getSocketBindingGroup() {
        throw new UnsupportedOperationException();
    }

    protected void collectMulticastAddressTrait(MeasurementReport report, MeasurementScheduleRequest request) {
        Address jgroupsUdpStackAddress = new Address(getServerAddress());
        jgroupsUdpStackAddress.add("subsystem", "jgroups");
        jgroupsUdpStackAddress.add("stack", "udp");
        jgroupsUdpStackAddress.add("transport", "TRANSPORT");

        String socketBinding;
        try {
            socketBinding = readAttribute(jgroupsUdpStackAddress, "socket-binding");
        } catch (Exception e) {
            socketBinding = null;
        }

        if (socketBinding != null) {
            Address jgroupsSocketBindingAddress = new Address(getServerAddress());
            String socketBindingGroup = getSocketBindingGroup();
            jgroupsSocketBindingAddress.add("socket-binding-group", socketBindingGroup);
            jgroupsSocketBindingAddress.add("socket-binding", socketBinding);
            String multicastHost = null;
            Integer multicastPort;
            try {
                try {
                    @SuppressWarnings("unchecked")
View Full Code Here

        if (content == null || content.isEmpty()) {
            // No content -> check for server group
            if (path.startsWith(("server-group="))) {
                // Server group has no content of its own - use the domain deployment
                String name = path.substring(path.lastIndexOf("=") + 1);
                op = new ReadResource(new Address("deployment", name));
                result = getASConnection().execute(op);
                if (result.isSuccess()) {
                    Map<String, Object> contentMap = (Map<String, Object>) result.getResult();
                    content = (List<Map<String, Object>>) contentMap.get("content");
                    if (content.get(0).containsKey("path")) {
                        String path = (String) content.get(0).get("path");
                        String relativeTo = (String) content.get(0).get("relative-to");
                        deploymentFile = getDeploymentFileFromPath(relativeTo, path);
                    } else if (content.get(0).containsKey("hash")) {
                        String base64Hash = ((Map<String, String>) content.get(0).get("hash")).get("BYTES_VALUE");
                        byte[] hash = Base64.decode(base64Hash);
                        ServerGroupComponent sgc = (ServerGroupComponent) context.getParentResourceComponent();
                        String baseDir = ((HostControllerComponent) sgc.context.getParentResourceComponent()).pluginConfiguration
                            .getSimpleValue("baseDir");
                        String contentPath = new File(baseDir, "/data/content").getAbsolutePath();
                        deploymentFile = getDeploymentFileFromHash(hash, contentPath);
                    }
                    return deploymentFile;
                }
            } else {
                getLog().warn(
                    "Could not determine the location of the deployment - the content descriptor wasn't found for deployment"
                        + getAddress() + ".");
                return null;
            }
        }

        Boolean archive = (Boolean) content.get(0).get("archive");
        if (archive != null && !archive) {
            getLog().debug("Exploded deployments not supported for retrieving the content.");
            return null;
        }

        File deploymentFile = null;
        if (content.get(0).containsKey("path")) {
            String path = (String) content.get(0).get("path");
            String relativeTo = (String) content.get(0).get("relative-to");
            deploymentFile = getDeploymentFileFromPath(relativeTo, path);
        } else if (content.get(0).containsKey("hash")) {
            String base64Hash = ((Map<String, String>) content.get(0).get("hash")).get("BYTES_VALUE");
            byte[] hash = Base64.decode(base64Hash);
            Address contentPathAddress;
            if (context.getParentResourceComponent() instanceof ManagedASComponent) {
                // -> managed server we need to check for host=x/server=y, but the path brings host=x,server-config=y
                String p = ((ManagedASComponent) context.getParentResourceComponent()).getPath();
                p = p.replaceAll("server-config=", "server=");
                contentPathAddress = new Address(p);
                contentPathAddress.add("core-service", "server-environment");
            } else {
                // standalone
                contentPathAddress = new Address("core-service", "server-environment");
            }
            op = new ReadAttribute(contentPathAddress, "content-dir");
            result = getASConnection().execute(op);

            String contentPath;
View Full Code Here

            if (relativeTo.startsWith("jboss.server")) {
                relativeTo = relativeTo.substring("jboss.server.".length());
                relativeTo = relativeTo.replace('.', '-');

                //now look for the transformed relativeTo in the server environment
                Operation op = new ReadAttribute(new Address("core-service", "server-environment"), relativeTo);
                Result res = getASConnection().execute(op);

                relativeTo = (String) res.getResult();

                return new File(relativeTo, path);
View Full Code Here

        return errorMessage;
    }

    private boolean isServerUp(ASConnection connection) {
        Operation op = new ReadAttribute(new Address(), "release-version");
        try {
            org.rhq.modules.plugins.jbossas7.json.Result res = connection.execute(op);
            if (res.isSuccess()) { // If op succeeds, server is not down
                return true;
            }
View Full Code Here

            }
        } else if ("add-custom-metric".equals(name)) {
            //update the address and operation name. Use class name as identifier.
            String newOperationDestination = getAddress().getPath() + DYNAMIC_PROVIDER
                + ",custom-load-metric,custom-load-metric=" + retrieveNewIdentifier(parameters, "class");
            op = new Operation("add", new Address(newOperationDestination));
            addAdditionalToOp(op, parameters, "class", false);
            addAdditionalToOp(op, parameters, "weight", false);
            addAdditionalToOp(op, parameters, "capacity", true);
            result = getASConnection().execute(op);
            if ((result != null) && (result.isSuccess())) {
                operationResult.setSimpleResult("Success");
            }
        } else if ("remove-custom-metric".equals(name)) {
            //update the address and operation name. Use class name as identifier.
            String newOperationDestination = getAddress().getPath() + DYNAMIC_PROVIDER
                + ",custom-load-metric,custom-load-metric=" + retrieveNewIdentifier(parameters, "class");
            op = new Operation("remove", new Address(newOperationDestination));
            addAdditionalToOp(op, parameters, "class", false);
            result = getASConnection().execute(op);
            if ((result != null) && (result.isSuccess())) {
                operationResult.setSimpleResult("Success");
            }
        } else if ("add-metric".equals(name)) {
            //update the address and operation name. Use class name as identifier.
            String newOperationDestination = getAddress().getPath() + DYNAMIC_PROVIDER
                + ",custom-load-metric,load-metric=" + retrieveNewIdentifier(parameters, "type");
            op = new Operation("add", new Address(newOperationDestination));
            addAdditionalToOp(op, parameters, "weight", false);
            addAdditionalToOp(op, parameters, "capacity", true);
            addAdditionalToOp(op, parameters, "type", false);
            result = getASConnection().execute(op);
            if ((result != null) && (result.isSuccess())) {
                operationResult.setSimpleResult("Success");
            }
        } else if ("remove-metric".equals(name)) {
            //update the address and operation name. Use class name as identifier.
            String newOperationDestination = getAddress().getPath() + DYNAMIC_PROVIDER
                + ",custom-load-metric,load-metric=" + retrieveNewIdentifier(parameters, "type");
            op = new Operation("remove", new Address(newOperationDestination));
            addAdditionalToOp(op, parameters, "type", false);
            result = getASConnection().execute(op);
            if ((result != null) && (result.isSuccess())) {
                operationResult.setSimpleResult("Success");
            }
View Full Code Here

        return identifier;
    }

    @Override
    public Address getAddress() {
        return new Address(key);
    }
View Full Code Here

TOP

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

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.