diff --git a/.github/workflows/hubble-ci.yml b/.github/workflows/hubble-ci.yml
index 4cdb18363..c6ae5fd92 100644
--- a/.github/workflows/hubble-ci.yml
+++ b/.github/workflows/hubble-ci.yml
@@ -56,6 +56,11 @@ jobs:
python-version: ${{ matrix.python-version }}
cache: 'pip'
+ - name: Set up Node.js 18.20.8
+ uses: actions/setup-node@v4
+ with:
+ node-version: '18.20.8'
+
# we also should cache python & yarn & downloads to avoid useless work
- name: Cache Maven packages
uses: actions/cache@v3
@@ -65,6 +70,17 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-
+ - name: Cache Node modules
+ uses: actions/cache@v3
+ with:
+ path: |
+ hugegraph-hubble/hubble-fe/node_modules
+ hugegraph-hubble/hubble-fe/node
+ ~/.cache/yarn
+ key: ${{ runner.os }}-node-${{ hashFiles('**/package.json', '**/yarn.lock') }}
+ restore-keys: |
+ ${{ runner.os }}-node-
+
- name: use staged maven repo settings
if: ${{ env.USE_STAGE == 'true' }}
run: |
@@ -78,7 +94,16 @@ jobs:
mvn -e compile -Dmaven.javadoc.skip=true -ntp
- name: Prepare env and service
+ env:
+ CI: false
run: |
+ echo "=== Environment Info ==="
+ node -v
+ yarn -v
+ echo "NODE_OPTIONS: $NODE_OPTIONS"
+ echo "CI: $CI"
+ free -h || true
+ echo "======================="
python -m pip install -r ${TRAVIS_DIR}/requirements.txt
cd hugegraph-hubble
diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
index 091e38fc2..854b97767 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClient.java
@@ -126,6 +126,11 @@ public static HugeClientBuilder builder(String url, String graph) {
return new HugeClientBuilder(url, HugeClientBuilder.DEFAULT_GRAPHSPACE, graph);
}
+ public static HugeClientBuilder builder(String url, String graphSpace, String graph,
+ boolean skipRequiredChecks) {
+ return new HugeClientBuilder(url, graphSpace, graph, skipRequiredChecks);
+ }
+
public HugeClient assignGraph(String graphSpace, String graph) {
this.graphSpaceName = graphSpace;
this.graphName = graph;
diff --git a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java
index 9b9c03b9e..ba5e8160e 100644
--- a/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java
+++ b/hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java
@@ -50,13 +50,24 @@ public class HugeClientBuilder {
/** Set them null by default to keep compatibility with 'timeout' */
private Integer connectTimeout;
private Integer readTimeout;
+ private final boolean skipRequiredChecks;
public HugeClientBuilder(String url, String graphSpace, String graph) {
- E.checkArgument(url != null && !url.isEmpty(),
- "Expect a string value as the url parameter argument, but got: %s", url);
- E.checkArgument(graph != null && !graph.isEmpty(),
- "Expect a string value as the graph name parameter argument, but got: %s",
- graph);
+ this(url, graphSpace, graph, false);
+ }
+
+ public HugeClientBuilder(String url, String graphSpace, String graph,
+ boolean skipRequiredChecks) {
+ this.skipRequiredChecks = skipRequiredChecks;
+
+ if (!skipRequiredChecks) {
+ E.checkArgument(url != null && !url.isEmpty(),
+ "Expect a string value as the url parameter argument, but got: %s", url);
+ E.checkArgument(graph != null && !graph.isEmpty(),
+ "Expect a string value as the graph name parameter argument, but got: %s",
+ graph);
+ }
+
this.url = url;
this.graphSpace = graphSpace;
this.graph = graph;
@@ -76,8 +87,10 @@ public HugeClientBuilder(String url, String graphSpace, String graph) {
}
public HugeClient build() {
- E.checkArgument(this.url != null, "The url parameter can't be null");
- E.checkArgument(this.graph != null, "The graph parameter can't be null");
+ if (!this.skipRequiredChecks) {
+ E.checkArgument(this.url != null, "The url parameter can't be null");
+ E.checkArgument(this.graph != null, "The graph parameter can't be null");
+ }
return new HugeClient(this);
}
diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
index 2fda81d66..50cedf646 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/BaseClientTest.java
@@ -55,6 +55,7 @@ public class BaseClientTest {
protected static final String GRAPH = "hugegraph";
protected static final String USERNAME = "admin";
protected static final String PASSWORD = "pa";
+ //protected static final String PASSWORD = "admin";
protected static final int TIMEOUT = 10;
private static HugeClient client;
diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LoginApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LoginApiTest.java
index e1dc90d7d..ae1f17e03 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LoginApiTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LoginApiTest.java
@@ -26,6 +26,7 @@
import org.apache.hugegraph.testutil.Assert;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
public class LoginApiTest extends AuthApiTest {
diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java
index 24c777807..de4549d04 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/LogoutApiTest.java
@@ -28,6 +28,7 @@
import org.apache.hugegraph.testutil.Whitebox;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
public class LogoutApiTest extends AuthApiTest {
diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java
index 9dcec5a30..b0d8407cb 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/api/auth/TokenApiTest.java
@@ -29,6 +29,7 @@
import org.apache.hugegraph.testutil.Whitebox;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
public class TokenApiTest extends AuthApiTest {
diff --git a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/AuthManagerTest.java b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/AuthManagerTest.java
index 243cb1f17..6b4f82860 100644
--- a/hugegraph-client/src/test/java/org/apache/hugegraph/functional/AuthManagerTest.java
+++ b/hugegraph-client/src/test/java/org/apache/hugegraph/functional/AuthManagerTest.java
@@ -41,6 +41,7 @@
import org.apache.hugegraph.testutil.Assert;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import com.google.common.collect.ImmutableSet;
diff --git a/hugegraph-hubble/README.md b/hugegraph-hubble/README.md
index c9392f5e3..ee18695fe 100644
--- a/hugegraph-hubble/README.md
+++ b/hugegraph-hubble/README.md
@@ -44,16 +44,16 @@ Then use a web browser to access `ip:8088` and you can see the `Hubble` page. Yo
### 2. Clone source code then compile and install
-> Note: Compiling Hubble requires the user’s local environment to have Node.js V16.x and yarn installed.
+> Note: Compiling Hubble requires the user's local environment to have Node.js V18.20.8 and yarn installed.
```bash
apt install curl build-essential
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
-nvm install 16
+nvm install 18.20.8
```
-Then, verify that the installed Node.js version is 16.x (please note that higher Node version may cause conflicts).
+Then, verify that the installed Node.js version is 18.20.8.
```bash
node -v
diff --git a/hugegraph-hubble/hubble-be/pom.xml b/hugegraph-hubble/hubble-be/pom.xml
index 6e81c1691..beb9ed49b 100644
--- a/hugegraph-hubble/hubble-be/pom.xml
+++ b/hugegraph-hubble/hubble-be/pom.xml
@@ -1,5 +1,6 @@
+
+ co.elastic.clients
+ elasticsearch-java
+ ${es.version}
+
org.mybatis.spring.boot
mybatis-spring-boot-starter
- ${mybatis.starter.version}
+ 2.1.0
com.baomidou
mybatis-plus-boot-starter
- ${mybatis.plus.starter.version}
+ 3.3.0
com.h2database
@@ -90,13 +96,29 @@
com.github.ben-manes.caffeine
caffeine
+ 2.8.0
-
+ net.sourceforge.javacsv
+ javacsv
+ 2.0
+
+
+ de.schlichtherle.truelicense
+ truelicense-core
+ 1.33
+
+
+
org.apache.hugegraph
- hugegraph-loader
- ${revision}
+ hugegraph-common
+ 1.5.0
+
+
+ com.baidu.hugegraph
+ hugegraph-core
+
org.apache.logging.log4j
log4j-api
@@ -117,29 +139,105 @@
javassist
org.javassist
+
+
+
+ org.apache.hugegraph
+ hg-pd-client
+ 1.5.0
+
+
+ org.apache.logging.log4j
+ log4j-api
+
+
+ org.apache.logging.log4j
+ log4j-core
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+
+
+
+
+
+ org.apache.hugegraph
+ hugegraph-loader
+ 1.3.0
+
+
+ com.baidu.hugegraph
+ hugegraph-client
+
+
+ com.baidu.hugegraph
+ hg-pd-client
+
+
+ com.baidu.hugegraph
+ hg-pd-grpc
+
+
+ com.baidu.hugegraph
+ hugegraph-core
+
+
+ com.baidu.hugegraph
+ hugegraph-api
+
+
+ org.apache.logging.log4j
+ log4j-api
+
+
+ org.apache.logging.log4j
+ log4j-core
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+
org.eclipse.jetty
jetty-runner
- com.oracle
- ojdbc8
+ hive-exec
+ org.apache.hive
+
+
+
+
+ org.apache.hugegraph
+ hugegraph-client
+ 1.7.0
+
+
- slf4j-log4j12
- org.slf4j
+ com.baidu.hugegraph
+ hugegraph-core
- log4j
- log4j
+ org.apache.logging.log4j
+ log4j-api
- org.jetbrains.kotlin
- kotlin-stdlib
+ org.apache.logging.log4j
+ log4j-core
- com.squareup.okhttp
- okhttp
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+
+
+ org.eclipse.jetty
+ jetty-runner
+
+
+ hive-exec
+ org.apache.hive
@@ -147,20 +245,120 @@
commons-fileupload
commons-fileupload
+ 1.4
+
+
+ org.parboiled
+ parboiled-core
+ 1.2.0
+
+
+ org.apache.hugegraph
+ hugegraph-core
+ 1.3.0
+ compile
+
+
+ org.apache.commons
+ commons-collections4
+ 4.2
+ compile
+
+
+ org.glassfish.jersey.inject
+ jersey-hk2
+ 3.0.3
+
+
+ org.glassfish.hk2
+ hk2-api
+ 3.0.3
+
+
+ org.glassfish.jersey.core
+ jersey-common
+ 3.0.3
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ 3.0.3
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ 3.0.3
+
+
+ com.fasterxml.jackson.jaxrs
+ jackson-jaxrs-base
+
+
+ com.fasterxml.jackson.jaxrs
+ jackson-jaxrs-json-provider
+
+
+
+
+ org.glassfish.jersey.connectors
+ jersey-apache-connector
+ 3.0.3
+
+
+ org.glassfish.jersey.ext
+ jersey-entity-filtering
+ 3.0.3
+
+
-
- com.squareup.okhttp3
- okhttp
+ jakarta.ws.rs
+ jakarta.ws.rs-api
+ 3.0.0
+ compile
+
+
+ commons-configuration
+ commons-configuration
+ 1.10
+
+
+ com.google.protobuf
+ protobuf-java
+ 3.17.3
+
- org.jetbrains.kotlin
- kotlin-stdlib
+ org.apache.hive
+ hive-exec
+ 3.1.3
+ core
+ compile
+
+
+ com.google.guava
+ guava
+
+
+ com.google.protobuf
+ protobuf-java
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+
+
+
- org.jetbrains.kotlin
- kotlin-stdlib-common
+ com.squareup.okhttp3
+ okhttp
+ 4.12.0
@@ -172,12 +370,72 @@
**/UnitTestSuite.java
+ 4.0.0-RC2
+ 3.0.3
+ 3.0.3
+ 3.0.2
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+ ${java.version}
+ ${java.version}
+
+ 500
+
+
+ -Xlint:unchecked
+ --add-modules=java.base
+
+
+
+
+ maven-clean-plugin
+ 3.0.0
+
+
+
+ ${top.level.dir}
+
+ *.tar
+ *.tar.gz
+ *.zip
+ ${final.name}/**
+
+ false
+
+
+ ${final.name}
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.20
+
org.apache.maven.plugins
maven-jar-plugin
@@ -231,6 +489,7 @@
+
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java
index e0c208279..8efe94dff 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/HugeGraphHubble.java
@@ -30,13 +30,18 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.time.ZoneOffset;
+import java.util.TimeZone;
+
@SpringBootApplication
@EnableScheduling
@MapperScan("org.apache.hugegraph.mapper")
public class HugeGraphHubble extends SpringBootServletInitializer {
public static void main(String[] args) {
+ System.out.println("user.dir ==> " + System.getProperty("user.dir"));
initEnv();
+ TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.of("+8")));
SpringApplication.run(HugeGraphHubble.class, args);
}
@@ -53,7 +58,8 @@ public static void initEnv() {
}
@Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
+ protected SpringApplicationBuilder configure(
+ SpringApplicationBuilder builder) {
return builder.sources(this.getClass());
}
}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppName.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppName.java
new file mode 100644
index 000000000..89b6cdc44
--- /dev/null
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppName.java
@@ -0,0 +1,54 @@
+/*
+ *
+ * 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.common;
+
+
+import org.apache.hugegraph.type.define.SerialEnum;
+
+public enum AppName implements SerialEnum {
+ GREMLIN(1, "GREMLIN"),
+
+ VERTEX_UPDATE(2, "VERTEX_UPDATE"),
+
+ EDGE_UPDATE(3, "EDGE_UPDATE")
+ ;
+
+ private final byte code;
+ private final String name;
+
+ static {
+ SerialEnum.register(AppName.class);
+ }
+
+ AppName(int code, String name) {
+ assert code < 256;
+ this.code = (byte) code;
+ this.name = name;
+ }
+
+ @Override
+ public byte code() {
+ return this.code;
+ }
+
+ public String string() {
+ return this.name;
+ }
+
+}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppType.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppType.java
new file mode 100644
index 000000000..9c9db9c6e
--- /dev/null
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/AppType.java
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.common;
+
+
+import org.apache.hugegraph.type.define.SerialEnum;
+
+public enum AppType implements SerialEnum {
+ // 通用功能
+ GENERAL(1, "GENERAL"),
+
+ // 定制功能
+ CUSTOMIZED(2, "CUSTOMIZED"),
+
+ ;
+
+ private final byte code;
+ private final String name;
+
+ static {
+ SerialEnum.register(AppName.class);
+ }
+
+ AppType(int code, String name) {
+ assert code < 256;
+ this.code = (byte) code;
+ this.name = name;
+ }
+
+ @Override
+ public byte code() {
+ return this.code;
+ }
+
+ public String string() {
+ return this.name;
+ }
+
+}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Constant.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Constant.java
index 11afe6a46..cdddf5ab1 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Constant.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Constant.java
@@ -18,13 +18,13 @@
package org.apache.hugegraph.common;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import com.google.common.collect.ImmutableSet;
import java.nio.charset.Charset;
import java.util.Set;
import java.util.regex.Pattern;
-import com.google.common.collect.ImmutableSet;
+import static java.nio.charset.StandardCharsets.UTF_8;
public final class Constant {
@@ -39,12 +39,13 @@ public final class Constant {
public static final String CONFIG_FILE = "hugegraph-hubble.properties";
public static final String CONTROLLER_PACKAGE =
- "org.apache.hugegraph.controller";
+ "com.baidu.hugegraph.controller";
public static final String COOKIE_USER = "user";
public static final String API_V1_1 = "/api/v1.1/";
public static final String API_V1_2 = "/api/v1.2/";
- public static final String API_VERSION = API_V1_2;
+ public static final String API_V1_3 = "/api/v1.3/";
+ public static final String API_VERSION = API_V1_3;
public static final String EDITION_COMMUNITY = "community";
public static final String EDITION_COMMERCIAL = "commercial";
@@ -58,6 +59,8 @@ public final class Constant {
public static final int STATUS_ILLEGAL_GREMLIN = 460;
public static final int STATUS_INTERNAL_ERROR = 500;
+ public static final String TOKEN_KEY = "auth_token";
+
public static final int NO_LIMIT = -1;
public static final Pattern COMMON_NAME_PATTERN = Pattern.compile(
@@ -73,4 +76,6 @@ public final class Constant {
);
public static final String[] LIKE_WILDCARDS = {"%", "_", "^", "[", "]"};
+
+ public static final String BUILT_IN = "neizhianli";
}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Mergeable.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Mergeable.java
index 3fd638bc3..1d9e3e477 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Mergeable.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/Mergeable.java
@@ -19,5 +19,4 @@
package org.apache.hugegraph.common;
public interface Mergeable {
-
}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/OptionType.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/OptionType.java
new file mode 100644
index 000000000..4cf08b09b
--- /dev/null
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/common/OptionType.java
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.common;
+
+
+import org.apache.hugegraph.type.define.SerialEnum;
+
+public enum OptionType implements SerialEnum {
+
+
+ DELETE(1, "DELETE"),
+
+ ADD(2, "ADD"),
+
+ UPDATE(3, "UPDATE"),
+
+ ;
+
+ private final byte code;
+ private final String name;
+
+ static {
+ SerialEnum.register(OptionType.class);
+ }
+
+ OptionType(int code, String name) {
+ assert code < 256;
+ this.code = (byte) code;
+ this.name = name;
+ }
+
+ @Override
+ public byte code() {
+ return this.code;
+ }
+
+ public String string() {
+ return this.name;
+ }
+
+}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/CacheConfig.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/CacheConfig.java
index d41b1e55b..8b367d307 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/CacheConfig.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/CacheConfig.java
@@ -43,7 +43,10 @@ public class CacheConfig {
public enum Caches {
// No used
- GREMLIN_QUERY;
+ GREMLIN_QUERY,
+
+ // es query cached
+ ES_QUERY(DEFAULT_MAXSIZE, 60);
private int maxSize = DEFAULT_MAXSIZE;
private int ttl = DEFAULT_TTL;
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java
index f5e2ae136..27e6e807b 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/HubbleConfig.java
@@ -18,23 +18,19 @@
package org.apache.hugegraph.config;
-import java.io.File;
-
import org.apache.hugegraph.common.Constant;
import org.apache.hugegraph.exception.ExternalException;
import org.apache.hugegraph.options.HubbleOptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import java.io.File;
+
@Configuration
public class HubbleConfig {
- private static final Logger LOG = LoggerFactory.getLogger(HubbleConfig.class);
-
@Autowired
private ApplicationArguments arguments;
@@ -43,7 +39,7 @@ public HugeConfig hugeConfig() {
String[] args = this.arguments.getSourceArgs();
if (args.length > 1) {
throw new ExternalException(
- "HugeGraphHubble accept up to one param as config file");
+ "HugeGraphHubble accept up to one param as config file");
} else if (args.length == 0) {
args = new String[]{Constant.CONFIG_FILE};
}
@@ -59,7 +55,6 @@ public HugeConfig hugeConfig() {
conf = path;
}
} catch (Exception ignored) {
- LOG.error("hugeConfig exception");
}
return new HugeConfig(conf);
}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/IngestionProxyServlet.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/IngestionProxyServlet.java
new file mode 100644
index 000000000..0993b6c8c
--- /dev/null
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/IngestionProxyServlet.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.config;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpVersion;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.message.BasicHttpResponse;
+import org.apache.hugegraph.common.Constant;
+import org.mitre.dsmiley.httpproxy.ProxyServlet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class IngestionProxyServlet extends ProxyServlet {
+ @Override
+ protected String rewriteQueryStringFromRequest(
+ HttpServletRequest servletRequest, String queryString) {
+ String username =
+ (String) servletRequest.getSession().getAttribute("username");
+
+ String requestQueryString = servletRequest.getQueryString();
+
+ if (StringUtils.isEmpty(requestQueryString)) {
+ requestQueryString = String.format("user=%s", username);
+ } else {
+ requestQueryString += String.format("&user=%s", username);
+ }
+
+ return requestQueryString;
+ }
+
+ @Override
+ protected HttpResponse doExecute(HttpServletRequest servletRequest,
+ HttpServletResponse servletResponse,
+ HttpRequest proxyRequest) throws IOException {
+ String username =
+ (String) servletRequest.getSession().getAttribute("username");
+
+ if (username == null) {
+ // check user login
+ HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
+ Constant.STATUS_OK,
+ "{\"status\": 401}");
+
+ response.setEntity(new StringEntity("{\"status\": 401}"));
+
+ return response;
+ }
+
+ return super.doExecute(servletRequest, servletResponse, proxyRequest);
+ }
+}
diff --git a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/JacksonConfig.java b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/JacksonConfig.java
index 4fc2ab300..c8ea6603e 100644
--- a/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/JacksonConfig.java
+++ b/hugegraph-hubble/hubble-be/src/main/java/org/apache/hugegraph/config/JacksonConfig.java
@@ -18,21 +18,21 @@
package org.apache.hugegraph.config;
-import java.io.IOException;
-import java.util.Map;
-
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.module.SimpleModule;
import org.apache.hugegraph.common.Response;
+import org.apache.hugegraph.entity.graph.VertexQueryEntity;
import org.apache.hugegraph.structure.graph.Edge;
import org.apache.hugegraph.structure.graph.Vertex;
import org.springframework.boot.jackson.JsonComponent;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.module.SimpleModule;
+import java.io.IOException;
+import java.util.Map;
@JsonComponent
public class JacksonConfig {
@@ -75,6 +75,11 @@ public void serialize(Vertex vertex, JsonGenerator generator,
writeIdField("id", vertex.id(), generator);
generator.writeStringField("label", vertex.label());
writePropertiesField(vertex.properties(), generator, provider);
+ if (vertex instanceof VertexQueryEntity) {
+ writeStatisticsField(
+ ((VertexQueryEntity) vertex).getStatistics(),
+ generator, provider);
+ }
generator.writeEndObject();
}
}
@@ -98,7 +103,7 @@ public void serialize(Edge edge, JsonGenerator generator,
private static void writeIdField(String fieldName, Object id,
JsonGenerator generator)
- throws IOException {
+ throws IOException {
// Serialize id to string
generator.writeStringField(fieldName, id.toString());
}
@@ -106,7 +111,7 @@ private static void writeIdField(String fieldName, Object id,
private static void writePropertiesField(Map properties,
JsonGenerator generator,
SerializerProvider provider)
- throws IOException {
+ throws IOException {
// Start write properties
generator.writeFieldName("properties");
generator.writeStartObject();
@@ -130,4 +135,32 @@ private static void writePropertiesField(Map properties,
// End wirte properties
generator.writeEndObject();
}
+
+ private static void writeStatisticsField(Map statistics,
+ JsonGenerator generator,
+ SerializerProvider provider)
+ throws IOException {
+ // Start write statistics
+ generator.writeFieldName("statistics");
+ generator.writeStartObject();
+ for (Map.Entry entry : statistics.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ generator.writeFieldName(key);
+ if (value != null) {
+ if (value instanceof Long) {
+ // To avoid javascript loss of long precision
+ generator.writeString(String.valueOf(value));
+ } else {
+ JsonSerializer