Examples of ReadAttribute


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

            if (currentNodeIsModuleType) {//if is an actual Module Option Type then update attribute retrieved.
                attribute = ModuleOptionsComponent.attributeMap.get(resourceType.getName());
            }

            //get the current attribute value
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));
                if (currentNodeIsModuleType) {//grab first available module type
                    Value loaded = currentAttributeState.get(0);
                    //populate configuration
                    populateCodeFlagType(configuration, attribute, loaded);
                } else {//Need to locate specific module type
                    //locate specific node and populate the config
                    //Ex."login-modules:";
                    String moduleTypeIdentifier = attribute + ":";
                    int index = path.indexOf(moduleTypeIdentifier);
                    String loginModuleIndex = path.substring(index + moduleTypeIdentifier.length());
                    int lmi = Integer.valueOf(loginModuleIndex);//Ex 0,1,30
                    if (currentAttributeState.size() > lmi) {//then retrieve.
                        Value loaded = currentAttributeState.get(lmi);
                        //populate configuration
                        populateCodeFlagType(configuration, attribute, loaded);
                    }
                }
            }
            //read attribute
            return configuration;
        }
        //Module Options child, Ex. 'Login Modules (Classic', ..-Managed, .. - Profile
        else if (supportsLoginModuleOptionType(grandParentType)) {
            //get type and lookup supported node and type
            String attribute = ModuleOptionsComponent.attributeMap.get(grandParentType.getName());

            //get the current attribute value
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));

                //locate specific node and populate the config
                //Ex."login-modules:";
                String moduleTypeIdentifier = attribute + ":";
                int index = path.indexOf(moduleTypeIdentifier);
                String loginModuleIndex = path.substring(index + moduleTypeIdentifier.length());
                String[] split = loginModuleIndex.split(",");
                int lmi = Integer.valueOf(split[0]);//Ex 0,1,30
                if (lmi < currentAttributeState.size()) {//then proceed
                    Value loaded = currentAttributeState.get(lmi);
                    //populate configuration: module-options
                    LinkedHashMap<String, Object> currentModuleOptions = loaded.getOptions();

                    //This must match exactly the mapping identifier from descriptor, otherwise loadResource fails silently.
                    String id = "Module Options";
                    PropertyMap map = new PropertyMap(id);
                    for (String key : currentModuleOptions.keySet()) {
                        PropertySimple option = new PropertySimple(key, currentModuleOptions.get(key));
                        map.put(option);
                    }
                    if (!currentModuleOptions.isEmpty()) {//check that keyset is non empty before adding to config.
                        configuration.put(map);
                    }
                }
            }
            return configuration;
        } else {//otherwise default subsystem discovery behavior.
            ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
            ConfigurationLoadDelegate delegate = new ConfigurationLoadDelegate(configDef, getASConnection(), address,
                includeRuntime);
            configuration = delegate.loadResourceConfiguration();

            // Read server state
            ReadAttribute op = new ReadAttribute(getAddress(), "name");
            executeAndGenerateServerUpdateIfNecessary(configuration, op);
            return configuration;
        }
    }
