|
52 | 52 | import java.util.Set; |
53 | 53 | import java.util.UUID; |
54 | 54 | import java.util.function.Function; |
55 | | -import java.util.function.Supplier; |
56 | 55 | import java.util.stream.Collectors; |
57 | 56 | import java.util.stream.Stream; |
58 | | -import org.apache.commons.lang3.NotImplementedException; |
59 | 57 | import org.apache.iceberg.BaseTable; |
60 | 58 | import org.apache.iceberg.CatalogProperties; |
61 | 59 | import org.apache.iceberg.ContentFile; |
|
114 | 112 | import org.apache.polaris.core.persistence.PolarisEntityManager; |
115 | 113 | import org.apache.polaris.core.persistence.PolarisMetaStoreManager; |
116 | 114 | import org.apache.polaris.core.persistence.PolarisResolvedPathWrapper; |
117 | | -import org.apache.polaris.core.persistence.bootstrap.RootCredentialsSet; |
118 | 115 | import org.apache.polaris.core.persistence.cache.InMemoryEntityCache; |
119 | 116 | import org.apache.polaris.core.persistence.dao.entity.BaseResult; |
120 | 117 | import org.apache.polaris.core.persistence.dao.entity.EntityResult; |
121 | | -import org.apache.polaris.core.persistence.dao.entity.PrincipalSecretsResult; |
122 | 118 | import org.apache.polaris.core.persistence.pagination.PageToken; |
123 | | -import org.apache.polaris.core.persistence.transactional.TransactionalPersistence; |
124 | 119 | import org.apache.polaris.core.secrets.UserSecretsManager; |
125 | 120 | import org.apache.polaris.core.secrets.UserSecretsManagerFactory; |
126 | 121 | import org.apache.polaris.core.storage.PolarisStorageActions; |
@@ -239,7 +234,7 @@ public Map<String, String> getConfigOverrides() { |
239 | 234 | CatalogProperties.TABLE_OVERRIDE_PREFIX + "override-key4", |
240 | 235 | "catalog-override-key4"); |
241 | 236 |
|
242 | | - @Inject MetaStoreManagerFactory managerFactory; |
| 237 | + @Inject MetaStoreManagerFactory metaStoreManagerFactory; |
243 | 238 | @Inject PolarisConfigurationStore configurationStore; |
244 | 239 | @Inject PolarisStorageIntegrationProvider storageIntegrationProvider; |
245 | 240 | @Inject UserSecretsManagerFactory userSecretsManagerFactory; |
@@ -284,12 +279,12 @@ public void before(TestInfo testInfo) { |
284 | 279 | testInfo.getTestMethod().map(Method::getName).orElse("test"), System.nanoTime()); |
285 | 280 | RealmContext realmContext = () -> realmName; |
286 | 281 | QuarkusMock.installMockForType(realmContext, RealmContext.class); |
287 | | - metaStoreManager = managerFactory.getOrCreateMetaStoreManager(realmContext); |
| 282 | + metaStoreManager = metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext); |
288 | 283 | userSecretsManager = userSecretsManagerFactory.getOrCreateUserSecretsManager(realmContext); |
289 | 284 | polarisContext = |
290 | 285 | new PolarisCallContext( |
291 | 286 | realmContext, |
292 | | - managerFactory.getOrCreateSessionSupplier(realmContext).get(), |
| 287 | + metaStoreManagerFactory.getOrCreateSessionSupplier(realmContext).get(), |
293 | 288 | diagServices, |
294 | 289 | configurationStore, |
295 | 290 | Clock.systemDefaultZone()); |
@@ -360,9 +355,10 @@ public void before(TestInfo testInfo) { |
360 | 355 | .asCatalog())); |
361 | 356 |
|
362 | 357 | RealmEntityManagerFactory realmEntityManagerFactory = |
363 | | - new RealmEntityManagerFactory(createMockMetaStoreManagerFactory()); |
| 358 | + new RealmEntityManagerFactory(metaStoreManagerFactory); |
364 | 359 | this.fileIOFactory = |
365 | | - new DefaultFileIOFactory(realmEntityManagerFactory, managerFactory, configurationStore); |
| 360 | + new DefaultFileIOFactory( |
| 361 | + realmEntityManagerFactory, metaStoreManagerFactory, configurationStore); |
366 | 362 |
|
367 | 363 | StsClient stsClient = Mockito.mock(StsClient.class); |
368 | 364 | when(stsClient.assumeRole(isA(AssumeRoleRequest.class))) |
@@ -450,42 +446,6 @@ protected boolean supportsNotifications() { |
450 | 446 | return true; |
451 | 447 | } |
452 | 448 |
|
453 | | - private MetaStoreManagerFactory createMockMetaStoreManagerFactory() { |
454 | | - return new MetaStoreManagerFactory() { |
455 | | - @Override |
456 | | - public PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmContext realmContext) { |
457 | | - return metaStoreManager; |
458 | | - } |
459 | | - |
460 | | - @Override |
461 | | - public Supplier<TransactionalPersistence> getOrCreateSessionSupplier( |
462 | | - RealmContext realmContext) { |
463 | | - return () -> ((TransactionalPersistence) polarisContext.getMetaStore()); |
464 | | - } |
465 | | - |
466 | | - @Override |
467 | | - public StorageCredentialCache getOrCreateStorageCredentialCache(RealmContext realmContext) { |
468 | | - return new StorageCredentialCache(realmContext, configurationStore); |
469 | | - } |
470 | | - |
471 | | - @Override |
472 | | - public InMemoryEntityCache getOrCreateEntityCache(RealmContext realmContext) { |
473 | | - return new InMemoryEntityCache(realmContext, configurationStore, metaStoreManager); |
474 | | - } |
475 | | - |
476 | | - @Override |
477 | | - public Map<String, PrincipalSecretsResult> bootstrapRealms( |
478 | | - Iterable<String> realms, RootCredentialsSet rootCredentialsSet) { |
479 | | - throw new NotImplementedException("Bootstrapping realms is not supported"); |
480 | | - } |
481 | | - |
482 | | - @Override |
483 | | - public Map<String, BaseResult> purgeRealms(Iterable<String> realms) { |
484 | | - throw new NotImplementedException("Purging realms is not supported"); |
485 | | - } |
486 | | - }; |
487 | | - } |
488 | | - |
489 | 449 | @Test |
490 | 450 | public void testEmptyNamespace() { |
491 | 451 | IcebergCatalog catalog = catalog(); |
@@ -1030,8 +990,8 @@ public void testValidateNotificationFailToCreateFileIO() { |
1030 | 990 | FileIOFactory fileIOFactory = |
1031 | 991 | spy( |
1032 | 992 | new DefaultFileIOFactory( |
1033 | | - new RealmEntityManagerFactory(createMockMetaStoreManagerFactory()), |
1034 | | - managerFactory, |
| 993 | + new RealmEntityManagerFactory(metaStoreManagerFactory), |
| 994 | + metaStoreManagerFactory, |
1035 | 995 | configurationStore)); |
1036 | 996 | IcebergCatalog catalog = |
1037 | 997 | new IcebergCatalog( |
@@ -1922,7 +1882,6 @@ public void testDropTableWithPurge() { |
1922 | 1882 | .containsEntry(StorageAccessProperty.AWS_KEY_ID, TEST_ACCESS_KEY) |
1923 | 1883 | .containsEntry(StorageAccessProperty.AWS_SECRET_KEY, SECRET_ACCESS_KEY) |
1924 | 1884 | .containsEntry(StorageAccessProperty.AWS_TOKEN, SESSION_TOKEN); |
1925 | | - MetaStoreManagerFactory metaStoreManagerFactory = createMockMetaStoreManagerFactory(); |
1926 | 1885 | FileIO fileIO = |
1927 | 1886 | new TaskFileIOSupplier( |
1928 | 1887 | new DefaultFileIOFactory( |
@@ -2071,8 +2030,8 @@ public void testFileIOWrapper() { |
2071 | 2030 |
|
2072 | 2031 | MeasuredFileIOFactory measured = |
2073 | 2032 | new MeasuredFileIOFactory( |
2074 | | - new RealmEntityManagerFactory(createMockMetaStoreManagerFactory()), |
2075 | | - managerFactory, |
| 2033 | + new RealmEntityManagerFactory(metaStoreManagerFactory), |
| 2034 | + metaStoreManagerFactory, |
2076 | 2035 | configurationStore); |
2077 | 2036 | IcebergCatalog catalog = |
2078 | 2037 | new IcebergCatalog( |
@@ -2144,8 +2103,7 @@ public FileIO loadFileIO( |
2144 | 2103 | }); |
2145 | 2104 |
|
2146 | 2105 | TableCleanupTaskHandler handler = |
2147 | | - new TableCleanupTaskHandler( |
2148 | | - Mockito.mock(), createMockMetaStoreManagerFactory(), taskFileIOSupplier); |
| 2106 | + new TableCleanupTaskHandler(Mockito.mock(), metaStoreManagerFactory, taskFileIOSupplier); |
2149 | 2107 | handler.handleTask(taskEntity, polarisContext); |
2150 | 2108 | Assertions.assertThat(measured.getNumDeletedFiles()).as("A table was deleted").isGreaterThan(0); |
2151 | 2109 | } |
|
0 commit comments