com.google.common.net.PercentEscaper Java Examples

The following examples show how to use com.google.common.net.PercentEscaper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Configuration.java    From azure-cosmosdb-java with MIT License 5 votes vote down vote up
@SuppressWarnings("UnstableApiUsage")
private synchronized MeterRegistry graphiteMeterRegistry(String serviceAddress) {

    if (this.graphiteMeterRegistry == null) {

        HostAndPort address = HostAndPort.fromString(serviceAddress);

        String host = address.getHost();
        int port = address.getPortOrDefault(DEFAULT_GRAPHITE_SERVER_PORT);
        boolean enabled = !Boolean.getBoolean("cosmos.monitoring.graphite.disabled");
        Duration step = Duration.ofSeconds(Integer.getInteger("cosmos.monitoring.graphite.step", this.printingInterval));

        final GraphiteConfig config = new GraphiteConfig() {

            private String[] tagNames = { "source" };

            @Override
            @Nullable
            public String get(@Nullable String key) {
                return null;
            }

            @Override
            public boolean enabled() {
                return enabled;
            }

            @Override
            @Nullable
            public String host() {
                return host;
            }

            @Override
            @Nullable
            public int port() {
                return port;
            }

            @Override
            @Nullable
            public Duration step() {
                return step;
            }

            @Override
            @Nullable
            public String[] tagsAsPrefix() {
                return this.tagNames;
            }
        };

        this.graphiteMeterRegistry = new GraphiteMeterRegistry(config, Clock.SYSTEM);
        String source;

        try {
            PercentEscaper escaper = new PercentEscaper("_-", false);
            source = escaper.escape(InetAddress.getLocalHost().getHostName());
        } catch (UnknownHostException error) {
            source = "unknown-host";
        }

        this.graphiteMeterRegistry.config()
            .namingConvention(NamingConvention.dot)
            .commonTags("source", source);
    }

    return this.graphiteMeterRegistry;
}
 
Example #2
Source File: ODataFesParser.java    From arctic-sea with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@code ODataFesParser}.
 */
public ODataFesParser() {
    this.urlEscaper = new PercentEscaper("-_.*", false);
    this.odata = new ODataImpl();
    this.csdlProvider = new ObservationCsdlEdmProvider();
    this.edm = new EdmProviderImpl(this.csdlProvider);
    // >=4.2.0
    this.parser = new Parser(this.edm, this.odata);
    // >=4.0.0 <4.2.0
    // this.parser = new Parser();

}