-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Alluxio cache #18719
Merged
Merged
Alluxio cache #18719
Changes from 1 commit
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 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 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 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 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
133 changes: 133 additions & 0 deletions
133
lib/trino-filesystem/src/main/java/io/trino/filesystem/cache/CacheFileSystem.java
This file contains 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,133 @@ | ||
/* | ||
* 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.cache; | ||
|
||
import io.trino.filesystem.FileIterator; | ||
import io.trino.filesystem.Location; | ||
import io.trino.filesystem.TrinoFileSystem; | ||
import io.trino.filesystem.TrinoInputFile; | ||
import io.trino.filesystem.TrinoOutputFile; | ||
|
||
import java.io.IOException; | ||
import java.io.UncheckedIOException; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public final class CacheFileSystem | ||
implements TrinoFileSystem | ||
{ | ||
private final TrinoFileSystem delegate; | ||
private final TrinoFileSystemCache cache; | ||
private final CacheKeyProvider keyProvider; | ||
|
||
public CacheFileSystem(TrinoFileSystem delegate, TrinoFileSystemCache cache, CacheKeyProvider keyProvider) | ||
{ | ||
this.delegate = requireNonNull(delegate, "delegate is null"); | ||
this.cache = requireNonNull(cache, "cache is null"); | ||
this.keyProvider = requireNonNull(keyProvider, "keyProvider is null"); | ||
} | ||
|
||
@Override | ||
public TrinoInputFile newInputFile(Location location) | ||
{ | ||
return new CacheInputFile(delegate.newInputFile(location), cache, keyProvider); | ||
} | ||
|
||
@Override | ||
public TrinoInputFile newInputFile(Location location, long length) | ||
{ | ||
return new CacheInputFile(delegate.newInputFile(location, length), cache, keyProvider); | ||
} | ||
|
||
@Override | ||
public TrinoOutputFile newOutputFile(Location location) | ||
{ | ||
TrinoOutputFile output = delegate.newOutputFile(location); | ||
try { | ||
cache.expire(location); | ||
} | ||
catch (IOException e) { | ||
throw new UncheckedIOException(e); | ||
} | ||
return output; | ||
} | ||
|
||
@Override | ||
public void deleteFile(Location location) | ||
throws IOException | ||
{ | ||
delegate.deleteFile(location); | ||
raunaqmorarka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cache.expire(location); | ||
} | ||
|
||
@Override | ||
public void deleteDirectory(Location location) | ||
throws IOException | ||
{ | ||
delegate.deleteDirectory(location); | ||
} | ||
|
||
@Override | ||
public void renameFile(Location source, Location target) | ||
raunaqmorarka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throws IOException | ||
{ | ||
delegate.renameFile(source, target); | ||
cache.expire(source); | ||
cache.expire(target); | ||
} | ||
|
||
@Override | ||
public FileIterator listFiles(Location location) | ||
throws IOException | ||
{ | ||
return delegate.listFiles(location); | ||
} | ||
|
||
@Override | ||
public Optional<Boolean> directoryExists(Location location) | ||
throws IOException | ||
{ | ||
return delegate.directoryExists(location); | ||
} | ||
|
||
@Override | ||
public void createDirectory(Location location) | ||
throws IOException | ||
{ | ||
delegate.createDirectory(location); | ||
} | ||
|
||
@Override | ||
public void renameDirectory(Location source, Location target) | ||
throws IOException | ||
{ | ||
delegate.renameDirectory(source, target); | ||
} | ||
|
||
@Override | ||
public Set<Location> listDirectories(Location location) | ||
throws IOException | ||
{ | ||
return delegate.listDirectories(location); | ||
} | ||
|
||
@Override | ||
public Optional<Location> createTemporaryDirectory(Location targetPath, String temporaryPrefix, String relativePrefix) | ||
throws IOException | ||
{ | ||
return delegate.createTemporaryDirectory(targetPath, temporaryPrefix, relativePrefix); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
lib/trino-filesystem/src/main/java/io/trino/filesystem/cache/CacheFileSystemFactory.java
This file contains 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,41 @@ | ||
/* | ||
* 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.cache; | ||
|
||
import io.trino.filesystem.TrinoFileSystem; | ||
import io.trino.filesystem.TrinoFileSystemFactory; | ||
import io.trino.spi.security.ConnectorIdentity; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public final class CacheFileSystemFactory | ||
implements TrinoFileSystemFactory | ||
{ | ||
private final TrinoFileSystemFactory delegate; | ||
private final TrinoFileSystemCache cache; | ||
private final CacheKeyProvider keyProvider; | ||
|
||
public CacheFileSystemFactory(TrinoFileSystemFactory delegate, TrinoFileSystemCache cache, CacheKeyProvider keyProvider) | ||
{ | ||
this.delegate = requireNonNull(delegate, "delegate is null"); | ||
this.cache = requireNonNull(cache, "cache is null"); | ||
this.keyProvider = requireNonNull(keyProvider, "keyProvider is null"); | ||
} | ||
|
||
@Override | ||
public TrinoFileSystem create(ConnectorIdentity identity) | ||
{ | ||
return new CacheFileSystem(delegate.create(identity), cache, keyProvider); | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than using an optional binder here, the configured cache implementation should bind the implementation. So the
NONE
cache should installNoCachingHostAddressProvider
andALLUXIO
should installConsistentHashingHostAddressProvider
.