mirror of https://github.com/apache/druid.git
* Revert changes from #12672 * Reverted more conflicting changes Changes are not needed given previous reversions.
This commit is contained in:
parent
679ccffe0f
commit
f7caee3b25
|
@ -61,24 +61,19 @@ public class MySQLConnector extends SQLMetadataConnector
|
|||
)
|
||||
{
|
||||
super(config, dbTables);
|
||||
this.dbi = createDBI(config.get(), driverConfig, connectorSslConfig, getValidationQuery());
|
||||
log.info("Loading \"MySQL\" metadata connector driver %s", driverConfig.getDriverClassName());
|
||||
tryLoadDriverClass(driverConfig.getDriverClassName(), true);
|
||||
|
||||
if (driverConfig.getDriverClassName().contains("mysql")) {
|
||||
myTransientExceptionClass = tryLoadDriverClass(MYSQL_TRANSIENT_EXCEPTION_CLASS_NAME, false);
|
||||
} else {
|
||||
myTransientExceptionClass = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static DBI createDBI(MetadataStorageConnectorConfig config, MySQLConnectorDriverConfig driverConfig, MySQLConnectorSslConfig connectorSslConfig, String validationQuery)
|
||||
{
|
||||
log.info("Loading \"MySQL\" metadata connector driver %s", driverConfig.getDriverClassName());
|
||||
tryLoadDriverClass(driverConfig.getDriverClassName(), true);
|
||||
|
||||
final BasicDataSource datasource = makeDatasource(config, validationQuery);
|
||||
final BasicDataSource datasource = getDatasource();
|
||||
// MySQL driver is classloader isolated as part of the extension
|
||||
// so we need to help JDBC find the driver
|
||||
datasource.setDriverClassLoader(MySQLConnector.class.getClassLoader());
|
||||
datasource.setDriverClassLoader(getClass().getClassLoader());
|
||||
datasource.setDriverClassName(driverConfig.getDriverClassName());
|
||||
datasource.addConnectionProperty("useSSL", String.valueOf(connectorSslConfig.isUseSSL()));
|
||||
if (connectorSslConfig.isUseSSL()) {
|
||||
|
@ -146,10 +141,9 @@ public class MySQLConnector extends SQLMetadataConnector
|
|||
// use double-quotes for quoting columns, so we can write SQL that works with most databases
|
||||
datasource.setConnectionInitSqls(ImmutableList.of("SET sql_mode='ANSI_QUOTES'"));
|
||||
|
||||
DBI dbi = new DBI(datasource);
|
||||
this.dbi = new DBI(datasource);
|
||||
|
||||
log.info("Configured MySQL as metadata storage");
|
||||
return dbi;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -258,10 +252,10 @@ public class MySQLConnector extends SQLMetadataConnector
|
|||
}
|
||||
|
||||
@Nullable
|
||||
private static Class<?> tryLoadDriverClass(String className, boolean failIfNotFound)
|
||||
private Class<?> tryLoadDriverClass(String className, boolean failIfNotFound)
|
||||
{
|
||||
try {
|
||||
return Class.forName(className, false, MySQLConnector.class.getClassLoader());
|
||||
return Class.forName(className, false, getClass().getClassLoader());
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
if (failIfNotFound) {
|
||||
|
|
|
@ -20,25 +20,13 @@
|
|||
package org.apache.druid.metadata.storage.mysql;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.base.Strings;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MySQLConnectorDriverConfig
|
||||
{
|
||||
public static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver";
|
||||
|
||||
@JsonProperty
|
||||
private String driverClassName = MYSQL_DRIVER;
|
||||
|
||||
public static MySQLConnectorDriverConfig create(String driverClassName)
|
||||
{
|
||||
MySQLConnectorDriverConfig config = new MySQLConnectorDriverConfig();
|
||||
if (!Strings.isNullOrEmpty(driverClassName)) {
|
||||
config.driverClassName = driverClassName;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
private String driverClassName = "com.mysql.jdbc.Driver";
|
||||
|
||||
@JsonProperty
|
||||
public String getDriverClassName()
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.apache.druid.metadata.storage.mysql;
|
|||
import nl.jqno.equalsverifier.EqualsVerifier;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MySQLConnectorDriverConfigTest
|
||||
{
|
||||
@Test
|
||||
|
@ -35,13 +33,4 @@ public class MySQLConnectorDriverConfigTest
|
|||
.withNonnullFields("driverClassName")
|
||||
.verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate()
|
||||
{
|
||||
MySQLConnectorDriverConfig config = MySQLConnectorDriverConfig.create(null);
|
||||
assertEquals(MySQLConnectorDriverConfig.MYSQL_DRIVER, config.getDriverClassName());
|
||||
config = MySQLConnectorDriverConfig.create("myDriver");
|
||||
assertEquals("myDriver", config.getDriverClassName());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue