Search in sources :

Example 16 with Measurement

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));
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement)

Example 17 with Measurement

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);
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) Instant(java.time.Instant)

Example 18 with Measurement

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));
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement)

Example 19 with Measurement

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());
}
Also used : Measurement(com.microsoft.dhalion.core.Measurement) Action(com.microsoft.dhalion.core.Action) HashMap(java.util.HashMap) Config(org.apache.heron.spi.common.Config) PackingPlan(org.apache.heron.spi.packing.PackingPlan) Instant(java.time.Instant) PackingPlanProvider(org.apache.heron.healthmgr.common.PackingPlanProvider) TopologyAPI(org.apache.heron.api.generated.TopologyAPI) UpdateTopologyRequest(org.apache.heron.proto.scheduler.Scheduler.UpdateTopologyRequest) ExecutionContext(com.microsoft.dhalion.policy.PoliciesExecutor.ExecutionContext) ISchedulerClient(org.apache.heron.scheduler.client.ISchedulerClient) Diagnosis(com.microsoft.dhalion.core.Diagnosis) Test(org.junit.Test)

Example 20 with Measurement

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);
}
Also used : TopologyManager(org.apache.heron.proto.tmanager.TopologyManager) Measurement(com.microsoft.dhalion.core.Measurement) MeasurementsTable(com.microsoft.dhalion.core.MeasurementsTable) Test(org.junit.Test)

Aggregations

Measurement (com.microsoft.dhalion.core.Measurement)28 Test (org.junit.Test)20 MeasurementsTable (com.microsoft.dhalion.core.MeasurementsTable)14 ArrayList (java.util.ArrayList)13 PoliciesExecutor (com.microsoft.dhalion.policy.PoliciesExecutor)8 HealthPolicyConfig (org.apache.heron.healthmgr.HealthPolicyConfig)7 Symptom (com.microsoft.dhalion.core.Symptom)6 Instant (java.time.Instant)6 SymptomsTable (com.microsoft.dhalion.core.SymptomsTable)4 TopologyManager (org.apache.heron.proto.tmanager.TopologyManager)4 MetricsProvider (com.microsoft.dhalion.api.MetricsProvider)3 ExecutionContext (com.microsoft.dhalion.policy.PoliciesExecutor.ExecutionContext)3 PackingPlanProvider (org.apache.heron.healthmgr.common.PackingPlanProvider)3 PhysicalPlanProvider (org.apache.heron.healthmgr.common.PhysicalPlanProvider)3 Duration (java.time.Duration)2 HealthManagerMetrics (org.apache.heron.healthmgr.HealthManagerMetrics)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 DocumentContext (com.jayway.jsonpath.DocumentContext)1 Action (com.microsoft.dhalion.core.Action)1 Diagnosis (com.microsoft.dhalion.core.Diagnosis)1