View Full Code Here

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

            if (currentNodeIsModuleType) {
                attribute = ModuleOptionsComponent.attributeMap.get(resourceType.getName());
            }

            //get the current attribute value. Will write module types back out exactly as read in with these new updates
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {
                List<String> entries = (List<String>) result.getResult();

                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
                currentAttributeState = ModuleOptionsComponent.populateSecurityDomainModuleOptions(result,
                    ModuleOptionsComponent.loadModuleOptionType(attribute));

                //retrieve current config changes   
                Configuration conf = report.getConfiguration();

                if (currentNodeIsModuleType) {//grab first available module type
                    Value loaded = currentAttributeState.get(0);
                    //iterate over properties and update values appropriately
                    for (String pKey : conf.getSimpleProperties().keySet()) {
                        if (pKey.equals("flag")) {
                            loaded.setFlag(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("code")) {
                            loaded.setCode(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("type")) {
                            loaded.setType(conf.getSimpleProperties().get(pKey).getStringValue());
                        }
                    }
                    Operation write = new WriteAttribute(address);
                    write.addAdditionalProperty("name", attribute);//attribute to execute on

                    //now complete the write operation by updating the value
                    write.addAdditionalProperty("value", (Object) currentAttributeState);
                    executeWriteAndGenerateAs7ServerUpdate(report, conf, write);
                } else {//Need to locate specific module type

                //locate specific node and populate the config
                    String loginModuleIdentifier = attribute + ":";
                int index = path.indexOf(loginModuleIdentifier);
                String loginModuleIndex = path.substring(index + loginModuleIdentifier.length());
                int lmi = Integer.valueOf(loginModuleIndex);//Ex 0,1,30
                Value valueObject = currentAttributeState.get(lmi);

                //iterate over properties and update values appropriately
                for (String pKey : conf.getSimpleProperties().keySet()) {
                    if (pKey.equals("flag")) {
                        valueObject.setFlag(conf.getSimpleProperties().get(pKey).getStringValue());
                    } else if (pKey.equals("code")) {
                        valueObject.setCode(conf.getSimpleProperties().get(pKey).getStringValue());
                        } else if (pKey.equals("type")) {
                            valueObject.setType(conf.getSimpleProperties().get(pKey).getStringValue());
                    }
                }
                Operation write = new WriteAttribute(address);
                write.addAdditionalProperty("name", attribute);//attribute to execute on

                //now complete the write operation by updating the value
                write.addAdditionalProperty("value", (Object) currentAttributeState);
                executeWriteAndGenerateAs7ServerUpdate(report, conf, write);
                }
            }
        } else if (supportsLoginModuleOptionType(grandParentType)) {//Module Options child.
            //get type and lookup supported node and type
            String attribute = ModuleOptionsComponent.attributeMap.get(grandParentType.getName());

            //get the current attribute value. Will write module types back out exactly as read in with these new updates
            ReadAttribute op = new ReadAttribute(address, attribute);
            Result result = getASConnection().execute(op);
            if (result.isSuccess()) {

                //populate attribute values
                List<Value> currentAttributeState = new ArrayList<Value>();
View Full Code Here

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

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

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

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

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

                "Unexpected IOException while converting host config file path to its canonical form", e);
        }
    }

    private <T> T getServerAttribute(ASConnection connection, String attributeName) {
        Operation op = new ReadAttribute(null, attributeName);
        Result res = connection.execute(op);
        if (!res.isSuccess()) {
            throw new InvalidPluginConfigurationException("Could not connect to remote server ["
                + res.getFailureDescription() + "]. Did you enable management?");
        }
View Full Code Here

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

            ComplexRequest request = null;
            Operation op;
            if (reqName.contains(":")) {
               request = ComplexRequest.create(reqName);
               op = new ReadAttribute(getAddress(), request.getProp());
            } else {
               op = new ReadAttribute(getAddress(), reqName); // TODO batching
            }

            Result res = getASConnection().execute(op);
            if (!res.isSuccess()) {
               log.warn("Getting metric [" + req.getName() + "] at [ " + getAddress() + "] failed: " + res.getFailureDescription());
View Full Code Here

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

    * Get the availability check based on if the cache is actually running or not
    * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
    */
   @Override
   public AvailabilityType getAvailability() {
      ReadAttribute op = new ReadAttribute(getAddress(), "cache-status");
      Result res = getASConnection().execute(op);
      if (res != null && res.isSuccess()) {
         if ("RUNNING".equals(res.getResult())) {
             return AvailabilityType.UP;
         }
View Full Code Here

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

    * Get the availability check based on if the cache is actually running or not
    * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
    */
   @Override
   public AvailabilityType getAvailability() {
      ReadAttribute op = new ReadAttribute(getAddress(), "cache-status");
      Result res = getASConnection().execute(op);
      if (res != null && res.isSuccess()) {
         if ("RUNNING".equals(res.getResult())) {
             return AvailabilityType.UP;
         }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.