From 465f48aa3a3798380a585a49a3f289000c7800bb Mon Sep 17 00:00:00 2001 From: Raunaq Morarka Date: Wed, 18 Dec 2024 13:28:10 +0530 Subject: [PATCH] Bind filesystem cache metrics per catalog --- lib/trino-filesystem-cache-alluxio/pom.xml | 11 +++++------ .../alluxio/AlluxioFileSystemCacheModule.java | 6 +++++- .../trino/tests/product/utils/CachingTestUtils.java | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/trino-filesystem-cache-alluxio/pom.xml b/lib/trino-filesystem-cache-alluxio/pom.xml index f66de3c15c38..f169d718b470 100644 --- a/lib/trino-filesystem-cache-alluxio/pom.xml +++ b/lib/trino-filesystem-cache-alluxio/pom.xml @@ -63,6 +63,11 @@ trino-filesystem + + io.trino + trino-spi + + jakarta.annotation jakarta.annotation-api @@ -112,12 +117,6 @@ runtime - - io.trino - trino-spi - runtime - - io.airlift junit-extensions diff --git a/lib/trino-filesystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioFileSystemCacheModule.java b/lib/trino-filesystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioFileSystemCacheModule.java index d4acfe96d4c8..4d063e05e5d9 100644 --- a/lib/trino-filesystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioFileSystemCacheModule.java +++ b/lib/trino-filesystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioFileSystemCacheModule.java @@ -16,11 +16,13 @@ import alluxio.metrics.MetricsConfig; import alluxio.metrics.MetricsSystem; import com.google.inject.Binder; +import com.google.inject.Provider; import io.airlift.configuration.AbstractConfigurationAwareModule; import io.trino.filesystem.cache.CachingHostAddressProvider; import io.trino.filesystem.cache.ConsistentHashingHostAddressProvider; import io.trino.filesystem.cache.ConsistentHashingHostAddressProviderConfig; import io.trino.filesystem.cache.TrinoFileSystemCache; +import io.trino.spi.catalog.CatalogName; import java.util.Properties; @@ -45,7 +47,9 @@ protected void setup(Binder binder) configBinder(binder).bindConfig(AlluxioFileSystemCacheConfig.class); configBinder(binder).bindConfig(ConsistentHashingHostAddressProviderConfig.class); binder.bind(AlluxioCacheStats.class).in(SINGLETON); - newExporter(binder).export(AlluxioCacheStats.class).as(generator -> generator.generatedNameOf(AlluxioCacheStats.class)); + Provider catalogName = binder.getProvider(CatalogName.class); + newExporter(binder).export(AlluxioCacheStats.class) + .as(generator -> generator.generatedNameOf(AlluxioCacheStats.class, catalogName.get().toString())); if (isCoordinator) { newOptionalBinder(binder, CachingHostAddressProvider.class).setBinding().to(ConsistentHashingHostAddressProvider.class).in(SINGLETON); diff --git a/testing/trino-product-tests/src/main/java/io/trino/tests/product/utils/CachingTestUtils.java b/testing/trino-product-tests/src/main/java/io/trino/tests/product/utils/CachingTestUtils.java index a1ce1d3a8c95..3e28296ac6e9 100644 --- a/testing/trino-product-tests/src/main/java/io/trino/tests/product/utils/CachingTestUtils.java +++ b/testing/trino-product-tests/src/main/java/io/trino/tests/product/utils/CachingTestUtils.java @@ -27,7 +27,7 @@ public static CacheStats getCacheStats(String catalog) QueryResult queryResult = onTrino().executeQuery("SELECT " + " sum(\"cachereads.alltime.count\") as cachereads, " + " sum(\"externalreads.alltime.count\") as externalreads " + - "FROM jmx.current.\"io.trino.filesystem.alluxio:name=" + catalog + ",type=alluxiocachestats\";"); + "FROM jmx.current.\"io.trino.filesystem.alluxio:catalog=" + catalog + ",name=" + catalog + ",type=alluxiocachestats\";"); double cacheReads = (Double) getOnlyElement(queryResult.rows()) .get(queryResult.tryFindColumnIndex("cachereads").get() - 1);