This is an automated email from the ASF dual-hosted git repository.
lujingshang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new f2dac1232dd Narayana can set parameter 'createTable' (#18213)
f2dac1232dd is described below
commit f2dac1232dd37feaa548ae0ba7abd76d225c7250
Author: natehuang <[email protected]>
AuthorDate: Tue Jun 7 14:10:01 2022 +0800
Narayana can set parameter 'createTable' (#18213)
---
.../config/NarayanaConfigurationFileGenerator.java | 8 +++++--
.../NarayanaConfigurationFileGeneratorTest.java | 26 +++++++++++++++++++++-
.../src/main/resources/conf/server.yaml | 3 +++
3 files changed, 34 insertions(+), 3 deletions(-)
diff --git
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-x
[...]
index 394c46ed8a3..4168f1e07f2 100644
---
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
+++
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGenerator.java
@@ -121,24 +121,28 @@ public final class NarayanaConfigurationFileGenerator
implements TransactionConf
String password =
String.valueOf(transactionProps.get("recoveryStorePassword"));
String dataSourceClass =
transactionProps.getProperty("recoveryStoreDataSource");
if (null != url && null != user && null != password && null !=
dataSourceClass) {
- appendJdbcStoreConfiguration(url, user, password, dataSourceClass,
config);
+ appendJdbcStoreConfiguration(url, user, password, dataSourceClass,
transactionProps, config);
}
}
- private void appendJdbcStoreConfiguration(final String jdbcUrl, final
String user, final String password, final String dataSourceClassName, final
NarayanaConfiguration config) {
+ private void appendJdbcStoreConfiguration(final String jdbcUrl, final
String user, final String password, final String dataSourceClassName,
+ final Properties
transactionProps, final NarayanaConfiguration config) {
String jdbcAccessPatten = DynamicDataSourceJDBCAccess.class.getName()
+ ";ClassName=%s;URL=%s;User=%s;Password=%s";
String jdbcAccess = String.format(jdbcAccessPatten,
dataSourceClassName, jdbcUrl, user, password);
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.objectStoreType",
JDBCStore.class.getName()));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.jdbcAccess",
jdbcAccess));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.tablePrefix",
"Action"));
+
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.createTable",
transactionProps.getProperty("createTable", Boolean.TRUE.toString())));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.dropTable",
Boolean.FALSE.toString()));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.stateStore.objectStoreType",
JDBCStore.class.getName()));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.stateStore.jdbcAccess",
jdbcAccess));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.stateStore.tablePrefix",
"stateStore"));
+
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.stateStore.createTable",
transactionProps.getProperty("stateStoreCreateTable",
Boolean.TRUE.toString())));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.stateStore.dropTable",
Boolean.FALSE.toString()));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.communicationStore.objectStoreType",
JDBCStore.class.getName()));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.communicationStore.jdbcAccess",
jdbcAccess));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.communicationStore.tablePrefix",
"Communication"));
+
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.communicationStore.createTable",
transactionProps.getProperty("communicationStoreCreateTable",
Boolean.TRUE.toString())));
config.getEntries().add(createEntry("ObjectStoreEnvironmentBean.communicationStore.dropTable",
Boolean.FALSE.toString()));
}
diff --git
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGeneratorTest.java
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transacti
[...]
index cdf07fef158..0e769e17126 100644
---
a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGeneratorTest.java
+++
b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/test/java/org/apache/shardingsphere/transaction/xa/narayana/config/NarayanaConfigurationFileGeneratorTest.java
@@ -87,7 +87,7 @@ public final class NarayanaConfigurationFileGeneratorTest {
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
InputStream inputStream = new FileInputStream(new
File(ClassLoader.getSystemResource("").getPath(), "jbossts-properties.xml"));
NarayanaConfiguration narayanaConfig = (NarayanaConfiguration)
unmarshaller.unmarshal(inputStream);
- assertThat(narayanaConfig.getEntries().size(), is(29));
+ assertThat(narayanaConfig.getEntries().size(), is(32));
assertCommitOnePhase(narayanaConfig);
assertTransactionSync(narayanaConfig);
assertNodeIdentifier(narayanaConfig);
@@ -107,13 +107,16 @@ public final class NarayanaConfigurationFileGeneratorTest
{
assertJdbcAccess(narayanaConfig);
assertTablePrefix(narayanaConfig);
assertDropTable(narayanaConfig);
+ assertCreateTable(narayanaConfig);
assertStateStoreJdbcAccess(narayanaConfig);
assertStateStoreObjectStoreType(narayanaConfig);
assertStateStoreTablePrefix(narayanaConfig);
assertStateStoreDropTable(narayanaConfig);
+ assertStateStoreCreateTable(narayanaConfig);
assertCommunicationStoreObjectStoreType(narayanaConfig);
assertCommunicationStoreJdbcAccess(narayanaConfig);
assertCommunicationStoreTablePrefix(narayanaConfig);
+ assertCommunicationStoreCreateTable(narayanaConfig);
assertCommunicationStoreDropTable(narayanaConfig);
}
@@ -246,6 +249,13 @@ public final class NarayanaConfigurationFileGeneratorTest {
assertTrue(entry.get().getValue().contains("Action"));
}
+ private void assertCreateTable(final NarayanaConfiguration narayanaConfig)
{
+ Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.createTable".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains(Boolean.TRUE.toString()));
+ }
+
private void assertDropTable(final NarayanaConfiguration narayanaConfig) {
Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.dropTable".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
@@ -274,6 +284,13 @@ public final class NarayanaConfigurationFileGeneratorTest {
assertTrue(entry.get().getValue().contains("stateStore"));
}
+ private void assertStateStoreCreateTable(final NarayanaConfiguration
narayanaConfig) {
+ Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.stateStore.createTable".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains(Boolean.TRUE.toString()));
+ }
+
private void assertStateStoreDropTable(final NarayanaConfiguration
narayanaConfig) {
Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.stateStore.dropTable".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
@@ -302,6 +319,13 @@ public final class NarayanaConfigurationFileGeneratorTest {
assertTrue(entry.get().getValue().contains("Communication"));
}
+ private void assertCommunicationStoreCreateTable(final
NarayanaConfiguration narayanaConfig) {
+ Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.communicationStore.createTable".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains(Boolean.TRUE.toString()));
+ }
+
private void assertCommunicationStoreDropTable(final NarayanaConfiguration
narayanaConfig) {
Optional<NarayanaConfigEntry> entry =
narayanaConfig.getEntries().stream().filter(each ->
"ObjectStoreEnvironmentBean.communicationStore.dropTable".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
diff --git
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
index 1f1592492ba..e111932916d 100644
---
a/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
+++
b/shardingsphere-proxy/shardingsphere-proxy-bootstrap/src/main/resources/conf/server.yaml
@@ -56,6 +56,9 @@
# defaultTimeout: 180
# expiryScanInterval: 12
# periodicRecoveryPeriod: 120
+# createTable: true
+# stateStoreCreateTable: true
+# communicationStoreCreateTable: true
# - !SQL_PARSER
# sqlCommentParseEnabled: true
# sqlStatementCache: