修改配置

This commit is contained in:
wanggeng 2022-01-25 11:19:10 +08:00
parent 668a572fb2
commit 1eabeb4953
3 changed files with 26 additions and 23 deletions

View File

@ -72,7 +72,7 @@ spring:
producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败
# 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。
retries: 0
retries: 3
#procedure要求leader在考虑完成请求之前收到的确认数用于控制发送记录在服务端的持久化其值可以为如下
#acks = 0 如果设置为零,则生产者将不会等待来自服务器的任何确认,该记录将立即添加到套接字缓冲区并视为已发送。在这种情况下,无法保证服务器已收到记录,并且重试配置将不会生效(因为客户端通常不会知道任何故障),为每条记录返回的偏移量始终设置为-1。
#acks = 1 这意味着leader会将记录写入其本地日志但无需等待所有副本服务器的完全确认即可做出回应在这种情况下如果leader在确认记录后立即失败但在将数据复制到所有的副本服务器之前则记录将会丢失。

View File

@ -72,7 +72,7 @@ spring:
producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败
# 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。
retries: 0
retries: 3
#procedure要求leader在考虑完成请求之前收到的确认数用于控制发送记录在服务端的持久化其值可以为如下
#acks = 0 如果设置为零,则生产者将不会等待来自服务器的任何确认,该记录将立即添加到套接字缓冲区并视为已发送。在这种情况下,无法保证服务器已收到记录,并且重试配置将不会生效(因为客户端通常不会知道任何故障),为每条记录返回的偏移量始终设置为-1。
#acks = 1 这意味着leader会将记录写入其本地日志但无需等待所有副本服务器的完全确认即可做出回应在这种情况下如果leader在确认记录后立即失败但在将数据复制到所有的副本服务器之前则记录将会丢失。

View File

