Search in sources :

Example 1 with KinesisAsyncClientBuilder

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder in project graylog-plugin-integrations by Graylog2.

the class KinesisConsumer method run.

public void run() {
    LOG.debug("Starting the Kinesis Consumer.");
    AwsCredentialsProvider credentialsProvider = AWSAuthFactory.create(request.region(), request.awsAccessKeyId(), request.awsSecretAccessKey(), request.assumeRoleArn());
    final Region region = Region.of(request.region());
    final DynamoDbAsyncClientBuilder dynamoDbClientBuilder = DynamoDbAsyncClient.builder();
    AWSClientBuilderUtil.initializeBuilder(dynamoDbClientBuilder, request.dynamodbEndpoint(), region, credentialsProvider);
    final DynamoDbAsyncClient dynamoClient = dynamoDbClientBuilder.build();
    final CloudWatchAsyncClientBuilder cloudwatchClientBuilder = CloudWatchAsyncClient.builder();
    AWSClientBuilderUtil.initializeBuilder(cloudwatchClientBuilder, request.cloudwatchEndpoint(), region, credentialsProvider);
    final CloudWatchAsyncClient cloudWatchClient = cloudwatchClientBuilder.build();
    final KinesisAsyncClientBuilder kinesisAsyncClientBuilder = KinesisAsyncClient.builder();
    AWSClientBuilderUtil.initializeBuilder(kinesisAsyncClientBuilder, request.kinesisEndpoint(), region, credentialsProvider);
    final KinesisAsyncClient kinesisAsyncClient = KinesisClientUtil.createKinesisAsyncClient(kinesisAsyncClientBuilder);
    final String workerId = String.format(Locale.ENGLISH, "graylog-node-%s", nodeId.anonymize());
    LOG.debug("Using workerId [{}].", workerId);
    // The application name needs to be unique per input/consumer.
    final String applicationName = String.format(Locale.ENGLISH, "graylog-aws-plugin-%s", kinesisStreamName);
    LOG.debug("Using Kinesis applicationName [{}].", applicationName);
    // The KinesisShardProcessorFactory contains the message processing logic.
    final KinesisShardProcessorFactory kinesisShardProcessorFactory = new KinesisShardProcessorFactory(objectMapper, transport, handleMessageCallback, kinesisStreamName, awsMessageType);
    ConfigsBuilder configsBuilder = new ConfigsBuilder(kinesisStreamName, applicationName, kinesisAsyncClient, dynamoClient, cloudWatchClient, workerId, kinesisShardProcessorFactory);
    final PollingConfig pollingConfig = new PollingConfig(kinesisStreamName, kinesisAsyncClient);
    // Default max records per request is 10k.
    if (recordBatchSize != null) {
        LOG.debug("Using explicit batch size [{}]", recordBatchSize);
        pollingConfig.maxRecords(recordBatchSize);
    }
    this.kinesisScheduler = new Scheduler(configsBuilder.checkpointConfig(), configsBuilder.coordinatorConfig(), configsBuilder.leaseManagementConfig(), configsBuilder.lifecycleConfig(), configsBuilder.metricsConfig(), configsBuilder.processorConfig(), configsBuilder.retrievalConfig().retrievalSpecificConfig(pollingConfig));
    LOG.debug("Starting Kinesis scheduler.");
    kinesisScheduler.run();
    LOG.debug("After Kinesis scheduler stopped.");
}
Also used : KinesisAsyncClient(software.amazon.awssdk.services.kinesis.KinesisAsyncClient) CloudWatchAsyncClient(software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient) Scheduler(software.amazon.kinesis.coordinator.Scheduler) PollingConfig(software.amazon.kinesis.retrieval.polling.PollingConfig) ConfigsBuilder(software.amazon.kinesis.common.ConfigsBuilder) CloudWatchAsyncClientBuilder(software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClientBuilder) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) DynamoDbAsyncClient(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient) Region(software.amazon.awssdk.regions.Region) DynamoDbAsyncClientBuilder(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder) KinesisAsyncClientBuilder(software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder)

Example 2 with KinesisAsyncClientBuilder

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder in project aws-sdk by reactiverse.

the class VertxKinesisClientSpec method kinesis.

private KinesisAsyncClient kinesis(Context context) throws Exception {
    final URI kinesisURI = new URI(Localstack.INSTANCE.getEndpointKinesis());
    final KinesisAsyncClientBuilder builder = KinesisAsyncClient.builder().region(Region.EU_WEST_1).endpointOverride(kinesisURI).credentialsProvider(credentialsProvider);
    return VertxSdkClient.withVertx(builder, context).build();
}
Also used : KinesisAsyncClientBuilder(software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder) URI(java.net.URI)

Example 3 with KinesisAsyncClientBuilder

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder in project pulsar by apache.

