Исключение при попытке подключения к AWS Athena с использованием JAVA API

Я пытаюсь выполнить запрос в AWS Athena, используя Java API:

public class AthenaClientFactory
{     
    String accessKey = "access";
    String secretKey = "secret";
    BasicAWSCredentials awsCredentials = new 
    BasicAWSCredentials(accessKey, secretKey);

    private final AmazonAthenaClientBuilder builder = AmazonAthenaClientBuilder.standard()
            .withRegion(Regions.US_WEST_1)
            .withCredentials(new AWSStaticCredentialsProvider(awsCredentials))
            .withClientConfiguration(new ClientConfiguration().withClientExecutionTimeout(10));

    public AmazonAthena createClient()
    {
        return builder.build();
    }
}


private static String submitAthenaQuery(AmazonAthena client) {
        QueryExecutionContext queryExecutionContext = new QueryExecutionContext().withDatabase("my_db");

        ResultConfiguration resultConfiguration = new ResultConfiguration().withOutputLocation("my_bucket");

        StartQueryExecutionRequest startQueryExecutionRequest = new StartQueryExecutionRequest()
                                                                    .withQueryString("select * from my_db limit 3;")
                                                                    .withQueryExecutionContext(queryExecutionContext)
                                                                    .withResultConfiguration(resultConfiguration);

        StartQueryExecutionResult startQueryExecutionResult = client.startQueryExecution(startQueryExecutionRequest);
        return startQueryExecutionResult.getQueryExecutionId();
}   

public void run() throws InterruptedException {
        AthenaClientFactory factory = new AthenaClientFactory();
        AmazonAthena client = factory.createClient(); 

        String queryExecutionId = submitAthenaQuery(client);
}

Но я получаю исключение из startQueryExecutionResult. Исключение составляет:

Выполнение клиента не завершилось до указанной конфигурации тайм-аута.

Кто-нибудь сталкивался с чем-то подобным?


person Alex L    schedule 14.03.2018    source источник
comment
Я получаю Exception in thread "main" java.lang.NoClassDefFoundError при запуске примера   -  person Abhilash Bolla    schedule 17.01.2019


Ответы (1)


Проблема была в withClientExecutionTimeout(10).

Увеличение этого числа до 5000 решило проблему

person Alex L    schedule 14.03.2018