Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Hubble graph connect error #378

Merged
merged 5 commits into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/workflows/check-dependencies.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: third-party dependencies check

on: [push, pull_request]
on:
push:
branches:
- master
- /^release-.*$/
- /^v[0-9]\..*$/
pull_request:

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/hubble-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
$TRAVIS_DIR/install-hugegraph.sh $SERVER_VERSION

- name: Unit test
run: mvn test -P unit-test -pl hugegraph-hubble -ntp
run: mvn test -P unit-test -pl hugegraph-hubble/hubble-be -ntp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it right?

Copy link
Member Author

@coderzc coderzc Nov 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should perform unit-test of the hubble-be module instead of the hubble module.


- name: API test
env:
Expand Down
31 changes: 6 additions & 25 deletions hugegraph-dist/scripts/dependency/known-dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ annotations-17.0.0.jar
ant-1.9.1.jar
ant-launcher-1.9.1.jar
antlr-runtime-3.5.2.jar
aopalliance-repackaged-2.5.0-b42.jar
aopalliance-repackaged-3.0.1.jar
apache-curator-2.12.0.pom
arrow-format-0.8.0.jar
Expand Down Expand Up @@ -58,7 +57,6 @@ commons-math3-3.1.1.jar
commons-math3-3.4.1.jar
commons-net-3.1.jar
commons-net-3.6.jar
commons-text-1.4.jar
commons-text-1.6.jar
commons-text-1.9.jar
curator-client-2.12.0.jar
Expand Down Expand Up @@ -137,11 +135,8 @@ hive-storage-api-2.7.0.jar
hive-storage-api-2.7.2.jar
hive-upgrade-acid-3.1.3.jar
hive-vector-code-gen-3.1.3.jar
hk2-api-2.5.0-b42.jar
hk2-api-3.0.1.jar
hk2-locator-2.5.0-b42.jar
hk2-locator-3.0.1.jar
hk2-utils-2.5.0-b42.jar
hk2-utils-3.0.1.jar
hppc-0.7.2.jar
htrace-core4-4.1.0-incubating.jar
Expand Down Expand Up @@ -171,9 +166,11 @@ jackson-databind-2.7.8.jar
jackson-databind-2.9.9.3.jar
jackson-datatype-jdk8-2.9.9.jar
jackson-datatype-jsr310-2.9.9.jar
jackson-jaxrs-base-2.9.9.jar
jackson-jaxrs-base-2.14.0-rc1.jar
jackson-jaxrs-json-provider-2.14.0-rc1.jar
jackson-jaxrs-json-provider-2.7.8.jar
jackson-jaxrs-json-provider-2.9.9.jar
jackson-mapper-asl-1.9.13.jar
jackson-module-jaxb-annotations-2.14.0-rc1.jar
jackson-module-jaxb-annotations-2.12.3.jar
Expand All @@ -197,14 +194,11 @@ javax.activation-api-1.2.0.jar
javax.annotation-api-1.3.2.jar
javax.el-3.0.0.jar
javax.el-3.0.1-b12.jar
javax.inject-1.jar
javax.inject-2.5.0-b42.jar
javax.json-1.0.jar
javax.servlet-api-3.1.0.jar
javax.servlet-api-4.0.1.jar
javax.servlet.jsp-2.3.2.jar
javax.servlet.jsp-api-2.3.1.jar
javax.ws.rs-api-2.1.jar
javolution-5.5.1.jar
jaxb-api-2.2.11.jar
jaxb-api-2.3.1.jar
Expand All @@ -215,24 +209,14 @@ jcip-annotations-1.0-1.jar
jcodings-1.0.18.jar
jcommander-1.72.jar
jcommander-1.78.jar
jersey-apache-connector-2.27.jar
jersey-apache-connector-3.0.3.jar
jersey-client-2.27.jar
jersey-client-3.0.3.jar
jersey-common-2.27.jar
jersey-common-3.0.3.jar
jersey-container-servlet-2.27.jar
jersey-container-servlet-3.0.3.jar
jersey-container-servlet-core-2.27.jar
jersey-container-servlet-core-3.0.3.jar
jersey-entity-filtering-2.27.jar
jersey-entity-filtering-3.0.3.jar
jersey-hk2-2.27.jar
jersey-hk2-3.0.3.jar
jersey-media-jaxb-2.27.jar
jersey-media-json-jackson-2.27.jar
jersey-media-json-jackson-3.0.3.jar
jersey-server-2.27.jar
jersey-server-3.0.3.jar
jetty-client-9.4.33.v20201020.jar
jetty-http-9.3.19.v20170502.jar
Expand Down Expand Up @@ -279,7 +263,6 @@ jsp-api-2.1.jar
jsqlparser-3.1.jar
jsr305-3.0.0.jar
jsr305-3.0.1.jar
jsr305-3.0.2.jar
jul-to-slf4j-1.7.28.jar
junit-4.12.jar
junit-4.13.1.jar
Expand Down Expand Up @@ -307,10 +290,10 @@ log4j-1.2.17.jar
log4j-api-2.11.2.jar
log4j-api-2.18.0.jar
log4j-core-2.18.0.jar
log4j-core-2.11.2.jar
log4j-jul-2.11.2.jar
log4j-slf4j-impl-2.18.0.jar
log4j-to-slf4j-2.11.2.jar
logback-classic-1.2.3.jar
logback-core-1.2.3.jar
log4j-slf4j-impl-2.11.2.jar
lombok-1.18.8.jar
lz4-java-1.4.0.jar
lz4-java-1.7.1.jar
Expand Down Expand Up @@ -345,7 +328,6 @@ orc-core-1.5.8.jar
orc-core-1.6.14.jar
orc-shims-1.5.8.jar
orc-shims-1.6.14.jar
osgi-resource-locator-1.0.1.jar
osgi-resource-locator-1.0.3.jar
ow2-asm-6.2.jar
paranamer-2.3.jar
Expand All @@ -362,7 +344,6 @@ sfm-util-8.2.1.jar
slf4j-api-1.7.25.jar
slf4j-api-1.7.28.jar
slf4j-api-1.7.30.jar
slf4j-log4j12-1.7.28.jar
slf4j-log4j12-1.7.30.jar
snakeyaml-1.23.jar
snappy-java-1.0.5.jar
Expand All @@ -379,7 +360,7 @@ spring-boot-starter-actuator-2.1.8.RELEASE.jar
spring-boot-starter-cache-2.1.8.RELEASE.jar
spring-boot-starter-jdbc-2.1.8.RELEASE.jar
spring-boot-starter-json-2.1.8.RELEASE.jar
spring-boot-starter-logging-2.1.8.RELEASE.jar
spring-boot-starter-log4j2-2.1.8.RELEASE.jar
spring-boot-starter-tomcat-2.1.8.RELEASE.jar
spring-boot-starter-web-2.1.8.RELEASE.jar
spring-context-5.1.9.RELEASE.jar
Expand Down
27 changes: 27 additions & 0 deletions hugegraph-hubble/hubble-be/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -63,6 +73,11 @@
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>${version}</version>
</dependency>

