All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.metricssampler.cmd.MetadataCommand Maven / Gradle / Ivy

The newest version!
package org.metricssampler.cmd;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import org.metricssampler.config.InputConfig;
import org.metricssampler.reader.MetricName;
import org.metricssampler.reader.MetricsReader;
import org.metricssampler.resources.SamplerStats;
import org.metricssampler.service.GlobalObjectFactory;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

@Parameters(commandNames="metadata", commandDescriptionKey="help.metadata.command")
public class MetadataCommand extends ConfigurationCommand {
	@Parameter(names="-n", descriptionKey="help.param.inputs")
	protected List inputs = new LinkedList();

	@Override
	protected void runBootstrapped() {
		final Set names = new HashSet<>();
		names.addAll(inputs);
		final GlobalObjectFactory factory = bootstrapper;
		for(final InputConfig input : bootstrapper.getConfiguration().getInputs()) {
			SamplerStats.init();
			if (names.isEmpty() || names.contains(input.getName())) {
				final MetricsReader reader = factory.newReaderForInput(input);
				reader.open();
				System.out.println("Reader: " + input.getName());
				for(final MetricName item : reader.readNames()) {
					System.out.println("\tName:" + item.getName());
					System.out.println("\tDescription:" + item.getDescription());
				}
				reader.close();
				SamplerStats.unset();
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy