6 package com.vesoft.nebula.client.storage;
8 import com.facebook.thrift.TException;
9 import com.facebook.thrift.protocol.TCompactProtocol;
10 import com.facebook.thrift.protocol.THeaderProtocol;
11 import com.facebook.thrift.protocol.TProtocol;
12 import com.facebook.thrift.transport.THeaderTransport;
13 import com.facebook.thrift.transport.TSocket;
14 import com.facebook.thrift.transport.TTransport;
15 import com.facebook.thrift.transport.TTransportException;
16 import com.vesoft.nebula.client.graph.data.CASignedSSLParam;
17 import com.vesoft.nebula.client.graph.data.HostAddress;
18 import com.vesoft.nebula.client.graph.data.SSLParam;
19 import com.vesoft.nebula.client.graph.data.SelfSignedSSLParam;
20 import com.vesoft.nebula.client.graph.exception.IOErrorException;
21 import com.vesoft.nebula.storage.GraphStorageService;
22 import com.vesoft.nebula.storage.ScanEdgeRequest;
23 import com.vesoft.nebula.storage.ScanResponse;
24 import com.vesoft.nebula.storage.ScanVertexRequest;
25 import com.vesoft.nebula.util.SslUtil;
26 import java.io.IOException;
27 import java.io.Serializable;
28 import java.net.InetAddress;
29 import javax.net.ssl.SSLSocketFactory;
33 private static final long serialVersionUID = -3631352515689239788L;
35 protected THeaderTransport transport =
null;
36 protected THeaderProtocol protocol =
null;
38 private GraphStorageService.Client client;
44 SSLParam sslParam)
throws Exception {
45 this.address = address;
46 int newTimeout = timeout <= 0 ? Integer.MAX_VALUE : timeout;
48 SSLSocketFactory sslSocketFactory;
50 sslSocketFactory = SslUtil.getSSLSocketFactoryWithCA((
CASignedSSLParam) sslParam);
57 new THeaderTransport(
new TSocket(
58 sslSocketFactory.createSocket(
59 InetAddress.getByName(address.getHost()).getHostAddress(),
63 }
catch (IOException e) {
67 this.transport =
new THeaderTransport(
new TSocket(
68 InetAddress.getByName(address.getHost()).getHostAddress(),
72 this.transport.open();
74 this.protocol =
new THeaderProtocol(transport);
75 client =
new GraphStorageService.Client(protocol);
80 public ScanResponse scanVertex(ScanVertexRequest request)
throws TException {
81 return client.scanVertex(request);
84 public ScanResponse scanEdge(ScanEdgeRequest request)
throws TException {
85 return client.scanEdge(request);
89 if (transport !=
null && transport.isOpen()) {