Skip to content

Commit bd6975c

Browse files
Adds provider for GlueClient, fixes test - TestIcebergPlugin#testGlueMetastore
1 parent a754210 commit bd6975c

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/glue/GlueMetastoreModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
3030
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
3131
import software.amazon.awssdk.services.glue.GlueAsyncClient;
32+
import software.amazon.awssdk.services.glue.GlueClient;
3233
import software.amazon.awssdk.services.glue.model.Table;
3334

3435
import java.util.concurrent.Executor;
@@ -68,7 +69,8 @@ protected void setup(Binder binder)
6869
// export under the old name, for backwards compatibility
6970
binder.bind(GlueHiveMetastoreFactory.class).in(Scopes.SINGLETON);
7071
binder.bind(Key.get(GlueMetastoreStats.class, ForGlueHiveMetastore.class)).toInstance(new GlueMetastoreStats());
71-
binder.bind(GlueAsyncClient.class).toProvider(HiveGlueClientProvider.class).in(Scopes.SINGLETON);
72+
binder.bind(GlueAsyncClient.class).toProvider(HiveGlueAsyncClientProvider.class).in(Scopes.SINGLETON);
73+
binder.bind(GlueClient.class).toProvider(HiveGlueSyncClientProvider.class).in(Scopes.SINGLETON);
7274
newExporter(binder).export(GlueHiveMetastoreFactory.class).as(generator -> generator.generatedNameOf(GlueHiveMetastore.class));
7375

7476
binder.bind(Key.get(boolean.class, AllowHiveTableRename.class)).toInstance(false);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import static io.trino.plugin.hive.metastore.glue.GlueClientUtil.createAsyncGlueClient;
2525
import static java.util.Objects.requireNonNull;
2626

27-
public class HiveGlueClientProvider
27+
public class HiveGlueAsyncClientProvider
2828
implements Provider<GlueAsyncClient>
2929
{
3030
private final GlueMetastoreStats stats;
@@ -33,7 +33,7 @@ public class HiveGlueClientProvider
3333
private final Optional<ExecutionInterceptor> requestHandler;
3434

3535
@Inject
36-
public HiveGlueClientProvider(
36+
public HiveGlueAsyncClientProvider(
3737
@ForGlueHiveMetastore GlueMetastoreStats stats,
3838
AwsCredentialsProvider credentialsProvider,
3939
@ForGlueHiveMetastore Optional<ExecutionInterceptor> requestHandler,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package io.trino.plugin.hive.metastore.glue;
15+
16+
import com.google.inject.Inject;
17+
import com.google.inject.Provider;
18+
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
19+
import software.amazon.awssdk.core.interceptor.ExecutionInterceptor;
20+
import software.amazon.awssdk.services.glue.GlueClient;
21+
22+
import java.util.Optional;
23+
24+
import static io.trino.plugin.hive.metastore.glue.GlueClientUtil.createSyncGlueClient;
25+
import static java.util.Objects.requireNonNull;
26+
27+
public class HiveGlueSyncClientProvider
28+
implements Provider<GlueClient>
29+
{
30+
private final GlueMetastoreStats stats;
31+
private final AwsCredentialsProvider credentialsProvider;
32+
private final GlueHiveMetastoreConfig glueConfig; // TODO do not keep mutable config instance on a field
33+
private final Optional<ExecutionInterceptor> requestHandler;
34+
35+
@Inject
36+
public HiveGlueSyncClientProvider(
37+
@ForGlueHiveMetastore GlueMetastoreStats stats,
38+
AwsCredentialsProvider credentialsProvider,
39+
@ForGlueHiveMetastore Optional<ExecutionInterceptor> requestHandler,
40+
GlueHiveMetastoreConfig glueConfig)
41+
{
42+
this.stats = requireNonNull(stats, "stats is null");
43+
this.credentialsProvider = requireNonNull(credentialsProvider, "credentialsProvider is null");
44+
this.requestHandler = requireNonNull(requestHandler, "requestHandler is null");
45+
this.glueConfig = glueConfig;
46+
}
47+
48+
@Override
49+
public GlueClient get()
50+
{
51+
return createSyncGlueClient(glueConfig, credentialsProvider, requestHandler, stats.newRequestMetricsPublisher());
52+
}
53+
}

plugin/trino-hive/src/test/java/io/trino/plugin/hive/metastore/glue/TestHiveGlueMetastore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import io.trino.plugin.hive.HiveMetastoreClosure;
2424
import io.trino.plugin.hive.HiveType;
2525
import io.trino.plugin.hive.PartitionStatistics;
26-
import io.trino.plugin.hive.aws.AwsApiCallStats;
2726
import io.trino.plugin.hive.metastore.HiveColumnStatistics;
2827
import io.trino.plugin.hive.metastore.HiveMetastore;
2928
import io.trino.plugin.hive.metastore.PartitionWithStatistics;
@@ -270,7 +269,7 @@ public void cleanupOrphanedDatabases()
270269
.forEach(database -> {
271270
orphanedDbBuilder.add(database.name());
272271
}),
273-
new AwsApiCallStats());
272+
stats.getGetDatabases());
274273

275274
List<String> orphanedDatabases = orphanedDbBuilder.build();
276275

0 commit comments

Comments
 (0)