use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class DataSkewDiagnoserTest method addMeasurements.
private void addMeasurements(MetricName metricExeCount, int i1, int i2, int i3) {
measurements.add(new Measurement(comp, "i1", metricExeCount.text(), now, i1));
measurements.add(new Measurement(comp, "i2", metricExeCount.text(), now, i2));
measurements.add(new Measurement(comp, "i3", metricExeCount.text(), now, i3));
}
use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class BackPressureSensorTest method registerStMgrInstanceMetricResponse.
static void registerStMgrInstanceMetricResponse(MetricsProvider metricsProvider, String metric, long value) {
Instant instant = Instant.ofEpochSecond(10);
Measurement measurement = new Measurement("__stmgr__", "stmgr-1", metric, instant, value);
Collection<Measurement> result = Collections.singletonList(measurement);
when(metricsProvider.getMeasurements(any(Instant.class), eq(DEFAULT_METRIC_DURATION), eq(metric), eq("__stmgr__"))).thenReturn(result);
}
use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class SlowInstanceDiagnoserTest method addMeasurements.
private void addMeasurements(BaseSensor.MetricName metricExeCount, int i1, int i2, int i3) {
measurements.add(new Measurement(comp, "i1", metricExeCount.text(), now, i1));
measurements.add(new Measurement(comp, "i2", metricExeCount.text(), now, i2));
measurements.add(new Measurement(comp, "i3", metricExeCount.text(), now, i3));
}
use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class ScaleUpResolverTest method testResolve.
@Test
public void testResolve() {
TopologyAPI.Topology topology = createTestTopology();
Config config = createConfig(topology);
PackingPlan currentPlan = createPacking(topology, config);
PackingPlanProvider packingPlanProvider = mock(PackingPlanProvider.class);
when(packingPlanProvider.get()).thenReturn(currentPlan);
ISchedulerClient scheduler = mock(ISchedulerClient.class);
when(scheduler.updateTopology(any(UpdateTopologyRequest.class))).thenReturn(true);
Instant now = Instant.now();
Collections.singletonList(new Measurement("bolt", "i1", METRIC_BACK_PRESSURE.text(), now, 123));
List<String> assignments = Collections.singletonList("bolt");
Diagnosis diagnoses = new Diagnosis(DIAGNOSIS_UNDER_PROVISIONING.text(), now, assignments, null);
List<Diagnosis> diagnosis = Collections.singletonList(diagnoses);
ExecutionContext context = mock(ExecutionContext.class);
when(context.checkpoint()).thenReturn(now);
ScaleUpResolver resolver = new ScaleUpResolver(null, packingPlanProvider, scheduler, eventManager, null);
resolver.initialize(context);
ScaleUpResolver spyResolver = spy(resolver);
doReturn(2).when(spyResolver).computeScaleUpFactor("bolt");
doReturn(currentPlan).when(spyResolver).buildNewPackingPlan(any(HashMap.class), eq(currentPlan));
Collection<Action> result = spyResolver.resolve(diagnosis);
verify(scheduler, times(1)).updateTopology(any(UpdateTopologyRequest.class));
assertEquals(1, result.size());
}
use of com.microsoft.dhalion.core.Measurement in project heron by twitter.
the class MetricsCacheMetricsProviderTest method providesMultipleComponentMetricsFromMetricsCache.
@Test
public void providesMultipleComponentMetricsFromMetricsCache() {
MetricsCacheMetricsProvider spyMetricsProvider = createMetricsProviderSpy();
String metric = "count";
String comp1 = "bolt-1";
TopologyManager.MetricResponse response1 = TopologyManager.MetricResponse.newBuilder().setStatus(Status.newBuilder().setStatus(StatusCode.OK)).addMetric(TaskMetric.newBuilder().setInstanceId("container_1_bolt-1_2").addMetric(IndividualMetric.newBuilder().setName(metric).addIntervalValues(IntervalValue.newBuilder().setValue("104").setInterval(MetricInterval.newBuilder().setStart(1497481288).setEnd(1497481288))))).build();
doReturn(response1).when(spyMetricsProvider).getMetricsFromMetricsCache(metric, comp1, Instant.ofEpochSecond(10), Duration.ofSeconds(60));
String comp2 = "bolt-2";
TopologyManager.MetricResponse response2 = TopologyManager.MetricResponse.newBuilder().setStatus(Status.newBuilder().setStatus(StatusCode.OK)).addMetric(TaskMetric.newBuilder().setInstanceId("container_1_bolt-2_1").addMetric(IndividualMetric.newBuilder().setName(metric).addIntervalValues(IntervalValue.newBuilder().setValue("12").setInterval(MetricInterval.newBuilder().setStart(1497481228).setEnd(1497481228))).addIntervalValues(IntervalValue.newBuilder().setValue("2").setInterval(MetricInterval.newBuilder().setStart(1497481348).setEnd(1497481348))).addIntervalValues(IntervalValue.newBuilder().setValue("3").setInterval(MetricInterval.newBuilder().setStart(1497481168).setEnd(1497481168))))).build();
doReturn(response2).when(spyMetricsProvider).getMetricsFromMetricsCache(metric, comp2, Instant.ofEpochSecond(10), Duration.ofSeconds(60));
Collection<Measurement> metrics = spyMetricsProvider.getMeasurements(Instant.ofEpochSecond(10), Duration.ofSeconds(60), Collections.singletonList(metric), Arrays.asList(comp1, comp2));
assertEquals(4, metrics.size());
MeasurementsTable table = MeasurementsTable.of(metrics);
assertEquals(2, table.uniqueComponents().size());
assertEquals(1, table.component(comp1).size());
assertEquals(104, table.instance("container_1_bolt-1_2").sum(), 0.01);
assertEquals(3, table.component(comp2).size());
assertEquals(1, table.uniqueTypes().size());
assertEquals(3, table.type(metric).instance("container_1_bolt-2_1").size());
assertEquals(17, table.instance("container_1_bolt-2_1").sum(), 0.01);
}
Aggregations