Skip to content
Closed
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
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<!-- grpc dependencies -->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<artifactId>grpc-netty-shaded</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
Expand All @@ -140,11 +140,13 @@
<artifactId>grpc-services</artifactId>
<version>${grpc.version}</version>
</dependency>
<!--
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${netty.tcnative.version}</version>
</dependency>
-->
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-testing</artifactId>
Expand Down Expand Up @@ -175,7 +177,7 @@
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-grpclb</artifactId>
<artifactId>grpc-netty</artifactId>
</exclusion>
</exclusions>
<version>${jetcd.version}</version>
Expand Down Expand Up @@ -442,18 +444,25 @@
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<relocations>
<!--
<relocation>
<pattern>io.grpc</pattern>
<shadedPattern>org.tikv.shade.io.grpc</shadedPattern>
<excludes>
<exclude>netty.shaded.*</exclude>
</excludes>
</relocation>
-->
<relocation>
<pattern>com.google</pattern>
<shadedPattern>org.tikv.shade.com.google</shadedPattern>
</relocation>
<!--
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>org.tikv.shade.io.netty</shadedPattern>
</relocation>
-->
<relocation>
<pattern>io.opencensus</pattern>
<shadedPattern>org.tikv.shade.io.opencensus</shadedPattern>
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/org/tikv/common/DefaultHostMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@
import com.google.common.annotations.Beta;
import io.etcd.jetcd.ByteSequence;
import io.etcd.jetcd.Client;
import io.etcd.jetcd.KeyValue;
import io.etcd.jetcd.kv.GetResponse;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -52,7 +47,7 @@ private ByteSequence hostToNetworkMappingKey(String host) {

@Beta
private String getMappedHostFromPD(String host) {
ByteSequence hostKey = hostToNetworkMappingKey(host);
/*ByteSequence hostKey = hostToNetworkMappingKey(host);
for (int i = 0; i < 5; i++) {
CompletableFuture<GetResponse> future = etcdClient.getKVClient().get(hostKey);
try {
Expand All @@ -72,7 +67,8 @@ private String getMappedHostFromPD(String host) {
break;
}
}
return host;
return host;*/
return "";
}

public URI getMappedURI(URI uri) {
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/org/tikv/common/PDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public TiConfiguration.ReplicaRead getReplicaRead() {

@Override
public void close() throws InterruptedException {
etcdClient.close();
// etcdClient.close();
if (service != null) {
service.shutdownNow();
}
Expand Down Expand Up @@ -635,16 +635,16 @@ private void initCluster() {
GetMembersResponse resp = null;
List<URI> pdAddrs = getConf().getPdAddrs();
this.pdAddrs = pdAddrs;
this.etcdClient =
Client.builder()
.endpoints(pdAddrs)
.executorService(
Executors.newCachedThreadPool(
new ThreadFactoryBuilder()
.setNameFormat("etcd-conn-manager-pool-%d")
.setDaemon(true)
.build()))
.build();
this.etcdClient = null;
/*Client.builder()
.endpoints(pdAddrs)
.executorService(
Executors.newCachedThreadPool(
new ThreadFactoryBuilder()
.setNameFormat("etcd-conn-manager-pool-%d")
.setDaemon(true)
.build()))
.build();*/
this.hostMapping =
Optional.ofNullable(getConf().getHostMapping())
.orElseGet(() -> new DefaultHostMapping(this.etcdClient, conf.getNetworkMappingName()));
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/tikv/common/util/ChannelFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
package org.tikv.common.util;

import io.grpc.ManagedChannel;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.NettyChannelBuilder;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContextBuilder;
import java.io.File;
import java.net.URI;
import java.util.concurrent.ConcurrentHashMap;
Expand Down