Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -334,8 +334,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 @@ -716,10 +716,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 @@ -34,6 +37,31 @@ public void tiFlashDefaultValueTest() {
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 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
public void testGrpcIdleTimeoutValue() {
TiConfiguration conf = TiConfiguration.createDefault();
Expand Down