Я пытаюсь сделать POC для AWS Athena, используя Java. Я использую пример кода, указанный в https://docs.aws.amazon.com/athena/latest/ug/code-samples.html
BasicAWSCredentials awsCredentials = new BasicAWSCredentials("accesskey","secretkey");
private final AmazonAthenaClientBuilder builder = AmazonAthenaClientBuilder.standard()
.withRegion(Regions.US_EAST_1)
.withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
.withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(5000));
public AmazonAthena createClient()
{
return builder.build();
}
=============================================================
public class StartQueryExample
{
public static void main(String[] args) throws InterruptedException
{
AthenaClientFactory factory = new AthenaClientFactory();
AmazonAthena client = factory.createClient();
String queryExecutionId = submitAthenaQuery(client);
}
private static String submitAthenaQuery(AmazonAthena client)
{
QueryExecutionContext queryExecutionContext = new QueryExecutionContext().withDatabase("DB_Name");
ResultConfiguration resultConfiguration = new ResultConfiguration()
.withOutputLocation("s3://bucket_name/results");
StartQueryExecutionRequest startQueryExecutionRequest = new StartQueryExecutionRequest()
.withQueryString("select * from tablename")
.withQueryExecutionContext(queryExecutionContext)
.withResultConfiguration(resultConfiguration);
StartQueryExecutionResult startQueryExecutionResult = client.startQueryExecution(startQueryExecutionRequest);
return startQueryExecutionResult.getQueryExecutionId();
}
Пример таблицы содержит только 6 строк и 2 столбца.
Я попытался запустить код с помощью Boto3, и он отлично работает.
Но при запуске из Java я получаю исключение ClientExecutionTimeoutException:
Exception in thread "main" **com.amazonaws.http.timers.client.ClientExecutionTimeoutException: Client execution did not complete before the specified timeout configuration.**
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleAbortedException(AmazonHttpClient.java:813)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:703)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
at com.amazonaws.services.athena.AmazonAthenaClient.doInvoke(AmazonAthenaClient.java:813)
at com.amazonaws.services.athena.AmazonAthenaClient.invoke(AmazonAthenaClient.java:789)
at com.amazonaws.services.athena.AmazonAthenaClient.executeStartQueryExecution(AmazonAthenaClient.java:694)
at com.amazonaws.services.athena.AmazonAthenaClient.startQueryExecution(AmazonAthenaClient.java:669)
at com.capitalone.aws.athena.StartQueryExample.submitAthenaQuery(StartQueryExample.java:60)
at com.capitalone.aws.athena.StartQueryExample.main(StartQueryExample.java:32)
Я попытался запустить его из eclipse, а также попытался создать jar и запустить его на экземпляре ec2 с использованием роли Athena IAM.
Любая помощь будет полезна.
Спасибо