修改配置
This commit is contained in:
parent
668a572fb2
commit
1eabeb4953
@ -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在确认记录后立即失败,但在将数据复制到所有的副本服务器之前,则记录将会丢失。
|
||||
|
@ -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在确认记录后立即失败,但在将数据复制到所有的副本服务器之前,则记录将会丢失。
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user