@ -59,7 +59,7 @@ public class BaseGridMemberTest {
"`gmt_modified`, " +
"`is_delete`) VALUES (?, ?, ?, ?, ?, '', NULL, NULL, 2, 0, '', '', '0', '0', '', NULL, 1, NULL, NULL, '1', ?, '1', ?, 0);";
// 删除用户拓展属性
private String SQL_DELETE_USER_EXPAND = "DELETE FROM sys_user_expand WHERE user_id = ?";
private String SQL_DELETE_USER_EXPAND = "DELETE FROM sys_user_expand WHERE user_id NOT IN (SELECT user_id FROM sys_user)";
// 用户拓展属性
private String SQL_INSERT_USER_EXPAND = "INSERT INTO sys_user_expand(" +
"`user_id`, " +
@ -78,7 +78,7 @@ public class BaseGridMemberTest {
"`modifier`, " +
"`gmt_modified`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '1', ?, '1', ?);";
// 删除用户角色
private String SQL_DELETE_USER_ROLE = "DELETE FROM sys_role_user WHERE user_id = ?";
private String SQL_DELETE_USER_ROLE = "DELETE FROM sys_role_user WHERE user_id NOT IN (SELECT user_id FROM sys_user)";
// 用户角色
private String SQL_INSERT_USER_ROLE = "INSERT INTO sys_role_user(`role_id`, `user_id`) VALUES(?, ?)";
// 字典
@ -95,6 +95,22 @@ public class BaseGridMemberTest {
}
}
@Test
public void deleteInvalidData() throws SQLException {
Connection connection = DriverManager.getConnection(String.format("jdbc:mysql://%s:%s/db_smart_city_usercenter?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC&nullCatalogMeansCurrent=true", "localhost", 3306), "root", "root");
PreparedStatement deleteUserExpandPS = connection.prepareStatement(SQL_DELETE_USER_EXPAND);
PreparedStatement deleteUserRolePS = connection.prepareStatement(SQL_DELETE_USER_ROLE);
// 删除无效拓展属性
int deleteUserExpandCount = deleteUserExpandPS.executeUpdate();
System.out.println(deleteUserExpandPS);
System.out.println("delete user expand count: " + deleteUserExpandCount);
// 删除无效用户角色
int deleteUserRoleCount = deleteUserRolePS.executeUpdate();
System.out.println(deleteUserRolePS);
System.out.println("delete user role count: " + deleteUserRoleCount);
}
@Test
public void importGridMember() throws SQLException {
long startTime = System.currentTimeMillis();
@ -104,9 +120,9 @@ public class BaseGridMemberTest {
// PreparedStatement
PreparedStatement getUserPS = connection.prepareStatement(SQL_GET_USER);
PreparedStatement insertUserPS = connection.prepareStatement(SQL_INSERT_USER);
PreparedStatement deleteUserExpandPS = connection.prepareStatement(SQL_DELETE_USER_EXPAND);
PreparedStatement insertUserExpandPS = connection.prepareStatement(SQL_INSERT_USER_EXPAND);
PreparedStatement deleteUserRolePS = connection.prepareStatement(SQL_DELETE_USER_ROLE);
PreparedStatement insertUserRolePS = connection.prepareStatement(SQL_INSERT_USER_ROLE);
// 性别字典
@ -147,9 +163,9 @@ public class BaseGridMemberTest {
// 新增用户
saveUserCount += saveUser(insertUserPS, userId, excelGridMember, currentDateTime);
// 新增用户拓展
saveUserExpandCount += saveUserExpand(deleteUserExpandPS, insertUserExpandPS, userId, excelGridMember, currentDateTime, getAreaByCodePS, getAreaByIdPS, sexMaps, educationMaps, politicalMaps);
saveUserExpandCount += saveUserExpand(insertUserExpandPS, userId, excelGridMember, currentDateTime, getAreaByCodePS, getAreaByIdPS, sexMaps, educationMaps, politicalMaps);
// 新增用户角色
saveUserRoleCount += saveUserRole(deleteUserRolePS, insertUserRolePS, userId, gridMemberRoleId);
saveUserRoleCount += saveUserRole(insertUserRolePS, userId, gridMemberRoleId);
}
System.out.println();
@ -305,7 +321,6 @@ public class BaseGridMemberTest {
/**
* 保存用户拓展
*
* @param deleteUserExpandPS
* @param insertUserExpandPS
* @param userId
* @param excelGridMember
@ -313,8 +328,7 @@ public class BaseGridMemberTest {
* @return
* @throws SQLException
*/
private int saveUserExpand(PreparedStatement deleteUserExpandPS,
PreparedStatement insertUserExpandPS,
private int saveUserExpand(PreparedStatement insertUserExpandPS,
String userId,
ExcelGridMember excelGridMember,
String currentDateTime,
@ -323,11 +337,6 @@ public class BaseGridMemberTest {
List<Map<String, Object>> sexMaps,
List<Map<String, Object>> educationMaps,
List<Map<String, Object>> politicalMaps) throws SQLException {
// 删除用户拓展属性
deleteUserExpandPS.setString(1, userId);
System.out.println(deleteUserExpandPS);
deleteUserExpandPS.executeUpdate();
// 新增用户拓展属性
insertUserExpandPS.setString(1, userId);
insertUserExpandPS.setString(2, excelGridMember.getAreaCode());
@ -349,19 +358,13 @@ public class BaseGridMemberTest {
/**
* 新增用户角色
*
* @param deleteUserRolePS
* @param insertUserRolePS
* @param userId
* @param roleId
* @return
* @throws SQLException
*/
private int saveUserRole(PreparedStatement deleteUserRolePS, PreparedStatement insertUserRolePS, String userId, String roleId) throws SQLException {
// 删除用户角色
deleteUserRolePS.setString(1, userId);
System.out.println(deleteUserRolePS);
deleteUserRolePS.executeUpdate();
private int saveUserRole(PreparedStatement insertUserRolePS, String userId, String roleId) throws SQLException {
// 新增用户角色
insertUserRolePS.setString(1, roleId);
insertUserRolePS.setString(2, userId);