-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Alluxio cache #18719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Alluxio cache #18719
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3afd696
Add NodeProvider interface, and use it in Delta Lake
jkylling 88562de
Add CacheFileSystem
jkylling f6be87d
Add Alluxio cache
jkylling ce3433a
Add scheduleOnCoordinator option to TestingNodeManager
jkylling 5165069
Add ConsistentHashingNodeProvider
jkylling 97e8df7
Add Delta Lake Alluxio cache
jkylling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-root</artifactId> | ||
| <version>438-SNAPSHOT</version> | ||
| <relativePath>../../pom.xml</relativePath> | ||
| </parent> | ||
|
|
||
| <artifactId>trino-filesystem-cache-alluxio</artifactId> | ||
| <description>Trino Filesystem - Alluxio</description> | ||
|
|
||
| <properties> | ||
| <air.main.basedir>${project.parent.basedir}</air.main.basedir> | ||
| <air.compiler.fail-warnings>true</air.compiler.fail-warnings> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.google.errorprone</groupId> | ||
| <artifactId>error_prone_annotations</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.guava</groupId> | ||
| <artifactId>guava</artifactId> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>com.google.code.findbugs</groupId> | ||
| <artifactId>jsr305</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.google.inject</groupId> | ||
| <artifactId>guice</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>configuration</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>stats</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>units</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-filesystem</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>jakarta.validation</groupId> | ||
| <artifactId>jakarta.validation-api</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.alluxio</groupId> | ||
| <artifactId>alluxio-core-client-fs</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.alluxio</groupId> | ||
| <artifactId>alluxio-core-common</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.weakref</groupId> | ||
| <artifactId>jmxutils</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>slice</artifactId> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-spi</artifactId> | ||
| <scope>runtime</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.airlift</groupId> | ||
| <artifactId>log-manager</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-client</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-filesystem</artifactId> | ||
| <version>${project.version}</version> | ||
| <classifier>tests</classifier> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-main</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino</groupId> | ||
| <artifactId>trino-testing</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>io.trino.hive</groupId> | ||
| <artifactId>hive-apache</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>it.unimi.dsi</groupId> | ||
| <artifactId>fastutil</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-api</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter-engine</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
54 changes: 54 additions & 0 deletions
54
...filesystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioCacheStats.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.filesystem.alluxio; | ||
|
|
||
| import com.google.errorprone.annotations.ThreadSafe; | ||
| import io.airlift.stats.DistributionStat; | ||
| import io.trino.filesystem.Location; | ||
| import org.weakref.jmx.Managed; | ||
| import org.weakref.jmx.Nested; | ||
|
|
||
| @ThreadSafe | ||
| public class AlluxioCacheStats | ||
| implements CacheStats | ||
| { | ||
| private final DistributionStat externalReads = new DistributionStat(); | ||
| private final DistributionStat cacheReads = new DistributionStat(); | ||
|
|
||
| @Managed | ||
|
raunaqmorarka marked this conversation as resolved.
Outdated
|
||
| @Nested | ||
| public DistributionStat getExternalReads() | ||
| { | ||
| return externalReads; | ||
| } | ||
|
|
||
| @Managed | ||
|
raunaqmorarka marked this conversation as resolved.
Outdated
|
||
| @Nested | ||
| public DistributionStat getCacheReads() | ||
| { | ||
| return cacheReads; | ||
| } | ||
|
|
||
| @Override | ||
| public void recordCacheRead(Location location, int length) | ||
| { | ||
| cacheReads.add(length); | ||
| } | ||
|
|
||
| @Override | ||
| public void recordExternalRead(Location location, int length) | ||
| { | ||
| externalReads.add(length); | ||
| } | ||
| } | ||
82 changes: 82 additions & 0 deletions
82
...ystem-cache-alluxio/src/main/java/io/trino/filesystem/alluxio/AlluxioFileSystemCache.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package io.trino.filesystem.alluxio; | ||
|
|
||
| import alluxio.client.file.CacheContext; | ||
| import alluxio.client.file.URIStatus; | ||
| import alluxio.client.file.cache.CacheManager; | ||
| import alluxio.conf.AlluxioConfiguration; | ||
| import alluxio.wire.FileInfo; | ||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.hash.HashFunction; | ||
| import com.google.common.hash.Hashing; | ||
| import com.google.inject.Inject; | ||
| import io.trino.filesystem.Location; | ||
| import io.trino.filesystem.TrinoInput; | ||
| import io.trino.filesystem.TrinoInputFile; | ||
| import io.trino.filesystem.TrinoInputStream; | ||
| import io.trino.filesystem.cache.TrinoFileSystemCache; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| import static java.nio.charset.StandardCharsets.UTF_8; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
||
| public class AlluxioFileSystemCache | ||
| implements TrinoFileSystemCache | ||
| { | ||
| private final CacheManager cacheManager; | ||
| private final AlluxioConfiguration config; | ||
| private final CacheStats statistics; | ||
| private final HashFunction hashFunction = Hashing.murmur3_128(); | ||
|
|
||
| @Inject | ||
| public AlluxioFileSystemCache(CacheManager cacheManager, AlluxioConfiguration config, CacheStats statistics) | ||
| { | ||
| this.cacheManager = requireNonNull(cacheManager, "cacheManager is null"); | ||
| this.config = requireNonNull(config, "config is null"); | ||
| this.statistics = requireNonNull(statistics, "statistics is null"); | ||
| } | ||
|
|
||
| @Override | ||
| public TrinoInput cacheInput(TrinoInputFile delegate, String key) | ||
| throws IOException | ||
| { | ||
| return new AlluxioInput(delegate, uriStatus(delegate, key), cacheManager, config, statistics); | ||
| } | ||
|
|
||
| @Override | ||
| public TrinoInputStream cacheStream(TrinoInputFile delegate, String key) | ||
| throws IOException | ||
| { | ||
| return new AlluxioInputStream(delegate, uriStatus(delegate, key), cacheManager, config, statistics); | ||
| } | ||
|
|
||
| @Override | ||
| public void expire(Location source) | ||
| throws IOException | ||
| { | ||
| } | ||
|
|
||
| @VisibleForTesting | ||
| protected URIStatus uriStatus(TrinoInputFile file, String key) | ||
| throws IOException | ||
| { | ||
| FileInfo info = new FileInfo() | ||
| .setPath(file.location().toString()) | ||
| .setLength(file.length()); | ||
| String cacheIdentifier = hashFunction.hashString(key, UTF_8).toString(); | ||
| return new URIStatus(info, CacheContext.defaults().setCacheIdentifier(cacheIdentifier)); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.