Skip to content

Commit

Permalink
iceberg rest cache
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Dec 27, 2024
1 parent d49e7eb commit 1582bd3
Show file tree
Hide file tree
Showing 24 changed files with 311 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.apache.gravitino.credential;

public class CredentialConstants {
public static final String CREDENTIAL_PROVIDER_TYPE = "credential-provider-type";
@Deprecated public static final String CREDENTIAL_PROVIDER_TYPE = "credential-provider-type";
public static final String CREDENTIAL_PROVIDERS = "credential-providers";
public static final String CREDENTIAL_CACHE_EXPIRE_RATIO = "credential-cache-expire-ratio";
public static final String CREDENTIAL_CACHE_MAX_SIZE = "credential-cache-max-size";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public Credential getCredential(String credentialType, CredentialContext context
return credentialCache.getCredential(credentialCacheKey, cacheKey -> doGetCredential(cacheKey));
}

// Get credential with only one credential provider.
public Credential getCredential(CredentialContext context) {
if (credentialProviders.size() == 0) {
throw new RuntimeException("There are not any credential provider for the catalog.");
} else if (credentialProviders.size() > 1) {
throw new RuntimeException("There are multiple credential providers for the catalog.");
}
return getCredential(credentialProviders.keySet().iterator().next(), context);
}

@Override
public void close() {
credentialProviders
Expand All @@ -67,6 +77,11 @@ public void close() {
e);
}
});
try {
credentialCache.close();
} catch (IOException e) {
LOG.warn("Close credential cache failed, catalog: {}", catalogName, e);
}
}

private Credential doGetCredential(CredentialCacheKey credentialCacheKey) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public class CredentialConfig extends Config {
false /* reserved */))
.build();

public static final ConfigEntry<String> CREDENTIAL_PROVIDERS =
new ConfigBuilder(CredentialConstants.CREDENTIAL_PROVIDERS)
.doc("Credential providers, separated by comma.")
.version(ConfigConstants.VERSION_0_8_0)
.stringConf()
.create();

public static final ConfigEntry<Double> CREDENTIAL_CACHE_EXPIRE_RATIO =
new ConfigBuilder(CredentialConstants.CREDENTIAL_CACHE_EXPIRE_RATIO)
.doc(
Expand All @@ -91,4 +98,8 @@ public CredentialConfig(Map<String, String> properties) {
super(false);
loadFromMap(properties, k -> true);
}

public CredentialConfig(boolean loadDefaults) {
super(loadDefaults);
}
}
3 changes: 2 additions & 1 deletion dev/docker/iceberg-rest-server/rewrite_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"GRAVITINO_IO_IMPL" : "io-impl",
"GRAVITINO_URI" : "uri",
"GRAVITINO_WAREHOUSE" : "warehouse",
"GRAVITINO_CREDENTIAL_PROVIDER_TYPE" : "credential-provider-type",
"GRAVITINO_CREDENTIAL_PROVIDER_TYPE" : "credential-providers",
"GRAVITINO_CREDENTIAL_PROVIDERS" : "credential-providers",
"GRAVITINO_GCS_CREDENTIAL_FILE_PATH" : "gcs-credential-file-path",
"GRAVITINO_S3_ACCESS_KEY" : "s3-access-key-id",
"GRAVITINO_S3_SECRET_KEY" : "s3-secret-access-key",
Expand Down
Loading

0 comments on commit 1582bd3

Please sign in to comment.