Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/main/java/org/tikv/common/TiSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ public TiSession(TiConfiguration conf) {
}

this.client = PDClient.createRaw(conf, keyCodec, channelFactory);
if (conf.getApiVersion().isV2() && !StoreVersion.minTiKVVersion(Version.API_V2, client)) {
throw new IllegalStateException("Store version should larger than " + Version.API_V2);
Comment thread
iosmanthus marked this conversation as resolved.
Outdated
}

this.enableGrpcForward = conf.getEnableGrpcForward();
if (this.enableGrpcForward) {
logger.info("enable grpc forward for high available");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/tikv/common/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ public class Version {
public static final String RESOLVE_LOCK_V4 = "4.0.0";

public static final String BATCH_WRITE = "3.0.14";

public static final String API_V2 = "6.1.0";
}
11 changes: 11 additions & 0 deletions src/test/java/org/tikv/common/ApiVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ public void testAccessV1ClusterWithTtl() throws InterruptedException {
Assert.assertNotNull(e);
}
}

@Test
public void testAccessOldVersionClusterWithV2() {
Assume.assumeFalse(minTiKVVersion("6.1.0"));

try (RawKVClient client = createRawClient(ApiVersion.V2)) {
Assert.fail("Should not create V2 client while store version is less than 6.1.0");
} catch (Exception e) {
Assert.assertNotNull(e);
}
}
}