su.nlq.prometheus.jmx.connection.remote.Connector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmx-prometheus-collector Show documentation
Show all versions of jmx-prometheus-collector Show documentation
Pipe for JMX MBeans to Prometheus
package su.nlq.prometheus.jmx.connection.remote;
import org.jetbrains.annotations.NotNull;
import javax.management.remote.JMXConnector;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public abstract class Connector {
private final @NotNull String address;
private final @NotNull Optional credentials;
protected Connector(@NotNull String address, @NotNull Optional credentials) {
this.address = address;
this.credentials = credentials;
}
public abstract @NotNull JMXConnector connect() throws IOException;
public final @NotNull String address() {
return address;
}
protected final @NotNull Map environment() {
final Map environment = new HashMap<>();
credentials.ifPresent(value -> environment.put(JMXConnector.CREDENTIALS, value));
return environment;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy