Skip to content

Commit ec595ae

Browse files
authored
Add --replication-tables option to the Schema Loader (#2747)
1 parent e7b9795 commit ec595ae

File tree

9 files changed

+712
-218
lines changed

9 files changed

+712
-218
lines changed

core/src/main/java/com/scalar/db/api/ReplicationAdmin.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.scalar.db.common.error.CoreError;
44
import com.scalar.db.exception.storage.ExecutionException;
5-
import java.util.Collections;
65
import java.util.Map;
76

87
/** An administrative interface for the replication feature. */
@@ -31,10 +30,7 @@ default void createReplicationTables(Map<String, String> options) throws Executi
3130
*/
3231
default void createReplicationTables(boolean ifNotExist, Map<String, String> options)
3332
throws ExecutionException {
34-
if (ifNotExist && replicationTablesExist()) {
35-
return;
36-
}
37-
createReplicationTables(options);
33+
throw new UnsupportedOperationException(CoreError.REPLICATION_NOT_ENABLED.buildMessage());
3834
}
3935

4036
/**
@@ -48,10 +44,7 @@ default void createReplicationTables(boolean ifNotExist, Map<String, String> opt
4844
* @throws ExecutionException if the operation fails
4945
*/
5046
default void createReplicationTables(boolean ifNotExist) throws ExecutionException {
51-
if (ifNotExist && replicationTablesExist()) {
52-
return;
53-
}
54-
createReplicationTables(Collections.emptyMap());
47+
throw new UnsupportedOperationException(CoreError.REPLICATION_NOT_ENABLED.buildMessage());
5548
}
5649

5750
/**
@@ -60,7 +53,7 @@ default void createReplicationTables(boolean ifNotExist) throws ExecutionExcepti
6053
* @throws ExecutionException if the operation fails
6154
*/
6255
default void createReplicationTables() throws ExecutionException {
63-
createReplicationTables(Collections.emptyMap());
56+
throw new UnsupportedOperationException(CoreError.REPLICATION_NOT_ENABLED.buildMessage());
6457
}
6558

6659
/**
@@ -83,10 +76,7 @@ default void dropReplicationTables() throws ExecutionException {
8376
* @throws ExecutionException if the operation fails
8477
*/
8578
default void dropReplicationTables(boolean ifExist) throws ExecutionException {
86-
if (ifExist && !replicationTablesExist()) {
87-
return;
88-
}
89-
dropReplicationTables();
79+
throw new UnsupportedOperationException(CoreError.REPLICATION_NOT_ENABLED.buildMessage());
9080
}
9181

9282
/**

core/src/main/java/com/scalar/db/common/error/CoreError.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,7 @@ public enum CoreError implements ScalarDbError {
861861
REPLICATION_NOT_ENABLED(
862862
Category.USER_ERROR,
863863
"0188",
864-
// TODO: Update the message once the licence type is determined.
865-
"The replication feature is not enabled. To use this feature, you must enable it",
864+
"The replication feature is not enabled. To use this feature, you must enable it. Note that this feature is supported only in the ScalarDB Enterprise edition",
866865
"",
867866
""),
868867
DATA_LOADER_IMPORT_TARGET_MISSING(

schema-loader/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ dependencies {
1919
implementation "com.google.code.gson:gson:${gsonVersion}"
2020
implementation "info.picocli:picocli:${picocliVersion}"
2121
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
22+
testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}"
2223
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
2324
testImplementation "org.assertj:assertj-core:${assertjVersion}"
2425
testImplementation "org.mockito:mockito-core:${mockitoVersion}"

0 commit comments

Comments
 (0)