Skip to content

Commit

Permalink
Merge pull request #209 from 17629354490/master
Browse files Browse the repository at this point in the history
dependency upgrade
  • Loading branch information
gudaoxuri authored Jan 15, 2024
2 parents bd7246a + c61e0c9 commit ed4c9c5
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
# queries: security-extended,security-and-quality
- uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
Expand Down
2 changes: 1 addition & 1 deletion devops/it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<version>3.0.0-RC5</version>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<maven.compiler.encoding>${project.build.sourceEncoding}</maven.compiler.encoding>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
spring:
redis: # Redis配置
host: localhost
port: 6378
database: 0
password: 123456
datasource:
redis: # Redis配置
host: localhost
port: 6378
database: 0
password: 123456

todo:
service:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
spring:
redis: # Redis配置
host: 172.25.208.23
port: 6378
database: 0
password: 123456
datasource:
redis: # Redis配置
host: 172.25.208.23
port: 6378
database: 0
password: 123456

todo:
service:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
spring:
redis: # Redis配置
host: 172.25.208.23
port: 6378
database: 0
password: 123456
datasource:
redis: # Redis配置
host: 172.25.208.23
port: 6378
database: 0
password: 123456

todo:
service:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
spring:
datasource: # DB配置
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
url: jdbc:sqlite:sample.db

dew:
cluster:
Expand Down
6 changes: 2 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,7 @@ <h4 id="framework-quick-start-core-code-instructions"><a class="anchor" href="#f
port: 6379
database: 0
datasource: # DB配置
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
url: jdbc:sqlite:sample.db

todo-compute:
ribbon: # 使用自定义ribbon列表
Expand Down Expand Up @@ -3217,8 +3216,7 @@ <h4 id="测试支持"><a class="anchor" href="#测试支持"></a>3.2.10. 测试
host: 127.0.0.1
port: 6379
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test</code></pre>
url: jdbc:sqlite:sample.db</code></pre>
</div>
</div>
</div>
Expand Down
3 changes: 1 addition & 2 deletions docs/src/main/asciidoc/_chapter/framework/quick-start.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ spring:
port: 6379
database: 0
datasource: # DB配置
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
url: jdbc:sqlite:sample.db
todo-compute:
ribbon: # 使用自定义ribbon列表
Expand Down
3 changes: 1 addition & 2 deletions docs/src/main/asciidoc/_chapter/framework/user-manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,7 @@ spring:
host: 127.0.0.1
port: 6379
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:test
url: jdbc:sqlite:sample.db
----

==== 幂等处理
Expand Down
4 changes: 4 additions & 0 deletions framework/modules/boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
<groupId>group.idealworld.dew</groupId>
<artifactId>test-starter</artifactId>
</dependency>
<dependency>
<groupId>com.ecfront.dew</groupId>
<artifactId>common</artifactId>
</dependency>
</dependencies>

