forked from hugegraph/hugegraph
Compare commits
19 Commits
master
...
cla-assist
| Author | SHA1 | Date |
|---|---|---|
|
|
e19ccb6779 | |
|
|
21ac3c9f9b | |
|
|
df3f7f1708 | |
|
|
6210c8fe1e | |
|
|
c2640f8e64 | |
|
|
6c427e1f8c | |
|
|
cbe774582d | |
|
|
9a78959e29 | |
|
|
365ce7a0a2 | |
|
|
eeb0fa98a2 | |
|
|
95b5f2fe4e | |
|
|
b5b8714b94 | |
|
|
241a9ece43 | |
|
|
6a72b07c8d | |
|
|
87f00cdc4b | |
|
|
027c7300a0 | |
|
|
2ac9db47fc | |
|
|
cf66bf215f | |
|
|
0c22ef16ce |
60
.asf.yaml
60
.asf.yaml
|
|
@ -1,60 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
github:
|
||||
features:
|
||||
# Enable issue management
|
||||
issues: true
|
||||
# Enable wiki for documentation
|
||||
wiki: true
|
||||
# Enable projects for project management boards
|
||||
projects: true
|
||||
description: A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
|
||||
homepage: https://hugegraph.apache.org
|
||||
del_branch_on_merge: true
|
||||
#labels:
|
||||
enabled_merge_buttons:
|
||||
merge: false
|
||||
rebase: true
|
||||
squash: true
|
||||
protected_branches:
|
||||
master:
|
||||
required_status_checks:
|
||||
# strict means "Require branches to be up-to-date before merging".
|
||||
strict: false
|
||||
# contexts are the names of checks that must pass (now only enable the basic check)
|
||||
contexts:
|
||||
- Analyze (java)
|
||||
- CodeQL
|
||||
- check-license
|
||||
- build (memory, 8)
|
||||
- build (memory, 11)
|
||||
required_pull_request_reviews:
|
||||
dismiss_stale_reviews: true
|
||||
require_code_owner_reviews: false
|
||||
required_approving_review_count: 2
|
||||
|
||||
# refer https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features#Git.asf.yamlfeatures-Notificationsettingsforrepositories
|
||||
notifications:
|
||||
# use https://selfserve.apache.org to manage it
|
||||
pullrequests_status: issues@hugegraph.apache.org
|
||||
pullrequests_comment: issues@hugegraph.apache.org
|
||||
pullrequests_bot_dependabot: issues@hugegraph.apache.org
|
||||
issues: issues@hugegraph.apache.org
|
||||
issues_status: dev@hugegraph.apache.org
|
||||
issues_comment: issues@hugegraph.apache.org
|
||||
discussions: dev@hugegraph.apache.org
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
# ignored file when package to source.tgz
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.asf.yaml export-ignore
|
||||
apache-release.sh export-ignore
|
||||
.licenserc.yaml export-ignore
|
||||
.editorconfig export-ignore
|
||||
|
||||
# ignored directory
|
||||
.github/ export-ignore
|
||||
hugegraph-dist/scripts/ export-ignore
|
||||
#assembly/ export-ignore
|
||||
|
|
@ -10,18 +10,18 @@ body:
|
|||
value: >-
|
||||
### Note (特别注意) :
|
||||
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有与您相同
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/hugegraph/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有与您相同
|
||||
/ 相关的问题 (请勿重复提交)
|
||||
|
||||
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
|
||||
会**越快**被响应和处理
|
||||
|
||||
> 3. Issue 标题请保留原有分类标签 (例如:`[Bug]`), 长段描述请增加`空行`并使用`序号`标记, 保持排版清晰
|
||||
> 3. Issue 标题请保持原有模板分类(例如:`[Bug]`), 长段描述之间可以增加`空行`或使用`序号`标记, 保持排版清晰
|
||||
|
||||
> 4. 请在对应的模块提交 issue, 缺乏有效信息 / 长时间 (> 14 天) 没有回复的 issue 可能会被 **关闭**
|
||||
(更新时会再开启)
|
||||
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Bug Type (问题类型)
|
||||
|
|
@ -31,38 +31,36 @@ body:
|
|||
- other exception / error (其他异常报错)
|
||||
- server status (启动/运行异常)
|
||||
- logic (逻辑设计问题)
|
||||
- performance (性能下降)
|
||||
- performence (性能下降)
|
||||
- others (please edit later)
|
||||
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Before submit
|
||||
options:
|
||||
- label: '我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed
|
||||
and searched that there are no similar problems in the historical issue and documents)'
|
||||
- label: 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment (环境信息)
|
||||
description: |
|
||||
> server version could get from [rest-api](https://hugegraph.apache.org/docs/clients/restful-api/) (http://localhost:8080/versions)
|
||||
> server version could get from [rest-api](https://hugegraph.github.io/hugegraph-doc/clients/restful-api/other.html) (http://localhost:8080/versions)
|
||||
value: |
|
||||
- Server Version: 1.0.0 (Apache Release Version)
|
||||
- Server Version: v0.11.x
|
||||
- Backend: RocksDB x nodes, HDD or SSD
|
||||
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
|
||||
- OS: xx CPUs, xx G RAM, Centos 7.x
|
||||
- Data Size: xx vertices, xx edges <!-- (like 1000W 点, 9000W 边) -->
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected & Actual behavior (期望与实际表现)
|
||||
description: |
|
||||
> we can refer [How to create a minimal reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) (如何提供最简的可复现用例)
|
||||
> if possible, please provide **screenshots** / Pic or `GIF` (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
> if possible, please provide screenshots or GIF (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
type the main problem here
|
||||
|
||||
```java
|
||||
|
|
@ -71,7 +69,7 @@ body:
|
|||
```
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Vertex/Edge example (问题点 / 边数据举例)
|
||||
|
|
@ -86,7 +84,7 @@ body:
|
|||
"vertex": { "id": "xxx" }
|
||||
}
|
||||
render: javascript
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ blank_issues_enabled: false
|
|||
|
||||
# 设置提 issue 前的参考文档
|
||||
contact_links:
|
||||
- name: HugeGraph Server Doc (EN/CN)
|
||||
url: https://hugegraph.apache.org/docs/quickstart/hugegraph-server/
|
||||
- name: HugeGraph Server Doc
|
||||
url: https://hugegraph.github.io/hugegraph-doc/quickstart/hugegraph-server.html
|
||||
about: Please search question here before opening a new issue
|
||||
- name: HugeGraph API Doc (EN/CN)
|
||||
url: https://hugegraph.apache.org/docs/clients/
|
||||
- name: HugeGraph API Doc
|
||||
url: https://hugegraph.github.io/hugegraph-doc/clients/hugegraph-api.html
|
||||
about: Please search usage here before opening a new issue
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ body:
|
|||
label: Feature Description (功能描述)
|
||||
description: |
|
||||
> 请简要描述新功能 / 需求的使用场景或上下文, 最好能给个具体的例子说明
|
||||
placeholder: type the feature description here
|
||||
placeholder: type the feature description here
|
||||
validations:
|
||||
required: true
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@ body:
|
|||
value: >-
|
||||
### Note (特别注意) :
|
||||
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有与您相同
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/hugegraph/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有与您相同
|
||||
/ 相关的问题 (请勿重复提交)
|
||||
|
||||
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
|
||||
会**越快**被响应和处理
|
||||
|
||||
> 3. Issue 标题请保留原有分类标签 (例如:`[Bug]`), 长段描述请增加`空行`并使用`序号`标记, 保持排版清晰
|
||||
> 3. Issue 标题请保持原有模板分类(例如:`[Bug]`), 长段描述之间可以增加`空行`或使用`序号`标记, 保持排版清晰
|
||||
|
||||
> 4. 请在对应的模块提交 issue, 缺乏有效信息 / 长时间 (> 14 天) 没有回复的 issue 可能会被 **关闭**
|
||||
(更新时会再开启)
|
||||
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Problem Type (问题类型)
|
||||
|
|
@ -29,40 +29,37 @@ body:
|
|||
- server status (启动/运行异常)
|
||||
- configs (配置项 / 文档相关)
|
||||
- struct / logic (架构 / 逻辑设计问题)
|
||||
- performance (性能优化)
|
||||
- performence (性能优化)
|
||||
- other exception / error (其他异常报错)
|
||||
- others (please edit later)
|
||||
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Before submit
|
||||
options:
|
||||
- label: '我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed
|
||||
and searched that there are no similar problems in the historical issue and documents)'
|
||||
- label: 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment (环境信息)
|
||||
description: |
|
||||
> server version could get from [rest-api](https://hugegraph.apache.org/docs/clients/restful-api/) (http://localhost:8080/versions)
|
||||
> server version could get from [rest-api](https://hugegraph.github.io/hugegraph-doc/clients/restful-api/other.html) (http://localhost:8080/versions)
|
||||
value: |
|
||||
- Server Version: 1.0.0 (Apache Release Version)
|
||||
- Server Version: v0.11.x
|
||||
- Backend: RocksDB x nodes, HDD or SSD
|
||||
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
|
||||
- OS: xx CPUs, xx G RAM, Centos 7.x
|
||||
- Data Size: xx vertices, xx edges <!-- (like 1000W 点, 9000W 边) -->
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Your Question (问题描述)
|
||||
description: |
|
||||
> 图使用 / 配置相关问题,请优先参考 [REST-API 文档](https://hugegraph.apache.org/docs/clients/restful-api/),
|
||||
> 以及 [Server 配置文档](https://hugegraph.apache.org/docs/config/)
|
||||
> if possible, please provide **screenshots** / Pic or `GIF` (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
> 图使用 / 配置相关问题,请优先参考 [REST-API 文档](https://hugegraph.github.io/hugegraph-doc/clients/hugegraph-api.html), 以及 [Server 配置文档](https://hugegraph.github.io/hugegraph-doc/config/config-option.html)
|
||||
> if possible, please provide screenshots or GIF (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
type the main problem here
|
||||
|
||||
```java
|
||||
|
|
@ -71,7 +68,7 @@ body:
|
|||
```
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Vertex/Edge example (问题点 / 边数据举例)
|
||||
|
|
@ -86,7 +83,7 @@ body:
|
|||
"vertex": { "id": "xxx" }
|
||||
}
|
||||
render: javascript
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,124 @@
|
|||
{
|
||||
"signedContributors": [
|
||||
{
|
||||
"name": "imbajin",
|
||||
"id": 17706099,
|
||||
"comment_id": 1066436644,
|
||||
"created_at": "2022-03-14T06:49:22Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1761
|
||||
},
|
||||
{
|
||||
"name": "sunlujing",
|
||||
"id": 54138330,
|
||||
"comment_id": 1066457731,
|
||||
"created_at": "2022-03-14T07:22:22Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1780
|
||||
},
|
||||
{
|
||||
"name": "javeme",
|
||||
"id": 9625821,
|
||||
"comment_id": 1072567496,
|
||||
"created_at": "2022-03-18T16:16:34Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1787
|
||||
},
|
||||
{
|
||||
"name": "zyxxoo",
|
||||
"id": 11863049,
|
||||
"comment_id": 1073482514,
|
||||
"created_at": "2022-03-21T04:48:04Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1784
|
||||
},
|
||||
{
|
||||
"name": "coderzc",
|
||||
"id": 26179648,
|
||||
"comment_id": 1073505703,
|
||||
"created_at": "2022-03-21T05:48:50Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1770
|
||||
},
|
||||
{
|
||||
"name": "jsoref",
|
||||
"id": 2119212,
|
||||
"comment_id": 1080136803,
|
||||
"created_at": "2022-03-28T03:17:48Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1797
|
||||
},
|
||||
{
|
||||
"name": "zhaoliangzl",
|
||||
"id": 25294531,
|
||||
"comment_id": 1080634141,
|
||||
"created_at": "2022-03-28T13:13:41Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1801
|
||||
},
|
||||
{
|
||||
"name": "JackyYangPassion",
|
||||
"id": 13795366,
|
||||
"comment_id": 1080801731,
|
||||
"created_at": "2022-03-28T15:31:47Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1696
|
||||
},
|
||||
{
|
||||
"name": "simon824",
|
||||
"id": 18065113,
|
||||
"comment_id": 1089817068,
|
||||
"created_at": "2022-04-06T04:50:52Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1809
|
||||
},
|
||||
{
|
||||
"name": "seagle-yuan",
|
||||
"id": 13429553,
|
||||
"comment_id": 1091082189,
|
||||
"created_at": "2022-04-07T05:01:24Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1810
|
||||
},
|
||||
{
|
||||
"name": "wuchaojing",
|
||||
"id": 37741352,
|
||||
"comment_id": 1092594374,
|
||||
"created_at": "2022-04-08T08:26:46Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1813
|
||||
},
|
||||
{
|
||||
"name": "yuanbingze",
|
||||
"id": 41111262,
|
||||
"comment_id": 1099863930,
|
||||
"created_at": "2022-04-15T05:20:53Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1810
|
||||
},
|
||||
{
|
||||
"name": "mayelena",
|
||||
"id": 15196165,
|
||||
"comment_id": 1099907683,
|
||||
"created_at": "2022-04-15T07:06:11Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1821
|
||||
},
|
||||
{
|
||||
"name": "z7658329",
|
||||
"id": 5474723,
|
||||
"comment_id": 1100006701,
|
||||
"created_at": "2022-04-15T09:53:06Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1822
|
||||
},
|
||||
{
|
||||
"name": "Linary",
|
||||
"id": 9151831,
|
||||
"comment_id": 1100565418,
|
||||
"created_at": "2022-04-16T04:22:19Z",
|
||||
"repoId": 141376301,
|
||||
"pullRequestNo": 1527
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
name: "3rd-party"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- /^release-.*$/
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-check:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
SCRIPT_DEPENDENCY: hugegraph-dist/scripts/dependency
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
- name: mvn install
|
||||
run: |
|
||||
mvn install -DskipTests=true -ntp
|
||||
- name: generate current dependencies
|
||||
run: |
|
||||
bash $SCRIPT_DEPENDENCY/regenerate_known_dependencies.sh current-dependencies.txt
|
||||
- name: check third dependencies
|
||||
run: |
|
||||
bash $SCRIPT_DEPENDENCY/check_dependencies.sh
|
||||
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@v3
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@v3
|
||||
# Refer: https://github.com/actions/dependency-review-action
|
||||
with:
|
||||
fail-on-severity: low
|
||||
# Action will fail if dependencies don't match the list
|
||||
#allow-licenses: Apache-2.0, MIT
|
||||
#deny-licenses: GPL-3.0, AGPL-1.0, AGPL-3.0, LGPL-2.0, CC-BY-3.0
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: "hugegraph-ci"
|
||||
name: hugegraph ci
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -7,6 +7,8 @@ on:
|
|||
- 'release-*'
|
||||
- 'test-*'
|
||||
pull_request:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
|
@ -24,46 +26,49 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
BACKEND: [ memory, cassandra, scylladb, hbase, rocksdb, mysql, postgresql ]
|
||||
JAVA_VERSION: [ '8', '11' ]
|
||||
BACKEND: [memory, cassandra, scylladb, hbase, rocksdb, mysql, postgresql]
|
||||
JAVA_VERSION: ['8']
|
||||
|
||||
steps:
|
||||
- name: Install JDK ${{ matrix.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: ${{ matrix.JAVA_VERSION }}
|
||||
distribution: 'zulu'
|
||||
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Compile
|
||||
run: |
|
||||
mvn clean compile -U -Dmaven.javadoc.skip=true -ntp
|
||||
mvn compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
|
||||
|
||||
- name: Install JDK 8
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'zulu'
|
||||
- name: Prepare env and service
|
||||
run: |
|
||||
$TRAVIS_DIR/install-backend.sh $BACKEND
|
||||
|
||||
- name: Install JDK ${{ matrix.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v3
|
||||
- name: Init MySQL Env
|
||||
if: ${{ env.BACKEND == 'mysql' }}
|
||||
uses: mirromutth/mysql-action@v1.1
|
||||
with:
|
||||
java-version: ${{ matrix.JAVA_VERSION }}
|
||||
distribution: 'zulu'
|
||||
host port: 3306 # Optional, default value is 3306. The port of host
|
||||
container port: 3306 # Optional, default value is 3306. The port of container
|
||||
character set server: 'utf8mb4' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
|
||||
collation server: 'utf8mb4_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
|
||||
mysql version: '5.7' # Optional, default value is "latest". The version of the MySQL
|
||||
mysql database: 'test' # Optional, default value is "test". The specified database which will be create
|
||||
mysql root password: "******" # Required if "mysql user" is empty, default is empty. The root superuser password
|
||||
#mysql user: 'root' # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Can use secrets, too
|
||||
#mysql password: ${{ secrets.DatabasePassword }} # Required if "mysql user" exists. The password for the "mysql user"
|
||||
|
||||
- name: Run unit test
|
||||
run: |
|
||||
|
|
@ -88,6 +93,6 @@ jobs:
|
|||
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND tinkerpop
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3.0.0
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: ${{ env.REPORT_DIR }}/*.xml
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, release-* ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
# branches: [ master ] # enable in all PR
|
||||
schedule:
|
||||
- cron: '33 0 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '11'
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
name: "License checker"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check-license:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Check License Header
|
||||
uses: apache/skywalking-eyes@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
log: info
|
||||
token: ${{ github.token }}
|
||||
config: .licenserc.yaml
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: License check(RAT)
|
||||
run: |
|
||||
mvn apache-rat:check -ntp
|
||||
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
|
||||
grep "Binaries" merged-rat.txt -C 3 && cat merged-rat.txt
|
||||
|
|
@ -17,27 +17,23 @@ jobs:
|
|||
distribution: 'zulu'
|
||||
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v3
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
mvn clean package -DskipTests -ntp
|
||||
mvn clean package -DskipTests
|
||||
mv "$(find hugegraph-*.tar.gz | head -1)" hugegraph-${TAG_NAME/#v/}.tar.gz
|
||||
|
||||
- name: Rename file
|
||||
if: contains(env.TAG_NAME, "-")
|
||||
run: mv "$(find hugegraph-*.tar.gz | head -1)" hugegraph-${TAG_NAME/#v/}.tar.gz
|
||||
|
||||
- name: Upload to GitHub
|
||||
uses: xresloader/upload-to-github-release@master
|
||||
- uses: xresloader/upload-to-github-release@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: "Mark stale issues and pull requests"
|
||||
name: Mark stale issues and pull requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
|
|
@ -20,8 +20,8 @@ jobs:
|
|||
stale-pr-message: 'Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label'
|
||||
stale-issue-label: 'inactive'
|
||||
stale-pr-label: 'inactive'
|
||||
exempt-issue-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
|
||||
exempt-pr-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
|
||||
exempt-issue-labels: 'feature,bug,enhancement,improvement,wontfix,todo'
|
||||
exempt-pr-labels: 'feature,bug,enhancement,improvement,wontfix,todo'
|
||||
exempt-all-milestones: true
|
||||
|
||||
days-before-issue-stale: 15
|
||||
|
|
@ -29,7 +29,7 @@ jobs:
|
|||
days-before-pr-stale: 30
|
||||
days-before-pr-close: 180
|
||||
operations-per-run: 10
|
||||
start-date: '2017-10-01T00:00:00Z'
|
||||
start-date: '2018-10-01T00:00:00Z'
|
||||
|
||||
exempt-all-assignees: true
|
||||
remove-stale-when-updated: true
|
||||
|
|
|
|||
|
|
@ -1,50 +1,6 @@
|
|||
target/
|
||||
**.db
|
||||
logs/
|
||||
ui
|
||||
node_modules
|
||||
upload-files/
|
||||
demo*
|
||||
gen-java
|
||||
*.class
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
.svn
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
.idea/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
dist/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
**/*.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
*.iml
|
||||
*.iws
|
||||
*.orig
|
||||
*.rej
|
||||
**/.keep
|
||||
|
|
@ -54,32 +10,12 @@ build/
|
|||
*.swp
|
||||
*.log
|
||||
*.pyc
|
||||
|
||||
# maven ignore
|
||||
apache-hugegraph-incubating-*/
|
||||
output/
|
||||
*.war
|
||||
*.zip
|
||||
*.tar
|
||||
*.tar.gz*
|
||||
tree.txt
|
||||
*.versionsBackup
|
||||
.flattened-pom.xml
|
||||
|
||||
|
||||
# eclipse ignore
|
||||
.settings/
|
||||
|
||||
# temp ignore
|
||||
*.cache
|
||||
*.diff
|
||||
*.patch
|
||||
*.tmp
|
||||
|
||||
# system ignore
|
||||
Thumbs.db
|
||||
hs_err_pid*
|
||||
# mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
# blueJ files
|
||||
*.ctxt
|
||||
.idea
|
||||
.svn
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
target
|
||||
gen-java
|
||||
build
|
||||
node*
|
||||
|
|
|
|||
103
.licenserc.yaml
103
.licenserc.yaml
|
|
@ -1,103 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
header: # `header` section is configurations for source codes license header.
|
||||
license:
|
||||
spdx-id: Apache-2.0 # the spdx id of the license, it's convenient when your license is standard SPDX license.
|
||||
copyright-owner: Apache Software Foundation # the copyright owner to replace the [owner] in the `spdx-id` template.
|
||||
content: | # `license` will be used as the content when `fix` command needs to insert a license header.
|
||||
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.
|
||||
# `pattern` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
|
||||
pattern: |
|
||||
Licensed to the Apache Software Foundation under one or more contributor
|
||||
license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright
|
||||
ownership. The Apache Software Foundation 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.
|
||||
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
|
||||
- '**'
|
||||
|
||||
paths-ignore: # `paths-ignore` are the path list that will be ignored by license-eye.
|
||||
- '.gitignore'
|
||||
- '.gitattributes'
|
||||
- 'LICENSE'
|
||||
- 'NOTICE'
|
||||
- 'DISCLAIMER'
|
||||
- '**/*.versionsBackup'
|
||||
- '**/*.versionsBackup'
|
||||
- '**/*.proto'
|
||||
- '**/*.log'
|
||||
- '**/*.txt'
|
||||
- '**/*.json'
|
||||
- '**/*.conf'
|
||||
- '**/*.map'
|
||||
- '**/*.properties'
|
||||
- '**/RaftRequests.java'
|
||||
- 'dist/**/*'
|
||||
- 'hugegraph-dist'
|
||||
- '**/assembly/static/bin/hugegraph.service'
|
||||
- 'scripts/dev/reviewers'
|
||||
- 'scripts/dev/reviewers'
|
||||
- '**/*.md'
|
||||
- '**/dependency-reduced-pom.xml'
|
||||
- '**/logs/*.log'
|
||||
- '**/META-INF/**/*'
|
||||
- '**/target/*'
|
||||
- 'style/*'
|
||||
- 'ChangeLog'
|
||||
- 'CONFIG.ini'
|
||||
- 'GROUPS'
|
||||
- 'OWNERS'
|
||||
- '.github/**/*'
|
||||
- '**/*.iml'
|
||||
- '**/*.iws'
|
||||
- '**/*.ipr'
|
||||
- '**/META-INF/MANIFEST.MF'
|
||||
- '.repository/**'
|
||||
- '**/.flattened-pom.xml'
|
||||
- 'hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/SnowflakeIdGenerator.java'
|
||||
- '**/optimize/HugeScriptTraversal.java'
|
||||
- '**/type/Nameable.java'
|
||||
- '**/define/Cardinality.java'
|
||||
- '**/util/StringEncoding.java'
|
||||
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java'
|
||||
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java'
|
||||
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
|
||||
|
||||
# license-location-threshold specifies the index threshold where the license header can be located,
|
||||
# after all, a "header" cannot be TOO far from the file start.
|
||||
license-location-threshold: 80
|
||||
|
|
@ -2,17 +2,17 @@
|
|||
|
||||
## Abstract
|
||||
|
||||
HugeGraph is a high-performance scalable graph database.
|
||||
HugeGraph is a high performance scalable graph database.
|
||||
|
||||
## Proposal
|
||||
|
||||
HugeGraph is a large-scale and easy-to-use graph database. In the cases of 100+ billion data (vertices and edges), HugeGraph has complete HTAP capabilities built into its internal system. The design goal of HugeGraph is to achieve a balance between availability, performance, and cost.
|
||||
HugeGraph is a large-scale and easy-to-use graph database. In the cases of 100+ billion data (vertices and edges), HugeGraph has complete HTAP capabilities built in its internal system. The design goal of HugeGraph is to achieve a balance between availability, performance and cost.
|
||||
|
||||
We believe that the HugeGraph project will benefit the open-source community if HugeGraph is introduced into the Apache Software Foundation.
|
||||
We believe that the HugeGraph project will benefit the open source community if HugeGraph is introduced into the Apache Software Foundation.
|
||||
|
||||
### Background
|
||||
|
||||
HugeGraph graph database was initially developed at Baidu, the leading search engine company in China. HugeGraph was designed to solve the large-scale graph analysis requirements for the task of anti-fraud. Relational databases are usually at a disadvantage in dealing with relational analysis, due to slow join performance, especially in the case of a large-scale graph with multiple dimensions and deep association relationships. Graph databases are in general considered a good alternative in dealing with large-scale relational analysis.
|
||||
HugeGraph graph database was initially developed at Baidu, the leading search engine company in China. HugeGraph was designed to solve the large-scale graph analysis requirements for the task of anti-fraud. Relational databases are usually at a disadvantage in dealing with relational analysis, due to slow join performance, especially in the case of a large-scale graph with multiple dimensions and deep association relationships. Graph databases are in general considered a good alternative in dealing with large scale relational analysis.
|
||||
|
||||
### Rationale
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ Generally, most graph databases can only process up to 1-billion-scale graphs, b
|
|||
Although most of the main development of HugeGraph has been completed, there are several areas that still need future development. Some areas we want to focus on in the Apache incubation stage include:
|
||||
|
||||
- Higher graph computing loading performance: the current architecture (especially the separation of computing and storage) brings greater flexibility and cost savings, but with some performance overhead, which needs to be improved.
|
||||
- RocksDB-based sharding storage development, based on the affinity architecture of query and storage. Since RocksDB is known for its good performance, but currently HugeGraph only supports the raft-based replication mode, we plan to support scale-out and distributed atomic transactions for RocksDB-based storage.
|
||||
- RocksDB-based sharding storage development, based on the affinity architecture of query and storage. Since RocksDB is known for its good performance, but currently HugeGraph only supports the raft-based replication mode. We plan to support scale-out and distributed atomic transactions for RocksDB-based storage.
|
||||
- Parallel OLTP query: at present, HugeGraph can perform parallel OLAP graph-computing, but the OLTP query only supports parallel execution on a single machine. In certain scenarios, the OLTP query needs to be implemented in parallel on multiple machines.
|
||||
- Higher-performance queries: such as supporting faster query optimization, parallel primitive collections, and fine-grained caching strategies.
|
||||
- Better usability: more OLTP/OLAP algorithms, APIs and toolchains, rich UI, etc...
|
||||
|
|
@ -34,57 +34,57 @@ Although most of the main development of HugeGraph has been completed, there are
|
|||
|
||||
#### Meritocracy
|
||||
|
||||
HugeGraph was incubated at Baidu in 2016 and open-sourced on [GitHub](https://github.com/hugegraph/hugegraph) in 2018. The project (including sub-projects) now has 30+ contributors from many companies. Some of these contributors become committers, and the project has hundreds of known users around the world. We will follow Apache's Meritocracy way to re-organize the community roles. We have set up the PPMC Team and Committer Team. Of course, contributions are welcomed and highly valued. New contributors are guided and reviewed by existing PMC members. When an active contributor has submitted enough good patches, PMC will start a vote to promote him/her to become a member of the Committer Team or PMC Team.
|
||||
HugeGraph was incubated at Baidu in 2016 and open sourced on [GitHub](https://github.com/hugegraph/hugegraph) in 2018. The project(include sub-projects) now has 30+ contributors from many companies. Some of these contributors become committers, and the project has hundreds of known users around the world. We will follow Apache's Meritocracy way to re-organize the community roles. We have set up the PPMC Team and Committer Team. Of course, contributions are welcomed and highly valued. New contributors are guided and reviewed by existing PMC members. When an active contributor has submitted enough good patches, PMC will start a vote to promote him/her to become a member of Committer Team or PMC Team.
|
||||
|
||||
#### Community
|
||||
|
||||
Baidu has been building a community around HugeGraph users and developers for the last 3 years, and now we make use of GitHub as code hosting and community communication. The most of core developers are from Baidu. Besides, there are 10+ contributors from other companies such as NetEase, 360, Iflytek, and Huya. We hope to grow the base of contributors by inviting all those who offer contributions through The Apache Way.
|
||||
Baidu has been building a community around HugeGraph users and developers for the last 3 years, and now we make use of GitHub as code hosting and community communication. The most of core developers are from Baidu. Besides, there are 10+ contributors from other companies such as NetEase, 360, Iflytek and Huya. We hope to grow the base of contributors by inviting all those who offer contributions through The Apache Way.
|
||||
|
||||
#### Core Developers
|
||||
|
||||
The core developers are all experienced open-source developers. They have operated the HugeGraph Community for 3 years, and they are contributors to Linux kernel, OpenStack, Ceph, RocksDB, Apache TinkerPop, Apache Hadoop, and Apache Groovy.
|
||||
The core developers are all experienced open source developers. They have operated the HugeGraph Community for 3 years, and they are contributors of Linux kernel, OpenStack, Ceph, RocksDB, Apache TinkerPop, Apache Hadoop and Apache Groovy.
|
||||
|
||||
#### Alignment
|
||||
|
||||
HugeGraph implements the API of [Apache TinkerPop](https://tinkerpop.apache.org/), which defines the [Gremlin](https://tinkerpop.apache.org/gremlin.html). Gremlin is a powerful graph traversal language, and various complicated graph queries can be accomplished through Gremlin. The TinkerPop ecosystem based on Java is relatively mature in terms of graph databases. We use Java language, which is developed efficient and stable, to develop upper-level components like graph engine, graph computing, graph API, and graph tools; and we manage storage through JNI which is able to freely manage memory and execute efficiently.
|
||||
HugeGraph implements the API of [Apache TinkerPop](https://tinkerpop.apache.org/), which defines the [Gremlin](https://tinkerpop.apache.org/gremlin.html). Gremlin is a powerful graph traversal language, and various complicated graph queries can be accomplished through Gremlin. The TinkerPop ecosystem based on Java is relatively mature in terms of graph databases. We use Java language, which is developed efficient and stable, to develop upper-level components like graph engine, graph computing, graph API and graph tools; and we manage storage through JNI which is able to freely manage memory and execute efficiently.
|
||||
|
||||
### Known Risks
|
||||
|
||||
#### Project Name
|
||||
|
||||
We have checked and believe the name is [suitable](https://github.com/hugegraph/hugegraph/issues/1646) and the project has legal permission to continue using its current name. There are no other projects found using this name through Google Search.
|
||||
We have checked and believe the name is [suitable](https://github.com/hugegraph/hugegraph/issues/1646) and the project has legal permission to continue using its current name. There is no other projects found using this name through Google search.
|
||||
|
||||
#### Relationship with Titan/Janus Graph
|
||||
|
||||
In the early stage of the project, we referred to the storage structure of Titan/Janus Graph, some folks thought that HugeGraph was forked from Titan/Janus. In fact, HugeGraph is not based on these projects. HugeGraph is developed completely from scratch and in the process it addressed many new challenges. Certainly, the project was inspired by Titan/Janus and we are really grateful for these inspirations.
|
||||
In the early stage of the project, we referred to the storage structure of Titan/Janus Graph, some folks thought that HugeGraph was forked from Titan/Janus. In fact, HugeGraph is not based on these projects. HugeGraph is developed completely from scratch and in the process it addressed many new challenges. Certainly, the project was inspired by Titan/Janus and we are really gratitious for such inspirations.
|
||||
|
||||
### Orphaned products
|
||||
|
||||
Due to a small and limited number of committers, the project has a relatively small risk of becoming an orphan project. However, the committers have been operating the HugeGraph Community for 3 years in the spirit of open-source, and continue to develop new contributors to participate.
|
||||
Due to a small and limited number of committers, the project has a relatively small risk of becoming an orphan project. However, the committers have been operating the HugeGraph Community for 3 years in the spirit of open source, and continue to develop new contributors to participate.
|
||||
|
||||
#### Inexperience with Open-Source
|
||||
#### Inexperience with Open Source:
|
||||
|
||||
HugeGraph has been open-sourced on GitHub for 3 years, during which committers submitted code and documents in full compliance with open-source specifications and requirements.
|
||||
HugeGraph has been open sourced on GitHub for 3 years, during which committers submitted code and documents in full compliance with open source specifications and requirements.
|
||||
|
||||
#### Length of Incubation
|
||||
#### Length of Incubation:
|
||||
|
||||
Expect to enter incubation in 4 months and graduate in about 2 years.
|
||||
|
||||
#### Homogenous Developers
|
||||
#### Homogenous Developers:
|
||||
|
||||
The developers on the current list come from several different companies plus many independent volunteers, but the most of committers are from Baidu. The developers are geographically concentrated in China now. They are experienced with working in a distributed environment in other open-source projects, e.g. OpenStack.
|
||||
The developers on the current list come from several different companies plus many independent volunteers, but the most of committers are from Baidu. The developers are geographically concentrated in China now. They are experienced with working in a distributed environment in other open source projects, e.g. OpenStack.
|
||||
|
||||
#### Reliance on Salaried Developers
|
||||
#### Reliance on Salaried Developers:
|
||||
|
||||
Most of the developers are paid by their employer to contribute to this project. Given some volunteer developers and the committers' sense of ownership for the code, the project could continue even if no salaried developers contributed to the project.
|
||||
|
||||
#### Relationships with Other Apache Products
|
||||
#### Relationships with Other Apache Products:
|
||||
|
||||
HugeGraph follows the Apache TinkerPop specification, uses Apache Commons, Apache HttpClient, and Apache HttpCore to implement the basic functions. Users can choose Apache Cassandra or Apache HBase as one of the storage backends of HugeGraph.
|
||||
|
||||
#### An Excessive Fascination with the Apache Brand
|
||||
#### An Excessive Fascination with the Apache Brand:
|
||||
|
||||
Although we expect that the Apache brand may help attract more contributors, our interest in starting this project is based on the factors mentioned in the fundamentals section. We are interested in joining ASF to increase our connections in the open-source world. Based on extensive collaboration, it is possible to build a community of developers and committers that live longer than the founder.
|
||||
Although we expect that the Apache brand may help attract more contributors, our interest in starting this project is based on the factors mentioned in the fundamentals section. We are interested in joining ASF to increase our connections in the open source world. Based on extensive collaboration, it is possible to build a community of developers and committers that live longer than the founder.
|
||||
|
||||
### Documentation
|
||||
|
||||
|
|
@ -94,18 +94,18 @@ HugeGraph documentation is provided on https://hugegraph.github.io/hugegraph-doc
|
|||
|
||||
This project consists of 2 core sub-projects and 2 other sub-projects, all of which are hosted by [GitHub hugegraph organization](https://github.com/orgs/hugegraph/repositories) since 2018. The codes are already under Apache License Version 2.0. The git address of sub-project repositories are as follows:
|
||||
|
||||
1. The graph database repository `hugegraph`, core sub-project, including graph server, graph engine, and graph storage: https://github.com/hugegraph/hugegraph
|
||||
1. The graph database repository `hugegraph`, core sub-project, including graph server, graph engine and graph storage: https://github.com/hugegraph/hugegraph
|
||||
2. The graph computing repository `hugegraph-computer`, core sub-project, including graph computing and graph algorithms: https://github.com/hugegraph/hugegraph-computer
|
||||
3. The common functions repository `hugegraph-commons`: https://github.com/hugegraph/hugegraph-commons
|
||||
4. The ecosystem repository `hugegraph-toolchain`, including `hugegraph-client`, `hugegraph-loader`, `hugegraph-tools`, `hugegraph-hubble`, `hugegraph-test`, `hugegraph-doc`: https://github.com/hugegraph/hugegraph-toolchain
|
||||
|
||||
### Source and Intellectual Property Submission Plan
|
||||
|
||||
The code is currently under Apache License Version 2.0, and it was verified there were no intellectual property or license issues when it was open-sourced by Baidu in 2018. Baidu will provide SGA and all committers will sign ICLA after HugeGraph is accepted into the Incubator.
|
||||
The codes are currently under Apache License Version 2.0, and have been verified there is no intellectual property or license issues when being released to open source by Baidu in 2018. Baidu will provide SGA and all committers will sign ICLA after HugeGraph is accepted into the Incubator.
|
||||
|
||||
#### External Dependencies
|
||||
#### External Dependencies:
|
||||
|
||||
As all dependencies are managed by Apache Maven, none of the external libraries need to be packaged in a source distribution. All dependencies have Apache compatible licenses except for 4 dependencies: MySQL Connector (GPL), word (GPL), JBoss Logging 3 (LGPL), and jnr-posix (LGPL+GPL), we will remove these dependencies in the future.
|
||||
As all dependencies are managed by Apache Maven, none of the external libraries need to be packaged in a source distribution. All dependencies have Apache compatible licenses except for 4 dependencies: MySQL Connector(GPL), word(GPL), JBoss Logging 3(LGPL) and jnr-posix(LGPL+GPL), we will remove these dependencies in future.
|
||||
|
||||
HugeGraph has the following external [dependencies](https://github.com/hugegraph/hugegraph/issues/1632):
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ None
|
|||
|
||||
### Required Resources
|
||||
|
||||
#### Mailing lists
|
||||
#### Mailing lists:
|
||||
|
||||
- hugegraph-dev: [dev@hugegraph.incubator.apache.org](mailto:dev@hugegraph.incubator.apache.org) for development and users discussions.
|
||||
- hugegraph-private: [private@hugegraph.incubator.apache.org](mailto:private@hugegraph.incubator.apache.org) for PPMC discussions.
|
||||
|
|
@ -276,13 +276,13 @@ None
|
|||
3. `hugegraph-commons`: https://github.com/hugegraph/hugegraph-commons.git
|
||||
4. `hugegraph-toolchain`: https://github.com/hugegraph/hugegraph-toolchain.git
|
||||
|
||||
#### Issue Tracking
|
||||
#### Issue Tracking:
|
||||
|
||||
The community would like to continue using [GitHub Issues](https://github.com/hugegraph/hugegraph/issues) (but will move to github.com/apache/).
|
||||
The community would like to continue using [GitHub Issues](https://github.com/hugegraph/hugegraph/issues) (but will moved to github.com/apache/).
|
||||
|
||||
#### Other Resources
|
||||
#### Other Resources:
|
||||
|
||||
- The community has already chosen [GitHub actions](https://github.com/hugegraph/hugegraph/actions) as continuous integration tools.
|
||||
- The community has already choosed [GitHub actions](https://github.com/hugegraph/hugegraph/actions) as continuous integration tools.
|
||||
- The community has already used [codecov](https://github.com/marketplace/codecov) to check code coverage.
|
||||
- The community has already used [mvn repository](https://mvnrepository.com/search?q=hugegraph) as binary package release platform.
|
||||
|
||||
|
|
@ -302,17 +302,17 @@ The community would like to continue using [GitHub Issues](https://github.com/hu
|
|||
|
||||
### Sponsors
|
||||
|
||||
#### Champion
|
||||
#### Champion:
|
||||
|
||||
- Willem Ning Jiang (ningjiang at apache dot org)
|
||||
|
||||
#### Nominated Mentors
|
||||
#### Nominated Mentors:
|
||||
|
||||
- Trista Pan (panjuan at apache dot org)
|
||||
- Lidong Dai (lidongdai at apache dot org)
|
||||
- Xiangdong Huang (hxd at apache dot org)
|
||||
- Yu Li (liyu at apache dot org)
|
||||
|
||||
#### Sponsoring Entity
|
||||
#### Sponsoring Entity:
|
||||
|
||||
We are expecting the Apache Incubator could sponsor this project.
|
||||
|
|
@ -3,7 +3,7 @@ Building hugegraph
|
|||
|
||||
Required:
|
||||
|
||||
* Java 8/11
|
||||
* Java 8 (0.9 and later)
|
||||
* Maven
|
||||
|
||||
To build without executing tests:
|
||||
|
|
@ -37,8 +37,9 @@ To find the Java binary in your environment, run the appropriate command for you
|
|||
To build without executing tests:
|
||||
|
||||
1. Click on "File" -> "Open", choose your project location.
|
||||
2. Open maven view by click "View" -> "Tool Windows" -> "Maven Projects".
|
||||
3. Choose root module "hugegraph: Distributed Graph Database", unfold the menu of "Lifecycle".
|
||||
2. Open maven view by click "View" -> "Tool Windows" -> "Maven Porjects".
|
||||
3. Choose root module "hugegraph: Distributed Graph Database", unfold the
|
||||
menu of "Lifecycle".
|
||||
4. Click the "Toggle 'Skip Tests' Mode" button which is located on the top
|
||||
navibar of "Maven Projects" window to skip tests.
|
||||
5. Double click "package" or "install" to build project.
|
||||
5. Double click "package" or "install" to build project.
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
# How to Contribute to HugeGraph
|
||||
|
||||
Thanks for taking the time to contribute! As an open source project, HugeGraph is looking forward to be contributed from everyone,
|
||||
and we are also grateful to all the contributors.
|
||||
Thanks for taking the time to contribute! As an open source project, HugeGraph is looking forward to be contributed from everyone, and we are also grateful to all of the contributors.
|
||||
|
||||
The following is a contribution guide for HugeGraph:
|
||||
|
||||
<img width="884" alt="image" src="https://user-images.githubusercontent.com/9625821/159643158-8bf72c0a-93c3-4a58-8912-7b2ab20ced1d.png">
|
||||
|
||||
## 1. Preparation
|
||||
|
||||
We can contribute by reporting issues, submitting code patches or any other feedback.
|
||||
|
|
@ -15,13 +12,13 @@ Before submitting the code, we need to do some preparation:
|
|||
|
||||
1. Sign up or login to GitHub: [https://github.com](https://github.com)
|
||||
|
||||
2. Fork HugeGraph repo from GitHub: [https://github.com/apache/incubator-hugegraph/fork](https://github.com/apache/incubator-hugegraph/fork)
|
||||
2. Fork HugeGraph repo from GitHub: [https://github.com/hugegraph/hugegraph/fork](https://github.com/hugegraph/hugegraph/fork)
|
||||
|
||||
3. Clone code from fork repo to local: [https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph](https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph)
|
||||
3. Clone code from fork repo to local: [https://github.com/${GITHUB_USER_NAME}/hugegraph](https://github.com/${GITHUB_USER_NAME}/hugegraph)
|
||||
|
||||
```shell
|
||||
# clone code from remote to local repo
|
||||
git clone https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph.git hugegraph
|
||||
git clone https://github.com/${GITHUB_USER_NAME}/hugegraph
|
||||
```
|
||||
|
||||
4. Configure local HugeGraph repo
|
||||
|
|
@ -30,24 +27,26 @@ Before submitting the code, we need to do some preparation:
|
|||
cd hugegraph
|
||||
|
||||
# add upstream to synchronize the latest code
|
||||
git remote add hugegraph https://github.com/apache/incubator-hugegraph
|
||||
git remote add hugegraph https://github.com/hugegraph/hugegraph
|
||||
|
||||
# set name and email to push code to github
|
||||
git config user.name "{full-name}" # like "Jermy Li"
|
||||
git config user.email "{email-address-of-github}" # like "jermy@apache.org"
|
||||
git config user.email "{email-address-of-github}" # like "jermy@gmail.com"
|
||||
```
|
||||
|
||||
**Recommended**: You can use [GitHub desktop](https://desktop.github.com/) to greatly simplify the PR process.
|
||||
5. Sign the HugeGraph CLA: [https://cla-assistant.io/hugegraph/hugegraph](https://cla-assistant.io/hugegraph/hugegraph)
|
||||
|
||||
Optional: You can use [Github desktop](https://desktop.github.com/) to greatly simplify the commit and update process.
|
||||
|
||||
## 2. Create an Issue on GitHub
|
||||
|
||||
If you encounter bugs or have any questions, please go to [GitHub Issues](https://github.com/apache/incubator-hugegraph/issues) to report them and feel free to [create an issue](https://github.com/apache/incubator-hugegraph/issues/new).
|
||||
If you encounter bugs or have any questions, please go to [GitHub Issues](https://github.com/hugegraph/hugegraph/issues) to report them and feel free to [create an issue](https://github.com/hugegraph/hugegraph/issues/new).
|
||||
|
||||
## 3. Make changes of code locally
|
||||
|
||||
#### 3.1 Create a new branch
|
||||
|
||||
Please don't use master branch for development. Instead, we should create a new branch:
|
||||
Please don't use master branch for development. Instead we should create a new branch:
|
||||
|
||||
```shell
|
||||
# checkout master branch
|
||||
|
|
@ -64,8 +63,8 @@ Assume that we need to modify some files like "HugeGraph.java" and "HugeFactory.
|
|||
|
||||
```shell
|
||||
# modify code to fix a bug
|
||||
vim hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
||||
vim hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||
vim hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java
|
||||
vim hugegraph-core/src/main/java/com/baidu/hugegraph/HugeFactory.java
|
||||
# run test locally (optional)
|
||||
mvn test -Pcore-test,memory
|
||||
```
|
||||
|
|
@ -77,8 +76,8 @@ After the code has been completed, we submit them to the local git repo:
|
|||
|
||||
```shell
|
||||
# add files to local git index
|
||||
git add hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
||||
git add hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||
git add hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java
|
||||
git add hugegraph-core/src/main/java/com/baidu/hugegraph/HugeFactory.java
|
||||
# commit to local git repo
|
||||
git commit
|
||||
```
|
||||
|
|
@ -102,20 +101,10 @@ Push the local commit to GitHub fork repo:
|
|||
git push origin bugfix-branch:bugfix-branch
|
||||
```
|
||||
|
||||
Note that since GitHub requires submitting code through `username + token` (instead of using `username + password` directly), you need to create a GitHub token from https://github.com/settings/tokens:
|
||||
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/9625821/163524204-7fe0e6bf-9c8b-4b1a-ac65-6a0ac423eb16.png">
|
||||
|
||||
## 4. Create a Pull Request
|
||||
|
||||
Go to the web page of GitHub fork repo, there would be a chance to create a Pull Request after pushing to a new branch, just click button "Compare & pull request" to do it. Then edit the description for proposed changes, which can just be copied from the commit message.
|
||||
|
||||
Please sign the HugeGraph CLA when contributing code for the first time. You can sign the CLA by just posting a Pull Request Comment same as the below format:
|
||||
|
||||
`I have read the CLA Document and I hereby sign the CLA`
|
||||
|
||||
Note: please make sure the email address you used to submit the code is bound to the GitHub account. For how to bind the email address, please refer to https://github.com/settings/emails:
|
||||
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/9625821/163522445-2a50a72a-dea2-434f-9868-3a0d40d0d037.png">
|
||||
|
||||
## 5. Code review
|
||||
|
||||
Maintainers will start the code review after all the **automatic** checks are passed:
|
||||
|
|
@ -136,11 +125,9 @@ If we have not passed the review, don't be discouraged. Usually a commit needs t
|
|||
After the further changes, we submit them to the local repo:
|
||||
|
||||
```shell
|
||||
# commit all updated files in a new commit,
|
||||
# please feel free to enter any appropriate commit message, note that
|
||||
# we will squash all commits in the pull request as one commit when
|
||||
# merging into the master branch.
|
||||
git commit -a
|
||||
# commit all updated files in amend mode
|
||||
# instead of creating a new commit
|
||||
git commit -a --amend
|
||||
```
|
||||
|
||||
> If there are conflicts that prevent the code from being merged, we need to rebase on master branch:
|
||||
|
|
@ -161,7 +148,7 @@ And push it to GitHub fork repo again:
|
|||
git push -f origin bugfix-branch:bugfix-branch
|
||||
```
|
||||
|
||||
GitHub will automatically update the Pull Request after we push it, just wait for code review.
|
||||
Github will automatically update the Pull Request after we push it, just wait for code review.
|
||||
|
||||
Any question please contact to us through [hugegraph@googlegroups.com](mailto:hugegraph@googlegroups.com) or [other contact information](https://hugegraph.github.io/hugegraph-doc/).
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
Apache HugeGraph (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
||||
|
||||
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications,
|
||||
and decision making process have stabilized in a manner consistent with other successful ASF projects.
|
||||
|
||||
While incubation status is not necessarily a reflection of the completeness or stability of the code,
|
||||
it does indicate that the project has yet to be fully endorsed by the ASF.
|
||||
81
Dockerfile
81
Dockerfile
|
|
@ -1,60 +1,51 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
FROM ubuntu:xenial
|
||||
|
||||
# Dockerfile for HugeGraph Server
|
||||
# 1st stage: build source code
|
||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||
LABEL maintainer="HugeGraph Docker Maintainers <hugegraph@googlegroups.com>"
|
||||
|
||||
COPY . /pkg
|
||||
WORKDIR /pkg
|
||||
RUN mvn package -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l
|
||||
ENV PKG_URL https://github.com/hugegraph
|
||||
|
||||
# 2nd stage: runtime env
|
||||
FROM openjdk:11-slim
|
||||
# TODO: get the version from the pom.xml
|
||||
ENV version=1.0.0
|
||||
COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph
|
||||
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
|
||||
|
||||
# TODO: use g1gc or zgc as default
|
||||
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm"
|
||||
|
||||
#COPY . /hugegraph/hugegraph-server
|
||||
WORKDIR /hugegraph/
|
||||
|
||||
# 1. Install environment
|
||||
# 1. Install needed dependencies of GraphServer & RocksDB
|
||||
RUN set -x \
|
||||
&& apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
dumb-init \
|
||||
procps \
|
||||
curl \
|
||||
lsof \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
g++ \
|
||||
gcc \
|
||||
openjdk-8-jdk \
|
||||
&& apt-get clean
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 2. Init HugeGraph Sever
|
||||
# (Optional) You can set the ip of github to speed up the local build
|
||||
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
|
||||
ENV SERVER_VERSION 0.10.4
|
||||
RUN set -e \
|
||||
&& pwd && cd /hugegraph/ \
|
||||
&& mkdir -p /root/hugegraph-server \
|
||||
&& curl -L -S ${PKG_URL}/hugegraph/releases/download/v${SERVER_VERSION}/hugegraph-${SERVER_VERSION}.tar.gz -o /root/server.tar.gz \
|
||||
&& tar xzf /root/server.tar.gz --strip-components 1 -C /root/hugegraph-server \
|
||||
&& rm /root/server.tar.gz \
|
||||
&& cd /root/hugegraph-server/ \
|
||||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
|
||||
&& sed -n '63p' ./bin/start-hugegraph.sh | grep "&" > /dev/null && sed -i 63{s/\&$/#/g} ./bin/start-hugegraph.sh \
|
||||
&& sed -n '74p' ./bin/start-hugegraph.sh | grep "exit" > /dev/null && sed -i 74{s/^/#/g} ./bin/start-hugegraph.sh \
|
||||
&& ./bin/init-store.sh
|
||||
|
||||
EXPOSE 8080
|
||||
VOLUME /hugegraph
|
||||
# 3. Prepare for HugeGraph Studio
|
||||
ENV STUDIO_VERSION 0.10.0
|
||||
# (Optional) You can set the ip of github to speed up the local build
|
||||
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
|
||||
RUN set -e \
|
||||
&& mkdir -p /root/hugegraph-studio \
|
||||
&& curl -L -S ${PKG_URL}/hugegraph-studio/releases/download/v${STUDIO_VERSION}/hugegraph-studio-${STUDIO_VERSION}.tar.gz -o /root/studio.tar.gz \
|
||||
&& tar xzf /root/studio.tar.gz --strip-components 1 -C /root/hugegraph-studio \
|
||||
&& rm /root/studio.tar.gz \
|
||||
&& cd /root/hugegraph-studio/ \
|
||||
&& sed -i "s/^studio.server.host.*$/studio.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties \
|
||||
&& sed -i "s/^graph.server.host.*$/graph.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties
|
||||
|
||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||
CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"]
|
||||
EXPOSE 8080 8088
|
||||
WORKDIR /root
|
||||
VOLUME /root
|
||||
|
||||
ENTRYPOINT ["./hugegraph-server/bin/start-hugegraph.sh"]
|
||||
|
|
|
|||
18
LICENSE
18
LICENSE
|
|
@ -1,4 +1,4 @@
|
|||
Apache License
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
|
|
@ -200,19 +200,3 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
========================================================================
|
||||
Apache 2.0 licenses
|
||||
========================================================================
|
||||
|
||||
The following components are provided under the Apache License. See project link for details.
|
||||
The text of each license is the standard Apache 2.0 license.
|
||||
|
||||
hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/StructureBasicSuite.java from https://github.com/apache/tinkerpop
|
||||
hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/ProcessBasicSuite.java from https://github.com/apache/tinkerpop
|
||||
hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/SnowflakeIdGenerator.java from https://github.com/twitter-archive/snowflake
|
||||
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java from https://github.com/apache/tinkerpop
|
||||
hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java from https://github.com/JanusGraph/janusgraph
|
||||
hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java from https://github.com/JanusGraph/janusgraph
|
||||
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java from https://github.com/JanusGraph/janusgraph
|
||||
hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java from https://github.com/opencypher/cypher-for-gremlin
|
||||
hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java from https://github.com/opencypher/cypher-for-gremlin
|
||||
|
|
|
|||
91
NOTICE
91
NOTICE
|
|
@ -1,91 +0,0 @@
|
|||
Apache HugeGraph(incubating)
|
||||
Copyright 2022-2023 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
This product contains code form the Apache TinkerPop Project:
|
||||
-----------------------------------------------------------------------
|
||||
Apache TinkerPop
|
||||
Copyright 2015-2022 The Apache Software Foundation.
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Activiti
|
||||
------------------------------------------------------------------------
|
||||
Activiti BPM Platform
|
||||
Copyright 2010-2014 Alfresco Software, Ltd.
|
||||
|
||||
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLWriterHelper.java
|
||||
contains DelegatingXMLStreamWriter.java and IndentingXMLStreamWriter.java from
|
||||
https://github.com/Activiti/Activiti/tree/activiti-5.16/modules/activiti-bpmn-converter/src/main/java/org/activiti/bpmn/converter
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Apache Kerby
|
||||
------------------------------------------------------------------------
|
||||
Apache Kerby
|
||||
Copyright 2015-2017 The Apache Software Foundation
|
||||
|
||||
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/JaasKrbUtil.java
|
||||
from
|
||||
https://github.com/apache/directory-kerby/blob/kerby-all-1.0.0/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/client/JaasKrbUtil.java
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
This product contains code form the JanusGraph Project:
|
||||
-----------------------------------------------------------------------
|
||||
==============================================================
|
||||
JanusGraph: Distributed Graph Database
|
||||
Copyright 2012 and onwards JanusGraph Authors
|
||||
==============================================================
|
||||
|
||||
This product includes software developed by JanusGraph contributors listed
|
||||
in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt.
|
||||
|
||||
This product is based on Titan, originally developed by Aurelius (acquired by
|
||||
DataStax) and the following individuals:
|
||||
|
||||
* Matthias Broecheler
|
||||
* Dan LaRocque
|
||||
* Marko A. Rodriguez
|
||||
* Stephen Mallette
|
||||
* Pavel Yaskevich
|
||||
|
||||
It also includes software from other open source projects including, but not limited to (check pom.xml for complete listing):
|
||||
|
||||
* Apache Cassandra [https://cassandra.apache.org/]
|
||||
* Apache Commons [https://commons.apache.org/]
|
||||
* Apache Groovy [http://groovy-lang.org/]
|
||||
* Apache HBase [https://hbase.apache.org/]
|
||||
* Apache Hadoop [https://hadoop.apache.org/]
|
||||
* Apache Kerby [https://github.com/apache/directory-kerby]
|
||||
* Apache Log4j [https://logging.apache.org/log4j]
|
||||
* Apache Lucene [https://lucene.apache.org/]
|
||||
* Apache Solr [https://lucene.apache.org/solr/]
|
||||
* Apache TinkerPop [https://tinkerpop.apache.org/]
|
||||
* Astyanax [https://github.com/Netflix/astyanax]
|
||||
* DataStax Driver for Apache Cassandra [https://github.com/datastax/java-driver]
|
||||
* EasyMock [http://easymock.org/]
|
||||
* Elasticsearch [https://www.elastic.co/]
|
||||
* Google Cloud Bigtable [https://github.com/googlecloudplatform/cloud-bigtable-client]
|
||||
* Google Guava [https://github.com/google/guava]
|
||||
* HPPC [https://labs.carrotsearch.com/hppc.html]
|
||||
* JUnit [https://www.junit.org/]
|
||||
* Jackson [https://github.com/FasterXML/jackson]
|
||||
* Kryo [https://github.com/EsotericSoftware/kryo]
|
||||
* Metrics [https://metrics.dropwizard.io]
|
||||
* Mockito [https://site.mockito.org/]
|
||||
* Noggit [https://github.com/yonik/noggit]
|
||||
* OpenRDF [http://rdf4j.org/]
|
||||
* Oracle BerkeleyDB Java Edition [https://www.oracle.com/technetwork/products/berkeleydb/] (see license below)
|
||||
* Project Lombok [https://projectlombok.org/]
|
||||
* Reflections8 [https://github.com/aschoerk/reflections8]
|
||||
* SLF4J [https://www.slf4j.org/]
|
||||
* Spatial4j [https://github.com/locationtech/spatial4j]
|
||||
* Vavr [https://www.vavr.io/]
|
||||
59
README.md
59
README.md
|
|
@ -3,57 +3,28 @@
|
|||
</div>
|
||||
|
||||
<p align="center">
|
||||
A graph database that supports more than 10 billion data, high performance and scalability
|
||||
A graph database that supports more than 10+ billion data, high performance and scalability
|
||||
</p>
|
||||
<hr/>
|
||||
|
||||
# Apache HugeGraph
|
||||
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
[](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml)
|
||||
[](https://github.com/apache/incubator-hugegraph/actions/workflows/codeql-analysis.yml)
|
||||
[](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml)
|
||||
[](https://codecov.io/gh/apache/hugegraph)
|
||||
[](https://github.com/apache/hugegraph/releases)
|
||||
[](https://github.com/hugegraph/hugegraph/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/hugegraph/hugegraph)
|
||||
[](https://github.com/hugegraph/hugegraph/releases)
|
||||
|
||||
[HugeGraph](https://hugegraph.apache.org/) is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database).
|
||||
Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
|
||||
HugeGraph is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database). Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
|
||||
|
||||
## Features
|
||||
|
||||
- Compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/), support [Gremlin](https://tinkerpop.apache.org/gremlin.html) & [Cypher](https://en.wikipedia.org/wiki/Cypher) language
|
||||
- Compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/), supporting [Gremlin](https://tinkerpop.apache.org/gremlin.html)
|
||||
- Schema Metadata Management, including VertexLabel, EdgeLabel, PropertyKey and IndexLabel
|
||||
- Multi-type Indexes, supporting exact query, range query and complex conditions combination query
|
||||
- Plug-in Backend Store Driver Framework, support `RocksDB`, `Cassandra`, `HBase`, `ScyllaDB`, and `MySQL/Postgre` now and easy to add other backend store driver if needed
|
||||
- Integration with `Flink/Spark/HDFS`, and friendly to connect other big data platforms
|
||||
- Plug-in Backend Store Driver Framework, supporting RocksDB, Cassandra, ScyllaDB, HBase and MySQL now and easy to add other backend store driver if needed
|
||||
- Integration with Hadoop/Spark
|
||||
|
||||
## Quick Start
|
||||
## Getting Started
|
||||
|
||||
### 1. Docker Way
|
||||
|
||||
We can use `docker run -itd --name=graph -p 8080:8080 hugegraph/hugegraph` to quickly start an inner
|
||||
HugeGraph server with `RocksDB` in background.
|
||||
|
||||
Optional: use `docker exec -it graph bash` to enter the container to do some operations.
|
||||
|
||||
### 2. Download Way
|
||||
|
||||
Visit [Download Page](https://hugegraph.apache.org/docs/download/download/) and refer the [doc](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#33-source-code-compilation)
|
||||
to download the latest release package and start the server.
|
||||
|
||||
### 3. Source Building Way
|
||||
|
||||
Visit [Source Building Page](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#33-source-code-compilation) and follow the
|
||||
steps to build the source code and start the server.
|
||||
|
||||
The project [doc page](https://hugegraph.apache.org/docs/) contains more information on HugeGraph
|
||||
and provides detailed documentation for users. (Structure / Usage / API / Configs...)
|
||||
|
||||
And here are links of other **HugeGraph** component/repositories:
|
||||
1. [hugegraph-toolchain](https://github.com/apache/incubator-hugegraph-toolchain) (graph **loader/dashboard/tool/client**)
|
||||
2. [hugegraph-computer](https://github.com/apache/incubator-hugegraph-computer) (matched **graph computing** system)
|
||||
3. [hugegraph-commons](https://github.com/apache/incubator-hugegraph-commons) (**common & rpc** module)
|
||||
4. [hugegraph-website](https://github.com/apache/incubator-hugegraph-doc) (**doc & website** code)
|
||||
The project [homepage](https://hugegraph.github.io/hugegraph-doc/) contains more information on HugeGraph and provides links to **documentation**, getting-started guides and release downloads.
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
@ -69,13 +40,3 @@ HugeGraph relies on the [TinkerPop](http://tinkerpop.apache.org) framework, we r
|
|||
Thanks to TinkerPop, thanks to Titan, thanks to DataStax. Thanks to all other organizations or authors who contributed to the project.
|
||||
|
||||
You are welcome to contribute to HugeGraph, and we are looking forward to working with you to build an excellent open source community.
|
||||
|
||||
### Contact Us
|
||||
|
||||
---
|
||||
|
||||
- [GitHub Issues](https://github.com/apache/incubator-hugegraph/issues): Feedback on usage issues and functional requirements (quick response)
|
||||
- Feedback Email: [dev@hugegraph.apache.org](mailto:dev@hugegraph.apache.org) ([subscriber](https://hugegraph.apache.org/docs/contribution-guidelines/subscribe/) only)
|
||||
- WeChat public account: Apache HugeGraph, welcome to scan this QR code to follow us.
|
||||
|
||||
<img src="https://github.com/apache/incubator-hugegraph-doc/blob/master/assets/images/wechat.png?raw=true" alt="QR png" width="350"/>
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
|
|
@ -6,7 +7,7 @@
|
|||
# (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
|
||||
# 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,
|
||||
|
|
@ -15,13 +16,9 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
root = true
|
||||
export MAVEN_HOME=/home/scmtools/buildkit/maven/apache-maven-3.3.9/
|
||||
export JAVA_HOME=/home/scmtools/buildkit/java/jdk1.8.0_25/
|
||||
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
mvn clean compile
|
||||
|
||||
[*.{java,xml,py}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
|
@ -1,28 +1,11 @@
|
|||
<?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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.apache.hugegraph</groupId>
|
||||
<artifactId>hugegraph</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<groupId>com.baidu.hugegraph</groupId>
|
||||
<version>0.12.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
@ -30,25 +13,16 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.hugegraph</groupId>
|
||||
<groupId>com.baidu.hugegraph</groupId>
|
||||
<artifactId>hugegraph-core</artifactId>
|
||||
<version>${revision}</version>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty-shaded</artifactId>
|
||||
<version>1.47.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.hugegraph</groupId>
|
||||
<groupId>com.baidu.hugegraph</groupId>
|
||||
<artifactId>hugegraph-rpc</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-netty-shaded</artifactId>
|
||||
</exclusion>
|
||||
<!-- conflict with jraft -->
|
||||
<exclusion>
|
||||
<groupId>com.alipay.sofa</groupId>
|
||||
|
|
@ -119,51 +93,54 @@
|
|||
<dependency>
|
||||
<groupId>org.glassfish.grizzly</groupId>
|
||||
<artifactId>grizzly-http</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>2.4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.grizzly</groupId>
|
||||
<artifactId>grizzly-framework</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>2.4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.grizzly</groupId>
|
||||
<artifactId>grizzly-http-server</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>2.4.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.grizzly</groupId>
|
||||
<artifactId>grizzly-http-servlet</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>2.4.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-jersey3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.opencypher.gremlin</groupId>
|
||||
<artifactId>translation</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-jaxrs2-jakarta</artifactId>
|
||||
<version>2.1.9</version>
|
||||
<artifactId>metrics-jersey2</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<filesets>
|
||||
<fileset>
|
||||
<directory>${top.level.dir}</directory>
|
||||
<includes>
|
||||
<include>*.tar.gz</include>
|
||||
</includes>
|
||||
<followSymlinks>false</followSymlinks>
|
||||
</fileset>
|
||||
<fileset>
|
||||
<directory>${final.name}</directory>
|
||||
</fileset>
|
||||
</filesets>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<index>true</index>
|
||||
|
|
@ -176,8 +153,7 @@
|
|||
</addDefaultSpecificationEntries>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- TODO: update it -->
|
||||
<Implementation-Version>0.69.0.0</Implementation-Version>
|
||||
<Implementation-Version>0.67.0.0</Implementation-Version>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,38 +17,38 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api;
|
||||
package com.baidu.hugegraph.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import jakarta.ws.rs.ForbiddenException;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.NotSupportedException;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.NotSupportedException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.metrics.MetricsUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class API {
|
||||
|
||||
protected static final Logger LOG = Log.logger(API.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
public static final String CHARSET = "UTF-8";
|
||||
|
||||
public static final String TEXT_PLAIN = MediaType.TEXT_PLAIN;
|
||||
public static final String APPLICATION_JSON = MediaType.APPLICATION_JSON;
|
||||
public static final String APPLICATION_JSON_WITH_CHARSET =
|
||||
APPLICATION_JSON + ";charset=" + CHARSET;
|
||||
|
|
@ -57,13 +59,13 @@ public class API {
|
|||
public static final String ACTION_ELIMINATE = "eliminate";
|
||||
public static final String ACTION_CLEAR = "clear";
|
||||
|
||||
private static final Meter SUCCEED_METER =
|
||||
private static final Meter succeedMeter =
|
||||
MetricsUtil.registerMeter(API.class, "commit-succeed");
|
||||
private static final Meter ILLEGAL_ARG_ERROR_METER =
|
||||
private static final Meter illegalArgErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "illegal-arg");
|
||||
private static final Meter EXPECTED_ERROR_METER =
|
||||
private static final Meter expectedErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "expected-error");
|
||||
private static final Meter UNKNOWN_ERROR_METER =
|
||||
private static final Meter unknownErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "unknown-error");
|
||||
|
||||
public static HugeGraph graph(GraphManager manager, String graph) {
|
||||
|
|
@ -94,19 +96,19 @@ public class API {
|
|||
try {
|
||||
R result = callable.call();
|
||||
g.tx().commit();
|
||||
SUCCEED_METER.mark();
|
||||
succeedMeter.mark();
|
||||
return result;
|
||||
} catch (IllegalArgumentException | NotFoundException |
|
||||
ForbiddenException e) {
|
||||
ILLEGAL_ARG_ERROR_METER.mark();
|
||||
illegalArgErrorMeter.mark();
|
||||
rollback.accept(null);
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
EXPECTED_ERROR_METER.mark();
|
||||
expectedErrorMeter.mark();
|
||||
rollback.accept(e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
UNKNOWN_ERROR_METER.mark();
|
||||
unknownErrorMeter.mark();
|
||||
rollback.accept(e);
|
||||
// TODO: throw the origin exception 'e'
|
||||
throw new HugeException("Failed to commit", e);
|
||||
|
|
@ -141,9 +143,9 @@ public class API {
|
|||
}
|
||||
|
||||
protected static void checkCreatingBody(
|
||||
Collection<? extends Checkable> bodies) {
|
||||
E.checkArgumentNotNull(bodies, "The request body can't be empty");
|
||||
for (Checkable body : bodies) {
|
||||
Collection<? extends Checkable> bodys) {
|
||||
E.checkArgumentNotNull(bodys, "The request body can't be empty");
|
||||
for (Checkable body : bodys) {
|
||||
E.checkArgument(body != null,
|
||||
"The batch body can't contain null record");
|
||||
body.checkCreate(true);
|
||||
|
|
@ -151,9 +153,9 @@ public class API {
|
|||
}
|
||||
|
||||
protected static void checkUpdatingBody(
|
||||
Collection<? extends Checkable> bodies) {
|
||||
E.checkArgumentNotNull(bodies, "The request body can't be empty");
|
||||
for (Checkable body : bodies) {
|
||||
Collection<? extends Checkable> bodys) {
|
||||
E.checkArgumentNotNull(bodys, "The request body can't be empty");
|
||||
for (Checkable body : bodys) {
|
||||
E.checkArgumentNotNull(body,
|
||||
"The batch body can't contain null record");
|
||||
body.checkUpdate();
|
||||
|
|
@ -169,9 +171,7 @@ public class API {
|
|||
Map<String, Object> props = null;
|
||||
try {
|
||||
props = JsonUtil.fromJson(properties, Map.class);
|
||||
} catch (Exception ignored) {
|
||||
// ignore
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
// If properties is the string "null", props will be null
|
||||
E.checkArgument(props != null,
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,47 +17,46 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Path;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.HugeAccess;
|
||||
import org.apache.hugegraph.auth.HugePermission;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.HugeAccess;
|
||||
import com.baidu.hugegraph.auth.HugePermission;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/accesses")
|
||||
@Singleton
|
||||
@Tag(name = "AccessAPI")
|
||||
public class AccessAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(AccessAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.HugeBelong;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.HugeBelong;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/belongs")
|
||||
@Singleton
|
||||
@Tag(name = "BelongAPI")
|
||||
public class BelongAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(BelongAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.HugeGroup;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.HugeGroup;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/groups")
|
||||
@Singleton
|
||||
@Tag(name = "GroupAPI")
|
||||
public class GroupAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(GroupAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,52 +17,52 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import javax.inject.Singleton;
|
||||
import javax.security.sasl.AuthenticationException;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.HeaderParam;
|
||||
import jakarta.ws.rs.NotAuthorizedException;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.NotAuthorizedException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.AuthenticationFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.AuthConstant;
|
||||
import org.apache.hugegraph.auth.UserWithRole;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.AuthenticationFilter;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.AuthConstant;
|
||||
import com.baidu.hugegraph.auth.UserWithRole;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("graphs/{graph}/auth")
|
||||
@Singleton
|
||||
@Tag(name = "LoginAPI")
|
||||
public class LoginAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(LoginAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Path("login")
|
||||
@Status(Status.OK)
|
||||
@Status(StatusFilter.Status.OK)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String login(@Context GraphManager manager,
|
||||
|
|
@ -83,7 +85,7 @@ public class LoginAPI extends API {
|
|||
@DELETE
|
||||
@Timed
|
||||
@Path("logout")
|
||||
@Status(Status.OK)
|
||||
@Status(StatusFilter.Status.OK)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public void logout(@Context GraphManager manager,
|
||||
|
|
@ -107,7 +109,7 @@ public class LoginAPI extends API {
|
|||
@GET
|
||||
@Timed
|
||||
@Path("verify")
|
||||
@Status(Status.OK)
|
||||
@Status(StatusFilter.Status.OK)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String verifyToken(@Context GraphManager manager,
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,57 +17,56 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.AuthManager;
|
||||
import org.apache.hugegraph.auth.HugeProject;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter;
|
||||
import com.baidu.hugegraph.auth.AuthManager;
|
||||
import com.baidu.hugegraph.auth.HugeProject;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/projects")
|
||||
@Singleton
|
||||
@Tag(name = "ProjectAPI")
|
||||
public class ProjectAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(ProjectAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
private static final String ACTION_ADD_GRAPH = "add_graph";
|
||||
private static final String ACTION_REMOVE_GRAPH = "remove_graph";
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Status(Status.CREATED)
|
||||
@StatusFilter.Status(StatusFilter.Status.CREATED)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String create(@Context GraphManager manager,
|
||||
|
|
@ -175,7 +176,6 @@ public class ProjectAPI extends API {
|
|||
throw new IllegalArgumentException("Invalid project id: " + id);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAddGraph(String action) {
|
||||
return ACTION_ADD_GRAPH.equals(action);
|
||||
}
|
||||
|
|
@ -267,6 +267,6 @@ public class ProjectAPI extends API {
|
|||
this.description != null,
|
||||
"Must specify 'graphs' or 'description' " +
|
||||
"field that need to be updated");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,47 +17,46 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.HugeTarget;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.HugeTarget;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/targets")
|
||||
@Singleton
|
||||
@Tag(name = "TargetAPI")
|
||||
public class TargetAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(TargetAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,49 +17,48 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.auth;
|
||||
package com.baidu.hugegraph.api.auth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.auth.HugeUser;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.apache.hugegraph.util.StringEncoding;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.auth.HugeUser;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.util.StringEncoding;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/auth/users")
|
||||
@Singleton
|
||||
@Tag(name = "UserAPI")
|
||||
public class UserAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(UserAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.Principal;
|
||||
|
|
@ -23,18 +25,18 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.annotation.Priority;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.NotAuthorizedException;
|
||||
import jakarta.ws.rs.Priorities;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerRequestFilter;
|
||||
import jakarta.ws.rs.container.PreMatching;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import javax.annotation.Priority;
|
||||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.NotAuthorizedException;
|
||||
import javax.ws.rs.Priorities;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerRequestFilter;
|
||||
import javax.ws.rs.container.PreMatching;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -43,14 +45,14 @@ import org.glassfish.grizzly.http.server.Request;
|
|||
import org.glassfish.grizzly.utils.Charsets;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.RequiredPerm;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.RolePerm;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.User;
|
||||
import org.apache.hugegraph.auth.RolePermission;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.RequiredPerm;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.RolePerm;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.User;
|
||||
import com.baidu.hugegraph.auth.RolePermission;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Provider
|
||||
|
|
@ -69,10 +71,10 @@ public class AuthenticationFilter implements ContainerRequestFilter {
|
|||
);
|
||||
|
||||
@Context
|
||||
private jakarta.inject.Provider<GraphManager> managerProvider;
|
||||
private javax.inject.Provider<GraphManager> managerProvider;
|
||||
|
||||
@Context
|
||||
private jakarta.inject.Provider<Request> requestProvider;
|
||||
private javax.inject.Provider<Request> requestProvider;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext context) throws IOException {
|
||||
|
|
@ -279,6 +281,9 @@ public class AuthenticationFilter implements ContainerRequestFilter {
|
|||
public static boolean isWhiteAPI(ContainerRequestContext context) {
|
||||
String path = context.getUriInfo().getPath();
|
||||
|
||||
E.checkArgument(StringUtils.isNotEmpty(path),
|
||||
"Invalid request uri '%s'", path);
|
||||
|
||||
for (String whiteApi : WHITE_API_LIST) {
|
||||
if (path.endsWith(whiteApi)) {
|
||||
return true;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
|
@ -24,27 +26,27 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import jakarta.ws.rs.NameBinding;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
import jakarta.ws.rs.core.MultivaluedMap;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import jakarta.ws.rs.ext.WriterInterceptor;
|
||||
import jakarta.ws.rs.ext.WriterInterceptorContext;
|
||||
import jakarta.inject.Singleton;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.NameBinding;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import javax.ws.rs.ext.WriterInterceptor;
|
||||
import javax.ws.rs.ext.WriterInterceptorContext;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
|
||||
@Provider
|
||||
@Singleton
|
||||
@Compress
|
||||
@CompressInterceptor.Compress
|
||||
public class CompressInterceptor implements WriterInterceptor {
|
||||
|
||||
public static final String GZIP = "gzip";
|
||||
|
||||
private static final Logger LOG = Log.logger(CompressInterceptor.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
// Set compress output buffer size to 4KB (about 40~600 vertices)
|
||||
public static final int BUFFER_SIZE = 1024 * 4;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,18 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.NameBinding;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import jakarta.ws.rs.ext.ReaderInterceptor;
|
||||
import jakarta.ws.rs.ext.ReaderInterceptorContext;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.NameBinding;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
import javax.ws.rs.ext.ReaderInterceptor;
|
||||
import javax.ws.rs.ext.ReaderInterceptorContext;
|
||||
|
||||
@Provider
|
||||
@Singleton
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,41 +17,39 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.json.Json;
|
||||
import javax.json.JsonArrayBuilder;
|
||||
import javax.json.JsonObjectBuilder;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.MultivaluedMap;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.ext.ExceptionMapper;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.glassfish.hk2.api.MultiException;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.exception.HugeGremlinException;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.exception.HugeGremlinException;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class ExceptionFilter {
|
|||
private static boolean forcedTrace = false;
|
||||
|
||||
@Context
|
||||
private jakarta.inject.Provider<HugeConfig> configProvider;
|
||||
private javax.inject.Provider<HugeConfig> configProvider;
|
||||
|
||||
protected boolean trace() {
|
||||
if (forcedTrace) {
|
||||
|
|
@ -83,7 +83,6 @@ public class ExceptionFilter {
|
|||
|
||||
@Path("exception/trace")
|
||||
@Singleton
|
||||
@Tag(name = "TracedExceptionAPI")
|
||||
public static class TracedExceptionAPI extends API {
|
||||
|
||||
@GET
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,25 +17,25 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.ServiceUnavailableException;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerRequestFilter;
|
||||
import jakarta.ws.rs.container.PreMatching;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.PathSegment;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.ServiceUnavailableException;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerRequestFilter;
|
||||
import javax.ws.rs.container.PreMatching;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.PathSegment;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.define.WorkLoad;
|
||||
import org.apache.hugegraph.util.Bytes;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.define.WorkLoad;
|
||||
import com.baidu.hugegraph.util.Bytes;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
|
||||
|
|
@ -54,9 +56,9 @@ public class LoadDetectFilter implements ContainerRequestFilter {
|
|||
RateLimiter.create(1.0 / 30);
|
||||
|
||||
@Context
|
||||
private jakarta.inject.Provider<HugeConfig> configProvider;
|
||||
private javax.inject.Provider<HugeConfig> configProvider;
|
||||
@Context
|
||||
private jakarta.inject.Provider<WorkLoad> loadProvider;
|
||||
private javax.inject.Provider<WorkLoad> loadProvider;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext context) {
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,23 +17,23 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseFilter;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerResponseContext;
|
||||
import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.apache.hugegraph.define.WorkLoad;
|
||||
import com.baidu.hugegraph.define.WorkLoad;
|
||||
|
||||
@Provider
|
||||
@Singleton
|
||||
public class LoadReleaseFilter implements ContainerResponseFilter {
|
||||
|
||||
@Context
|
||||
private jakarta.inject.Provider<WorkLoad> loadProvider;
|
||||
private javax.inject.Provider<WorkLoad> loadProvider;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext,
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,18 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.filter;
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import jakarta.ws.rs.NameBinding;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseFilter;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import javax.ws.rs.NameBinding;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerResponseContext;
|
||||
import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
@Provider
|
||||
public class StatusFilter implements ContainerResponseFilter {
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,27 +17,27 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.graph;
|
||||
package com.baidu.hugegraph.api.graph;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Element;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.define.UpdateStrategy;
|
||||
import org.apache.hugegraph.metrics.MetricsUtil;
|
||||
import org.apache.hugegraph.server.RestServer;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.structure.HugeElement;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.define.UpdateStrategy;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeElement;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -45,11 +47,11 @@ public class BatchAPI extends API {
|
|||
private static final Logger LOG = Log.logger(BatchAPI.class);
|
||||
|
||||
// NOTE: VertexAPI and EdgeAPI should share a counter
|
||||
private static final AtomicInteger BATCH_WRITE_THREADS = new AtomicInteger(0);
|
||||
private static final AtomicInteger batchWriteThreads = new AtomicInteger(0);
|
||||
|
||||
static {
|
||||
MetricsUtil.registerGauge(RestServer.class, "batch-write-threads",
|
||||
() -> BATCH_WRITE_THREADS.intValue());
|
||||
() -> batchWriteThreads.intValue());
|
||||
}
|
||||
|
||||
private final Meter batchMeter;
|
||||
|
|
@ -62,24 +64,24 @@ public class BatchAPI extends API {
|
|||
public <R> R commit(HugeConfig config, HugeGraph g, int size,
|
||||
Callable<R> callable) {
|
||||
int maxWriteThreads = config.get(ServerOptions.MAX_WRITE_THREADS);
|
||||
int writingThreads = BATCH_WRITE_THREADS.incrementAndGet();
|
||||
int writingThreads = batchWriteThreads.incrementAndGet();
|
||||
if (writingThreads > maxWriteThreads) {
|
||||
BATCH_WRITE_THREADS.decrementAndGet();
|
||||
batchWriteThreads.decrementAndGet();
|
||||
throw new HugeException("The rest server is too busy to write");
|
||||
}
|
||||
|
||||
LOG.debug("The batch writing threads is {}", BATCH_WRITE_THREADS);
|
||||
LOG.debug("The batch writing threads is {}", batchWriteThreads);
|
||||
try {
|
||||
R result = commit(g, callable);
|
||||
this.batchMeter.mark(size);
|
||||
return result;
|
||||
} finally {
|
||||
BATCH_WRITE_THREADS.decrementAndGet();
|
||||
batchWriteThreads.decrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
@JsonIgnoreProperties(value = {"type"})
|
||||
protected abstract static class JsonElement implements Checkable {
|
||||
protected static abstract class JsonElement implements Checkable {
|
||||
|
||||
@JsonProperty("id")
|
||||
public Object id;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.graph;
|
||||
package com.baidu.hugegraph.api.graph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -24,57 +26,55 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
|
||||
import org.apache.tinkerpop.gremlin.structure.Direction;
|
||||
import org.apache.tinkerpop.gremlin.structure.Edge;
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.tinkerpop.gremlin.util.function.TriFunction;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.UpdateStrategy;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import org.apache.hugegraph.api.filter.DecompressInterceptor.Decompress;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.EdgeId;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.ConditionQuery;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.schema.EdgeLabel;
|
||||
import org.apache.hugegraph.schema.PropertyKey;
|
||||
import org.apache.hugegraph.schema.VertexLabel;
|
||||
import org.apache.hugegraph.structure.HugeEdge;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.optimize.QueryHolder;
|
||||
import org.apache.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.api.filter.DecompressInterceptor.Decompress;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.EdgeId;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.ConditionQuery;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.UpdateStrategy;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.schema.EdgeLabel;
|
||||
import com.baidu.hugegraph.schema.PropertyKey;
|
||||
import com.baidu.hugegraph.schema.VertexLabel;
|
||||
import com.baidu.hugegraph.structure.HugeEdge;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.optimize.QueryHolder;
|
||||
import com.baidu.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/graph/edges")
|
||||
@Singleton
|
||||
@Tag(name = "EdgeAPI")
|
||||
public class EdgeAPI extends BatchAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(EdgeAPI.class);
|
||||
|
|
@ -464,7 +464,7 @@ public class EdgeAPI extends BatchAPI {
|
|||
Directions.OUT, labelId, sortKeys,
|
||||
HugeVertex.getIdValue(newEdge.target));
|
||||
if (newEdge.id != null) {
|
||||
E.checkArgument(edgeId.asString().equals(newEdge.id),
|
||||
E.checkArgument(edgeId.equals(newEdge.id),
|
||||
"The ids are different between server and " +
|
||||
"request body ('%s' != '%s'). And note the sort " +
|
||||
"key values should either be null or equal to " +
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.graph;
|
||||
package com.baidu.hugegraph.api.graph;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -25,55 +27,53 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
|
||||
import org.apache.tinkerpop.gremlin.structure.T;
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.UpdateStrategy;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import org.apache.hugegraph.api.filter.DecompressInterceptor.Decompress;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.SplicingIdGenerator;
|
||||
import org.apache.hugegraph.backend.query.ConditionQuery;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.exception.NotFoundException;
|
||||
import org.apache.hugegraph.schema.PropertyKey;
|
||||
import org.apache.hugegraph.schema.VertexLabel;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.optimize.QueryHolder;
|
||||
import org.apache.hugegraph.traversal.optimize.Text;
|
||||
import org.apache.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import org.apache.hugegraph.type.define.IdStrategy;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.api.filter.DecompressInterceptor.Decompress;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.SplicingIdGenerator;
|
||||
import com.baidu.hugegraph.backend.query.ConditionQuery;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.UpdateStrategy;
|
||||
import com.baidu.hugegraph.exception.NotFoundException;
|
||||
import com.baidu.hugegraph.schema.PropertyKey;
|
||||
import com.baidu.hugegraph.schema.VertexLabel;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.optimize.QueryHolder;
|
||||
import com.baidu.hugegraph.traversal.optimize.Text;
|
||||
import com.baidu.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import com.baidu.hugegraph.type.define.IdStrategy;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/graph/vertices")
|
||||
@Singleton
|
||||
@Tag(name = "VertexAPI")
|
||||
public class VertexAPI extends BatchAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(VertexAPI.class);
|
||||
|
|
@ -125,8 +125,8 @@ public class VertexAPI extends BatchAPI {
|
|||
|
||||
/**
|
||||
* Batch update steps like:
|
||||
* 1. Get all newVertices' ID & combine first
|
||||
* 2. Get all oldVertices & update
|
||||
* 1. Get all newVertices' ID & combine first
|
||||
* 2. Get all oldVertices & update
|
||||
* 3. Add the final vertex together
|
||||
*/
|
||||
@PUT
|
||||
|
|
@ -405,7 +405,7 @@ public class VertexAPI extends BatchAPI {
|
|||
E.checkArgument(req.updateStrategies != null &&
|
||||
!req.updateStrategies.isEmpty(),
|
||||
"Parameter 'update_strategies' can't be empty");
|
||||
E.checkArgument(req.createIfNotExist,
|
||||
E.checkArgument(req.createIfNotExist == true,
|
||||
"Parameter 'create_if_not_exist' " +
|
||||
"dose not support false now");
|
||||
}
|
||||
|
|
@ -462,7 +462,6 @@ public class VertexAPI extends BatchAPI {
|
|||
}
|
||||
if (this.id != null) {
|
||||
newProps[appendIndex++] = T.id;
|
||||
// Keep value++ to avoid code trap
|
||||
newProps[appendIndex++] = this.id;
|
||||
}
|
||||
return newProps;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,39 +17,57 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.gremlin;
|
||||
package com.baidu.hugegraph.api.gremlin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.exception.HugeGremlinException;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.exception.HugeGremlinException;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import jakarta.inject.Provider;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
@Path("gremlin")
|
||||
@Singleton
|
||||
public class GremlinAPI extends API {
|
||||
|
||||
public class GremlinQueryAPI extends API {
|
||||
private static final Histogram gremlinInputHistogram =
|
||||
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-input");
|
||||
private static final Histogram gremlinOutputHistogram =
|
||||
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-output");
|
||||
|
||||
private static final Set<String> FORBIDDEN_REQUEST_EXCEPTIONS =
|
||||
ImmutableSet.of("java.lang.SecurityException",
|
||||
"jakarta.ws.rs.ForbiddenException");
|
||||
"javax.ws.rs.ForbiddenException");
|
||||
private static final Set<String> BAD_REQUEST_EXCEPTIONS = ImmutableSet.of(
|
||||
"java.lang.IllegalArgumentException",
|
||||
"java.util.concurrent.TimeoutException",
|
||||
"groovy.lang.",
|
||||
"org.codehaus.",
|
||||
"org.apache.hugegraph."
|
||||
"com.baidu.hugegraph."
|
||||
);
|
||||
|
||||
@Context
|
||||
private Provider<HugeConfig> configProvider;
|
||||
private javax.inject.Provider<HugeConfig> configProvider;
|
||||
|
||||
private GremlinClient client;
|
||||
|
||||
|
|
@ -63,7 +83,44 @@ public class GremlinQueryAPI extends API {
|
|||
return this.client;
|
||||
}
|
||||
|
||||
protected static Response transformResponseIfNeeded(Response response) {
|
||||
@POST
|
||||
@Timed
|
||||
@Compress
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public Response post(@Context HugeConfig conf,
|
||||
@Context HttpHeaders headers,
|
||||
String request) {
|
||||
/* The following code is reserved for forwarding request */
|
||||
// context.getRequestDispatcher(location).forward(request, response);
|
||||
// return Response.seeOther(UriBuilder.fromUri(location).build())
|
||||
// .build();
|
||||
// Response.temporaryRedirect(UriBuilder.fromUri(location).build())
|
||||
// .build();
|
||||
String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION);
|
||||
Response response = this.client().doPostRequest(auth, request);
|
||||
gremlinInputHistogram.update(request.length());
|
||||
gremlinOutputHistogram.update(response.getLength());
|
||||
return transformResponseIfNeeded(response);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Compress(buffer=(1024 * 40))
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public Response get(@Context HugeConfig conf,
|
||||
@Context HttpHeaders headers,
|
||||
@Context UriInfo uriInfo) {
|
||||
String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION);
|
||||
String query = uriInfo.getRequestUri().getRawQuery();
|
||||
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
|
||||
Response response = this.client().doGetRequest(auth, params);
|
||||
gremlinInputHistogram.update(query.length());
|
||||
gremlinOutputHistogram.update(response.getLength());
|
||||
return transformResponseIfNeeded(response);
|
||||
}
|
||||
|
||||
private static Response transformResponseIfNeeded(Response response) {
|
||||
MediaType mediaType = response.getMediaType();
|
||||
if (mediaType != null) {
|
||||
// Append charset
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,22 +17,22 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.gremlin;
|
||||
package com.baidu.hugegraph.api.gremlin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jakarta.ws.rs.client.Entity;
|
||||
import jakarta.ws.rs.client.WebTarget;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.MultivaluedMap;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor;
|
||||
import org.apache.hugegraph.rest.AbstractRestClient;
|
||||
import org.apache.hugegraph.testutil.Whitebox;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor;
|
||||
import com.baidu.hugegraph.rest.AbstractRestClient;
|
||||
import com.baidu.hugegraph.testutil.Whitebox;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
|
||||
public class GremlinClient extends AbstractRestClient {
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,43 +17,41 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.job;
|
||||
package com.baidu.hugegraph.api.job;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.job.ComputerJob;
|
||||
import org.apache.hugegraph.job.JobBuilder;
|
||||
import org.apache.hugegraph.task.HugeTask;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.job.ComputerJob;
|
||||
import com.baidu.hugegraph.job.JobBuilder;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.task.HugeTask;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/jobs/computer")
|
||||
@Singleton
|
||||
@Tag(name = "ComputerAPI")
|
||||
public class ComputerAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(ComputerAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -59,7 +59,6 @@ public class ComputerAPI extends API {
|
|||
@Status(Status.CREATED)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String computer,
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.job;
|
||||
package com.baidu.hugegraph.api.job;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
|
|
@ -25,47 +27,45 @@ import java.nio.charset.CodingErrorAction;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.job.GremlinJob;
|
||||
import org.apache.hugegraph.job.JobBuilder;
|
||||
import org.apache.hugegraph.metrics.MetricsUtil;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.job.GremlinJob;
|
||||
import com.baidu.hugegraph.job.JobBuilder;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/jobs/gremlin")
|
||||
@Singleton
|
||||
@Tag(name = "GremlinAPI")
|
||||
public class GremlinAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(GremlinAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
private static final int MAX_NAME_LENGTH = 256;
|
||||
|
||||
private static final Histogram GREMLIN_JOB_INPUT_HISTOGRAM =
|
||||
private static final Histogram gremlinJobInputHistogram =
|
||||
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-input");
|
||||
|
||||
@POST
|
||||
|
|
@ -74,13 +74,12 @@ public class GremlinAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=gremlin_execute"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
GremlinRequest request) {
|
||||
LOG.debug("Graph [{}] schedule gremlin job: {}", graph, request);
|
||||
checkCreatingBody(request);
|
||||
GREMLIN_JOB_INPUT_HISTOGRAM.update(request.gremlin.length());
|
||||
gremlinJobInputHistogram.update(request.gremlin.length());
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
request.aliase(graph, "graph");
|
||||
|
|
@ -152,6 +151,9 @@ public class GremlinAPI extends API {
|
|||
return firstLine;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reference https://stackoverflow.com/questions/3576754/truncating-strings-by-bytes
|
||||
*/
|
||||
CharsetDecoder decoder = charset.newDecoder();
|
||||
decoder.onMalformedInput(CodingErrorAction.IGNORE);
|
||||
decoder.reset();
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,34 +17,31 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.job;
|
||||
package com.baidu.hugegraph.api.job;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/jobs/rebuild")
|
||||
@Singleton
|
||||
@Tag(name = "RebuildAPI")
|
||||
public class RebuildAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RebuildAPI.class);
|
||||
|
|
@ -53,7 +52,6 @@ public class RebuildAPI extends API {
|
|||
@Status(Status.ACCEPTED)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=index_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> vertexLabelRebuild(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -70,7 +68,6 @@ public class RebuildAPI extends API {
|
|||
@Status(Status.ACCEPTED)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=index_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> edgeLabelRebuild(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -87,7 +84,6 @@ public class RebuildAPI extends API {
|
|||
@Status(Status.ACCEPTED)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=index_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> indexLabelRebuild(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -97,4 +93,4 @@ public class RebuildAPI extends API {
|
|||
return ImmutableMap.of("task_id",
|
||||
g.schema().indexLabel(name).rebuild());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.job;
|
||||
package com.baidu.hugegraph.api.job;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -24,43 +26,41 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.NotSupportedException;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.groovy.util.Maps;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.backend.page.PageInfo;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.task.HugeTask;
|
||||
import org.apache.hugegraph.task.TaskScheduler;
|
||||
import org.apache.hugegraph.task.TaskStatus;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.backend.page.PageInfo;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.task.HugeTask;
|
||||
import com.baidu.hugegraph.task.TaskScheduler;
|
||||
import com.baidu.hugegraph.task.TaskStatus;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.BadRequestException;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.NotSupportedException;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/tasks")
|
||||
@Singleton
|
||||
@Tag(name = "TaskAPI")
|
||||
public class TaskAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(TaskAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
private static final long NO_LIMIT = -1L;
|
||||
|
||||
public static final String ACTION_CANCEL = "cancel";
|
||||
|
|
@ -133,7 +133,6 @@ public class TaskAPI extends API {
|
|||
@DELETE
|
||||
@Timed
|
||||
@Path("{id}")
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public void delete(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("id") long id) {
|
||||
|
|
@ -149,7 +148,6 @@ public class TaskAPI extends API {
|
|||
@Path("{id}")
|
||||
@Status(Status.ACCEPTED)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Object> update(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("id") long id,
|
||||
|
|
@ -178,11 +176,11 @@ public class TaskAPI extends API {
|
|||
|
||||
private static TaskStatus parseStatus(String status) {
|
||||
try {
|
||||
return TaskStatus.valueOf(status.toUpperCase());
|
||||
return TaskStatus.valueOf(status);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Status value must be in %s, but got '%s'",
|
||||
Arrays.asList(TaskStatus.values()), status));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.metrics;
|
||||
package com.baidu.hugegraph.api.metrics;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
|
@ -23,32 +25,30 @@ import static java.util.concurrent.TimeUnit.SECONDS;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.metrics.MetricsModule;
|
||||
import org.apache.hugegraph.metrics.ServerReporter;
|
||||
import org.apache.hugegraph.metrics.SystemMetrics;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.store.BackendMetrics;
|
||||
import org.apache.hugegraph.util.InsertionOrderUtil;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.store.BackendMetrics;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.metrics.MetricsModule;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.metrics.SystemMetrics;
|
||||
import com.baidu.hugegraph.util.InsertionOrderUtil;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Metric;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Singleton
|
||||
@Path("metrics")
|
||||
@Tag(name = "MetricsAPI")
|
||||
public class MetricsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(MetricsAPI.class);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,53 +17,52 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.profile;
|
||||
package com.baidu.hugegraph.api.profile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.ForbiddenException;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.NotSupportedException;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.SecurityContext;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.NotSupportedException;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.RequiredPerm;
|
||||
import org.apache.hugegraph.auth.HugePermission;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.type.define.GraphReadMode;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.RequiredPerm;
|
||||
import com.baidu.hugegraph.auth.HugePermission;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.type.define.GraphReadMode;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("graphs")
|
||||
@Singleton
|
||||
@Tag(name = "GraphsAPI")
|
||||
public class GraphsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(GraphsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
private static final String CONFIRM_CLEAR = "I'm sure to delete all data";
|
||||
private static final String CONFIRM_DROP = "I'm sure to drop the graph";
|
||||
|
|
@ -106,7 +107,7 @@ public class GraphsAPI extends API {
|
|||
@Timed
|
||||
@Path("{name}")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin"})
|
||||
@RolesAllowed({"admin", "$owner=$name"})
|
||||
public void drop(@Context GraphManager manager,
|
||||
@PathParam("name") String name,
|
||||
@QueryParam("confirm_message") String message) {
|
||||
|
|
@ -120,7 +121,7 @@ public class GraphsAPI extends API {
|
|||
@POST
|
||||
@Timed
|
||||
@Path("{name}")
|
||||
@Consumes(TEXT_PLAIN)
|
||||
@Consumes(APPLICATION_JSON_WITH_CHARSET)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin"})
|
||||
public Object create(@Context GraphManager manager,
|
||||
|
|
@ -151,7 +152,7 @@ public class GraphsAPI extends API {
|
|||
HugeGraph g = graph4admin(manager, name);
|
||||
|
||||
HugeConfig config = (HugeConfig) g.configuration();
|
||||
File file = config.file();
|
||||
File file = config.getFile();
|
||||
if (file == null) {
|
||||
throw new NotSupportedException("Can't access the api in " +
|
||||
"a node which started with non local file config.");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.profile;
|
||||
package com.baidu.hugegraph.api.profile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -24,37 +26,34 @@ import java.util.Set;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Application;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.tinkerpop.shaded.jackson.annotation.JsonProperty;
|
||||
import org.glassfish.jersey.model.Parameter.Source;
|
||||
import org.glassfish.jersey.server.model.Parameter;
|
||||
import org.glassfish.jersey.server.model.Parameter.Source;
|
||||
import org.glassfish.jersey.server.model.Resource;
|
||||
import org.glassfish.jersey.server.model.ResourceMethod;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.InsertionOrderUtil;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.version.CoreVersion;
|
||||
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.InsertionOrderUtil;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.version.CoreVersion;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("/")
|
||||
@Singleton
|
||||
@Tag(name = "ProfileAPI")
|
||||
public class ProfileAPI {
|
||||
|
||||
private static final String SERVICE = "hugegraph";
|
||||
private static final String DOC = "https://hugegraph.apache.org/docs/";
|
||||
private static final String API_DOC = DOC + "clients/";
|
||||
private static final String DOC = "https://hugegraph.github.io/hugegraph-doc/";
|
||||
private static final String API_DOC = DOC + "clients/hugegraph-api.html";
|
||||
|
||||
private static String SERVER_PROFILES = null;
|
||||
private static String API_PROFILES = null;
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,26 +17,24 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.profile;
|
||||
package com.baidu.hugegraph.api.profile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.version.ApiVersion;
|
||||
import org.apache.hugegraph.version.CoreVersion;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.version.ApiVersion;
|
||||
import com.baidu.hugegraph.version.CoreVersion;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("versions")
|
||||
@Singleton
|
||||
@Tag(name = "VersionAPI")
|
||||
public class VersionAPI extends API {
|
||||
|
||||
@GET
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,47 +17,37 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.raft;
|
||||
package com.baidu.hugegraph.api.raft;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.store.raft.RaftAddPeerJob;
|
||||
import org.apache.hugegraph.backend.store.raft.RaftGroupManager;
|
||||
import org.apache.hugegraph.backend.store.raft.RaftRemovePeerJob;
|
||||
import org.apache.hugegraph.job.JobBuilder;
|
||||
import org.apache.hugegraph.util.DateUtil;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.store.raft.RaftGroupManager;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("graphs/{graph}/raft")
|
||||
@Singleton
|
||||
@Tag(name = "RaftAPI")
|
||||
public class RaftAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RaftAPI.class);
|
||||
|
|
@ -152,27 +144,19 @@ public class RaftAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> addPeer(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("group") @DefaultValue("default")
|
||||
String group,
|
||||
@QueryParam("endpoint") String endpoint) {
|
||||
public Map<String, String> addPeer(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("group")
|
||||
@DefaultValue("default")
|
||||
String group,
|
||||
@QueryParam("endpoint")
|
||||
String endpoint) {
|
||||
LOG.debug("Graph [{}] prepare to add peer: {}", graph, endpoint);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
RaftGroupManager raftManager = raftGroupManager(g, group, "add_peer");
|
||||
|
||||
JobBuilder<String> builder = JobBuilder.of(g);
|
||||
String name = String.format("raft-group-[%s]-add-peer-[%s]-at-[%s]",
|
||||
raftManager.group(), endpoint,
|
||||
DateUtil.now());
|
||||
Map<String, String> inputs = new HashMap<>();
|
||||
inputs.put("endpoint", endpoint);
|
||||
builder.name(name)
|
||||
.input(JsonUtil.toJson(inputs))
|
||||
.job(new RaftAddPeerJob());
|
||||
return ImmutableMap.of("task_id", builder.schedule().id());
|
||||
String peerId = raftManager.addPeer(endpoint);
|
||||
return ImmutableMap.of(raftManager.group(), peerId);
|
||||
}
|
||||
|
||||
@POST
|
||||
|
|
@ -182,33 +166,26 @@ public class RaftAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> removePeer(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("group")
|
||||
@DefaultValue("default") String group,
|
||||
@QueryParam("endpoint") String endpoint) {
|
||||
public Map<String, String> removePeer(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("group")
|
||||
@DefaultValue("default")
|
||||
String group,
|
||||
@QueryParam("endpoint")
|
||||
String endpoint) {
|
||||
LOG.debug("Graph [{}] prepare to remove peer: {}", graph, endpoint);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
RaftGroupManager raftManager = raftGroupManager(g, group,
|
||||
"remove_peer");
|
||||
JobBuilder<String> builder = JobBuilder.of(g);
|
||||
String name = String.format("raft-group-[%s]-remove-peer-[%s]-at-[%s]",
|
||||
raftManager.group(), endpoint,
|
||||
DateUtil.now());
|
||||
Map<String, String> inputs = new HashMap<>();
|
||||
inputs.put("endpoint", endpoint);
|
||||
builder.name(name)
|
||||
.input(JsonUtil.toJson(inputs))
|
||||
.job(new RaftRemovePeerJob());
|
||||
return ImmutableMap.of("task_id", builder.schedule().id());
|
||||
String peerId = raftManager.removePeer(endpoint);
|
||||
return ImmutableMap.of(raftManager.group(), peerId);
|
||||
}
|
||||
|
||||
private static RaftGroupManager raftGroupManager(HugeGraph graph,
|
||||
String group,
|
||||
String operation) {
|
||||
RaftGroupManager raftManager = graph.raftGroupManager();
|
||||
RaftGroupManager raftManager = graph.raftGroupManager(group);
|
||||
if (raftManager == null) {
|
||||
throw new HugeException("Allowed %s operation only when " +
|
||||
"working on raft mode", operation);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,51 +17,47 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.schema;
|
||||
package com.baidu.hugegraph.api.schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.schema.EdgeLabel;
|
||||
import org.apache.hugegraph.schema.Userdata;
|
||||
import org.apache.hugegraph.type.define.Frequency;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.schema.EdgeLabel;
|
||||
import com.baidu.hugegraph.schema.Userdata;
|
||||
import com.baidu.hugegraph.type.define.Frequency;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/schema/edgelabels")
|
||||
@Singleton
|
||||
@Tag(name = "EdgeLabelAPI")
|
||||
public class EdgeLabelAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(EdgeLabelAPI.class);
|
||||
|
|
@ -70,7 +68,6 @@ public class EdgeLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=edge_label_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String create(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
JsonEdgeLabel jsonEdgeLabel) {
|
||||
|
|
@ -89,7 +86,6 @@ public class EdgeLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=edge_label_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String update(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name,
|
||||
|
|
@ -160,7 +156,6 @@ public class EdgeLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=edge_label_delete"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> delete(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -208,7 +203,8 @@ public class EdgeLabelAPI extends API {
|
|||
|
||||
@Override
|
||||
public void checkCreate(boolean isBatch) {
|
||||
E.checkArgumentNotNull(this.name, "The name of edge label can't be null");
|
||||
E.checkArgumentNotNull(this.name,
|
||||
"The name of edge label can't be null");
|
||||
}
|
||||
|
||||
private EdgeLabel.Builder convert2Builder(HugeGraph g) {
|
||||
|
|
@ -265,13 +261,12 @@ public class EdgeLabelAPI extends API {
|
|||
@Override
|
||||
public String toString() {
|
||||
return String.format("JsonEdgeLabel{" +
|
||||
"name=%s, sourceLabel=%s, targetLabel=%s, frequency=%s, " +
|
||||
"sortKeys=%s, nullableKeys=%s, properties=%s, ttl=%s, " +
|
||||
"ttlStartTime=%s}",
|
||||
this.name, this.sourceLabel, this.targetLabel,
|
||||
this.frequency, Arrays.toString(this.sortKeys),
|
||||
Arrays.toString(this.nullableKeys),
|
||||
Arrays.toString(this.properties), this.ttl, this.ttlStartTime);
|
||||
"name=%s, sourceLabel=%s, targetLabel=%s, frequency=%s, " +
|
||||
"sortKeys=%s, nullableKeys=%s, properties=%s, ttl=%s, " +
|
||||
"ttlStartTime=%s}",
|
||||
this.name, this.sourceLabel, this.targetLabel,
|
||||
this.frequency, this.sortKeys, this.nullableKeys,
|
||||
this.properties, this.ttl, this.ttlStartTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,53 +17,49 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.schema;
|
||||
package com.baidu.hugegraph.api.schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.schema.IndexLabel;
|
||||
import org.apache.hugegraph.schema.SchemaElement;
|
||||
import org.apache.hugegraph.schema.Userdata;
|
||||
import org.apache.hugegraph.type.HugeType;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.type.define.IndexType;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.schema.IndexLabel;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.Userdata;
|
||||
import com.baidu.hugegraph.type.HugeType;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.type.define.IndexType;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/schema/indexlabels")
|
||||
@Singleton
|
||||
@Tag(name = "IndexLabelAPI")
|
||||
public class IndexLabelAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(IndexLabelAPI.class);
|
||||
|
|
@ -72,7 +70,6 @@ public class IndexLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=index_label_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String create(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
JsonIndexLabel jsonIndexLabel) {
|
||||
|
|
@ -91,7 +88,6 @@ public class IndexLabelAPI extends API {
|
|||
@Path("{name}")
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String update(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name,
|
||||
|
|
@ -108,8 +104,8 @@ public class IndexLabelAPI extends API {
|
|||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
IndexLabel.Builder builder = jsonIndexLabel.convert2Builder(g);
|
||||
IndexLabel indexLabel = append ? builder.append() : builder.eliminate();
|
||||
return manager.serializer(g).writeIndexlabel(mapIndexLabel(indexLabel));
|
||||
IndexLabel IndexLabel = append ? builder.append() : builder.eliminate();
|
||||
return manager.serializer(g).writeIndexlabel(mapIndexLabel(IndexLabel));
|
||||
}
|
||||
|
||||
@GET
|
||||
|
|
@ -161,7 +157,6 @@ public class IndexLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=index_label_delete"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> delete(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -291,7 +286,7 @@ public class IndexLabelAPI extends API {
|
|||
return String.format("JsonIndexLabel{name=%s, baseType=%s," +
|
||||
"baseValue=%s, indexType=%s, fields=%s}",
|
||||
this.name, this.baseType, this.baseValue,
|
||||
this.indexType, Arrays.toString(this.fields));
|
||||
this.indexType, this.fields);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,56 +17,52 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.schema;
|
||||
package com.baidu.hugegraph.api.schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.schema.PropertyKey;
|
||||
import org.apache.hugegraph.schema.SchemaElement;
|
||||
import org.apache.hugegraph.schema.Userdata;
|
||||
import org.apache.hugegraph.type.define.AggregateType;
|
||||
import org.apache.hugegraph.type.define.Cardinality;
|
||||
import org.apache.hugegraph.type.define.DataType;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.type.define.WriteType;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.schema.PropertyKey;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.Userdata;
|
||||
import com.baidu.hugegraph.type.define.AggregateType;
|
||||
import com.baidu.hugegraph.type.define.Cardinality;
|
||||
import com.baidu.hugegraph.type.define.DataType;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.type.define.WriteType;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/schema/propertykeys")
|
||||
@Singleton
|
||||
@Tag(name = "PropertyKeyAPI")
|
||||
public class PropertyKeyAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(PropertyKeyAPI.class);
|
||||
|
|
@ -75,11 +73,11 @@ public class PropertyKeyAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=property_key_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String create(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
JsonPropertyKey jsonPropertyKey) {
|
||||
LOG.debug("Graph [{}] create property key: {}", graph, jsonPropertyKey);
|
||||
LOG.debug("Graph [{}] create property key: {}",
|
||||
graph, jsonPropertyKey);
|
||||
checkCreatingBody(jsonPropertyKey);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
|
@ -95,7 +93,6 @@ public class PropertyKeyAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=property_key_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String update(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name,
|
||||
|
|
@ -181,7 +178,6 @@ public class PropertyKeyAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=property_key_delete"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> delete(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -270,7 +266,7 @@ public class PropertyKeyAPI extends API {
|
|||
"writeType=%s, properties=%s}",
|
||||
this.name, this.cardinality,
|
||||
this.dataType, this.aggregateType,
|
||||
this.writeType, Arrays.toString(this.properties));
|
||||
this.writeType, this.properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,33 +17,31 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.schema;
|
||||
package com.baidu.hugegraph.api.schema;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.schema.SchemaManager;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.schema.SchemaManager;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/schema")
|
||||
@Singleton
|
||||
@Tag(name = "SchemaAPI")
|
||||
public class SchemaAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(SchemaAPI.class);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,51 +17,47 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.schema;
|
||||
package com.baidu.hugegraph.api.schema;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.RedirectFilter;
|
||||
import org.apache.hugegraph.api.filter.StatusFilter.Status;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.define.Checkable;
|
||||
import org.apache.hugegraph.schema.Userdata;
|
||||
import org.apache.hugegraph.schema.VertexLabel;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.type.define.IdStrategy;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.StatusFilter.Status;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.schema.Userdata;
|
||||
import com.baidu.hugegraph.schema.VertexLabel;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.type.define.IdStrategy;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.security.RolesAllowed;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
|
||||
@Path("graphs/{graph}/schema/vertexlabels")
|
||||
@Singleton
|
||||
@Tag(name = "VertexLabelAPI")
|
||||
public class VertexLabelAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(VertexLabelAPI.class);
|
||||
|
|
@ -70,7 +68,6 @@ public class VertexLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=vertex_label_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String create(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
JsonVertexLabel jsonVertexLabel) {
|
||||
|
|
@ -90,7 +87,6 @@ public class VertexLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=vertex_label_write"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public String update(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name,
|
||||
|
|
@ -163,7 +159,6 @@ public class VertexLabelAPI extends API {
|
|||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner=$graph $action=vertex_label_delete"})
|
||||
@RedirectFilter.RedirectMasterRole
|
||||
public Map<String, Id> delete(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@PathParam("name") String name) {
|
||||
|
|
@ -259,11 +254,11 @@ public class VertexLabelAPI extends API {
|
|||
@Override
|
||||
public String toString() {
|
||||
return String.format("JsonVertexLabel{" +
|
||||
"name=%s, idStrategy=%s, primaryKeys=%s, nullableKeys=%s, " +
|
||||
"properties=%s, ttl=%s, ttlStartTime=%s}",
|
||||
this.name, this.idStrategy, Arrays.toString(this.primaryKeys),
|
||||
Arrays.toString(this.nullableKeys),
|
||||
Arrays.toString(this.properties), this.ttl, this.ttlStartTime);
|
||||
"name=%s, idStrategy=%s, primaryKeys=%s, nullableKeys=%s, " +
|
||||
"properties=%s, ttl=%s, ttlStartTime=%s}",
|
||||
this.name, this.idStrategy, this.primaryKeys,
|
||||
this.nullableKeys, this.properties, this.ttl,
|
||||
this.ttlStartTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,44 +17,43 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/allshortestpaths")
|
||||
@Singleton
|
||||
@Tag(name = "AllShortestPathsAPI")
|
||||
public class AllShortestPathsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(AllShortestPathsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,36 +17,36 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_SKIP_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_SKIP_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.CountTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CountTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -52,10 +54,9 @@ import com.google.common.collect.ImmutableMap;
|
|||
|
||||
@Path("graphs/{graph}/traversers/count")
|
||||
@Singleton
|
||||
@Tag(name = "CountAPI")
|
||||
public class CountAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(CountAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,42 +17,41 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/crosspoints")
|
||||
@Singleton
|
||||
@Tag(name = "CrosspointsAPI")
|
||||
public class CrosspointsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(CrosspointsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -67,7 +68,7 @@ public class CrosspointsAPI extends API {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get crosspoints with paths from '{}', to '{}' " +
|
||||
"with direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,11 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -28,38 +30,37 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/customizedcrosspoints")
|
||||
@Singleton
|
||||
@Tag(name = "CustomizedCrosspointsAPI")
|
||||
public class CustomizedCrosspointsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(CustomizedCrosspointsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -138,7 +139,7 @@ public class CustomizedCrosspointsAPI extends API {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_PATHS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_path")
|
||||
public boolean withPath = false;
|
||||
@JsonProperty("with_vertex")
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,13 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_SAMPLE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_WEIGHT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_SAMPLE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_WEIGHT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -30,39 +32,38 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CustomizePathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.WeightedEdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/customizedpaths")
|
||||
@Singleton
|
||||
@Tag(name = "CustomizedPathsAPI")
|
||||
public class CustomizedPathsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(CustomizedPathsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -138,7 +139,7 @@ public class CustomizedPathsAPI extends API {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_PATHS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,45 +17,44 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PAGE_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PAGE_LIMIT;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Edge;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.ConditionQuery;
|
||||
import org.apache.hugegraph.backend.store.Shard;
|
||||
import org.apache.hugegraph.structure.HugeEdge;
|
||||
import org.apache.hugegraph.type.HugeType;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.ConditionQuery;
|
||||
import com.baidu.hugegraph.backend.store.Shard;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeEdge;
|
||||
import com.baidu.hugegraph.type.HugeType;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/edges")
|
||||
@Singleton
|
||||
@Tag(name = "EdgesAPI")
|
||||
public class EdgesAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(EdgesAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser.SimilarsMap;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.FusiformSimilarityTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.FusiformSimilarityTraverser.SimilarsMap;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/fusiformsimilarity")
|
||||
@Singleton
|
||||
@Tag(name = "FusiformSimilarityAPI")
|
||||
public class FusiformSimilarityAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(FusiformSimilarityAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -143,7 +144,7 @@ public class FusiformSimilarityAPI extends API {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_PATHS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_intermediary")
|
||||
public boolean withIntermediary = false;
|
||||
@JsonProperty("with_vertex")
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,50 +17,49 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.traversal.algorithm.JaccardSimilarTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("graphs/{graph}/traversers/jaccardsimilarity")
|
||||
@Singleton
|
||||
@Tag(name = "JaccardSimilarityAPI")
|
||||
public class JaccardSimilarityAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(JaccardSimilarityAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -83,8 +84,8 @@ public class JaccardSimilarityAPI extends TraverserAPI {
|
|||
double similarity;
|
||||
try (JaccardSimilarTraverser traverser =
|
||||
new JaccardSimilarTraverser(g)) {
|
||||
similarity = traverser.jaccardSimilarity(sourceId, targetId, dir,
|
||||
edgeLabel, maxDegree);
|
||||
similarity = traverser.jaccardSimilarity(sourceId, targetId, dir,
|
||||
edgeLabel, maxDegree);
|
||||
}
|
||||
return JsonUtil.toJson(ImmutableMap.of("jaccard_similarity",
|
||||
similarity));
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,56 +17,55 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.Query;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.KneighborTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.records.KneighborRecords;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.Query;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.KneighborTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.records.KneighborRecords;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/kneighbor")
|
||||
@Singleton
|
||||
@Tag(name = "KneighborAPI")
|
||||
public class KneighborAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(KneighborAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -78,7 +79,7 @@ public class KneighborAPI extends TraverserAPI {
|
|||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get k-neighbor from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}' and limit '{}'",
|
||||
|
|
@ -169,7 +170,7 @@ public class KneighborAPI extends TraverserAPI {
|
|||
@JsonProperty("max_depth")
|
||||
public int maxDepth;
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_ELEMENTS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_ELEMENTS_LIMIT);
|
||||
@JsonProperty("count_only")
|
||||
public boolean countOnly = false;
|
||||
@JsonProperty("with_vertex")
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,57 +17,56 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.Query;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.KoutTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.records.KoutRecords;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.Query;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.KoutTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.records.KoutRecords;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/kout")
|
||||
@Singleton
|
||||
@Tag(name = "KoutAPI")
|
||||
public class KoutAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(KoutAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -83,7 +84,7 @@ public class KoutAPI extends TraverserAPI {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get k-out from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', nearest " +
|
||||
"'{}', max degree '{}', capacity '{}' and limit '{}'",
|
||||
|
|
@ -153,7 +154,6 @@ public class KoutAPI extends TraverserAPI {
|
|||
if (request.withPath) {
|
||||
paths.addAll(results.paths(request.limit));
|
||||
}
|
||||
|
||||
Iterator<Vertex> iter = QueryResults.emptyIterator();
|
||||
if (request.withVertex && !request.countOnly) {
|
||||
Set<Id> ids = new HashSet<>(neighbors);
|
||||
|
|
@ -185,7 +185,7 @@ public class KoutAPI extends TraverserAPI {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_ELEMENTS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_ELEMENTS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
@JsonProperty("with_path")
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,45 +17,44 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/multinodeshortestpath")
|
||||
@Singleton
|
||||
@Tag(name = "MultiNodeShortestPathAPI")
|
||||
public class MultiNodeShortestPathAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(MultiNodeShortestPathAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.NeighborRankTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/neighborrank")
|
||||
@Singleton
|
||||
@Tag(name = "NeighborRankAPI")
|
||||
public class NeighborRankAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(NeighborRankAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,55 +17,54 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CollectionPathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/paths")
|
||||
@Singleton
|
||||
@Tag(name = "PathsAPI")
|
||||
public class PathsAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(PathsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -80,7 +81,7 @@ public class PathsAPI extends TraverserAPI {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get paths from '{}', to '{}' with " +
|
||||
"direction {}, edge label {}, max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
|
|
@ -166,7 +167,7 @@ public class PathsAPI extends TraverserAPI {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_PATHS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,43 +17,42 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEPTH;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.PersonalRankTraverser;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/personalrank")
|
||||
@Singleton
|
||||
@Tag(name = "PersonalRankAPI")
|
||||
public class PersonalRankAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(PersonalRankAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
private static final double DEFAULT_DIFF = 0.0001;
|
||||
private static final double DEFAULT_ALPHA = 0.85;
|
||||
|
|
@ -118,7 +119,7 @@ public class PersonalRankAPI extends API {
|
|||
@JsonProperty("max_degree")
|
||||
private long maxDegree = Long.parseLong(DEFAULT_MAX_DEGREE);
|
||||
@JsonProperty("limit")
|
||||
private int limit = Integer.parseInt(DEFAULT_LIMIT);
|
||||
private long limit = Long.parseLong(DEFAULT_LIMIT);
|
||||
@JsonProperty("max_depth")
|
||||
private int maxDepth = DEFAULT_DEPTH;
|
||||
@JsonProperty("with_label")
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,42 +17,41 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/rays")
|
||||
@Singleton
|
||||
@Tag(name = "RaysAPI")
|
||||
public class RaysAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RaysAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -66,7 +67,7 @@ public class RaysAPI extends API {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get rays paths from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,42 +17,41 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/rings")
|
||||
@Singleton
|
||||
@Tag(name = "RingsAPI")
|
||||
public class RingsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RingsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -68,7 +69,7 @@ public class RingsAPI extends API {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get rings paths reachable from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"source in ring '{}', max degree '{}', capacity '{}' " +
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,42 +17,41 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/sameneighbors")
|
||||
@Singleton
|
||||
@Tag(name = "SameNeighborsAPI")
|
||||
public class SameNeighborsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(SameNeighborsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -64,7 +65,7 @@ public class SameNeighborsAPI extends API {
|
|||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) int limit) {
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get same neighbors between '{}' and '{}' with " +
|
||||
"direction {}, edge label {}, max degree '{}' and limit '{}'",
|
||||
graph, vertex, other, direction, edgeLabel, maxDegree, limit);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,44 +17,43 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/shortestpath")
|
||||
@Singleton
|
||||
@Tag(name = "ShortestPathAPI")
|
||||
public class ShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(ShortestPathAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.WeightedPaths;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.WeightedPaths;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/singlesourceshortestpath")
|
||||
@Singleton
|
||||
@Tag(name = "SingleSourceShortestPathAPI")
|
||||
public class SingleSourceShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(SingleSourceShortestPathAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -72,7 +73,7 @@ public class SingleSourceShortestPathAPI extends API {
|
|||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) int limit,
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit,
|
||||
@QueryParam("with_vertex") boolean withVertex) {
|
||||
LOG.debug("Graph [{}] get single source shortest path from '{}' " +
|
||||
"with direction {}, edge label {}, weight property {}, " +
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,10 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -26,36 +28,35 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.TemplatePathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.RepeatEdgeStep;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/templatepaths")
|
||||
@Singleton
|
||||
@Tag(name = "TemplatePathsAPI")
|
||||
public class TemplatePathsAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(TemplatePathsAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
|
|
@ -133,7 +134,7 @@ public class TemplatePathsAPI extends TraverserAPI {
|
|||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public int limit = Integer.parseInt(DEFAULT_PATHS_LIMIT);
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,17 +17,17 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -25,14 +27,14 @@ import java.util.Set;
|
|||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.ConditionQuery;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import org.apache.hugegraph.type.HugeType;
|
||||
import org.apache.hugegraph.type.define.HugeKeys;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.ConditionQuery;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.optimize.TraversalUtil;
|
||||
import com.baidu.hugegraph.type.HugeType;
|
||||
import com.baidu.hugegraph.type.define.HugeKeys;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class Vertices {
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,45 +17,44 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PAGE_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PAGE_LIMIT;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.ConditionQuery;
|
||||
import org.apache.hugegraph.backend.store.Shard;
|
||||
import org.apache.hugegraph.type.HugeType;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.ConditionQuery;
|
||||
import com.baidu.hugegraph.backend.store.Shard;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.type.HugeType;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/vertices")
|
||||
@Singleton
|
||||
@Tag(name = "VerticesAPI")
|
||||
public class VerticesAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(VerticesAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,46 +17,45 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.traversers;
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.DefaultValue;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.api.graph.EdgeAPI;
|
||||
import org.apache.hugegraph.api.graph.VertexAPI;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.query.QueryResults;
|
||||
import org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.NodeWithWeight;
|
||||
import org.apache.hugegraph.type.define.Directions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.NodeWithWeight;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/weightedshortestpath")
|
||||
@Singleton
|
||||
@Tag(name = "WeightedShortestPathAPI")
|
||||
public class WeightedShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(WeightedShortestPathAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,39 +17,38 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.api.variables;
|
||||
package com.baidu.hugegraph.api.variables;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.PUT;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.hugegraph.core.GraphManager;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.api.API;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("graphs/{graph}/variables")
|
||||
@Singleton
|
||||
@Tag(name = "VariablesAPI")
|
||||
public class VariablesAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(VariablesAPI.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@PUT
|
||||
@Timed
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -23,17 +25,19 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens;
|
||||
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
|
||||
public class ConfigAuthenticator implements HugeAuthenticator {
|
||||
|
||||
public static final String KEY_USERNAME = CredentialGraphTokens.PROPERTY_USERNAME;
|
||||
public static final String KEY_PASSWORD = CredentialGraphTokens.PROPERTY_PASSWORD;
|
||||
public static final String KEY_USERNAME =
|
||||
CredentialGraphTokens.PROPERTY_USERNAME;
|
||||
public static final String KEY_PASSWORD =
|
||||
CredentialGraphTokens.PROPERTY_PASSWORD;
|
||||
|
||||
private final Map<String, String> tokens;
|
||||
|
||||
|
|
@ -69,7 +73,7 @@ public class ConfigAuthenticator implements HugeAuthenticator {
|
|||
if (username.equals(USER_ADMIN)) {
|
||||
role = ROLE_ADMIN;
|
||||
} else {
|
||||
// Return role with all permission, set username as owner graph
|
||||
// Return role with all permission, set user name as owner graph
|
||||
role = RolePermission.all(username);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -81,16 +85,12 @@ public class ConfigAuthenticator implements HugeAuthenticator {
|
|||
|
||||
@Override
|
||||
public AuthManager authManager() {
|
||||
throw new NotImplementedException("AuthManager is unsupported by ConfigAuthenticator");
|
||||
throw new NotImplementedException(
|
||||
"AuthManager is unsupported by ConfigAuthenticator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public HugeGraph graph() {
|
||||
throw new NotImplementedException("graph() is unsupported by ConfigAuthenticator");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAdminUser(String password) {
|
||||
public void initAdminUser(String password) throws Exception {
|
||||
String adminToken = this.tokens.get(USER_ADMIN);
|
||||
E.checkArgument(Objects.equals(adminToken, password),
|
||||
"The password can't be changed for " +
|
||||
|
|
@ -99,6 +99,7 @@ public class ConfigAuthenticator implements HugeAuthenticator {
|
|||
|
||||
@Override
|
||||
public SaslNegotiator newSaslNegotiator(InetAddress remoteAddress) {
|
||||
throw new NotImplementedException("SaslNegotiator is unsupported by ConfigAuthenticator");
|
||||
throw new NotImplementedException(
|
||||
"SaslNegotiator is unsupported by ConfigAuthenticator");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,21 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.auth.HugeGraphAuthProxy.Context;
|
||||
import org.apache.hugegraph.auth.HugeGraphAuthProxy.ContextThreadPoolExecutor;
|
||||
import org.apache.hugegraph.config.CoreOptions;
|
||||
import org.apache.hugegraph.event.EventHub;
|
||||
import org.apache.hugegraph.testutil.Whitebox;
|
||||
import org.apache.hugegraph.util.Events;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
|
||||
import org.apache.tinkerpop.gremlin.server.GraphManager;
|
||||
|
|
@ -39,21 +32,27 @@ import org.apache.tinkerpop.gremlin.server.util.ThreadFactoryUtil;
|
|||
import org.apache.tinkerpop.gremlin.structure.Graph;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.ContextThreadPoolExecutor;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.event.EventHub;
|
||||
import com.baidu.hugegraph.testutil.Whitebox;
|
||||
import com.baidu.hugegraph.util.Events;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
|
||||
/**
|
||||
* GremlinServer with custom ServerGremlinExecutor, which can pass Context
|
||||
*/
|
||||
public class ContextGremlinServer extends GremlinServer {
|
||||
|
||||
private static final Logger LOG = Log.logger(ContextGremlinServer.class);
|
||||
private static final Logger LOG = Log.logger(GremlinServer.class);
|
||||
|
||||
private static final String G_PREFIX = "__g_";
|
||||
|
||||
private final EventHub eventHub;
|
||||
|
||||
static {
|
||||
HugeGraphAuthProxy.setContext(Context.admin());
|
||||
}
|
||||
|
||||
public ContextGremlinServer(final Settings settings, EventHub eventHub) {
|
||||
/*
|
||||
* pass custom Executor https://github.com/apache/tinkerpop/pull/813
|
||||
|
|
@ -81,9 +80,6 @@ public class ContextGremlinServer extends GremlinServer {
|
|||
}
|
||||
|
||||
private void unlistenChanges() {
|
||||
if (this.eventHub == null) {
|
||||
return;
|
||||
}
|
||||
this.eventHub.unlisten(Events.GRAPH_CREATE);
|
||||
this.eventHub.unlisten(Events.GRAPH_DROP);
|
||||
}
|
||||
|
|
@ -98,6 +94,8 @@ public class ContextGremlinServer extends GremlinServer {
|
|||
}
|
||||
|
||||
public void injectAuthGraph() {
|
||||
HugeGraphAuthProxy.setContext(Context.admin());
|
||||
|
||||
GraphManager manager = this.getServerGremlinExecutor()
|
||||
.getGraphManager();
|
||||
for (String name : manager.getGraphNames()) {
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,61 +17,61 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.hugegraph.HugeException;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.auth.HugeGraphAuthProxy.Context;
|
||||
import org.apache.hugegraph.auth.SchemaDefine.AuthElement;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.OptionSpace;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.type.Nameable;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.JsonUtil;
|
||||
import org.apache.tinkerpop.gremlin.groovy.jsr223.dsl.credential.CredentialGraphTokens;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticationException;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.Authenticator;
|
||||
import org.apache.tinkerpop.shaded.jackson.annotation.JsonProperty;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context;
|
||||
import com.baidu.hugegraph.auth.SchemaDefine.AuthElement;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.OptionSpace;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.type.Namifiable;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
|
||||
public interface HugeAuthenticator extends Authenticator {
|
||||
|
||||
String KEY_USERNAME = CredentialGraphTokens.PROPERTY_USERNAME;
|
||||
String KEY_PASSWORD = CredentialGraphTokens.PROPERTY_PASSWORD;
|
||||
String KEY_TOKEN = "token";
|
||||
String KEY_ROLE = "role";
|
||||
String KEY_ADDRESS = "address";
|
||||
String KEY_PATH = "path";
|
||||
public static final String KEY_USERNAME =
|
||||
CredentialGraphTokens.PROPERTY_USERNAME;
|
||||
public static final String KEY_PASSWORD =
|
||||
CredentialGraphTokens.PROPERTY_PASSWORD;
|
||||
public static final String KEY_TOKEN = "token";
|
||||
public static final String KEY_ROLE = "role";
|
||||
public static final String KEY_ADDRESS = "address";
|
||||
public static final String KEY_PATH = "path";
|
||||
|
||||
String USER_SYSTEM = "system";
|
||||
String USER_ADMIN = "admin";
|
||||
String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME;
|
||||
public static final String USER_SYSTEM = "system";
|
||||
public static final String USER_ADMIN = "admin";
|
||||
public static final String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME;
|
||||
|
||||
RolePermission ROLE_NONE = RolePermission.none();
|
||||
RolePermission ROLE_ADMIN = RolePermission.admin();
|
||||
public static final RolePermission ROLE_NONE = RolePermission.none();
|
||||
public static final RolePermission ROLE_ADMIN = RolePermission.admin();
|
||||
|
||||
String VAR_PREFIX = "$";
|
||||
String KEY_OWNER = VAR_PREFIX + "owner";
|
||||
String KEY_DYNAMIC = VAR_PREFIX + "dynamic";
|
||||
String KEY_ACTION = VAR_PREFIX + "action";
|
||||
public static final String VAR_PREFIX = "$";
|
||||
public static final String KEY_OWNER = VAR_PREFIX + "owner";
|
||||
public static final String KEY_DYNAMIC = VAR_PREFIX + "dynamic";
|
||||
public static final String KEY_ACTION = VAR_PREFIX + "action";
|
||||
|
||||
void setup(HugeConfig config);
|
||||
public void setup(HugeConfig config);
|
||||
|
||||
UserWithRole authenticate(String username, String password, String token);
|
||||
|
||||
AuthManager authManager();
|
||||
|
||||
HugeGraph graph();
|
||||
public UserWithRole authenticate(String username, String password,
|
||||
String token);
|
||||
public AuthManager authManager();
|
||||
|
||||
@Override
|
||||
default void setup(final Map<String, Object> config) {
|
||||
public default void setup(final Map<String, Object> config) {
|
||||
E.checkState(config != null,
|
||||
"Must provide a 'config' in the 'authentication'");
|
||||
String path = (String) config.get("tokens");
|
||||
|
|
@ -80,9 +82,8 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
|
||||
@Override
|
||||
default User authenticate(final Map<String, String> credentials)
|
||||
throws AuthenticationException {
|
||||
|
||||
public default User authenticate(final Map<String, String> credentials)
|
||||
throws AuthenticationException {
|
||||
HugeGraphAuthProxy.resetContext();
|
||||
|
||||
User user = User.ANONYMOUS;
|
||||
|
|
@ -113,11 +114,11 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
|
||||
@Override
|
||||
default boolean requireAuthentication() {
|
||||
public default boolean requireAuthentication() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default boolean verifyRole(RolePermission role) {
|
||||
public default boolean verifyRole(RolePermission role) {
|
||||
if (role == ROLE_NONE || role == null) {
|
||||
return false;
|
||||
} else {
|
||||
|
|
@ -125,9 +126,9 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
}
|
||||
|
||||
void initAdminUser(String password) throws Exception;
|
||||
public void initAdminUser(String password) throws Exception;
|
||||
|
||||
static HugeAuthenticator loadAuthenticator(HugeConfig conf) {
|
||||
public static HugeAuthenticator loadAuthenticator(HugeConfig conf) {
|
||||
String authClass = conf.get(ServerOptions.AUTHENTICATOR);
|
||||
if (authClass.isEmpty()) {
|
||||
return null;
|
||||
|
|
@ -148,7 +149,7 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
return authenticator;
|
||||
}
|
||||
|
||||
class User extends AuthenticatedUser {
|
||||
public static class User extends AuthenticatedUser {
|
||||
|
||||
public static final User ADMIN = new User(USER_ADMIN, ROLE_ADMIN);
|
||||
public static final User ANONYMOUS = new User(USER_ANONY, ROLE_ADMIN);
|
||||
|
|
@ -253,7 +254,7 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
}
|
||||
|
||||
class RolePerm {
|
||||
public static class RolePerm {
|
||||
|
||||
@JsonProperty("roles") // graph -> action -> resource
|
||||
private Map<String, Map<HugePermission, Object>> roles;
|
||||
|
|
@ -393,7 +394,7 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
}
|
||||
|
||||
class RequiredPerm {
|
||||
public static class RequiredPerm {
|
||||
|
||||
@JsonProperty("owner")
|
||||
private String owner;
|
||||
|
|
@ -431,7 +432,7 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
}
|
||||
|
||||
public ResourceObject<?> resourceObject() {
|
||||
Nameable elem = HugeResource.NameObject.ANY;
|
||||
Namifiable elem = HugeResource.NameObject.ANY;
|
||||
return ResourceObject.of(this.owner, this.resource, elem);
|
||||
}
|
||||
|
||||
|
|
@ -491,7 +492,7 @@ public interface HugeAuthenticator extends Authenticator {
|
|||
String[] actionKV = ownerAndAction[1].split("=", 2);
|
||||
E.checkState(actionKV.length == 2,
|
||||
"Bad permission format: '%s'", permission);
|
||||
E.checkState(actionKV[0].equals(KEY_ACTION),
|
||||
E.checkState(actionKV[0].equals(StandardAuthenticator.KEY_ACTION),
|
||||
"Bad permission format: '%s'", permission);
|
||||
requiredPerm.action(actionKV[1]);
|
||||
|
||||
|
|
@ -0,0 +1,333 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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 com.baidu.hugegraph.auth;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.configuration.Configuration;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeFactory;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.StandardHugeGraph;
|
||||
import com.baidu.hugegraph.backend.cache.CacheManager;
|
||||
import com.baidu.hugegraph.backend.tx.AbstractTransaction;
|
||||
import com.baidu.hugegraph.concurrent.LockManager;
|
||||
import com.baidu.hugegraph.license.LicenseVerifier;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.SchemaManager;
|
||||
import com.baidu.hugegraph.schema.builder.EdgeLabelBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.IndexLabelBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.PropertyKeyBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.VertexLabelBuilder;
|
||||
import com.baidu.hugegraph.serializer.JsonSerializer;
|
||||
import com.baidu.hugegraph.structure.HugeEdge;
|
||||
import com.baidu.hugegraph.structure.HugeProperty;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.task.HugeTask;
|
||||
import com.baidu.hugegraph.task.StandardTaskScheduler;
|
||||
import com.baidu.hugegraph.task.TaskCallable;
|
||||
import com.baidu.hugegraph.task.TaskCallable.SysTaskCallable;
|
||||
import com.baidu.hugegraph.task.TaskManager;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy;
|
||||
import com.baidu.hugegraph.variables.HugeVariables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
public final class HugeFactoryAuthProxy {
|
||||
|
||||
public static final String GRAPH_FACTORY =
|
||||
"gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy";
|
||||
|
||||
private static final Set<String> PROTECT_METHODS = ImmutableSet.of(
|
||||
"instance");
|
||||
|
||||
private static final Map<HugeGraph, HugeGraph> graphs = new HashMap<>();
|
||||
|
||||
static {
|
||||
HugeGraphAuthProxy.setContext(HugeGraphAuthProxy.Context.admin());
|
||||
HugeFactoryAuthProxy.registerPrivateActions();
|
||||
}
|
||||
|
||||
public static synchronized HugeGraph open(Configuration config) {
|
||||
/*
|
||||
* Inject authentication (replace HugeGraph with HugeGraphAuthProxy)
|
||||
* TODO: Add verify to StandardHugeGraph() to prevent dynamic creation
|
||||
*/
|
||||
HugeGraph graph = HugeFactory.open(config);
|
||||
HugeGraph proxy = graphs.get(graph);
|
||||
if (proxy == null) {
|
||||
proxy = new HugeGraphAuthProxy(graph);
|
||||
graphs.put(graph, proxy);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private static void registerPrivateActions() {
|
||||
// Thread
|
||||
Reflection.registerFieldsToFilter(java.lang.Thread.class, "name", "priority", "threadQ", "eetop", "single_step", "daemon", "stillborn", "target", "group", "contextClassLoader", "inheritedAccessControlContext", "threadInitNumber", "threadLocals", "inheritableThreadLocals", "stackSize", "nativeParkEventPointer", "tid", "threadSeqNumber", "threadStatus", "parkBlocker", "blocker", "blockerLock", "EMPTY_STACK_TRACE", "SUBCLASS_IMPLEMENTATION_PERMISSION", "uncaughtExceptionHandler", "defaultUncaughtExceptionHandler", "threadLocalRandomSeed", "threadLocalRandomProbe", "threadLocalRandomSecondarySeed");
|
||||
Reflection.registerMethodsToFilter(java.lang.Thread.class, "exit", "dispatchUncaughtException", "clone", "isInterrupted", "registerNatives", "init", "init", "nextThreadNum", "nextThreadID", "blockedOn", "start0", "isCCLOverridden", "auditSubclass", "dumpThreads", "getThreads", "processQueue", "setPriority0", "stop0", "suspend0", "resume0", "interrupt0", "setNativeName");
|
||||
Reflection.registerFieldsToFilter(java.lang.ThreadLocal.class, "threadLocalHashCode", "nextHashCode", "HASH_INCREMENT");
|
||||
Reflection.registerMethodsToFilter(java.lang.ThreadLocal.class, "access$400", "createInheritedMap", "nextHashCode", "initialValue", "setInitialValue", "getMap", "createMap", "childValue");
|
||||
Reflection.registerMethodsToFilter(java.lang.InheritableThreadLocal.class, "getMap", "createMap", "childValue");
|
||||
|
||||
// HugeGraph
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.StandardAuthenticator.class, "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.StandardAuthenticator.class, "initAdminUser", "inputPassword", "graph");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.ConfigAuthenticator.class, "tokens");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeFactoryAuthProxy.class, "PROTECT_METHODS");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeFactoryAuthProxy.class, "genRegisterPrivateActions", "registerClass", "registerPrivateActions", "registerPrivateActions", "c");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeAuthenticator.User.class, "role", "client");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser.class, "name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.class, "LOG", "hugegraph", "taskScheduler", "authManager", "contexts", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.class, "lambda$0", "access$3", "access$4", "access$2", "access$5", "resetContext", "logUser", "verifyAdminPermission", "verifyStatusPermission", "verifyPermission", "verifySchemaPermission", "verifySchemaPermission", "verifySchemaPermission", "verifySchemaPermission", "verifyNamePermission", "verifyNameExistsPermission", "verifyElemPermission", "verifyElemPermission", "verifyElemPermission", "verifyElemPermission", "verifyResPermission", "verifyResPermission", "verifyUserPermission", "verifyUserPermission", "verifyUserPermission", "getContextString", "access$6", "access$7", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "lambda$8", "lambda$9", "lambda$10", "lambda$11", "lambda$12", "lambda$13", "lambda$14", "lambda$15", "lambda$16", "lambda$17", "lambda$18", "lambda$19", "lambda$20", "lambda$21", "lambda$22", "lambda$23", "lambda$24", "access$8", "access$9", "access$10", "setContext", "getContext");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.AuthManagerProxy.class, "authManager", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.AuthManagerProxy.class, "currentUsername", "updateCreator");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TaskSchedulerProxy.class, "taskScheduler", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TaskSchedulerProxy.class, "lambda$0", "lambda$1", "lambda$2", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "hasTaskPermission");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.GraphTraversalSourceProxy.class, "this$0");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.class, "connection", "graph", "strategies", "bytecode");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TraversalStrategiesProxy.class, "REST_WOEKER", "serialVersionUID", "strategies", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TraversalStrategiesProxy.class, "translate");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.VariablesProxy.class, "variables", "this$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context.class, "ADMIN", "user");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.ContextTask.class, "runner", "context");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.StandardHugeGraph.class, "LOG", "started", "closed", "mode", "variables", "name", "params", "configuration", "schemaEventHub", "graphEventHub", "indexEventHub", "writeRateLimiter", "readRateLimiter", "taskManager", "authManager", "features", "storeProvider", "tx", "ramtable", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.StandardHugeGraph.class, "lambda$0", "access$3", "access$4", "access$2", "access$5", "access$6", "access$7", "waitUntilAllTasksCompleted", "access$8", "loadStoreProvider", "graphTransaction", "schemaTransaction", "openSchemaTransaction", "checkGraphNotClosed", "openSystemTransaction", "openGraphTransaction", "systemTransaction", "access$9", "access$10", "access$11", "access$12", "access$13", "access$14", "access$15", "access$16", "access$17", "access$18", "serializer", "loadSchemaStore", "loadSystemStore", "loadGraphStore", "closeTx", "analyzer", "serverInfoManager", "reloadRamtable", "reloadRamtable", "access$19", "access$20", "access$21");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "graph", "this$0");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "access$1", "graph");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction"), "refs", "opened", "transactions", "this$0", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction"), "lambda$0", "access$3", "access$2", "lambda$1", "graphTransaction", "schemaTransaction", "systemTransaction", "access$1", "setOpened", "doCommit", "verifyOpened", "doRollback", "doClose", "destroyTransaction", "doOpen", "setClosed", "getOrNewTransaction", "access$0", "resetState");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractThreadLocalTransaction.class, "readWriteConsumerInternal", "closeConsumerInternal", "transactionListeners");
|
||||
Reflection.registerMethodsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractThreadLocalTransaction.class, "doClose", "fireOnCommit", "fireOnRollback", "doReadWrite", "lambda$fireOnRollback$1", "lambda$fireOnCommit$0");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.class, "g");
|
||||
Reflection.registerMethodsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.class, "doCommit", "doRollback", "doClose", "doOpen", "fireOnCommit", "fireOnRollback", "doReadWrite");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$Txs"), "schemaTx", "systemTx", "graphTx", "openedTime", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$Txs"), "access$2", "access$1", "access$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.GraphTransaction.class, "indexTx", "addedVertices", "removedVertices", "addedEdges", "removedEdges", "addedProps", "removedProps", "updatedVertices", "updatedEdges", "updatedOldestProps", "locksTable", "checkCustomVertexExist", "checkAdjacentVertexExist", "lazyLoadAdjacentVertex", "ignoreInvalidEntry", "commitPartOfAdjacentEdges", "batchSize", "pageSize", "verticesCapacity", "edgesCapacity", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.GraphTransaction.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "lambda$8", "lambda$9", "lambda$10", "lambda$11", "lambda$12", "lambda$13", "lambda$14", "lambda$15", "lambda$16", "lambda$17", "lambda$18", "lambda$19", "access$1", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "indexTransaction", "indexTransaction", "beforeWrite", "prepareCommit", "verticesInTxSize", "edgesInTxSize", "checkTxVerticesCapacity", "checkTxEdgesCapacity", "verticesInTxUpdated", "verticesInTxRemoved", "removingEdgeOwner", "prepareDeletions", "prepareDeletions", "prepareUpdates", "prepareAdditions", "checkVertexExistIfCustomizedId", "checkAggregateProperty", "checkAggregateProperty", "checkNonnullProperty", "queryEdgesFromBackend", "commitPartOfEdgeDeletions", "optimizeQueries", "checkVertexLabel", "checkId", "queryVerticesFromBackend", "joinTxVertices", "joinTxEdges", "lockForUpdateProperty", "optimizeQuery", "verifyVerticesConditionQuery", "verifyEdgesConditionQuery", "indexQuery", "joinTxRecords", "propertyUpdated", "parseEntry", "traverseByLabel", "reset", "queryVerticesByIds", "filterUnmatchedRecords", "skipOffsetOrStopLimit", "filterExpiredResultFromFromBackend", "queryEdgesByIds", "matchEdgeSortKeys", "rightResultFromIndexQuery");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.IndexableTransaction.class, "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.IndexableTransaction.class, "indexTransaction", "commit2Backend", "reset");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.AbstractTransaction.class, "LOG", "ownerThread", "autoCommit", "closed", "committing", "committing2Backend", "graph", "store", "mutation", "serializer", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.AbstractTransaction.class, "beforeWrite", "prepareCommit", "params", "mutation", "commit2Backend", "autoCommit", "beforeRead", "afterWrite", "afterRead", "commitMutation2Backend", "checkOwnerThread", "doAction", "store", "reset");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.HugeFactory.class, "LOG", "NAME_REGEX", "graphs");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.HugeFactory.class, "lambda$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.SchemaElement.class, "graph", "id", "name", "userdata", "status");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeVertex.class, "EMPTY_SET", "id", "label", "edges", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeVertex.class, "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "newProperty", "newProperty", "tx", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "checkIdLength", "onUpdateProperty", "ensureFilledProperties", "clone", "clone");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeElement.class, "EMPTY_MAP", "MAX_PROPERTIES", "graph", "properties", "expiredTime", "removed", "fresh", "propLoaded", "defaultValueUpdated", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeElement.class, "removed", "addProperty", "newProperty", "tx", "onUpdateProperty", "ensureFilledProperties", "propLoaded", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality", "getIdValue", "fresh", "updateToDefaultValueIfNone", "copyProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeEdge.class, "id", "label", "name", "sourceVertex", "targetVertex", "isOutEdge", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "$SWITCH_TABLE$org$apache$tinkerpop$gremlin$structure$Direction");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeEdge.class, "checkAdjacentVertexExist", "newProperty", "newProperty", "tx", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "onUpdateProperty", "ensureFilledProperties", "$SWITCH_TABLE$org$apache$tinkerpop$gremlin$structure$Direction", "clone", "clone");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeProperty.class, "owner", "pkey", "value");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.variables.HugeVariables.class, "LOG", "VARIABLES", "VARIABLE_KEY", "VARIABLE_TYPE", "BYTE_VALUE", "BOOLEAN_VALUE", "INTEGER_VALUE", "LONG_VALUE", "FLOAT_VALUE", "DOUBLE_VALUE", "STRING_VALUE", "LIST", "SET", "TYPES", "params", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.variables.HugeVariables.class, "createPropertyKey", "queryAllVariableVertices", "queryVariableVertex", "createVariableVertex", "removeVariableVertex", "extractSingleObject", "setProperty");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.SchemaManager.class, "transaction", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.SchemaManager.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "checkExists");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.PropertyKeyBuilder.class, "id", "name", "dataType", "cardinality", "aggregateType", "checkExist", "userdata", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.PropertyKeyBuilder.class, "lambda$0", "checkStableVars", "checkAggregateType", "hasSameProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.AbstractBuilder.class, "transaction", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.AbstractBuilder.class, "rebuildIndex", "graph", "checkSchemaName", "validOrGenerateId", "lockCheckAndCreateSchema", "propertyKeyOrNull", "checkSchemaIdIfRestoringMode", "vertexLabelOrNull", "edgeLabelOrNull", "indexLabelOrNull", "updateSchemaStatus");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.VertexLabelBuilder.class, "id", "name", "idStrategy", "properties", "primaryKeys", "nullableKeys", "ttl", "ttlStartTime", "enableLabelIndex", "userdata", "checkExist", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.VertexLabelBuilder.class, "lambda$0", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "checkProperties", "checkNullableKeys", "checkIdStrategy", "checkPrimaryKeys", "hasSameProperties", "checkTtl", "checkUserdata", "mapPkId2Name", "mapPkId2Name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.EdgeLabelBuilder.class, "id", "name", "sourceLabel", "targetLabel", "frequency", "properties", "sortKeys", "nullableKeys", "ttl", "ttlStartTime", "enableLabelIndex", "userdata", "checkExist", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.EdgeLabelBuilder.class, "lambda$0", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "checkProperties", "checkNullableKeys", "checkSortKeys", "checkRelation", "hasSameProperties", "checkTtl", "checkUserdata", "mapPkId2Name", "mapPkId2Name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.IndexLabelBuilder.class, "id", "name", "baseType", "baseValue", "indexType", "indexFields", "userdata", "checkExist", "rebuild", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$DataType", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IndexType");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.IndexLabelBuilder.class, "lambda$0", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$DataType", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IndexType", "checkBaseType", "checkIndexType", "checkFields4Range", "loadElement", "checkFields", "checkRepeatIndex", "checkRepeatIndex", "checkRepeatIndex", "checkPrimaryKeyIndex", "checkRepeatRangeIndex", "checkRepeatSearchIndex", "checkRepeatSecondaryIndex", "checkRepeatShardIndex", "checkRepeatUniqueIndex", "removeSubIndex", "hasSubIndex", "allStringIndex", "oneNumericField", "hasSameProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskManager.class, "LOG", "SCHEDULE_PERIOD", "THREADS", "MANAGER", "schedulers", "taskExecutor", "taskDbExecutor", "serverInfoDbExecutor", "schedulerExecutor", "contexts", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskManager.class, "lambda$0", "resetContext", "closeTaskTx", "setContext", "instance", "closeSchedulerTx", "notifyNewTask", "scheduleOrExecuteJob", "scheduleOrExecuteJobForGraph");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.StandardTaskScheduler.class, "LOG", "graph", "serverManager", "taskExecutor", "taskDbExecutor", "eventListener", "tasks", "taskTx", "NO_LIMIT", "PAGE_SIZE", "QUERY_INTERVAL", "MAX_PENDING_TASKS", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.StandardTaskScheduler.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "tx", "listenChanges", "unlistenChanges", "submitTask", "queryTask", "queryTask", "queryTask", "call", "call", "remove", "sleep", "taskDone", "serverManager", "supportsPaging", "restore", "checkOnMasterNode", "waitUntilTaskCompleted", "scheduleTasks", "executeTasksOnWorker", "cancelTasksOnWorker");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.HugeTask.class, "LOG", "DECOMPRESS_RATIO", "scheduler", "callable", "type", "name", "id", "parent", "dependencies", "description", "context", "create", "server", "load", "status", "progress", "update", "retries", "input", "result", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.HugeTask.class, "property", "scheduler", "scheduler", "asArray", "checkPropertySize", "checkPropertySize", "checkDependenciesSuccess", "toOrderSet", "done", "callable", "setException", "set", "result", "status");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskCallable.class, "LOG", "ERROR_COMMIT", "ERROR_MESSAGES", "task", "graph", "lastSaveTime", "saveInterval");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskCallable.class, "graph", "closeTx", "cancelled", "done", "task", "save", "needSaveWithEx");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskCallable.SysTaskCallable.class, "params");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskCallable.SysTaskCallable.class, "params", "params");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.StandardAuthManager.class, "CACHE_EXPIRE", "graph", "eventListener", "usersCache", "users", "groups", "targets", "belong", "access", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.StandardAuthManager.class, "lambda$0", "listenChanges", "unlistenChanges", "invalidCache", "initSchemaIfNeeded", "rolePermission", "rolePermission", "rolePermission", "cache");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.SchemaDefine.class, "graph", "label");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.SchemaDefine.class, "schema", "createPropertyKey", "createPropertyKey", "createPropertyKey", "existEdgeLabel", "createRangeIndex", "unhideField", "hideField", "existVertexLabel", "initProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.EntityManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.EntityManager.class, "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryEntity", "constructVertex", "save", "query");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.RelationshipManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.RelationshipManager.class, "lambda$0", "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryRelationship", "newVertex", "save");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.cache.CacheManager.class, "LOG", "INSTANCE", "TIMER_TICK_PERIOD", "LOG_TICK_COST_TIME", "caches", "timer");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.cache.CacheManager.class, "access$0", "scheduleTimer", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.concurrent.LockManager.class, "INSTANCE", "lockGroupMap");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.concurrent.LockManager.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.license.LicenseVerifier.class, "LOG", "LICENSE_PARAM_PATH", "INSTANCE", "CHECK_INTERVAL", "lastCheckTime", "verifyParam", "manager");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.license.LicenseVerifier.class, "buildVerifyParam", "initLicenseParam", "verifyPublicCert", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.metrics.ServerReporter.class, "instance", "gauges", "counters", "histograms", "meters", "timers");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.metrics.ServerReporter.class, "instance", "instance");
|
||||
Reflection.registerFieldsToFilter(com.codahale.metrics.ScheduledReporter.class, "LOG", "FACTORY_ID", "registry", "executor", "shutdownExecutorOnStop", "disabledMetricAttributes", "scheduledFuture", "filter", "durationFactor", "durationUnit", "rateFactor", "rateUnit");
|
||||
Reflection.registerMethodsToFilter(com.codahale.metrics.ScheduledReporter.class, "convertDuration", "convertRate", "getRateUnit", "getDurationUnit", "isShutdownExecutorOnStop", "getDisabledMetricAttributes", "calculateRateUnit", "createDefaultExecutor", "lambda$start$0", "start");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.serializer.JsonSerializer.class, "LBUF_SIZE", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.serializer.JsonSerializer.class, "writeIterator", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy.class, "lambda$0", "instance");
|
||||
|
||||
// Enable this line to generate registration statement
|
||||
//genRegisterPrivateActions();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void genRegisterPrivateActions() {
|
||||
registerPrivateActions(Thread.class);
|
||||
registerPrivateActions(ThreadLocal.class);
|
||||
registerPrivateActions(InheritableThreadLocal.class);
|
||||
|
||||
registerPrivateActions(StandardAuthenticator.class);
|
||||
registerPrivateActions(ConfigAuthenticator.class);
|
||||
registerPrivateActions(HugeFactoryAuthProxy.class);
|
||||
registerPrivateActions(HugeAuthenticator.User.class);
|
||||
|
||||
registerPrivateActions(HugeGraphAuthProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.AuthManagerProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.TaskSchedulerProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.GraphTraversalSourceProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.TraversalStrategiesProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.VariablesProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.Context.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.ContextThreadPoolExecutor.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.ContextTask.class);
|
||||
|
||||
for (Class<?> clazz : StandardHugeGraph.PROTECT_CLASSES) {
|
||||
registerPrivateActions(clazz);
|
||||
}
|
||||
|
||||
registerPrivateActions(HugeFactory.class);
|
||||
registerPrivateActions(AbstractTransaction.class);
|
||||
|
||||
registerPrivateActions(SchemaElement.class);
|
||||
registerPrivateActions(HugeVertex.class);
|
||||
registerPrivateActions(HugeEdge.class);
|
||||
registerPrivateActions(HugeProperty.class);
|
||||
registerPrivateActions(HugeVariables.class);
|
||||
|
||||
registerPrivateActions(SchemaManager.class);
|
||||
registerPrivateActions(PropertyKeyBuilder.class);
|
||||
registerPrivateActions(VertexLabelBuilder.class);
|
||||
registerPrivateActions(EdgeLabelBuilder.class);
|
||||
registerPrivateActions(IndexLabelBuilder.class);
|
||||
|
||||
registerPrivateActions(TaskManager.class);
|
||||
registerPrivateActions(StandardTaskScheduler.class);
|
||||
registerPrivateActions(HugeTask.class);
|
||||
registerPrivateActions(TaskCallable.class);
|
||||
registerPrivateActions(SysTaskCallable.class);
|
||||
|
||||
registerPrivateActions(StandardAuthManager.class);
|
||||
registerPrivateActions(SchemaDefine.class);
|
||||
registerPrivateActions(EntityManager.class);
|
||||
registerPrivateActions(RelationshipManager.class);
|
||||
|
||||
// Don't shield them because need to access by auth RPC
|
||||
//registerPrivateActions(HugeUser.class);
|
||||
//registerPrivateActions(RolePermission.class);
|
||||
//registerPrivateActions(HugeResource.class);
|
||||
|
||||
registerPrivateActions(CacheManager.class);
|
||||
registerPrivateActions(LockManager.class);
|
||||
registerPrivateActions(LicenseVerifier.class);
|
||||
registerPrivateActions(ServerReporter.class);
|
||||
registerPrivateActions(JsonSerializer.class);
|
||||
registerPrivateActions(HugeVertexStepStrategy.class);
|
||||
registerPrivateActions(HugeGraphStepStrategy.class);
|
||||
registerPrivateActions(HugeCountStepStrategy.class);
|
||||
}
|
||||
|
||||
private static void registerPrivateActions(Class<?> clazz) {
|
||||
while (clazz != Object.class) {
|
||||
List<String> fields = new ArrayList<>();
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
fields.add(field.getName());
|
||||
}
|
||||
}
|
||||
List<String> methods = new ArrayList<>();
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (!Modifier.isPublic(method.getModifiers()) ||
|
||||
PROTECT_METHODS.contains(method.getName())) {
|
||||
methods.add(method.getName());
|
||||
}
|
||||
}
|
||||
registerClass(clazz, fields, methods);
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean registerClass(Class<?> clazz,
|
||||
List<String> fields,
|
||||
List<String> methods) {
|
||||
if (clazz.getName().startsWith("java") ||
|
||||
fields.isEmpty() && methods.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final String[] array = new String[fields.size()];
|
||||
try {
|
||||
Reflection.registerFieldsToFilter(clazz, fields.toArray(array));
|
||||
Reflection.registerMethodsToFilter(clazz, methods.toArray(array));
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (e.getMessage().contains("Filter already registered: class")) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
String code;
|
||||
code = String.format("Reflection.registerFieldsToFilter(%s.class, \"%s\");",
|
||||
clazz.getCanonicalName(), String.join("\", \"", fields));
|
||||
if (!fields.isEmpty()) {
|
||||
System.out.println(code);
|
||||
}
|
||||
|
||||
code = String.format("Reflection.registerMethodsToFilter(%s.class, \"%s\");",
|
||||
clazz.getCanonicalName(), String.join("\", \"", methods));
|
||||
if (!methods.isEmpty()) {
|
||||
System.out.println(code);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Class<?> c(String clazz) {
|
||||
try {
|
||||
return Class.forName(clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new HugeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,12 +17,11 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
|
@ -35,62 +36,17 @@ import java.util.concurrent.TimeoutException;
|
|||
import java.util.function.Supplier;
|
||||
|
||||
import javax.security.sasl.AuthenticationException;
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.NotAuthorizedException;
|
||||
|
||||
import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.RolePerm;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator.User;
|
||||
import org.apache.hugegraph.auth.SchemaDefine.AuthElement;
|
||||
import org.apache.hugegraph.backend.cache.Cache;
|
||||
import org.apache.hugegraph.backend.cache.CacheManager;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.backend.query.Query;
|
||||
import org.apache.hugegraph.backend.store.BackendFeatures;
|
||||
import org.apache.hugegraph.backend.store.BackendStoreInfo;
|
||||
import org.apache.hugegraph.backend.store.raft.RaftGroupManager;
|
||||
import org.apache.hugegraph.config.AuthOptions;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.TypedOption;
|
||||
import org.apache.hugegraph.exception.NotSupportException;
|
||||
import org.apache.hugegraph.iterator.FilterIterator;
|
||||
import org.apache.hugegraph.iterator.MapperIterator;
|
||||
import org.apache.hugegraph.masterelection.RoleElectionStateMachine;
|
||||
import org.apache.hugegraph.rpc.RpcServiceConfig4Client;
|
||||
import org.apache.hugegraph.rpc.RpcServiceConfig4Server;
|
||||
import org.apache.hugegraph.schema.EdgeLabel;
|
||||
import org.apache.hugegraph.schema.IndexLabel;
|
||||
import org.apache.hugegraph.schema.PropertyKey;
|
||||
import org.apache.hugegraph.schema.SchemaElement;
|
||||
import org.apache.hugegraph.schema.SchemaLabel;
|
||||
import org.apache.hugegraph.schema.SchemaManager;
|
||||
import org.apache.hugegraph.schema.VertexLabel;
|
||||
import org.apache.hugegraph.structure.HugeEdge;
|
||||
import org.apache.hugegraph.structure.HugeElement;
|
||||
import org.apache.hugegraph.structure.HugeFeatures;
|
||||
import org.apache.hugegraph.structure.HugeVertex;
|
||||
import org.apache.hugegraph.task.HugeTask;
|
||||
import org.apache.hugegraph.task.TaskManager;
|
||||
import org.apache.hugegraph.task.TaskScheduler;
|
||||
import org.apache.hugegraph.task.TaskStatus;
|
||||
import org.apache.hugegraph.traversal.optimize.HugeScriptTraversal;
|
||||
import org.apache.hugegraph.type.HugeType;
|
||||
import org.apache.hugegraph.type.Nameable;
|
||||
import org.apache.hugegraph.type.define.GraphMode;
|
||||
import org.apache.hugegraph.type.define.GraphReadMode;
|
||||
import org.apache.hugegraph.type.define.NodeRole;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.apache.hugegraph.util.RateLimiter;
|
||||
import org.apache.tinkerpop.gremlin.groovy.jsr223.GroovyTranslator;
|
||||
import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.Bytecode;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.Bytecode.Instruction;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.Script;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.translator.GroovyTranslator;
|
||||
import org.apache.tinkerpop.gremlin.structure.Edge;
|
||||
import org.apache.tinkerpop.gremlin.structure.Element;
|
||||
import org.apache.tinkerpop.gremlin.structure.Graph;
|
||||
|
|
@ -101,10 +57,49 @@ import org.apache.tinkerpop.gremlin.structure.VertexProperty;
|
|||
import org.apache.tinkerpop.gremlin.structure.io.Io;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.alipay.remoting.rpc.RpcServer;
|
||||
|
||||
import jakarta.ws.rs.ForbiddenException;
|
||||
import jakarta.ws.rs.NotAuthorizedException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.RolePerm;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator.User;
|
||||
import com.baidu.hugegraph.auth.SchemaDefine.AuthElement;
|
||||
import com.baidu.hugegraph.backend.cache.Cache;
|
||||
import com.baidu.hugegraph.backend.cache.CacheManager;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.backend.query.Query;
|
||||
import com.baidu.hugegraph.backend.store.BackendFeatures;
|
||||
import com.baidu.hugegraph.backend.store.BackendStoreSystemInfo;
|
||||
import com.baidu.hugegraph.backend.store.raft.RaftGroupManager;
|
||||
import com.baidu.hugegraph.config.AuthOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.TypedOption;
|
||||
import com.baidu.hugegraph.exception.NotSupportException;
|
||||
import com.baidu.hugegraph.iterator.FilterIterator;
|
||||
import com.baidu.hugegraph.rpc.RpcServiceConfig4Client;
|
||||
import com.baidu.hugegraph.rpc.RpcServiceConfig4Server;
|
||||
import com.baidu.hugegraph.schema.EdgeLabel;
|
||||
import com.baidu.hugegraph.schema.IndexLabel;
|
||||
import com.baidu.hugegraph.schema.PropertyKey;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.SchemaLabel;
|
||||
import com.baidu.hugegraph.schema.SchemaManager;
|
||||
import com.baidu.hugegraph.schema.VertexLabel;
|
||||
import com.baidu.hugegraph.structure.HugeEdge;
|
||||
import com.baidu.hugegraph.structure.HugeElement;
|
||||
import com.baidu.hugegraph.structure.HugeFeatures;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.task.HugeTask;
|
||||
import com.baidu.hugegraph.task.TaskManager;
|
||||
import com.baidu.hugegraph.task.TaskScheduler;
|
||||
import com.baidu.hugegraph.task.TaskStatus;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeScriptTraversal;
|
||||
import com.baidu.hugegraph.type.HugeType;
|
||||
import com.baidu.hugegraph.type.Namifiable;
|
||||
import com.baidu.hugegraph.type.define.GraphMode;
|
||||
import com.baidu.hugegraph.type.define.GraphReadMode;
|
||||
import com.baidu.hugegraph.type.define.NodeRole;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.util.RateLimiter;
|
||||
|
||||
public final class HugeGraphAuthProxy implements HugeGraph {
|
||||
|
||||
|
|
@ -194,12 +189,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return this.hugegraph.addPropertyKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePropertyKey(PropertyKey key) {
|
||||
verifySchemaPermission(HugePermission.WRITE, key);
|
||||
this.hugegraph.updatePropertyKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id removePropertyKey(Id key) {
|
||||
PropertyKey pkey = this.hugegraph.propertyKey(key);
|
||||
|
|
@ -245,12 +234,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
this.hugegraph.addVertexLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateVertexLabel(VertexLabel label) {
|
||||
verifySchemaPermission(HugePermission.WRITE, label);
|
||||
this.hugegraph.updateVertexLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id removeVertexLabel(Id id) {
|
||||
VertexLabel label = this.hugegraph.vertexLabel(id);
|
||||
|
|
@ -304,12 +287,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
this.hugegraph.addEdgeLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEdgeLabel(EdgeLabel label) {
|
||||
verifySchemaPermission(HugePermission.WRITE, label);
|
||||
this.hugegraph.updateEdgeLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id removeEdgeLabel(Id id) {
|
||||
EdgeLabel label = this.hugegraph.edgeLabel(id);
|
||||
|
|
@ -356,12 +333,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
this.hugegraph.addIndexLabel(schemaLabel, indexLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIndexLabel(IndexLabel label) {
|
||||
verifySchemaPermission(HugePermission.WRITE, label);
|
||||
this.hugegraph.updateIndexLabel(label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id removeIndexLabel(Id id) {
|
||||
IndexLabel label = this.hugegraph.indexLabel(id);
|
||||
|
|
@ -579,8 +550,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
|
||||
@Override
|
||||
public HugeConfig configuration() {
|
||||
this.verifyAdminPermission();
|
||||
return (HugeConfig) this.hugegraph.configuration();
|
||||
throw new NotSupportException("Graph.configuration()");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -627,9 +597,15 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BackendStoreInfo backendStoreInfo() {
|
||||
public String backendVersion() {
|
||||
this.verifyAnyPermission();
|
||||
return this.hugegraph.backendVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackendStoreSystemInfo backendStoreSystemInfo() {
|
||||
this.verifyAdminPermission();
|
||||
return this.hugegraph.backendStoreInfo();
|
||||
return this.hugegraph.backendStoreSystemInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -663,9 +639,9 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void waitReady(RpcServer rpcServer) {
|
||||
public void waitStarted() {
|
||||
this.verifyAnyPermission();
|
||||
this.hugegraph.waitReady(rpcServer);
|
||||
this.hugegraph.waitStarted();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -705,12 +681,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return this.authManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoleElectionStateMachine roleElectionStateMachine() {
|
||||
this.verifyAdminPermission();
|
||||
return this.hugegraph.roleElectionStateMachine();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void switchAuthManager(AuthManager authManager) {
|
||||
this.verifyAdminPermission();
|
||||
|
|
@ -718,9 +688,9 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
|
||||
@Override
|
||||
public RaftGroupManager raftGroupManager() {
|
||||
public RaftGroupManager raftGroupManager(String group) {
|
||||
this.verifyAdminPermission();
|
||||
return this.hugegraph.raftGroupManager();
|
||||
return this.hugegraph.raftGroupManager(group);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -757,12 +727,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSystemInfo() {
|
||||
this.verifyAdminPermission();
|
||||
this.hugegraph.initSystemInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSnapshot() {
|
||||
this.verifyPermission(HugePermission.WRITE, ResourceType.STATUS);
|
||||
|
|
@ -826,7 +790,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
*/
|
||||
verifyResPermission(actionPerm, true, () -> {
|
||||
String graph = this.hugegraph.name();
|
||||
Nameable elem = HugeResource.NameObject.ANY;
|
||||
Namifiable elem = HugeResource.NameObject.ANY;
|
||||
return ResourceObject.of(graph, resType, elem);
|
||||
});
|
||||
}
|
||||
|
|
@ -905,7 +869,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
ResourceType resType, String name) {
|
||||
verifyResPermission(actionPerm, true, () -> {
|
||||
String graph = this.hugegraph.name();
|
||||
Nameable elem = HugeResource.NameObject.of(name);
|
||||
Namifiable elem = HugeResource.NameObject.of(name);
|
||||
return ResourceObject.of(graph, resType, elem);
|
||||
});
|
||||
}
|
||||
|
|
@ -1027,12 +991,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return this.taskScheduler.graph();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
verifyAdminPermission();
|
||||
this.taskScheduler.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int pendingTasks() {
|
||||
verifyTaskPermission(HugePermission.READ);
|
||||
|
|
@ -1147,7 +1105,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
Object r = verifyResPermission(actionPerm, throwIfNoPerm, () -> {
|
||||
String graph = HugeGraphAuthProxy.this.hugegraph.name();
|
||||
String name = task.id().toString();
|
||||
Nameable elem = HugeResource.NameObject.of(name);
|
||||
Namifiable elem = HugeResource.NameObject.of(name);
|
||||
return ResourceObject.of(graph, ResourceType.TASK, elem);
|
||||
}, () -> {
|
||||
return hasTaskPermission(task);
|
||||
|
|
@ -1196,12 +1154,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
verifyAdminPermission();
|
||||
this.authManager.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean close() {
|
||||
verifyAdminPermission();
|
||||
|
|
@ -1659,20 +1611,40 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Iterator<TraversalStrategy<?>> iterator() {
|
||||
if (this.strategies == null) {
|
||||
return Collections.emptyIterator();
|
||||
|
||||
public void applyStrategies(Admin<?, ?> traversal) {
|
||||
String script;
|
||||
if (traversal instanceof HugeScriptTraversal) {
|
||||
script = ((HugeScriptTraversal<?, ?>) traversal).script();
|
||||
} else {
|
||||
GroovyTranslator translator = GroovyTranslator.of("g");
|
||||
script = translator.translate(traversal.getBytecode());
|
||||
}
|
||||
return new MapperIterator<>(this.strategies.iterator(), TraversalStrategyProxy::new);
|
||||
|
||||
/*
|
||||
* Verify gremlin-execute permission for user gremlin(in gremlin-
|
||||
* server-exec worker) and gremlin job(in task worker).
|
||||
* But don't check permission in rest worker, because the following
|
||||
* places need to call traversal():
|
||||
* 1.vertices/edges rest api
|
||||
* 2.oltp rest api (like crosspointpath/neighborrank)
|
||||
* 3.olap rest api (like centrality/lpa/louvain/subgraph)
|
||||
*/
|
||||
String caller = Thread.currentThread().getName();
|
||||
if (!caller.contains(REST_WORKER)) {
|
||||
verifyNamePermission(HugePermission.EXECUTE,
|
||||
ResourceType.GREMLIN, script);
|
||||
}
|
||||
|
||||
this.strategies.applyStrategies(traversal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TraversalStrategies addStrategies(TraversalStrategy<?>... strategies) {
|
||||
public TraversalStrategies addStrategies(TraversalStrategy<?>...
|
||||
strategies) {
|
||||
return this.strategies.addStrategies(strategies);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked"})
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Override
|
||||
public TraversalStrategies removeStrategies(
|
||||
Class<? extends TraversalStrategy>... strategyClasses) {
|
||||
|
|
@ -1681,7 +1653,6 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
|
||||
@Override
|
||||
public TraversalStrategies clone() {
|
||||
// CHECKSTYLE:OFF
|
||||
return this.strategies.clone();
|
||||
}
|
||||
|
||||
|
|
@ -1703,106 +1674,20 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
}
|
||||
}
|
||||
|
||||
private final class TraversalStrategyProxy<T extends TraversalStrategy<?>>
|
||||
implements TraversalStrategy<T> {
|
||||
private static final ThreadLocal<Context> contexts =
|
||||
new InheritableThreadLocal<>();
|
||||
|
||||
private static final long serialVersionUID = 2071829024642435735L;
|
||||
|
||||
private final TraversalStrategy<T> origin;
|
||||
|
||||
public TraversalStrategyProxy(TraversalStrategy<?> origin) {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
TraversalStrategy<T> strategy = (TraversalStrategy) origin;
|
||||
this.origin = strategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Traversal.Admin<?, ?> traversal) {
|
||||
String script;
|
||||
if (traversal instanceof HugeScriptTraversal) {
|
||||
script = ((HugeScriptTraversal<?, ?>) traversal).script();
|
||||
} else {
|
||||
GroovyTranslator translator = GroovyTranslator.of("g");
|
||||
Script script1 = translator.translate(traversal.getBytecode());
|
||||
if (script1 != null) {
|
||||
script = script1.getScript();
|
||||
} else {
|
||||
script = "";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify gremlin-execute permission for user gremlin(in gremlin-
|
||||
* server-exec worker) and gremlin job(in task worker).
|
||||
* But don't check permission in rest worker, because the following
|
||||
* places need to call traversal():
|
||||
* 1.vertices/edges rest api
|
||||
* 2.oltp rest api (like crosspointpath/neighborrank)
|
||||
* 3.olap rest api (like centrality/lpa/louvain/subgraph)
|
||||
*/
|
||||
String caller = Thread.currentThread().getName();
|
||||
if (!caller.contains(TraversalStrategiesProxy.REST_WORKER)) {
|
||||
verifyNamePermission(HugePermission.EXECUTE,
|
||||
ResourceType.GREMLIN, script);
|
||||
}
|
||||
|
||||
this.origin.apply(traversal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class<? extends T>> applyPrior() {
|
||||
return this.origin.applyPrior();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Class<? extends T>> applyPost() {
|
||||
return this.origin.applyPost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getTraversalCategory() {
|
||||
return this.origin.getTraversalCategory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
return this.origin.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Class<? extends TraversalStrategy> other) {
|
||||
return this.origin.compareTo(other);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.origin.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return this.origin.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.origin.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Context> CONTEXTS = new InheritableThreadLocal<>();
|
||||
|
||||
protected static Context setContext(Context context) {
|
||||
Context old = CONTEXTS.get();
|
||||
CONTEXTS.set(context);
|
||||
protected static final Context setContext(Context context) {
|
||||
Context old = contexts.get();
|
||||
contexts.set(context);
|
||||
return old;
|
||||
}
|
||||
|
||||
protected static void resetContext() {
|
||||
CONTEXTS.remove();
|
||||
protected static final void resetContext() {
|
||||
contexts.remove();
|
||||
}
|
||||
|
||||
protected static Context getContext() {
|
||||
protected static final Context getContext() {
|
||||
// Return task context first
|
||||
String taskContext = TaskManager.getContext();
|
||||
User user = User.fromJson(taskContext);
|
||||
|
|
@ -1810,10 +1695,10 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return new Context(user);
|
||||
}
|
||||
|
||||
return CONTEXTS.get();
|
||||
return contexts.get();
|
||||
}
|
||||
|
||||
protected static String getContextString() {
|
||||
protected static final String getContextString() {
|
||||
Context context = getContext();
|
||||
if (context == null) {
|
||||
return null;
|
||||
|
|
@ -1821,7 +1706,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
return context.user().toJson();
|
||||
}
|
||||
|
||||
protected static void logUser(User user, String path) {
|
||||
protected static final void logUser(User user, String path) {
|
||||
LOG.info("User '{}' login from client [{}] with path '{}'",
|
||||
user.username(), user.client(), path);
|
||||
}
|
||||
|
|
@ -1872,7 +1757,7 @@ public final class HugeGraphAuthProxy implements HugeGraph {
|
|||
public ContextThreadPoolExecutor(int corePoolSize, int maxPoolSize,
|
||||
ThreadFactory threadFactory) {
|
||||
super(corePoolSize, maxPoolSize, 0L, TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<>(), threadFactory);
|
||||
new LinkedBlockingQueue<Runnable>(), threadFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,36 +17,37 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.io.Console;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.config.CoreOptions;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.masterelection.RoleElectionOptions;
|
||||
import org.apache.hugegraph.rpc.RpcClientProviderWithAuth;
|
||||
import org.apache.hugegraph.util.ConfigUtil;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.StringEncoding;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticationException;
|
||||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.rpc.RpcClientProviderWithAuth;
|
||||
import com.baidu.hugegraph.util.ConfigUtil;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.StringEncoding;
|
||||
|
||||
public class StandardAuthenticator implements HugeAuthenticator {
|
||||
|
||||
private static final String INITING_STORE = "initing_store";
|
||||
|
||||
private HugeGraph graph = null;
|
||||
|
||||
private HugeGraph graph() {
|
||||
E.checkState(this.graph != null, "Must setup Authenticator first");
|
||||
return this.graph;
|
||||
}
|
||||
|
||||
private void initAdminUser() throws Exception {
|
||||
if (this.requireInitAdminUser()) {
|
||||
this.initAdminUser(this.inputPassword());
|
||||
|
|
@ -52,15 +55,9 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
this.graph.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HugeGraph graph() {
|
||||
E.checkState(this.graph != null, "Must setup Authenticator first");
|
||||
return this.graph;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAdminUser(String password) {
|
||||
// Not allowed to call by non-main thread
|
||||
// Not allowed to call by non main thread
|
||||
String caller = Thread.currentThread().getName();
|
||||
E.checkState("main".equals(caller), "Invalid caller '%s'", caller);
|
||||
|
||||
|
|
@ -85,24 +82,20 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
String notEmptyPrompt = "The admin password can't be empty";
|
||||
Console console = System.console();
|
||||
while (true) {
|
||||
String password;
|
||||
String password = "";
|
||||
if (console != null) {
|
||||
char[] chars = console.readPassword(inputPrompt);
|
||||
password = new String(chars);
|
||||
} else {
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(inputPrompt);
|
||||
// CHECKSTYLE:ON
|
||||
// just wrapper of System.in
|
||||
System.out.print(inputPrompt);
|
||||
@SuppressWarnings("resource") // just wrapper of System.in
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
password = scanner.nextLine();
|
||||
}
|
||||
if (!password.isEmpty()) {
|
||||
return password;
|
||||
}
|
||||
// CHECKSTYLE:OFF
|
||||
System.out.println(notEmptyPrompt);
|
||||
// CHECKSTYLE:ON
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,13 +118,6 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
// Forced set RAFT_MODE to false when initializing backend
|
||||
graphConfig.setProperty(CoreOptions.RAFT_MODE.name(), "false");
|
||||
}
|
||||
|
||||
// Transfer `raft.group_peers` from server config to graph config
|
||||
String raftGroupPeers = config.get(ServerOptions.RAFT_GROUP_PEERS);
|
||||
graphConfig.addProperty(ServerOptions.RAFT_GROUP_PEERS.name(),
|
||||
raftGroupPeers);
|
||||
this.transferRoleWorkerConfig(graphConfig, config);
|
||||
|
||||
this.graph = (HugeGraph) GraphFactory.open(graphConfig);
|
||||
|
||||
String remoteUrl = config.get(ServerOptions.AUTH_REMOTE_URL);
|
||||
|
|
@ -142,21 +128,6 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
}
|
||||
}
|
||||
|
||||
private void transferRoleWorkerConfig(HugeConfig graphConfig, HugeConfig config) {
|
||||
graphConfig.addProperty(RoleElectionOptions.NODE_EXTERNAL_URL.name(),
|
||||
config.get(ServerOptions.REST_SERVER_URL));
|
||||
graphConfig.addProperty(RoleElectionOptions.BASE_TIMEOUT_MILLISECOND.name(),
|
||||
config.get(RoleElectionOptions.BASE_TIMEOUT_MILLISECOND));
|
||||
graphConfig.addProperty(RoleElectionOptions.EXCEEDS_FAIL_COUNT.name(),
|
||||
config.get(RoleElectionOptions.EXCEEDS_FAIL_COUNT));
|
||||
graphConfig.addProperty(RoleElectionOptions.RANDOM_TIMEOUT_MILLISECOND.name(),
|
||||
config.get(RoleElectionOptions.RANDOM_TIMEOUT_MILLISECOND));
|
||||
graphConfig.addProperty(RoleElectionOptions.HEARTBEAT_INTERVAL_SECOND.name(),
|
||||
config.get(RoleElectionOptions.HEARTBEAT_INTERVAL_SECOND));
|
||||
graphConfig.addProperty(RoleElectionOptions.MASTER_DEAD_TIMES.name(),
|
||||
config.get(RoleElectionOptions.MASTER_DEAD_TIMES));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a user is legal
|
||||
* @param username the username for authentication
|
||||
|
|
@ -198,7 +169,7 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
|
||||
@Override
|
||||
public SaslNegotiator newSaslNegotiator(InetAddress remoteAddress) {
|
||||
return new TokenSaslAuthenticator();
|
||||
throw new NotImplementedException("SaslNegotiator is unsupported");
|
||||
}
|
||||
|
||||
public static void initAdminUserIfNeeded(String confFile) throws Exception {
|
||||
|
|
@ -214,78 +185,4 @@ public class StandardAuthenticator implements HugeAuthenticator {
|
|||
auth.initAdminUser();
|
||||
}
|
||||
}
|
||||
|
||||
private class TokenSaslAuthenticator implements SaslNegotiator {
|
||||
|
||||
private static final byte NUL = 0;
|
||||
private String username;
|
||||
private String password;
|
||||
private String token;
|
||||
|
||||
@Override
|
||||
public byte[] evaluateResponse(final byte[] clientResponse) throws AuthenticationException {
|
||||
decode(clientResponse);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return this.username != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticatedUser getAuthenticatedUser() throws AuthenticationException {
|
||||
if (!this.isComplete()) {
|
||||
throw new AuthenticationException(
|
||||
"The SASL negotiation has not yet been completed.");
|
||||
}
|
||||
|
||||
final Map<String, String> credentials = new HashMap<>(6, 1);
|
||||
credentials.put(KEY_USERNAME, username);
|
||||
credentials.put(KEY_PASSWORD, password);
|
||||
credentials.put(KEY_TOKEN, token);
|
||||
|
||||
return authenticate(credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* SASL PLAIN mechanism specifies that credentials are encoded in a
|
||||
* sequence of UTF-8 bytes, delimited by 0 (US-ASCII NUL).
|
||||
* The form is : {code}authzId<NUL>authnId<NUL>password<NUL>{code}.
|
||||
*
|
||||
* @param bytes encoded credentials string sent by the client
|
||||
*/
|
||||
private void decode(byte[] bytes) throws AuthenticationException {
|
||||
this.username = null;
|
||||
this.password = null;
|
||||
|
||||
int end = bytes.length;
|
||||
|
||||
for (int i = bytes.length - 1; i >= 0; i--) {
|
||||
if (bytes[i] != NUL) {
|
||||
continue;
|
||||
}
|
||||
if (this.password == null) {
|
||||
password = new String(Arrays.copyOfRange(bytes, i + 1, end),
|
||||
StandardCharsets.UTF_8);
|
||||
} else if (this.username == null) {
|
||||
username = new String(Arrays.copyOfRange(bytes, i + 1, end),
|
||||
StandardCharsets.UTF_8);
|
||||
}
|
||||
end = i;
|
||||
}
|
||||
|
||||
if (this.username == null) {
|
||||
throw new AuthenticationException("SASL authentication ID must not be null.");
|
||||
}
|
||||
if (this.password == null) {
|
||||
throw new AuthenticationException("SASL password must not be null.");
|
||||
}
|
||||
|
||||
/* The trick is here. >_*/
|
||||
if (password.isEmpty()) {
|
||||
token = username;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,23 @@
|
|||
/*
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* 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.auth;
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.CONNECTION;
|
||||
import static io.netty.handler.codec.http.HttpHeaderNames.UPGRADE;
|
||||
|
|
@ -55,7 +57,7 @@ public class WsAndHttpBasicAuthHandler extends SaslAuthenticationHandler {
|
|||
private static final String HTTP_AUTH = "http-authentication";
|
||||
|
||||
public WsAndHttpBasicAuthHandler(Authenticator authenticator,
|
||||
Settings settings) {
|
||||
Settings.AuthenticationSettings settings) {
|
||||
super(authenticator, settings);
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +70,8 @@ public class WsAndHttpBasicAuthHandler extends SaslAuthenticationHandler {
|
|||
if (authHandler != null) {
|
||||
authHandler = pipeline.remove(HTTP_AUTH);
|
||||
} else {
|
||||
authHandler = new HttpBasicAuthHandler(this.authenticator);
|
||||
authHandler = new HttpBasicAuthHandler(
|
||||
this.authenticator, this.authenticationSettings);
|
||||
}
|
||||
pipeline.addAfter(AUTHENTICATOR, HTTP_AUTH, authHandler);
|
||||
ctx.fireChannelRead(obj);
|
||||
|
|
@ -90,7 +93,8 @@ public class WsAndHttpBasicAuthHandler extends SaslAuthenticationHandler {
|
|||
|
||||
private final Base64.Decoder decoder = Base64.getUrlDecoder();
|
||||
|
||||
public HttpBasicAuthHandler(Authenticator authenticator) {
|
||||
public HttpBasicAuthHandler(Authenticator authenticator,
|
||||
Settings.AuthenticationSettings settings) {
|
||||
super(authenticator);
|
||||
}
|
||||
|
||||
|
|
@ -148,10 +152,10 @@ public class WsAndHttpBasicAuthHandler extends SaslAuthenticationHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void sendError(ChannelHandlerContext context, Object msg) {
|
||||
private void sendError(ChannelHandlerContext ctx, Object msg) {
|
||||
// Close the connection as soon as the error message is sent.
|
||||
context.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED))
|
||||
.addListener(ChannelFutureListener.CLOSE);
|
||||
ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED))
|
||||
.addListener(ChannelFutureListener.CLOSE);
|
||||
ReferenceCountUtil.release(msg);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,13 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.config;
|
||||
package com.baidu.hugegraph.config;
|
||||
|
||||
import static org.apache.hugegraph.config.OptionChecker.allowValues;
|
||||
import static org.apache.hugegraph.config.OptionChecker.disallowEmpty;
|
||||
import static org.apache.hugegraph.config.OptionChecker.nonNegativeInt;
|
||||
import static org.apache.hugegraph.config.OptionChecker.positiveInt;
|
||||
import static org.apache.hugegraph.config.OptionChecker.rangeInt;
|
||||
import static com.baidu.hugegraph.config.OptionChecker.allowValues;
|
||||
import static com.baidu.hugegraph.config.OptionChecker.disallowEmpty;
|
||||
import static com.baidu.hugegraph.config.OptionChecker.nonNegativeInt;
|
||||
import static com.baidu.hugegraph.config.OptionChecker.positiveInt;
|
||||
import static com.baidu.hugegraph.config.OptionChecker.rangeInt;
|
||||
|
||||
public class ServerOptions extends OptionHolder {
|
||||
|
||||
|
|
@ -175,14 +177,6 @@ public class ServerOptions extends OptionHolder {
|
|||
nonNegativeInt(),
|
||||
0);
|
||||
|
||||
public static final ConfigOption<String> RAFT_GROUP_PEERS =
|
||||
new ConfigOption<>(
|
||||
"raft.group_peers",
|
||||
"The rpc address of raft group initial peers.",
|
||||
disallowEmpty(),
|
||||
"127.0.0.1:8090"
|
||||
);
|
||||
|
||||
public static final ConfigOption<Boolean> ALLOW_TRACE =
|
||||
new ConfigOption<>(
|
||||
"exception.allow_trace",
|
||||
|
|
@ -195,8 +189,8 @@ public class ServerOptions extends OptionHolder {
|
|||
new ConfigOption<>(
|
||||
"auth.authenticator",
|
||||
"The class path of authenticator implementation. " +
|
||||
"e.g., org.apache.hugegraph.auth.StandardAuthenticator, " +
|
||||
"or org.apache.hugegraph.auth.ConfigAuthenticator.",
|
||||
"e.g., com.baidu.hugegraph.auth.StandardAuthenticator, " +
|
||||
"or com.baidu.hugegraph.auth.ConfigAuthenticator.",
|
||||
null,
|
||||
""
|
||||
);
|
||||
|
|
@ -205,7 +199,7 @@ public class ServerOptions extends OptionHolder {
|
|||
new ConfigOption<>(
|
||||
"auth.graph_store",
|
||||
"The name of graph used to store authentication information, " +
|
||||
"like users, only for org.apache.hugegraph.auth.StandardAuthenticator.",
|
||||
"like users, only for com.baidu.hugegraph.auth.StandardAuthenticator.",
|
||||
disallowEmpty(),
|
||||
"hugegraph"
|
||||
);
|
||||
|
|
@ -214,7 +208,7 @@ public class ServerOptions extends OptionHolder {
|
|||
new ConfigOption<>(
|
||||
"auth.admin_token",
|
||||
"Token for administrator operations, " +
|
||||
"only for org.apache.hugegraph.auth.ConfigAuthenticator.",
|
||||
"only for com.baidu.hugegraph.auth.ConfigAuthenticator.",
|
||||
disallowEmpty(),
|
||||
"162f7848-0b6d-4faf-b557-3a0797869c55"
|
||||
);
|
||||
|
|
@ -223,7 +217,7 @@ public class ServerOptions extends OptionHolder {
|
|||
new ConfigListOption<>(
|
||||
"auth.user_tokens",
|
||||
"The map of user tokens with name and password, " +
|
||||
"only for org.apache.hugegraph.auth.ConfigAuthenticator.",
|
||||
"only for com.baidu.hugegraph.auth.ConfigAuthenticator.",
|
||||
disallowEmpty(),
|
||||
"hugegraph:9fd95c9c-711b-415b-b85f-d4df46ba5c31"
|
||||
);
|
||||
|
|
@ -256,12 +250,4 @@ public class ServerOptions extends OptionHolder {
|
|||
null,
|
||||
"hugegraph"
|
||||
);
|
||||
|
||||
public static final ConfigOption<Boolean> ENABLE_DYNAMIC_CREATE_DROP =
|
||||
new ConfigOption<>(
|
||||
"graphs.enable_dynamic_create_drop",
|
||||
"Whether to enable create or drop graph dynamically.",
|
||||
disallowEmpty(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,61 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.core;
|
||||
package com.baidu.hugegraph.core;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.hugegraph.HugeFactory;
|
||||
import org.apache.hugegraph.HugeGraph;
|
||||
import org.apache.hugegraph.auth.AuthManager;
|
||||
import org.apache.hugegraph.auth.HugeAuthenticator;
|
||||
import org.apache.hugegraph.auth.HugeFactoryAuthProxy;
|
||||
import org.apache.hugegraph.auth.HugeGraphAuthProxy;
|
||||
import org.apache.hugegraph.auth.StandardAuthenticator;
|
||||
import org.apache.hugegraph.backend.BackendException;
|
||||
import org.apache.hugegraph.backend.cache.Cache;
|
||||
import org.apache.hugegraph.backend.cache.CacheManager;
|
||||
import org.apache.hugegraph.backend.id.Id;
|
||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
||||
import org.apache.hugegraph.backend.store.BackendStoreInfo;
|
||||
import org.apache.hugegraph.config.CoreOptions;
|
||||
import org.apache.hugegraph.config.HugeConfig;
|
||||
import org.apache.hugegraph.config.ServerOptions;
|
||||
import org.apache.hugegraph.config.TypedOption;
|
||||
import org.apache.hugegraph.event.EventHub;
|
||||
import org.apache.hugegraph.exception.NotSupportException;
|
||||
import org.apache.hugegraph.masterelection.GlobalMasterInfo;
|
||||
import org.apache.hugegraph.masterelection.RoleElectionOptions;
|
||||
import org.apache.hugegraph.masterelection.RoleElectionStateMachine;
|
||||
import org.apache.hugegraph.masterelection.StandardStateMachineCallback;
|
||||
import org.apache.hugegraph.metrics.MetricsUtil;
|
||||
import org.apache.hugegraph.metrics.ServerReporter;
|
||||
import org.apache.hugegraph.rpc.RpcClientProvider;
|
||||
import org.apache.hugegraph.rpc.RpcConsumerConfig;
|
||||
import org.apache.hugegraph.rpc.RpcProviderConfig;
|
||||
import org.apache.hugegraph.rpc.RpcServer;
|
||||
import org.apache.hugegraph.serializer.JsonSerializer;
|
||||
import org.apache.hugegraph.serializer.Serializer;
|
||||
import org.apache.hugegraph.server.RestServer;
|
||||
import org.apache.hugegraph.task.TaskManager;
|
||||
import org.apache.hugegraph.testutil.Whitebox;
|
||||
import org.apache.hugegraph.type.define.NodeRole;
|
||||
import org.apache.hugegraph.util.ConfigUtil;
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.Events;
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticationException;
|
||||
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
|
||||
import org.apache.tinkerpop.gremlin.structure.Graph;
|
||||
|
|
@ -77,21 +37,50 @@ import org.apache.tinkerpop.gremlin.structure.Transaction;
|
|||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.alipay.sofa.rpc.config.ServerConfig;
|
||||
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.backend.BackendException;
|
||||
import com.baidu.hugegraph.backend.cache.Cache;
|
||||
import com.baidu.hugegraph.backend.cache.CacheManager;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.backend.store.BackendStoreSystemInfo;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.config.TypedOption;
|
||||
import com.baidu.hugegraph.event.EventHub;
|
||||
import com.baidu.hugegraph.exception.NotSupportException;
|
||||
import com.baidu.hugegraph.license.LicenseVerifier;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.rpc.RpcClientProvider;
|
||||
import com.baidu.hugegraph.rpc.RpcConsumerConfig;
|
||||
import com.baidu.hugegraph.rpc.RpcProviderConfig;
|
||||
import com.baidu.hugegraph.rpc.RpcServer;
|
||||
import com.baidu.hugegraph.serializer.JsonSerializer;
|
||||
import com.baidu.hugegraph.serializer.Serializer;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.task.TaskManager;
|
||||
import com.baidu.hugegraph.type.define.NodeRole;
|
||||
import com.baidu.hugegraph.util.ConfigUtil;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Events;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
|
||||
public final class GraphManager {
|
||||
|
||||
private static final Logger LOG = Log.logger(GraphManager.class);
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
private final String graphsDir;
|
||||
private final Map<String, Graph> graphs;
|
||||
private final HugeAuthenticator authenticator;
|
||||
private final RpcServer rpcServer;
|
||||
private final RpcClientProvider rpcClient;
|
||||
private final HugeConfig conf;
|
||||
|
||||
private RoleElectionStateMachine roleStateWorker;
|
||||
private GlobalMasterInfo globalMasterInfo;
|
||||
|
||||
private Id server;
|
||||
private NodeRole role;
|
||||
|
|
@ -105,42 +94,37 @@ public final class GraphManager {
|
|||
this.rpcServer = new RpcServer(conf);
|
||||
this.rpcClient = new RpcClientProvider(conf);
|
||||
this.eventHub = hub;
|
||||
this.conf = conf;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
E.checkArgument(this.graphs.isEmpty(),
|
||||
"GraphManager has been initialized before");
|
||||
this.listenChanges();
|
||||
|
||||
this.loadGraphs(ConfigUtil.scanGraphsDir(this.graphsDir));
|
||||
|
||||
// Start RPC-Server for raft-rpc/auth-rpc/cache-notify-rpc...
|
||||
this.startRpcServer();
|
||||
|
||||
// this.installLicense(conf, "");
|
||||
// Raft will load snapshot firstly then launch election and replay log
|
||||
this.waitGraphsReady();
|
||||
|
||||
this.checkBackendVersionOrExit(this.conf);
|
||||
this.serverStarted(this.conf);
|
||||
|
||||
this.addMetrics(this.conf);
|
||||
this.waitGraphsStarted();
|
||||
this.checkBackendVersionOrExit(conf);
|
||||
this.startRpcServer();
|
||||
this.serverStarted(conf);
|
||||
this.addMetrics(conf);
|
||||
}
|
||||
|
||||
public void loadGraphs(Map<String, String> graphConfs) {
|
||||
public void loadGraphs(final Map<String, String> graphConfs) {
|
||||
for (Map.Entry<String, String> conf : graphConfs.entrySet()) {
|
||||
String name = conf.getKey();
|
||||
String graphConfPath = conf.getValue();
|
||||
String path = conf.getValue();
|
||||
HugeFactory.checkGraphName(name, "rest-server.properties");
|
||||
try {
|
||||
this.loadGraph(name, graphConfPath);
|
||||
} catch (Throwable e) {
|
||||
LOG.error("Graph '{}' can't be loaded: '{}'",
|
||||
name, graphConfPath, e);
|
||||
this.loadGraph(name, path);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("Graph '{}' can't be loaded: '{}'", name, path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void waitGraphsStarted() {
|
||||
this.graphs.keySet().forEach(name -> {
|
||||
HugeGraph graph = this.graph(name);
|
||||
graph.waitStarted();
|
||||
});
|
||||
}
|
||||
|
||||
public HugeGraph cloneGraph(String name, String newName,
|
||||
String configText) {
|
||||
/*
|
||||
|
|
@ -173,10 +157,6 @@ public final class GraphManager {
|
|||
}
|
||||
|
||||
public HugeGraph createGraph(String name, String configText) {
|
||||
E.checkArgument(this.conf.get(ServerOptions.ENABLE_DYNAMIC_CREATE_DROP),
|
||||
"Not allowed to create graph '%s' dynamically, " +
|
||||
"please set `enable_dynamic_create_drop` to true.",
|
||||
name);
|
||||
E.checkArgument(StringUtils.isNotEmpty(name),
|
||||
"The graph name can't be null or empty");
|
||||
E.checkArgument(!this.graphs().contains(name),
|
||||
|
|
@ -191,10 +171,6 @@ public final class GraphManager {
|
|||
|
||||
public void dropGraph(String name) {
|
||||
HugeGraph graph = this.graph(name);
|
||||
E.checkArgument(this.conf.get(ServerOptions.ENABLE_DYNAMIC_CREATE_DROP),
|
||||
"Not allowed to drop graph '%s' dynamically, " +
|
||||
"please set `enable_dynamic_create_drop` to true.",
|
||||
name);
|
||||
E.checkArgumentNotNull(graph, "The graph '%s' doesn't exist", name);
|
||||
E.checkArgument(this.graphs.size() > 1,
|
||||
"The graph '%s' is the only one, not allowed to delete",
|
||||
|
|
@ -225,12 +201,12 @@ public final class GraphManager {
|
|||
}
|
||||
|
||||
public void rollbackAll() {
|
||||
for (Graph graph : this.graphs.values()) {
|
||||
this.graphs.values().forEach(graph -> {
|
||||
if (graph.features().graph().supportsTransactions() &&
|
||||
graph.tx().isOpen()) {
|
||||
graph.tx().rollback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void rollback(final Set<String> graphSourceNamesToCloseTxOn) {
|
||||
|
|
@ -238,12 +214,12 @@ public final class GraphManager {
|
|||
}
|
||||
|
||||
public void commitAll() {
|
||||
for (Graph graph : this.graphs.values()) {
|
||||
this.graphs.values().forEach(graph -> {
|
||||
if (graph.features().graph().supportsTransactions() &&
|
||||
graph.tx().isOpen()) {
|
||||
graph.tx().commit();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void commit(final Set<String> graphSourceNamesToCloseTxOn) {
|
||||
|
|
@ -267,18 +243,8 @@ public final class GraphManager {
|
|||
}
|
||||
|
||||
public void close() {
|
||||
for (Graph graph : this.graphs.values()) {
|
||||
try {
|
||||
graph.close();
|
||||
} catch (Throwable e) {
|
||||
LOG.warn("Failed to close graph '{}'", graph, e);
|
||||
}
|
||||
}
|
||||
this.destroyRpcServer();
|
||||
this.unlistenChanges();
|
||||
if (this.roleStateWorker != null) {
|
||||
this.roleStateWorker.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
private void startRpcServer() {
|
||||
|
|
@ -313,20 +279,6 @@ public final class GraphManager {
|
|||
}
|
||||
}
|
||||
|
||||
private com.alipay.remoting.rpc.RpcServer remotingRpcServer() {
|
||||
ServerConfig serverConfig = Whitebox.getInternalState(this.rpcServer,
|
||||
"serverConfig");
|
||||
serverConfig.buildIfAbsent();
|
||||
|
||||
// Start remote rpc server if none rpc services registered
|
||||
// Note it goes here only when raft mode enabled
|
||||
if (!serverConfig.getServer().isStarted()) {
|
||||
serverConfig.getServer().start();
|
||||
}
|
||||
return Whitebox.getInternalState(serverConfig.getServer(),
|
||||
"remotingServer");
|
||||
}
|
||||
|
||||
private void destroyRpcServer() {
|
||||
try {
|
||||
this.rpcClient.destroy();
|
||||
|
|
@ -342,6 +294,10 @@ public final class GraphManager {
|
|||
return this.authenticator;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void installLicense(HugeConfig config, String md5) {
|
||||
LicenseVerifier.instance().install(config, this, md5);
|
||||
}
|
||||
|
||||
private void closeTx(final Set<String> graphSourceNamesToCloseTxOn,
|
||||
final Transaction.Status tx) {
|
||||
|
|
@ -365,65 +321,22 @@ public final class GraphManager {
|
|||
});
|
||||
}
|
||||
|
||||
private void loadGraph(String name, String graphConfPath) {
|
||||
HugeConfig config = new HugeConfig(graphConfPath);
|
||||
|
||||
// Transfer `raft.group_peers` from server config to graph config
|
||||
String raftGroupPeers = this.conf.get(ServerOptions.RAFT_GROUP_PEERS);
|
||||
config.addProperty(ServerOptions.RAFT_GROUP_PEERS.name(),
|
||||
raftGroupPeers);
|
||||
this.transferRoleWorkerConfig(config);
|
||||
|
||||
Graph graph = GraphFactory.open(config);
|
||||
private void loadGraph(String name, String path) {
|
||||
final Graph graph = GraphFactory.open(path);
|
||||
this.graphs.put(name, graph);
|
||||
|
||||
HugeConfig graphConfig = (HugeConfig) graph.configuration();
|
||||
assert graphConfPath.equals(Objects.requireNonNull(graphConfig.file()).getPath());
|
||||
|
||||
LOG.info("Graph '{}' was successfully configured via '{}'",
|
||||
name, graphConfPath);
|
||||
LOG.info("Graph '{}' was successfully configured via '{}'", name, path);
|
||||
|
||||
if (this.requireAuthentication() &&
|
||||
!(graph instanceof HugeGraphAuthProxy)) {
|
||||
LOG.warn("You may need to support access control for '{}' with {}",
|
||||
graphConfPath, HugeFactoryAuthProxy.GRAPH_FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
private void transferRoleWorkerConfig(HugeConfig config) {
|
||||
config.addProperty(RoleElectionOptions.NODE_EXTERNAL_URL.name(),
|
||||
this.conf.get(ServerOptions.REST_SERVER_URL));
|
||||
config.addProperty(RoleElectionOptions.BASE_TIMEOUT_MILLISECOND.name(),
|
||||
this.conf.get(RoleElectionOptions.BASE_TIMEOUT_MILLISECOND));
|
||||
config.addProperty(RoleElectionOptions.EXCEEDS_FAIL_COUNT.name(),
|
||||
this.conf.get(RoleElectionOptions.EXCEEDS_FAIL_COUNT));
|
||||
config.addProperty(RoleElectionOptions.RANDOM_TIMEOUT_MILLISECOND.name(),
|
||||
this.conf.get(RoleElectionOptions.RANDOM_TIMEOUT_MILLISECOND));
|
||||
config.addProperty(RoleElectionOptions.HEARTBEAT_INTERVAL_SECOND.name(),
|
||||
this.conf.get(RoleElectionOptions.HEARTBEAT_INTERVAL_SECOND));
|
||||
config.addProperty(RoleElectionOptions.MASTER_DEAD_TIMES.name(),
|
||||
this.conf.get(RoleElectionOptions.MASTER_DEAD_TIMES));
|
||||
}
|
||||
|
||||
private void waitGraphsReady() {
|
||||
if (!this.rpcServer.enabled()) {
|
||||
LOG.info("RpcServer is not enabled, skip wait graphs ready");
|
||||
return;
|
||||
}
|
||||
com.alipay.remoting.rpc.RpcServer remotingRpcServer =
|
||||
this.remotingRpcServer();
|
||||
for (String graphName : this.graphs.keySet()) {
|
||||
HugeGraph graph = this.graph(graphName);
|
||||
graph.waitReady(remotingRpcServer);
|
||||
path, HugeFactoryAuthProxy.GRAPH_FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBackendVersionOrExit(HugeConfig config) {
|
||||
LOG.info("Check backend version");
|
||||
for (String graph : this.graphs()) {
|
||||
// TODO: close tx from main thread
|
||||
HugeGraph hugegraph = this.graph(graph);
|
||||
assert hugegraph != null;
|
||||
if (!hugegraph.backendStoreFeatures().supportsPersistence()) {
|
||||
hugegraph.initBackend();
|
||||
if (this.requireAuthentication()) {
|
||||
|
|
@ -437,7 +350,7 @@ public final class GraphManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
BackendStoreInfo info = hugegraph.backendStoreInfo();
|
||||
BackendStoreSystemInfo info = hugegraph.backendStoreSystemInfo();
|
||||
if (!info.exists()) {
|
||||
throw new BackendException(
|
||||
"The backend store of '%s' has not been initialized",
|
||||
|
|
@ -459,57 +372,11 @@ public final class GraphManager {
|
|||
"The server role can't be null or empty");
|
||||
this.server = IdGenerator.of(server);
|
||||
this.role = NodeRole.valueOf(role.toUpperCase());
|
||||
|
||||
boolean supportRoleStateWorker = this.supportRoleStateWorker();
|
||||
if (supportRoleStateWorker) {
|
||||
this.role = NodeRole.WORKER;
|
||||
}
|
||||
|
||||
for (String graph : this.graphs()) {
|
||||
HugeGraph hugegraph = this.graph(graph);
|
||||
assert hugegraph != null;
|
||||
hugegraph.serverStarted(this.server, this.role);
|
||||
}
|
||||
|
||||
if (supportRoleStateWorker) {
|
||||
this.initRoleStateWorker();
|
||||
}
|
||||
}
|
||||
|
||||
private void initRoleStateWorker() {
|
||||
E.checkArgument(this.roleStateWorker == null, "Repetition init");
|
||||
Executor applyThread = Executors.newSingleThreadExecutor();
|
||||
this.roleStateWorker = this.authenticator().graph().roleElectionStateMachine();
|
||||
this.globalMasterInfo = new GlobalMasterInfo();
|
||||
StandardStateMachineCallback stateMachineCallback = new StandardStateMachineCallback(
|
||||
TaskManager.instance(),
|
||||
this.globalMasterInfo);
|
||||
applyThread.execute(() -> {
|
||||
this.roleStateWorker.apply(stateMachineCallback);
|
||||
});
|
||||
}
|
||||
|
||||
public GlobalMasterInfo globalMasterInfo() {
|
||||
return this.globalMasterInfo;
|
||||
}
|
||||
|
||||
private boolean supportRoleStateWorker() {
|
||||
if (this.role.computer()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!(this.authenticator() instanceof StandardAuthenticator)) {
|
||||
LOG.info("{} authenticator does not support role election currently",
|
||||
this.authenticator().getClass().getSimpleName());
|
||||
return false;
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
LOG.info("Unconfigured StandardAuthenticator, not support role election currently");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addMetrics(HugeConfig config) {
|
||||
|
|
@ -628,7 +495,6 @@ public final class GraphManager {
|
|||
Object incomingValue = config.get(option);
|
||||
for (String graphName : this.graphs.keySet()) {
|
||||
HugeGraph graph = this.graph(graphName);
|
||||
assert graph != null;
|
||||
Object existedValue = graph.option(option);
|
||||
E.checkArgument(!incomingValue.equals(existedValue),
|
||||
"The value '%s' of option '%s' conflicts with " +
|
||||
|
|
@ -653,11 +519,11 @@ public final class GraphManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
MetricsUtil.registerGauge(Cache.class, hits, cache::hits);
|
||||
MetricsUtil.registerGauge(Cache.class, miss, cache::miss);
|
||||
MetricsUtil.registerGauge(Cache.class, exp, cache::expire);
|
||||
MetricsUtil.registerGauge(Cache.class, size, cache::size);
|
||||
MetricsUtil.registerGauge(Cache.class, cap, cache::capacity);
|
||||
MetricsUtil.registerGauge(Cache.class, hits, () -> cache.hits());
|
||||
MetricsUtil.registerGauge(Cache.class, miss, () -> cache.miss());
|
||||
MetricsUtil.registerGauge(Cache.class, exp, () -> cache.expire());
|
||||
MetricsUtil.registerGauge(Cache.class, size, () -> cache.size());
|
||||
MetricsUtil.registerGauge(Cache.class, cap, () -> cache.capacity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.baidu.hugegraph.define;
|
||||
|
||||
public interface Checkable {
|
||||
|
||||
public void checkCreate(boolean isBatch);
|
||||
|
||||
public default void checkUpdate() {
|
||||
this.checkCreate(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.define;
|
||||
package com.baidu.hugegraph.define;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
|
@ -24,8 +26,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
import org.apache.hugegraph.util.NumericUtil;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.NumericUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public enum UpdateStrategy {
|
||||
|
|
@ -34,7 +36,7 @@ public enum UpdateStrategy {
|
|||
SUM {
|
||||
@Override
|
||||
Object updatePropertyValue(Object oldProperty, Object newProperty) {
|
||||
// TODO: Improve performance? (like write a method in common module)
|
||||
// TODO: Improve preformance? (like write a method in common module)
|
||||
BigDecimal oldNumber = new BigDecimal(oldProperty.toString());
|
||||
BigDecimal newNumber = new BigDecimal(newProperty.toString());
|
||||
return oldNumber.add(newNumber);
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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
|
||||
|
|
@ -15,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.define;
|
||||
package com.baidu.hugegraph.define;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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 com.baidu.hugegraph.license;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class LicenseVerifier {
|
||||
|
||||
private static final Logger LOG = Log.logger(HugeGraph.class);
|
||||
|
||||
private static final String LICENSE_PARAM_PATH = "/verify-license.json";
|
||||
|
||||
private static volatile LicenseVerifier INSTANCE = null;
|
||||
|
||||
private static final Duration CHECK_INTERVAL = Duration.ofMinutes(10);
|
||||
private volatile Instant lastCheckTime = Instant.now();
|
||||
|
||||
private final LicenseInstallParam installParam;
|
||||
private final LicenseVerifyManager manager;
|
||||
|
||||
private LicenseVerifier() {
|
||||
this.installParam = buildInstallParam(LICENSE_PARAM_PATH);
|
||||
this.manager = new LicenseVerifyManager(this.installParam);
|
||||
}
|
||||
|
||||
public static LicenseVerifier instance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized(LicenseVerifier.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new LicenseVerifier();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public synchronized void install(HugeConfig config,
|
||||
GraphManager graphManager,
|
||||
String md5) {
|
||||
this.manager.config(config);
|
||||
this.manager.graphManager(graphManager);
|
||||
LicenseManager licenseManager = this.manager.licenseManager();
|
||||
try {
|
||||
licenseManager.uninstallLicense();
|
||||
this.verifyPublicCert(md5);
|
||||
LicenseParams params = licenseManager.installLicense();
|
||||
LOG.info("The license '{}' is successfully installed for '{}', " +
|
||||
"the term of validity is from {} to {}",
|
||||
params.subject(), params.consumerType(),
|
||||
params.notBefore(), params.notAfter());
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to install license", e);
|
||||
throw new HugeException("Failed to install license", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void verifyIfNeeded() {
|
||||
Instant now = Instant.now();
|
||||
Duration interval = Duration.between(this.lastCheckTime, now);
|
||||
if (!interval.minus(CHECK_INTERVAL).isNegative()) {
|
||||
this.verify();
|
||||
this.lastCheckTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
try {
|
||||
LicenseParams params = this.manager.licenseManager()
|
||||
.verifyLicense();
|
||||
LOG.info("The license verification passed, " +
|
||||
"the term of validity is from {} to {}",
|
||||
params.notBefore(), params.notAfter());
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to verify license", e);
|
||||
throw new HugeException("Failed to verify license", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyPublicCert(String expectMD5) {
|
||||
String path = this.installParam.publicKeyPath();
|
||||
try (InputStream is = LicenseVerifier.class.getResourceAsStream(path)) {
|
||||
String actualMD5 = DigestUtils.md5Hex(is);
|
||||
if (!actualMD5.equals(expectMD5)) {
|
||||
throw new HugeException("Invalid public cert");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to read public cert", e);
|
||||
throw new HugeException("Failed to read public cert", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static LicenseInstallParam buildInstallParam(String path) {
|
||||
// NOTE: can't use JsonUtil due to it bind tinkerpop jackson
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try (InputStream stream =
|
||||
LicenseVerifier.class.getResourceAsStream(path)) {
|
||||
return mapper.readValue(stream, LicenseInstallParam.class);
|
||||
} catch (IOException e) {
|
||||
throw new HugeException("Failed to read json stream to %s",
|
||||
LicenseInstallParam.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* 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 com.baidu.hugegraph.license;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Bytes;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.util.VersionUtil;
|
||||
import com.baidu.hugegraph.version.CoreVersion;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
|
||||
public class LicenseVerifyManager {
|
||||
|
||||
private static final Logger LOG = Log.logger(LicenseVerifyManager.class);
|
||||
|
||||
private final LicenseManager licenseManager;
|
||||
private final MachineInfo machineInfo;
|
||||
|
||||
private HugeConfig config;
|
||||
private GraphManager graphManager;
|
||||
|
||||
public LicenseVerifyManager(LicenseInstallParam param) {
|
||||
this.licenseManager = LicenseManagerFactory.create(param,
|
||||
this::validate);
|
||||
this.machineInfo = new MachineInfo();
|
||||
}
|
||||
|
||||
public LicenseManager licenseManager() {
|
||||
return this.licenseManager;
|
||||
}
|
||||
|
||||
public void config(HugeConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public HugeConfig config() {
|
||||
E.checkState(this.config != null,
|
||||
"License verify manager has not been installed");
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public void graphManager(GraphManager graphManager) {
|
||||
this.graphManager = graphManager;
|
||||
}
|
||||
|
||||
public GraphManager graphManager() {
|
||||
E.checkState(this.graphManager != null,
|
||||
"License verify manager has not been installed");
|
||||
return this.graphManager;
|
||||
}
|
||||
|
||||
private synchronized void validate(LicenseParams params) {
|
||||
// Verify the customized license parameters.
|
||||
String serverId = this.getServerId();
|
||||
LOG.debug("Verify server id '{}'", serverId);
|
||||
LicenseExtraParam param = params.matchParam(serverId);
|
||||
if (param == null) {
|
||||
throw new HugeException("The current server id is not authorized");
|
||||
}
|
||||
|
||||
this.checkVersion(param);
|
||||
this.checkGraphs(param);
|
||||
this.checkIpAndMac(param);
|
||||
this.checkCpu(param);
|
||||
this.checkRam(param);
|
||||
this.checkThreads(param);
|
||||
this.checkMemory(param);
|
||||
}
|
||||
|
||||
private String getServerId() {
|
||||
return this.config().get(ServerOptions.SERVER_ID);
|
||||
}
|
||||
|
||||
private void checkVersion(LicenseExtraParam param) {
|
||||
String expectVersion = param.version();
|
||||
if (StringUtils.isEmpty(expectVersion)) {
|
||||
return;
|
||||
}
|
||||
VersionUtil.Version acutalVersion = CoreVersion.VERSION;
|
||||
if (acutalVersion.compareTo(VersionUtil.Version.of(expectVersion)) > 0) {
|
||||
throw newLicenseException(
|
||||
"The server's version '%s' exceeded the authorized '%s'",
|
||||
acutalVersion.get(), expectVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGraphs(LicenseExtraParam param) {
|
||||
int expectGraphs = param.graphs();
|
||||
if (expectGraphs == LicenseExtraParam.NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualGraphs = this.graphManager().graphs().size();
|
||||
if (actualGraphs > expectGraphs) {
|
||||
throw newLicenseException(
|
||||
"The server's graphs '%s' exceeded the authorized '%s'",
|
||||
actualGraphs, expectGraphs);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIpAndMac(LicenseExtraParam param) {
|
||||
String expectIp = param.ip();
|
||||
boolean matched = false;
|
||||
List<String> actualIps = this.machineInfo.getIpAddress();
|
||||
for (String actualIp : actualIps) {
|
||||
if (StringUtils.isEmpty(expectIp) ||
|
||||
actualIp.equalsIgnoreCase(expectIp)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
throw newLicenseException(
|
||||
"The server's ip '%s' doesn't match the authorized '%s'",
|
||||
actualIps, expectIp);
|
||||
}
|
||||
|
||||
String expectMac = param.mac();
|
||||
if (StringUtils.isEmpty(expectMac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The mac must be not empty here
|
||||
if (!StringUtils.isEmpty(expectIp)) {
|
||||
String actualMac;
|
||||
try {
|
||||
actualMac = this.machineInfo.getMacByInetAddress(
|
||||
InetAddress.getByName(expectIp));
|
||||
} catch (UnknownHostException e) {
|
||||
throw newLicenseException(
|
||||
"Failed to get mac address for ip '%s'", expectIp);
|
||||
}
|
||||
String expectFormatMac = expectMac.replaceAll(":", "-");
|
||||
String actualFormatMac = actualMac.replaceAll(":", "-");
|
||||
if (!actualFormatMac.equalsIgnoreCase(expectFormatMac)) {
|
||||
throw newLicenseException(
|
||||
"The server's mac '%s' doesn't match the authorized '%s'",
|
||||
actualMac, expectMac);
|
||||
}
|
||||
} else {
|
||||
String expectFormatMac = expectMac.replaceAll(":", "-");
|
||||
List<String> actualMacs = this.machineInfo.getMacAddress();
|
||||
matched = false;
|
||||
for (String actualMac : actualMacs) {
|
||||
String actualFormatMac = actualMac.replaceAll(":", "-");
|
||||
if (actualFormatMac.equalsIgnoreCase(expectFormatMac)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
throw newLicenseException(
|
||||
"The server's macs %s don't match the authorized '%s'",
|
||||
actualMacs, expectMac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCpu(LicenseExtraParam param) {
|
||||
int expectCpus = param.cpus();
|
||||
if (expectCpus == LicenseExtraParam.NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualCpus = CoreOptions.CPUS;
|
||||
if (actualCpus > expectCpus) {
|
||||
throw newLicenseException(
|
||||
"The server's cpus '%s' exceeded the limit '%s'",
|
||||
actualCpus, expectCpus);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRam(LicenseExtraParam param) {
|
||||
// Unit MB
|
||||
int expectRam = param.ram();
|
||||
if (expectRam == LicenseExtraParam.NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
OperatingSystemMXBean mxBean = (OperatingSystemMXBean) ManagementFactory
|
||||
.getOperatingSystemMXBean();
|
||||
long actualRam = mxBean.getTotalPhysicalMemorySize() / Bytes.MB;
|
||||
if (actualRam > expectRam) {
|
||||
throw newLicenseException(
|
||||
"The server's ram(MB) '%s' exceeded the limit(MB) '%s'",
|
||||
actualRam, expectRam);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkThreads(LicenseExtraParam param) {
|
||||
int expectThreads = param.threads();
|
||||
if (expectThreads == LicenseExtraParam.NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualThreads = this.config().get(ServerOptions.MAX_WORKER_THREADS);
|
||||
if (actualThreads > expectThreads) {
|
||||
throw newLicenseException(
|
||||
"The server's max threads '%s' exceeded limit '%s'",
|
||||
actualThreads, expectThreads);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMemory(LicenseExtraParam param) {
|
||||
// Unit MB
|
||||
int expectMemory = param.memory();
|
||||
if (expectMemory == LicenseExtraParam.NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* NOTE: this max memory will be slightly smaller than XMX,
|
||||
* because only one survivor will be used
|
||||
*/
|
||||
long actualMemory = Runtime.getRuntime().maxMemory() / Bytes.MB;
|
||||
if (actualMemory > expectMemory) {
|
||||
throw newLicenseException(
|
||||
"The server's max heap memory(MB) '%s' exceeded the " +
|
||||
"limit(MB) '%s'", actualMemory, expectMemory);
|
||||
}
|
||||
}
|
||||
|
||||
private HugeException newLicenseException(String message, Object... args) {
|
||||
return new HugeException(message, args);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue