Skip to content
Merged
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
30 changes: 13 additions & 17 deletions src/main/java/org/tikv/common/TiSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.tikv.common.meta.TiTimestamp;
import org.tikv.common.region.RegionManager;
import org.tikv.common.region.RegionStoreClient;
import org.tikv.common.region.RegionStoreClient.RegionStoreClientBuilder;
import org.tikv.common.region.TiRegion;
import org.tikv.common.region.TiStore;
import org.tikv.common.util.*;
Expand Down Expand Up @@ -124,17 +123,13 @@ public static TiSession getInstance(TiConfiguration conf) {
public RawKVClient createRawClient() {
checkIsClosed();

RegionStoreClientBuilder builder =
new RegionStoreClientBuilder(conf, channelFactory, this.getRegionManager(), client);
return new RawKVClient(this, builder);
return new RawKVClient(this, this.getRegionStoreClientBuilder());
}

public KVClient createKVClient() {
checkIsClosed();

RegionStoreClientBuilder builder =
new RegionStoreClientBuilder(conf, channelFactory, this.getRegionManager(), client);
return new KVClient(conf, builder, this);
return new KVClient(this.conf, this.getRegionStoreClientBuilder(), this);
}

public TxnKVClient createTxnClient() {
Expand All @@ -146,18 +141,19 @@ public TxnKVClient createTxnClient() {
public RegionStoreClient.RegionStoreClientBuilder getRegionStoreClientBuilder() {
checkIsClosed();

RegionStoreClient.RegionStoreClientBuilder res = clientBuilder;
if (res == null) {
synchronized (this) {
if (clientBuilder == null) {
clientBuilder =
new RegionStoreClient.RegionStoreClientBuilder(
conf, this.channelFactory, this.getRegionManager(), this.getPDClient());
}
res = clientBuilder;
if (this.clientBuilder != null) {
return this.clientBuilder;
}

// lazily create the clientBuilder for the current TiSession
synchronized (this) {
if (this.clientBuilder == null) {
this.clientBuilder =
new RegionStoreClient.RegionStoreClientBuilder(
this.conf, this.channelFactory, this.getRegionManager(), this.getPDClient());
}
}
return res;
return this.clientBuilder;
}

public ImporterStoreClient.ImporterStoreClientBuilder getImporterRegionStoreClientBuilder() {
Expand Down