Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4f0a920
Support dlf cache policy control
Jul 23, 2026
15207c6
[jindo] Fix Jindo Hadoop options serialization
Jul 26, 2026
22cbde4
Fix cache fs close
Jul 26, 2026
ef87e8d
[jindo] Support DLF cache VPC validation
Aug 11, 2026
6ad9471
[jindo] Support cache file type whitelist
Aug 11, 2026
7f0ff8d
[jindo] Support combined cache whitelists
Aug 17, 2026
a2ca079
[jindo] Address DLF cache review comments
Aug 18, 2026
991a461
Support cache policy for pypaimon
Nov 8, 2026
456662d
Adapt cache policy tests to current master
Nov 8, 2026
67ff004
[cache] Move REST cache policy above FileIO and preserve legacy Jindo…
Nov 16, 2026
8e8e877
[cache] Preserve token-based FileIO reuse across tables
Nov 19, 2026
3d7a8c2
[cache] Honor server validation and use the standard OSS cache endpoint
Nov 19, 2026
82cfca9
[cache] Remove VPC validation and document cache policy
Nov 19, 2026
0e2ac3d
Fall back to origin when cache policy endpoint is unreachable
Nov 19, 2026
6b3b9ac
Log full exception when cache policy falls back to origin
Nov 20, 2026
5b5c7cd
Fix native format routing and fork lifecycle in cache policy FileIO
Nov 20, 2026
1d88e5d
Preserve native cache policy routing through local block cache
Nov 20, 2026
d7b135d
Honor client cache routing overrides and bypass identical endpoints
Nov 22, 2026
2388f41
Remove cache policy guide from the source repository
Nov 22, 2026
0f98c40
Preserve existing REST catalog option descriptions and annotations
Nov 23, 2026
e7ffe6e
Adapt cache policy writer regression to current Vortex API
Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ public class RESTCatalogOptions {
.withDescription(
"Enable cache for visiting files using file io (currently only JindoFileIO supports cache).");

public static final ConfigOption<String> IO_CACHE_ORIGIN_ENDPOINT =
ConfigOptions.key("io-cache.origin.endpoint")
.stringType()
.noDefaultValue()
.withDescription("The original OSS endpoint used when cache is bypassed.");

public static final ConfigOption<String> IO_CACHE_WHITELIST =
ConfigOptions.key("io-cache.whitelist")
.stringType()
.defaultValue("*")
.withDescription(
"Comma-separated list of file types allowed to use the cache endpoint. "
+ "Supported values: meta, global-index, bucket-index, data, file-index. "
+ "Use * to allow all file types.");

public static final ConfigOption<String> IO_CACHE_WHITELIST_PATH =
ConfigOptions.key("io-cache.whitelist-path")
.stringType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.paimon.fs;

import org.apache.paimon.annotation.VisibleForTesting;
import org.apache.paimon.fs.cache.CachePolicyFileIO;
import org.apache.paimon.rest.RESTTokenFileIO;

import org.slf4j.Logger;
Expand Down Expand Up @@ -111,14 +112,17 @@ private void abortMultipartUpload(FileIO fileIO) throws IOException {
}

private MultiPartUploadStore<T, C> multiPartUploadStore(FileIO fileIO) throws IOException {
if (fileIO instanceof RESTTokenFileIO) {
RESTTokenFileIO restTokenFileIO = (RESTTokenFileIO) fileIO;
fileIO = restTokenFileIO.fileIO();
}
if (fileIO instanceof ResolvingFileIO) {
// The upload was started on the FileIO this resolver resolved to, and
// multiPartUploadStore casts to that concrete type, so resolve again here.
fileIO = ((ResolvingFileIO) fileIO).fileIO(targetPath());
while (true) {
if (fileIO instanceof RESTTokenFileIO) {
fileIO = ((RESTTokenFileIO) fileIO).fileIO();
} else if (fileIO instanceof CachePolicyFileIO) {
// Transactional uploads are always started on the origin endpoint.
fileIO = ((CachePolicyFileIO) fileIO).originFileIO();
} else if (fileIO instanceof ResolvingFileIO) {
fileIO = ((ResolvingFileIO) fileIO).fileIO(targetPath());
} else {
break;
}
}
return multiPartUploadStore(fileIO, targetPath());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.paimon.fs.cache;

import java.io.FileNotFoundException;
import java.io.InterruptedIOException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.nio.file.AccessDeniedException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.NoSuchFileException;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;

/** Identifies transport failures without depending on a filesystem SDK or its class loader. */
final class CacheConnectionFailure {

private CacheConnectionFailure() {}

static boolean isConnectionFailure(Throwable failure) {
Set<Throwable> visited =
Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>());
if (hasLogicalFailure(failure, visited)) {
return false;
}
return isConnectionFailure(
failure, Collections.newSetFromMap(new IdentityHashMap<Throwable, Boolean>()));
}

private static boolean hasLogicalFailure(Throwable failure, Set<Throwable> visited) {
if (failure == null || !visited.add(failure)) {
return false;
}
if (failure instanceof FileNotFoundException
|| failure instanceof NoSuchFileException
|| failure instanceof FileAlreadyExistsException
|| failure instanceof AccessDeniedException
|| failure instanceof SecurityException
|| failure instanceof InterruptedException
|| (failure instanceof InterruptedIOException
&& !(failure instanceof SocketTimeoutException)
&& !isConnectTimeout(failure))) {
return true;
}
return hasLogicalFailure(failure.getCause(), visited);
}

private static boolean isConnectTimeout(Throwable failure) {
// Apache HTTP's connect timeout extends InterruptedIOException, not SocketTimeoutException.
return failure.getClass().getName().endsWith(".ConnectTimeoutException");
}

private static boolean isConnectionFailure(Throwable failure, Set<Throwable> visited) {
if (failure == null || !visited.add(failure)) {
return false;
}
if (failure instanceof SocketException
|| failure instanceof SocketTimeoutException
|| failure instanceof UnknownHostException
|| isConnectTimeout(failure)) {
return true;
}
// Jindo's JNI bridge loses the socket exception and exposes this native error text.
// Match its transport diagnostic, not arbitrary strings such as "timeout" or "failed".
String message = failure.getMessage();
if (message != null
&& (message.startsWith("Failed to connect Http service:")
|| (message.startsWith("ErrorCode : 2001, ErrorMessage :")
&& message.contains("Failed to connect Http service:")))) {
return true;
}
if (isConnectionFailure(failure.getCause(), visited)) {
return true;
}
// FileIO.get retains failed loader probes as suppressed exceptions.
for (Throwable suppressed : failure.getSuppressed()) {
if (isConnectionFailure(suppressed, visited)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.paimon.fs.cache;

import org.apache.paimon.fs.Path;
import org.apache.paimon.options.Options;
import org.apache.paimon.utils.FileType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static org.apache.paimon.rest.RESTCatalogOptions.IO_CACHE_POLICY;
import static org.apache.paimon.rest.RESTCatalogOptions.IO_CACHE_WHITELIST;
import static org.apache.paimon.rest.RESTCatalogOptions.IO_CACHE_WHITELIST_PATH;

/** Backend-independent routing policy supplied by the REST server. */
public final class CachePolicy implements Serializable {

private static final long serialVersionUID = 1L;

private final boolean enabled;
private final boolean metaEnabled;
private final boolean readEnabled;
private final boolean writeEnabled;
private final Set<FileType> whitelist;
private final boolean allPaths;
private final List<String> paths;

public CachePolicy(Options options) {
String policy = options.get(IO_CACHE_POLICY);
enabled = policy != null && !policy.contains("none");
metaEnabled = enabled && policy.contains("meta");
readEnabled = enabled && policy.contains("read");
writeEnabled = enabled && policy.contains("write");
whitelist = FileType.parseWhitelist(options.get(IO_CACHE_WHITELIST));
// Keep the option's original default for legacy JindoCache while remote endpoint
// routing allows all paths by default.
String whitelistPath =
options.contains(IO_CACHE_WHITELIST_PATH)
? options.get(IO_CACHE_WHITELIST_PATH)
: "*";
allPaths = whitelistPath != null && "*".equals(whitelistPath.trim());
paths = new ArrayList<>();
if (whitelistPath != null && !allPaths) {
for (String pattern : whitelistPath.split(",")) {
pattern = pattern.trim();
if (!pattern.isEmpty()) {
paths.add(pattern);
}
}
}
}

public boolean enabled() {
return enabled;
}

public boolean shouldCache(Path path, String operation) {
boolean operationEnabled =
(metaEnabled && "meta".equalsIgnoreCase(operation))
|| (readEnabled && "read".equalsIgnoreCase(operation))
|| (writeEnabled && "write".equalsIgnoreCase(operation));
if (!operationEnabled
|| FileType.isMutable(path)
|| !whitelist.contains(FileType.classify(path))) {
return false;
}
if (allPaths) {
return true;
}
String uriPath = path.toUri().getPath();
for (String pattern : paths) {
if (uriPath.contains(pattern)) {
return true;
}
}
return false;
}
}
Loading
Loading