KKcorps commented on a change in pull request #8333: URL: https://github.com/apache/pinot/pull/8333#discussion_r825711460
########## File path: pinot-plugins/pinot-stream-ingestion/pinot-kinesis/src/main/java/org/apache/pinot/plugin/stream/kinesis/server/KinesisDataServerStartable.java ########## @@ -0,0 +1,120 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.plugin.stream.kinesis.server; + +import cloud.localstack.Localstack; +import cloud.localstack.ServiceName; +import cloud.localstack.docker.annotation.LocalstackDockerConfiguration; +import java.net.URI; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import org.apache.pinot.spi.stream.StreamDataServerStartable; +import org.apache.pinot.spi.utils.NetUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.http.SdkHttpConfigurationOption; +import software.amazon.awssdk.http.apache.ApacheSdkHttpService; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.kinesis.KinesisClient; +import software.amazon.awssdk.services.kinesis.model.CreateStreamRequest; +import software.amazon.awssdk.services.kinesis.model.DescribeStreamRequest; +import software.amazon.awssdk.utils.AttributeMap; + + +public class KinesisDataServerStartable implements StreamDataServerStartable { + private static final Logger LOGGER = LoggerFactory.getLogger(KinesisDataServerStartable.class); + + public static final String NUM_SHARDS_PROPERTY = "numShards"; + public static final String DEFAULT_REGION = "us-east-1"; + public static final String DEFAULT_ACCESS_KEY = "access"; + public static final String DEFAULT_SECRET_KEY = "secret"; + public static final String DEFAULT_PORT = "4566"; + + private final Localstack _localstackDocker = Localstack.INSTANCE; + LocalstackDockerConfiguration _dockerConfig; + Properties _serverProperties; + private String _localStackKinesisEndpoint = "http://localhost:%s"; + + @Override + public void init(Properties props) { + _serverProperties = props; + final Map<String, String> environmentVariables = new HashMap<>(); + environmentVariables.put("SERVICES", ServiceName.KINESIS); + _dockerConfig = + LocalstackDockerConfiguration.builder().portEdge(_serverProperties.getProperty("port", DEFAULT_PORT)) + .portElasticSearch(String.valueOf(NetUtils.findOpenPort(4571))).imageTag("0.12.15") + .environmentVariables(environmentVariables).build(); + + _localStackKinesisEndpoint = + String.format(_localStackKinesisEndpoint, _serverProperties.getProperty("port", DEFAULT_PORT)); + } + + @Override + public void start() { + _localstackDocker.startup(_dockerConfig); + } + + @Override + public void stop() { + _localstackDocker.stop(); + } + + @Override + public void createTopic(String topic, Properties topicProps) { + try { + KinesisClient kinesisClient = KinesisClient.builder().httpClient( Review comment: I can do that but I will prefer it to do in a seperate PR. Reason being, it will affect KinesisConnectionHandler and KinesisIntegrationTest as well. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org