From e6d553c05a17e71e68f6a6263484c6b80188c61c Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Wed, 5 Mar 2025 23:52:47 -0800 Subject: [PATCH 01/15] POC: Separate Polaris Entities --- .../LocalPolarisMetaStoreManagerFactory.java | 3 +- .../core/persistence/dao/CatalogDao.java | 46 ++++ .../core/persistence/dao/CatalogRoleDao.java | 23 ++ .../core/persistence/dao/NamespaceDao.java | 40 +++ .../dao/PolarisMetastoreManagerDao.java | 255 ++++++++++++++++++ .../core/persistence/dao/PrincipalRole.java | 23 ++ .../core/persistence/dao/TableLikeDao.java | 41 +++ .../polaris/core/persistence/dao/TaskDao.java | 23 ++ .../mongodb/MongoDbCatalogDaoImpl.java | 50 ++++ .../mongodb/MongoDbNamespaceDaoImpl.java | 43 +++ .../mongodb/MongoDbTableLikeDaoImpl.java | 44 +++ .../postgres/PostgresCatalogDaoImpl.java | 50 ++++ .../postgres/PostgresNamespaceDaoImpl.java | 23 ++ .../postgres/PostgresTableLikeDaoImpl.java | 44 +++ .../transactional/FdbCatalogDaoImpl.java | 59 ++++ .../transactional/FdbNamespaceDaoImpl.java | 49 ++++ .../transactional/FdbTableLikeDaoImpl.java | 50 ++++ 17 files changed, 865 insertions(+), 1 deletion(-) create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java index ff2eaaf131..5a4df5bd7b 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java @@ -36,6 +36,7 @@ import org.apache.polaris.core.entity.PolarisPrincipalSecrets; import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet; import org.apache.polaris.core.persistence.cache.EntityCache; +import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.core.persistence.dao.entity.BaseResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; @@ -94,7 +95,7 @@ private void initializeForRealm( realmContext.getRealmIdentifier(), () -> createMetaStoreSession(backingStore, realmContext, rootCredentialsSet, diagnostics)); - PolarisMetaStoreManager metaStoreManager = new PolarisMetaStoreManagerImpl(); + PolarisMetaStoreManager metaStoreManager = new PolarisMetastoreManagerDao(); metaStoreManagerMap.put(realmContext.getRealmIdentifier(), metaStoreManager); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java new file mode 100644 index 0000000000..eee4607c02 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -0,0 +1,46 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisBaseEntity; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.entity.PolarisEntityType; +import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public interface CatalogDao { + CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles); + + // TODO this should return a type-specific entity result, e.g., CatalogEntityResult + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name); + + // TODO this should return a type-specific entity result + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java new file mode 100644 index 0000000000..055b8e537f --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface CatalogRoleDao { +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java new file mode 100644 index 0000000000..b92596d1ad --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java @@ -0,0 +1,40 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public interface NamespaceDao { + // TODO this should return a type-specific entity result + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name); + + // TODO this should return a type-specific entity result + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java new file mode 100644 index 0000000000..998eca81a3 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java @@ -0,0 +1,255 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisBaseEntity; +import org.apache.polaris.core.entity.PolarisEntity; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntityId; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.entity.PolarisEntityType; +import org.apache.polaris.core.entity.PolarisPrivilege; +import org.apache.polaris.core.persistence.BaseMetaStoreManager; +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.CreateCatalogResult; +import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; +import org.apache.polaris.core.persistence.dao.entity.GenerateEntityIdResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; +import org.apache.polaris.core.persistence.transactional.FdbCatalogDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbNamespaceDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbTableLikeDaoImpl; +import org.apache.polaris.core.storage.PolarisStorageActions; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * This class servers as a bridge so that we defer the business logic refactor + */ +public class PolarisMetastoreManagerDao extends BaseMetaStoreManager { + private static final Logger LOGGER = LoggerFactory.getLogger(PolarisMetastoreManagerDao.class); + + // TODO, using factory or CDI to create following instances, so that the implementation can be injected. + FdbCatalogDaoImpl catalogDao = new FdbCatalogDaoImpl(); + FdbNamespaceDaoImpl namespaceDao = new FdbNamespaceDaoImpl(); + FdbTableLikeDaoImpl tableLikeDao = new FdbTableLikeDaoImpl(); + + @NotNull + @Override + public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { + return null; + } + + @NotNull + @Override + public BaseResult purge(@NotNull PolarisCallContext callCtx) { + return null; + } + + @NotNull + @Override + public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityType entityType, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { + switch (entityType) { + case CATALOG: + return catalogDao.readEntityByName(callCtx, catalogPath, name); + case NAMESPACE: + return namespaceDao.readEntityByName(callCtx, catalogPath, name); + case TABLE_LIKE: + return tableLikeDao.readEntityByName(callCtx, catalogPath, entitySubType, name); + } + throw new IllegalArgumentException("Unknown entity type: " + entityType); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityType entityType, @NotNull PolarisEntitySubType entitySubType) { + switch (entityType) { + case CATALOG: + return catalogDao.listEntities(callCtx); + case NAMESPACE: + return namespaceDao.listEntities(callCtx, catalogPath); + case TABLE_LIKE: + return tableLikeDao.listEntities(callCtx, catalogPath, entitySubType); + } + throw new IllegalArgumentException("Unknown entity type: " + entityType); + } + + @NotNull + @Override + public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { + return null; + } + + @NotNull + @Override + public CreatePrincipalResult createPrincipal(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { + return null; + } + + @NotNull + @Override + public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { + return catalogDao.createCatalog(callCtx, catalog, principalRoles); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisBaseEntity entity) { + return null; + } + + @NotNull + @Override + public EntitiesResult createEntitiesIfNotExist(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull List entities) { + return null; + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisBaseEntity entity) { + return null; + } + + @NotNull + @Override + public EntitiesResult updateEntitiesPropertiesIfNotChanged(@NotNull PolarisCallContext callCtx, @NotNull List entities) { + return null; + } + + @NotNull + @Override + public EntityResult renameEntity(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityCore entityToRename, @Nullable List newCatalogPath, @NotNull PolarisEntity renamedEntity) { + return null; + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { + return null; + } + + @NotNull + @Override + public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId, @NotNull PolarisEntityType entityType) { + return null; + } + + @NotNull + @Override + public EntitiesResult loadTasks(@NotNull PolarisCallContext callCtx, String executorId, int limit) { + return null; + } + + @NotNull + @Override + public ChangeTrackingResult loadEntitiesChangeTracking(@NotNull PolarisCallContext callCtx, @NotNull List entityIds) { + return null; + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId, PolarisEntityType entityType) { + return null; + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName(@NotNull PolarisCallContext callCtx, long entityCatalogId, long parentId, @NotNull PolarisEntityType entityType, @NotNull String entityName) { + return null; + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity(@NotNull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, @NotNull PolarisEntityType entityType, long entityCatalogId, long entityId) { + return null; + } + + @NotNull + @Override + public PrivilegeResult grantUsageOnRoleToGrantee(@NotNull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, @NotNull PolarisEntityCore role, @NotNull PolarisEntityCore grantee) { + return null; + } + + @NotNull + @Override + public PrivilegeResult revokeUsageOnRoleFromGrantee(@NotNull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, @NotNull PolarisEntityCore role, @NotNull PolarisEntityCore grantee) { + return null; + } + + @NotNull + @Override + public PrivilegeResult grantPrivilegeOnSecurableToRole(@NotNull PolarisCallContext callCtx, @NotNull PolarisEntityCore grantee, @Nullable List catalogPath, @NotNull PolarisEntityCore securable, @NotNull PolarisPrivilege privilege) { + return null; + } + + @NotNull + @Override + public PrivilegeResult revokePrivilegeOnSecurableFromRole(@NotNull PolarisCallContext callCtx, @NotNull PolarisEntityCore grantee, @Nullable List catalogPath, @NotNull PolarisEntityCore securable, @NotNull PolarisPrivilege privilege) { + return null; + } + + @NotNull + @Override + public LoadGrantsResult loadGrantsOnSecurable(@NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + return null; + } + + @NotNull + @Override + public LoadGrantsResult loadGrantsToGrantee(PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { + return null; + } + + @NotNull + @Override + public PrincipalSecretsResult loadPrincipalSecrets(@NotNull PolarisCallContext callCtx, @NotNull String clientId) { + return null; + } + + @NotNull + @Override + public PrincipalSecretsResult rotatePrincipalSecrets(@NotNull PolarisCallContext callCtx, @NotNull String clientId, long principalId, boolean reset, @NotNull String oldSecretHash) { + return null; + } + + @NotNull + @Override + public ScopedCredentialsResult getSubscopedCredsForEntity(@NotNull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, boolean allowListOperation, @NotNull Set allowedReadLocations, @NotNull Set allowedWriteLocations) { + return null; + } + + @NotNull + @Override + public ValidateAccessResult validateAccessToLocations(@NotNull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, @NotNull Set actions, @NotNull Set locations) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java new file mode 100644 index 0000000000..7920944574 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface PrincipalRole { +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java new file mode 100644 index 0000000000..c2427f1176 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java @@ -0,0 +1,41 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public interface TableLikeDao { + // TODO this should return a type-specific entity result + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name); + + // TODO this should return a type-specific entity result + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath, @NotNull PolarisEntitySubType entitySubType); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java new file mode 100644 index 0000000000..c36a5010d8 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -0,0 +1,23 @@ +/* + * 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; + +public interface TaskDao { +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java new file mode 100644 index 0000000000..f1fe127361 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java @@ -0,0 +1,50 @@ +/* + * 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.mongodb; + +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.CatalogDao; +import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MongoDbCatalogDaoImpl implements CatalogDao { + @Override + public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { + return null; + } + + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { + return null; + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java new file mode 100644 index 0000000000..28d1c12bb6 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java @@ -0,0 +1,43 @@ +/* + * 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.mongodb; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.persistence.dao.NamespaceDao; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MongoDbNamespaceDaoImpl implements NamespaceDao { + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { + return null; + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java new file mode 100644 index 0000000000..a5094f0a31 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java @@ -0,0 +1,44 @@ +/* + * 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.mongodb; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.persistence.dao.TableLikeDao; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class MongoDbTableLikeDaoImpl implements TableLikeDao { + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { + return null; + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java new file mode 100644 index 0000000000..0816244710 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java @@ -0,0 +1,50 @@ +/* + * 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.postgres; + +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.CatalogDao; +import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class PostgresCatalogDaoImpl implements CatalogDao { + @Override + public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { + return null; + } + + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { + return null; + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java new file mode 100644 index 0000000000..6713d25c61 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java @@ -0,0 +1,23 @@ +/* + * 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.postgres; + +public class PostgresNamespaceDaoImpl { +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java new file mode 100644 index 0000000000..7af3f706e6 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java @@ -0,0 +1,44 @@ +/* + * 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.postgres; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.persistence.dao.TableLikeDao; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +public class PostgresTableLikeDaoImpl implements TableLikeDao { + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { + return null; + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java new file mode 100644 index 0000000000..090947e9af --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java @@ -0,0 +1,59 @@ +/* + * 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.transactional; + +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.entity.PolarisEntitySubType; +import org.apache.polaris.core.entity.PolarisEntityType; +import org.apache.polaris.core.persistence.dao.CatalogDao; +import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; + +public class FdbCatalogDaoImpl implements CatalogDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { + return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); + } + + @NotNull + @Override + public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG, ANY_SUBTYPE, name); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java new file mode 100644 index 0000000000..fb3144bb2b --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java @@ -0,0 +1,49 @@ +/* + * 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.transactional; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.persistence.dao.NamespaceDao; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; + +public class FdbNamespaceDaoImpl implements NamespaceDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { + return null; + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java new file mode 100644 index 0000000000..7c53fd8107 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java @@ -0,0 +1,50 @@ +/* + * 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.transactional; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.entity.PolarisEntityType; +import org.apache.polaris.core.persistence.dao.TableLikeDao; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; + +public class FdbTableLikeDaoImpl implements TableLikeDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { + return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); + } +} From 1db510d9f0f0e6a359264617babe345a031c96f8 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sat, 8 Mar 2025 18:40:23 -0800 Subject: [PATCH 02/15] All tests passed --- .../LocalPolarisMetaStoreManagerFactory.java | 1 - .../core/persistence/dao/CatalogDao.java | 63 +- .../core/persistence/dao/CatalogRoleDao.java | 65 +- .../core/persistence/dao/CommonDao.java | 93 +++ .../persistence/dao/CredentialVendorDao.java | 94 +++ .../core/persistence/dao/GrantRecordDao.java | 167 +++++ .../core/persistence/dao/NamespaceDao.java | 65 +- .../dao/PolarisMetastoreManagerDao.java | 649 ++++++++++++------ .../core/persistence/dao/PrincipalDao.java | 79 +++ .../core/persistence/dao/PrincipalRole.java | 23 - .../persistence/dao/PrincipalRoleDao.java | 81 +++ .../persistence/dao/PrincipalSecretsDao.java | 57 ++ .../core/persistence/dao/TableLikeDao.java | 91 ++- .../polaris/core/persistence/dao/TaskDao.java | 30 +- .../mongodb/MongoDbCatalogDaoImpl.java | 31 +- .../mongodb/MongoDbNamespaceDaoImpl.java | 24 +- .../mongodb/MongoDbTableLikeDaoImpl.java | 25 +- .../postgres/PostgresCatalogDaoImpl.java | 31 +- .../postgres/PostgresNamespaceDaoImpl.java | 4 +- .../postgres/PostgresTableLikeDaoImpl.java | 25 +- .../transactional/FdbCatalogDaoImpl.java | 114 ++- .../transactional/FdbCatalogRoleDaoImpl.java | 122 ++++ .../transactional/FdbCommonDaoImpl.java | 92 +++ .../FdbCredentialVendorDaoImpl.java | 64 ++ .../transactional/FdbGrantRecordDaoImpl.java | 90 +++ .../transactional/FdbNamespaceDaoImpl.java | 109 ++- .../transactional/FdbPrincipalDaoImpl.java | 115 ++++ .../FdbPrincipalRoleDaoImpl.java | 123 ++++ .../FdbPrincipalSecretsDaoImpl.java | 46 ++ .../transactional/FdbTableLikeDaoImpl.java | 133 +++- .../transactional/FdbTaskDaoImpl.java | 71 ++ .../core/persistence/EntityCacheTest.java | 4 +- .../core/persistence/ResolverTest.java | 4 +- 33 files changed, 2336 insertions(+), 449 deletions(-) create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CredentialVendorDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/GrantRecordDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalSecretsDao.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java create mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java index 5a4df5bd7b..08140c86e4 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java @@ -39,7 +39,6 @@ import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.core.persistence.dao.entity.BaseResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; import org.apache.polaris.core.storage.cache.StorageCredentialCache; import org.slf4j.Logger; diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java index eee4607c02..ae675d7285 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -16,31 +16,70 @@ * 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 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.entity.PolarisEntitySubType; -import org.apache.polaris.core.entity.PolarisEntityType; 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; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public interface CatalogDao { - CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles); + CreateCatalogResult createCatalog( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisBaseEntity catalog, + @NotNull List principalRoles); + + // TODO this should return a type-specific entity result, e.g., CatalogEntityResult + @NotNull + EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + + @Nonnull + EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup); + + @Nonnull + ResolvedEntityResult loadResolvedEntityById( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); - // TODO this should return a type-specific entity result, e.g., CatalogEntityResult - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name); + @Nonnull + ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName); - // TODO this should return a type-specific entity result - @Nonnull - ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + @Nonnull + ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java index 055b8e537f..9f354ed52b 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java @@ -16,8 +16,71 @@ * 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 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; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + public interface CatalogRoleDao { + @NotNull + EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, @Nullable List 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, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @jakarta.annotation.Nullable Map cleanupProperties, + boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.java new file mode 100644 index 0000000000..0a524c87a1 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CommonDao.java @@ -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. + * + *

*************************** WARNING ************************ + * + *

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 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); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CredentialVendorDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CredentialVendorDao.java new file mode 100644 index 0000000000..920fdc05df --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CredentialVendorDao.java @@ -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 allowedReadLocations, + @Nonnull Set 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 }, a validate result value looks like this + *

