Package org.jmxtrans.embedded.output

Examples of org.jmxtrans.embedded.output.OutputWriter


        embeddedJmxTrans.addQuery(query);

        final AtomicInteger exportCount = new AtomicInteger();
        final AtomicInteger exportResultCount = new AtomicInteger();

        OutputWriter outputWriter = new AbstractOutputWriter() {
            @Override
            public void write(Iterable<QueryResult> results) {
                exportCount.incrementAndGet();
                for (QueryResult result : results) {
                    exportResultCount.incrementAndGet();
View Full Code Here


        embeddedJmxTrans.addQuery(query);

        final AtomicInteger exportCount = new AtomicInteger();
        final AtomicInteger exportResultCount = new AtomicInteger();

        OutputWriter outputWriter = new AbstractOutputWriter() {

            @Override
            public void write(Iterable<QueryResult> results) {
                exportCount.incrementAndGet();
                for (QueryResult result : results) {
                    exportResultCount.incrementAndGet();
                }
            }
        };
        outputWriter.setEnabled(false);

        embeddedJmxTrans.getOutputWriters().add(outputWriter);
        assertThat(query.getOutputWriters().size(), is(0));
        assertThat(query.getEffectiveOutputWriters().size(), is(0));
    }
View Full Code Here

        if (outputWritersNode.isMissingNode()) {
        } else if (outputWritersNode.isArray()) {
            for (JsonNode outputWriterNode : outputWritersNode) {
                try {
                    String className = outputWriterNode.path("@class").asText();
                    OutputWriter outputWriter = (OutputWriter) Class.forName(className).newInstance();
                    JsonNode deprecatedEnabledNode = outputWriterNode.path("enabled");
                    if (!deprecatedEnabledNode.isMissingNode()) {
                        logger.warn("OutputWriter {}, deprecated usage of attribute 'enabled', settings{ \"enabled\":... } should be used instead");
                        outputWriter.setEnabled(deprecatedEnabledNode.asBoolean());
                    }
                    JsonNode settingsNode = outputWriterNode.path("settings");
                    if (settingsNode.isMissingNode()) {
                    } else if (settingsNode.isObject()) {
                        ObjectMapper mapper = new ObjectMapper();
                        @SuppressWarnings("unchecked")
                        Map<String, Object> settings = mapper.treeToValue(settingsNode, Map.class);
                        outputWriter.setSettings(settings);
                        if (settings.containsKey("enabled")) {
                            outputWriter.setEnabled(Boolean.valueOf(String.valueOf(settings.get("enabled"))));
                        }
                    } else {
                        logger.warn("Ignore invalid node {}", outputWriterNode);
                    }
                    logger.trace("Add {}", outputWriter);
View Full Code Here

        assertThat(query.getResultAlias(), is("test-with-outputwriter"));
        assertThat(query.getQueryAttributes().size(), is(1));
        QueryAttribute queryAttribute = query.getQueryAttributes().iterator().next();
        assertThat(queryAttribute.getName(), is("CollectionUsageThresholdCount"));
        assertThat(query.getOutputWriters().size(), is(1));
        OutputWriter outputWriter = query.getOutputWriters().get(0);
        assertThat(outputWriter, instanceOf(NoOpWriter.class));
    }
View Full Code Here

TOP

Related Classes of org.jmxtrans.embedded.output.OutputWriter

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.