mirror of
https://github.com/actiontech/dble.git
synced 2026-05-21 23:29:15 -05:00
inner-1552:add close conf for record heartbeat (#3020)
Signed-off-by: dcy <dcy10000@gmail.com>
This commit is contained in:
@@ -203,9 +203,13 @@ public final class SystemConfig {
|
||||
// For rwSplitUser, Implement stickiness for read and write instances, the default value is 1000ms
|
||||
private long rwStickyTime = 1000;
|
||||
|
||||
|
||||
private boolean closeHeartBeatRecord = false;
|
||||
|
||||
public int getSamplingRate() {
|
||||
return samplingRate;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public void setSamplingRate(int samplingRate) {
|
||||
if (samplingRate >= 0 && samplingRate <= 100) {
|
||||
@@ -1548,6 +1552,15 @@ public final class SystemConfig {
|
||||
", tableByUserByEntryTableSize=" + tableByUserByEntryTableSize +
|
||||
", statisticQueueSize=" + statisticQueueSize +
|
||||
", inSubQueryTransformToJoin=" + inSubQueryTransformToJoin +
|
||||
", closeHeartBeatRecord=" + closeHeartBeatRecord +
|
||||
"]";
|
||||
}
|
||||
|
||||
public boolean isCloseHeartBeatRecord() {
|
||||
return closeHeartBeatRecord;
|
||||
}
|
||||
|
||||
public void setCloseHeartBeatRecord(boolean closeHeartBeatRecord) {
|
||||
this.closeHeartBeatRecord = closeHeartBeatRecord;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.actiontech.dble.backend.heartbeat.MySQLHeartbeat;
|
||||
import com.actiontech.dble.backend.mysql.PacketUtil;
|
||||
import com.actiontech.dble.config.Fields;
|
||||
import com.actiontech.dble.config.ServerConfig;
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.net.mysql.*;
|
||||
import com.actiontech.dble.services.manager.ManagerService;
|
||||
import com.actiontech.dble.statistic.DbInstanceSyncRecorder;
|
||||
@@ -100,10 +101,11 @@ public final class ShowDbInstanceSyn {
|
||||
|
||||
// write rows
|
||||
byte packetId = EOF.getPacketId();
|
||||
|
||||
for (RowDataPacket row : getRows(service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
if (!SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
for (RowDataPacket row : getRows(service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
}
|
||||
}
|
||||
|
||||
// write last eof
|
||||
|
||||
+7
-4
@@ -12,6 +12,7 @@ import com.actiontech.dble.backend.heartbeat.MySQLHeartbeat;
|
||||
import com.actiontech.dble.backend.mysql.PacketUtil;
|
||||
import com.actiontech.dble.config.Fields;
|
||||
import com.actiontech.dble.config.ServerConfig;
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.net.mysql.*;
|
||||
import com.actiontech.dble.route.parser.ManagerParseShow;
|
||||
import com.actiontech.dble.services.manager.ManagerService;
|
||||
@@ -93,10 +94,12 @@ public final class ShowDbInstanceSynDetail {
|
||||
// write rows
|
||||
byte packetId = EOF.getPacketId();
|
||||
|
||||
String name = ManagerParseShow.getWhereParameter(stmt);
|
||||
for (RowDataPacket row : getRows(name, service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
if (!SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
String name = ManagerParseShow.getWhereParameter(stmt);
|
||||
for (RowDataPacket row : getRows(name, service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
}
|
||||
}
|
||||
|
||||
// write last eof
|
||||
|
||||
+6
-3
@@ -13,6 +13,7 @@ import com.actiontech.dble.backend.mysql.PacketUtil;
|
||||
import com.actiontech.dble.config.ErrorCode;
|
||||
import com.actiontech.dble.config.Fields;
|
||||
import com.actiontech.dble.config.ServerConfig;
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.net.mysql.*;
|
||||
import com.actiontech.dble.services.manager.ManagerService;
|
||||
import com.actiontech.dble.statistic.HeartbeatRecorder;
|
||||
@@ -88,9 +89,11 @@ public final class ShowHeartbeatDetail {
|
||||
// write rows
|
||||
byte packetId = EOF.getPacketId();
|
||||
|
||||
for (RowDataPacket row : getRows(name, service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
if (!SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
for (RowDataPacket row : getRows(name, service.getCharset().getResults())) {
|
||||
row.setPacketId(++packetId);
|
||||
buffer = row.write(buffer, service, true);
|
||||
}
|
||||
}
|
||||
|
||||
// write last eof
|
||||
|
||||
@@ -135,6 +135,7 @@ public final class SystemParams {
|
||||
readOnlyParams.add(new ParamInfo("statisticQueueSize", StatisticManager.getInstance().getStatisticQueueSize() + "", "Sets the queue size for statistic, value must not be less than 1 and must be a power of 2,the default value is 4096"));
|
||||
readOnlyParams.add(new ParamInfo("inSubQueryTransformToJoin", sysConfig.isInSubQueryTransformToJoin() + "", "The inSubQuery is transformed into the join ,the default value is false"));
|
||||
readOnlyParams.add(new ParamInfo("rwStickyTime", sysConfig.getRwStickyTime() + "ms", "For rwSplitUser, Implement stickiness for read and write instances, the default value is 1000ms"));
|
||||
readOnlyParams.add(new ParamInfo("closeHeartBeatRecord", sysConfig.isCloseHeartBeatRecord() + "", "close heartbeat record. if closed, `show @@dbinstance.synstatus`,`show @@dbinstance.syndetail`,`show @@heartbeat.detail` will be empty and `show @@heartbeat`'s EXECUTE_TIME will be '-' .The default value is false"));
|
||||
}
|
||||
|
||||
public List<ParamInfo> getVolatileParams() {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package com.actiontech.dble.statistic;
|
||||
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.util.TimeUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -36,10 +37,10 @@ public class DbInstanceSyncRecorder {
|
||||
this.asyncRecords = new LinkedList<>();
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return records.toString();
|
||||
}
|
||||
public void setBySlaveStatus(Map<String, String> resultResult) {
|
||||
if (SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
return;
|
||||
}
|
||||
long time = TimeUtil.currentTimeMillis();
|
||||
try {
|
||||
remove(time);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
package com.actiontech.dble.statistic;
|
||||
|
||||
import com.actiontech.dble.config.model.SystemConfig;
|
||||
import com.actiontech.dble.util.TimeUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -39,10 +40,17 @@ public class HeartbeatRecorder {
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return String.valueOf(avg1) + ',' + avg2 + ',' + avg3;
|
||||
if (SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
return "-";
|
||||
} else {
|
||||
return String.valueOf(avg1) + ',' + avg2 + ',' + avg3;
|
||||
}
|
||||
}
|
||||
|
||||
public void set(long value) {
|
||||
if (SystemConfig.getInstance().isCloseHeartBeatRecord()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long time = TimeUtil.currentTimeMillis();
|
||||
if (value < 0) {
|
||||
|
||||
Reference in New Issue
Block a user