Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[close #370] make gRPC and TiKV health check configurable #369

Merged
merged 7 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/org/tikv/common/TiConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ private static ReplicaRead getReplicaRead(String key) {

private boolean metricsEnable = getBoolean(TIKV_METRICS_ENABLE);
private int metricsPort = getInt(TIKV_METRICS_PORT);
private final int grpcHealthCheckTimeout = getInt(TIKV_GRPC_HEALTH_CHECK_TIMEOUT);
private final int healthCheckPeriodDuration = getInt(TIKV_HEALTH_CHECK_PERIOD_DURATION);
private int grpcHealthCheckTimeout = getInt(TIKV_GRPC_HEALTH_CHECK_TIMEOUT);
private int healthCheckPeriodDuration = getInt(TIKV_HEALTH_CHECK_PERIOD_DURATION);

private final String networkMappingName = get(TIKV_NETWORK_MAPPING_NAME);
private HostMapping hostMapping = null;
Expand Down Expand Up @@ -690,10 +690,18 @@ public long getGrpcHealthCheckTimeout() {
return this.grpcHealthCheckTimeout;
}

public void setGrpcHealthCheckTimeout(int grpcHealthCheckTimeout) {
this.grpcHealthCheckTimeout = grpcHealthCheckTimeout;
}

public long getHealthCheckPeriodDuration() {
return this.healthCheckPeriodDuration;
}

public void setHealthCheckPeriodDuration(int healthCheckPeriodDuration) {
this.healthCheckPeriodDuration = healthCheckPeriodDuration;
}

public boolean isEnableAtomicForCAS() {
return enableAtomicForCAS;
}
Expand Down
28 changes: 28 additions & 0 deletions src/test/java/org/tikv/common/TiConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.tikv.common.ConfigUtils.TIKV_GRPC_HEALTH_CHECK_TIMEOUT;
import static org.tikv.common.ConfigUtils.TIKV_HEALTH_CHECK_PERIOD_DURATION;

import org.junit.Assert;
import org.junit.Test;

public class TiConfigurationTest {
Expand All @@ -33,4 +36,29 @@ public void tiFlashDefaultValueTest() {
TiConfiguration conf = TiConfiguration.createRawDefault();
assertFalse(conf.isTiFlashEnabled());
}

@Test
public void testGrpcHealthCheckTimeoutValue() {
TiConfiguration conf = TiConfiguration.createDefault();
// default value
Assert.assertEquals(
TiConfiguration.getInt(TIKV_GRPC_HEALTH_CHECK_TIMEOUT), conf.getGrpcHealthCheckTimeout());
// new value
int newValue = 100000;
conf.setGrpcHealthCheckTimeout(newValue);
Assert.assertEquals(newValue, conf.getGrpcHealthCheckTimeout());
}

@Test
public void testHealthCheckPeriodDuration() {
TiConfiguration conf = TiConfiguration.createDefault();
// default value
Assert.assertEquals(
TiConfiguration.getInt(TIKV_HEALTH_CHECK_PERIOD_DURATION),
conf.getHealthCheckPeriodDuration());
// new value
int newValue = 100000;
conf.setHealthCheckPeriodDuration(newValue);
Assert.assertEquals(newValue, conf.getHealthCheckPeriodDuration());
}
}