</project>
4 changes: 2 additions & 2 deletions framework/modules/cluster-common-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<artifactId>cluster-common</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,16 @@ public void testHA(ClusterMQ mq) throws InterruptedException {
throw new RuntimeException("Mock Some Error");
}
}));
mockErrorThread.start();
Thread.startVirtualThread(mockErrorThread);
Thread.sleep(1000);
mq.publish("test_ha", "ha_msgA");
waitingOccurError.await();
var jdKVersion = System.getProperty("java.version");
if (!jdKVersion.startsWith("19") && !jdKVersion.startsWith("20") && !jdKVersion.startsWith("21")) {
mockErrorThread.stop();
}
// restart subscribe
CountDownLatch waiting = new CountDownLatch(2);
new Thread(() -> mq.subscribe("test_ha", message -> {
Thread.startVirtualThread(new Thread(() -> mq.subscribe("test_ha", message -> {
LOGGER.info("subscribe new instance: pub_sub_ha>>" + message);
waiting.countDown();
})).start();
})));
Thread.sleep(1000);
mq.publish("test_ha", "ha_msgB");
waiting.await();
Expand Down
4 changes: 2 additions & 2 deletions framework/modules/cluster-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.ecfront.dew.common.DependencyHelper;
import group.idealworld.dew.core.cluster.dto.MessageHeader;
import group.idealworld.dew.core.cluster.ha.ClusterHA;
import group.idealworld.dew.core.cluster.ha.H2ClusterHA;
import group.idealworld.dew.core.cluster.ha.SqliteClusterHA;
import group.idealworld.dew.core.cluster.ha.dto.HAConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -79,7 +79,7 @@ public static void init(String appName, String instId) {
* Output:Header Items
*/
public static void initMqHeader(Function<String, Map<String, Object>> mqGetHeader,
Function<MessageHeader, Map<String, Object>> mqSetHeader) {
Function<MessageHeader, Map<String, Object>> mqSetHeader) {
Cluster.mqGetHeader = mqGetHeader;
Cluster.mqSetHeader = mqSetHeader;
}
Expand All @@ -99,23 +99,13 @@ public static void ha() {
* @param haConfig HA配置信息
*/
public static void ha(HAConfig haConfig) {
if (DependencyHelper.hasDependency("org.h2.jdbcx.JdbcConnectionPool")) {
clusterHA = new H2ClusterHA();
if (DependencyHelper.hasDependency("org.sqlite.javax.SQLiteConnectionPoolDataSource")) {
clusterHA = new SqliteClusterHA();
} else {
LOGGER.warn("Not found HA implementation drives , HA disabled.");
return;
}
try {
if (haConfig.getStoragePath() == null || haConfig.getStoragePath().isEmpty()) {
haConfig.setStoragePath("./");
} else {
if (!haConfig.getStoragePath().endsWith("/")) {
haConfig.setStoragePath(haConfig.getStoragePath() + "/");
}
}
if (haConfig.getStorageName() == null || haConfig.getStorageName().isEmpty()) {
haConfig.setStorageName(applicationName);
}
clusterHA.init(haConfig);
LOGGER.info("HA initialized");
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import group.idealworld.dew.core.cluster.dto.MessageWrap;
import group.idealworld.dew.core.cluster.ha.dto.HAConfig;
import group.idealworld.dew.core.cluster.ha.entity.PrepareCommitMsg;
import org.h2.jdbcx.JdbcConnectionPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sqlite.javax.SQLiteConnectionPoolDataSource;

import java.sql.*;
import java.util.ArrayList;
Expand All @@ -17,15 +17,15 @@
*
* @author gudaoxuri
*/
public class H2ClusterHA implements ClusterHA {
public class SqliteClusterHA implements ClusterHA {

private static final Logger LOGGER = LoggerFactory.getLogger(H2ClusterHA.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SqliteClusterHA.class);

private static JdbcConnectionPool jdbcConnectionPool;
private static SQLiteConnectionPoolDataSource dataSource;

private static boolean update(String sql, Object... params) throws SQLException {
try (Connection conn = jdbcConnectionPool.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
try (Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
for (int i = 1; i <= params.length; i++) {
stmt.setObject(i, params[i - 1]);
}
Expand All @@ -35,8 +35,8 @@ private static boolean update(String sql, Object... params) throws SQLException

private static List<PrepareCommitMsg> queryList(String sql, Object... params) throws SQLException {
ResultSet rs = null;
try (Connection conn = jdbcConnectionPool.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
try (Connection conn = dataSource.getConnection();
PreparedStatement stmt = conn.prepareStatement(sql)) {
for (int i = 1; i <= params.length; i++) {
stmt.setObject(i, params[i - 1]);
}
Expand Down Expand Up @@ -67,11 +67,9 @@ private static List<PrepareCommitMsg> convertResultSetToJob(ResultSet rs) throws

@Override
public void init(HAConfig haConfig) throws SQLException {
String url = "jdbc:h2:" + haConfig.getStoragePath() + haConfig.getStorageName() + ";DB_CLOSE_ON_EXIT=FALSE";
jdbcConnectionPool = JdbcConnectionPool.create(url,
haConfig.getAuthUsername() == null ? "" : haConfig.getAuthUsername(),
haConfig.getAuthPassword() == null ? "" : haConfig.getAuthPassword());
try (Connection conn = jdbcConnectionPool.getConnection(); Statement stmt = conn.createStatement()) {
dataSource = new SQLiteConnectionPoolDataSource();
dataSource.setUrl("jdbc:sqlite:sample.db");
try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement()) {
stmt.execute("CREATE TABLE IF NOT EXISTS MQ_MSG("
+ "ADDR VARCHAR(1024)," + "MSG_ID VARCHAR(32)," + "MSG TEXT," + "CREATED_TIME TIMESTAMP ,"
+ "PRIMARY KEY(MSG_ID)" + ")");
Expand Down
5 changes: 2 additions & 3 deletions framework/modules/dbutils-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<optional>true</optional>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
2 changes: 1 addition & 1 deletion framework/modules/parent-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<version>3.0.0-RC5</version>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>${project.build.sourceEncoding}</project.reporting.outputEncoding>
<maven.compiler.encoding>${project.build.sourceEncoding}</maven.compiler.encoding>
Expand Down

0 comments on commit ed4c9c5

Please sign in to comment.