use of com.linkedin.pinot.common.metrics.ServerMetrics in project pinot by linkedin.
the class RealtimeQueriesSentinelTest method setup.
@BeforeClass
public void setup() throws Exception {
TableDataManagerProvider.setServerMetrics(new ServerMetrics(new MetricsRegistry()));
PINOT_SCHEMA = getTestSchema();
PINOT_SCHEMA.setSchemaName("realtimeSchema");
AVRO_RECORD_TRANSFORMER = new AvroRecordToPinotRowGenerator(PINOT_SCHEMA);
final IndexSegment indexSegment = getRealtimeSegment();
setUpTestQueries("testTable");
CONFIG_BUILDER = new TestingServerPropertiesBuilder("testTable");
final PropertiesConfiguration serverConf = CONFIG_BUILDER.build();
serverConf.setDelimiterParsingDisabled(false);
final FileBasedInstanceDataManager instanceDataManager = FileBasedInstanceDataManager.getInstanceDataManager();
instanceDataManager.init(new FileBasedInstanceDataManagerConfig(serverConf.subset("pinot.server.instance")));
instanceDataManager.start();
instanceDataManager.getTableDataManager("testTable");
instanceDataManager.getTableDataManager("testTable").addSegment(indexSegment);
QUERY_EXECUTOR = new ServerQueryExecutorV1Impl(false);
QUERY_EXECUTOR.init(serverConf.subset("pinot.server.query.executor"), instanceDataManager, new ServerMetrics(new MetricsRegistry()));
}
use of com.linkedin.pinot.common.metrics.ServerMetrics in project pinot by linkedin.
the class ScheduledRequestHandler method serializeDataTable.
static byte[] serializeDataTable(QueryRequest queryRequest, DataTable instanceResponse) {
byte[] responseByte;
InstanceRequest instanceRequest = queryRequest.getInstanceRequest();
ServerMetrics metrics = queryRequest.getServerMetrics();
TimerContext timerContext = queryRequest.getTimerContext();
timerContext.startNewPhaseTimer(ServerQueryPhase.RESPONSE_SERIALIZATION);
long requestId = instanceRequest != null ? instanceRequest.getRequestId() : -1;
String brokerId = instanceRequest != null ? instanceRequest.getBrokerId() : "null";
try {
if (instanceResponse == null) {
LOGGER.warn("Instance response is null for requestId: {}, brokerId: {}", requestId, brokerId);
responseByte = new byte[0];
} else {
responseByte = instanceResponse.toBytes();
}
} catch (Exception e) {
metrics.addMeteredGlobalValue(ServerMeter.RESPONSE_SERIALIZATION_EXCEPTIONS, 1);
LOGGER.error("Got exception while serializing response for requestId: {}, brokerId: {}", requestId, brokerId, e);
responseByte = null;
}
timerContext.getPhaseTimer(ServerQueryPhase.RESPONSE_SERIALIZATION).stopAndRecord();
timerContext.startNewPhaseTimerAtNs(ServerQueryPhase.TOTAL_QUERY_TIME, timerContext.getQueryArrivalTimeNs());
timerContext.getPhaseTimer(ServerQueryPhase.TOTAL_QUERY_TIME).stopAndRecord();
return responseByte;
}
use of com.linkedin.pinot.common.metrics.ServerMetrics in project pinot by linkedin.
the class ServerBuilder method initMetrics.
private void initMetrics() {
MetricsHelper.initializeMetrics(_serverConf.getMetricsConfig());
MetricsHelper.registerMetricsRegistry(metricsRegistry);
_serverMetrics = new ServerMetrics(metricsRegistry, !_serverConf.emitTableLevelMetrics());
_serverMetrics.initializeGlobalMeters();
TableDataManagerProvider.setServerMetrics(_serverMetrics);
}
use of com.linkedin.pinot.common.metrics.ServerMetrics 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.linkedin.pinot.common.metrics.ServerMetrics 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;
}
Aggregations