Package org.rhq.core.domain.configuration

Examples of org.rhq.core.domain.configuration.PropertyList


    public void testListCompare() {
        Configuration c1 = new Configuration();
        Configuration c2 = new Configuration();

        c1.put(new PropertyList("listA", new Property[] { new PropertySimple("foo", "111") }));
        c2.put(new PropertyList("listA", new Property[] { new PropertySimple("foo", "111") }));

        assert c1.equals(c1); // can compare itself
        assert c2.equals(c2); // can compare itself
        assert c1.equals(c2);
        assert c2.equals(c1);
View Full Code Here


    public void testListInListCompare() {
        Configuration c1 = new Configuration();
        Configuration c2 = new Configuration();

        PropertyList listInner1 = new PropertyList("inner", new Property[] { new PropertySimple("uno", 111) });
        PropertyList listInner2 = new PropertyList("inner", new Property[] { new PropertySimple("uno", 111) });
        PropertyList listOuter1 = new PropertyList("outer", new Property[] { listInner1 });
        PropertyList listOuter2 = new PropertyList("outer", new Property[] { listInner2 });

        c1.put(listOuter1);
        c2.put(listOuter2);

        assert c1.equals(c1); // can compare itself
View Full Code Here

    public void testMapAndListCompare() {
        Configuration c1 = new Configuration();
        Configuration c2 = new Configuration();

        PropertyList listInner1 = new PropertyList("inner", new Property[] { new PropertySimple("uno", 111) });
        PropertyList listInner2 = new PropertyList("inner", new Property[] { new PropertySimple("uno", 111) });
        PropertyMap mapOuter1 = new PropertyMap("outer", new Property[] { listInner1,
            new PropertySimple("hello", "world!") });
        PropertyMap mapOuter2 = new PropertyMap("outer", new Property[] { listInner2,
            new PropertySimple("hello", "world!") });
View Full Code Here

        configuration.setNotes("- Added new login manager");

        // Automatically set by JON server
        configuration.setVersion(2);

        PropertyList propertyList = new PropertyList("applicationPolicies");

        PropertyMap applicationPolicy1 = new PropertyMap("jmx-console");
        propertyList.add(applicationPolicy1);
        // ------------------------------------
        // Application Policy Properties

        /* The following properties are used to describe the data found in the following
         * example security domain:
View Full Code Here

        verifyDriftDefinition(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
            @Override
            public void assertDriftTemplate(DriftDefinitionTemplate driftTemplate) throws Exception {
                Configuration config = driftTemplate.getConfiguration();
                PropertyList includes = config.getList(DriftConfigurationDefinition.PROP_INCLUDES);

                assertNotNull(includes, "Expected to find default property set for <includes>");
                assertEquals(includes.getList().size(), 2,
                    "Expected <includes> property list to have two property elements.");

                PropertyMap include1 = (PropertyMap) includes.getList().get(0);
                PropertySimple path1 = include1.getSimple(DriftConfigurationDefinition.PROP_PATH);
                PropertySimple pattern1 = include1.getSimple(DriftConfigurationDefinition.PROP_PATTERN);

                assertNotNull(path1, "Expected to find a simple property for the path of the first <include>");
                assertEquals(path1.getStringValue(), "lib", "The value is wrong for the path of the first <include>");

                assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <include>");
                assertEquals(pattern1.getStringValue(), "*.jar",
                    "The value is wrong for the pattern of the first <include>");

                PropertyMap include2 = (PropertyMap) includes.getList().get(1);
                PropertySimple path2 = include2.getSimple(DriftConfigurationDefinition.PROP_PATH);
                PropertySimple pattern2 = include2.getSimple(DriftConfigurationDefinition.PROP_PATTERN);

                assertNotNull(path2, "Expected to find a simple property for the path of the second <include>");
                assertEquals(path2.getStringValue(), "conf", "The value is wrong for the path of the second <include>");
View Full Code Here

        verifyDriftDefinition(descriptor, "TestServer", "test1", new AssertDriftTemplateRunnable() {
            @Override
            public void assertDriftTemplate(DriftDefinitionTemplate driftTemplate) throws Exception {
                Configuration config = driftTemplate.getConfiguration();
                PropertyList excludes = config.getList(DriftConfigurationDefinition.PROP_EXCLUDES);

                assertNotNull(excludes, "Expected to find default property set for <excludes>");
                assertEquals(excludes.getList().size(), 2,
                    "Expected <excludes> property list to have two property elements.");

                PropertyMap exclude1 = (PropertyMap) excludes.getList().get(0);
                PropertySimple path1 = exclude1.getSimple(DriftConfigurationDefinition.PROP_PATH);
                PropertySimple pattern1 = exclude1.getSimple(DriftConfigurationDefinition.PROP_PATTERN);

                assertNotNull(path1, "Expected to find a simple property for the path of the first <exclude>");
                assertEquals(path1.getStringValue(), "lib", "The value is wrong for the path of the first <exclude>");

                assertNotNull(pattern1, "Expected to find a simple property for the pattern of the first <exclude>");
                assertEquals(pattern1.getStringValue(), "*.jar",
                    "The value is wrong for the pattern of the first <exclude>");

                PropertyMap exclude2 = (PropertyMap) excludes.getList().get(1);
                PropertySimple path2 = exclude2.getSimple(DriftConfigurationDefinition.PROP_PATH);
                PropertySimple pattern2 = exclude2.getSimple(DriftConfigurationDefinition.PROP_PATTERN);

                assertNotNull(path2, "Expected to find a simple property for the path of the second <exclude>");
                assertEquals(path2.getStringValue(), "conf", "The value is wrong for the path of the second <exclude>");
View Full Code Here

        report.getConfiguration().remove("snapshots");
        super.updateResourceConfiguration(report);
    }

    private PropertyList getSnapshotsWithDetails() {
        PropertyList listOfSnapshots = new PropertyList("snapshots");

        KeyspaceComponent parentKeyspace = this.getParentKeyspace();
        PropertyList parentDataFileLocations = parentKeyspace.getKeySpaceDataFileLocations();

        for (Property directory : parentDataFileLocations.getList()) {
            String directoryName = ((PropertySimple) directory).getStringValue();
            directoryName += "/" + this.getResourceContext().getPluginConfiguration().getSimpleValue("name");
            directoryName += "/snapshots";

            File snapshotDirectory = new File(directoryName);
View Full Code Here

    private OperationResult restoreSnapshot(Configuration parameters) {
        OperationResult result = new OperationResult();

        //1. Find the list of snapshots discovered
        String requestedSnapshotName = parameters.getSimpleValue("snapshotName");
        PropertyList listOfSnapShots = this.getSnapshotsWithDetails();

        String snapshotDirectoryName = null;
        for (Property property : listOfSnapShots.getList()) {
            String snapshotName = ((PropertyMap) property).getSimpleValue("name", null);
            if (requestedSnapshotName.equals(snapshotName)) {
                snapshotDirectoryName = ((PropertyMap) property).getSimpleValue("folder", null);
                break;
            }
        }

        //2. Find out if the discovered snapshot still exists on disk
        if (snapshotDirectoryName == null) {
            result.setErrorMessage("Restore failed! The snapshot does not exist!");
            return result;
        }

        File snapshotDirectory = new File(snapshotDirectoryName);
        if (!snapshotDirectory.exists() || !snapshotDirectory.isDirectory()) {
            result.setErrorMessage("Restore failed! The snapshot does not exist on disk!");
            return result;
        }

        //3. Shutdown Cassandra
        CassandraNodeComponent node = this.getParentKeyspace().getCassandraNodeComponent();
        node.shutdownNode();

        //4. Remove the entire commit log
        KeyspaceComponent parentKeyspace = this.getParentKeyspace();

        parentKeyspace.clearCommitLog();

        //5. Copy the snapshot files to the column family folders
        PropertyList parentDataFileLocations = parentKeyspace.getKeySpaceDataFileLocations();

        for (Property dataFileDirectoryProperty : parentDataFileLocations.getList()) {
            String columnFamilyDirectoryName = ((PropertySimple) dataFileDirectoryProperty).getStringValue();
            columnFamilyDirectoryName += "/" + this.getResourceContext().getPluginConfiguration().getSimpleValue("name");

            File columnFamilyDirectory = new File(columnFamilyDirectoryName);
            if(columnFamilyDirectory.exists()){
View Full Code Here

                if (intermediaryResult.getErrorMessage() != null) {
                    result.setErrorMessage(intermediaryResult.getErrorMessage());
                } else {
                    String output = intermediaryConfig.getSimpleValue(OPERATION_RESULT_OUTPUT, "");
                    if (output.length() > 0) {
                        PropertyList list = new PropertyList("networkConnections");
                        config.put(list);

                        String[] lines = output.split("\n");
                        for (String line : lines) {
                            Matcher matcher = pattern.matcher(line);
                            if (matcher.matches()) {
                                PropertyMap map = new PropertyMap("networkConnection");
                                list.add(map);
                                map.put(new PropertySimple("localHost", matcher.group(1)));
                                map.put(new PropertySimple("localPort", matcher.group(2)));
                                map.put(new PropertySimple("remoteHost", matcher.group(3)));
                                map.put(new PropertySimple("remotePort", matcher.group(4)));
                            }
                        }
                    }
                }
            } else {
                log.info("Getting network connections using the internal mechanism");
                result = new OperationResult();
                Configuration config = result.getComplexResults();
                config.put(new PropertySimple("detectionMechanism", mechanism.toString()));

                try {
                    List<NetConnection> conns;
                    conns = getResourcContext().getSystemInformation().getNetworkConnections(null, 0);
                    config.put(new PropertySimple(OPERATION_RESULT_EXITCODE, "0"));
                    if (conns.size() > 0) {
                        PropertyList list = new PropertyList("networkConnections");
                        config.put(list);
                        for (NetConnection conn : conns) {
                            PropertyMap map = new PropertyMap("networkConnection");
                            list.add(map);
                            map.put(new PropertySimple("localHost", conn.getLocalAddress()));
                            map.put(new PropertySimple("localPort", conn.getLocalPort()));
                            map.put(new PropertySimple("remoteHost", conn.getRemoteAddress()));
                            map.put(new PropertySimple("remotePort", conn.getRemotePort()));
                        }
View Full Code Here

        return result;
    }

    protected OperationResult updateSeedsList(Configuration params) {
        PropertyList list = params.getList("seedsList");
        List<String> addresses = getAddresses(list);

        OperationResult result = new OperationResult();
        try {
            updateSeedsList(addresses);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.configuration.PropertyList

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.