geyanggang commented on code in PR #13769:
URL: https://github.com/apache/gravitino/pull/13769#discussion_r4247170798


##########
catalogs/catalog-jdbc-common/src/main/java/org/apache/gravitino/catalog/jdbc/JdbcCatalog.java:
##########
@@ -79,6 +82,51 @@ public Capability newCapability() {
     return new JdbcCatalogCapability();
   }
 
+  /**
+   * Returns the effective {@link Catalog#PROPERTY_VERIFY_ON_CREATE 
verify-on-create} setting for
+   * this catalog. A relational JDBC catalog verifies its backend at create 
time by default; an
+   * administrator opts out by setting {@code 
gravitino.catalog.verify-on-create=false} to register
+   * a catalog whose backend is temporarily unavailable.
+   *
+   * @return {@code true} to verify the backend at create (default); {@code 
false} to skip the check
+   */
+  @Override
+  public boolean shouldValidateOnCreate() {
+    Map<String, String> properties = entity().getProperties();
+    if (properties == null) {
+      return true;
+    }
+    return 
Boolean.parseBoolean(properties.getOrDefault(Catalog.PROPERTY_VERIFY_ON_CREATE, 
"true"));
+  }
+
+  /**
+   * Verifies the backend is reachable at create time by running a single 
{@code testConnection}
+   * (one {@code listDatabases} round trip) through the catalog operations. On 
failure the backend
+   * raises a {@link ConnectionFailedException}, which propagates so {@code 
CatalogManager} rolls
+   * back the just-persisted catalog entity.
+   *
+   * <p>No connection-pool leak: the probe borrows one connection and returns 
it (JDBC operations
+   * use try-with-resources), and the pool stays lazy. If verification throws, 
{@code
+   * CatalogManager.initCatalogWrapper} closes the partially-initialized 
catalog, which closes the
+   * datasource and releases the pool.
+   */
+  @Override
+  public void validateOnCreate() {

Review Comment:
   Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to