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


##########
catalogs-contrib/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/TestOceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import java.util.Collections;
+import java.util.Map;
+import 
org.apache.gravitino.catalog.jdbc.MySQLProtocolCompatibleCatalogOperations;
+import org.apache.gravitino.connector.CatalogOperations;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestOceanBaseCatalogOperations {
+
+  @Test
+  public void testOceanBaseCatalogUsesOceanBaseOperations() {
+    CatalogOperations operations = new 
TestableOceanBaseCatalog().newOps(Collections.emptyMap());
+
+    Assertions.assertInstanceOf(OceanBaseCatalogOperations.class, operations);
+    Assertions.assertFalse(operations instanceof 
MySQLProtocolCompatibleCatalogOperations);
+  }
+
+  @Test
+  public void testCheckJDBCDriverVersionDoesNotRejectOceanBaseDriverVersion() {
+    OceanBaseCatalogOperations operations =
+        new OceanBaseCatalogOperations(null, null, null, null, null);
+
+    Assertions.assertDoesNotThrow(operations::checkJDBCDriverVersion);
+  }
+
+  private static class TestableOceanBaseCatalog extends OceanBaseCatalog {
+    @Override
+    protected CatalogOperations newOps(Map<String, String> config) {
+      return super.newOps(config);
+    }
+  }

Review Comment:
   newOps is protected and the test class is in the same package as 
OceanBaseCatalog, so you can call it directly without the 
TestableOceanBaseCatalog subclass.



##########
catalogs-contrib/catalog-jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations;
+import 
org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
+import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
+import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Operations for interacting with the OceanBase catalog in Apache Gravitino.
+ *
+ * <p>OceanBase supports both MySQL Connector/J and the OceanBase JDBC driver, 
so it should not use
+ * {@code MySQLProtocolCompatibleCatalogOperations}, which rejects non-MySQL 
Connector/J drivers by
+ * major version during catalog initialization.
+ */
+public class OceanBaseCatalogOperations extends JdbcCatalogOperations {
+  private static final Logger LOG = 
LoggerFactory.getLogger(OceanBaseCatalogOperations.class);
+
+  /**
+   * Constructs a new instance of {@link OceanBaseCatalogOperations}.
+   *
+   * @param exceptionConverter The exception converter to be used by the 
operations.
+   * @param jdbcTypeConverter The type converter to be used by the operations.
+   * @param databaseOperation The database operations to be used by the 
operations.
+   * @param tableOperation The table operations to be used by the operations.
+   * @param columnDefaultValueConverter The column default value converter to 
be used by the
+   *     operations.
+   */
+  public OceanBaseCatalogOperations(
+      JdbcExceptionConverter exceptionConverter,
+      JdbcTypeConverter jdbcTypeConverter,
+      JdbcDatabaseOperations databaseOperation,
+      JdbcTableOperations tableOperation,
+      JdbcColumnDefaultValueConverter columnDefaultValueConverter) {
+    super(
+        exceptionConverter,
+        jdbcTypeConverter,
+        databaseOperation,
+        tableOperation,
+        columnDefaultValueConverter);
+  }
+
+  /** Closes the OceanBase catalog and shuts down MySQL Connector/J cleanup 
resources if present. */
+  @Override
+  public void close() {
+    super.close();
+
+    try {
+      Class.forName("com.mysql.cj.jdbc.AbandonedConnectionCleanupThread")
+          .getMethod("uncheckedShutdown")
+          .invoke(null);
+      LOG.info("AbandonedConnectionCleanupThread has been shutdown...");
+    } catch (ClassNotFoundException e) {
+      LOG.debug("MySQL AbandonedConnectionCleanupThread was not found", e);

Review Comment:
   since the ClassNotFoundException is completely expected when OceanBase's own 
driver is used (no MySQL classes on classpath), logging the full stack trace at 
DEBUG level is unnecessary noise. Consider dropping the exception parameter:
   
   } catch (ClassNotFoundException e) {
       LOG.debug("MySQL AbandonedConnectionCleanupThread not found on 
classpath, skipping shutdown");
   }



##########
catalogs-contrib/catalog-jdbc-oceanbase/src/test/java/org/apache/gravitino/catalog/oceanbase/TestOceanBaseCatalogOperations.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.gravitino.catalog.oceanbase;
+
+import java.util.Collections;
+import java.util.Map;
+import 
org.apache.gravitino.catalog.jdbc.MySQLProtocolCompatibleCatalogOperations;
+import org.apache.gravitino.connector.CatalogOperations;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestOceanBaseCatalogOperations {
+
+  @Test
+  public void testOceanBaseCatalogUsesOceanBaseOperations() {
+    CatalogOperations operations = new 
TestableOceanBaseCatalog().newOps(Collections.emptyMap());
+
+    Assertions.assertInstanceOf(OceanBaseCatalogOperations.class, operations);
+    Assertions.assertFalse(operations instanceof 
MySQLProtocolCompatibleCatalogOperations);
+  }
+
+  @Test
+  public void testCheckJDBCDriverVersionDoesNotRejectOceanBaseDriverVersion() {
+    OceanBaseCatalogOperations operations =
+        new OceanBaseCatalogOperations(null, null, null, null, null);
+
+    Assertions.assertDoesNotThrow(operations::checkJDBCDriverVersion);
+  }

Review Comment:
   Mind adding a quick comment here to explain what this test is for?



-- 
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