Skip to content

Commit ccea5b3

Browse files
committed
import hugegraph-rpc component
Change-Id: Ia5fe99a116e7282d7ed34b8bc1d345996c9870a3
1 parent 4c4b770 commit ccea5b3

File tree

14 files changed

+80
-653
lines changed

14 files changed

+80
-653
lines changed

hugegraph-api/pom.xml

Lines changed: 30 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,33 @@
1717
<artifactId>hugegraph-core</artifactId>
1818
<version>${project.version}</version>
1919
</dependency>
20+
21+
<dependency>
22+
<groupId>com.baidu.hugegraph</groupId>
23+
<artifactId>hugegraph-rpc</artifactId>
24+
<version>1.0.0</version>
25+
<exclusions>
26+
<!-- conflict with jraft -->
27+
<exclusion>
28+
<groupId>com.alipay.sofa</groupId>
29+
<artifactId>bolt</artifactId>
30+
</exclusion>
31+
<exclusion>
32+
<groupId>com.alipay.sofa.common</groupId>
33+
<artifactId>sofa-common-tools</artifactId>
34+
</exclusion>
35+
<exclusion>
36+
<groupId>com.alipay.sofa</groupId>
37+
<artifactId>hessian</artifactId>
38+
</exclusion>
39+
<!-- conflict with cassandra-netty/tinkerpop-server -->
40+
<exclusion>
41+
<groupId>io.netty</groupId>
42+
<artifactId>netty-all</artifactId>
43+
</exclusion>
44+
</exclusions>
45+
</dependency>
46+
2047
<dependency>
2148
<groupId>org.apache.tinkerpop</groupId>
2249
<artifactId>gremlin-server</artifactId>
@@ -27,6 +54,7 @@
2754
</exclusion>
2855
</exclusions>
2956
</dependency>
57+
3058
<dependency>
3159
<groupId>org.glassfish.jersey.core</groupId>
3260
<artifactId>jersey-server</artifactId>
@@ -62,11 +90,6 @@
6290
</exclusions>
6391
</dependency>
6492

65-
<dependency>
66-
<groupId>io.dropwizard.metrics</groupId>
67-
<artifactId>metrics-jersey2</artifactId>
68-
</dependency>
69-
7093
<dependency>
7194
<groupId>org.glassfish.grizzly</groupId>
7295
<artifactId>grizzly-http</artifactId>
@@ -88,50 +111,9 @@
88111
<version>2.4.4</version>
89112
</dependency>
90113

91-
<!-- sofa rpc -->
92114
<dependency>
93-
<groupId>com.lmax</groupId>
94-
<artifactId>disruptor</artifactId>
95-
<version>3.3.7</version>
96-
</dependency>
97-
<dependency>
98-
<groupId>com.alipay.sofa</groupId>
99-
<artifactId>sofa-rpc-all</artifactId>
100-
<version>5.7.6</version>
101-
<exclusions>
102-
<exclusion>
103-
<groupId>io.netty</groupId>
104-
<artifactId>netty-all</artifactId>
105-
</exclusion>
106-
<exclusion>
107-
<groupId>org.jboss.resteasy</groupId>
108-
<artifactId>resteasy-client</artifactId>
109-
</exclusion>
110-
<exclusion>
111-
<groupId>com.alipay.sofa</groupId>
112-
<artifactId>bolt</artifactId>
113-
</exclusion>
114-
<exclusion>
115-
<groupId>org.apache.httpcomponents</groupId>
116-
<artifactId>httpcore</artifactId>
117-
</exclusion>
118-
<exclusion>
119-
<groupId>org.apache.httpcomponents</groupId>
120-
<artifactId>httpmime</artifactId>
121-
</exclusion>
122-
<exclusion>
123-
<groupId>com.alipay.sofa.common</groupId>
124-
<artifactId>sofa-common-tools</artifactId>
125-
</exclusion>
126-
<exclusion>
127-
<groupId>org.jboss.logging</groupId>
128-
<artifactId>jboss-logging</artifactId>
129-
</exclusion>
130-
<exclusion>
131-
<groupId>com.alipay.sofa</groupId>
132-
<artifactId>hessian</artifactId>
133-
</exclusion>
134-
</exclusions>
115+
<groupId>io.dropwizard.metrics</groupId>
116+
<artifactId>metrics-jersey2</artifactId>
135117
</dependency>
136118
</dependencies>
137119

