-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yufei Gu
committed
Mar 9, 2025
1 parent
e6d553c
commit 1db510d
Showing
33 changed files
with
2,336 additions
and
449 deletions.
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
93 changes: 93 additions & 0 deletions
93
polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.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,93 @@ | ||
/* | ||
* 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.polaris.core.persistence.dao; | ||
|
||
import jakarta.annotation.Nonnull; | ||
import java.util.List; | ||
import org.apache.polaris.core.PolarisCallContext; | ||
import org.apache.polaris.core.entity.PolarisEntityId; | ||
import org.apache.polaris.core.persistence.dao.entity.BaseResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ChangeTrackingResult; | ||
import org.apache.polaris.core.persistence.dao.entity.EntityResult; | ||
import org.apache.polaris.core.persistence.dao.entity.GenerateEntityIdResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; | ||
|
||
public interface CommonDao { | ||
/** | ||
* Generate a new unique id that can be used by the Polaris client when it needs to create a new | ||
* entity | ||
* | ||
* @param callCtx call context | ||
* @return the newly created id, not expected to fail | ||
*/ | ||
@Nonnull | ||
GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx); | ||
|
||
/** | ||
* Bootstrap the Polaris service, creating the root catalog, root principal, and associated | ||
* service admin role. Will fail if the service has already been bootstrapped. | ||
* | ||
* @param callCtx call context | ||
* @return the result of the bootstrap attempt | ||
*/ | ||
@Nonnull | ||
BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx); | ||
|
||
/** | ||
* Purge all metadata associated with the Polaris service, resetting the metastore to the state it | ||
* was in prior to bootstrapping. | ||
* | ||
* <p>*************************** WARNING ************************ | ||
* | ||
* <p>This will destroy whatever Polaris metadata exists in the metastore | ||
* | ||
* @param callCtx call context | ||
* @return always success or unexpected error | ||
*/ | ||
@Nonnull | ||
BaseResult purge(@Nonnull PolarisCallContext callCtx); | ||
|
||
/** For ROOT only */ | ||
@Nonnull | ||
ResolvedEntityResult loadResolvedEntityByName( | ||
@Nonnull PolarisCallContext callCtx, | ||
long entityCatalogId, | ||
long parentId, | ||
@Nonnull String entityName); | ||
|
||
@Nonnull | ||
ChangeTrackingResult loadEntitiesChangeTracking( | ||
@Nonnull PolarisCallContext callCtx, @Nonnull List<PolarisEntityId> entityIds); | ||
|
||
/** For ROOT only */ | ||
@Nonnull | ||
ResolvedEntityResult refreshResolvedEntity( | ||
@Nonnull PolarisCallContext callCtx, | ||
int entityVersion, | ||
int entityGrantRecordsVersion, | ||
long entityCatalogId, | ||
long entityId); | ||
|
||
/** | ||
* only for NULL_TYPE, looks like this is only used by Tests. We could remove this method if it is | ||
* only used by tests. | ||
*/ | ||
@Nonnull | ||
EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); | ||
} |
94 changes: 94 additions & 0 deletions
94
polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CredentialVendorDao.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,94 @@ | ||
/* | ||
* 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.polaris.core.persistence.dao; | ||
|
||
import jakarta.annotation.Nonnull; | ||
import java.util.Set; | ||
import org.apache.polaris.core.PolarisCallContext; | ||
import org.apache.polaris.core.entity.PolarisEntityType; | ||
import org.apache.polaris.core.storage.PolarisCredentialVendor; | ||
import org.apache.polaris.core.storage.PolarisStorageActions; | ||
|
||
/** This seems not necessarily to be a DAO, keep it here for future refactor */ | ||
public interface CredentialVendorDao { | ||
/** | ||
* Get a sub-scoped credentials for an entity against the provided allowed read and write | ||
* locations. | ||
* | ||
* @param callCtx the polaris call context | ||
* @param catalogId the catalog id | ||
* @param entityId the entity id | ||
* @param allowListOperation whether to allow LIST operation on the allowedReadLocations and | ||
* allowedWriteLocations | ||
* @param allowedReadLocations a set of allowed to read locations | ||
* @param allowedWriteLocations a set of allowed to write locations | ||
* @return an enum map containing the scoped credentials | ||
*/ | ||
@Nonnull | ||
PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntity( | ||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long entityId, | ||
PolarisEntityType entityType, | ||
boolean allowListOperation, | ||
@Nonnull Set<String> allowedReadLocations, | ||
@Nonnull Set<String> allowedWriteLocations); | ||
|
||
/** | ||
* Validate whether the entity has access to the locations with the provided target operations | ||
* | ||
* @param callCtx the polaris call context | ||
* @param catalogId the catalog id | ||
* @param entityId the entity id | ||
* @param actions a set of operation actions: READ/WRITE/LIST/DELETE/ALL | ||
* @param locations a set of locations to verify | ||
* @return a Map of {@code <location, validate result>}, a validate result value looks like this | ||
* <pre> | ||
* { | ||
* "status" : "failure", | ||
* "actions" : { | ||
* "READ" : { | ||
* "message" : "The specified file was not found", | ||
* "status" : "failure" | ||
* }, | ||
* "DELETE" : { | ||
* "message" : "One or more objects could not be deleted (Status Code: 200; Error Code: null)", | ||
* "status" : "failure" | ||
* }, | ||
* "LIST" : { | ||
* "status" : "success" | ||
* }, | ||
* "WRITE" : { | ||
* "message" : "Access Denied (Status Code: 403; Error Code: AccessDenied)", | ||
* "status" : "failure" | ||
* } | ||
* }, | ||
* "message" : "Some of the integration checks failed. Check the Polaris documentation for more information." | ||
* } | ||
* </pre> | ||
*/ | ||
@Nonnull | ||
PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( | ||
@Nonnull PolarisCallContext callCtx, | ||
long catalogId, | ||
long entityId, | ||
PolarisEntityType entityType, | ||
@Nonnull Set<PolarisStorageActions> actions, | ||
@Nonnull Set<String> locations); | ||
} |
Oops, something went wrong.