-
Notifications
You must be signed in to change notification settings - Fork 392
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
[#6024] feat(iceberg): refactor Iceberg credential code to reuse credential component in Gravitino server #6021
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a more meaningful exception instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
} | ||
|
||
@Override | ||
public void close() { | ||
credentialProviders | ||
|
@@ -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) { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
|
||
public static final ConfigEntry<Double> CREDENTIAL_CACHE_EXPIRE_RATIO = | ||
new ConfigBuilder(CredentialConstants.CREDENTIAL_CACHE_EXPIRE_RATIO) | ||
.doc( | ||
|
@@ -91,4 +98,8 @@ public CredentialConfig(Map<String, String> properties) { | |
super(false); | ||
loadFromMap(properties, k -> true); | ||
} | ||
|
||
public CredentialConfig(boolean loadDefaults) { | ||
super(loadDefaults); | ||
} | ||
} |
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.
"There is no credential..."
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.
updated