9191import org .apache .polaris .core .catalog .PolarisCatalogHelpers ;
9292import org .apache .polaris .core .config .BehaviorChangeConfiguration ;
9393import org .apache .polaris .core .config .FeatureConfiguration ;
94- import org .apache .polaris .core .config .PolarisConfiguration ;
9594import org .apache .polaris .core .context .CallContext ;
9695import org .apache .polaris .core .entity .CatalogEntity ;
9796import org .apache .polaris .core .entity .NamespaceEntity ;
@@ -170,14 +169,15 @@ public class IcebergCatalog extends BaseMetastoreViewCatalog
170169 private final SecurityContext securityContext ;
171170 private final PolarisEventListener polarisEventListener ;
172171
173- private String ioImplClassName ;
174- private FileIO catalogFileIO ;
172+ protected String ioImplClassName ;
173+ protected FileIO catalogFileIO ;
174+ protected CloseableGroup closeableGroup ;
175+ protected Map <String , String > tableDefaultProperties ;
176+
175177 private final String catalogName ;
176178 private long catalogId = -1 ;
177179 private String defaultBaseLocation ;
178- private CloseableGroup closeableGroup ;
179180 private Map <String , String > catalogProperties ;
180- private Map <String , String > tableDefaultProperties ;
181181 private FileIOFactory fileIOFactory ;
182182 private PolarisMetaStoreManager metaStoreManager ;
183183
@@ -263,33 +263,13 @@ public void initialize(String name, Map<String, String> properties) {
263263 tableDefaultProperties =
264264 PropertyUtil .propertiesWithPrefix (properties , CatalogProperties .TABLE_DEFAULT_PREFIX );
265265
266- if (initializeDefaultCatalogFileioForTest ()) {
267- LOGGER .debug (
268- "Initializing a default catalogFileIO with properties {}" , tableDefaultProperties );
269- this .catalogFileIO = loadFileIO (ioImplClassName , tableDefaultProperties );
270- closeableGroup .addCloseable (this .catalogFileIO );
271- } else {
272- LOGGER .debug ("Not initializing default catalogFileIO" );
273- this .catalogFileIO = null ;
274- }
275-
276266 callContext .closeables ().addCloseable (this );
277267 this .closeableGroup = new CloseableGroup ();
278268 closeableGroup .addCloseable (metricsReporter ());
279269 closeableGroup .setSuppressCloseFailure (true );
280270
281271 tableDefaultProperties =
282272 PropertyUtil .propertiesWithPrefix (properties , CatalogProperties .TABLE_DEFAULT_PREFIX );
283-
284- if (initializeDefaultCatalogFileioForTest ()) {
285- LOGGER .debug (
286- "Initializing a default catalogFileIO with properties {}" , tableDefaultProperties );
287- this .catalogFileIO = loadFileIO (ioImplClassName , tableDefaultProperties );
288- closeableGroup .addCloseable (this .catalogFileIO );
289- } else {
290- LOGGER .debug ("Not initializing default catalogFileIO" );
291- this .catalogFileIO = null ;
292- }
293273 }
294274
295275 public void setMetaStoreManager (PolarisMetaStoreManager newMetaStoreManager ) {
@@ -359,8 +339,7 @@ public ViewBuilder buildView(TableIdentifier identifier) {
359339 @ VisibleForTesting
360340 public TableOperations newTableOps (
361341 TableIdentifier tableIdentifier , boolean makeMetadataCurrentOnCommit ) {
362- return new BasePolarisTableOperations (
363- catalogFileIO , tableIdentifier , makeMetadataCurrentOnCommit );
342+ return new BasePolarisTableOperations (getIo (), tableIdentifier , makeMetadataCurrentOnCommit );
364343 }
365344
366345 @ Override
@@ -862,9 +841,10 @@ private Page<TableIdentifier> listViews(Namespace namespace, PageToken pageToken
862841 return listTableLike (PolarisEntitySubType .ICEBERG_VIEW , namespace , pageToken );
863842 }
864843
844+ @ VisibleForTesting
865845 @ Override
866846 protected ViewOperations newViewOps (TableIdentifier identifier ) {
867- return new BasePolarisViewOperations (catalogFileIO , identifier );
847+ return new BasePolarisViewOperations (getIo () , identifier );
868848 }
869849
870850 @ Override
@@ -2514,7 +2494,7 @@ private Page<TableIdentifier> listTableLike(
25142494 * @param properties used to initialize the FileIO implementation
25152495 * @return FileIO object
25162496 */
2517- private FileIO loadFileIO (String ioImpl , Map <String , String > properties ) {
2497+ protected FileIO loadFileIO (String ioImpl , Map <String , String > properties ) {
25182498 IcebergTableLikeEntity icebergTableLikeEntity = IcebergTableLikeEntity .of (catalogEntity );
25192499 TableIdentifier identifier = icebergTableLikeEntity .getTableIdentifier ();
25202500 Set <String > locations = Set .of (catalogEntity .getDefaultBaseLocation ());
@@ -2545,12 +2525,6 @@ private Boolean getBooleanContextConfiguration(String configKey, boolean default
25452525 .getConfiguration (callContext .getPolarisCallContext (), configKey , defaultValue );
25462526 }
25472527
2548- private boolean initializeDefaultCatalogFileioForTest () {
2549- var ctx = callContext .getPolarisCallContext ();
2550- return ctx .getConfigurationStore ()
2551- .getConfiguration (ctx , INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST );
2552- }
2553-
25542528 private int getMaxMetadataRefreshRetries () {
25552529 var ctx = callContext .getPolarisCallContext ();
25562530 return ctx .getConfigurationStore ()
@@ -2574,11 +2548,4 @@ private PageToken buildPageToken(@Nullable String tokenString, @Nullable Integer
25742548 return PageToken .build (tokenString , pageSize );
25752549 }
25762550 }
2577-
2578- static final FeatureConfiguration <Boolean > INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST =
2579- PolarisConfiguration .<Boolean >builder ()
2580- .key ("INITIALIZE_DEFAULT_CATALOG_FILEIO_FOR_TEST" )
2581- .defaultValue (false )
2582- .description ("" )
2583- .buildFeatureConfiguration ();
25842551}
0 commit comments