-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into release-vaughn
- Loading branch information
Showing
79 changed files
with
2,289 additions
and
969 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# HugeGraph PD | ||
|
||
HugeGraph PD is a meta server responsible for service discovery, partition information storage, and node scheduling. | ||
|
||
> Note: Currently, the contents of this folder are empty. Starting from revision 1.5.0, the code of HugeGraph PD will be adapted to this location (WIP). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,14 @@ FROM maven:3.9.0-eclipse-temurin-11 AS build | |
|
||
COPY . /pkg | ||
WORKDIR /pkg | ||
RUN mvn package -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l | ||
ARG MAVEN_ARGS | ||
|
||
RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l | ||
|
||
# 2nd stage: runtime env | ||
FROM openjdk:11-slim | ||
# TODO: get the version from the pom.xml | ||
ENV version=1.5.0 | ||
ENV version=1.2.0 | ||
COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-$version/ /hugegraph-server | ||
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# HugeGraph Server | ||
|
||
HugeGraph Server consists of two layers of functionality: the graph engine layer, and the storage layer. | ||
|
||
- Graph Engine Layer: | ||
- REST Server: Provides a RESTful API for querying graph/schema information, supports the [Gremlin](https://tinkerpop.apache.org/gremlin.html) and [Cypher](https://en.wikipedia.org/wiki/Cypher) query languages, and offers APIs for service monitoring and operations. | ||
- Graph Engine: Supports both OLTP and OLAP graph computation types, with OLTP implementing the [Apache TinkerPop3](https://tinkerpop.apache.org) framework. | ||
- Backend Interface: Implements the storage of graph data to the backend. | ||
|
||
- Storage Layer: | ||
- Storage Backend: Supports multiple built-in storage backends (RocksDB/MySQL/HBase/...) and allows users to extend custom backends without modifying the existing source code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
...ugegraph-api/src/main/java/org/apache/hugegraph/api/gremlin/AbstractJerseyRestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with this | ||
* work for additional information regarding copyright ownership. The ASF | ||
* licenses this file to You under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.hugegraph.api.gremlin; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; | ||
import org.apache.http.pool.PoolStats; | ||
import org.apache.hugegraph.util.ExecutorUtil; | ||
import org.glassfish.jersey.apache.connector.ApacheClientProperties; | ||
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; | ||
import org.glassfish.jersey.client.ClientConfig; | ||
import org.glassfish.jersey.client.ClientProperties; | ||
import org.glassfish.jersey.client.JerseyClientBuilder; | ||
import org.glassfish.jersey.message.GZipEncoder; | ||
|
||
import jakarta.ws.rs.client.Client; | ||
import jakarta.ws.rs.client.WebTarget; | ||
|
||
/** | ||
* This class is a simplified class of AbstractRestClient from hugegraph-common. | ||
* For some reason, we replace the rest implementation from jersey to okhttp. | ||
* But GremlinClient still uses jersey-client to forward request, so we copy the old | ||
* AbstractRestClient from hugegraph-common and rename the name to AbstractJerseyRestClient. | ||
* Because we don't need the full feature of AbstractRestClient, so we reduce some useless code. | ||
*/ | ||
public abstract class AbstractJerseyRestClient { | ||
|
||
/** | ||
* Time unit: hour | ||
*/ | ||
private static final long TTL = 24L; | ||
/** | ||
* Time unit: ms | ||
*/ | ||
private static final long IDLE_TIME = 40L * 1000L; | ||
private static final String PROPERTY_MAX_TOTAL = "maxTotal"; | ||
private static final String PROPERTY_MAX_PER_ROUTE = "maxPerRoute"; | ||
private static final String PROPERTY_IDLE_TIME = "idleTime"; | ||
private static final String CONNECTION_MANAGER = ApacheClientProperties.CONNECTION_MANAGER; | ||
|
||
private final Client client; | ||
private final WebTarget webTarget; | ||
private final PoolingHttpClientConnectionManager pool; | ||
private ScheduledExecutorService cleanExecutor; | ||
|
||
public AbstractJerseyRestClient(String url, int timeout, int maxTotal, int maxPerRoute) { | ||
this(url, new ConfigBuilder().configTimeout(timeout) | ||
.configPool(maxTotal, maxPerRoute) | ||
.build()); | ||
} | ||
|
||
public AbstractJerseyRestClient(String url, ClientConfig config) { | ||
this.pool = configConnectionManager(config); | ||
|
||
this.client = JerseyClientBuilder.newClient(config); | ||
this.client.register(GZipEncoder.class); | ||
this.webTarget = this.client.target(url); | ||
|
||
cleanThreadPoolExecutor(config); | ||
} | ||
|
||
private static PoolingHttpClientConnectionManager configConnectionManager(ClientConfig conf) { | ||
/* | ||
* Using httpclient with connection pooling, and configuring the | ||
* jersey connector. But the jersey that has been released in the maven central | ||
* repository seems to have a bug: https://github.com/jersey/jersey/pull/3752 | ||
*/ | ||
PoolingHttpClientConnectionManager pool = | ||
new PoolingHttpClientConnectionManager(TTL, TimeUnit.HOURS); | ||
Integer maxTotal = (Integer) conf.getProperty(PROPERTY_MAX_TOTAL); | ||
Integer maxPerRoute = (Integer) conf.getProperty(PROPERTY_MAX_PER_ROUTE); | ||
|
||
if (maxTotal != null) { | ||
pool.setMaxTotal(maxTotal); | ||
} | ||
if (maxPerRoute != null) { | ||
pool.setDefaultMaxPerRoute(maxPerRoute); | ||
} | ||
conf.property(CONNECTION_MANAGER, pool); | ||
conf.connectorProvider(new ApacheConnectorProvider()); | ||
return pool; | ||
} | ||
|
||
private void cleanThreadPoolExecutor(ClientConfig config) { | ||
this.cleanExecutor = ExecutorUtil.newScheduledThreadPool("conn-clean-worker-%d"); | ||
Number idleTimeProp = (Number) config.getProperty(PROPERTY_IDLE_TIME); | ||
final long idleTime = idleTimeProp == null ? IDLE_TIME : idleTimeProp.longValue(); | ||
final long checkPeriod = idleTime / 2L; | ||
this.cleanExecutor.scheduleWithFixedDelay(() -> { | ||
PoolStats stats = this.pool.getTotalStats(); | ||
int using = stats.getLeased() + stats.getPending(); | ||
if (using > 0) { | ||
// Do clean only when all connections are idle | ||
return; | ||
} | ||
// Release connections when all clients are inactive | ||
this.pool.closeIdleConnections(idleTime, TimeUnit.MILLISECONDS); | ||
this.pool.closeExpiredConnections(); | ||
}, checkPeriod, checkPeriod, TimeUnit.MILLISECONDS); | ||
} | ||
|
||
protected WebTarget getWebTarget() { | ||
return this.webTarget; | ||
} | ||
|
||
public void close() { | ||
try { | ||
if (this.pool != null) { | ||
this.pool.close(); | ||
this.cleanExecutor.shutdownNow(); | ||
} | ||
} finally { | ||
this.client.close(); | ||
} | ||
} | ||
|
||
private static class ConfigBuilder { | ||
|
||
private final ClientConfig config; | ||
|
||
ConfigBuilder() { | ||
this.config = new ClientConfig(); | ||
} | ||
|
||
public ConfigBuilder configTimeout(int timeout) { | ||
this.config.property(ClientProperties.CONNECT_TIMEOUT, timeout); | ||
this.config.property(ClientProperties.READ_TIMEOUT, timeout); | ||
return this; | ||
} | ||
|
||
public ConfigBuilder configPool(int maxTotal, int maxPerRoute) { | ||
this.config.property(PROPERTY_MAX_TOTAL, maxTotal); | ||
this.config.property(PROPERTY_MAX_PER_ROUTE, maxPerRoute); | ||
return this; | ||
} | ||
|
||
public ClientConfig build() { | ||
return this.config; | ||
} | ||
} | ||
} |
Oops, something went wrong.