Skip to content

Commit

Permalink
Add TRANSACTION_MANAGER_NAME to XXXConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
brfrn169 committed Dec 10, 2023
1 parent 62eb1fa commit 4e30ac3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class JdbcConfig {
private static final Logger logger = LoggerFactory.getLogger(JdbcConfig.class);

public static final String STORAGE_NAME = "jdbc";
public static final String TRANSACTION_MANAGER_NAME = STORAGE_NAME;
public static final String PREFIX = DatabaseConfig.PREFIX + STORAGE_NAME + ".";
public static final String CONNECTION_POOL_MIN_IDLE = PREFIX + "connection_pool.min_idle";
public static final String CONNECTION_POOL_MAX_IDLE = PREFIX + "connection_pool.max_idle";
Expand Down Expand Up @@ -83,7 +84,7 @@ public class JdbcConfig {
public JdbcConfig(DatabaseConfig databaseConfig) {
String storage = databaseConfig.getStorage();
String transactionManager = databaseConfig.getTransactionManager();
if (!storage.equals(STORAGE_NAME) && !transactionManager.equals(STORAGE_NAME)) {
if (!storage.equals(STORAGE_NAME) && !transactionManager.equals(TRANSACTION_MANAGER_NAME)) {
throw new IllegalArgumentException(
DatabaseConfig.STORAGE
+ " or "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
public class ConsensusCommitConfig {
private static final Logger logger = LoggerFactory.getLogger(ConsensusCommitConfig.class);

public static final String TRANSACTION_MANAGER_NAME = "consensus-commit";
public static final String PREFIX = DatabaseConfig.PREFIX + "consensus_commit.";
public static final String ISOLATION_LEVEL = PREFIX + "isolation_level";
public static final String SERIALIZABLE_STRATEGY = PREFIX + "serializable_strategy";
Expand Down Expand Up @@ -58,9 +59,9 @@ public class ConsensusCommitConfig {

public ConsensusCommitConfig(DatabaseConfig databaseConfig) {
String transactionManager = databaseConfig.getTransactionManager();
if (!"consensus-commit".equals(transactionManager)) {
if (!transactionManager.equals(TRANSACTION_MANAGER_NAME)) {
throw new IllegalArgumentException(
DatabaseConfig.TRANSACTION_MANAGER + " should be 'consensus-commit'");
DatabaseConfig.TRANSACTION_MANAGER + " should be '" + TRANSACTION_MANAGER_NAME + "'");
}

if (databaseConfig.getProperties().containsKey("scalar.db.isolation_level")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public class ConsensusCommitProvider implements DistributedTransactionProvider {
@Override
public String getName() {
return "consensus-commit";
return ConsensusCommitConfig.TRANSACTION_MANAGER_NAME;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import com.scalar.db.api.DistributedTransactionProvider;
import com.scalar.db.api.TwoPhaseCommitTransactionManager;
import com.scalar.db.config.DatabaseConfig;
import com.scalar.db.storage.jdbc.JdbcConfig;

public class JdbcTransactionProvider implements DistributedTransactionProvider {
@Override
public String getName() {
return "jdbc";
return JdbcConfig.TRANSACTION_MANAGER_NAME;
}

@Override
Expand Down

0 comments on commit 4e30ac3

Please sign in to comment.