use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class SnapshotConverterTest method testPointConversion.
@Test
public void testPointConversion() {
MetricDimensions a = SnapshotConverter.convert(new Point(Collections.emptyMap()));
MetricDimensions b = SnapshotConverter.convert(new Point(new HashMap<>(0)));
MetricDimensions c = SnapshotConverter.convert((Point) null);
assertEquals(a.hashCode(), b.hashCode());
assertEquals(a, b);
assertEquals(a.hashCode(), c.hashCode());
assertEquals(a, c);
assertEquals(b.hashCode(), c.hashCode());
assertEquals(b, c);
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class DocumentApiMetrics method reportSuccessful.
public void reportSuccessful(DocumentOperationType documentOperationType, double latencyInSeconds) {
Point point = points.get(DocumentOperationStatus.OK).get(documentOperationType);
feedLatency.sample(latencyInSeconds, point);
feeds.add(point);
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class RateLimitingSearcherTestCase method testRateLimiting.
@Test
public void testRateLimiting() {
RateLimitingConfig.Builder rateLimitingConfig = new RateLimitingConfig.Builder();
rateLimitingConfig.maxAvailableCapacity(4);
rateLimitingConfig.capacityIncrement(2);
rateLimitingConfig.recheckForCapacityProbability(1.0);
ClusterInfoConfig.Builder clusterInfoConfig = new ClusterInfoConfig.Builder();
clusterInfoConfig.clusterId("testCluster");
clusterInfoConfig.nodeCount(4);
ManualClock clock = new ManualClock();
MetricReceiver.MockReceiver metric = new MetricReceiver.MockReceiver();
Chain<Searcher> chain = new Chain<Searcher>("test", new RateLimitingSearcher(new RateLimitingConfig(rateLimitingConfig), new ClusterInfoConfig(clusterInfoConfig), metric, clock), new CostSettingSearcher());
assertEquals("'rate' request are available initially", 2, tryRequests(chain, "id1"));
assertTrue("However, don't reject if we dryRun", executeWasAllowed(chain, "id1", true));
// causes 2 new requests to become available
clock.advance(Duration.ofMillis(1500));
assertEquals("'rate' new requests became available", 2, tryRequests(chain, "id1"));
assertEquals("Another id", 2, tryRequests(chain, "id2"));
clock.advance(Duration.ofMillis(1000000));
assertEquals("'maxAvailableCapacity' request became available", 4, tryRequests(chain, "id2"));
assertFalse("If quota is set to 0, all requests are rejected, even initially", executeWasAllowed(chain, "id3", 0));
clock.advance(Duration.ofMillis(1000000));
assertTrue("A single query which costs more than capacity is allowed as cost is calculated after allowing it", executeWasAllowed(chain, "id1", 8, 8, false));
assertFalse("capacity is -4: disallowing", executeWasAllowed(chain, "id1"));
clock.advance(Duration.ofMillis(1000));
assertFalse("capacity is -2: disallowing", executeWasAllowed(chain, "id1"));
clock.advance(Duration.ofMillis(1000));
assertFalse("capacity is 0: disallowing", executeWasAllowed(chain, "id1"));
clock.advance(Duration.ofMillis(1000));
assertTrue(executeWasAllowed(chain, "id1"));
// check metrics
Map<Point, UntypedMetric> map = metric.getSnapshot().getMapForMetric("requestsOverQuota");
assertEquals(requestsToTry - 2 + 1 + requestsToTry - 2 + 3, map.get(metric.point("id", "id1")).getCount());
assertEquals(requestsToTry - 2 + requestsToTry - 4, map.get(metric.point("id", "id2")).getCount());
}
use of com.yahoo.metrics.simple.Point in project vespa by vespa-engine.
the class RateLimitingBenchmark method rejectedRequests.
private int rejectedRequests(int id) {
Point context = metric.pointBuilder().set("id", toClientId(id)).build();
UntypedMetric rejectedRequestsMetric = metricSnapshot.getMapForMetric("requestsOverQuota").get(context);
if (rejectedRequestsMetric == null)
return 0;
return (int) rejectedRequestsMetric.getCount();
}
Aggregations