Skip to content

Commit

Permalink
Bind filesystem cache metrics per catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka committed Dec 18, 2024
1 parent 8205581 commit 465f48a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/trino-filesystem-cache-alluxio/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@
<artifactId>trino-filesystem</artifactId>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand Down Expand Up @@ -112,12 +117,6 @@
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 465f48a

Please sign in to comment.