Search in sources :

Example 11 with ServerMetrics

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()));
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) AvroRecordToPinotRowGenerator(com.linkedin.pinot.core.realtime.impl.kafka.AvroRecordToPinotRowGenerator) IndexSegment(com.linkedin.pinot.core.indexsegment.IndexSegment) FileBasedInstanceDataManager(com.linkedin.pinot.core.data.manager.offline.FileBasedInstanceDataManager) ServerQueryExecutorV1Impl(com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl) ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics) FileBasedInstanceDataManagerConfig(com.linkedin.pinot.core.data.manager.config.FileBasedInstanceDataManagerConfig) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) BeforeClass(org.testng.annotations.BeforeClass)

Example 12 with ServerMetrics

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;
}
Also used : TimerContext(com.linkedin.pinot.common.query.context.TimerContext) ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics) InstanceRequest(com.linkedin.pinot.common.request.InstanceRequest) QueryException(com.linkedin.pinot.common.exception.QueryException)

Example 13 with ServerMetrics

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);
}
Also used : ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics)

Example 14 with 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);
}
Also used : GenericRow(com.linkedin.pinot.core.data.GenericRow) MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) HashMap(java.util.HashMap) Schema(com.linkedin.pinot.common.data.Schema) ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics) RealtimeSegmentImpl(com.linkedin.pinot.core.realtime.impl.RealtimeSegmentImpl) Test(org.testng.annotations.Test)

Example 15 with ServerMetrics

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;
}
Also used : Field(java.lang.reflect.Field) MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) OfflineSegmentDataManager(com.linkedin.pinot.core.data.manager.offline.OfflineSegmentDataManager) TableDataManagerConfig(com.linkedin.pinot.core.data.manager.config.TableDataManagerConfig) OfflineTableDataManager(com.linkedin.pinot.core.data.manager.offline.OfflineTableDataManager) ServerMetrics(com.linkedin.pinot.common.metrics.ServerMetrics)

Aggregations

ServerMetrics (com.linkedin.pinot.common.metrics.ServerMetrics)15 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)13 File (java.io.File)7 ServerQueryExecutorV1Impl (com.linkedin.pinot.core.query.executor.ServerQueryExecutorV1Impl)6 BeforeClass (org.testng.annotations.BeforeClass)6 FileBasedInstanceDataManagerConfig (com.linkedin.pinot.core.data.manager.config.FileBasedInstanceDataManagerConfig)5 FileBasedInstanceDataManager (com.linkedin.pinot.core.data.manager.offline.FileBasedInstanceDataManager)5 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)5 GenericRow (com.linkedin.pinot.core.data.GenericRow)4 IndexSegment (com.linkedin.pinot.core.indexsegment.IndexSegment)3 RealtimeSegmentImpl (com.linkedin.pinot.core.realtime.impl.RealtimeSegmentImpl)3 Schema (com.linkedin.pinot.common.data.Schema)2 FileBasedStreamProviderConfig (com.linkedin.pinot.core.realtime.impl.FileBasedStreamProviderConfig)2 FileBasedStreamProviderImpl (com.linkedin.pinot.core.realtime.impl.FileBasedStreamProviderImpl)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)1 FieldType (com.linkedin.pinot.common.data.FieldSpec.FieldType)1 QueryException (com.linkedin.pinot.common.exception.QueryException)1 InstanceZKMetadata (com.linkedin.pinot.common.metadata.instance.InstanceZKMetadata)1