diff --git a/core/src/main/java/com/scalar/db/common/CheckedDistributedStorageAdmin.java b/core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java similarity index 97% rename from core/src/main/java/com/scalar/db/common/CheckedDistributedStorageAdmin.java rename to core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java index 74b05b27d7..8ef43e47ff 100644 --- a/core/src/main/java/com/scalar/db/common/CheckedDistributedStorageAdmin.java +++ b/core/src/main/java/com/scalar/db/common/CommonDistributedStorageAdmin.java @@ -13,10 +13,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class CheckedDistributedStorageAdmin implements DistributedStorageAdmin { +public class CommonDistributedStorageAdmin implements DistributedStorageAdmin { - private static final Logger logger = - LoggerFactory.getLogger(CheckedDistributedStorageAdmin.class); + private static final Logger logger = LoggerFactory.getLogger(CommonDistributedStorageAdmin.class); private final DistributedStorageAdmin admin; @@ -26,12 +25,12 @@ public class CheckedDistributedStorageAdmin implements DistributedStorageAdmin { */ private final boolean checkNamespace; - public CheckedDistributedStorageAdmin(DistributedStorageAdmin admin) { + public CommonDistributedStorageAdmin(DistributedStorageAdmin admin) { this(admin, true); } @SuppressFBWarnings("EI_EXPOSE_REP2") - public CheckedDistributedStorageAdmin(DistributedStorageAdmin admin, boolean checkNamespace) { + public CommonDistributedStorageAdmin(DistributedStorageAdmin admin, boolean checkNamespace) { this.admin = admin; this.checkNamespace = checkNamespace; } diff --git a/core/src/main/java/com/scalar/db/storage/cassandra/CassandraProvider.java b/core/src/main/java/com/scalar/db/storage/cassandra/CassandraProvider.java index 313be499c1..0f5f3c22ae 100644 --- a/core/src/main/java/com/scalar/db/storage/cassandra/CassandraProvider.java +++ b/core/src/main/java/com/scalar/db/storage/cassandra/CassandraProvider.java @@ -3,7 +3,7 @@ import com.scalar.db.api.DistributedStorage; import com.scalar.db.api.DistributedStorageAdmin; import com.scalar.db.api.DistributedStorageProvider; -import com.scalar.db.common.CheckedDistributedStorageAdmin; +import com.scalar.db.common.CommonDistributedStorageAdmin; import com.scalar.db.config.DatabaseConfig; public class CassandraProvider implements DistributedStorageProvider { @@ -19,6 +19,6 @@ public DistributedStorage createDistributedStorage(DatabaseConfig config) { @Override public DistributedStorageAdmin createDistributedStorageAdmin(DatabaseConfig config) { - return new CheckedDistributedStorageAdmin(new CassandraAdmin(config)); + return new CommonDistributedStorageAdmin(new CassandraAdmin(config)); } } diff --git a/core/src/main/java/com/scalar/db/storage/cosmos/CosmosProvider.java b/core/src/main/java/com/scalar/db/storage/cosmos/CosmosProvider.java index a926dded40..9e673be416 100644 --- a/core/src/main/java/com/scalar/db/storage/cosmos/CosmosProvider.java +++ b/core/src/main/java/com/scalar/db/storage/cosmos/CosmosProvider.java @@ -3,7 +3,7 @@ import com.scalar.db.api.DistributedStorage; import com.scalar.db.api.DistributedStorageAdmin; import com.scalar.db.api.DistributedStorageProvider; -import com.scalar.db.common.CheckedDistributedStorageAdmin; +import com.scalar.db.common.CommonDistributedStorageAdmin; import com.scalar.db.config.DatabaseConfig; public class CosmosProvider implements DistributedStorageProvider { @@ -19,6 +19,6 @@ public DistributedStorage createDistributedStorage(DatabaseConfig config) { @Override public DistributedStorageAdmin createDistributedStorageAdmin(DatabaseConfig config) { - return new CheckedDistributedStorageAdmin(new CosmosAdmin(config)); + return new CommonDistributedStorageAdmin(new CosmosAdmin(config)); } } diff --git a/core/src/main/java/com/scalar/db/storage/dynamo/DynamoProvider.java b/core/src/main/java/com/scalar/db/storage/dynamo/DynamoProvider.java index 67c263c164..74877a8186 100644 --- a/core/src/main/java/com/scalar/db/storage/dynamo/DynamoProvider.java +++ b/core/src/main/java/com/scalar/db/storage/dynamo/DynamoProvider.java @@ -3,7 +3,7 @@ import com.scalar.db.api.DistributedStorage; import com.scalar.db.api.DistributedStorageAdmin; import com.scalar.db.api.DistributedStorageProvider; -import com.scalar.db.common.CheckedDistributedStorageAdmin; +import com.scalar.db.common.CommonDistributedStorageAdmin; import com.scalar.db.config.DatabaseConfig; public class DynamoProvider implements DistributedStorageProvider { @@ -20,6 +20,6 @@ public DistributedStorage createDistributedStorage(DatabaseConfig config) { @Override public DistributedStorageAdmin createDistributedStorageAdmin(DatabaseConfig config) { // Set the namespace check to false because DynamoDB does not support namespaces. - return new CheckedDistributedStorageAdmin(new DynamoAdmin(config), false); + return new CommonDistributedStorageAdmin(new DynamoAdmin(config), false); } } diff --git a/core/src/main/java/com/scalar/db/storage/jdbc/JdbcProvider.java b/core/src/main/java/com/scalar/db/storage/jdbc/JdbcProvider.java index 2bc7869a05..e91245b216 100644 --- a/core/src/main/java/com/scalar/db/storage/jdbc/JdbcProvider.java +++ b/core/src/main/java/com/scalar/db/storage/jdbc/JdbcProvider.java @@ -3,7 +3,7 @@ import com.scalar.db.api.DistributedStorage; import com.scalar.db.api.DistributedStorageAdmin; import com.scalar.db.api.DistributedStorageProvider; -import com.scalar.db.common.CheckedDistributedStorageAdmin; +import com.scalar.db.common.CommonDistributedStorageAdmin; import com.scalar.db.config.DatabaseConfig; public class JdbcProvider implements DistributedStorageProvider { @@ -22,6 +22,6 @@ public DistributedStorageAdmin createDistributedStorageAdmin(DatabaseConfig conf // If the database is SQLite, the namespace check is skipped because SQLite does not support // namespaces. boolean isSqlite = JdbcUtils.isSqlite(new JdbcConfig(config)); - return new CheckedDistributedStorageAdmin(new JdbcAdmin(config), !isSqlite); + return new CommonDistributedStorageAdmin(new JdbcAdmin(config), !isSqlite); } } diff --git a/core/src/main/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdmin.java b/core/src/main/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdmin.java index 24d49c2e26..1c520cfe6a 100644 --- a/core/src/main/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdmin.java +++ b/core/src/main/java/com/scalar/db/transaction/jdbc/JdbcTransactionAdmin.java @@ -5,7 +5,7 @@ import com.scalar.db.api.DistributedStorageAdmin; import com.scalar.db.api.DistributedTransactionAdmin; import com.scalar.db.api.TableMetadata; -import com.scalar.db.common.CheckedDistributedStorageAdmin; +import com.scalar.db.common.CommonDistributedStorageAdmin; import com.scalar.db.config.DatabaseConfig; import com.scalar.db.exception.storage.ExecutionException; import com.scalar.db.io.DataType; @@ -26,7 +26,7 @@ public JdbcTransactionAdmin(DatabaseConfig databaseConfig) { // If the database is SQLite, the namespace check is skipped because SQLite does not support // namespaces. boolean isSqlite = JdbcUtils.isSqlite(new JdbcConfig(databaseConfig)); - jdbcAdmin = new CheckedDistributedStorageAdmin(new JdbcAdmin(databaseConfig), !isSqlite); + jdbcAdmin = new CommonDistributedStorageAdmin(new JdbcAdmin(databaseConfig), !isSqlite); } @VisibleForTesting diff --git a/core/src/test/java/com/scalar/db/common/CheckedDistributedStorageAdminTest.java b/core/src/test/java/com/scalar/db/common/CommonDistributedStorageAdminTest.java similarity index 81% rename from core/src/test/java/com/scalar/db/common/CheckedDistributedStorageAdminTest.java rename to core/src/test/java/com/scalar/db/common/CommonDistributedStorageAdminTest.java index 97ac94d245..127b8517cc 100644 --- a/core/src/test/java/com/scalar/db/common/CheckedDistributedStorageAdminTest.java +++ b/core/src/test/java/com/scalar/db/common/CommonDistributedStorageAdminTest.java @@ -16,18 +16,18 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -public class CheckedDistributedStorageAdminTest { +public class CommonDistributedStorageAdminTest { @Mock private DistributedStorageAdmin admin; - private CheckedDistributedStorageAdmin checkedAdmin; + private CommonDistributedStorageAdmin commonDistributedStorageAdmin; @BeforeEach public void setUp() throws Exception { MockitoAnnotations.openMocks(this).close(); // Arrange - checkedAdmin = new CheckedDistributedStorageAdmin(admin); + commonDistributedStorageAdmin = new CommonDistributedStorageAdmin(admin); } @Test @@ -42,7 +42,7 @@ public void createTable_ShouldCallAdminProperly() throws ExecutionException { when(admin.tableExists(namespaceName, tableName)).thenReturn(true); // Act - checkedAdmin.createTable(namespaceName, tableName, tableMetadata, options); + commonDistributedStorageAdmin.createTable(namespaceName, tableName, tableMetadata, options); // Assert verify(admin).createTable(namespaceName, tableName, tableMetadata, options); @@ -66,7 +66,9 @@ public void createTable_ShouldCallAdminProperly() throws ExecutionException { // Act Assert assertThatThrownBy( - () -> checkedAdmin.createTable(namespaceName, tableName, tableMetadata, options)) + () -> + commonDistributedStorageAdmin.createTable( + namespaceName, tableName, tableMetadata, options)) .isInstanceOf(UnsupportedOperationException.class); } @@ -80,7 +82,7 @@ public void repairTable_ShouldCallAdminProperly() throws ExecutionException { Map options = ImmutableMap.of("name", "value"); // Act - checkedAdmin.repairTable(namespaceName, tableName, tableMetadata, options); + commonDistributedStorageAdmin.repairTable(namespaceName, tableName, tableMetadata, options); // Assert verify(admin).repairTable(namespaceName, tableName, tableMetadata, options); @@ -100,7 +102,9 @@ public void repairTable_ShouldCallAdminProperly() throws ExecutionException { // Act Assert assertThatThrownBy( - () -> checkedAdmin.repairTable(namespaceName, tableName, tableMetadata, options)) + () -> + commonDistributedStorageAdmin.repairTable( + namespaceName, tableName, tableMetadata, options)) .isInstanceOf(UnsupportedOperationException.class); } }