the class KinesisSourceConfig method buildKinesisAsyncClient.

public KinesisAsyncClient buildKinesisAsyncClient(AwsCredentialProviderPlugin credPlugin) {
    KinesisAsyncClientBuilder builder = KinesisAsyncClient.builder();
    if (!this.getAwsEndpoint().isEmpty()) {
        builder.endpointOverride(URI.create(this.getAwsEndpoint()));
    }
    if (!this.getAwsRegion().isEmpty()) {
        builder.region(this.regionAsV2Region());
    }
    builder.credentialsProvider(credPlugin.getV2CredentialsProvider());
    return KinesisClientUtil.createKinesisAsyncClient(builder);
}
Also used : KinesisAsyncClientBuilder(software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder)

Example 4 with KinesisAsyncClientBuilder

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder in project micronaut-aws-sdk by agorapulse.

the class KinesisFactory method kinesisAsync.

@Singleton
@Bean(preDestroy = "close")
@EachBean(KinesisConfiguration.class)
KinesisAsyncClient kinesisAsync(KinesisConfiguration configuration, AwsCredentialsProvider credentialsProvider, AwsRegionProvider awsRegionProvider, Optional<SdkAsyncHttpClient> httpClient) {
    KinesisAsyncClientBuilder builder = KinesisAsyncClient.builder().credentialsProvider(credentialsProvider);
    configuration.configure(builder, awsRegionProvider);
    httpClient.ifPresent(builder::httpClient);
    return builder.build();
}
Also used : KinesisAsyncClientBuilder(software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder) Singleton(javax.inject.Singleton) EachBean(io.micronaut.context.annotation.EachBean) Bean(io.micronaut.context.annotation.Bean) EachBean(io.micronaut.context.annotation.EachBean)

Example 5 with KinesisAsyncClientBuilder

use of software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder in project aws-sdk by reactiverse.

the class ProxyTest method testGetThroughProxy.

@Test
@Timeout(value = 15, timeUnit = TimeUnit.SECONDS)
public void testGetThroughProxy(VertxTestContext ctx) throws Exception {
    final KinesisAsyncClientBuilder builder = KinesisAsyncClient.builder().region(Region.EU_WEST_1).endpointOverride(// something that just doesn't exist, the only thing that matters is that every request has traveled through proxy
    new URI("http://localhost:1111")).credentialsProvider(credentialsProvider);
    HttpClientOptions throughProxyOptions = new HttpClientOptions().setProxyOptions(new ProxyOptions().setHost(PROXY_HOST).setPort(PROXY_PORT));
    KinesisAsyncClient kinesis = VertxSdkClient.withVertx(builder, throughProxyOptions, vertx.getOrCreateContext()).build();
    assertEquals(proxyAccess.get(), 0, "Proxy access count should have been reset");
    kinesis.listStreams().handle((res, err) -> {
        assertTrue(proxyAccess.get() > 0, "Requests should have been transferred through proxy");
        ctx.completeNow();
        return null;
    });
}
Also used : KinesisAsyncClient(software.amazon.awssdk.services.kinesis.KinesisAsyncClient) ProxyOptions(io.vertx.core.net.ProxyOptions) KinesisAsyncClientBuilder(software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder) URI(java.net.URI) HttpClientOptions(io.vertx.core.http.HttpClientOptions) Test(org.junit.jupiter.api.Test) Timeout(io.vertx.junit5.Timeout)

Aggregations

KinesisAsyncClientBuilder (software.amazon.awssdk.services.kinesis.KinesisAsyncClientBuilder)5 URI (java.net.URI)2 KinesisAsyncClient (software.amazon.awssdk.services.kinesis.KinesisAsyncClient)2 Bean (io.micronaut.context.annotation.Bean)1 EachBean (io.micronaut.context.annotation.EachBean)1 HttpClientOptions (io.vertx.core.http.HttpClientOptions)1 ProxyOptions (io.vertx.core.net.ProxyOptions)1 Timeout (io.vertx.junit5.Timeout)1 Singleton (javax.inject.Singleton)1 Test (org.junit.jupiter.api.Test)1 AwsCredentialsProvider (software.amazon.awssdk.auth.credentials.AwsCredentialsProvider)1 Region (software.amazon.awssdk.regions.Region)1 CloudWatchAsyncClient (software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient)1 CloudWatchAsyncClientBuilder (software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClientBuilder)1 DynamoDbAsyncClient (software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient)1 DynamoDbAsyncClientBuilder (software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClientBuilder)1 ConfigsBuilder (software.amazon.kinesis.common.ConfigsBuilder)1 Scheduler (software.amazon.kinesis.coordinator.Scheduler)1 PollingConfig (software.amazon.kinesis.retrieval.polling.PollingConfig)1