Skip to content

Commit

Permalink
xx
Browse files Browse the repository at this point in the history
  • Loading branch information
FANNG1 committed Dec 25, 2024
1 parent 7df3df6 commit e6fb39c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
21 changes: 11 additions & 10 deletions core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import org.apache.gravitino.connector.authorization.AuthorizationProvider;
import org.apache.gravitino.connector.authorization.BaseAuthorization;
import org.apache.gravitino.connector.capability.Capability;
import org.apache.gravitino.credential.CatalogCredentialProvider;
import org.apache.gravitino.credential.CatalogCredentialOperationDispatcher;
import org.apache.gravitino.meta.CatalogEntity;
import org.apache.gravitino.utils.IsolatedClassLoader;
import org.slf4j.Logger;
Expand Down Expand Up @@ -80,7 +80,7 @@ public abstract class BaseCatalog<T extends BaseCatalog>

private volatile Map<String, String> properties;

private volatile CatalogCredentialProvider catalogCredentialProvider;
private volatile CatalogCredentialOperationDispatcher catalogCredentialOperationDispatcher;

private static String ENTITY_IS_NOT_SET = "entity is not set";

Expand Down Expand Up @@ -262,9 +262,9 @@ public void close() throws IOException {
authorizationPlugin.close();
authorizationPlugin = null;
}
if (catalogCredentialProvider != null) {
catalogCredentialProvider.close();
catalogCredentialProvider = null;
if (catalogCredentialOperationDispatcher != null) {
catalogCredentialOperationDispatcher.close();
catalogCredentialOperationDispatcher = null;
}
}

Expand All @@ -280,15 +280,16 @@ public Capability capability() {
return capability;
}

public CatalogCredentialProvider getCatalogCredentialManager() {
if (catalogCredentialProvider == null) {
public CatalogCredentialOperationDispatcher catalogCredentialOperationDispatcher() {
if (catalogCredentialOperationDispatcher == null) {
synchronized (this) {
if (catalogCredentialProvider == null) {
this.catalogCredentialProvider = new CatalogCredentialProvider(name(), properties());
if (catalogCredentialOperationDispatcher == null) {
this.catalogCredentialOperationDispatcher =
new CatalogCredentialOperationDispatcher(name(), properties());
}
}
}
return catalogCredentialProvider;
return catalogCredentialOperationDispatcher;
}

private CatalogOperations createOps(Map<String, String> conf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Generate credentials for the objects in the same catalog. */
public class CatalogCredentialProvider implements Closeable {
/**
* Manage lifetime of the credential provider in one catalog, dispatch credential request to the
* corresponding credential provider.
*/
public class CatalogCredentialOperationDispatcher implements Closeable {

private static final Logger LOG = LoggerFactory.getLogger(CatalogCredentialProvider.class);
private static final Logger LOG =
LoggerFactory.getLogger(CatalogCredentialOperationDispatcher.class);

private final String catalogName;
private final Map<String, CredentialProvider> credentialProviders;

public CatalogCredentialProvider(String catalogName, Map<String, String> catalogProperties) {
public CatalogCredentialOperationDispatcher(
String catalogName, Map<String, String> catalogProperties) {
this.catalogName = catalogName;
this.credentialProviders = CredentialUtils.loadCredentialProviders(catalogProperties);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private List<Credential> getCredentials(
.map(
entry ->
baseCatalog
.getCatalogCredentialManager()
.catalogCredentialOperationDispatcher()
.getCredential(entry.getKey(), entry.getValue()))
.filter(Objects::nonNull)
.collect(Collectors.toList());
Expand Down

0 comments on commit e6fb39c

Please sign in to comment.