/** Create a new instance. */ public StatelessRegistry(Clock clock, StatelessConfig config) { super(clock, config); this.enabled = config.enabled(); this.frequency = config.frequency(); this.meterTTL = config.meterTTL().toMillis(); this.connectTimeout = (int) config.connectTimeout().toMillis(); this.readTimeout = (int) config.readTimeout().toMillis(); this.uri = URI.create(config.uri()); this.batchSize = config.batchSize(); this.commonTags = config.commonTags(); this.client = HttpClient.create(this); }
/** * Returns the URI for the aggregation service. The default is * {@code http://localhost:7101/api/v4/update}. */ default String uri() { String v = get("stateless.uri"); return (v == null) ? "http://localhost:7101/api/v4/update" : v; }
@Test public void explicitlyDisabled() { Map<String, String> props = new HashMap<>(); props.put("stateless.enabled", "false"); StatelessConfig config = props::get; Assertions.assertFalse(config.enabled()); }
@Test public void explicitlyEnabled() { Map<String, String> props = new HashMap<>(); props.put("stateless.enabled", "true"); StatelessConfig config = props::get; Assertions.assertTrue(config.enabled()); }
/** Create a new instance. */ public StatelessRegistry(Clock clock, StatelessConfig config) { super(clock, config); this.enabled = config.enabled(); this.frequency = config.frequency(); this.meterTTL = config.meterTTL().toMillis(); this.connectTimeout = (int) config.connectTimeout().toMillis(); this.readTimeout = (int) config.readTimeout().toMillis(); this.uri = URI.create(config.uri()); this.batchSize = config.batchSize(); this.commonTags = config.commonTags(); this.client = HttpClient.create(this); }
/** * Returns the URI for the aggregation service. The default is * {@code http://localhost:7101/api/v4/update}. */ default String uri() { String v = get("stateless.uri"); return (v == null) ? "http://localhost:7101/api/v4/update" : v; }
@Test public void enabledBadValue() { Map<String, String> props = new HashMap<>(); props.put("stateless.enabled", "abc"); StatelessConfig config = props::get; Assertions.assertFalse(config.enabled()); } }
/** * Returns true if publishing is enabled. Default is true. */ default boolean enabled() { String v = get("stateless.enabled"); return v == null || Boolean.valueOf(v); }
@Test public void enabledByDefault() { Map<String, String> props = Collections.emptyMap(); StatelessConfig config = props::get; Assertions.assertTrue(config.enabled()); }
/** * Returns the number of measurements per request to use for the backend. If more * measurements are found, then multiple requests will be made. The default is * 10,000. */ default int batchSize() { String v = get("stateless.batchSize"); return (v == null) ? 10000 : Integer.parseInt(v); }
/** * Returns true if publishing is enabled. Default is true. */ default boolean enabled() { String v = get("stateless.enabled"); return v == null || Boolean.valueOf(v); }
/** * Returns the number of measurements per request to use for the backend. If more * measurements are found, then multiple requests will be made. The default is * 10,000. */ default int batchSize() { String v = get("stateless.batchSize"); return (v == null) ? 10000 : Integer.parseInt(v); }
/** * Returns the connection timeout for requests to the backend. The default is * 1 second. */ default Duration connectTimeout() { String v = get("stateless.connectTimeout"); return (v == null) ? Duration.ofSeconds(1) : Duration.parse(v); }
/** * Returns the read timeout for requests to the backend. The default is * 10 seconds. */ default Duration readTimeout() { String v = get("stateless.readTimeout"); return (v == null) ? Duration.ofSeconds(10) : Duration.parse(v); }
/** * Returns the frequency to collect data and forward to the aggregation service. The * default is 5 seconds. */ default Duration frequency() { String v = get("stateless.enabled"); return v == null ? Duration.ofSeconds(5) : Duration.parse(v); }
/** * Returns the TTL for meters that do not have any activity. After this period the meter * will be considered expired and will not get reported. Default is 15 minutes. */ default Duration meterTTL() { String v = get("stateless.meterTTL"); return (v == null) ? Duration.ofMinutes(15) : Duration.parse(v); }
/** * Returns the TTL for meters that do not have any activity. After this period the meter * will be considered expired and will not get reported. Default is 15 minutes. */ default Duration meterTTL() { String v = get("stateless.meterTTL"); return (v == null) ? Duration.ofMinutes(15) : Duration.parse(v); }
/** * Returns the frequency to collect data and forward to the aggregation service. The * default is 5 seconds. */ default Duration frequency() { String v = get("stateless.enabled"); return v == null ? Duration.ofSeconds(5) : Duration.parse(v); }
/** * Returns the connection timeout for requests to the backend. The default is * 1 second. */ default Duration connectTimeout() { String v = get("stateless.connectTimeout"); return (v == null) ? Duration.ofSeconds(1) : Duration.parse(v); }
/** * Returns the read timeout for requests to the backend. The default is * 10 seconds. */ default Duration readTimeout() { String v = get("stateless.readTimeout"); return (v == null) ? Duration.ofSeconds(10) : Duration.parse(v); }