use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class SegmentStatusCheckerTest method missingIdealTest.
@Test
public void missingIdealTest() throws Exception {
final String tableName = "myTable_REALTIME";
List<String> allTableNames = new ArrayList<String>();
allTableNames.add(tableName);
IdealState idealState = null;
HelixAdmin helixAdmin;
{
helixAdmin = mock(HelixAdmin.class);
when(helixAdmin.getResourceIdealState("StatusChecker", tableName)).thenReturn(null);
when(helixAdmin.getResourceExternalView("StatusChecker", tableName)).thenReturn(null);
}
{
helixResourceManager = mock(PinotHelixResourceManager.class);
when(helixResourceManager.isLeader()).thenReturn(true);
when(helixResourceManager.getAllPinotTableNames()).thenReturn(allTableNames);
when(helixResourceManager.getHelixClusterName()).thenReturn("StatusChecker");
when(helixResourceManager.getHelixAdmin()).thenReturn(helixAdmin);
}
{
config = mock(ControllerConf.class);
when(config.getStatusCheckerFrequencyInSeconds()).thenReturn(300);
when(config.getStatusCheckerWaitForPushTimeInSeconds()).thenReturn(300);
}
metricsRegistry = new MetricsRegistry();
controllerMetrics = new ControllerMetrics(metricsRegistry);
segmentStatusChecker = new SegmentStatusChecker(helixResourceManager, config);
segmentStatusChecker.setMetricsRegistry(controllerMetrics);
segmentStatusChecker.runSegmentMetrics();
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName, ControllerGauge.SEGMENTS_IN_ERROR_STATE), 0);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName, ControllerGauge.NUMBER_OF_REPLICAS), 1);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(tableName, ControllerGauge.PERCENT_OF_REPLICAS), 100);
segmentStatusChecker.stop();
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class SegmentStatusCheckerTest method missingEVPartitionPushTest.
@Test
public void missingEVPartitionPushTest() throws Exception {
final String tableName = "myTable_OFFLINE";
List<String> allTableNames = new ArrayList<String>();
allTableNames.add(tableName);
IdealState idealState = new IdealState(tableName);
idealState.setPartitionState("myTable_0", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot1", "ONLINE");
idealState.setPartitionState("myTable_1", "pinot2", "ONLINE");
idealState.setReplicas("2");
idealState.setRebalanceMode(IdealState.RebalanceMode.CUSTOMIZED);
ExternalView externalView = new ExternalView(tableName);
externalView.setState("myTable_1", "pinot1", "ONLINE");
externalView.setState("myTable_1", "pinot2", "ONLINE");
HelixAdmin helixAdmin;
{
helixAdmin = mock(HelixAdmin.class);
when(helixAdmin.getResourceIdealState("StatusChecker", "myTable_OFFLINE")).thenReturn(idealState);
when(helixAdmin.getResourceExternalView("StatusChecker", "myTable_OFFLINE")).thenReturn(externalView);
}
ZNRecord znrecord = new ZNRecord("myTable_0");
znrecord.setSimpleField(CommonConstants.Segment.SEGMENT_NAME, "myTable_0");
znrecord.setSimpleField(CommonConstants.Segment.TABLE_NAME, "myTable_OFFLINE");
znrecord.setSimpleField(CommonConstants.Segment.INDEX_VERSION, "v1");
znrecord.setEnumField(CommonConstants.Segment.SEGMENT_TYPE, CommonConstants.Segment.SegmentType.OFFLINE);
znrecord.setLongField(CommonConstants.Segment.START_TIME, 1000);
znrecord.setLongField(CommonConstants.Segment.END_TIME, 2000);
znrecord.setSimpleField(CommonConstants.Segment.TIME_UNIT, TimeUnit.HOURS.toString());
znrecord.setLongField(CommonConstants.Segment.TOTAL_DOCS, 10000);
znrecord.setLongField(CommonConstants.Segment.CRC, 1234);
znrecord.setLongField(CommonConstants.Segment.CREATION_TIME, 3000);
znrecord.setSimpleField(CommonConstants.Segment.Offline.DOWNLOAD_URL, "http://localhost:8000/myTable_0");
znrecord.setLongField(CommonConstants.Segment.Offline.PUSH_TIME, System.currentTimeMillis());
znrecord.setLongField(CommonConstants.Segment.Offline.REFRESH_TIME, System.currentTimeMillis());
ZkHelixPropertyStore<ZNRecord> propertyStore;
{
propertyStore = (ZkHelixPropertyStore<ZNRecord>) mock(ZkHelixPropertyStore.class);
when(propertyStore.get("/SEGMENTS/myTable_OFFLINE/myTable_0", null, AccessOption.PERSISTENT)).thenReturn(znrecord);
}
{
helixResourceManager = mock(PinotHelixResourceManager.class);
when(helixResourceManager.isLeader()).thenReturn(true);
when(helixResourceManager.getAllPinotTableNames()).thenReturn(allTableNames);
when(helixResourceManager.getHelixClusterName()).thenReturn("StatusChecker");
when(helixResourceManager.getHelixAdmin()).thenReturn(helixAdmin);
when(helixResourceManager.getPropertyStore()).thenReturn(propertyStore);
}
{
config = mock(ControllerConf.class);
when(config.getStatusCheckerFrequencyInSeconds()).thenReturn(300);
when(config.getStatusCheckerWaitForPushTimeInSeconds()).thenReturn(300);
}
metricsRegistry = new MetricsRegistry();
controllerMetrics = new ControllerMetrics(metricsRegistry);
segmentStatusChecker = new SegmentStatusChecker(helixResourceManager, config);
segmentStatusChecker.setMetricsRegistry(controllerMetrics);
segmentStatusChecker.runSegmentMetrics();
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.SEGMENTS_IN_ERROR_STATE), 0);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.NUMBER_OF_REPLICAS), 2);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.PERCENT_OF_REPLICAS), 100);
Assert.assertEquals(controllerMetrics.getValueOfTableGauge(externalView.getId(), ControllerGauge.PERCENT_SEGMENTS_AVAILABLE), 100);
segmentStatusChecker.stop();
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class RealtimeSegmentImplTest method testDropInvalidRows.
@Test
public void testDropInvalidRows() throws Exception {
Schema schema = new Schema.SchemaBuilder().setSchemaName("potato").addSingleValueDimension("dimension", FieldSpec.DataType.STRING).addMetric("metric", FieldSpec.DataType.LONG).addTime("time", TimeUnit.SECONDS, FieldSpec.DataType.LONG).build();
RealtimeSegmentImpl realtimeSegment = createRealtimeSegmentImpl(schema, 100, "noTable", "noSegment", schema.getSchemaName(), new ServerMetrics(new MetricsRegistry()));
// Segment should be empty
Assert.assertEquals(realtimeSegment.getRawDocumentCount(), 0);
Map<String, Object> genericRowContents = new HashMap<>();
genericRowContents.put("dimension", "potato");
genericRowContents.put("metric", 1234L);
genericRowContents.put("time", 4567L);
GenericRow row = new GenericRow();
row.init(genericRowContents);
// Add a valid row
boolean notFull = realtimeSegment.index(row);
Assert.assertEquals(notFull, true);
Assert.assertEquals(realtimeSegment.getRawDocumentCount(), 1);
// Add an invalid row
genericRowContents.put("metric", null);
notFull = realtimeSegment.index(row);
Assert.assertEquals(notFull, true);
Assert.assertEquals(realtimeSegment.getRawDocumentCount(), 1);
// Add another valid row
genericRowContents.put("metric", 2222L);
notFull = realtimeSegment.index(row);
Assert.assertEquals(notFull, true);
Assert.assertEquals(realtimeSegment.getRawDocumentCount(), 2);
}
use of com.yammer.metrics.core.MetricsRegistry in project pinot by linkedin.
the class OfflineTableDataManagerTest method makeTestableManager.
private OfflineTableDataManager makeTestableManager() throws Exception {
OfflineTableDataManager tableDataManager = new OfflineTableDataManager();
TableDataManagerConfig config;
{
config = mock(TableDataManagerConfig.class);
when(config.getTableName()).thenReturn(tableName);
when(config.getDataDir()).thenReturn(_tmpDir.getAbsolutePath());
when(config.getReadMode()).thenReturn(readMode.toString());
when(config.getIndexLoadingConfigMetadata()).thenReturn(null);
}
tableDataManager.init(config, new ServerMetrics(new MetricsRegistry()), null);
tableDataManager.start();
Field segsMapField = AbstractTableDataManager.class.getDeclaredField("_segmentsMap");
segsMapField.setAccessible(true);
_internalSegMap = (Map<String, OfflineSegmentDataManager>) segsMapField.get(tableDataManager);
return tableDataManager;
}
use of com.yammer.metrics.core.MetricsRegistry in project Dempsy by Dempsy.
the class TestStatsCollectorCoda method getStatValue.
@SuppressWarnings("unchecked")
long getStatValue(StatsCollectorCoda statCollector, String metricName) {
MetricsRegistry metricReg = statCollector.getMetricsRegistry();
Object meter = metricReg.allMetrics().get(statCollector.createName(metricName));
if (com.yammer.metrics.core.Gauge.class.isAssignableFrom(meter.getClass()))
return ((com.yammer.metrics.core.Gauge<Long>) metricReg.allMetrics().get(statCollector.createName(metricName))).value();
else if (com.yammer.metrics.core.Histogram.class.isAssignableFrom(meter.getClass())) {
final com.yammer.metrics.core.Histogram h = (com.yammer.metrics.core.Histogram) metricReg.allMetrics().get(statCollector.createName(metricName));
return Math.round(h.count() * h.mean());
} else
return ((Metered) metricReg.allMetrics().get(statCollector.createName(metricName))).count();
}
Aggregations