You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by lu...@apache.org on 2022/06/06 10:17:02 UTC
[shardingsphere] branch master updated: remove unused method getRecoverId (#18197)
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 3fcec6c3050 remove unused method getRecoverId (#18197)
3fcec6c3050 is described below
commit 3fcec6c3050cd62c98807f832e7aaa8ec06e32e1
Author: natehuang <na...@tencent.com>
AuthorDate: Mon Jun 6 18:16:54 2022 +0800
remove unused method getRecoverId (#18197)
* can set some parameters of narayana in server.yaml
* remove nodeIdentifier and xaRecoveryNodes in narayana prop
* rm unused method getRecoveryId
---
.../config/NarayanaConfigurationFileGenerator.java | 18 ++++++------
.../NarayanaConfigurationFileGeneratorTest.java | 32 +++++++++++++++++++---
.../src/main/resources/conf/server.yaml | 6 ++++
3 files changed, 44 insertions(+), 12 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 957ec0fc2f0..394c46ed8a3 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
@@ -57,19 +57,19 @@ public final class NarayanaConfigurationFileGenerator implements TransactionConf
public void generateFile(final Properties transactionProps, final InstanceContext instanceContext) {
String instanceId = instanceContext.getInstance().getInstanceDefinition().getInstanceId();
String recoveryId = instanceContext.getInstance().getXaRecoveryIds().isEmpty() ? instanceId : Joiner.on(",").join(instanceContext.getInstance().getXaRecoveryIds());
- NarayanaConfiguration config = createDefaultConfiguration(instanceId, recoveryId);
+ NarayanaConfiguration config = createDefaultConfiguration(instanceId, recoveryId, transactionProps);
if (!transactionProps.isEmpty()) {
appendUserDefinedJdbcStoreConfiguration(transactionProps, config);
}
JAXB.marshal(config, new File(ClassLoader.getSystemResource("").getPath(), "jbossts-properties.xml"));
}
- private NarayanaConfiguration createDefaultConfiguration(final String instanceId, final String recoveryId) {
+ private NarayanaConfiguration createDefaultConfiguration(final String instanceId, final String recoverId, final Properties transactionProps) {
NarayanaConfiguration result = new NarayanaConfiguration();
- result.getEntries().add(createEntry("CoordinatorEnvironmentBean.commitOnePhase", "YES"));
- result.getEntries().add(createEntry("ObjectStoreEnvironmentBean.transactionSync", "NO"));
+ result.getEntries().add(createEntry("CoordinatorEnvironmentBean.commitOnePhase", transactionProps.getOrDefault("commitOnePhase", Boolean.TRUE).toString()));
+ result.getEntries().add(createEntry("ObjectStoreEnvironmentBean.transactionSync", transactionProps.getOrDefault("transactionSync", Boolean.FALSE).toString()));
result.getEntries().add(createEntry("CoreEnvironmentBean.nodeIdentifier", instanceId));
- result.getEntries().add(createEntry("JTAEnvironmentBean.xaRecoveryNodes", recoveryId));
+ result.getEntries().add(createEntry("JTAEnvironmentBean.xaRecoveryNodes", recoverId));
result.getEntries().add(createEntry("JTAEnvironmentBean.xaResourceOrphanFilterClassNames", createXAResourceOrphanFilterClassNames()));
result.getEntries().add(createEntry("CoreEnvironmentBean.socketProcessIdPort", "0"));
result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryModuleClassNames", getRecoveryModuleClassNames()));
@@ -78,9 +78,11 @@ public final class NarayanaConfigurationFileGenerator implements TransactionConf
result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryAddress", ""));
result.getEntries().add(createEntry("RecoveryEnvironmentBean.transactionStatusManagerPort", "0"));
result.getEntries().add(createEntry("RecoveryEnvironmentBean.transactionStatusManagerAddress", ""));
- result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryListener", "NO"));
- result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryBackoffPeriod", "1"));
- result.getEntries().add(createEntry("CoordinatorEnvironmentBean.defaultTimeout", "180"));
+ result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryListener", Boolean.FALSE.toString()));
+ result.getEntries().add(createEntry("RecoveryEnvironmentBean.recoveryBackoffPeriod", transactionProps.getOrDefault("recoveryBackoffPeriod", "1").toString()));
+ result.getEntries().add(createEntry("CoordinatorEnvironmentBean.defaultTimeout", transactionProps.getOrDefault("defaultTimeout", "180").toString()));
+ result.getEntries().add(createEntry("RecoveryEnvironmentBean.expiryScanInterval", transactionProps.getOrDefault("expiryScanInterval", "12").toString()));
+ result.getEntries().add(createEntry("RecoveryEnvironmentBean.periodicRecoveryPeriod", transactionProps.getOrDefault("periodicRecoveryPeriod", "120").toString()));
return result;
}
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 42ce233aaae..cdf07fef158 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(27));
+ assertThat(narayanaConfig.getEntries().size(), is(29));
assertCommitOnePhase(narayanaConfig);
assertTransactionSync(narayanaConfig);
assertNodeIdentifier(narayanaConfig);
@@ -100,6 +100,9 @@ public final class NarayanaConfigurationFileGeneratorTest {
assertTransactionStatusManagerPort(narayanaConfig);
assertRecoveryListener(narayanaConfig);
assertRecoveryBackoffPeriod(narayanaConfig);
+ assertDefaultTimeout(narayanaConfig);
+ assertExpiryScanInterval(narayanaConfig);
+ assertPeriodicRecoveryPeriod(narayanaConfig);
assertObjectStoreType(narayanaConfig);
assertJdbcAccess(narayanaConfig);
assertTablePrefix(narayanaConfig);
@@ -118,14 +121,14 @@ public final class NarayanaConfigurationFileGeneratorTest {
Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "CoordinatorEnvironmentBean.commitOnePhase".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
assertThat(entry.get().getValue().size(), is(1));
- assertTrue(entry.get().getValue().contains("YES"));
+ assertTrue(entry.get().getValue().contains(Boolean.TRUE.toString()));
}
private void assertTransactionSync(final NarayanaConfiguration narayanaConfig) {
Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "ObjectStoreEnvironmentBean.transactionSync".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
assertThat(entry.get().getValue().size(), is(1));
- assertTrue(entry.get().getValue().contains("NO"));
+ assertTrue(entry.get().getValue().contains(Boolean.FALSE.toString()));
}
private void assertNodeIdentifier(final NarayanaConfiguration narayanaConfig) {
@@ -191,7 +194,7 @@ public final class NarayanaConfigurationFileGeneratorTest {
Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "RecoveryEnvironmentBean.recoveryListener".equals(each.getKey())).findFirst();
assertTrue(entry.isPresent());
assertThat(entry.get().getValue().size(), is(1));
- assertTrue(entry.get().getValue().contains("NO"));
+ assertTrue(entry.get().getValue().contains(Boolean.FALSE.toString()));
}
private void assertRecoveryBackoffPeriod(final NarayanaConfiguration narayanaConfig) {
@@ -201,6 +204,27 @@ public final class NarayanaConfigurationFileGeneratorTest {
assertTrue(entry.get().getValue().contains("1"));
}
+ private void assertDefaultTimeout(final NarayanaConfiguration narayanaConfig) {
+ Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "CoordinatorEnvironmentBean.defaultTimeout".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains("180"));
+ }
+
+ private void assertExpiryScanInterval(final NarayanaConfiguration narayanaConfig) {
+ Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "RecoveryEnvironmentBean.expiryScanInterval".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains("12"));
+ }
+
+ private void assertPeriodicRecoveryPeriod(final NarayanaConfiguration narayanaConfig) {
+ Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "RecoveryEnvironmentBean.periodicRecoveryPeriod".equals(each.getKey())).findFirst();
+ assertTrue(entry.isPresent());
+ assertThat(entry.get().getValue().size(), is(1));
+ assertTrue(entry.get().getValue().contains("120"));
+ }
+
private void assertObjectStoreType(final NarayanaConfiguration narayanaConfig) {
Optional<NarayanaConfigEntry> entry = narayanaConfig.getEntries().stream().filter(each -> "ObjectStoreEnvironmentBean.objectStoreType".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 4538a7d230d..1f1592492ba 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
@@ -50,6 +50,12 @@
# recoveryStoreDataSource: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
# recoveryStoreUser: root
# recoveryStorePassword: 12345678
+# commitOnePhase: true
+# transactionSync: false
+# recoveryBackoffPeriod: 1
+# defaultTimeout: 180
+# expiryScanInterval: 12
+# periodicRecoveryPeriod: 120
# - !SQL_PARSER
# sqlCommentParseEnabled: true
# sqlStatementCache: