This is an automated email from the ASF dual-hosted git repository.
jinsongzhou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/amoro.git
The following commit(s) were added to refs/heads/master by this push:
new f211a1c6b [AMORO-3677] Fill catalogProperties in creating catalog
rather than building (#3678)
f211a1c6b is described below
commit f211a1c6ba97ebf43dffeca4e8c274caf1ac5970
Author: Marig_Weizhi <[email protected]>
AuthorDate: Mon Aug 4 14:16:47 2025 +0800
[AMORO-3677] Fill catalogProperties in creating catalog rather than
building (#3678)
* set clients if not exists
* set clients if not exists
* delete code
* fill catalogProperties in creating catalog rather than building
---------
Co-authored-by: ZhouJinsong <[email protected]>
---
.../apache/amoro/server/catalog/CatalogBuilder.java | 16 ----------------
.../amoro/server/catalog/DefaultCatalogManager.java | 21 +++++++++++++++++++++
.../amoro/server/table/TestCatalogService.java | 12 ++++++++++++
3 files changed, 33 insertions(+), 16 deletions(-)
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/catalog/CatalogBuilder.java
b/amoro-ams/src/main/java/org/apache/amoro/server/catalog/CatalogBuilder.java
index c00310f35..2fb8b4e29 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/catalog/CatalogBuilder.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/catalog/CatalogBuilder.java
@@ -23,14 +23,10 @@ import static
org.apache.amoro.properties.CatalogMetaProperties.CATALOG_TYPE_CUS
import static
org.apache.amoro.properties.CatalogMetaProperties.CATALOG_TYPE_GLUE;
import static
org.apache.amoro.properties.CatalogMetaProperties.CATALOG_TYPE_HADOOP;
import static
org.apache.amoro.properties.CatalogMetaProperties.CATALOG_TYPE_HIVE;
-import static
org.apache.amoro.properties.CatalogMetaProperties.CLIENT_POOL_SIZE;
-import static
org.apache.amoro.properties.CatalogMetaProperties.CLIENT_POOL_SIZE_DEFAULT;
import org.apache.amoro.TableFormat;
import org.apache.amoro.api.CatalogMeta;
import org.apache.amoro.config.Configurations;
-import org.apache.amoro.properties.CatalogMetaProperties;
-import org.apache.amoro.server.AmoroManagementConf;
import org.apache.amoro.shade.guava32.com.google.common.base.Preconditions;
import org.apache.amoro.shade.guava32.com.google.common.collect.ImmutableMap;
import org.apache.amoro.shade.guava32.com.google.common.collect.Sets;
@@ -61,12 +57,6 @@ public class CatalogBuilder {
TableFormat.HUDI),
CATALOG_TYPE_AMS, Sets.newHashSet(TableFormat.ICEBERG,
TableFormat.MIXED_ICEBERG));
- private static String getAmsURI(Configurations serviceConfig) {
- String host =
serviceConfig.getString(AmoroManagementConf.SERVER_EXPOSE_HOST);
- Integer port =
serviceConfig.getInteger(AmoroManagementConf.TABLE_SERVICE_THRIFT_BIND_PORT);
- return String.format("thrift://%s:%d", host, port);
- }
-
public static ServerCatalog buildServerCatalog(
CatalogMeta catalogMeta, Configurations serverConfiguration) {
String type = catalogMeta.getCatalogType();
@@ -86,13 +76,7 @@ public class CatalogBuilder {
case CATALOG_TYPE_HADOOP:
case CATALOG_TYPE_GLUE:
case CATALOG_TYPE_CUSTOM:
- return new ExternalCatalog(catalogMeta);
case CATALOG_TYPE_HIVE:
- String amsUri = getAmsURI(serverConfiguration);
- catalogMeta.getCatalogProperties().put(CatalogMetaProperties.AMS_URI,
amsUri);
- catalogMeta
- .getCatalogProperties()
- .put(CLIENT_POOL_SIZE, String.valueOf(CLIENT_POOL_SIZE_DEFAULT));
return new ExternalCatalog(catalogMeta);
case CATALOG_TYPE_AMS:
return new InternalCatalogImpl(catalogMeta, serverConfiguration);
diff --git
a/amoro-ams/src/main/java/org/apache/amoro/server/catalog/DefaultCatalogManager.java
b/amoro-ams/src/main/java/org/apache/amoro/server/catalog/DefaultCatalogManager.java
index fbd03eb6d..967a6a57f 100644
---
a/amoro-ams/src/main/java/org/apache/amoro/server/catalog/DefaultCatalogManager.java
+++
b/amoro-ams/src/main/java/org/apache/amoro/server/catalog/DefaultCatalogManager.java
@@ -18,7 +18,12 @@
package org.apache.amoro.server.catalog;
+import static
org.apache.amoro.properties.CatalogMetaProperties.CATALOG_TYPE_HIVE;
+import static
org.apache.amoro.properties.CatalogMetaProperties.CLIENT_POOL_SIZE;
+import static
org.apache.amoro.properties.CatalogMetaProperties.CLIENT_POOL_SIZE_DEFAULT;
+
import org.apache.amoro.AmoroTable;
+import org.apache.amoro.Constants;
import org.apache.amoro.api.CatalogMeta;
import org.apache.amoro.config.Configurations;
import org.apache.amoro.exception.AlreadyExistsException;
@@ -26,6 +31,7 @@ import org.apache.amoro.exception.IllegalMetadataException;
import org.apache.amoro.exception.ObjectNotExistsException;
import org.apache.amoro.properties.CatalogMetaProperties;
import org.apache.amoro.server.AmoroManagementConf;
+import org.apache.amoro.server.dashboard.utils.AmsUtil;
import org.apache.amoro.server.persistence.PersistentBase;
import org.apache.amoro.server.persistence.mapper.CatalogMetaMapper;
import
org.apache.amoro.shade.guava32.com.google.common.annotations.VisibleForTesting;
@@ -162,6 +168,7 @@ public class DefaultCatalogManager extends PersistentBase
implements CatalogMana
if (catalogExist(catalogMeta.getCatalogName())) {
throw new AlreadyExistsException("Catalog " +
catalogMeta.getCatalogName());
}
+ fillCatalogProperties(catalogMeta);
// Build to make sure the catalog is valid
ServerCatalog catalog = CatalogBuilder.buildServerCatalog(catalogMeta,
serverConfiguration);
doAs(CatalogMetaMapper.class, mapper ->
mapper.insertCatalog(catalog.getMetadata()));
@@ -171,6 +178,20 @@ public class DefaultCatalogManager extends PersistentBase
implements CatalogMana
"Create catalog {}, type:{}", catalogMeta.getCatalogName(),
catalogMeta.getCatalogType());
}
+ private void fillCatalogProperties(CatalogMeta catalogMeta) {
+ String type = catalogMeta.getCatalogType();
+
+ if (CATALOG_TYPE_HIVE.equals(type)) {
+ String amsUri =
+ AmsUtil.getAMSThriftAddress(serverConfiguration,
Constants.THRIFT_TABLE_SERVICE_NAME);
+ catalogMeta.getCatalogProperties().put(CatalogMetaProperties.AMS_URI,
amsUri);
+
+ catalogMeta
+ .getCatalogProperties()
+ .putIfAbsent(CLIENT_POOL_SIZE,
String.valueOf(CLIENT_POOL_SIZE_DEFAULT));
+ }
+ }
+
@Override
public void dropCatalog(String catalogName) {
doAs(
diff --git
a/amoro-ams/src/test/java/org/apache/amoro/server/table/TestCatalogService.java
b/amoro-ams/src/test/java/org/apache/amoro/server/table/TestCatalogService.java
index 95be73d40..05f40eea9 100644
---
a/amoro-ams/src/test/java/org/apache/amoro/server/table/TestCatalogService.java
+++
b/amoro-ams/src/test/java/org/apache/amoro/server/table/TestCatalogService.java
@@ -18,6 +18,8 @@
package org.apache.amoro.server.table;
+import static
org.apache.amoro.properties.CatalogMetaProperties.CLIENT_POOL_SIZE;
+
import org.apache.amoro.TableFormat;
import org.apache.amoro.TestedCatalogs;
import org.apache.amoro.api.CatalogMeta;
@@ -135,4 +137,14 @@ public class TestCatalogService extends AMSServiceTestBase
{
catalog.dropDatabase("test_db");
CATALOG_MANAGER.dropCatalog(catalogMeta.getCatalogName());
}
+
+ @Test
+ public void testCreateCatalogWithProperties() {
+ CatalogMeta catalogMeta = catalogTestHelper.buildCatalogMeta("/tmp");
+ catalogMeta.getCatalogProperties().put(CLIENT_POOL_SIZE, "15");
+ CATALOG_MANAGER.createCatalog(catalogMeta);
+ CatalogMeta readCatalogMeta =
CATALOG_MANAGER.getCatalogMeta(catalogMeta.getCatalogName());
+ Assert.assertEquals("15",
readCatalogMeta.getCatalogProperties().get(CLIENT_POOL_SIZE));
+ CATALOG_MANAGER.dropCatalog(catalogMeta.getCatalogName());
+ }
}