+   * {
+   *   "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."
+   * }
+   * 
+ */ + @Nonnull + PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( + @Nonnull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + @Nonnull Set actions, + @Nonnull Set locations); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/GrantRecordDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/GrantRecordDao.java new file mode 100644 index 0000000000..a7b409e34e --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/GrantRecordDao.java @@ -0,0 +1,167 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisGrantManager; +import org.apache.polaris.core.entity.PolarisBaseEntity; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisPrivilege; + +/** This will replace the class PolarisGrantManager. */ +public interface GrantRecordDao { + /** + * Grant usage on a role to a grantee, for example granting usage on a catalog role to a principal + * role or granting a principal role to a principal. + * + * @param callCtx call context + * @param catalog if the role is a catalog role, the caller needs to pass-in the catalog entity + * which was used to resolve that granted. Else null. + * @param role resolved catalog or principal role + * @param grantee principal role or principal as resolved by the caller + * @return the grant record we created for this grant. Will return ENTITY_NOT_FOUND if the + * specified role couldn't be found. Should be retried in that case + */ + @Nonnull + PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( + @Nonnull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee); + + /** + * Revoke usage on a role (a catalog or a principal role) from a grantee (e.g. a principal role or + * a principal). + * + * @param callCtx call context + * @param catalog if the granted is a catalog role, the caller needs to pass-in the catalog entity + * which was used to resolve that role. Else null should be passed-in. + * @param role a catalog/principal role as resolved by the caller + * @param grantee resolved principal role or principal + * @return the result. Will return ENTITY_NOT_FOUND if the * specified role couldn't be found. + * Should be retried in that case. Will return GRANT_NOT_FOUND if the grant to revoke cannot + * be found + */ + @Nonnull + PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( + @Nonnull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee); + + /** + * Grant a privilege on a catalog securable to a grantee. + * + * @param callCtx call context + * @param grantee resolved role, the grantee + * @param catalogPath path to that entity, cannot be null or empty unless securable is top-level + * @param securable securable entity, must have been resolved by the client. Can be the catalog + * itself + * @param privilege privilege to grant + * @return the grant record we created for this grant. Will return ENTITY_NOT_FOUND if the + * specified role couldn't be found. Should be retried in that case + */ + @Nonnull + PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege); + + /** + * Revoke a privilege on a catalog securable from a grantee. + * + * @param callCtx call context + * @param grantee resolved role, the grantee + * @param catalogPath path to that entity, cannot be null or empty unless securable is top-level + * @param securable securable entity, must have been resolved by the client. Can be the catalog + * itself. + * @param privilege privilege to revoke + * @return the result. Will return ENTITY_NOT_FOUND if the * specified role couldn't be found. + * Should be retried in that case. Will return GRANT_NOT_FOUND if the grant to revoke cannot + * be found + */ + @Nonnull + PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege); + + /** + * This method should be used by the Polaris app to cache all grant records on a securable. + * + * @param callCtx call context + * @param securable the securable entity + * @return the list of grants and the version of the grant records. We will return + * ENTITY_NOT_FOUND if the securable cannot be found + */ + @Nonnull + default PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( + @Nonnull PolarisCallContext callCtx, PolarisBaseEntity securable) { + return loadGrantsOnSecurable(callCtx, securable.getCatalogId(), securable.getId()); + } + + /** + * This method should be used by the Polaris app to cache all grant records on a securable. + * + * @param callCtx call context + * @param securableCatalogId id of the catalog this securable belongs to + * @param securableId id of the securable + * @return the list of grants and the version of the grant records. We will return + * ENTITY_NOT_FOUND if the securable cannot be found + */ + @Nonnull + PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( + @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId); + + /** + * This method should be used by the Polaris app to load all grants made to a grantee, either a + * role or a principal. + * + * @param callCtx call context + * @param grantee the grantee entity + * @return the list of grants and the version of the grant records. We will return NULL if the + * grantee does not exist + */ + @Nonnull + default PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( + @Nonnull PolarisCallContext callCtx, PolarisBaseEntity grantee) { + return loadGrantsToGrantee(callCtx, grantee.getCatalogId(), grantee.getId()); + } + + /** + * This method should be used by the Polaris app to load all grants made to a grantee, either a + * role or a principal. + * + * @param callCtx call context + * @param granteeCatalogId id of the catalog this grantee belongs to + * @param granteeId id of the grantee + * @return the list of grants and the version of the grant records. We will return NULL if the + * grantee does not exist + */ + @Nonnull + PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( + PolarisCallContext callCtx, long granteeCatalogId, long granteeId); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java index b92596d1ad..e3a8f66742 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java @@ -16,25 +16,72 @@ * 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 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; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public interface NamespaceDao { - // TODO this should return a type-specific entity result - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name); + // TODO this should return a type-specific entity result + @NotNull + EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, @Nonnull List 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, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); - // TODO this should return a type-specific entity result - @Nonnull - ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath); + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @jakarta.annotation.Nullable Map cleanupProperties, + boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java index 998eca81a3..a4f2b915f5 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.dao; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisBaseEntity; import org.apache.polaris.core.entity.PolarisEntity; @@ -40,216 +42,477 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; import org.apache.polaris.core.persistence.transactional.FdbCatalogDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbCatalogRoleDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbCommonDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbCredentialVendorDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbGrantRecordDaoImpl; import org.apache.polaris.core.persistence.transactional.FdbNamespaceDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbPrincipalDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbPrincipalRoleDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbPrincipalSecretsDaoImpl; import org.apache.polaris.core.persistence.transactional.FdbTableLikeDaoImpl; +import org.apache.polaris.core.persistence.transactional.FdbTaskDaoImpl; import org.apache.polaris.core.storage.PolarisStorageActions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * This class servers as a bridge so that we defer the business logic refactor - */ +/** This class servers as a bridge so that we defer the business logic refactor */ public class PolarisMetastoreManagerDao extends BaseMetaStoreManager { - private static final Logger LOGGER = LoggerFactory.getLogger(PolarisMetastoreManagerDao.class); - - // TODO, using factory or CDI to create following instances, so that the implementation can be injected. - FdbCatalogDaoImpl catalogDao = new FdbCatalogDaoImpl(); - FdbNamespaceDaoImpl namespaceDao = new FdbNamespaceDaoImpl(); - FdbTableLikeDaoImpl tableLikeDao = new FdbTableLikeDaoImpl(); - - @NotNull - @Override - public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { - return null; - } - - @NotNull - @Override - public BaseResult purge(@NotNull PolarisCallContext callCtx) { - return null; - } - - @NotNull - @Override - public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityType entityType, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { - switch (entityType) { - case CATALOG: - return catalogDao.readEntityByName(callCtx, catalogPath, name); - case NAMESPACE: - return namespaceDao.readEntityByName(callCtx, catalogPath, name); - case TABLE_LIKE: - return tableLikeDao.readEntityByName(callCtx, catalogPath, entitySubType, name); - } + private static final Logger LOGGER = LoggerFactory.getLogger(PolarisMetastoreManagerDao.class); + + // TODO, using factory or CDI to create following instances, so that the implementation can be + // injected. + FdbCatalogDaoImpl catalogDao = new FdbCatalogDaoImpl(); + FdbNamespaceDaoImpl namespaceDao = new FdbNamespaceDaoImpl(); + FdbTableLikeDaoImpl tableLikeDao = new FdbTableLikeDaoImpl(); + FdbCatalogRoleDaoImpl catalogRoleDao = new FdbCatalogRoleDaoImpl(); + FdbPrincipalRoleDaoImpl principalRoleDao = new FdbPrincipalRoleDaoImpl(); + FdbPrincipalDaoImpl principalDao = new FdbPrincipalDaoImpl(); + FdbTaskDaoImpl taskDao = new FdbTaskDaoImpl(); + FdbPrincipalSecretsDaoImpl principalSecretsDao = new FdbPrincipalSecretsDaoImpl(); + FdbGrantRecordDaoImpl grantRecordDao = new FdbGrantRecordDaoImpl(); + FdbCommonDaoImpl commonDao = new FdbCommonDaoImpl(); + FdbCredentialVendorDaoImpl credentialVendorDao = new FdbCredentialVendorDaoImpl(); + + @NotNull + @Override + public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { + return commonDao.bootstrapPolarisService(callCtx); + } + + @NotNull + @Override + public BaseResult purge(@NotNull PolarisCallContext callCtx) { + return commonDao.purge(callCtx); + } + + @NotNull + @Override + public EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityType entityType, + @NotNull PolarisEntitySubType entitySubType, + @NotNull String name) { + switch (entityType) { + case CATALOG: + return catalogDao.readEntityByName(callCtx, catalogPath, name); + case NAMESPACE: + return namespaceDao.readEntityByName(callCtx, catalogPath, name); + case TABLE_LIKE: + return tableLikeDao.readEntityByName(callCtx, catalogPath, entitySubType, name); + case CATALOG_ROLE: + return catalogRoleDao.readEntityByName(callCtx, catalogPath, name); + case PRINCIPAL: + return principalDao.readEntityByName(callCtx, name); + case PRINCIPAL_ROLE: + return principalRoleDao.readEntityByName(callCtx, name); + default: throw new IllegalArgumentException("Unknown entity type: " + entityType); } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityType entityType, @NotNull PolarisEntitySubType entitySubType) { - switch (entityType) { - case CATALOG: - return catalogDao.listEntities(callCtx); - case NAMESPACE: - return namespaceDao.listEntities(callCtx, catalogPath); - case TABLE_LIKE: - return tableLikeDao.listEntities(callCtx, catalogPath, entitySubType); - } + } + + @NotNull + @Override + public ListEntitiesResult listEntities( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityType entityType, + @NotNull PolarisEntitySubType entitySubType) { + switch (entityType) { + case CATALOG: + return catalogDao.listEntities(callCtx); + case NAMESPACE: + return namespaceDao.listEntities(callCtx, catalogPath); + case TABLE_LIKE: + return tableLikeDao.listEntities(callCtx, catalogPath, entitySubType); + case CATALOG_ROLE: + return catalogRoleDao.listEntities(callCtx, catalogPath); + case PRINCIPAL: + return principalDao.listEntities(callCtx); + case PRINCIPAL_ROLE: + return principalRoleDao.listEntities(callCtx); + default: throw new IllegalArgumentException("Unknown entity type: " + entityType); } - - @NotNull - @Override - public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { - return null; - } - - @NotNull - @Override - public CreatePrincipalResult createPrincipal(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { - return null; - } - - @NotNull - @Override - public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { - return catalogDao.createCatalog(callCtx, catalog, principalRoles); - } - - @NotNull - @Override - public EntityResult createEntityIfNotExists(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisBaseEntity entity) { - return null; - } - - @NotNull - @Override - public EntitiesResult createEntitiesIfNotExist(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull List entities) { - return null; - } - - @NotNull - @Override - public EntityResult updateEntityPropertiesIfNotChanged(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisBaseEntity entity) { - return null; - } - - @NotNull - @Override - public EntitiesResult updateEntitiesPropertiesIfNotChanged(@NotNull PolarisCallContext callCtx, @NotNull List entities) { - return null; + } + + @NotNull + @Override + public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { + return commonDao.generateNewEntityId(callCtx); + } + + @NotNull + @Override + public CreatePrincipalResult createPrincipal( + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { + return principalDao.createPrincipal(callCtx, principal); + } + + @NotNull + @Override + public CreateCatalogResult createCatalog( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisBaseEntity catalog, + @NotNull List principalRoles) { + return catalogDao.createCatalog(callCtx, catalog, principalRoles); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + switch (entity.getType()) { + case NAMESPACE: + return namespaceDao.createEntityIfNotExists(callCtx, catalogPath, entity); + case TABLE_LIKE: + return tableLikeDao.createEntityIfNotExists(callCtx, catalogPath, entity); + case CATALOG_ROLE: + return catalogRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); + case PRINCIPAL_ROLE: + return principalRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); + default: + throw new IllegalArgumentException("Unknown entity type: " + entity.getType()); } - - @NotNull - @Override - public EntityResult renameEntity(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityCore entityToRename, @Nullable List newCatalogPath, @NotNull PolarisEntity renamedEntity) { - return null; + } + + @NotNull + @Override + public EntitiesResult createEntitiesIfNotExist( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull List entities) { + // only for tasks + return taskDao.createEntitiesIfNotExist(callCtx, catalogPath, entities); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + switch (entity.getType()) { + case CATALOG: + return catalogDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + case NAMESPACE: + return namespaceDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + case TABLE_LIKE: + return tableLikeDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + case CATALOG_ROLE: + return catalogRoleDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + case PRINCIPAL: + return principalDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + case PRINCIPAL_ROLE: + return principalRoleDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + default: + throw new IllegalArgumentException("Unknown entity type: " + entity.getType()); } - - @NotNull - @Override - public DropEntityResult dropEntityIfExists(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return null; + } + + @NotNull + @Override + public EntitiesResult updateEntitiesPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, @NotNull List entities) { + // only for multi-table transactions + return tableLikeDao.updateEntitiesPropertiesIfNotChanged(callCtx, entities); + } + + @NotNull + @Override + public EntityResult renameEntity( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToRename, + @Nullable List newCatalogPath, + @NotNull PolarisEntity renamedEntity) { + // only tableLike is supported + return tableLikeDao.renameEntity( + callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + switch (entityToDrop.getType()) { + case CATALOG: + return catalogDao.dropEntityIfExists(callCtx, entityToDrop, cleanupProperties, cleanup); + case NAMESPACE: + return namespaceDao.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + case TABLE_LIKE: + return tableLikeDao.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + case CATALOG_ROLE: + return catalogRoleDao.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + case PRINCIPAL: + return principalDao.dropEntityIfExists(callCtx, entityToDrop, cleanupProperties, cleanup); + case PRINCIPAL_ROLE: + return principalRoleDao.dropEntityIfExists( + callCtx, entityToDrop, cleanupProperties, cleanup); + case TASK: + return taskDao.dropEntityIfExists(callCtx, entityToDrop, cleanupProperties, cleanup); + default: + throw new IllegalArgumentException("Unknown entity type: " + entityToDrop.getType()); } - - @NotNull - @Override - public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId, @NotNull PolarisEntityType entityType) { - return null; - } - - @NotNull - @Override - public EntitiesResult loadTasks(@NotNull PolarisCallContext callCtx, String executorId, int limit) { - return null; - } - - @NotNull - @Override - public ChangeTrackingResult loadEntitiesChangeTracking(@NotNull PolarisCallContext callCtx, @NotNull List entityIds) { - return null; - } - - @NotNull - @Override - public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId, PolarisEntityType entityType) { - return null; - } - - @NotNull - @Override - public ResolvedEntityResult loadResolvedEntityByName(@NotNull PolarisCallContext callCtx, long entityCatalogId, long parentId, @NotNull PolarisEntityType entityType, @NotNull String entityName) { - return null; - } - - @NotNull - @Override - public ResolvedEntityResult refreshResolvedEntity(@NotNull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, @NotNull PolarisEntityType entityType, long entityCatalogId, long entityId) { - return null; - } - - @NotNull - @Override - public PrivilegeResult grantUsageOnRoleToGrantee(@NotNull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, @NotNull PolarisEntityCore role, @NotNull PolarisEntityCore grantee) { - return null; - } - - @NotNull - @Override - public PrivilegeResult revokeUsageOnRoleFromGrantee(@NotNull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, @NotNull PolarisEntityCore role, @NotNull PolarisEntityCore grantee) { - return null; - } - - @NotNull - @Override - public PrivilegeResult grantPrivilegeOnSecurableToRole(@NotNull PolarisCallContext callCtx, @NotNull PolarisEntityCore grantee, @Nullable List catalogPath, @NotNull PolarisEntityCore securable, @NotNull PolarisPrivilege privilege) { - return null; - } - - @NotNull - @Override - public PrivilegeResult revokePrivilegeOnSecurableFromRole(@NotNull PolarisCallContext callCtx, @NotNull PolarisEntityCore grantee, @Nullable List catalogPath, @NotNull PolarisEntityCore securable, @NotNull PolarisPrivilege privilege) { - return null; - } - - @NotNull - @Override - public LoadGrantsResult loadGrantsOnSecurable(@NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { - return null; - } - - @NotNull - @Override - public LoadGrantsResult loadGrantsToGrantee(PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { - return null; - } - - @NotNull - @Override - public PrincipalSecretsResult loadPrincipalSecrets(@NotNull PolarisCallContext callCtx, @NotNull String clientId) { - return null; + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long entityId, + @NotNull PolarisEntityType entityType) { + switch (entityType) { + case CATALOG: + return catalogDao.loadEntity(callCtx, entityCatalogId, entityId); + case NAMESPACE: + return namespaceDao.loadEntity(callCtx, entityCatalogId, entityId); + case TABLE_LIKE: + return tableLikeDao.loadEntity(callCtx, entityCatalogId, entityId); + case CATALOG_ROLE: + return catalogRoleDao.loadEntity(callCtx, entityCatalogId, entityId); + case PRINCIPAL: + return principalDao.loadEntity(callCtx, entityCatalogId, entityId); + case PRINCIPAL_ROLE: + return principalRoleDao.loadEntity(callCtx, entityCatalogId, entityId); + case TASK: + return taskDao.loadEntity(callCtx, entityCatalogId, entityId); + case NULL_TYPE: + return commonDao.loadEntity(callCtx, entityCatalogId, entityId); + default: + throw new IllegalArgumentException("Unknown entity type: " + entityType); } - - @NotNull - @Override - public PrincipalSecretsResult rotatePrincipalSecrets(@NotNull PolarisCallContext callCtx, @NotNull String clientId, long principalId, boolean reset, @NotNull String oldSecretHash) { - return null; + } + + @NotNull + @Override + public EntitiesResult loadTasks( + @NotNull PolarisCallContext callCtx, String executorId, int limit) { + return taskDao.loadTasks(callCtx, executorId, limit); + } + + @NotNull + @Override + public ChangeTrackingResult loadEntitiesChangeTracking( + @NotNull PolarisCallContext callCtx, @NotNull List entityIds) { + // todo we need to figure out how to handle type-specific one later + return commonDao.loadEntitiesChangeTracking(callCtx, entityIds); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long entityId, + PolarisEntityType entityType) { + switch (entityType) { + case CATALOG: + return catalogDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + case NAMESPACE: + return namespaceDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + case TABLE_LIKE: + return tableLikeDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + case PRINCIPAL: + return principalDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + case PRINCIPAL_ROLE: + return principalRoleDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + case CATALOG_ROLE: + return catalogRoleDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + default: + throw new IllegalArgumentException("Unknown entity type: " + entityType); } - - @NotNull - @Override - public ScopedCredentialsResult getSubscopedCredsForEntity(@NotNull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, boolean allowListOperation, @NotNull Set allowedReadLocations, @NotNull Set allowedWriteLocations) { - return null; + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull PolarisEntityType entityType, + @NotNull String entityName) { + switch (entityType) { + case NAMESPACE: + return namespaceDao.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, entityName); + case TABLE_LIKE: + return tableLikeDao.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, entityName); + case PRINCIPAL: + return principalDao.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, entityName); + case PRINCIPAL_ROLE: + return principalRoleDao.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, entityName); + case ROOT: + return commonDao.loadResolvedEntityByName(callCtx, entityCatalogId, parentId, entityName); + case CATALOG: + return catalogDao.loadResolvedEntityByName(callCtx, entityCatalogId, parentId, entityName); + case CATALOG_ROLE: + return catalogRoleDao.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, entityName); + default: + throw new IllegalArgumentException("Unknown entity type: " + entityType); } - - @NotNull - @Override - public ValidateAccessResult validateAccessToLocations(@NotNull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, @NotNull Set actions, @NotNull Set locations) { - return null; + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + @NotNull PolarisEntityType entityType, + long entityCatalogId, + long entityId) { + switch (entityType) { + case CATALOG: + return catalogDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case NAMESPACE: + return namespaceDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case TABLE_LIKE: + return tableLikeDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case PRINCIPAL: + return principalDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case PRINCIPAL_ROLE: + return principalRoleDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case CATALOG_ROLE: + return catalogRoleDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + case ROOT: + return commonDao.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + default: + throw new IllegalArgumentException("Unknown entity type: " + entityType); } + } + + @NotNull + @Override + public PrivilegeResult grantUsageOnRoleToGrantee( + @NotNull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @NotNull PolarisEntityCore role, + @NotNull PolarisEntityCore grantee) { + return grantRecordDao.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); + } + + @NotNull + @Override + public PrivilegeResult revokeUsageOnRoleFromGrantee( + @NotNull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @NotNull PolarisEntityCore role, + @NotNull PolarisEntityCore grantee) { + return grantRecordDao.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); + } + + @NotNull + @Override + public PrivilegeResult grantPrivilegeOnSecurableToRole( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore grantee, + @Nullable List catalogPath, + @NotNull PolarisEntityCore securable, + @NotNull PolarisPrivilege privilege) { + return grantRecordDao.grantPrivilegeOnSecurableToRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @NotNull + @Override + public PrivilegeResult revokePrivilegeOnSecurableFromRole( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore grantee, + @Nullable List catalogPath, + @NotNull PolarisEntityCore securable, + @NotNull PolarisPrivilege privilege) { + return grantRecordDao.revokePrivilegeOnSecurableFromRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @NotNull + @Override + public LoadGrantsResult loadGrantsOnSecurable( + @NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + return grantRecordDao.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); + } + + @NotNull + @Override + public LoadGrantsResult loadGrantsToGrantee( + PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { + return grantRecordDao.loadGrantsToGrantee(callCtx, granteeCatalogId, granteeId); + } + + @NotNull + @Override + public PrincipalSecretsResult loadPrincipalSecrets( + @NotNull PolarisCallContext callCtx, @NotNull String clientId) { + return principalSecretsDao.loadPrincipalSecrets(callCtx, clientId); + } + + @NotNull + @Override + public PrincipalSecretsResult rotatePrincipalSecrets( + @NotNull PolarisCallContext callCtx, + @NotNull String clientId, + long principalId, + boolean reset, + @NotNull String oldSecretHash) { + return principalSecretsDao.rotatePrincipalSecrets( + callCtx, clientId, principalId, reset, oldSecretHash); + } + + @NotNull + @Override + public ScopedCredentialsResult getSubscopedCredsForEntity( + @NotNull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + boolean allowListOperation, + @NotNull Set allowedReadLocations, + @NotNull Set allowedWriteLocations) { + return credentialVendorDao.getSubscopedCredsForEntity( + callCtx, + catalogId, + entityId, + entityType, + allowListOperation, + allowedReadLocations, + allowedWriteLocations); + } + + @NotNull + @Override + public ValidateAccessResult validateAccessToLocations( + @NotNull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + @NotNull Set actions, + @NotNull Set locations) { + return credentialVendorDao.validateAccessToLocations( + callCtx, catalogId, entityId, entityType, actions, locations); + } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java new file mode 100644 index 0000000000..f48cb03175 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java @@ -0,0 +1,79 @@ +/* + * 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.CreatePrincipalResult; +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; +import org.jetbrains.annotations.NotNull; + +public interface PrincipalDao { + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + + CreatePrincipalResult createPrincipal( + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal); + + @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 updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @jakarta.annotation.Nullable Map cleanupProperties, + boolean cleanup); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java deleted file mode 100644 index 7920944574..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRole.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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; - -public interface PrincipalRole { -} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java new file mode 100644 index 0000000000..81aaa6df9d --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java @@ -0,0 +1,81 @@ +/* + * 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; +import org.jetbrains.annotations.NotNull; + +public interface PrincipalRoleDao { + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @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 catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @jakarta.annotation.Nullable Map cleanupProperties, + boolean cleanup); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalSecretsDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalSecretsDao.java new file mode 100644 index 0000000000..bd9890389a --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalSecretsDao.java @@ -0,0 +1,57 @@ +/* + * 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 org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisSecretsManager; + +/** This can be used to replace the class PolarisSecretsManager */ +public interface PrincipalSecretsDao { + /** + * Load the principal secrets given the client_id. + * + * @param callCtx call context + * @param clientId principal client id + * @return the secrets associated to that principal, including the entity id of the principal + */ + @Nonnull + PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( + @Nonnull PolarisCallContext callCtx, @Nonnull String clientId); + + /** + * Rotate secrets + * + * @param callCtx call context + * @param clientId principal client id + * @param principalId id of the principal + * @param reset true if the principal's secrets should be disabled and replaced with a one-time + * password. if the principal's secret is already a one-time password, this flag is + * automatically true + * @param oldSecretHash main secret hash for the principal + * @return the secrets associated to that principal amd the id of the principal + */ + @Nonnull + PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( + @Nonnull PolarisCallContext callCtx, + @Nonnull String clientId, + long principalId, + boolean reset, + @Nonnull String oldSecretHash); +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java index c2427f1176..35acac20ba 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java @@ -16,26 +16,99 @@ * 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 java.util.Map; import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisBaseEntity; +import org.apache.polaris.core.entity.PolarisEntity; import org.apache.polaris.core.entity.PolarisEntityCore; import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public interface TableLikeDao { - // TODO this should return a type-specific entity result - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name); + @NotNull + EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntitySubType entitySubType, + @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, + @Nonnull List catalogPath, + @NotNull PolarisEntitySubType entitySubType); + + @Nonnull + EntityResult renameEntity( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToRename, + @Nullable List newCatalogPath, + @Nonnull PolarisEntity renamedEntity); + + @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, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @jakarta.annotation.Nullable Map cleanupProperties, + boolean cleanup); - // TODO this should return a type-specific entity result - @Nonnull - ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath, @NotNull PolarisEntitySubType entitySubType); + /** + * This allows to operate on multiple tables at once. Just loop through the list, calling each + * entity update and return null if any of those fail. + * + * @param callCtx call context + * @param entities the set of entities to update + * @return list of all entities we updated or null if the client should retry because one update + * failed + */ + @Nonnull + EntitiesResult updateEntitiesPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull List entities); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java index c36a5010d8..3895a09692 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -16,8 +16,36 @@ * 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.EntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; + public interface TaskDao { + @Nonnull + EntitiesResult loadTasks(@Nonnull PolarisCallContext callCtx, String executorId, int limit); + + @Nonnull + EntitiesResult createEntitiesIfNotExist( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull List entities); + + @Nonnull + DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java index f1fe127361..917828cbd1 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java @@ -16,35 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.mongodb; -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.CatalogDao; -import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class MongoDbCatalogDaoImpl implements CatalogDao { - @Override - public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { - return null; - } - - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { - return null; - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { - return null; - } -} +public class MongoDbCatalogDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java index 28d1c12bb6..91b2abe876 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java @@ -16,28 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.mongodb; -import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.entity.PolarisEntityCore; -import org.apache.polaris.core.persistence.dao.NamespaceDao; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class MongoDbNamespaceDaoImpl implements NamespaceDao { - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { - return null; - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { - return null; - } -} +public class MongoDbNamespaceDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java index a5094f0a31..13abcba85e 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java @@ -16,29 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.mongodb; -import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.entity.PolarisEntityCore; -import org.apache.polaris.core.entity.PolarisEntitySubType; -import org.apache.polaris.core.persistence.dao.TableLikeDao; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class MongoDbTableLikeDaoImpl implements TableLikeDao { - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { - return null; - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { - return null; - } -} +public class MongoDbTableLikeDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java index 0816244710..fccf8b86e1 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java @@ -16,35 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.postgres; -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.CatalogDao; -import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class PostgresCatalogDaoImpl implements CatalogDao { - @Override - public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { - return null; - } - - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { - return null; - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { - return null; - } -} +public class PostgresCatalogDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java index 6713d25c61..85469b5e6e 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java @@ -16,8 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.postgres; -public class PostgresNamespaceDaoImpl { -} +public class PostgresNamespaceDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java index 7af3f706e6..a2e5bae813 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java @@ -16,29 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.postgres; -import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.entity.PolarisEntityCore; -import org.apache.polaris.core.entity.PolarisEntitySubType; -import org.apache.polaris.core.persistence.dao.TableLikeDao; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.List; - -public class PostgresTableLikeDaoImpl implements TableLikeDao { - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { - return null; - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { - return null; - } -} +public class PostgresTableLikeDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java index 090947e9af..24d05e9e87 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java @@ -16,44 +16,106 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.transactional; +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; + +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.entity.PolarisEntitySubType; -import org.apache.polaris.core.entity.PolarisEntityType; import org.apache.polaris.core.persistence.dao.CatalogDao; 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; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +public class FdbCatalogDaoImpl implements CatalogDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; + @Override + public CreateCatalogResult createCatalog( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisBaseEntity catalog, + @NotNull List principalRoles) { + return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); + } -public class FdbCatalogDaoImpl implements CatalogDao { - // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - - @Override - public CreateCatalogResult createCatalog(@NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles) { - return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); - } - - @NotNull - @Override - public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG, ANY_SUBTYPE, name); - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { - return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); - } + @NotNull + @Override + public EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG, ANY_SUBTYPE, name); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, CATALOG); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, CATALOG, entityName); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, entityCatalogId, entityId); + } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java new file mode 100644 index 0000000000..7b6c77d11f --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java @@ -0,0 +1,122 @@ +/* + * 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.transactional; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG_ROLE; + +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.CatalogRoleDao; +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; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class FdbCatalogRoleDaoImpl implements CatalogRoleDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE, name); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG_ROLE); + } + + @NotNull + @Override + public ListEntitiesResult listEntities( + @NotNull PolarisCallContext callCtx, @Nullable List catalogPath) { + return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById( + callCtx, entityCatalogId, entityId, CATALOG_ROLE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, CATALOG_ROLE, entityName); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG_ROLE, entityCatalogId, entityId); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java new file mode 100644 index 0000000000..bd65f303cb --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java @@ -0,0 +1,92 @@ +/* + * 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.transactional; + +import static org.apache.polaris.core.entity.PolarisEntityType.NULL_TYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.ROOT; + +import java.util.List; +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityId; +import org.apache.polaris.core.persistence.dao.CommonDao; +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; +import org.jetbrains.annotations.NotNull; + +public class FdbCommonDaoImpl implements CommonDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.generateNewEntityId(callCtx); + } + + @NotNull + @Override + public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.bootstrapPolarisService(callCtx); + } + + @NotNull + @Override + public BaseResult purge(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.purge(callCtx); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, ROOT, entityName); + } + + @NotNull + @Override + public ChangeTrackingResult loadEntitiesChangeTracking( + @NotNull PolarisCallContext callCtx, @NotNull List entityIds) { + return metaStoreManager.loadEntitiesChangeTracking(callCtx, entityIds); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, ROOT, entityCatalogId, entityId); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NULL_TYPE); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java new file mode 100644 index 0000000000..39f10ab056 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java @@ -0,0 +1,64 @@ +/* + * 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.transactional; + +import java.util.Set; +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.entity.PolarisEntityType; +import org.apache.polaris.core.persistence.dao.CredentialVendorDao; +import org.apache.polaris.core.storage.PolarisCredentialVendor; +import org.apache.polaris.core.storage.PolarisStorageActions; +import org.jetbrains.annotations.NotNull; + +public class FdbCredentialVendorDaoImpl implements CredentialVendorDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntity( + @NotNull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + boolean allowListOperation, + @NotNull Set allowedReadLocations, + @NotNull Set allowedWriteLocations) { + return metaStoreManager.getSubscopedCredsForEntity( + callCtx, + catalogId, + entityId, + entityType, + allowListOperation, + allowedReadLocations, + allowedWriteLocations); + } + + @NotNull + @Override + public PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( + @NotNull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + @NotNull Set actions, + @NotNull Set locations) { + return metaStoreManager.validateAccessToLocations( + callCtx, catalogId, entityId, entityType, actions, locations); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java new file mode 100644 index 0000000000..a4efeb3052 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java @@ -0,0 +1,90 @@ +/* + * 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.transactional; + +import java.util.List; +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisGrantManager; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisPrivilege; +import org.apache.polaris.core.persistence.dao.GrantRecordDao; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class FdbGrantRecordDaoImpl implements GrantRecordDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( + @NotNull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @NotNull PolarisEntityCore role, + @NotNull PolarisEntityCore grantee) { + return metaStoreManager.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); + } + + @NotNull + @Override + public PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( + @NotNull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @NotNull PolarisEntityCore role, + @NotNull PolarisEntityCore grantee) { + return metaStoreManager.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); + } + + @NotNull + @Override + public PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore grantee, + @Nullable List catalogPath, + @NotNull PolarisEntityCore securable, + @NotNull PolarisPrivilege privilege) { + return metaStoreManager.grantPrivilegeOnSecurableToRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @NotNull + @Override + public PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore grantee, + @Nullable List catalogPath, + @NotNull PolarisEntityCore securable, + @NotNull PolarisPrivilege privilege) { + return metaStoreManager.revokePrivilegeOnSecurableFromRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @NotNull + @Override + public PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( + @NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + return metaStoreManager.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); + } + + @NotNull + @Override + public PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( + PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { + return metaStoreManager.loadGrantsToGrantee(callCtx, granteeCatalogId, granteeId); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java index fb3144bb2b..069605344a 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java @@ -16,34 +16,107 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.transactional; +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; + +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.NamespaceDao; +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; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +public class FdbNamespaceDaoImpl implements NamespaceDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); + } -public class FdbNamespaceDaoImpl implements NamespaceDao { - // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { - return null; - } + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NAMESPACE); + } + + @NotNull + @Override + public ListEntitiesResult listEntities( + @NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { + return metaStoreManager.listEntities(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, NAMESPACE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, NAMESPACE, entityName); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, NAMESPACE, entityCatalogId, entityId); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java new file mode 100644 index 0000000000..c197f353d6 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java @@ -0,0 +1,115 @@ +/* + * 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.transactional; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL; + +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.PrincipalDao; +import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult; +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; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class FdbPrincipalDaoImpl implements PrincipalDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL, NULL_SUBTYPE, name); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, PRINCIPAL); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, PRINCIPAL, NULL_SUBTYPE); + } + + @Override + public CreatePrincipalResult createPrincipal( + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { + return metaStoreManager.createPrincipal(callCtx, principal); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long catalogId, long id) { + return metaStoreManager.loadResolvedEntityById(callCtx, catalogId, id, PRINCIPAL); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String Name) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, PRINCIPAL, Name); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, entityCatalogId, entityId); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java new file mode 100644 index 0000000000..30414c7e5b --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java @@ -0,0 +1,123 @@ +/* + * 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.transactional; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL_ROLE; + +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.PrincipalRoleDao; +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; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class FdbPrincipalRoleDaoImpl implements PrincipalRoleDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE); + } + + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE, name); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, PRINCIPAL_ROLE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById( + callCtx, entityCatalogId, entityId, PRINCIPAL_ROLE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, PRINCIPAL_ROLE, entityName); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, + entityVersion, + entityGrantRecordsVersion, + PRINCIPAL_ROLE, + entityCatalogId, + entityId); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java new file mode 100644 index 0000000000..efb232917f --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java @@ -0,0 +1,46 @@ +/* + * 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.transactional; + +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisSecretsManager; +import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; +import org.jetbrains.annotations.NotNull; + +public class FdbPrincipalSecretsDaoImpl implements PrincipalSecretsDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( + @NotNull PolarisCallContext callCtx, @NotNull String clientId) { + return metaStoreManager.loadPrincipalSecrets(callCtx, clientId); + } + + @Override + public @NotNull PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( + @NotNull PolarisCallContext callCtx, + @NotNull String clientId, + long principalId, + boolean reset, + @NotNull String oldSecretHash) { + return metaStoreManager.rotatePrincipalSecrets( + callCtx, clientId, principalId, reset, oldSecretHash); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java index 7c53fd8107..b7fce503e8 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java @@ -16,35 +16,132 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.polaris.core.persistence.transactional; +import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; + +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.PolarisEntity; import org.apache.polaris.core.entity.PolarisEntityCore; import org.apache.polaris.core.entity.PolarisEntitySubType; -import org.apache.polaris.core.entity.PolarisEntityType; import org.apache.polaris.core.persistence.dao.TableLikeDao; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; +public class FdbTableLikeDaoImpl implements TableLikeDao { + // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); -import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntitySubType entitySubType, + @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); + } -public class FdbTableLikeDaoImpl implements TableLikeDao { - // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - - @Override - public @NotNull EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @Nullable List catalogPath, @NotNull PolarisEntitySubType entitySubType, @NotNull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); - } - - @NotNull - @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx, @NotNull List catalogPath, @NotNull PolarisEntitySubType entitySubType) { - return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); - } + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TABLE_LIKE); + } + + @NotNull + @Override + public ListEntitiesResult listEntities( + @NotNull PolarisCallContext callCtx, + @NotNull List catalogPath, + @NotNull PolarisEntitySubType entitySubType) { + return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); + } + + @NotNull + @Override + public EntityResult renameEntity( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToRename, + @Nullable List newCatalogPath, + @NotNull PolarisEntity renamedEntity) { + return metaStoreManager.renameEntity( + callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, TABLE_LIKE); + } + + @NotNull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @NotNull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @NotNull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, TABLE_LIKE, entityName); + } + + @NotNull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @NotNull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, TABLE_LIKE, entityCatalogId, entityId); + } + + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } + + @NotNull + @Override + public EntitiesResult updateEntitiesPropertiesIfNotChanged( + @NotNull PolarisCallContext callCtx, @NotNull List entities) { + return metaStoreManager.updateEntitiesPropertiesIfNotChanged(callCtx, entities); + } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java new file mode 100644 index 0000000000..af43c2c6d9 --- /dev/null +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java @@ -0,0 +1,71 @@ +/* + * 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.transactional; + +import static org.apache.polaris.core.entity.PolarisEntityType.TASK; + +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.TaskDao; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class FdbTaskDaoImpl implements TaskDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @NotNull + @Override + public EntitiesResult loadTasks( + @NotNull PolarisCallContext callCtx, String executorId, int limit) { + return metaStoreManager.loadTasks(callCtx, executorId, limit); + } + + @NotNull + @Override + public EntitiesResult createEntitiesIfNotExist( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull List entities) { + return metaStoreManager.createEntitiesIfNotExist(callCtx, catalogPath, entities); + } + + @NotNull + @Override + public DropEntityResult dropEntityIfExists( + @NotNull PolarisCallContext callCtx, + @NotNull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } + + @NotNull + @Override + public EntityResult loadEntity( + @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TASK); + } +} diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java index 0a3986357c..147caccb1d 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java @@ -33,7 +33,7 @@ import org.apache.polaris.core.persistence.cache.EntityCache; import org.apache.polaris.core.persistence.cache.EntityCacheByNameKey; import org.apache.polaris.core.persistence.cache.EntityCacheLookupResult; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; +import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore; import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; @@ -89,7 +89,7 @@ public EntityCacheTest() { store = new PolarisTreeMapStore(diagServices); metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS); callCtx = new PolarisCallContext(metaStore, diagServices); - metaStoreManager = new PolarisMetaStoreManagerImpl(); + metaStoreManager = new PolarisMetastoreManagerDao(); // bootstrap the mata store with our test schema tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx); diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java index fbcb2f9c94..fc87cb7ab0 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java @@ -45,12 +45,12 @@ import org.apache.polaris.core.entity.PrincipalEntity; import org.apache.polaris.core.entity.PrincipalRoleEntity; import org.apache.polaris.core.persistence.cache.EntityCache; +import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; import org.apache.polaris.core.persistence.resolver.Resolver; import org.apache.polaris.core.persistence.resolver.ResolverPath; import org.apache.polaris.core.persistence.resolver.ResolverStatus; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore; import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; @@ -118,7 +118,7 @@ public ResolverTest() { store = new PolarisTreeMapStore(diagServices); metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS); callCtx = new PolarisCallContext(metaStore, diagServices); - metaStoreManager = new PolarisMetaStoreManagerImpl(); + metaStoreManager = new PolarisMetastoreManagerDao(); // bootstrap the mata store with our test schema tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx); From f3bc46c6f1cf5b1fc3b12d5fe3827101b1b090aa Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sat, 8 Mar 2025 21:49:22 -0800 Subject: [PATCH 03/15] Make the EclipseLinkMetastore tests work --- ...olarisEclipseLinkMetaStoreManagerTest.java | 5 ++-- .../dao/PolarisMetastoreManagerDao.java | 6 +++++ .../polaris/core/persistence/dao/TaskDao.java | 14 +++++++++++ .../transactional/FdbTaskDaoImpl.java | 24 +++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java index 9415696dae..c5559da5f8 100644 --- a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java +++ b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java @@ -42,7 +42,7 @@ import org.apache.polaris.core.entity.PolarisPrincipalSecrets; import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest; import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; +import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.jpa.models.ModelPrincipalSecrets; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -104,7 +104,8 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { new PolarisEclipseLinkMetaStoreSessionImpl( store, Mockito.mock(), () -> "realm", null, "polaris", RANDOM_SECRETS); return new PolarisTestMetaStoreManager( - new PolarisMetaStoreManagerImpl(), + // new PolarisMetaStoreManagerImpl(), + new PolarisMetastoreManagerDao(), new PolarisCallContext( session, diagServices, diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java index a4f2b915f5..5d3420f722 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java @@ -109,6 +109,8 @@ public EntityResult readEntityByName( return principalDao.readEntityByName(callCtx, name); case PRINCIPAL_ROLE: return principalRoleDao.readEntityByName(callCtx, name); + case TASK: + return taskDao.readEntityByName(callCtx, name); default: throw new IllegalArgumentException("Unknown entity type: " + entityType); } @@ -134,6 +136,8 @@ public ListEntitiesResult listEntities( return principalDao.listEntities(callCtx); case PRINCIPAL_ROLE: return principalRoleDao.listEntities(callCtx); + case TASK: + return taskDao.listEntities(callCtx); default: throw new IllegalArgumentException("Unknown entity type: " + entityType); } @@ -176,6 +180,8 @@ public EntityResult createEntityIfNotExists( return catalogRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); case PRINCIPAL_ROLE: return principalRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); + case TASK: + return taskDao.createEntityIfNotExists(callCtx, catalogPath, entity); default: throw new IllegalArgumentException("Unknown entity type: " + entity.getType()); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java index 3895a09692..1463f08381 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -28,11 +28,25 @@ import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.jetbrains.annotations.NotNull; public interface TaskDao { + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + @Nonnull EntitiesResult loadTasks(@Nonnull PolarisCallContext callCtx, String executorId, int limit); + @Nonnull + EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, + @jakarta.annotation.Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity); + @Nonnull EntitiesResult createEntitiesIfNotExist( @Nonnull PolarisCallContext callCtx, diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java index af43c2c6d9..6941b92e74 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java @@ -18,6 +18,7 @@ */ package org.apache.polaris.core.persistence.transactional; +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.TASK; import java.util.List; @@ -29,12 +30,26 @@ import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class FdbTaskDaoImpl implements TaskDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + @Override + public @NotNull EntityResult readEntityByName( + @NotNull PolarisCallContext callCtx, @NotNull String name) { + // Task shouldn't have a catalog path and subtype + return metaStoreManager.readEntityByName(callCtx, null, TASK, ANY_SUBTYPE, name); + } + + @NotNull + @Override + public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, TASK, ANY_SUBTYPE); + } + @NotNull @Override public EntitiesResult loadTasks( @@ -42,6 +57,15 @@ public EntitiesResult loadTasks( return metaStoreManager.loadTasks(callCtx, executorId, limit); } + @NotNull + @Override + public EntityResult createEntityIfNotExists( + @NotNull PolarisCallContext callCtx, + @Nullable List catalogPath, + @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + @NotNull @Override public EntitiesResult createEntitiesIfNotExist( From 85cce3a8e448c226fff1badfe47f33c77a10014f Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sat, 8 Mar 2025 22:07:14 -0800 Subject: [PATCH 04/15] Make the TreeMapMetastoreManager tests work --- .../PolarisEclipseLinkMetaStoreManagerTest.java | 6 +++++- .../persistence/PolarisTreeMapMetaStoreManagerTest.java | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java index c5559da5f8..13d2403c9b 100644 --- a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java +++ b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java @@ -104,7 +104,11 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { new PolarisEclipseLinkMetaStoreSessionImpl( store, Mockito.mock(), () -> "realm", null, "polaris", RANDOM_SECRETS); return new PolarisTestMetaStoreManager( - // new PolarisMetaStoreManagerImpl(), + // TODO: Currently, EclipseLinkMetaStoreManager resides within a persistence implementation + // layer, below the DAO layer, + // and ideally shouldn't directly invoke DAO classes. The change is temporarily for refactor + // verification purposes. + // We should identify a cleaner testing strategy moving forward. new PolarisMetastoreManagerDao(), new PolarisCallContext( session, diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java index 65f8080d91..6240daf251 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java @@ -25,7 +25,7 @@ import org.apache.polaris.core.PolarisConfigurationStore; import org.apache.polaris.core.PolarisDefaultDiagServiceImpl; import org.apache.polaris.core.PolarisDiagnostics; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; +import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore; import org.mockito.Mockito; @@ -42,6 +42,11 @@ public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { new PolarisConfigurationStore() {}, timeSource.withZone(ZoneId.systemDefault())); - return new PolarisTestMetaStoreManager(new PolarisMetaStoreManagerImpl(), callCtx); + // TODO: PolarisTreeMapMetaStoreSessionImpl now resides within a persistence implementation + // layer, below the DAO layer, + // and ideally shouldn't directly invoke DAO classes. The change is temporarily for refactor + // verification purposes. + // We should identify a cleaner testing strategy moving forward. + return new PolarisTestMetaStoreManager(new PolarisMetastoreManagerDao(), callCtx); } } From 7bc5704f1bdc32283848fd0fbcba31bce1e01ea3 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sat, 8 Mar 2025 22:08:52 -0800 Subject: [PATCH 05/15] Reformat --- .../PolarisEclipseLinkMetaStoreManagerTest.java | 5 ++--- .../persistence/PolarisTreeMapMetaStoreManagerTest.java | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java index 13d2403c9b..ef13e76b29 100644 --- a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java +++ b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java @@ -105,9 +105,8 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { store, Mockito.mock(), () -> "realm", null, "polaris", RANDOM_SECRETS); return new PolarisTestMetaStoreManager( // TODO: Currently, EclipseLinkMetaStoreManager resides within a persistence implementation - // layer, below the DAO layer, - // and ideally shouldn't directly invoke DAO classes. The change is temporarily for refactor - // verification purposes. + // layer, below the DAO layer, and ideally shouldn't directly invoke DAO classes. The change + // is temporarily for refactor verification purposes. // We should identify a cleaner testing strategy moving forward. new PolarisMetastoreManagerDao(), new PolarisCallContext( diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java index 6240daf251..0c2865074b 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java @@ -43,10 +43,9 @@ public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { timeSource.withZone(ZoneId.systemDefault())); // TODO: PolarisTreeMapMetaStoreSessionImpl now resides within a persistence implementation - // layer, below the DAO layer, - // and ideally shouldn't directly invoke DAO classes. The change is temporarily for refactor - // verification purposes. - // We should identify a cleaner testing strategy moving forward. + // layer, below the DAO layer, and ideally shouldn't directly invoke DAO classes. The change + // is temporarily for refactor verification purposes. We should identify a cleaner testing + // strategy moving forward. return new PolarisTestMetaStoreManager(new PolarisMetastoreManagerDao(), callCtx); } } From c0a0b89028bfa21f7dbcf2ee22f191ca66f862f3 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 00:07:06 -0800 Subject: [PATCH 06/15] Rename --- .../PolarisEclipseLinkMetaStoreManagerTest.java | 4 ++-- .../LocalPolarisMetaStoreManagerFactory.java | 4 ++-- ...storeManagerDao.java => PolarisDaoManager.java} | 14 +++++++------- .../polaris/core/persistence/EntityCacheTest.java | 4 ++-- .../PolarisTreeMapMetaStoreManagerTest.java | 4 ++-- .../polaris/core/persistence/ResolverTest.java | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/{PolarisMetastoreManagerDao.java => PolarisDaoManager.java} (98%) diff --git a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java index ef13e76b29..e8374989a5 100644 --- a/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java +++ b/extension/persistence/eclipselink/src/test/java/org/apache/polaris/extension/persistence/impl/eclipselink/PolarisEclipseLinkMetaStoreManagerTest.java @@ -42,7 +42,7 @@ import org.apache.polaris.core.entity.PolarisPrincipalSecrets; import org.apache.polaris.core.persistence.BasePolarisMetaStoreManagerTest; import org.apache.polaris.core.persistence.PolarisTestMetaStoreManager; -import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.jpa.models.ModelPrincipalSecrets; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; @@ -108,7 +108,7 @@ protected PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { // layer, below the DAO layer, and ideally shouldn't directly invoke DAO classes. The change // is temporarily for refactor verification purposes. // We should identify a cleaner testing strategy moving forward. - new PolarisMetastoreManagerDao(), + new PolarisDaoManager(), new PolarisCallContext( session, diagServices, diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java index 08140c86e4..cc4f376690 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/LocalPolarisMetaStoreManagerFactory.java @@ -36,7 +36,7 @@ import org.apache.polaris.core.entity.PolarisPrincipalSecrets; import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet; import org.apache.polaris.core.persistence.cache.EntityCache; -import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.core.persistence.dao.entity.BaseResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; @@ -94,7 +94,7 @@ private void initializeForRealm( realmContext.getRealmIdentifier(), () -> createMetaStoreSession(backingStore, realmContext, rootCredentialsSet, diagnostics)); - PolarisMetaStoreManager metaStoreManager = new PolarisMetastoreManagerDao(); + PolarisMetaStoreManager metaStoreManager = new PolarisDaoManager(); metaStoreManagerMap.put(realmContext.getRealmIdentifier(), metaStoreManager); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 5d3420f722..59774b9b96 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisMetastoreManagerDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -29,7 +29,7 @@ import org.apache.polaris.core.entity.PolarisEntitySubType; import org.apache.polaris.core.entity.PolarisEntityType; import org.apache.polaris.core.entity.PolarisPrivilege; -import org.apache.polaris.core.persistence.BaseMetaStoreManager; +import org.apache.polaris.core.persistence.PolarisMetaStoreManager; 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.CreateCatalogResult; @@ -55,13 +55,13 @@ import org.apache.polaris.core.storage.PolarisStorageActions; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** This class servers as a bridge so that we defer the business logic refactor */ -public class PolarisMetastoreManagerDao extends BaseMetaStoreManager { - private static final Logger LOGGER = LoggerFactory.getLogger(PolarisMetastoreManagerDao.class); +/** + * This class acts as a temporary bridge to defer refactoring of business logic. It currently + * implements PolarisMetaStoreManager, but it is no longer be necessary after refactoring. + * Post-refactor, callers can directly interact with individual DAO objects as needed. + */ +public class PolarisDaoManager implements PolarisMetaStoreManager { // TODO, using factory or CDI to create following instances, so that the implementation can be // injected. FdbCatalogDaoImpl catalogDao = new FdbCatalogDaoImpl(); diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java index 147caccb1d..03a9cfa6de 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/EntityCacheTest.java @@ -33,7 +33,7 @@ import org.apache.polaris.core.persistence.cache.EntityCache; import org.apache.polaris.core.persistence.cache.EntityCacheByNameKey; import org.apache.polaris.core.persistence.cache.EntityCacheLookupResult; -import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore; import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; @@ -89,7 +89,7 @@ public EntityCacheTest() { store = new PolarisTreeMapStore(diagServices); metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS); callCtx = new PolarisCallContext(metaStore, diagServices); - metaStoreManager = new PolarisMetastoreManagerDao(); + metaStoreManager = new PolarisDaoManager(); // bootstrap the mata store with our test schema tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx); diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java index 0c2865074b..6a015948d3 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/PolarisTreeMapMetaStoreManagerTest.java @@ -25,7 +25,7 @@ import org.apache.polaris.core.PolarisConfigurationStore; import org.apache.polaris.core.PolarisDefaultDiagServiceImpl; import org.apache.polaris.core.PolarisDiagnostics; -import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapMetaStoreSessionImpl; import org.apache.polaris.core.persistence.transactional.PolarisTreeMapStore; import org.mockito.Mockito; @@ -46,6 +46,6 @@ public PolarisTestMetaStoreManager createPolarisTestMetaStoreManager() { // layer, below the DAO layer, and ideally shouldn't directly invoke DAO classes. The change // is temporarily for refactor verification purposes. We should identify a cleaner testing // strategy moving forward. - return new PolarisTestMetaStoreManager(new PolarisMetastoreManagerDao(), callCtx); + return new PolarisTestMetaStoreManager(new PolarisDaoManager(), callCtx); } } diff --git a/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java b/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java index fc87cb7ab0..d367b6a4e5 100644 --- a/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java +++ b/polaris-core/src/test/java/org/apache/polaris/core/persistence/ResolverTest.java @@ -45,7 +45,7 @@ import org.apache.polaris.core.entity.PrincipalEntity; import org.apache.polaris.core.entity.PrincipalRoleEntity; import org.apache.polaris.core.persistence.cache.EntityCache; -import org.apache.polaris.core.persistence.dao.PolarisMetastoreManagerDao; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; import org.apache.polaris.core.persistence.resolver.Resolver; @@ -118,7 +118,7 @@ public ResolverTest() { store = new PolarisTreeMapStore(diagServices); metaStore = new PolarisTreeMapMetaStoreSessionImpl(store, Mockito.mock(), RANDOM_SECRETS); callCtx = new PolarisCallContext(metaStore, diagServices); - metaStoreManager = new PolarisMetastoreManagerDao(); + metaStoreManager = new PolarisDaoManager(); // bootstrap the mata store with our test schema tm = new PolarisTestMetaStoreManager(metaStoreManager, callCtx); From 3a7b209a9dc9eba81568ea47f9a980b350150556 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 00:29:43 -0800 Subject: [PATCH 07/15] Refactor --- .../core/persistence/dao/CatalogDao.java | 27 ++++++++----------- .../core/persistence/dao/CatalogRoleDao.java | 8 +++--- .../core/persistence/dao/NamespaceDao.java | 8 +++--- .../persistence/dao/PolarisDaoManager.java | 4 +-- .../core/persistence/dao/PrincipalDao.java | 2 +- .../persistence/dao/PrincipalRoleDao.java | 2 +- .../core/persistence/dao/TableLikeDao.java | 8 +++--- .../polaris/core/persistence/dao/TaskDao.java | 2 +- .../transactional/FdbCatalogDaoImpl.java | 13 +++------ 9 files changed, 32 insertions(+), 42 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java index ae675d7285..e6bd23fbc0 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -38,24 +38,9 @@ CreateCatalogResult createCatalog( @NotNull PolarisBaseEntity catalog, @NotNull List principalRoles); - // TODO this should return a type-specific entity result, e.g., CatalogEntityResult - @NotNull - EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull String name); - - @Nonnull - EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); - - @Nonnull - ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); - @Nonnull EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( @@ -64,6 +49,16 @@ DropEntityResult dropEntityIfExists( @Nullable Map cleanupProperties, boolean cleanup); + // TODO this should return a type-specific entity result, e.g., CatalogEntityResult + @NotNull + EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + + @Nonnull + ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); + @Nonnull ResolvedEntityResult loadResolvedEntityById( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java index 9f354ed52b..eef095fe8e 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java @@ -67,20 +67,20 @@ ResolvedEntityResult refreshResolvedEntity( @Nonnull EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisEntityCore entityToDrop, - @jakarta.annotation.Nullable Map cleanupProperties, + @Nullable Map cleanupProperties, boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java index e3a8f66742..095e3ed217 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java @@ -68,20 +68,20 @@ ResolvedEntityResult refreshResolvedEntity( @Nonnull EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisEntityCore entityToDrop, - @jakarta.annotation.Nullable Map cleanupProperties, + @Nullable Map cleanupProperties, boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 59774b9b96..21bc8ed38a 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -98,7 +98,7 @@ public EntityResult readEntityByName( @NotNull String name) { switch (entityType) { case CATALOG: - return catalogDao.readEntityByName(callCtx, catalogPath, name); + return catalogDao.readEntityByName(callCtx, name); case NAMESPACE: return namespaceDao.readEntityByName(callCtx, catalogPath, name); case TABLE_LIKE: @@ -205,7 +205,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( @NotNull PolarisBaseEntity entity) { switch (entity.getType()) { case CATALOG: - return catalogDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return catalogDao.updateEntityPropertiesIfNotChanged(callCtx, entity); case NAMESPACE: return namespaceDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); case TABLE_LIKE: diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java index f48cb03175..fbf19cae35 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java @@ -74,6 +74,6 @@ EntityResult updateEntityPropertiesIfNotChanged( DropEntityResult dropEntityIfExists( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisEntityCore entityToDrop, - @jakarta.annotation.Nullable Map cleanupProperties, + @Nullable Map cleanupProperties, boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java index 81aaa6df9d..186ad42ea0 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java @@ -76,6 +76,6 @@ EntityResult updateEntityPropertiesIfNotChanged( DropEntityResult dropEntityIfExists( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisEntityCore entityToDrop, - @jakarta.annotation.Nullable Map cleanupProperties, + @Nullable Map cleanupProperties, boolean cleanup); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java index 35acac20ba..76698972c7 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java @@ -82,21 +82,21 @@ ResolvedEntityResult refreshResolvedEntity( @Nonnull EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisEntityCore entityToDrop, - @jakarta.annotation.Nullable Map cleanupProperties, + @Nullable Map cleanupProperties, boolean cleanup); /** diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java index 1463f08381..82a0a4c944 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -44,7 +44,7 @@ public interface TaskDao { @Nonnull EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, - @jakarta.annotation.Nullable List catalogPath, + @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java index 24d05e9e87..f8ac75befd 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java @@ -49,11 +49,8 @@ public CreateCatalogResult createCatalog( @NotNull @Override - public EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG, ANY_SUBTYPE, name); + public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name) { + return metaStoreManager.readEntityByName(callCtx, null, CATALOG, ANY_SUBTYPE, name); } @NotNull @@ -72,10 +69,8 @@ public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { @NotNull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } @NotNull From 67e714a44f78c5e2b77c2a861295240151d5c306 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 00:47:14 -0800 Subject: [PATCH 08/15] Refactor PrincipalDao --- .../persistence/dao/PolarisDaoManager.java | 11 ++++--- .../core/persistence/dao/PrincipalDao.java | 18 ++++------- .../transactional/FdbPrincipalDaoImpl.java | 30 +++++++------------ 3 files changed, 20 insertions(+), 39 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 21bc8ed38a..bf2aa3f531 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -213,7 +213,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( case CATALOG_ROLE: return catalogRoleDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); case PRINCIPAL: - return principalDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return principalDao.updateEntityPropertiesIfNotChanged(callCtx, entity); case PRINCIPAL_ROLE: return principalRoleDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); default: @@ -291,7 +291,7 @@ public EntityResult loadEntity( case CATALOG_ROLE: return catalogRoleDao.loadEntity(callCtx, entityCatalogId, entityId); case PRINCIPAL: - return principalDao.loadEntity(callCtx, entityCatalogId, entityId); + return principalDao.loadEntity(callCtx, entityId); case PRINCIPAL_ROLE: return principalRoleDao.loadEntity(callCtx, entityCatalogId, entityId); case TASK: @@ -333,7 +333,7 @@ public ResolvedEntityResult loadResolvedEntityById( case TABLE_LIKE: return tableLikeDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); case PRINCIPAL: - return principalDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + return principalDao.loadResolvedEntityById(callCtx, entityId); case PRINCIPAL_ROLE: return principalRoleDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); case CATALOG_ROLE: @@ -359,8 +359,7 @@ public ResolvedEntityResult loadResolvedEntityByName( return tableLikeDao.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, entityName); case PRINCIPAL: - return principalDao.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, entityName); + return principalDao.loadResolvedEntityByName(callCtx, parentId, entityName); case PRINCIPAL_ROLE: return principalRoleDao.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, entityName); @@ -397,7 +396,7 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); case PRINCIPAL: return principalDao.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, entityId); case PRINCIPAL_ROLE: return principalRoleDao.refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java index fbf19cae35..b8dc161c0c 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java @@ -20,7 +20,6 @@ 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; @@ -37,7 +36,7 @@ public interface PrincipalDao { EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); @Nonnull - EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id); @Nonnull ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); @@ -46,29 +45,22 @@ CreatePrincipalResult createPrincipal( @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal); @Nonnull - ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id); @Nonnull ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName); + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String name); @Nonnull ResolvedEntityResult refreshResolvedEntity( @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, - long entityId); + long id); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java index c197f353d6..d53c5f8632 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java @@ -21,7 +21,6 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL; -import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisBaseEntity; @@ -46,9 +45,8 @@ public class FdbPrincipalDaoImpl implements PrincipalDao { @NotNull @Override - public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, PRINCIPAL); + public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL); } @NotNull @@ -65,20 +63,15 @@ public CreatePrincipalResult createPrincipal( @NotNull @Override - public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long catalogId, long id) { - return metaStoreManager.loadResolvedEntityById(callCtx, catalogId, id, PRINCIPAL); + public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL); } @NotNull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @NotNull String Name) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, PRINCIPAL, Name); + @NotNull PolarisCallContext callCtx, long parentId, @NotNull String name) { + return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, PRINCIPAL, name); } @NotNull @@ -87,19 +80,16 @@ public ResolvedEntityResult refreshResolvedEntity( @NotNull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { + long id) { return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, 0L, id); } @NotNull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } @NotNull From 199b60c90a6bac212d3c91bb2bbbbde8b6250201 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 00:57:50 -0800 Subject: [PATCH 09/15] Refactor TaskDao --- .../persistence/dao/PolarisDaoManager.java | 6 +++--- .../polaris/core/persistence/dao/TaskDao.java | 16 ++++++---------- .../transactional/FdbTaskDaoImpl.java | 19 +++++++------------ 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index bf2aa3f531..294611414e 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -181,7 +181,7 @@ public EntityResult createEntityIfNotExists( case PRINCIPAL_ROLE: return principalRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); case TASK: - return taskDao.createEntityIfNotExists(callCtx, catalogPath, entity); + return taskDao.createEntityIfNotExists(callCtx, entity); default: throw new IllegalArgumentException("Unknown entity type: " + entity.getType()); } @@ -194,7 +194,7 @@ public EntitiesResult createEntitiesIfNotExist( @Nullable List catalogPath, @NotNull List entities) { // only for tasks - return taskDao.createEntitiesIfNotExist(callCtx, catalogPath, entities); + return taskDao.createTasksIfNotExist(callCtx, entities); } @NotNull @@ -295,7 +295,7 @@ public EntityResult loadEntity( case PRINCIPAL_ROLE: return principalRoleDao.loadEntity(callCtx, entityCatalogId, entityId); case TASK: - return taskDao.loadEntity(callCtx, entityCatalogId, entityId); + return taskDao.loadEntity(callCtx, entityId); case NULL_TYPE: return commonDao.loadEntity(callCtx, entityCatalogId, entityId); default: diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java index 82a0a4c944..b179c5cd8b 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -41,17 +41,16 @@ public interface TaskDao { @Nonnull EntitiesResult loadTasks(@Nonnull PolarisCallContext callCtx, String executorId, int limit); + @Nonnull + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id); + @Nonnull EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); @Nonnull - EntitiesResult createEntitiesIfNotExist( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull List entities); + EntitiesResult createTasksIfNotExist( + @Nonnull PolarisCallContext callCtx, @Nonnull List entities); @Nonnull DropEntityResult dropEntityIfExists( @@ -59,7 +58,4 @@ DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup); - - @Nonnull - EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java index 6941b92e74..bf400ece18 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java @@ -60,19 +60,15 @@ public EntitiesResult loadTasks( @NotNull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); } @NotNull @Override - public EntitiesResult createEntitiesIfNotExist( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull List entities) { - return metaStoreManager.createEntitiesIfNotExist(callCtx, catalogPath, entities); + public EntitiesResult createTasksIfNotExist( + @NotNull PolarisCallContext callCtx, @NotNull List entities) { + return metaStoreManager.createEntitiesIfNotExist(callCtx, null, entities); } @NotNull @@ -88,8 +84,7 @@ public DropEntityResult dropEntityIfExists( @NotNull @Override - public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TASK); + public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long entityId) { + return metaStoreManager.loadEntity(callCtx, 0L, entityId, TASK); } } From 953770da18d0dedff2c17718b0c443b6cd7c681c Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 01:12:54 -0800 Subject: [PATCH 10/15] Refactor PrincipalRoleDao --- .../persistence/dao/PolarisDaoManager.java | 13 +++--- .../persistence/dao/PrincipalRoleDao.java | 20 +++------ .../FdbPrincipalRoleDaoImpl.java | 41 ++++++------------- 3 files changed, 23 insertions(+), 51 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 294611414e..2f3fd72bf4 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -179,7 +179,7 @@ public EntityResult createEntityIfNotExists( case CATALOG_ROLE: return catalogRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); case PRINCIPAL_ROLE: - return principalRoleDao.createEntityIfNotExists(callCtx, catalogPath, entity); + return principalRoleDao.createEntityIfNotExists(callCtx, entity); case TASK: return taskDao.createEntityIfNotExists(callCtx, entity); default: @@ -215,7 +215,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( case PRINCIPAL: return principalDao.updateEntityPropertiesIfNotChanged(callCtx, entity); case PRINCIPAL_ROLE: - return principalRoleDao.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return principalRoleDao.updateEntityPropertiesIfNotChanged(callCtx, entity); default: throw new IllegalArgumentException("Unknown entity type: " + entity.getType()); } @@ -293,7 +293,7 @@ public EntityResult loadEntity( case PRINCIPAL: return principalDao.loadEntity(callCtx, entityId); case PRINCIPAL_ROLE: - return principalRoleDao.loadEntity(callCtx, entityCatalogId, entityId); + return principalRoleDao.loadEntity(callCtx, entityId); case TASK: return taskDao.loadEntity(callCtx, entityId); case NULL_TYPE: @@ -335,7 +335,7 @@ public ResolvedEntityResult loadResolvedEntityById( case PRINCIPAL: return principalDao.loadResolvedEntityById(callCtx, entityId); case PRINCIPAL_ROLE: - return principalRoleDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + return principalRoleDao.loadResolvedEntityById(callCtx, entityId); case CATALOG_ROLE: return catalogRoleDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); default: @@ -361,8 +361,7 @@ public ResolvedEntityResult loadResolvedEntityByName( case PRINCIPAL: return principalDao.loadResolvedEntityByName(callCtx, parentId, entityName); case PRINCIPAL_ROLE: - return principalRoleDao.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, entityName); + return principalRoleDao.loadResolvedEntityByName(callCtx, parentId, entityName); case ROOT: return commonDao.loadResolvedEntityByName(callCtx, entityCatalogId, parentId, entityName); case CATALOG: @@ -399,7 +398,7 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, entityId); case PRINCIPAL_ROLE: return principalRoleDao.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, entityId); case CATALOG_ROLE: return catalogRoleDao.refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java index 186ad42ea0..3518f822ea 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java @@ -20,7 +20,6 @@ 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; @@ -39,38 +38,29 @@ public interface PrincipalRoleDao { EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); @Nonnull - EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id); @Nonnull - ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id); @Nonnull ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName); + @Nonnull PolarisCallContext callCtx, 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 catalogPath, - @Nonnull PolarisBaseEntity entity); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity); @Nonnull DropEntityResult dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java index 30414c7e5b..a85580e29f 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java @@ -21,7 +21,6 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL_ROLE; -import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisBaseEntity; @@ -51,28 +50,22 @@ public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { @NotNull @Override - public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, PRINCIPAL_ROLE); + public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL_ROLE); } @NotNull @Override - public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById( - callCtx, entityCatalogId, entityId, PRINCIPAL_ROLE); + public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL_ROLE); } @NotNull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @NotNull String entityName) { + @NotNull PolarisCallContext callCtx, long parentId, @NotNull String entityName) { return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, PRINCIPAL_ROLE, entityName); + callCtx, 0L, parentId, PRINCIPAL_ROLE, entityName); } @NotNull @@ -81,33 +74,23 @@ public ResolvedEntityResult refreshResolvedEntity( @NotNull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { + long id) { return metaStoreManager.refreshResolvedEntity( - callCtx, - entityVersion, - entityGrantRecordsVersion, - PRINCIPAL_ROLE, - entityCatalogId, - entityId); + callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL_ROLE, 0L, id); } @NotNull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); } @NotNull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, - @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } @NotNull From d173d1a47c7b9d428e3f544aa93cb942d92afe2e Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 15:01:44 -0700 Subject: [PATCH 11/15] Use jarkarta Nonnull and Nullable instead of jetbrain ones --- .../core/persistence/dao/CatalogDao.java | 13 +- .../core/persistence/dao/CatalogRoleDao.java | 9 +- .../core/persistence/dao/NamespaceDao.java | 9 +- .../persistence/dao/PolarisDaoManager.java | 184 +++++++++--------- .../core/persistence/dao/PrincipalDao.java | 7 +- .../persistence/dao/PrincipalRoleDao.java | 5 +- .../core/persistence/dao/TableLikeDao.java | 13 +- .../polaris/core/persistence/dao/TaskDao.java | 5 +- .../transactional/FdbCatalogDaoImpl.java | 46 ++--- .../transactional/FdbCatalogRoleDaoImpl.java | 50 ++--- .../transactional/FdbCommonDaoImpl.java | 32 +-- .../FdbCredentialVendorDaoImpl.java | 18 +- .../transactional/FdbGrantRecordDaoImpl.java | 46 ++--- .../transactional/FdbNamespaceDaoImpl.java | 51 +++-- .../transactional/FdbPrincipalDaoImpl.java | 40 ++-- .../FdbPrincipalRoleDaoImpl.java | 42 ++-- .../FdbPrincipalSecretsDaoImpl.java | 14 +- .../transactional/FdbTableLikeDaoImpl.java | 69 ++++--- .../transactional/FdbTaskDaoImpl.java | 34 ++-- 19 files changed, 339 insertions(+), 348 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java index e6bd23fbc0..a4c0295880 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -19,6 +19,7 @@ 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; @@ -29,14 +30,12 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface CatalogDao { CreateCatalogResult createCatalog( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisBaseEntity catalog, - @NotNull List principalRoles); + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisBaseEntity catalog, + @Nonnull List principalRoles); @Nonnull EntityResult updateEntityPropertiesIfNotChanged( @@ -50,8 +49,8 @@ DropEntityResult dropEntityIfExists( boolean cleanup); // TODO this should return a type-specific entity result, e.g., CatalogEntityResult - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + @Nonnull + EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java index eef095fe8e..2d88fc0266 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogRoleDao.java @@ -19,6 +19,7 @@ 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; @@ -28,15 +29,13 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface CatalogRoleDao { - @NotNull + @Nonnull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull String name); + @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java index 095e3ed217..97c9a19281 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/NamespaceDao.java @@ -19,6 +19,7 @@ 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; @@ -28,16 +29,14 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface NamespaceDao { // TODO this should return a type-specific entity result - @NotNull + @Nonnull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull String name); + @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 2f3fd72bf4..35e49491fd 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -18,6 +18,8 @@ */ package org.apache.polaris.core.persistence.dao; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import java.util.Set; @@ -53,8 +55,6 @@ import org.apache.polaris.core.persistence.transactional.FdbTableLikeDaoImpl; import org.apache.polaris.core.persistence.transactional.FdbTaskDaoImpl; import org.apache.polaris.core.storage.PolarisStorageActions; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * This class acts as a temporary bridge to defer refactoring of business logic. It currently @@ -76,26 +76,26 @@ public class PolarisDaoManager implements PolarisMetaStoreManager { FdbCommonDaoImpl commonDao = new FdbCommonDaoImpl(); FdbCredentialVendorDaoImpl credentialVendorDao = new FdbCredentialVendorDaoImpl(); - @NotNull + @Nonnull @Override - public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { + public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { return commonDao.bootstrapPolarisService(callCtx); } - @NotNull + @Nonnull @Override - public BaseResult purge(@NotNull PolarisCallContext callCtx) { + public BaseResult purge(@Nonnull PolarisCallContext callCtx) { return commonDao.purge(callCtx); } - @NotNull + @Nonnull @Override public EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityType entityType, - @NotNull PolarisEntitySubType entitySubType, - @NotNull String name) { + @Nonnull PolarisEntityType entityType, + @Nonnull PolarisEntitySubType entitySubType, + @Nonnull String name) { switch (entityType) { case CATALOG: return catalogDao.readEntityByName(callCtx, name); @@ -116,13 +116,13 @@ public EntityResult readEntityByName( } } - @NotNull + @Nonnull @Override public ListEntitiesResult listEntities( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityType entityType, - @NotNull PolarisEntitySubType entitySubType) { + @Nonnull PolarisEntityType entityType, + @Nonnull PolarisEntitySubType entitySubType) { switch (entityType) { case CATALOG: return catalogDao.listEntities(callCtx); @@ -143,34 +143,34 @@ public ListEntitiesResult listEntities( } } - @NotNull + @Nonnull @Override - public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { + public GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx) { return commonDao.generateNewEntityId(callCtx); } - @NotNull + @Nonnull @Override public CreatePrincipalResult createPrincipal( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal) { return principalDao.createPrincipal(callCtx, principal); } - @NotNull + @Nonnull @Override public CreateCatalogResult createCatalog( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisBaseEntity catalog, - @NotNull List principalRoles) { + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisBaseEntity catalog, + @Nonnull List principalRoles) { return catalogDao.createCatalog(callCtx, catalog, principalRoles); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { switch (entity.getType()) { case NAMESPACE: return namespaceDao.createEntityIfNotExists(callCtx, catalogPath, entity); @@ -187,22 +187,22 @@ public EntityResult createEntityIfNotExists( } } - @NotNull + @Nonnull @Override public EntitiesResult createEntitiesIfNotExist( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull List entities) { + @Nonnull List entities) { // only for tasks return taskDao.createTasksIfNotExist(callCtx, entities); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { switch (entity.getType()) { case CATALOG: return catalogDao.updateEntityPropertiesIfNotChanged(callCtx, entity); @@ -221,33 +221,33 @@ public EntityResult updateEntityPropertiesIfNotChanged( } } - @NotNull + @Nonnull @Override public EntitiesResult updateEntitiesPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, @NotNull List entities) { + @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { // only for multi-table transactions return tableLikeDao.updateEntitiesPropertiesIfNotChanged(callCtx, entities); } - @NotNull + @Nonnull @Override public EntityResult renameEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToRename, + @Nonnull PolarisEntityCore entityToRename, @Nullable List newCatalogPath, - @NotNull PolarisEntity renamedEntity) { + @Nonnull PolarisEntity renamedEntity) { // only tableLike is supported return tableLikeDao.renameEntity( callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { switch (entityToDrop.getType()) { @@ -274,13 +274,13 @@ public DropEntityResult dropEntityIfExists( } } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId, - @NotNull PolarisEntityType entityType) { + @Nonnull PolarisEntityType entityType) { switch (entityType) { case CATALOG: return catalogDao.loadEntity(callCtx, entityCatalogId, entityId); @@ -303,25 +303,25 @@ public EntityResult loadEntity( } } - @NotNull + @Nonnull @Override public EntitiesResult loadTasks( - @NotNull PolarisCallContext callCtx, String executorId, int limit) { + @Nonnull PolarisCallContext callCtx, String executorId, int limit) { return taskDao.loadTasks(callCtx, executorId, limit); } - @NotNull + @Nonnull @Override public ChangeTrackingResult loadEntitiesChangeTracking( - @NotNull PolarisCallContext callCtx, @NotNull List entityIds) { + @Nonnull PolarisCallContext callCtx, @Nonnull List entityIds) { // todo we need to figure out how to handle type-specific one later return commonDao.loadEntitiesChangeTracking(callCtx, entityIds); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId, PolarisEntityType entityType) { @@ -343,14 +343,14 @@ public ResolvedEntityResult loadResolvedEntityById( } } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull PolarisEntityType entityType, - @NotNull String entityName) { + @Nonnull PolarisEntityType entityType, + @Nonnull String entityName) { switch (entityType) { case NAMESPACE: return namespaceDao.loadResolvedEntityByName( @@ -374,13 +374,13 @@ public ResolvedEntityResult loadResolvedEntityByName( } } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - @NotNull PolarisEntityType entityType, + @Nonnull PolarisEntityType entityType, long entityCatalogId, long entityId) { switch (entityType) { @@ -410,93 +410,93 @@ public ResolvedEntityResult refreshResolvedEntity( } } - @NotNull + @Nonnull @Override public PrivilegeResult grantUsageOnRoleToGrantee( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, - @NotNull PolarisEntityCore role, - @NotNull PolarisEntityCore grantee) { + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { return grantRecordDao.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); } - @NotNull + @Nonnull @Override public PrivilegeResult revokeUsageOnRoleFromGrantee( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, - @NotNull PolarisEntityCore role, - @NotNull PolarisEntityCore grantee) { + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { return grantRecordDao.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); } - @NotNull + @Nonnull @Override public PrivilegeResult grantPrivilegeOnSecurableToRole( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore grantee, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, @Nullable List catalogPath, - @NotNull PolarisEntityCore securable, - @NotNull PolarisPrivilege privilege) { + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { return grantRecordDao.grantPrivilegeOnSecurableToRole( callCtx, grantee, catalogPath, securable, privilege); } - @NotNull + @Nonnull @Override public PrivilegeResult revokePrivilegeOnSecurableFromRole( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore grantee, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, @Nullable List catalogPath, - @NotNull PolarisEntityCore securable, - @NotNull PolarisPrivilege privilege) { + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { return grantRecordDao.revokePrivilegeOnSecurableFromRole( callCtx, grantee, catalogPath, securable, privilege); } - @NotNull + @Nonnull @Override public LoadGrantsResult loadGrantsOnSecurable( - @NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId) { return grantRecordDao.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); } - @NotNull + @Nonnull @Override public LoadGrantsResult loadGrantsToGrantee( PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { return grantRecordDao.loadGrantsToGrantee(callCtx, granteeCatalogId, granteeId); } - @NotNull + @Nonnull @Override public PrincipalSecretsResult loadPrincipalSecrets( - @NotNull PolarisCallContext callCtx, @NotNull String clientId) { + @Nonnull PolarisCallContext callCtx, @Nonnull String clientId) { return principalSecretsDao.loadPrincipalSecrets(callCtx, clientId); } - @NotNull + @Nonnull @Override public PrincipalSecretsResult rotatePrincipalSecrets( - @NotNull PolarisCallContext callCtx, - @NotNull String clientId, + @Nonnull PolarisCallContext callCtx, + @Nonnull String clientId, long principalId, boolean reset, - @NotNull String oldSecretHash) { + @Nonnull String oldSecretHash) { return principalSecretsDao.rotatePrincipalSecrets( callCtx, clientId, principalId, reset, oldSecretHash); } - @NotNull + @Nonnull @Override public ScopedCredentialsResult getSubscopedCredsForEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, boolean allowListOperation, - @NotNull Set allowedReadLocations, - @NotNull Set allowedWriteLocations) { + @Nonnull Set allowedReadLocations, + @Nonnull Set allowedWriteLocations) { return credentialVendorDao.getSubscopedCredsForEntity( callCtx, catalogId, @@ -507,15 +507,15 @@ public ScopedCredentialsResult getSubscopedCredsForEntity( allowedWriteLocations); } - @NotNull + @Nonnull @Override public ValidateAccessResult validateAccessToLocations( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, - @NotNull Set actions, - @NotNull Set locations) { + @Nonnull Set actions, + @Nonnull Set locations) { return credentialVendorDao.validateAccessToLocations( callCtx, catalogId, entityId, entityType, actions, locations); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java index b8dc161c0c..23a53fd8d2 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalDao.java @@ -29,11 +29,10 @@ 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; -import org.jetbrains.annotations.NotNull; public interface PrincipalDao { - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + @Nonnull + EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id); @@ -42,7 +41,7 @@ public interface PrincipalDao { ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); CreatePrincipalResult createPrincipal( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal); + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal); @Nonnull ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java index 3518f822ea..8dd1799334 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PrincipalRoleDao.java @@ -28,14 +28,13 @@ 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; -import org.jetbrains.annotations.NotNull; public interface PrincipalRoleDao { @Nonnull ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + @Nonnull + EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java index 76698972c7..f41a883ef4 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TableLikeDao.java @@ -19,6 +19,7 @@ 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; @@ -32,16 +33,14 @@ import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface TableLikeDao { - @NotNull + @Nonnull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntitySubType entitySubType, - @NotNull String name); + @Nonnull PolarisEntitySubType entitySubType, + @Nonnull String name); @Nonnull EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); @@ -50,7 +49,7 @@ EntityResult readEntityByName( ListEntitiesResult listEntities( @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath, - @NotNull PolarisEntitySubType entitySubType); + @Nonnull PolarisEntitySubType entitySubType); @Nonnull EntityResult renameEntity( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java index b179c5cd8b..364f773eef 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/TaskDao.java @@ -29,11 +29,10 @@ import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; public interface TaskDao { - @NotNull - EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name); + @Nonnull + EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); @Nonnull ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java index f8ac75befd..e425f78f28 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; @@ -32,8 +34,6 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbCatalogDaoImpl implements CatalogDao { // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well @@ -41,71 +41,71 @@ public class FdbCatalogDaoImpl implements CatalogDao { @Override public CreateCatalogResult createCatalog( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisBaseEntity catalog, - @NotNull List principalRoles) { + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisBaseEntity catalog, + @Nonnull List principalRoles) { return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); } - @NotNull + @Nonnull @Override - public EntityResult readEntityByName(@NotNull PolarisCallContext callCtx, @NotNull String name) { + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, null, CATALOG, ANY_SUBTYPE, name); } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG); } - @NotNull + @Nonnull @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( callCtx, null, entityToDrop, cleanupProperties, cleanup); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, CATALOG); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull String entityName) { + @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, CATALOG, entityName); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long entityCatalogId, diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java index 7b6c77d11f..ff50ab373f 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG_ROLE; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; @@ -31,57 +33,55 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbCatalogRoleDaoImpl implements CatalogRoleDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull String name) { + @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE, name); } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG_ROLE); } - @NotNull + @Nonnull @Override public ListEntitiesResult listEntities( - @NotNull PolarisCallContext callCtx, @Nullable List catalogPath) { + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath) { return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadResolvedEntityById( callCtx, entityCatalogId, entityId, CATALOG_ROLE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull String entityName) { + @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, CATALOG_ROLE, entityName); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long entityCatalogId, @@ -90,30 +90,30 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, CATALOG_ROLE, entityCatalogId, entityId); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java index bd65f303cb..b301493fa5 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java @@ -21,6 +21,7 @@ import static org.apache.polaris.core.entity.PolarisEntityType.NULL_TYPE; import static org.apache.polaris.core.entity.PolarisEntityType.ROOT; +import jakarta.annotation.Nonnull; import java.util.List; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisEntityId; @@ -30,51 +31,50 @@ 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; -import org.jetbrains.annotations.NotNull; public class FdbCommonDaoImpl implements CommonDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @NotNull + @Nonnull @Override - public GenerateEntityIdResult generateNewEntityId(@NotNull PolarisCallContext callCtx) { + public GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.generateNewEntityId(callCtx); } - @NotNull + @Nonnull @Override - public BaseResult bootstrapPolarisService(@NotNull PolarisCallContext callCtx) { + public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.bootstrapPolarisService(callCtx); } - @NotNull + @Nonnull @Override - public BaseResult purge(@NotNull PolarisCallContext callCtx) { + public BaseResult purge(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.purge(callCtx); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull String entityName) { + @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, ROOT, entityName); } - @NotNull + @Nonnull @Override public ChangeTrackingResult loadEntitiesChangeTracking( - @NotNull PolarisCallContext callCtx, @NotNull List entityIds) { + @Nonnull PolarisCallContext callCtx, @Nonnull List entityIds) { return metaStoreManager.loadEntitiesChangeTracking(callCtx, entityIds); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long entityCatalogId, @@ -83,10 +83,10 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, ROOT, entityCatalogId, entityId); } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NULL_TYPE); } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java index 39f10ab056..7b13843e9e 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java @@ -18,27 +18,27 @@ */ package org.apache.polaris.core.persistence.transactional; +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.persistence.dao.CredentialVendorDao; import org.apache.polaris.core.storage.PolarisCredentialVendor; import org.apache.polaris.core.storage.PolarisStorageActions; -import org.jetbrains.annotations.NotNull; public class FdbCredentialVendorDaoImpl implements CredentialVendorDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @NotNull + @Nonnull @Override public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, boolean allowListOperation, - @NotNull Set allowedReadLocations, - @NotNull Set allowedWriteLocations) { + @Nonnull Set allowedReadLocations, + @Nonnull Set allowedWriteLocations) { return metaStoreManager.getSubscopedCredsForEntity( callCtx, catalogId, @@ -49,15 +49,15 @@ public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntit allowedWriteLocations); } - @NotNull + @Nonnull @Override public PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long catalogId, long entityId, PolarisEntityType entityType, - @NotNull Set actions, - @NotNull Set locations) { + @Nonnull Set actions, + @Nonnull Set locations) { return metaStoreManager.validateAccessToLocations( callCtx, catalogId, entityId, entityType, actions, locations); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java index a4efeb3052..64b948ef3c 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java @@ -18,70 +18,70 @@ */ package org.apache.polaris.core.persistence.transactional; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.auth.PolarisGrantManager; import org.apache.polaris.core.entity.PolarisEntityCore; import org.apache.polaris.core.entity.PolarisPrivilege; import org.apache.polaris.core.persistence.dao.GrantRecordDao; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbGrantRecordDaoImpl implements GrantRecordDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @NotNull + @Nonnull @Override public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, - @NotNull PolarisEntityCore role, - @NotNull PolarisEntityCore grantee) { + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { return metaStoreManager.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); } - @NotNull + @Nonnull @Override public PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable PolarisEntityCore catalog, - @NotNull PolarisEntityCore role, - @NotNull PolarisEntityCore grantee) { + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { return metaStoreManager.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); } - @NotNull + @Nonnull @Override public PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore grantee, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, @Nullable List catalogPath, - @NotNull PolarisEntityCore securable, - @NotNull PolarisPrivilege privilege) { + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { return metaStoreManager.grantPrivilegeOnSecurableToRole( callCtx, grantee, catalogPath, securable, privilege); } - @NotNull + @Nonnull @Override public PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore grantee, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, @Nullable List catalogPath, - @NotNull PolarisEntityCore securable, - @NotNull PolarisPrivilege privilege) { + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { return metaStoreManager.revokePrivilegeOnSecurableFromRole( callCtx, grantee, catalogPath, securable, privilege); } - @NotNull + @Nonnull @Override public PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( - @NotNull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId) { return metaStoreManager.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); } - @NotNull + @Nonnull @Override public PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java index 069605344a..bf767466dc 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; @@ -31,57 +33,54 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbNamespaceDaoImpl implements NamespaceDao { - // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull String name) { + @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NAMESPACE); } - @NotNull + @Nonnull @Override public ListEntitiesResult listEntities( - @NotNull PolarisCallContext callCtx, @NotNull List catalogPath) { + @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath) { return metaStoreManager.listEntities(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, NAMESPACE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull String entityName) { + @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, NAMESPACE, entityName); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long entityCatalogId, @@ -90,30 +89,30 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, NAMESPACE, entityCatalogId, entityId); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java index d53c5f8632..66f0f15af9 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisBaseEntity; @@ -31,53 +33,51 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbPrincipalDaoImpl implements PrincipalDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, @NotNull String name) { + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL, NULL_SUBTYPE, name); } - @NotNull + @Nonnull @Override - public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long id) { + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL); } - @NotNull + @Nonnull @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.listEntities(callCtx, null, PRINCIPAL, NULL_SUBTYPE); } @Override public CreatePrincipalResult createPrincipal( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity principal) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal) { return metaStoreManager.createPrincipal(callCtx, principal); } - @NotNull + @Nonnull @Override - public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long id) { + public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, long parentId, @NotNull String name) { + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String name) { return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, PRINCIPAL, name); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long id) { @@ -85,18 +85,18 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, 0L, id); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java index a85580e29f..ad789f88ca 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL_ROLE; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.entity.PolarisBaseEntity; @@ -30,48 +32,46 @@ 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; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbPrincipalRoleDaoImpl implements PrincipalRoleDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @NotNull + @Nonnull @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.listEntities(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE); } @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, @NotNull String name) { + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE, name); } - @NotNull + @Nonnull @Override - public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long id) { + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL_ROLE); } - @NotNull + @Nonnull @Override - public ResolvedEntityResult loadResolvedEntityById(@NotNull PolarisCallContext callCtx, long id) { + public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL_ROLE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, long parentId, @NotNull String entityName) { + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, 0L, parentId, PRINCIPAL_ROLE, entityName); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long id) { @@ -79,25 +79,25 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL_ROLE, 0L, id); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java index efb232917f..f1a28b5d59 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java @@ -18,28 +18,28 @@ */ package org.apache.polaris.core.persistence.transactional; +import jakarta.annotation.Nonnull; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.auth.PolarisSecretsManager; import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; -import org.jetbrains.annotations.NotNull; public class FdbPrincipalSecretsDaoImpl implements PrincipalSecretsDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @NotNull + @Nonnull @Override public PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( - @NotNull PolarisCallContext callCtx, @NotNull String clientId) { + @Nonnull PolarisCallContext callCtx, @Nonnull String clientId) { return metaStoreManager.loadPrincipalSecrets(callCtx, clientId); } @Override - public @NotNull PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( - @NotNull PolarisCallContext callCtx, - @NotNull String clientId, + public @Nonnull PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( + @Nonnull PolarisCallContext callCtx, + @Nonnull String clientId, long principalId, boolean reset, - @NotNull String oldSecretHash) { + @Nonnull String oldSecretHash) { return metaStoreManager.rotatePrincipalSecrets( callCtx, clientId, principalId, reset, oldSecretHash); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java index b7fce503e8..da040d5360 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java @@ -20,6 +20,8 @@ import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; @@ -34,72 +36,69 @@ import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbTableLikeDaoImpl implements TableLikeDao { - // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntitySubType entitySubType, - @NotNull String name) { + @Nonnull PolarisEntitySubType entitySubType, + @Nonnull String name) { return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); } - @NotNull + @Nonnull @Override public EntityResult loadEntity( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TABLE_LIKE); } - @NotNull + @Nonnull @Override public ListEntitiesResult listEntities( - @NotNull PolarisCallContext callCtx, - @NotNull List catalogPath, - @NotNull PolarisEntitySubType entitySubType) { + @Nonnull PolarisCallContext callCtx, + @Nonnull List catalogPath, + @Nonnull PolarisEntitySubType entitySubType) { return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); } - @NotNull + @Nonnull @Override public EntityResult renameEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToRename, + @Nonnull PolarisEntityCore entityToRename, @Nullable List newCatalogPath, - @NotNull PolarisEntity renamedEntity) { + @Nonnull PolarisEntity renamedEntity) { return metaStoreManager.renameEntity( callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @NotNull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, TABLE_LIKE); } - @NotNull + @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long parentId, - @NotNull String entityName) { + @Nonnull String entityName) { return metaStoreManager.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, TABLE_LIKE, entityName); } - @NotNull + @Nonnull @Override public ResolvedEntityResult refreshResolvedEntity( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, long entityCatalogId, @@ -108,40 +107,40 @@ public ResolvedEntityResult refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, TABLE_LIKE, entityCatalogId, entityId); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisBaseEntity entity) { return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); } - @NotNull + @Nonnull @Override public EntitiesResult updateEntitiesPropertiesIfNotChanged( - @NotNull PolarisCallContext callCtx, @NotNull List entities) { + @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { return metaStoreManager.updateEntitiesPropertiesIfNotChanged(callCtx, entities); } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java index bf400ece18..99c4ff8ec7 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java @@ -21,6 +21,8 @@ import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.TASK; +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; import java.util.List; import java.util.Map; import org.apache.polaris.core.PolarisCallContext; @@ -31,60 +33,58 @@ import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class FdbTaskDaoImpl implements TaskDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override - public @NotNull EntityResult readEntityByName( - @NotNull PolarisCallContext callCtx, @NotNull String name) { + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { // Task shouldn't have a catalog path and subtype return metaStoreManager.readEntityByName(callCtx, null, TASK, ANY_SUBTYPE, name); } - @NotNull + @Nonnull @Override - public ListEntitiesResult listEntities(@NotNull PolarisCallContext callCtx) { + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { return metaStoreManager.listEntities(callCtx, null, TASK, ANY_SUBTYPE); } - @NotNull + @Nonnull @Override public EntitiesResult loadTasks( - @NotNull PolarisCallContext callCtx, String executorId, int limit) { + @Nonnull PolarisCallContext callCtx, String executorId, int limit) { return metaStoreManager.loadTasks(callCtx, executorId, limit); } - @NotNull + @Nonnull @Override public EntityResult createEntityIfNotExists( - @NotNull PolarisCallContext callCtx, @NotNull PolarisBaseEntity entity) { + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); } - @NotNull + @Nonnull @Override public EntitiesResult createTasksIfNotExist( - @NotNull PolarisCallContext callCtx, @NotNull List entities) { + @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { return metaStoreManager.createEntitiesIfNotExist(callCtx, null, entities); } - @NotNull + @Nonnull @Override public DropEntityResult dropEntityIfExists( - @NotNull PolarisCallContext callCtx, - @NotNull PolarisEntityCore entityToDrop, + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { return metaStoreManager.dropEntityIfExists( callCtx, null, entityToDrop, cleanupProperties, cleanup); } - @NotNull + @Nonnull @Override - public EntityResult loadEntity(@NotNull PolarisCallContext callCtx, long entityId) { + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId) { return metaStoreManager.loadEntity(callCtx, 0L, entityId, TASK); } } From 7451a34243393f25b03e0b1ab1fc492dbf076a19 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 15:09:50 -0700 Subject: [PATCH 12/15] Refactor --- .../postgres/PostgresCatalogDaoImpl.java | 117 ++++++++++++++ .../postgres/PostgresCatalogRoleDaoImpl.java | 123 +++++++++++++++ .../postgres/PostgresCommonDaoImpl.java | 93 +++++++++++ .../PostgresCredentialVendorDaoImpl.java | 65 ++++++++ .../postgres/PostgresGrantRecordDaoImpl.java | 91 +++++++++++ .../postgres/PostgresNamespaceDaoImpl.java | 122 +++++++++++++++ .../postgres/PostgresPrincipalDaoImpl.java | 106 +++++++++++++ .../PostgresPrincipalRoleDaoImpl.java | 107 +++++++++++++ .../PostgresPrincipalSecretsDaoImpl.java | 47 ++++++ .../postgres/PostgresTableLikeDaoImpl.java | 147 ++++++++++++++++++ .../postgres/PostgresTaskDaoImpl.java | 91 +++++++++++ .../mongodb/MongoDbCatalogDaoImpl.java | 21 --- .../mongodb/MongoDbNamespaceDaoImpl.java | 21 --- .../mongodb/MongoDbTableLikeDaoImpl.java | 21 --- .../postgres/PostgresCatalogDaoImpl.java | 21 --- .../postgres/PostgresNamespaceDaoImpl.java | 21 --- .../postgres/PostgresTableLikeDaoImpl.java | 21 --- 17 files changed, 1109 insertions(+), 126 deletions(-) create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java create mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java delete mode 100644 polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java new file mode 100644 index 0000000000..a5f466ec56 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java @@ -0,0 +1,117 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; + +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.CatalogDao; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresCatalogDaoImpl implements CatalogDao { + // TODO it uses PolarisMetaStoreManagerImpl now, we can change it later + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public CreateCatalogResult createCatalog( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisBaseEntity catalog, + @Nonnull List principalRoles) { + return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); + } + + @Nonnull + @Override + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, null, CATALOG, ANY_SUBTYPE, name); + } + + @Nonnull + @Override + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, CATALOG); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, CATALOG, entityName); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, entityCatalogId, entityId); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java new file mode 100644 index 0000000000..5371c26a8f --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java @@ -0,0 +1,123 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG_ROLE; + +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.CatalogRoleDao; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresCatalogRoleDaoImpl implements CatalogRoleDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE, name); + } + + @Nonnull + @Override + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG_ROLE); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath) { + return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById( + callCtx, entityCatalogId, entityId, CATALOG_ROLE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, CATALOG_ROLE, entityName); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG_ROLE, entityCatalogId, entityId); + } + + @Nonnull + @Override + public EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java new file mode 100644 index 0000000000..6366016885 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java @@ -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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntityType.NULL_TYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.ROOT; + +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.CommonDao; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresCommonDaoImpl implements CommonDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Nonnull + @Override + public GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.generateNewEntityId(callCtx); + } + + @Nonnull + @Override + public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.bootstrapPolarisService(callCtx); + } + + @Nonnull + @Override + public BaseResult purge(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.purge(callCtx); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, ROOT, entityName); + } + + @Nonnull + @Override + public ChangeTrackingResult loadEntitiesChangeTracking( + @Nonnull PolarisCallContext callCtx, @Nonnull List entityIds) { + return metaStoreManager.loadEntitiesChangeTracking(callCtx, entityIds); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, ROOT, entityCatalogId, entityId); + } + + @Nonnull + @Override + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NULL_TYPE); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java new file mode 100644 index 0000000000..70c1c2bfc5 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java @@ -0,0 +1,65 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +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.persistence.dao.CredentialVendorDao; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; +import org.apache.polaris.core.storage.PolarisCredentialVendor; +import org.apache.polaris.core.storage.PolarisStorageActions; + +public class PostgresCredentialVendorDaoImpl implements CredentialVendorDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Nonnull + @Override + public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntity( + @Nonnull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + boolean allowListOperation, + @Nonnull Set allowedReadLocations, + @Nonnull Set allowedWriteLocations) { + return metaStoreManager.getSubscopedCredsForEntity( + callCtx, + catalogId, + entityId, + entityType, + allowListOperation, + allowedReadLocations, + allowedWriteLocations); + } + + @Nonnull + @Override + public PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( + @Nonnull PolarisCallContext callCtx, + long catalogId, + long entityId, + PolarisEntityType entityType, + @Nonnull Set actions, + @Nonnull Set locations) { + return metaStoreManager.validateAccessToLocations( + callCtx, catalogId, entityId, entityType, actions, locations); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java new file mode 100644 index 0000000000..7c91285bb7 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java @@ -0,0 +1,91 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; +import java.util.List; +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisGrantManager; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisPrivilege; +import org.apache.polaris.core.persistence.dao.GrantRecordDao; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresGrantRecordDaoImpl implements GrantRecordDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Nonnull + @Override + public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( + @Nonnull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { + return metaStoreManager.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); + } + + @Nonnull + @Override + public PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( + @Nonnull PolarisCallContext callCtx, + @Nullable PolarisEntityCore catalog, + @Nonnull PolarisEntityCore role, + @Nonnull PolarisEntityCore grantee) { + return metaStoreManager.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); + } + + @Nonnull + @Override + public PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { + return metaStoreManager.grantPrivilegeOnSecurableToRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @Nonnull + @Override + public PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore grantee, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore securable, + @Nonnull PolarisPrivilege privilege) { + return metaStoreManager.revokePrivilegeOnSecurableFromRole( + callCtx, grantee, catalogPath, securable, privilege); + } + + @Nonnull + @Override + public PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( + @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId) { + return metaStoreManager.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); + } + + @Nonnull + @Override + public PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( + PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { + return metaStoreManager.loadGrantsToGrantee(callCtx, granteeCatalogId, granteeId); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java new file mode 100644 index 0000000000..e13e59e429 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java @@ -0,0 +1,122 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; + +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.NamespaceDao; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresNamespaceDaoImpl implements NamespaceDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); + } + + @Nonnull + @Override + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NAMESPACE); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath) { + return metaStoreManager.listEntities(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, NAMESPACE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, NAMESPACE, entityName); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, NAMESPACE, entityCatalogId, entityId); + } + + @Nonnull + @Override + public EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java new file mode 100644 index 0000000000..1f3a0d26f0 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java @@ -0,0 +1,106 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL; + +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; +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.PrincipalDao; +import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresPrincipalDaoImpl implements PrincipalDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL, NULL_SUBTYPE, name); + } + + @Nonnull + @Override + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, PRINCIPAL, NULL_SUBTYPE); + } + + @Override + public CreatePrincipalResult createPrincipal( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal) { + return metaStoreManager.createPrincipal(callCtx, principal); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String name) { + return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, PRINCIPAL, name); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long id) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, 0L, id); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java new file mode 100644 index 0000000000..36eee88c42 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java @@ -0,0 +1,107 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL_ROLE; + +import jakarta.annotation.Nonnull; +import jakarta.annotation.Nullable; +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.PrincipalRoleDao; +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; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresPrincipalRoleDaoImpl implements PrincipalRoleDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Nonnull + @Override + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE); + } + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE, name); + } + + @Nonnull + @Override + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL_ROLE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL_ROLE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, 0L, parentId, PRINCIPAL_ROLE, entityName); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long id) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL_ROLE, 0L, id); + } + + @Nonnull + @Override + public EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java new file mode 100644 index 0000000000..b155823ba8 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java @@ -0,0 +1,47 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import jakarta.annotation.Nonnull; +import org.apache.polaris.core.PolarisCallContext; +import org.apache.polaris.core.auth.PolarisSecretsManager; +import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresPrincipalSecretsDaoImpl implements PrincipalSecretsDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Nonnull + @Override + public PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( + @Nonnull PolarisCallContext callCtx, @Nonnull String clientId) { + return metaStoreManager.loadPrincipalSecrets(callCtx, clientId); + } + + @Override + public @Nonnull PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( + @Nonnull PolarisCallContext callCtx, + @Nonnull String clientId, + long principalId, + boolean reset, + @Nonnull String oldSecretHash) { + return metaStoreManager.rotatePrincipalSecrets( + callCtx, clientId, principalId, reset, oldSecretHash); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java new file mode 100644 index 0000000000..59d7bcc303 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java @@ -0,0 +1,147 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; + +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.PolarisEntity; +import org.apache.polaris.core.entity.PolarisEntityCore; +import org.apache.polaris.core.entity.PolarisEntitySubType; +import org.apache.polaris.core.persistence.dao.TableLikeDao; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresTableLikeDaoImpl implements TableLikeDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntitySubType entitySubType, + @Nonnull String name) { + return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); + } + + @Nonnull + @Override + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TABLE_LIKE); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities( + @Nonnull PolarisCallContext callCtx, + @Nonnull List catalogPath, + @Nonnull PolarisEntitySubType entitySubType) { + return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); + } + + @Nonnull + @Override + public EntityResult renameEntity( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToRename, + @Nullable List newCatalogPath, + @Nonnull PolarisEntity renamedEntity) { + return metaStoreManager.renameEntity( + callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityById( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, TABLE_LIKE); + } + + @Nonnull + @Override + public ResolvedEntityResult loadResolvedEntityByName( + @Nonnull PolarisCallContext callCtx, + long entityCatalogId, + long parentId, + @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName( + callCtx, entityCatalogId, parentId, TABLE_LIKE, entityName); + } + + @Nonnull + @Override + public ResolvedEntityResult refreshResolvedEntity( + @Nonnull PolarisCallContext callCtx, + int entityVersion, + int entityGrantRecordsVersion, + long entityCatalogId, + long entityId) { + return metaStoreManager.refreshResolvedEntity( + callCtx, entityVersion, entityGrantRecordsVersion, TABLE_LIKE, entityCatalogId, entityId); + } + + @Nonnull + @Override + public EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nullable List catalogPath, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + } + + @Nonnull + @Override + public EntitiesResult updateEntitiesPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { + return metaStoreManager.updateEntitiesPropertiesIfNotChanged(callCtx, entities); + } +} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java new file mode 100644 index 0000000000..5203a71787 --- /dev/null +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java @@ -0,0 +1,91 @@ +/* + * 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.extension.persistence.impl.eclipselink.postgres; + +import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntityType.TASK; + +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.TaskDao; +import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; +import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; +import org.apache.polaris.core.persistence.dao.entity.EntityResult; +import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; +import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; + +public class PostgresTaskDaoImpl implements TaskDao { + PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + + @Override + public @Nonnull EntityResult readEntityByName( + @Nonnull PolarisCallContext callCtx, @Nonnull String name) { + // Task shouldn't have a catalog path and subtype + return metaStoreManager.readEntityByName(callCtx, null, TASK, ANY_SUBTYPE, name); + } + + @Nonnull + @Override + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { + return metaStoreManager.listEntities(callCtx, null, TASK, ANY_SUBTYPE); + } + + @Nonnull + @Override + public EntitiesResult loadTasks( + @Nonnull PolarisCallContext callCtx, String executorId, int limit) { + return metaStoreManager.loadTasks(callCtx, executorId, limit); + } + + @Nonnull + @Override + public EntityResult createEntityIfNotExists( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); + } + + @Nonnull + @Override + public EntitiesResult createTasksIfNotExist( + @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { + return metaStoreManager.createEntitiesIfNotExist(callCtx, null, entities); + } + + @Nonnull + @Override + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return metaStoreManager.dropEntityIfExists( + callCtx, null, entityToDrop, cleanupProperties, cleanup); + } + + @Nonnull + @Override + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId) { + return metaStoreManager.loadEntity(callCtx, 0L, entityId, TASK); + } +} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java deleted file mode 100644 index 917828cbd1..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbCatalogDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.mongodb; - -public class MongoDbCatalogDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java deleted file mode 100644 index 91b2abe876..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbNamespaceDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.mongodb; - -public class MongoDbNamespaceDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java deleted file mode 100644 index 13abcba85e..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/mongodb/MongoDbTableLikeDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.mongodb; - -public class MongoDbTableLikeDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java deleted file mode 100644 index fccf8b86e1..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresCatalogDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.postgres; - -public class PostgresCatalogDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java deleted file mode 100644 index 85469b5e6e..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresNamespaceDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.postgres; - -public class PostgresNamespaceDaoImpl {} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java deleted file mode 100644 index a2e5bae813..0000000000 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/postgres/PostgresTableLikeDaoImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.postgres; - -public class PostgresTableLikeDaoImpl {} From 25a37f6eb449a4d26fb461aa7dfcacf2ae6b5a29 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 15:19:34 -0700 Subject: [PATCH 13/15] Refactor --- .../postgres/PostgresCatalogDaoImpl.java | 15 +++++---------- .../core/persistence/dao/CatalogDao.java | 9 ++------- .../core/persistence/dao/PolarisDaoManager.java | 6 +++--- .../transactional/FdbCatalogDaoImpl.java | 17 ++++++----------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java index a5f466ec56..5387d16a7d 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java @@ -88,19 +88,15 @@ public DropEntityResult dropEntityIfExists( @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, CATALOG); + @Nonnull PolarisCallContext callCtx, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, entityId, CATALOG); } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, CATALOG, entityName); + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, CATALOG, entityName); } @Nonnull @@ -109,9 +105,8 @@ public ResolvedEntityResult refreshResolvedEntity( @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, long entityId) { return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, 0L, entityId); } } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java index a4c0295880..72ce34fd45 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -59,21 +59,16 @@ DropEntityResult dropEntityIfExists( ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); @Nonnull - ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long entityId); @Nonnull ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName); + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName); @Nonnull ResolvedEntityResult refreshResolvedEntity( @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, long entityId); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index 35e49491fd..a1e436b4db 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -327,7 +327,7 @@ public ResolvedEntityResult loadResolvedEntityById( PolarisEntityType entityType) { switch (entityType) { case CATALOG: - return catalogDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); + return catalogDao.loadResolvedEntityById(callCtx, entityId); case NAMESPACE: return namespaceDao.loadResolvedEntityById(callCtx, entityCatalogId, entityId); case TABLE_LIKE: @@ -365,7 +365,7 @@ public ResolvedEntityResult loadResolvedEntityByName( case ROOT: return commonDao.loadResolvedEntityByName(callCtx, entityCatalogId, parentId, entityName); case CATALOG: - return catalogDao.loadResolvedEntityByName(callCtx, entityCatalogId, parentId, entityName); + return catalogDao.loadResolvedEntityByName(callCtx, parentId, entityName); case CATALOG_ROLE: return catalogRoleDao.loadResolvedEntityByName( callCtx, entityCatalogId, parentId, entityName); @@ -386,7 +386,7 @@ public ResolvedEntityResult refreshResolvedEntity( switch (entityType) { case CATALOG: return catalogDao.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, entityId); case NAMESPACE: return namespaceDao.refreshResolvedEntity( callCtx, entityVersion, entityGrantRecordsVersion, entityCatalogId, entityId); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java index e425f78f28..66de14fb94 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java @@ -57,7 +57,7 @@ public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnu @Override public EntityResult loadEntity( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG); + return metaStoreManager.loadEntity(callCtx, 0L, entityId, CATALOG); } @Nonnull @@ -87,19 +87,15 @@ public DropEntityResult dropEntityIfExists( @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, CATALOG); + @Nonnull PolarisCallContext callCtx, long entityId) { + return metaStoreManager.loadResolvedEntityById(callCtx, 0L, entityId, CATALOG); } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, CATALOG, entityName); + @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { + return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, CATALOG, entityName); } @Nonnull @@ -108,9 +104,8 @@ public ResolvedEntityResult refreshResolvedEntity( @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long entityCatalogId, long entityId) { return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, entityCatalogId, entityId); + callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, 0L, entityId); } } From 2438108b1db9b1d688d3cd130b6b40677191deac Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Sun, 9 Mar 2025 22:48:50 -0700 Subject: [PATCH 14/15] Refactor --- .../PostgresCatalogDaoImpl.java | 50 ++++++++----------- .../PostgresCatalogRoleDaoImpl.java | 32 +++++------- .../PostgresCommonDaoImpl.java | 24 +++------ .../PostgresCredentialVendorDaoImpl.java | 16 ++---- .../PostgresGrantRecordDaoImpl.java | 19 +++---- .../PostgresNamespaceDaoImpl.java | 32 +++++------- .../PostgresPrincipalDaoImpl.java | 32 +++++------- .../PostgresPrincipalRoleDaoImpl.java | 34 +++++-------- .../PostgresPrincipalSecretsDaoImpl.java | 12 ++--- .../PostgresTableLikeDaoImpl.java | 36 ++++++------- .../PostgresTaskDaoImpl.java | 38 ++++++-------- 11 files changed, 122 insertions(+), 203 deletions(-) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresCatalogDaoImpl.java (70%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresCatalogRoleDaoImpl.java (69%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresCommonDaoImpl.java (72%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresCredentialVendorDaoImpl.java (76%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresGrantRecordDaoImpl.java (76%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresNamespaceDaoImpl.java (70%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresPrincipalDaoImpl.java (68%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresPrincipalRoleDaoImpl.java (66%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresPrincipalSecretsDaoImpl.java (73%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresTableLikeDaoImpl.java (73%) rename extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/{eclipselink/postgres => jdbc}/PostgresTaskDaoImpl.java (67%) diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java similarity index 70% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java index 5387d16a7d..9cddc931d5 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -34,69 +31,65 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresCatalogDaoImpl implements CatalogDao { - // TODO it uses PolarisMetaStoreManagerImpl now, we can change it later - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override public CreateCatalogResult createCatalog( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity catalog, @Nonnull List principalRoles) { - return metaStoreManager.createCatalog(callCtx, catalog, principalRoles); + return null; } @Nonnull @Override - public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, null, CATALOG, ANY_SUBTYPE, name); + public EntityResult updateEntityPropertiesIfNotChanged( + @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { + return null; } @Nonnull @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG); + public DropEntityResult dropEntityIfExists( + @Nonnull PolarisCallContext callCtx, + @Nonnull PolarisEntityCore entityToDrop, + @Nullable Map cleanupProperties, + boolean cleanup) { + return null; } @Nonnull @Override - public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.listEntities(callCtx, null, CATALOG, ANY_SUBTYPE); + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return null; } @Nonnull @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + public EntityResult loadEntity( + @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + return null; } @Nonnull @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, null, entityToDrop, cleanupProperties, cleanup); + public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( @Nonnull PolarisCallContext callCtx, long entityId) { - return metaStoreManager.loadResolvedEntityById(callCtx, 0L, entityId, CATALOG); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, CATALOG, entityName); + return null; } @Nonnull @@ -106,7 +99,6 @@ public ResolvedEntityResult refreshResolvedEntity( int entityVersion, int entityGrantRecordsVersion, long entityId) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, CATALOG, 0L, entityId); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java similarity index 69% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java index 5371c26a8f..be95dd6a2b 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCatalogRoleDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG_ROLE; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -33,39 +30,37 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresCatalogRoleDaoImpl implements CatalogRoleDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( + public EntityResult readEntityByName( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE, name); + return null; } @Nonnull @Override public EntityResult loadEntity( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, CATALOG_ROLE); + return null; } @Nonnull @Override public ListEntitiesResult listEntities( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath) { - return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById( - callCtx, entityCatalogId, entityId, CATALOG_ROLE); + return null; } @Nonnull @@ -75,8 +70,7 @@ public ResolvedEntityResult loadResolvedEntityByName( long entityCatalogId, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, CATALOG_ROLE, entityName); + return null; } @Nonnull @@ -87,8 +81,7 @@ public ResolvedEntityResult refreshResolvedEntity( int entityGrantRecordsVersion, long entityCatalogId, long entityId) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, CATALOG_ROLE, entityCatalogId, entityId); + return null; } @Nonnull @@ -97,7 +90,7 @@ public EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -106,7 +99,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -117,7 +110,6 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java similarity index 72% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java index 6366016885..aeb2a7dc6c 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCommonDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntityType.NULL_TYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.ROOT; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import java.util.List; @@ -31,27 +28,24 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresCommonDaoImpl implements CommonDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @Nonnull @Override public GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.generateNewEntityId(callCtx); + return null; } @Nonnull @Override public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.bootstrapPolarisService(callCtx); + return null; } @Nonnull @Override public BaseResult purge(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.purge(callCtx); + return null; } @Nonnull @@ -61,15 +55,14 @@ public ResolvedEntityResult loadResolvedEntityByName( long entityCatalogId, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, ROOT, entityName); + return null; } @Nonnull @Override public ChangeTrackingResult loadEntitiesChangeTracking( @Nonnull PolarisCallContext callCtx, @Nonnull List entityIds) { - return metaStoreManager.loadEntitiesChangeTracking(callCtx, entityIds); + return null; } @Nonnull @@ -80,14 +73,13 @@ public ResolvedEntityResult refreshResolvedEntity( int entityGrantRecordsVersion, long entityCatalogId, long entityId) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, ROOT, entityCatalogId, entityId); + return null; } @Nonnull @Override public EntityResult loadEntity( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NULL_TYPE); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java similarity index 76% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java index 70c1c2bfc5..b57e470a00 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresCredentialVendorDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java @@ -16,19 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; +package org.apache.polaris.extension.persistence.impl.jdbc; 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.persistence.dao.CredentialVendorDao; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; import org.apache.polaris.core.storage.PolarisCredentialVendor; import org.apache.polaris.core.storage.PolarisStorageActions; public class PostgresCredentialVendorDaoImpl implements CredentialVendorDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull @Override @@ -40,14 +38,7 @@ public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntit boolean allowListOperation, @Nonnull Set allowedReadLocations, @Nonnull Set allowedWriteLocations) { - return metaStoreManager.getSubscopedCredsForEntity( - callCtx, - catalogId, - entityId, - entityType, - allowListOperation, - allowedReadLocations, - allowedWriteLocations); + return null; } @Nonnull @@ -59,7 +50,6 @@ public PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( PolarisEntityType entityType, @Nonnull Set actions, @Nonnull Set locations) { - return metaStoreManager.validateAccessToLocations( - callCtx, catalogId, entityId, entityType, actions, locations); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java similarity index 76% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java index 7c91285bb7..9ca392ae77 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresGrantRecordDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -26,11 +26,8 @@ import org.apache.polaris.core.entity.PolarisEntityCore; import org.apache.polaris.core.entity.PolarisPrivilege; import org.apache.polaris.core.persistence.dao.GrantRecordDao; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresGrantRecordDaoImpl implements GrantRecordDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - @Nonnull @Override public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( @@ -38,7 +35,7 @@ public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( @Nullable PolarisEntityCore catalog, @Nonnull PolarisEntityCore role, @Nonnull PolarisEntityCore grantee) { - return metaStoreManager.grantUsageOnRoleToGrantee(callCtx, catalog, role, grantee); + return null; } @Nonnull @@ -48,7 +45,7 @@ public PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( @Nullable PolarisEntityCore catalog, @Nonnull PolarisEntityCore role, @Nonnull PolarisEntityCore grantee) { - return metaStoreManager.revokeUsageOnRoleFromGrantee(callCtx, catalog, role, grantee); + return null; } @Nonnull @@ -59,8 +56,7 @@ public PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( @Nullable List catalogPath, @Nonnull PolarisEntityCore securable, @Nonnull PolarisPrivilege privilege) { - return metaStoreManager.grantPrivilegeOnSecurableToRole( - callCtx, grantee, catalogPath, securable, privilege); + return null; } @Nonnull @@ -71,21 +67,20 @@ public PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( @Nullable List catalogPath, @Nonnull PolarisEntityCore securable, @Nonnull PolarisPrivilege privilege) { - return metaStoreManager.revokePrivilegeOnSecurableFromRole( - callCtx, grantee, catalogPath, securable, privilege); + return null; } @Nonnull @Override public PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId) { - return metaStoreManager.loadGrantsOnSecurable(callCtx, securableCatalogId, securableId); + return null; } @Nonnull @Override public PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { - return metaStoreManager.loadGrantsToGrantee(callCtx, granteeCatalogId, granteeId); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java similarity index 70% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java index e13e59e429..ab18dc0abc 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresNamespaceDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.NAMESPACE; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -33,38 +30,36 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresNamespaceDaoImpl implements NamespaceDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( + public EntityResult readEntityByName( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE, name); + return null; } @Nonnull @Override public EntityResult loadEntity( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, NAMESPACE); + return null; } @Nonnull @Override public ListEntitiesResult listEntities( @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath) { - return metaStoreManager.listEntities(callCtx, catalogPath, NAMESPACE, ANY_SUBTYPE); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, NAMESPACE); + return null; } @Nonnull @@ -74,8 +69,7 @@ public ResolvedEntityResult loadResolvedEntityByName( long entityCatalogId, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, NAMESPACE, entityName); + return null; } @Nonnull @@ -86,8 +80,7 @@ public ResolvedEntityResult refreshResolvedEntity( int entityGrantRecordsVersion, long entityCatalogId, long entityId) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, NAMESPACE, entityCatalogId, entityId); + return null; } @Nonnull @@ -96,7 +89,7 @@ public EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -105,7 +98,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -116,7 +109,6 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java similarity index 68% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java index 1f3a0d26f0..8cd4a97532 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -33,46 +30,43 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresPrincipalDaoImpl implements PrincipalDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL, NULL_SUBTYPE, name); + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return null; } @Nonnull @Override public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { - return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL); + return null; } @Nonnull @Override public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.listEntities(callCtx, null, PRINCIPAL, NULL_SUBTYPE); + return null; } @Override public CreatePrincipalResult createPrincipal( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal) { - return metaStoreManager.createPrincipal(callCtx, principal); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { - return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String name) { - return metaStoreManager.loadResolvedEntityByName(callCtx, 0L, parentId, PRINCIPAL, name); + return null; } @Nonnull @@ -82,15 +76,14 @@ public ResolvedEntityResult refreshResolvedEntity( int entityVersion, int entityGrantRecordsVersion, long id) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL, 0L, id); + return null; } @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + return null; } @Nonnull @@ -100,7 +93,6 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, null, entityToDrop, cleanupProperties, cleanup); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java similarity index 66% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java index 36eee88c42..951a401f27 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalRoleDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.PRINCIPAL_ROLE; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -32,41 +29,38 @@ 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; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresPrincipalRoleDaoImpl implements PrincipalRoleDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull @Override public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.listEntities(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE); + return null; } + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, null, PRINCIPAL_ROLE, NULL_SUBTYPE, name); + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return null; } @Nonnull @Override public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { - return metaStoreManager.loadEntity(callCtx, 0L, id, PRINCIPAL_ROLE); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { - return metaStoreManager.loadResolvedEntityById(callCtx, 0L, id, PRINCIPAL_ROLE); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityByName( @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, 0L, parentId, PRINCIPAL_ROLE, entityName); + return null; } @Nonnull @@ -75,23 +69,22 @@ public ResolvedEntityResult refreshResolvedEntity( @Nonnull PolarisCallContext callCtx, int entityVersion, int entityGrantRecordsVersion, - long id) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, PRINCIPAL_ROLE, 0L, id); + long entityId) { + return null; } @Nonnull @Override public EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); + return null; } @Nonnull @Override public EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, null, entity); + return null; } @Nonnull @@ -101,7 +94,6 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, null, entityToDrop, cleanupProperties, cleanup); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java similarity index 73% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java index b155823ba8..5782f42141 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresPrincipalSecretsDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java @@ -16,32 +16,30 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import org.apache.polaris.core.PolarisCallContext; import org.apache.polaris.core.auth.PolarisSecretsManager; import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresPrincipalSecretsDaoImpl implements PrincipalSecretsDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull @Override public PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( @Nonnull PolarisCallContext callCtx, @Nonnull String clientId) { - return metaStoreManager.loadPrincipalSecrets(callCtx, clientId); + return null; } + @Nonnull @Override - public @Nonnull PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( + public PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( @Nonnull PolarisCallContext callCtx, @Nonnull String clientId, long principalId, boolean reset, @Nonnull String oldSecretHash) { - return metaStoreManager.rotatePrincipalSecrets( - callCtx, clientId, principalId, reset, oldSecretHash); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java similarity index 73% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java index 59d7bcc303..c48710bac4 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTableLikeDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java @@ -16,9 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntityType.TABLE_LIKE; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -36,25 +34,23 @@ import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresTableLikeDaoImpl implements TableLikeDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( + public EntityResult readEntityByName( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisEntitySubType entitySubType, @Nonnull String name) { - return metaStoreManager.readEntityByName(callCtx, catalogPath, TABLE_LIKE, entitySubType, name); + return null; } @Nonnull @Override public EntityResult loadEntity( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadEntity(callCtx, entityCatalogId, entityId, TABLE_LIKE); + return null; } @Nonnull @@ -63,7 +59,7 @@ public ListEntitiesResult listEntities( @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath, @Nonnull PolarisEntitySubType entitySubType) { - return metaStoreManager.listEntities(callCtx, catalogPath, TABLE_LIKE, entitySubType); + return null; } @Nonnull @@ -74,15 +70,14 @@ public EntityResult renameEntity( @Nonnull PolarisEntityCore entityToRename, @Nullable List newCatalogPath, @Nonnull PolarisEntity renamedEntity) { - return metaStoreManager.renameEntity( - callCtx, catalogPath, entityToRename, newCatalogPath, renamedEntity); + return null; } @Nonnull @Override public ResolvedEntityResult loadResolvedEntityById( @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return metaStoreManager.loadResolvedEntityById(callCtx, entityCatalogId, entityId, TABLE_LIKE); + return null; } @Nonnull @@ -92,8 +87,7 @@ public ResolvedEntityResult loadResolvedEntityByName( long entityCatalogId, long parentId, @Nonnull String entityName) { - return metaStoreManager.loadResolvedEntityByName( - callCtx, entityCatalogId, parentId, TABLE_LIKE, entityName); + return null; } @Nonnull @@ -104,8 +98,7 @@ public ResolvedEntityResult refreshResolvedEntity( int entityGrantRecordsVersion, long entityCatalogId, long entityId) { - return metaStoreManager.refreshResolvedEntity( - callCtx, entityVersion, entityGrantRecordsVersion, TABLE_LIKE, entityCatalogId, entityId); + return null; } @Nonnull @@ -114,7 +107,7 @@ public EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -123,7 +116,7 @@ public EntityResult updateEntityPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.updateEntityPropertiesIfNotChanged(callCtx, catalogPath, entity); + return null; } @Nonnull @@ -134,14 +127,13 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, catalogPath, entityToDrop, cleanupProperties, cleanup); + return null; } @Nonnull @Override public EntitiesResult updateEntitiesPropertiesIfNotChanged( @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { - return metaStoreManager.updateEntitiesPropertiesIfNotChanged(callCtx, entities); + return null; } } diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java similarity index 67% rename from extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java rename to extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java index 5203a71787..1c84fa902e 100644 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/eclipselink/postgres/PostgresTaskDaoImpl.java +++ b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java @@ -16,10 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.polaris.extension.persistence.impl.eclipselink.postgres; - -import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; -import static org.apache.polaris.core.entity.PolarisEntityType.TASK; +package org.apache.polaris.extension.persistence.impl.jdbc; import jakarta.annotation.Nonnull; import jakarta.annotation.Nullable; @@ -33,43 +30,45 @@ import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.apache.polaris.core.persistence.transactional.PolarisMetaStoreManagerImpl; public class PostgresTaskDaoImpl implements TaskDao { - PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); - + @Nonnull @Override - public @Nonnull EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, @Nonnull String name) { - // Task shouldn't have a catalog path and subtype - return metaStoreManager.readEntityByName(callCtx, null, TASK, ANY_SUBTYPE, name); + public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { + return null; } @Nonnull @Override public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return metaStoreManager.listEntities(callCtx, null, TASK, ANY_SUBTYPE); + return null; } @Nonnull @Override public EntitiesResult loadTasks( @Nonnull PolarisCallContext callCtx, String executorId, int limit) { - return metaStoreManager.loadTasks(callCtx, executorId, limit); + return null; + } + + @Nonnull + @Override + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { + return null; } @Nonnull @Override public EntityResult createEntityIfNotExists( @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return metaStoreManager.createEntityIfNotExists(callCtx, null, entity); + return null; } @Nonnull @Override public EntitiesResult createTasksIfNotExist( @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { - return metaStoreManager.createEntitiesIfNotExist(callCtx, null, entities); + return null; } @Nonnull @@ -79,13 +78,6 @@ public DropEntityResult dropEntityIfExists( @Nonnull PolarisEntityCore entityToDrop, @Nullable Map cleanupProperties, boolean cleanup) { - return metaStoreManager.dropEntityIfExists( - callCtx, null, entityToDrop, cleanupProperties, cleanup); - } - - @Nonnull - @Override - public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId) { - return metaStoreManager.loadEntity(callCtx, 0L, entityId, TASK); + return null; } } From 900dd8eb1992c2a5c1200fc3e40977d102642400 Mon Sep 17 00:00:00 2001 From: Yufei Gu Date: Mon, 10 Mar 2025 21:34:59 -0700 Subject: [PATCH 15/15] Resolve comments --- .../impl/jdbc/PostgresCatalogDaoImpl.java | 104 ------ .../impl/jdbc/PostgresCatalogRoleDaoImpl.java | 115 ------- .../impl/jdbc/PostgresCommonDaoImpl.java | 85 ----- .../jdbc/PostgresCredentialVendorDaoImpl.java | 55 ---- .../impl/jdbc/PostgresGrantRecordDaoImpl.java | 86 ----- .../impl/jdbc/PostgresNamespaceDaoImpl.java | 114 ------- .../impl/jdbc/PostgresPrincipalDaoImpl.java | 98 ------ .../jdbc/PostgresPrincipalRoleDaoImpl.java | 99 ------ .../jdbc/PostgresPrincipalSecretsDaoImpl.java | 45 --- .../impl/jdbc/PostgresTableLikeDaoImpl.java | 139 --------- .../impl/jdbc/PostgresTaskDaoImpl.java | 83 ----- .../core/persistence/dao/CatalogDao.java | 2 +- .../persistence/dao/PolarisDaoManager.java | 91 ++++-- ...mpl.java => DelegatingCatalogDaoImpl.java} | 5 +- ...java => DelegatingCatalogRoleDaoImpl.java} | 5 +- ...Impl.java => DelegatingCommonDaoImpl.java} | 2 +- ...=> DelegatingCredentialVendorDaoImpl.java} | 2 +- ...java => DelegatingGrantRecordDaoImpl.java} | 2 +- ...l.java => DelegatingNamespaceDaoImpl.java} | 2 +- ...l.java => DelegatingPrincipalDaoImpl.java} | 2 +- ...va => DelegatingPrincipalRoleDaoImpl.java} | 2 +- ...=> DelegatingPrincipalSecretsDaoImpl.java} | 2 +- ...l.java => DelegatingTableLikeDaoImpl.java} | 2 +- ...aoImpl.java => DelegatingTaskDaoImpl.java} | 2 +- .../service/admin/PolarisAdminService.java | 295 ++++++++++-------- 25 files changed, 256 insertions(+), 1183 deletions(-) delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java delete mode 100644 extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbCatalogDaoImpl.java => DelegatingCatalogDaoImpl.java} (96%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbCatalogRoleDaoImpl.java => DelegatingCatalogRoleDaoImpl.java} (96%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbCommonDaoImpl.java => DelegatingCommonDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbCredentialVendorDaoImpl.java => DelegatingCredentialVendorDaoImpl.java} (96%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbGrantRecordDaoImpl.java => DelegatingGrantRecordDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbNamespaceDaoImpl.java => DelegatingNamespaceDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbPrincipalDaoImpl.java => DelegatingPrincipalDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbPrincipalRoleDaoImpl.java => DelegatingPrincipalRoleDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbPrincipalSecretsDaoImpl.java => DelegatingPrincipalSecretsDaoImpl.java} (95%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbTableLikeDaoImpl.java => DelegatingTableLikeDaoImpl.java} (98%) rename polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/{FdbTaskDaoImpl.java => DelegatingTaskDaoImpl.java} (98%) diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java deleted file mode 100644 index 9cddc931d5..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogDaoImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.CatalogDao; -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 class PostgresCatalogDaoImpl implements CatalogDao { - - @Override - public CreateCatalogResult createCatalog( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisBaseEntity catalog, - @Nonnull List principalRoles) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } - - @Nonnull - @Override - public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityId) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityId) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java deleted file mode 100644 index be95dd6a2b..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCatalogRoleDaoImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.CatalogRoleDao; -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 class PostgresCatalogRoleDaoImpl implements CatalogRoleDao { - - @Nonnull - @Override - public EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities( - @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { - return null; - } - - @Nonnull - @Override - public EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java deleted file mode 100644 index aeb2a7dc6c..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCommonDaoImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.CommonDao; -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 class PostgresCommonDaoImpl implements CommonDao { - @Nonnull - @Override - public GenerateEntityIdResult generateNewEntityId(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public BaseResult purge(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ChangeTrackingResult loadEntitiesChangeTracking( - @Nonnull PolarisCallContext callCtx, @Nonnull List entityIds) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java deleted file mode 100644 index b57e470a00..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresCredentialVendorDaoImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.persistence.dao.CredentialVendorDao; -import org.apache.polaris.core.storage.PolarisCredentialVendor; -import org.apache.polaris.core.storage.PolarisStorageActions; - -public class PostgresCredentialVendorDaoImpl implements CredentialVendorDao { - - @Nonnull - @Override - public PolarisCredentialVendor.ScopedCredentialsResult getSubscopedCredsForEntity( - @Nonnull PolarisCallContext callCtx, - long catalogId, - long entityId, - PolarisEntityType entityType, - boolean allowListOperation, - @Nonnull Set allowedReadLocations, - @Nonnull Set allowedWriteLocations) { - return null; - } - - @Nonnull - @Override - public PolarisCredentialVendor.ValidateAccessResult validateAccessToLocations( - @Nonnull PolarisCallContext callCtx, - long catalogId, - long entityId, - PolarisEntityType entityType, - @Nonnull Set actions, - @Nonnull Set locations) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java deleted file mode 100644 index 9ca392ae77..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresGrantRecordDaoImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; -import java.util.List; -import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.auth.PolarisGrantManager; -import org.apache.polaris.core.entity.PolarisEntityCore; -import org.apache.polaris.core.entity.PolarisPrivilege; -import org.apache.polaris.core.persistence.dao.GrantRecordDao; - -public class PostgresGrantRecordDaoImpl implements GrantRecordDao { - @Nonnull - @Override - public PolarisGrantManager.PrivilegeResult grantUsageOnRoleToGrantee( - @Nonnull PolarisCallContext callCtx, - @Nullable PolarisEntityCore catalog, - @Nonnull PolarisEntityCore role, - @Nonnull PolarisEntityCore grantee) { - return null; - } - - @Nonnull - @Override - public PolarisGrantManager.PrivilegeResult revokeUsageOnRoleFromGrantee( - @Nonnull PolarisCallContext callCtx, - @Nullable PolarisEntityCore catalog, - @Nonnull PolarisEntityCore role, - @Nonnull PolarisEntityCore grantee) { - return null; - } - - @Nonnull - @Override - public PolarisGrantManager.PrivilegeResult grantPrivilegeOnSecurableToRole( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore grantee, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore securable, - @Nonnull PolarisPrivilege privilege) { - return null; - } - - @Nonnull - @Override - public PolarisGrantManager.PrivilegeResult revokePrivilegeOnSecurableFromRole( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore grantee, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore securable, - @Nonnull PolarisPrivilege privilege) { - return null; - } - - @Nonnull - @Override - public PolarisGrantManager.LoadGrantsResult loadGrantsOnSecurable( - @Nonnull PolarisCallContext callCtx, long securableCatalogId, long securableId) { - return null; - } - - @Nonnull - @Override - public PolarisGrantManager.LoadGrantsResult loadGrantsToGrantee( - PolarisCallContext callCtx, long granteeCatalogId, long granteeId) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java deleted file mode 100644 index ab18dc0abc..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresNamespaceDaoImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.NamespaceDao; -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 class PostgresNamespaceDaoImpl implements NamespaceDao { - @Nonnull - @Override - public EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities( - @Nonnull PolarisCallContext callCtx, @Nonnull List catalogPath) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { - return null; - } - - @Nonnull - @Override - public EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java deleted file mode 100644 index 8cd4a97532..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalDaoImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; -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.PrincipalDao; -import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult; -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 class PostgresPrincipalDaoImpl implements PrincipalDao { - @Nonnull - @Override - public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Override - public CreatePrincipalResult createPrincipal( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity principal) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long id) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java deleted file mode 100644 index 951a401f27..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalRoleDaoImpl.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; -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.PrincipalRoleDao; -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 class PostgresPrincipalRoleDaoImpl implements PrincipalRoleDao { - - @Nonnull - @Override - public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById(@Nonnull PolarisCallContext callCtx, long id) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, long parentId, @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityId) { - return null; - } - - @Nonnull - @Override - public EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java deleted file mode 100644 index 5782f42141..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresPrincipalSecretsDaoImpl.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -import jakarta.annotation.Nonnull; -import org.apache.polaris.core.PolarisCallContext; -import org.apache.polaris.core.auth.PolarisSecretsManager; -import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; - -public class PostgresPrincipalSecretsDaoImpl implements PrincipalSecretsDao { - - @Nonnull - @Override - public PolarisSecretsManager.PrincipalSecretsResult loadPrincipalSecrets( - @Nonnull PolarisCallContext callCtx, @Nonnull String clientId) { - return null; - } - - @Nonnull - @Override - public PolarisSecretsManager.PrincipalSecretsResult rotatePrincipalSecrets( - @Nonnull PolarisCallContext callCtx, - @Nonnull String clientId, - long principalId, - boolean reset, - @Nonnull String oldSecretHash) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java deleted file mode 100644 index c48710bac4..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTableLikeDaoImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.PolarisEntity; -import org.apache.polaris.core.entity.PolarisEntityCore; -import org.apache.polaris.core.entity.PolarisEntitySubType; -import org.apache.polaris.core.persistence.dao.TableLikeDao; -import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; -import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.EntityWithPath; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; - -public class PostgresTableLikeDaoImpl implements TableLikeDao { - @Nonnull - @Override - public EntityResult readEntityByName( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisEntitySubType entitySubType, - @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities( - @Nonnull PolarisCallContext callCtx, - @Nonnull List catalogPath, - @Nonnull PolarisEntitySubType entitySubType) { - return null; - } - - @Nonnull - @Override - public EntityResult renameEntity( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore entityToRename, - @Nullable List newCatalogPath, - @Nonnull PolarisEntity renamedEntity) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityById( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult loadResolvedEntityByName( - @Nonnull PolarisCallContext callCtx, - long entityCatalogId, - long parentId, - @Nonnull String entityName) { - return null; - } - - @Nonnull - @Override - public ResolvedEntityResult refreshResolvedEntity( - @Nonnull PolarisCallContext callCtx, - int entityVersion, - int entityGrantRecordsVersion, - long entityCatalogId, - long entityId) { - return null; - } - - @Nonnull - @Override - public EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public EntityResult updateEntityPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nullable List catalogPath, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } - - @Nonnull - @Override - public EntitiesResult updateEntitiesPropertiesIfNotChanged( - @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { - return null; - } -} diff --git a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java b/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java deleted file mode 100644 index 1c84fa902e..0000000000 --- a/extension/persistence/eclipselink/src/main/java/org/apache/polaris/extension/persistence/impl/jdbc/PostgresTaskDaoImpl.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.extension.persistence.impl.jdbc; - -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.TaskDao; -import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; -import org.apache.polaris.core.persistence.dao.entity.EntitiesResult; -import org.apache.polaris.core.persistence.dao.entity.EntityResult; -import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; - -public class PostgresTaskDaoImpl implements TaskDao { - @Nonnull - @Override - public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name) { - return null; - } - - @Nonnull - @Override - public ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx) { - return null; - } - - @Nonnull - @Override - public EntitiesResult loadTasks( - @Nonnull PolarisCallContext callCtx, String executorId, int limit) { - return null; - } - - @Nonnull - @Override - public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long id) { - return null; - } - - @Nonnull - @Override - public EntityResult createEntityIfNotExists( - @Nonnull PolarisCallContext callCtx, @Nonnull PolarisBaseEntity entity) { - return null; - } - - @Nonnull - @Override - public EntitiesResult createTasksIfNotExist( - @Nonnull PolarisCallContext callCtx, @Nonnull List entities) { - return null; - } - - @Nonnull - @Override - public DropEntityResult dropEntityIfExists( - @Nonnull PolarisCallContext callCtx, - @Nonnull PolarisEntityCore entityToDrop, - @Nullable Map cleanupProperties, - boolean cleanup) { - return null; - } -} diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java index 72ce34fd45..c49c938c65 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/CatalogDao.java @@ -53,7 +53,7 @@ DropEntityResult dropEntityIfExists( EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnull String name); @Nonnull - EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId); + EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId); @Nonnull ListEntitiesResult listEntities(@Nonnull PolarisCallContext callCtx); diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java index a1e436b4db..1101069c41 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/dao/PolarisDaoManager.java @@ -43,17 +43,17 @@ import org.apache.polaris.core.persistence.dao.entity.GenerateEntityIdResult; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -import org.apache.polaris.core.persistence.transactional.FdbCatalogDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbCatalogRoleDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbCommonDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbCredentialVendorDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbGrantRecordDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbNamespaceDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbPrincipalDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbPrincipalRoleDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbPrincipalSecretsDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbTableLikeDaoImpl; -import org.apache.polaris.core.persistence.transactional.FdbTaskDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingCatalogDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingCatalogRoleDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingCommonDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingCredentialVendorDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingGrantRecordDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingNamespaceDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingPrincipalDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingPrincipalRoleDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingPrincipalSecretsDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingTableLikeDaoImpl; +import org.apache.polaris.core.persistence.transactional.DelegatingTaskDaoImpl; import org.apache.polaris.core.storage.PolarisStorageActions; /** @@ -64,18 +64,63 @@ public class PolarisDaoManager implements PolarisMetaStoreManager { // TODO, using factory or CDI to create following instances, so that the implementation can be // injected. - FdbCatalogDaoImpl catalogDao = new FdbCatalogDaoImpl(); - FdbNamespaceDaoImpl namespaceDao = new FdbNamespaceDaoImpl(); - FdbTableLikeDaoImpl tableLikeDao = new FdbTableLikeDaoImpl(); - FdbCatalogRoleDaoImpl catalogRoleDao = new FdbCatalogRoleDaoImpl(); - FdbPrincipalRoleDaoImpl principalRoleDao = new FdbPrincipalRoleDaoImpl(); - FdbPrincipalDaoImpl principalDao = new FdbPrincipalDaoImpl(); - FdbTaskDaoImpl taskDao = new FdbTaskDaoImpl(); - FdbPrincipalSecretsDaoImpl principalSecretsDao = new FdbPrincipalSecretsDaoImpl(); - FdbGrantRecordDaoImpl grantRecordDao = new FdbGrantRecordDaoImpl(); - FdbCommonDaoImpl commonDao = new FdbCommonDaoImpl(); - FdbCredentialVendorDaoImpl credentialVendorDao = new FdbCredentialVendorDaoImpl(); + private final CatalogDao catalogDao = new DelegatingCatalogDaoImpl(); + private final NamespaceDao namespaceDao = new DelegatingNamespaceDaoImpl(); + private final TableLikeDao tableLikeDao = new DelegatingTableLikeDaoImpl(); + private final CatalogRoleDao catalogRoleDao = new DelegatingCatalogRoleDaoImpl(); + private final PrincipalRoleDao principalRoleDao = new DelegatingPrincipalRoleDaoImpl(); + private final PrincipalDao principalDao = new DelegatingPrincipalDaoImpl(); + private final TaskDao taskDao = new DelegatingTaskDaoImpl(); + private final PrincipalSecretsDao principalSecretsDao = new DelegatingPrincipalSecretsDaoImpl(); + private final GrantRecordDao grantRecordDao = new DelegatingGrantRecordDaoImpl(); + private final CommonDao commonDao = new DelegatingCommonDaoImpl(); + private final CredentialVendorDao credentialVendorDao = new DelegatingCredentialVendorDaoImpl(); + public CatalogDao getCatalogDao() { + return catalogDao; + } + + public NamespaceDao getNamespaceDao() { + return namespaceDao; + } + + public TableLikeDao getTableLikeDao() { + return tableLikeDao; + } + + public CatalogRoleDao getCatalogRoleDao() { + return catalogRoleDao; + } + + public PrincipalRoleDao getPrincipalRoleDao() { + return principalRoleDao; + } + + public PrincipalDao getPrincipalDao() { + return principalDao; + } + + public TaskDao getTaskDao() { + return taskDao; + } + + public PrincipalSecretsDao getPrincipalSecretsDao() { + return principalSecretsDao; + } + + public GrantRecordDao getGrantRecordDao() { + return grantRecordDao; + } + + public CommonDao getCommonDao() { + return commonDao; + } + + public CredentialVendorDao getCredentialVendorDao() { + return credentialVendorDao; + } + + // TODO, we can remove all following methods once we finished the business logic refactor. @Nonnull @Override public BaseResult bootstrapPolarisService(@Nonnull PolarisCallContext callCtx) { @@ -283,7 +328,7 @@ public EntityResult loadEntity( @Nonnull PolarisEntityType entityType) { switch (entityType) { case CATALOG: - return catalogDao.loadEntity(callCtx, entityCatalogId, entityId); + return catalogDao.loadEntity(callCtx, entityId); case NAMESPACE: return namespaceDao.loadEntity(callCtx, entityCatalogId, entityId); case TABLE_LIKE: diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogDaoImpl.java similarity index 96% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogDaoImpl.java index 66de14fb94..82d719dcc1 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogDaoImpl.java @@ -35,7 +35,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbCatalogDaoImpl implements CatalogDao { +public class DelegatingCatalogDaoImpl implements CatalogDao { // TODO we need a map to cache the PolarisMetaStoreManagerImpl as well PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @@ -55,8 +55,7 @@ public EntityResult readEntityByName(@Nonnull PolarisCallContext callCtx, @Nonnu @Nonnull @Override - public EntityResult loadEntity( - @Nonnull PolarisCallContext callCtx, long entityCatalogId, long entityId) { + public EntityResult loadEntity(@Nonnull PolarisCallContext callCtx, long entityId) { return metaStoreManager.loadEntity(callCtx, 0L, entityId, CATALOG); } diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogRoleDaoImpl.java similarity index 96% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogRoleDaoImpl.java index ff50ab373f..276c3c4d4a 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCatalogRoleDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCatalogRoleDaoImpl.java @@ -19,6 +19,7 @@ package org.apache.polaris.core.persistence.transactional; import static org.apache.polaris.core.entity.PolarisEntitySubType.ANY_SUBTYPE; +import static org.apache.polaris.core.entity.PolarisEntitySubType.NULL_SUBTYPE; import static org.apache.polaris.core.entity.PolarisEntityType.CATALOG_ROLE; import jakarta.annotation.Nonnull; @@ -34,7 +35,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbCatalogRoleDaoImpl implements CatalogRoleDao { +public class DelegatingCatalogRoleDaoImpl implements CatalogRoleDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override @@ -56,7 +57,7 @@ public EntityResult loadEntity( @Override public ListEntitiesResult listEntities( @Nonnull PolarisCallContext callCtx, @Nullable List catalogPath) { - return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, ANY_SUBTYPE); + return metaStoreManager.listEntities(callCtx, catalogPath, CATALOG_ROLE, NULL_SUBTYPE); } @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCommonDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCommonDaoImpl.java index b301493fa5..fd92a6bbaf 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCommonDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCommonDaoImpl.java @@ -32,7 +32,7 @@ import org.apache.polaris.core.persistence.dao.entity.GenerateEntityIdResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbCommonDaoImpl implements CommonDao { +public class DelegatingCommonDaoImpl implements CommonDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCredentialVendorDaoImpl.java similarity index 96% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCredentialVendorDaoImpl.java index 7b13843e9e..f97c1daec0 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbCredentialVendorDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingCredentialVendorDaoImpl.java @@ -26,7 +26,7 @@ import org.apache.polaris.core.storage.PolarisCredentialVendor; import org.apache.polaris.core.storage.PolarisStorageActions; -public class FdbCredentialVendorDaoImpl implements CredentialVendorDao { +public class DelegatingCredentialVendorDaoImpl implements CredentialVendorDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingGrantRecordDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingGrantRecordDaoImpl.java index 64b948ef3c..5c812d54e2 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbGrantRecordDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingGrantRecordDaoImpl.java @@ -27,7 +27,7 @@ import org.apache.polaris.core.entity.PolarisPrivilege; import org.apache.polaris.core.persistence.dao.GrantRecordDao; -public class FdbGrantRecordDaoImpl implements GrantRecordDao { +public class DelegatingGrantRecordDaoImpl implements GrantRecordDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingNamespaceDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingNamespaceDaoImpl.java index bf767466dc..b627da98fd 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbNamespaceDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingNamespaceDaoImpl.java @@ -34,7 +34,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbNamespaceDaoImpl implements NamespaceDao { +public class DelegatingNamespaceDaoImpl implements NamespaceDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalDaoImpl.java index 66f0f15af9..25269ea47d 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalDaoImpl.java @@ -34,7 +34,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbPrincipalDaoImpl implements PrincipalDao { +public class DelegatingPrincipalDaoImpl implements PrincipalDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalRoleDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalRoleDaoImpl.java index ad789f88ca..b6cb41e493 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalRoleDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalRoleDaoImpl.java @@ -33,7 +33,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbPrincipalRoleDaoImpl implements PrincipalRoleDao { +public class DelegatingPrincipalRoleDaoImpl implements PrincipalRoleDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalSecretsDaoImpl.java similarity index 95% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalSecretsDaoImpl.java index f1a28b5d59..e79016a029 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbPrincipalSecretsDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingPrincipalSecretsDaoImpl.java @@ -23,7 +23,7 @@ import org.apache.polaris.core.auth.PolarisSecretsManager; import org.apache.polaris.core.persistence.dao.PrincipalSecretsDao; -public class FdbPrincipalSecretsDaoImpl implements PrincipalSecretsDao { +public class DelegatingPrincipalSecretsDaoImpl implements PrincipalSecretsDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Nonnull diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTableLikeDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTableLikeDaoImpl.java index da040d5360..138e5ca4ac 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTableLikeDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTableLikeDaoImpl.java @@ -37,7 +37,7 @@ import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; import org.apache.polaris.core.persistence.dao.entity.ResolvedEntityResult; -public class FdbTableLikeDaoImpl implements TableLikeDao { +public class DelegatingTableLikeDaoImpl implements TableLikeDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override diff --git a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTaskDaoImpl.java similarity index 98% rename from polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java rename to polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTaskDaoImpl.java index 99c4ff8ec7..94b29bc1ce 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/FdbTaskDaoImpl.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/persistence/transactional/DelegatingTaskDaoImpl.java @@ -34,7 +34,7 @@ import org.apache.polaris.core.persistence.dao.entity.EntityResult; import org.apache.polaris.core.persistence.dao.entity.ListEntitiesResult; -public class FdbTaskDaoImpl implements TaskDao { +public class DelegatingTaskDaoImpl implements TaskDao { PolarisMetaStoreManagerImpl metaStoreManager = new PolarisMetaStoreManagerImpl(); @Override diff --git a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java index c05a6b2a3d..017d5027a4 100644 --- a/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java +++ b/service/common/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java @@ -84,6 +84,7 @@ import org.apache.polaris.core.persistence.PolarisEntityManager; import org.apache.polaris.core.persistence.PolarisMetaStoreManager; import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper; +import org.apache.polaris.core.persistence.dao.PolarisDaoManager; import org.apache.polaris.core.persistence.dao.entity.CreateCatalogResult; import org.apache.polaris.core.persistence.dao.entity.CreatePrincipalResult; import org.apache.polaris.core.persistence.dao.entity.DropEntityResult; @@ -116,7 +117,7 @@ public class PolarisAdminService { private final SecurityContext securityContext; private final AuthenticatedPolarisPrincipal authenticatedPrincipal; private final PolarisAuthorizer authorizer; - private final PolarisMetaStoreManager metaStoreManager; + private final PolarisDaoManager daoManager; // Initialized in the authorize methods. private PolarisResolutionManifest resolutionManifest = null; @@ -129,7 +130,8 @@ public PolarisAdminService( @NotNull PolarisAuthorizer authorizer) { this.callContext = callContext; this.entityManager = entityManager; - this.metaStoreManager = metaStoreManager; + // TODO remove the casting in a followup PR + this.daoManager = (PolarisDaoManager) metaStoreManager; this.securityContext = securityContext; PolarisDiagnostics diagServices = callContext.getPolarisCallContext().getDiagServices(); diagServices.checkNotNull(securityContext, "null_security_context"); @@ -573,11 +575,14 @@ public PolarisEntity createCatalog(PolarisEntity entity) { PolarisEntity polarisEntity = new PolarisEntity.Builder(entity) - .setId(metaStoreManager.generateNewEntityId(getCurrentPolarisContext()).getId()) + .setId( + daoManager.getCommonDao().generateNewEntityId(getCurrentPolarisContext()).getId()) .setCreateTimestamp(System.currentTimeMillis()) .build(); CreateCatalogResult catalogResult = - metaStoreManager.createCatalog(getCurrentPolarisContext(), polarisEntity, List.of()); + daoManager + .getCatalogDao() + .createCatalog(getCurrentPolarisContext(), polarisEntity, List.of()); if (catalogResult.alreadyExists()) { throw new AlreadyExistsException( "Cannot create Catalog %s. Catalog already exists or resolution failed", @@ -600,8 +605,9 @@ public void deleteCatalog(String name) { .getConfigurationStore() .getConfiguration(polarisCallContext, PolarisConfiguration.CLEANUP_ON_CATALOG_DROP); DropEntityResult dropEntityResult = - metaStoreManager.dropEntityIfExists( - getCurrentPolarisContext(), null, entity, Map.of(), cleanup); + daoManager + .getCatalogDao() + .dropEntityIfExists(getCurrentPolarisContext(), entity, Map.of(), cleanup); // at least some handling of error if (!dropEntityResult.isSuccess()) { @@ -730,8 +736,10 @@ private void validateUpdateCatalogDiffOrThrow( Optional.ofNullable( CatalogEntity.of( PolarisEntity.of( - metaStoreManager.updateEntityPropertiesIfNotChanged( - getCurrentPolarisContext(), null, updatedEntity)))) + daoManager + .getCatalogDao() + .updateEntityPropertiesIfNotChanged( + getCurrentPolarisContext(), updatedEntity)))) .orElseThrow( () -> new CommitFailedException( @@ -751,19 +759,17 @@ public List listCatalogs() { * process before it could be loaded. */ private List listCatalogsUnsafe() { - return metaStoreManager - .listEntities( - getCurrentPolarisContext(), - null, - PolarisEntityType.CATALOG, - PolarisEntitySubType.ANY_SUBTYPE) + return daoManager + .getCatalogDao() + .listEntities(getCurrentPolarisContext()) .getEntities() .stream() .map( nameAndId -> PolarisEntity.of( - metaStoreManager.loadEntity( - getCurrentPolarisContext(), 0, nameAndId.getId(), nameAndId.getType()))) + daoManager + .getCatalogDao() + .loadEntity(getCurrentPolarisContext(), nameAndId.getId()))) .toList(); } @@ -774,12 +780,18 @@ public PrincipalWithCredentials createPrincipal(PolarisEntity entity) { checkArgument(entity.getId() == -1, "Entity to be created must have no ID assigned"); CreatePrincipalResult principalResult = - metaStoreManager.createPrincipal( - getCurrentPolarisContext(), - new PolarisEntity.Builder(entity) - .setId(metaStoreManager.generateNewEntityId(getCurrentPolarisContext()).getId()) - .setCreateTimestamp(System.currentTimeMillis()) - .build()); + daoManager + .getPrincipalDao() + .createPrincipal( + getCurrentPolarisContext(), + new PolarisEntity.Builder(entity) + .setId( + daoManager + .getCommonDao() + .generateNewEntityId(getCurrentPolarisContext()) + .getId()) + .setCreateTimestamp(System.currentTimeMillis()) + .build()); if (principalResult.alreadyExists()) { throw new AlreadyExistsException( "Cannot create Principal %s. Principal already exists or resolution failed", @@ -801,8 +813,9 @@ public void deletePrincipal(String name) { .orElseThrow(() -> new NotFoundException("Principal %s not found", name)); // TODO: Handle return value in case of concurrent modification DropEntityResult dropEntityResult = - metaStoreManager.dropEntityIfExists( - getCurrentPolarisContext(), null, entity, Map.of(), false); + daoManager + .getPrincipalDao() + .dropEntityIfExists(getCurrentPolarisContext(), entity, Map.of(), false); // at least some handling of error if (!dropEntityResult.isSuccess()) { @@ -848,8 +861,10 @@ public void deletePrincipal(String name) { Optional.ofNullable( PrincipalEntity.of( PolarisEntity.of( - metaStoreManager.updateEntityPropertiesIfNotChanged( - getCurrentPolarisContext(), null, updatedEntity)))) + daoManager + .getPrincipalDao() + .updateEntityPropertiesIfNotChanged( + getCurrentPolarisContext(), updatedEntity)))) .orElseThrow( () -> new CommitFailedException( @@ -864,7 +879,8 @@ public void deletePrincipal(String name) { .orElseThrow(() -> new NotFoundException("Principal %s not found", principalName)); PolarisPrincipalSecrets currentSecrets = - metaStoreManager + daoManager + .getPrincipalSecretsDao() .loadPrincipalSecrets(getCurrentPolarisContext(), currentPrincipalEntity.getClientId()) .getPrincipalSecrets(); if (currentSecrets == null) { @@ -872,7 +888,8 @@ public void deletePrincipal(String name) { String.format("Failed to load current secrets for principal '%s'", principalName)); } PolarisPrincipalSecrets newSecrets = - metaStoreManager + daoManager + .getPrincipalSecretsDao() .rotatePrincipalSecrets( getCurrentPolarisContext(), currentPrincipalEntity.getClientId(), @@ -888,11 +905,9 @@ public void deletePrincipal(String name) { } PolarisEntity newPrincipal = PolarisEntity.of( - metaStoreManager.loadEntity( - getCurrentPolarisContext(), - 0L, - currentPrincipalEntity.getId(), - currentPrincipalEntity.getType())); + daoManager + .getPrincipalDao() + .loadEntity(getCurrentPolarisContext(), currentPrincipalEntity.getId())); return new PrincipalWithCredentials( PrincipalEntity.of(newPrincipal).asPrincipal(), new PrincipalWithCredentialsCredentials( @@ -917,19 +932,17 @@ public List listPrincipals() { PolarisAuthorizableOperation op = PolarisAuthorizableOperation.LIST_PRINCIPALS; authorizeBasicRootOperationOrThrow(op); - return metaStoreManager - .listEntities( - getCurrentPolarisContext(), - null, - PolarisEntityType.PRINCIPAL, - PolarisEntitySubType.NULL_SUBTYPE) + return daoManager + .getPrincipalDao() + .listEntities(getCurrentPolarisContext()) .getEntities() .stream() .map( nameAndId -> PolarisEntity.of( - metaStoreManager.loadEntity( - getCurrentPolarisContext(), 0, nameAndId.getId(), nameAndId.getType()))) + daoManager + .getPrincipalDao() + .loadEntity(getCurrentPolarisContext(), nameAndId.getId()))) .toList(); } @@ -941,13 +954,18 @@ public PolarisEntity createPrincipalRole(PolarisEntity entity) { PolarisEntity returnedEntity = PolarisEntity.of( - metaStoreManager.createEntityIfNotExists( - getCurrentPolarisContext(), - null, - new PolarisEntity.Builder(entity) - .setId(metaStoreManager.generateNewEntityId(getCurrentPolarisContext()).getId()) - .setCreateTimestamp(System.currentTimeMillis()) - .build())); + daoManager + .getPrincipalRoleDao() + .createEntityIfNotExists( + getCurrentPolarisContext(), + new PolarisEntity.Builder(entity) + .setId( + daoManager + .getCommonDao() + .generateNewEntityId(getCurrentPolarisContext()) + .getId()) + .setCreateTimestamp(System.currentTimeMillis()) + .build())); if (returnedEntity == null) { throw new AlreadyExistsException( "Cannot create PrincipalRole %s. PrincipalRole already exists or resolution failed", @@ -965,8 +983,10 @@ public void deletePrincipalRole(String name) { .orElseThrow(() -> new NotFoundException("PrincipalRole %s not found", name)); // TODO: Handle return value in case of concurrent modification DropEntityResult dropEntityResult = - metaStoreManager.dropEntityIfExists( - getCurrentPolarisContext(), null, entity, Map.of(), true); // cleanup grants + daoManager + .getPrincipalRoleDao() + .dropEntityIfExists( + getCurrentPolarisContext(), entity, Map.of(), true); // cleanup grants // at least some handling of error if (!dropEntityResult.isSuccess()) { @@ -1013,8 +1033,10 @@ public void deletePrincipalRole(String name) { Optional.ofNullable( PrincipalRoleEntity.of( PolarisEntity.of( - metaStoreManager.updateEntityPropertiesIfNotChanged( - getCurrentPolarisContext(), null, updatedEntity)))) + daoManager + .getPrincipalRoleDao() + .updateEntityPropertiesIfNotChanged( + getCurrentPolarisContext(), updatedEntity)))) .orElseThrow( () -> new CommitFailedException( @@ -1026,19 +1048,17 @@ public List listPrincipalRoles() { PolarisAuthorizableOperation op = PolarisAuthorizableOperation.LIST_PRINCIPAL_ROLES; authorizeBasicRootOperationOrThrow(op); - return metaStoreManager - .listEntities( - getCurrentPolarisContext(), - null, - PolarisEntityType.PRINCIPAL_ROLE, - PolarisEntitySubType.NULL_SUBTYPE) + return daoManager + .getPrincipalRoleDao() + .listEntities(getCurrentPolarisContext()) .getEntities() .stream() .map( nameAndId -> PolarisEntity.of( - metaStoreManager.loadEntity( - getCurrentPolarisContext(), 0, nameAndId.getId(), nameAndId.getType()))) + daoManager + .getPrincipalRoleDao() + .loadEntity(getCurrentPolarisContext(), nameAndId.getId()))) .toList(); } @@ -1054,15 +1074,21 @@ public PolarisEntity createCatalogRole(String catalogName, PolarisEntity entity) PolarisEntity returnedEntity = PolarisEntity.of( - metaStoreManager.createEntityIfNotExists( - getCurrentPolarisContext(), - PolarisEntity.toCoreList(List.of(catalogEntity)), - new PolarisEntity.Builder(entity) - .setId(metaStoreManager.generateNewEntityId(getCurrentPolarisContext()).getId()) - .setCatalogId(catalogEntity.getId()) - .setParentId(catalogEntity.getId()) - .setCreateTimestamp(System.currentTimeMillis()) - .build())); + daoManager + .getCatalogRoleDao() + .createEntityIfNotExists( + getCurrentPolarisContext(), + PolarisEntity.toCoreList(List.of(catalogEntity)), + new PolarisEntity.Builder(entity) + .setId( + daoManager + .getCommonDao() + .generateNewEntityId(getCurrentPolarisContext()) + .getId()) + .setCatalogId(catalogEntity.getId()) + .setParentId(catalogEntity.getId()) + .setCreateTimestamp(System.currentTimeMillis()) + .build())); if (returnedEntity == null) { throw new AlreadyExistsException( "Cannot create CatalogRole %s in %s. CatalogRole already exists or resolution failed", @@ -1081,12 +1107,14 @@ public void deleteCatalogRole(String catalogName, String name) { } // TODO: Handle return value in case of concurrent modification DropEntityResult dropEntityResult = - metaStoreManager.dropEntityIfExists( - getCurrentPolarisContext(), - PolarisEntity.toCoreList(resolvedCatalogRoleEntity.getRawParentPath()), - resolvedCatalogRoleEntity.getRawLeafEntity(), - Map.of(), - true); // cleanup grants + daoManager + .getCatalogRoleDao() + .dropEntityIfExists( + getCurrentPolarisContext(), + PolarisEntity.toCoreList(resolvedCatalogRoleEntity.getRawParentPath()), + resolvedCatalogRoleEntity.getRawLeafEntity(), + Map.of(), + true); // cleanup grants // at least some handling of error if (!dropEntityResult.isSuccess()) { @@ -1136,10 +1164,12 @@ public void deleteCatalogRole(String catalogName, String name) { Optional.ofNullable( CatalogRoleEntity.of( PolarisEntity.of( - metaStoreManager.updateEntityPropertiesIfNotChanged( - getCurrentPolarisContext(), - PolarisEntity.toCoreList(List.of(catalogEntity)), - updatedEntity)))) + daoManager + .getCatalogRoleDao() + .updateEntityPropertiesIfNotChanged( + getCurrentPolarisContext(), + PolarisEntity.toCoreList(List.of(catalogEntity)), + updatedEntity)))) .orElseThrow( () -> new CommitFailedException( @@ -1154,22 +1184,18 @@ public List listCatalogRoles(String catalogName) { PolarisEntity catalogEntity = findCatalogByName(catalogName) .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); - return metaStoreManager - .listEntities( - getCurrentPolarisContext(), - PolarisEntity.toCoreList(List.of(catalogEntity)), - PolarisEntityType.CATALOG_ROLE, - PolarisEntitySubType.NULL_SUBTYPE) + return daoManager + .getCatalogRoleDao() + .listEntities(getCurrentPolarisContext(), PolarisEntity.toCoreList(List.of(catalogEntity))) .getEntities() .stream() .map( nameAndId -> PolarisEntity.of( - metaStoreManager.loadEntity( - getCurrentPolarisContext(), - catalogEntity.getId(), - nameAndId.getId(), - nameAndId.getType()))) + daoManager + .getCatalogRoleDao() + .loadEntity( + getCurrentPolarisContext(), catalogEntity.getId(), nameAndId.getId()))) .toList(); } @@ -1185,7 +1211,8 @@ public boolean assignPrincipalRole(String principalName, String principalRoleNam .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantUsageOnRoleToGrantee( getCurrentPolarisContext(), null, principalRoleEntity, principalEntity) .isSuccess(); @@ -1202,7 +1229,8 @@ public boolean revokePrincipalRole(String principalName, String principalRoleNam findPrincipalRoleByName(principalRoleName) .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokeUsageOnRoleFromGrantee( getCurrentPolarisContext(), null, principalRoleEntity, principalEntity) .isSuccess(); @@ -1217,8 +1245,12 @@ public List listPrincipalRolesAssigned(String principalName) { findPrincipalByName(principalName) .orElseThrow(() -> new NotFoundException("Principal %s not found", principalName)); LoadGrantsResult grantList = - metaStoreManager.loadGrantsToGrantee( - getCurrentPolarisContext(), principalEntity.getCatalogId(), principalEntity.getId()); + daoManager + .getGrantRecordDao() + .loadGrantsToGrantee( + getCurrentPolarisContext(), + principalEntity.getCatalogId(), + principalEntity.getId()); return buildEntitiesFromGrantResults(grantList, false, PolarisEntityType.PRINCIPAL_ROLE, null); } @@ -1240,7 +1272,8 @@ public boolean assignCatalogRoleToPrincipalRole( findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantUsageOnRoleToGrantee( getCurrentPolarisContext(), catalogEntity, catalogRoleEntity, principalRoleEntity) .isSuccess(); @@ -1263,7 +1296,8 @@ public boolean revokeCatalogRoleFromPrincipalRole( PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokeUsageOnRoleFromGrantee( getCurrentPolarisContext(), catalogEntity, catalogRoleEntity, principalRoleEntity) .isSuccess(); @@ -1281,10 +1315,12 @@ public List listAssigneePrincipalsForPrincipalRole(String princip .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); LoadGrantsResult grantList = - metaStoreManager.loadGrantsOnSecurable( - getCurrentPolarisContext(), - principalRoleEntity.getCatalogId(), - principalRoleEntity.getId()); + daoManager + .getGrantRecordDao() + .loadGrantsOnSecurable( + getCurrentPolarisContext(), + principalRoleEntity.getCatalogId(), + principalRoleEntity.getId()); return buildEntitiesFromGrantResults(grantList, true, PolarisEntityType.PRINCIPAL, null); } @@ -1336,10 +1372,12 @@ public List listCatalogRolesForPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); LoadGrantsResult grantList = - metaStoreManager.loadGrantsToGrantee( - getCurrentPolarisContext(), - principalRoleEntity.getCatalogId(), - principalRoleEntity.getId()); + daoManager + .getGrantRecordDao() + .loadGrantsToGrantee( + getCurrentPolarisContext(), + principalRoleEntity.getCatalogId(), + principalRoleEntity.getId()); return buildEntitiesFromGrantResults( grantList, false, @@ -1360,7 +1398,8 @@ public boolean grantPrivilegeOnRootContainerToPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantPrivilegeOnSecurableToRole( getCurrentPolarisContext(), principalRoleEntity, null, rootContainerEntity, privilege) .isSuccess(); @@ -1380,7 +1419,8 @@ public boolean revokePrivilegeOnRootContainerFromPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokePrivilegeOnSecurableFromRole( getCurrentPolarisContext(), principalRoleEntity, null, rootContainerEntity, privilege) .isSuccess(); @@ -1404,7 +1444,8 @@ public boolean grantPrivilegeOnCatalogToRole( findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantPrivilegeOnSecurableToRole( getCurrentPolarisContext(), catalogRoleEntity, @@ -1428,7 +1469,8 @@ public boolean revokePrivilegeOnCatalogFromRole( findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokePrivilegeOnSecurableFromRole( getCurrentPolarisContext(), catalogRoleEntity, @@ -1456,7 +1498,8 @@ public boolean grantPrivilegeOnNamespaceToRole( List catalogPath = resolvedPathWrapper.getRawParentPath(); PolarisEntity namespaceEntity = resolvedPathWrapper.getRawLeafEntity(); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantPrivilegeOnSecurableToRole( getCurrentPolarisContext(), catalogRoleEntity, @@ -1484,7 +1527,8 @@ public boolean revokePrivilegeOnNamespaceFromRole( List catalogPath = resolvedPathWrapper.getRawParentPath(); PolarisEntity namespaceEntity = resolvedPathWrapper.getRawLeafEntity(); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokePrivilegeOnSecurableFromRole( getCurrentPolarisContext(), catalogRoleEntity, @@ -1565,10 +1609,12 @@ public List listAssigneePrincipalRolesForCatalogRole( findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); LoadGrantsResult grantList = - metaStoreManager.loadGrantsOnSecurable( - getCurrentPolarisContext(), - catalogRoleEntity.getCatalogId(), - catalogRoleEntity.getId()); + daoManager + .getGrantRecordDao() + .loadGrantsOnSecurable( + getCurrentPolarisContext(), + catalogRoleEntity.getCatalogId(), + catalogRoleEntity.getId()); return buildEntitiesFromGrantResults(grantList, true, PolarisEntityType.PRINCIPAL_ROLE, null); } @@ -1584,10 +1630,12 @@ public List listGrantsForCatalogRole(String catalogName, String c findCatalogRoleByName(catalogName, catalogRoleName) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", catalogRoleName)); LoadGrantsResult grantList = - metaStoreManager.loadGrantsToGrantee( - getCurrentPolarisContext(), - catalogRoleEntity.getCatalogId(), - catalogRoleEntity.getId()); + daoManager + .getGrantRecordDao() + .loadGrantsToGrantee( + getCurrentPolarisContext(), + catalogRoleEntity.getCatalogId(), + catalogRoleEntity.getId()); List catalogGrants = new ArrayList<>(); List namespaceGrants = new ArrayList<>(); List tableGrants = new ArrayList<>(); @@ -1673,7 +1721,7 @@ public List listGrantsForCatalogRole(String catalogName, String c long id, PolarisEntityType entityType) { return (entitiesMap == null) - ? metaStoreManager + ? daoManager // TODO use type-specific DAO here .loadEntity(getCurrentPolarisContext(), catalogId, id, entityType) .getEntity() : entitiesMap.get(id); @@ -1687,7 +1735,8 @@ public List listGrantsForCatalogRole(String catalogName, String c for (PolarisEntityType type : PolarisEntityType.values()) { EntityResult entityResult = - metaStoreManager.loadEntity( + // TODO use type-specific DAO here + daoManager.loadEntity( getCurrentPolarisContext(), record.getSecurableCatalogId(), record.getSecurableId(), @@ -1726,7 +1775,8 @@ private boolean grantPrivilegeOnTableLikeToRole( List catalogPath = resolvedPathWrapper.getRawParentPath(); PolarisEntity tableLikeEntity = resolvedPathWrapper.getRawLeafEntity(); - return metaStoreManager + return daoManager + .getGrantRecordDao() .grantPrivilegeOnSecurableToRole( getCurrentPolarisContext(), catalogRoleEntity, @@ -1764,7 +1814,8 @@ private boolean revokePrivilegeOnTableLikeFromRole( List catalogPath = resolvedPathWrapper.getRawParentPath(); PolarisEntity tableLikeEntity = resolvedPathWrapper.getRawLeafEntity(); - return metaStoreManager + return daoManager + .getGrantRecordDao() .revokePrivilegeOnSecurableFromRole( getCurrentPolarisContext(), catalogRoleEntity,