Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
package com.scalar.db.storage.jdbc;

import com.google.common.util.concurrent.Uninterruptibles;
import com.google.errorprone.annotations.concurrent.LazyInit;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.transaction.consensuscommit.ConsensusCommitAdminRepairTableIntegrationTestBase;
import com.scalar.db.util.AdminTestUtils;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

public class ConsensusCommitAdminRepairTableIntegrationTestWithJdbcDatabase
extends ConsensusCommitAdminRepairTableIntegrationTestBase {
@LazyInit private RdbEngineStrategy rdbEngine;

@Override
protected Properties getProps(String testName) {
return JdbcEnv.getProperties(testName);
}

@Override
protected void initialize(String testName) throws Exception {
super.initialize(testName);
Properties properties = getProperties(testName);
rdbEngine = RdbEngineFactory.create(new JdbcConfig(new DatabaseConfig(properties)));
}

@Override
protected AdminTestUtils getAdminTestUtils(String testName) {
return new JdbcAdminTestUtils(getProperties(testName));
}

@Override
protected void waitForDifferentSessionDdl() {
if (JdbcTestUtils.isYugabyte(rdbEngine)) {
// This is needed to avoid schema or catalog version mismatch database errors.
Uninterruptibles.sleepUninterruptibly(1000, TimeUnit.MILLISECONDS);
return;
}
super.waitForDifferentSessionDdl();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public List<TestData> createExistingDatabaseWithAllDataTypes(String namespace)
}

public void createExistingDatabase(String namespace) throws SQLException {
execute(rdbEngine.createNamespaceSqls(rdbEngine.enclose(namespace)));
execute(rdbEngine.createSchemaSqls(namespace));
}

public List<String> getIntCompatibleColumnNamesOnExistingDatabase(String table) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public JdbcAdminTestUtils(Properties properties) {
@Override
public void dropMetadataTable() throws SQLException {
execute(
"DROP TABLE " + rdbEngine.encloseFullTableName(metadataSchema, JdbcAdmin.METADATA_TABLE));
"DROP TABLE "
+ rdbEngine.encloseFullTableName(metadataSchema, TableMetadataService.TABLE_NAME));

String dropNamespaceStatement = rdbEngine.dropNamespaceSql(metadataSchema);
execute(dropNamespaceStatement);
Expand All @@ -40,7 +41,7 @@ public void dropMetadataTable() throws SQLException {
@Override
public void truncateMetadataTable() throws Exception {
String truncateTableStatement =
rdbEngine.truncateTableSql(metadataSchema, JdbcAdmin.METADATA_TABLE);
rdbEngine.truncateTableSql(metadataSchema, TableMetadataService.TABLE_NAME);
execute(truncateTableStatement);
}

Expand All @@ -49,7 +50,7 @@ public void truncateMetadataTable() throws Exception {
public void corruptMetadata(String namespace, String table) throws Exception {
String insertCorruptedMetadataStatement =
"INSERT INTO "
+ rdbEngine.encloseFullTableName(metadataSchema, JdbcAdmin.METADATA_TABLE)
+ rdbEngine.encloseFullTableName(metadataSchema, TableMetadataService.TABLE_NAME)
+ " VALUES ('"
+ getFullTableName(namespace, table)
+ "','corrupted','corrupted','corrupted','corrupted','0','0')";
Expand All @@ -60,9 +61,9 @@ public void corruptMetadata(String namespace, String table) throws Exception {
public void deleteMetadata(String namespace, String table) throws Exception {
String deleteMetadataStatement =
"DELETE FROM "
+ rdbEngine.encloseFullTableName(metadataSchema, JdbcAdmin.METADATA_TABLE)
+ rdbEngine.encloseFullTableName(metadataSchema, TableMetadataService.TABLE_NAME)
+ " WHERE "
+ rdbEngine.enclose(JdbcAdmin.METADATA_COL_FULL_TABLE_NAME)
+ rdbEngine.enclose(TableMetadataService.COL_FULL_TABLE_NAME)
+ " = ?";
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import com.datastax.driver.core.schemabuilder.SchemaBuilder;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.storage.cassandra.ClusterManager;
import com.scalar.db.storage.jdbc.JdbcAdmin;
import com.scalar.db.storage.jdbc.JdbcConfig;
import com.scalar.db.storage.jdbc.JdbcTestUtils;
import com.scalar.db.storage.jdbc.JdbcUtils;
import com.scalar.db.storage.jdbc.RdbEngineFactory;
import com.scalar.db.storage.jdbc.RdbEngineOracle;
import com.scalar.db.storage.jdbc.RdbEngineStrategy;
import com.scalar.db.storage.jdbc.TableMetadataService;
import com.scalar.db.util.AdminTestUtils;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.sql.Connection;
Expand Down Expand Up @@ -52,14 +51,9 @@ public void dropMetadataTable() throws SQLException {
// for JDBC
execute(
"DROP TABLE "
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, JdbcAdmin.METADATA_TABLE));
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, TableMetadataService.TABLE_NAME));

String dropNamespaceStatement;
if (rdbEngine instanceof RdbEngineOracle) {
dropNamespaceStatement = "DROP USER " + rdbEngine.enclose(jdbcMetadataSchema);
} else {
dropNamespaceStatement = "DROP SCHEMA " + rdbEngine.enclose(jdbcMetadataSchema);
}
String dropNamespaceStatement = rdbEngine.dropNamespaceSql(jdbcMetadataSchema);
execute(dropNamespaceStatement);
}

Expand All @@ -70,7 +64,7 @@ public void truncateMetadataTable() throws Exception {
// for JDBC
String truncateTableStatement =
"TRUNCATE TABLE "
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, JdbcAdmin.METADATA_TABLE);
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, TableMetadataService.TABLE_NAME);
execute(truncateTableStatement);
}

Expand All @@ -82,7 +76,7 @@ public void corruptMetadata(String namespace, String table) throws Exception {
// for JDBC
String insertCorruptedMetadataStatement =
"INSERT INTO "
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, JdbcAdmin.METADATA_TABLE)
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, TableMetadataService.TABLE_NAME)
+ " VALUES ('"
+ getFullTableName(namespace, table)
+ "','corrupted','corrupted','corrupted','corrupted','0','0')";
Expand All @@ -96,9 +90,9 @@ public void deleteMetadata(String namespace, String table) throws Exception {
// for JDBC
String deleteMetadataStatement =
"DELETE FROM "
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, JdbcAdmin.METADATA_TABLE)
+ rdbEngine.encloseFullTableName(jdbcMetadataSchema, TableMetadataService.TABLE_NAME)
+ " WHERE "
+ rdbEngine.enclose(JdbcAdmin.METADATA_COL_FULL_TABLE_NAME)
+ rdbEngine.enclose(TableMetadataService.COL_FULL_TABLE_NAME)
+ " = ?";
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public Set<String> getNamespaceNames() throws ExecutionException {

@Override
public StorageInfo getStorageInfo(String namespace) throws ExecutionException {
if (!namespaceExists(namespace)) {
if (checkNamespace && !namespaceExists(namespace)) {
throw new IllegalArgumentException(CoreError.NAMESPACE_NOT_FOUND.buildMessage(namespace));
}

Expand Down
Loading