hugegraph-api/src/main/java/com/baidu/hugegraph/auth/StandardAuthenticator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import com.baidu.hugegraph.config.CoreOptions;
3232
import com.baidu.hugegraph.config.HugeConfig;
3333
import com.baidu.hugegraph.config.ServerOptions;
34-
import com.baidu.hugegraph.rpc.RpcClientProvider;
34+
import com.baidu.hugegraph.rpc.RpcClientProviderWithAuth;
3535
import com.baidu.hugegraph.util.E;
3636
import com.baidu.hugegraph.util.StringEncoding;
3737

@@ -94,7 +94,8 @@ public void setup(HugeConfig config) {
9494

9595
String remoteUrl = config.get(ServerOptions.AUTH_REMOTE_URL);
9696
if (StringUtils.isNotEmpty(remoteUrl)) {
97-
RpcClientProvider clientProvider = new RpcClientProvider(config);
97+
RpcClientProviderWithAuth clientProvider =
98+
new RpcClientProviderWithAuth(config);
9899
this.graph.switchAuthManager(clientProvider.authManager());
99100
}
100101
}

hugegraph-api/src/main/java/com/baidu/hugegraph/config/ServerOptions.java

Lines changed: 0 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -233,113 +233,6 @@ public static synchronized ServerOptions instance() {
233233
""
234234
);
235235

