Search in sources :

Example 1 with KafkaLowLevelStreamProviderConfig

use of com.linkedin.pinot.core.realtime.impl.kafka.KafkaLowLevelStreamProviderConfig in project pinot by linkedin.

the class LLRealtimeSegmentDataManagerTest method testTimeString.

@Test
public void testTimeString() throws Exception {
    JSONObject tableConfigJson = new JSONObject(_tableConfigJson);
    JSONObject tableIndexConfig = (JSONObject) tableConfigJson.get("tableIndexConfig");
    JSONObject streamConfigs = (JSONObject) tableIndexConfig.get("streamConfigs");
    {
        streamConfigs.put(CommonConstants.Helix.DataSource.Realtime.REALTIME_SEGMENT_FLUSH_TIME, "3h");
        AbstractTableConfig tableConfig = createTableConfig(tableConfigJson.toString());
        InstanceZKMetadata instanceZKMetadata = new InstanceZKMetadata();
        Schema schema = Schema.fromString(makeSchema());
        KafkaLowLevelStreamProviderConfig config = new KafkaLowLevelStreamProviderConfig();
        config.init(tableConfig, instanceZKMetadata, schema);
        Assert.assertEquals(3 * 3600 * 1000L, config.getTimeThresholdToFlushSegment());
    }
    {
        streamConfigs.put(CommonConstants.Helix.DataSource.Realtime.REALTIME_SEGMENT_FLUSH_TIME, "3h30m");
        AbstractTableConfig tableConfig = createTableConfig(tableConfigJson.toString());
        InstanceZKMetadata instanceZKMetadata = new InstanceZKMetadata();
        Schema schema = Schema.fromString(makeSchema());
        KafkaLowLevelStreamProviderConfig config = new KafkaLowLevelStreamProviderConfig();
        config.init(tableConfig, instanceZKMetadata, schema);
        Assert.assertEquals((3 * 3600 + 30 * 60) * 1000L, config.getTimeThresholdToFlushSegment());
    }
    {
        final long segTime = 898789748357L;
        streamConfigs.put(CommonConstants.Helix.DataSource.Realtime.REALTIME_SEGMENT_FLUSH_TIME, String.valueOf(segTime));
        AbstractTableConfig tableConfig = createTableConfig(tableConfigJson.toString());
        InstanceZKMetadata instanceZKMetadata = new InstanceZKMetadata();
        Schema schema = Schema.fromString(makeSchema());
        KafkaLowLevelStreamProviderConfig config = new KafkaLowLevelStreamProviderConfig();
        config.init(tableConfig, instanceZKMetadata, schema);
        Assert.assertEquals(segTime, config.getTimeThresholdToFlushSegment());
    }
}
Also used : JSONObject(org.json.JSONObject) InstanceZKMetadata(com.linkedin.pinot.common.metadata.instance.InstanceZKMetadata) Schema(com.linkedin.pinot.common.data.Schema) KafkaLowLevelStreamProviderConfig(com.linkedin.pinot.core.realtime.impl.kafka.KafkaLowLevelStreamProviderConfig) AbstractTableConfig(com.linkedin.pinot.common.config.AbstractTableConfig) Test(org.testng.annotations.Test)

Aggregations

AbstractTableConfig (com.linkedin.pinot.common.config.AbstractTableConfig)1 Schema (com.linkedin.pinot.common.data.Schema)1 InstanceZKMetadata (com.linkedin.pinot.common.metadata.instance.InstanceZKMetadata)1 KafkaLowLevelStreamProviderConfig (com.linkedin.pinot.core.realtime.impl.kafka.KafkaLowLevelStreamProviderConfig)1 JSONObject (org.json.JSONObject)1 Test (org.testng.annotations.Test)1