<dependency>
<groupId>org.apache.hugegraph</groupId>
Expand Down Expand Up @@ -97,6 +112,18 @@
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
</exclusion>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
</exclusion>
</exclusions>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.apache.hugegraph.config;

import org.apache.hugegraph.handler.CustomInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
Expand All @@ -43,7 +42,6 @@ public void addInterceptors(InterceptorRegistry registry) {
.addPathPatterns("/**");
}

@Bean
Copy link
Member Author

@coderzc coderzc Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'customInterceptor', defined in class path resource [org/apache/hugegraph/config/WebMvcConfig.class], could not be registered. A bean with that name has already been defined in file [/Users/zc/IdeaProjects/incubator-hugegraph-toolchain/hugegraph-hubble/hubble-be/target/classes/org/apache/hugegraph/handler/CustomInterceptor.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


public CustomInterceptor customInterceptor() {
return new CustomInterceptor();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class ExceptionAdvisor {
@ExceptionHandler(InternalException.class)
@ResponseStatus(HttpStatus.OK)
public Response exceptionHandler(InternalException e) {
log.error("InternalException:", e);
String message = this.handleMessage(e.getMessage(), e.args());
return Response.builder()
.status(Constant.STATUS_INTERNAL_ERROR)
Expand All @@ -55,6 +56,7 @@ public Response exceptionHandler(InternalException e) {
@ExceptionHandler(ExternalException.class)
@ResponseStatus(HttpStatus.OK)
public Response exceptionHandler(ExternalException e) {
log.error("ExternalException:", e);
String message = this.handleMessage(e.getMessage(), e.args());
return Response.builder()
.status(e.status())
Expand All @@ -66,6 +68,7 @@ public Response exceptionHandler(ExternalException e) {
@ExceptionHandler(ParameterizedException.class)
@ResponseStatus(HttpStatus.OK)
public Response exceptionHandler(ParameterizedException e) {
log.error("ParameterizedException", e);
String message = this.handleMessage(e.getMessage(), e.args());
return Response.builder()
.status(Constant.STATUS_BAD_REQUEST)
Expand All @@ -77,6 +80,7 @@ public Response exceptionHandler(ParameterizedException e) {
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.OK)
public Response exceptionHandler(Exception e) {
log.error("Exception:", e);
String message = this.handleMessage(e.getMessage(), null);
return Response.builder()
.status(Constant.STATUS_BAD_REQUEST)
Expand All @@ -88,6 +92,7 @@ public Response exceptionHandler(Exception e) {
@ExceptionHandler(IllegalGremlinException.class)
@ResponseStatus(HttpStatus.OK)
public Response exceptionHandler(IllegalGremlinException e) {
log.error("IllegalGremlinException:", e);
String message = this.handleMessage(e.getMessage(), e.args());
return Response.builder()
.status(Constant.STATUS_ILLEGAL_GREMLIN)
Expand Down
75 changes: 75 additions & 0 deletions hugegraph-hubble/hubble-be/src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<configuration status="error">
<Properties>
<property name="log-charset">UTF-8</property>
</Properties>
<appenders>
<Console name="console" target="SYSTEM_OUT">
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout charset="${log-charset}" pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%-5p] %c{1.} %x - %m%n" />
</Console>

<RollingRandomAccessFile name="file" fileName="logs/hugegraph-hubble.log"
filePattern="logs/hugegraph-hubble-%d{yyyy-MM-dd}-%i.log">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout charset="${log-charset}" pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%-5p] %c{1.} %x - %m%n" />
<!-- Trigger after exceeding 1day or 100MB -->
<Policies>
<SizeBasedTriggeringPolicy size="100MB"/>
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
</Policies>
<!-- Keep max 5 files per day & auto delete after over 1GB or 100 files -->
<DefaultRolloverStrategy max="5">
<Delete basePath="logs" maxDepth="2">
<IfFileName glob="*/*.log"/>
<!-- Limit log amount & size -->
<IfAny>
<IfAccumulatedFileSize exceeds="1GB" />
<IfAccumulatedFileCount exceeds="100" />
</IfAny>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
</appenders>
<loggers>
<root level="INFO">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</root>
<logger name="org.apache.cassandra" level="WARN" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</logger>
<logger name="org.apache.hadoop" level="WARN" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</logger>
<logger name="io.netty" level="WARN" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</logger>
<logger name="org.apache.commons" level="WARN" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</logger>

<logger name="org.apache.hugegraph" level="INFO" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
</logger>
</loggers>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.unit;

import org.apache.hugegraph.HugeGraphHubble;
import org.apache.hugegraph.common.Constant;
import org.apache.hugegraph.common.Response;
import org.apache.hugegraph.entity.GraphConnection;
import org.apache.hugegraph.testutil.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@TestPropertySource("classpath:application.properties")
@SpringBootTest(classes = HugeGraphHubble.class, webEnvironment =
SpringBootTest.WebEnvironment.RANDOM_PORT)
public class GraphConnectionTest {

private static final String HOST = "127.0.0.1";
private static final int PORT = 8080;

@Autowired
private TestRestTemplate testRestTemplate;

@Test
public void testGraphConnect() {
GraphConnection entry =
GraphConnection.builder().host(HOST).port(PORT).name("test").graph(
"hugegraph").build();
Response response = testRestTemplate.postForObject(
Constant.API_VERSION + "graph-connections",
entry, Response.class);
Assert.assertEquals(response.getMessage(), 200, response.getStatus());
}
}
Loading