236-
public static final ConfigOption<Integer> RPC_SERVER_PORT =
237-
new ConfigOption<>(
238-
"rpc.server_port",
239-
"The port bound by rpc server to provide services.",
240-
rangeInt(1, Integer.MAX_VALUE),
241-
8090
242-
);
243-
244-
public static final ConfigOption<String> RPC_SERVER_HOST =
245-
new ConfigOption<>(
246-
"rpc.server_host",
247-
"The hosts/ips bound by rpc server to provide " +
248-
"services.",
249-
disallowEmpty(),
250-
"127.0.0.1"
251-
);
252-
253-
public static final ConfigOption<Integer> RPC_SERVER_TIMEOUT =
254-
new ConfigOption<>(
255-
"rpc.server_timeout",
256-
"The timeout(in seconds) of rpc server execution.",
257-
rangeInt(1, Integer.MAX_VALUE),
258-
30
259-
);
260-
261-
public static final ConfigOption<String> RPC_REMOTE_URL =
262-
new ConfigOption<>(
263-
"rpc.remote_url",
264-
"The remote urls of rpc peers, it can be set to " +
265-
"multiple addresses, which are concat by ','.",
266-
disallowEmpty(),
267-
"127.0.0.1:8090"
268-
);
269-
270-
public static final ConfigOption<Integer> RPC_CLIENT_CONNECT_TIMEOUT =
271-
new ConfigOption<>(
272-
"rpc.client_connect_timeout",
273-
"The timeout(in seconds) of rpc client connect to rpc " +
274-
"server.",
275-
rangeInt(1, Integer.MAX_VALUE),
276-
20
277-
);
278-
279-
public static final ConfigOption<Integer> RPC_CLIENT_RECONNECT_PERIOD =
280-
new ConfigOption<>(
281-
"rpc.client_reconnect_period",
282-
"The period(in seconds) of rpc client reconnect to rpc " +
283-
"server.",
284-
rangeInt(1, Integer.MAX_VALUE),
285-
10
286-
);
287-
288-
public static final ConfigOption<Integer> RPC_CLIENT_READ_TIMEOUT =
289-
new ConfigOption<>(
290-
"rpc.client_read_timeout",
291-
"The timeout(in seconds) of rpc client read from rpc " +
292-
"server.",
293-
rangeInt(1, Integer.MAX_VALUE),
294-
40
295-
);
296-
297-
public static final ConfigOption<Integer> RPC_CLIENT_RETRIES =
298-
new ConfigOption<>(
299-
"rpc.client_retries",
300-
"Failed retry number of rpc client calls to rpc server.",
301-
rangeInt(0, Integer.MAX_VALUE),
302-
3
303-
);
304-
305-
public static final ConfigOption<String> RPC_CLIENT_LOAD_BALANCER =
306-
new ConfigOption<>(
307-
"rpc.client_load_balancer",
308-
"The rpc client uses a load-balancing algorithm to " +
309-
"access multiple rpc servers in one cluster. Default " +
310-
"value is 'consistentHash', means forwording by request " +
311-
"parameters.",
312-
allowValues("random", "localPref", "roundRobin",
313-
"consistentHash", "weightRoundRobin"),
314-
"consistentHash"
315-
);
316-
317-
public static final ConfigOption<String> RPC_PROTOCOL =
318-
new ConfigOption<>(
319-
"rpc.protocol",
320-
"Rpc communication protocol, client and server need to " +
321-
"be specified the same value.",
322-
allowValues("bolt", "rest", "dubbo", "h2c", "http"),
323-
"bolt"
324-
);
325-
326-
public static final ConfigOption<Integer> RPC_CONFIG_ORDER =
327-
new ConfigOption<>(
328-
"rpc.config_order",
329-
"Sofa rpc configuration file loading order, the larger " +
330-
"the more later loading.",
331-
rangeInt(1, Integer.MAX_VALUE),
332-
999
333-
);
334-
335-
public static final ConfigOption<String> RPC_LOGGER_IMPL =
336-
new ConfigOption<>(
337-
"rpc.logger_impl",
338-
"Sofa rpc log implementation class.",
339-
disallowEmpty(),
340-
"com.alipay.sofa.rpc.log.SLF4JLoggerImpl"
341-
);
342-
343236
public static final ConfigOption<String> SSL_KEYSTORE_FILE =
344237
new ConfigOption<>(
345238
"ssl.keystore_file",

hugegraph-api/src/main/java/com/baidu/hugegraph/core/GraphManager.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636

3737
import com.baidu.hugegraph.HugeFactory;
3838
import com.baidu.hugegraph.HugeGraph;
39+
import com.baidu.hugegraph.auth.AuthManager;
3940
import com.baidu.hugegraph.auth.HugeAuthenticator;
4041
import com.baidu.hugegraph.auth.HugeFactoryAuthProxy;
4142
import com.baidu.hugegraph.auth.HugeGraphAuthProxy;
42-
import com.baidu.hugegraph.auth.AuthManager;
4343
import com.baidu.hugegraph.backend.BackendException;
4444
import com.baidu.hugegraph.backend.cache.Cache;
4545
import com.baidu.hugegraph.backend.cache.CacheManager;
@@ -173,13 +173,20 @@ public void close() {
173173
}
174174

175175
private void startRpcServer() {
176+
if (!this.rpcServer.enabled()) {
177+
LOG.info("RpcServer is not enabled, skip starting rpc service");
178+
return;
179+
}
180+
176181
RpcProviderConfig serverConfig = this.rpcServer.config();
177182

183+
// Start auth rpc service if authenticator enabled
178184
if (this.authenticator != null) {
179185
serverConfig.addService(AuthManager.class,
180186
this.authenticator.authManager());
181187
}
182188

189+
// Start graph rpc service if RPC_REMOTE_URL enabled
183190
if (this.rpcClient.enabled()) {
184191
RpcConsumerConfig clientConfig = this.rpcClient.config();
185192

@@ -198,7 +205,11 @@ private void startRpcServer() {
198205
}
199206

200207
private void destroyRpcServer() {
201-
this.rpcServer.destroy();
208+
try {
209+
this.rpcClient.destroy();
210+
} finally {
211+
this.rpcServer.destroy();
212+
}
202213
}
203214

204215
private HugeAuthenticator authenticator() {

hugegraph-api/src/main/java/com/baidu/hugegraph/rpc/RpcClientProvider.java

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)