Skip to content

Commit

Permalink
[close tikv#370] make gRPC and TiKV health check configurable (tikv#369)
Browse files Browse the repository at this point in the history
Signed-off-by: Ankita Wagh <awagh@pinterest.com>
  • Loading branch information
humengyu2012 authored and ankita25 committed Dec 14, 2021
1 parent 24c7635 commit 1170503
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
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 @@ -335,8 +335,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 @@ -723,10 +723,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 @@ -38,6 +41,31 @@ public void tiFlashDefaultValueTest() {
public void tiJksDefaultValueTest() {
TiConfiguration conf = TiConfiguration.createRawDefault();
assertFalse(conf.isJksEnable());


@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 testHealthCheckPeriodDurationValue() {
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());
}

@Test
Expand Down

0 comments on commit 1170503

Please sign in to comment.