Search in sources :

Example 1 with KinesisRecordSupplier

use of org.apache.druid.indexing.kinesis.KinesisRecordSupplier in project druid by druid-io.

the class KinesisSupervisor method setupRecordSupplier.

@Override
protected RecordSupplier<String, String, ByteEntity> setupRecordSupplier() throws RuntimeException {
    KinesisSupervisorIOConfig ioConfig = spec.getIoConfig();
    KinesisIndexTaskTuningConfig taskTuningConfig = spec.getTuningConfig();
    return new KinesisRecordSupplier(KinesisRecordSupplier.getAmazonKinesisClient(ioConfig.getEndpoint(), awsCredentialsConfig, ioConfig.getAwsAssumedRoleArn(), ioConfig.getAwsExternalId()), ioConfig.getRecordsPerFetch(), ioConfig.getFetchDelayMillis(), // skip starting background fetch, it is not used
    0, ioConfig.isDeaggregate(), taskTuningConfig.getRecordBufferSize(), taskTuningConfig.getRecordBufferOfferTimeout(), taskTuningConfig.getRecordBufferFullWait(), taskTuningConfig.getFetchSequenceNumberTimeout(), taskTuningConfig.getMaxRecordsPerPoll(), ioConfig.isUseEarliestSequenceNumber());
}
Also used : KinesisRecordSupplier(org.apache.druid.indexing.kinesis.KinesisRecordSupplier) KinesisIndexTaskTuningConfig(org.apache.druid.indexing.kinesis.KinesisIndexTaskTuningConfig)

Example 2 with KinesisRecordSupplier

use of org.apache.druid.indexing.kinesis.KinesisRecordSupplier in project druid by druid-io.

the class KinesisSupervisorTest method testRecordSupplier.

@Test
public void testRecordSupplier() {
    KinesisSupervisorIOConfig kinesisSupervisorIOConfig = new KinesisSupervisorIOConfig(STREAM, INPUT_FORMAT, "awsEndpoint", null, 1, 1, new Period("PT30M"), new Period("P1D"), new Period("PT30S"), false, new Period("PT30M"), null, null, null, 100, 1000, null, null, null, false);
    KinesisIndexTaskClientFactory clientFactory = new KinesisIndexTaskClientFactory(null, OBJECT_MAPPER);
    KinesisSupervisor supervisor = new KinesisSupervisor(taskStorage, taskMaster, indexerMetadataStorageCoordinator, clientFactory, OBJECT_MAPPER, new KinesisSupervisorSpec(null, dataSchema, tuningConfig, kinesisSupervisorIOConfig, null, false, taskStorage, taskMaster, indexerMetadataStorageCoordinator, clientFactory, OBJECT_MAPPER, new NoopServiceEmitter(), new DruidMonitorSchedulerConfig(), rowIngestionMetersFactory, null, new SupervisorStateManagerConfig()), rowIngestionMetersFactory, null);
    KinesisRecordSupplier supplier = (KinesisRecordSupplier) supervisor.setupRecordSupplier();
    Assert.assertNotNull(supplier);
    Assert.assertEquals(0, supplier.bufferSize());
    Assert.assertEquals(Collections.emptySet(), supplier.getAssignment());
    // background fetch should not be enabled for supervisor supplier
    supplier.start();
    Assert.assertFalse(supplier.isBackgroundFetchRunning());
}
Also used : KinesisIndexTaskClientFactory(org.apache.druid.indexing.kinesis.KinesisIndexTaskClientFactory) DruidMonitorSchedulerConfig(org.apache.druid.server.metrics.DruidMonitorSchedulerConfig) KinesisRecordSupplier(org.apache.druid.indexing.kinesis.KinesisRecordSupplier) SupervisorStateManagerConfig(org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig) Period(org.joda.time.Period) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) Test(org.junit.Test)

Example 3 with KinesisRecordSupplier

use of org.apache.druid.indexing.kinesis.KinesisRecordSupplier in project druid by druid-io.

the class KinesisSupervisor method updatePartitionLagFromStream.

@Override
protected void updatePartitionLagFromStream() {
    KinesisRecordSupplier supplier = (KinesisRecordSupplier) recordSupplier;
    // this recordSupplier method is thread safe, so does not need to acquire the recordSupplierLock
    currentPartitionTimeLag = supplier.getPartitionsTimeLag(getIoConfig().getStream(), getHighestCurrentOffsets());
}
Also used : KinesisRecordSupplier(org.apache.druid.indexing.kinesis.KinesisRecordSupplier)

Example 4 with KinesisRecordSupplier

use of org.apache.druid.indexing.kinesis.KinesisRecordSupplier in project druid by druid-io.

the class KinesisSupervisor method updateClosedShardCache.

private synchronized void updateClosedShardCache() {
    final KinesisRecordSupplier kinesisRecordSupplier = (KinesisRecordSupplier) recordSupplier;
    final String stream = spec.getSource();
    final Set<Shard> allActiveShards = kinesisRecordSupplier.getShards(stream);
    final Set<String> activeClosedShards = allActiveShards.stream().filter(shard -> isShardClosed(shard)).map(Shard::getShardId).collect(Collectors.toSet());
    // clear stale shards
    emptyClosedShardIds.retainAll(activeClosedShards);
    nonEmptyClosedShardIds.retainAll(activeClosedShards);
    for (String closedShardId : activeClosedShards) {
        // Try to utilize cache
        if (emptyClosedShardIds.contains(closedShardId) || nonEmptyClosedShardIds.contains(closedShardId)) {
            continue;
        }
        // Check if it is closed using kinesis and add to cache
        if (kinesisRecordSupplier.isClosedShardEmpty(stream, closedShardId)) {
            emptyClosedShardIds.add(closedShardId);
        } else {
            nonEmptyClosedShardIds.add(closedShardId);
        }
    }
}
Also used : KinesisRecordSupplier(org.apache.druid.indexing.kinesis.KinesisRecordSupplier) Shard(com.amazonaws.services.kinesis.model.Shard)

Aggregations

KinesisRecordSupplier (org.apache.druid.indexing.kinesis.KinesisRecordSupplier)4 Shard (com.amazonaws.services.kinesis.model.Shard)1 KinesisIndexTaskClientFactory (org.apache.druid.indexing.kinesis.KinesisIndexTaskClientFactory)1 KinesisIndexTaskTuningConfig (org.apache.druid.indexing.kinesis.KinesisIndexTaskTuningConfig)1 SupervisorStateManagerConfig (org.apache.druid.indexing.overlord.supervisor.SupervisorStateManagerConfig)1 DruidMonitorSchedulerConfig (org.apache.druid.server.metrics.DruidMonitorSchedulerConfig)1 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)1 Period (org.joda.time.Period)1 Test (org.junit.Test)1