Skip to content

Commit

Permalink
import hugegraph-rpc component (#1397)
Browse files Browse the repository at this point in the history
Change-Id: Ia5fe99a116e7282d7ed34b8bc1d345996c9870a3
  • Loading branch information
javeme authored Apr 16, 2021
1 parent d895826 commit acaeb3a
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 653 deletions.
78 changes: 30 additions & 48 deletions hugegraph-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@
<artifactId>hugegraph-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-rpc</artifactId>
<version>1.0.0</version>
<exclusions>
<!-- conflict with jraft -->
<exclusion>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
</exclusion>
<exclusion>
<groupId>com.alipay.sofa.common</groupId>
<artifactId>sofa-common-tools</artifactId>
</exclusion>
<exclusion>
<groupId>com.alipay.sofa</groupId>
<artifactId>hessian</artifactId>
</exclusion>
<!-- conflict with cassandra-netty/tinkerpop-server -->
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-server</artifactId>
Expand All @@ -27,6 +54,7 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
Expand Down Expand Up @@ -62,11 +90,6 @@
</exclusions>
</dependency>

<dependency>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jersey2</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http</artifactId>
Expand All @@ -88,50 +111,9 @@
<version>2.4.4</version>
</dependency>

<!-- sofa rpc -->
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofa-rpc-all</artifactId>
<version>5.7.6</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
</exclusion>
<exclusion>
<groupId>com.alipay.sofa</groupId>
<artifactId>bolt</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</exclusion>
<exclusion>
<groupId>com.alipay.sofa.common</groupId>
<artifactId>sofa-common-tools</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
<exclusion>
<groupId>com.alipay.sofa</groupId>
<artifactId>hessian</artifactId>
</exclusion>
</exclusions>
<groupId>io.dropwizard.metrics</groupId>
<artifactId>metrics-jersey2</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import com.baidu.hugegraph.config.CoreOptions;
import com.baidu.hugegraph.config.HugeConfig;
import com.baidu.hugegraph.config.ServerOptions;
import com.baidu.hugegraph.rpc.RpcClientProvider;
import com.baidu.hugegraph.rpc.RpcClientProviderWithAuth;
import com.baidu.hugegraph.util.E;
import com.baidu.hugegraph.util.StringEncoding;

Expand Down Expand Up @@ -102,7 +102,8 @@ public void setup(HugeConfig config) {

String remoteUrl = config.get(ServerOptions.AUTH_REMOTE_URL);
if (StringUtils.isNotEmpty(remoteUrl)) {
RpcClientProvider clientProvider = new RpcClientProvider(config);
RpcClientProviderWithAuth clientProvider =
new RpcClientProviderWithAuth(config);
this.graph.switchAuthManager(clientProvider.authManager());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,113 +233,6 @@ public static synchronized ServerOptions instance() {
""
);

public static final ConfigOption<Integer> RPC_SERVER_PORT =
new ConfigOption<>(
"rpc.server_port",
"The port bound by rpc server to provide services.",
rangeInt(1, Integer.MAX_VALUE),
8090
);

public static final ConfigOption<String> RPC_SERVER_HOST =
new ConfigOption<>(
"rpc.server_host",
"The hosts/ips bound by rpc server to provide " +
"services.",
disallowEmpty(),
"127.0.0.1"
);

public static final ConfigOption<Integer> RPC_SERVER_TIMEOUT =
new ConfigOption<>(
"rpc.server_timeout",
"The timeout(in seconds) of rpc server execution.",
rangeInt(1, Integer.MAX_VALUE),
30
);

public static final ConfigOption<String> RPC_REMOTE_URL =
new ConfigOption<>(
"rpc.remote_url",
"The remote urls of rpc peers, it can be set to " +
"multiple addresses, which are concat by ','.",
disallowEmpty(),
"127.0.0.1:8090"
);

public static final ConfigOption<Integer> RPC_CLIENT_CONNECT_TIMEOUT =
new ConfigOption<>(
"rpc.client_connect_timeout",
"The timeout(in seconds) of rpc client connect to rpc " +
"server.",
rangeInt(1, Integer.MAX_VALUE),
20
);

public static final ConfigOption<Integer> RPC_CLIENT_RECONNECT_PERIOD =
new ConfigOption<>(
"rpc.client_reconnect_period",
"The period(in seconds) of rpc client reconnect to rpc " +
"server.",
rangeInt(1, Integer.MAX_VALUE),
10
);

public static final ConfigOption<Integer> RPC_CLIENT_READ_TIMEOUT =
new ConfigOption<>(
"rpc.client_read_timeout",
"The timeout(in seconds) of rpc client read from rpc " +
"server.",
rangeInt(1, Integer.MAX_VALUE),
40
);

public static final ConfigOption<Integer> RPC_CLIENT_RETRIES =
new ConfigOption<>(
"rpc.client_retries",
"Failed retry number of rpc client calls to rpc server.",
rangeInt(0, Integer.MAX_VALUE),
3
);

public static final ConfigOption<String> RPC_CLIENT_LOAD_BALANCER =
new ConfigOption<>(
"rpc.client_load_balancer",
"The rpc client uses a load-balancing algorithm to " +
"access multiple rpc servers in one cluster. Default " +
"value is 'consistentHash', means forwording by request " +
"parameters.",
allowValues("random", "localPref", "roundRobin",
"consistentHash", "weightRoundRobin"),
"consistentHash"
);

public static final ConfigOption<String> RPC_PROTOCOL =
new ConfigOption<>(
"rpc.protocol",
"Rpc communication protocol, client and server need to " +
"be specified the same value.",
allowValues("bolt", "rest", "dubbo", "h2c", "http"),
"bolt"
);

public static final ConfigOption<Integer> RPC_CONFIG_ORDER =
new ConfigOption<>(
"rpc.config_order",
"Sofa rpc configuration file loading order, the larger " +
"the more later loading.",
rangeInt(1, Integer.MAX_VALUE),
999
);

public static final ConfigOption<String> RPC_LOGGER_IMPL =
new ConfigOption<>(
"rpc.logger_impl",
"Sofa rpc log implementation class.",
disallowEmpty(),
"com.alipay.sofa.rpc.log.SLF4JLoggerImpl"
);

public static final ConfigOption<String> SSL_KEYSTORE_FILE =
new ConfigOption<>(
"ssl.keystore_file",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

import com.baidu.hugegraph.HugeFactory;
import com.baidu.hugegraph.HugeGraph;
import com.baidu.hugegraph.auth.AuthManager;
import com.baidu.hugegraph.auth.HugeAuthenticator;
import com.baidu.hugegraph.auth.HugeFactoryAuthProxy;
import com.baidu.hugegraph.auth.HugeGraphAuthProxy;
import com.baidu.hugegraph.auth.AuthManager;
import com.baidu.hugegraph.backend.BackendException;
import com.baidu.hugegraph.backend.cache.Cache;
import com.baidu.hugegraph.backend.cache.CacheManager;
Expand Down Expand Up @@ -173,13 +173,20 @@ public void close() {
}

private void startRpcServer() {
if (!this.rpcServer.enabled()) {
LOG.info("RpcServer is not enabled, skip starting rpc service");
return;
}

RpcProviderConfig serverConfig = this.rpcServer.config();

// Start auth rpc service if authenticator enabled
if (this.authenticator != null) {
serverConfig.addService(AuthManager.class,
this.authenticator.authManager());
}

// Start graph rpc service if RPC_REMOTE_URL enabled
if (this.rpcClient.enabled()) {
RpcConsumerConfig clientConfig = this.rpcClient.config();

Expand All @@ -198,7 +205,11 @@ private void startRpcServer() {
}

private void destroyRpcServer() {
this.rpcServer.destroy();
try {
this.rpcClient.destroy();
} finally {
this.rpcServer.destroy();
}
}

private HugeAuthenticator authenticator() {
Expand Down

This file was deleted.

Loading

0 comments on commit acaeb3a

Please sign in to comment.