-
Notifications
You must be signed in to change notification settings - Fork 272
Separate Polaris Entities #1128
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e6d553c
POC: Separate Polaris Entities
1db510d
All tests passed
f3bc46c
Make the EclipseLinkMetastore tests work
85cce3a
Make the TreeMapMetastoreManager tests work
7bc5704
Reformat
c0a0b89
Rename
3a7b209
Refactor
67e714a
Refactor PrincipalDao
199b60c
Refactor TaskDao
953770d
Refactor PrincipalRoleDao
d173d1a
Use jarkarta Nonnull and Nullable instead of jetbrain ones
7451a34
Refactor
25a37f6
Refactor
2438108
Refactor
900dd8e
Resolve comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java
This file contains hidden or 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,74 @@ | ||
/* | ||
* 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 jakarta.annotation.Nullable; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.polaris.core.PolarisCallContext; | ||
import org.apache.polaris.core.entity.PolarisBaseEntity; | ||
import org.apache.polaris.core.entity.PolarisEntityCore; | ||
import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; | ||
import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; | ||
import org.apache.polaris.core.persistence.dao.entity.EntityResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; | ||
|
||
public interface CatalogDao { | ||
CreateCatalogResult createCatalog( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nonnull PolarisBaseEntity catalog, | ||
@Nonnull List<PolarisEntityCore> principalRoles); | ||
|
||
@Nonnull | ||
EntityResult updateEntityPropertiesIfNotChanged( | ||
@Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); | ||
|
||
@Nonnull | ||
DropEntityResult dropEntityIfExists( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nonnull PolarisEntityCore entityToDrop, | ||
@Nullable Map<String, String> cleanupProperties, | ||
boolean cleanup); | ||
|
||
// TODO this should return a type-specific entity result, e.g., CatalogEntityResult | ||
@Nonnull | ||
EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); | ||
|
||
@Nonnull | ||
EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId); | ||
|
||
@Nonnull | ||
ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); | ||
|
||
@Nonnull | ||
ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long entityId); | ||
|
||
@Nonnull | ||
ResolvedEntityResult loadResolvedEntityByName( | ||
@Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName); | ||
|
||
@Nonnull | ||
ResolvedEntityResult refreshResolvedEntity( | ||
@Nonnull PolarisCallContext callCtx, | ||
int entityVersion, | ||
int entityGrantRecordsVersion, | ||
long entityId); | ||
} |
85 changes: 85 additions & 0 deletions
85
polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java
This file contains hidden or 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,85 @@ | ||
/* | ||
* 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 jakarta.annotation.Nullable; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.apache.polaris.core.PolarisCallContext; | ||
import org.apache.polaris.core.entity.PolarisBaseEntity; | ||
import org.apache.polaris.core.entity.PolarisEntityCore; | ||
import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; | ||
import org.apache.polaris.core.persistence.dao.entity.EntityResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; | ||
import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; | ||
|
||
public interface CatalogRoleDao { | ||
@Nonnull | ||
EntityResult readEntityByName( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nullable List<PolarisEntityCore> catalogPath, | ||
@Nonnull String name); | ||
|
||
@Nonnull | ||
EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); | ||
|
||
@Nonnull | ||
ListEntitiesResult listEntities( | ||
@Nonnull PolarisCallContext callCtx, @Nullable List<PolarisEntityCore> catalogPath); | ||
|
||
@Nonnull | ||
ResolvedEntityResult loadResolvedEntityById( | ||
@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); | ||
|
||
@Nonnull | ||
ResolvedEntityResult loadResolvedEntityByName( | ||
@Nonnull PolarisCallContext callCtx, | ||
long entityCatalogId, | ||
long parentId, | ||
@Nonnull String entityName); | ||
|
||
@Nonnull | ||
ResolvedEntityResult refreshResolvedEntity( | ||
@Nonnull PolarisCallContext callCtx, | ||
int entityVersion, | ||
int entityGrantRecordsVersion, | ||
long entityCatalogId, | ||
long entityId); | ||
|
||
@Nonnull | ||
EntityResult createEntityIfNotExists( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nullable List<PolarisEntityCore> catalogPath, | ||
@Nonnull PolarisBaseEntity entity); | ||
|
||
@Nonnull | ||
EntityResult updateEntityPropertiesIfNotChanged( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nullable List<PolarisEntityCore> catalogPath, | ||
@Nonnull PolarisBaseEntity entity); | ||
|
||
@Nonnull | ||
DropEntityResult dropEntityIfExists( | ||
@Nonnull PolarisCallContext callCtx, | ||
@Nullable List<PolarisEntityCore> catalogPath, | ||
@Nonnull PolarisEntityCore entityToDrop, | ||
@Nullable Map<String, String> cleanupProperties, | ||
boolean cleanup); | ||
} |
93 changes: 93 additions & 0 deletions
93
polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.java
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As I put in the comment and dev mail list, the type-specific return entity refactor will come later.