forked from hugegraph/hugegraph-sync
Compare commits
140 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
e1bd70831a | |
|
|
4c6eda8409 | |
|
|
4ba5c9dedd | |
|
|
a534417dd9 | |
|
|
9affa6ecd2 | |
|
|
1d47fd38e2 | |
|
|
3ea3fa6623 | |
|
|
4d11dd5e05 | |
|
|
301e99b008 | |
|
|
7aedba253a | |
|
|
2843d4c78e | |
|
|
50ae4dee72 | |
|
|
08e0f6486a | |
|
|
dcc335fc3e | |
|
|
6d04e9b5cb | |
|
|
67aba571cc | |
|
|
f34b528885 | |
|
|
d56ad10105 | |
|
|
f4edfe3692 | |
|
|
bdb64767ca | |
|
|
c74ec03a27 | |
|
|
6565a22137 | |
|
|
a199534b89 | |
|
|
044fd091a6 | |
|
|
6db8b08f14 | |
|
|
198f7004ae | |
|
|
3b9507001e | |
|
|
74cf3109ec | |
|
|
02c9b4eac0 | |
|
|
9fc3788d9c | |
|
|
168cf69ac7 | |
|
|
b7f8b56730 | |
|
|
5551ec17f2 | |
|
|
960b7330fd | |
|
|
721111d11a | |
|
|
d61aaae44f | |
|
|
e4bd6446f0 | |
|
|
92f2ecb5e7 | |
|
|
7b14857828 | |
|
|
bc9c1e7ac9 | |
|
|
d4a20a120a | |
|
|
b06779aed6 | |
|
|
ec3779c709 | |
|
|
70150ad448 | |
|
|
46cb612eb5 | |
|
|
499f8e74b5 | |
|
|
12ff9154ab | |
|
|
94a79326ea | |
|
|
e11dc8e5f3 | |
|
|
dd44f701f5 | |
|
|
8b3624aa03 | |
|
|
896d943538 | |
|
|
73bf6607fd | |
|
|
ee0299e6d3 | |
|
|
785d387294 | |
|
|
e705740e1e | |
|
|
94edfcd720 | |
|
|
263bb2feb4 | |
|
|
87509b8a99 | |
|
|
785afe05ba | |
|
|
8115325d9a | |
|
|
5a064de05a | |
|
|
176637c47a | |
|
|
4bb48814bb | |
|
|
b116fc8a21 | |
|
|
10c570d368 | |
|
|
9c2d3ad6d3 | |
|
|
4ad54181b4 | |
|
|
51df7ec871 | |
|
|
1bac480710 | |
|
|
d5fa5c8e33 | |
|
|
07b7243efe | |
|
|
c7054e0704 | |
|
|
c13b4e2b3a | |
|
|
823b1902eb | |
|
|
fe7697e9a7 | |
|
|
f34743b5fb | |
|
|
b670c01002 | |
|
|
0903e900e4 | |
|
|
c70a2944b0 | |
|
|
d6a2548427 | |
|
|
b19aa30454 | |
|
|
dfd3c6700e | |
|
|
7e9b8afbc6 | |
|
|
4f34d01eb2 | |
|
|
eb76bc62a0 | |
|
|
c72bda6237 | |
|
|
a891780c36 | |
|
|
84273f2093 | |
|
|
497d62eefe | |
|
|
1234c110e7 | |
|
|
cbdd65a06f | |
|
|
e78eb82b6a | |
|
|
02c36d848e | |
|
|
51ca58746d | |
|
|
8923b5d6e0 | |
|
|
84d8beb7e0 | |
|
|
61a8bedd70 | |
|
|
28bb45d60c | |
|
|
7b56c40650 | |
|
|
cffa495446 | |
|
|
0cad1fdb45 | |
|
|
8c03d72744 | |
|
|
3910af8f5b | |
|
|
49a1acf3b2 | |
|
|
fd161f2f15 | |
|
|
9068cef7e8 | |
|
|
3559aced8c | |
|
|
7c325c5efd | |
|
|
a37177207c | |
|
|
ec0b0e006b | |
|
|
3ea878c3a8 | |
|
|
6092dc0fc1 | |
|
|
ed00d4eb29 | |
|
|
8ddf8291af | |
|
|
6a813d2c06 | |
|
|
1252f5097c | |
|
|
9ccbeb7de7 | |
|
|
33749fddaf | |
|
|
bd3d313a1b | |
|
|
4166b6f8ff | |
|
|
fd13bb436b | |
|
|
61ecb66e8f | |
|
|
dd49f3f54b | |
|
|
08f560f388 | |
|
|
d97ba4cb51 | |
|
|
e79d5f63a1 | |
|
|
7175358fa6 | |
|
|
34d7516618 | |
|
|
a90fc30cde | |
|
|
c4f4a3c877 | |
|
|
082d3399de | |
|
|
6bce8990af | |
|
|
740563bc61 | |
|
|
4ec8c3a0f6 | |
|
|
0a60f24f9c | |
|
|
7b5c5f87b7 | |
|
|
bb081bcfc2 | |
|
|
d62386b5a3 | |
|
|
03b6d3761b |
|
|
@ -28,7 +28,7 @@ github:
|
||||||
del_branch_on_merge: true
|
del_branch_on_merge: true
|
||||||
#labels:
|
#labels:
|
||||||
enabled_merge_buttons:
|
enabled_merge_buttons:
|
||||||
merge: false
|
merge: true
|
||||||
rebase: true
|
rebase: true
|
||||||
squash: true
|
squash: true
|
||||||
protected_branches:
|
protected_branches:
|
||||||
|
|
@ -41,7 +41,6 @@ github:
|
||||||
- Analyze (java)
|
- Analyze (java)
|
||||||
- CodeQL
|
- CodeQL
|
||||||
- check-license
|
- check-license
|
||||||
- build (memory, 8)
|
|
||||||
- build (memory, 11)
|
- build (memory, 11)
|
||||||
required_pull_request_reviews:
|
required_pull_request_reviews:
|
||||||
dismiss_stale_reviews: true
|
dismiss_stale_reviews: true
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,10 @@ insert_final_newline = true
|
||||||
[*.{java,xml,py}]
|
[*.{java,xml,py}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{java,xml}]
|
||||||
|
# Ignore the IDEA unsupported warning & it works well (indeed)
|
||||||
|
continuation_indent_size = 8
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ published)
|
||||||
|
|
||||||
## Purpose of the PR
|
## Purpose of the PR
|
||||||
|
|
||||||
- close #xxx <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, e.g: close #1024 -->
|
- close #xxx <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, e.g: close #1024 -->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Please explain more context in this section, clarify why the changes are needed.
|
Please explain more context in this section, clarify why the changes are needed.
|
||||||
|
|
@ -30,7 +30,7 @@ e.g:
|
||||||
|
|
||||||
## Main Changes
|
## Main Changes
|
||||||
|
|
||||||
<!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. These change logs are helpful for better ant faster reviews.)
|
<!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. These change logs are helpful for better and faster reviews.)
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
|
@ -51,11 +51,12 @@ For example:
|
||||||
|
|
||||||
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
|
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
|
||||||
|
|
||||||
- [ ] Nope
|
- [ ] Dependencies ([add/update license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses) info & [regenerate_dependencies](../hugegraph-server/hugegraph-dist/scripts/dependency/regenerate_known_dependencies.sh)) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
|
||||||
- [ ] Dependencies (add/update license info) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
|
|
||||||
- [ ] Modify configurations
|
- [ ] Modify configurations
|
||||||
- [ ] The public API
|
- [ ] The public API
|
||||||
- [ ] Other affects (typed here)
|
- [ ] Other affects (typed here)
|
||||||
|
- [ ] Nope
|
||||||
|
|
||||||
|
|
||||||
## Documentation Status
|
## Documentation Status
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||||
|
<servers>
|
||||||
|
<server>
|
||||||
|
<id>github</id>
|
||||||
|
<username>${env.GITHUB_ACTOR}</username>
|
||||||
|
<password>${env.GITHUB_TOKEN}</password>
|
||||||
|
</server>
|
||||||
|
</servers>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>local-repo</id>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<url>https://repo.maven.apache.org/maven2</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>staged-releases</id>
|
||||||
|
<url>https://repository.apache.org/content/groups/staging/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<pluginRepositories>
|
||||||
|
<pluginRepository>
|
||||||
|
<id>staged-releases</id>
|
||||||
|
<url>https://repository.apache.org/content/groups/staging/</url>
|
||||||
|
</pluginRepository>
|
||||||
|
</pluginRepositories>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<activeProfiles>
|
||||||
|
<activeProfile>local-repo</activeProfile>
|
||||||
|
</activeProfiles>
|
||||||
|
</settings>
|
||||||
|
|
@ -115,7 +115,7 @@ env:
|
||||||
global:
|
global:
|
||||||
- RELEASE_BRANCH=^release-.*$
|
- RELEASE_BRANCH=^release-.*$
|
||||||
- RELEASE_TAG=^v[0-9]\..*$
|
- RELEASE_TAG=^v[0-9]\..*$
|
||||||
- TRAVIS_DIR=hugegraph-dist/src/assembly/travis
|
- TRAVIS_DIR=hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||||
- DEPLOYED=0
|
- DEPLOYED=0
|
||||||
- secure: dYmFTVeEtRzLNaHp9ToTV/+CkTD0/rEj+K7dRN8wsv/yg4pbqwnyWbSXcqMlj6iNFzAz3nPbmFLCvAWON9/SMN9iJIT6x/xfcf+LqCT8QWczo2nc9xeX144ij2VHX1Drvtk5fRTMaTXRfWEQIrjqx2yrJTIdrXWzWSaZLFv1CRCUizEiGGCePnzUWxx9dBypNyC6IaH6lIv8uN5E6+10SYhb7UJGjWUMDg1bCeW9X7X2wg4QpsGDzlGFXT2EBPU/dAb5attTAtW8dKxrCZqZJTPWe0BarXDBR4PO15BC+a0V1g8LwexedtDjJeFRcGPaJ5NN4d3jDSusCzt5Jf4U0Wa1gDRMVTU3jT+KYkm5eoV4wOZMySobjh6VpQH/LyL0QTDy5apRPAxw+wO+tc91P+nkJmnlr3pN8abtMZ6NciZizUBYQRgR/m2Ir0stvtbZxBQOATuPtBgNDKiDgVdSYcRJzSqYEMFOn35AvsDZ9aUsyC8k29PCUZ0gQO2Is6cV1ClFBnM52hfU9XX0gu+NviSnYNGvcokod8z9VjGtnM7V3LYjqXSFqO9kkMbOmkME1tD2Bh/klw2/OM+2tBBZiAgxB89st5jSUHI4a2hpUyaQBezJUcU9t2vVT/zAVEIqzw2PDxkMU7t0n6L1x+qUIUTG/WynfIni5msxuR7HoiU=
|
- secure: dYmFTVeEtRzLNaHp9ToTV/+CkTD0/rEj+K7dRN8wsv/yg4pbqwnyWbSXcqMlj6iNFzAz3nPbmFLCvAWON9/SMN9iJIT6x/xfcf+LqCT8QWczo2nc9xeX144ij2VHX1Drvtk5fRTMaTXRfWEQIrjqx2yrJTIdrXWzWSaZLFv1CRCUizEiGGCePnzUWxx9dBypNyC6IaH6lIv8uN5E6+10SYhb7UJGjWUMDg1bCeW9X7X2wg4QpsGDzlGFXT2EBPU/dAb5attTAtW8dKxrCZqZJTPWe0BarXDBR4PO15BC+a0V1g8LwexedtDjJeFRcGPaJ5NN4d3jDSusCzt5Jf4U0Wa1gDRMVTU3jT+KYkm5eoV4wOZMySobjh6VpQH/LyL0QTDy5apRPAxw+wO+tc91P+nkJmnlr3pN8abtMZ6NciZizUBYQRgR/m2Ir0stvtbZxBQOATuPtBgNDKiDgVdSYcRJzSqYEMFOn35AvsDZ9aUsyC8k29PCUZ0gQO2Is6cV1ClFBnM52hfU9XX0gu+NviSnYNGvcokod8z9VjGtnM7V3LYjqXSFqO9kkMbOmkME1tD2Bh/klw2/OM+2tBBZiAgxB89st5jSUHI4a2hpUyaQBezJUcU9t2vVT/zAVEIqzw2PDxkMU7t0n6L1x+qUIUTG/WynfIni5msxuR7HoiU=
|
||||||
- secure: XbX6AX5zDPc2PcWYAMW+6fazqRRUqpgQkt4eXUugLuVIYZBmJ0WqncEhJ4+mdwOGPIhnP2HsOaSeK2eE/O+iLY2XpBFbugoBgm9VaZlCC4CY1gRNHaanYg64Lrm3NPY3n08IHRMazHqMpJwUqNO+OG/6QwkepULQLj5Rluf716AoXHa7IEJhAIrwr+OXQvdEaJdUXlS1lRycXVeYtOewl7qYxCO4dD4RMhPlNykh9KEK7fd5wnPkiUsp1SwF4g5XsaLvGXmT/qQ1nj8oa9Caej/iaj6HMKG3BO057mq4KK5JDxTPWhBueNpEkUwldAnrMhYWLRnNf4IyjUsaB/Pmi6HspzcaiORPLYwPmdvLGGSnYwbtO+fAHebgpgOnj/vGmRmY4YtIkYdFtbPBI0HpbGB77tqNRFCe/5deLrjx0hXJBfoKTy7d42SI1eBhNR0svZYUHkSfuXwly6hMTlH1DN/bumMFxfXDkY9PFHlzV1Mn3vb9BxKTaP88hJsWk7JqgniqUF7EWAc0EhHMbJct2gC0pDc95z4Yy9391n7/XWJErhIdYon1Ukds5+a43xFXoy76gR4LuMDpzzCnutMjhC2yDuGaZx/DfkPBb5JFU7SHtTKj05zb73Moogi7qqbH8jwcwoSfogAKyrIAWTcAgvJ2LVnRzwdsiLTc6MEagiM=
|
- secure: XbX6AX5zDPc2PcWYAMW+6fazqRRUqpgQkt4eXUugLuVIYZBmJ0WqncEhJ4+mdwOGPIhnP2HsOaSeK2eE/O+iLY2XpBFbugoBgm9VaZlCC4CY1gRNHaanYg64Lrm3NPY3n08IHRMazHqMpJwUqNO+OG/6QwkepULQLj5Rluf716AoXHa7IEJhAIrwr+OXQvdEaJdUXlS1lRycXVeYtOewl7qYxCO4dD4RMhPlNykh9KEK7fd5wnPkiUsp1SwF4g5XsaLvGXmT/qQ1nj8oa9Caej/iaj6HMKG3BO057mq4KK5JDxTPWhBueNpEkUwldAnrMhYWLRnNf4IyjUsaB/Pmi6HspzcaiORPLYwPmdvLGGSnYwbtO+fAHebgpgOnj/vGmRmY4YtIkYdFtbPBI0HpbGB77tqNRFCe/5deLrjx0hXJBfoKTy7d42SI1eBhNR0svZYUHkSfuXwly6hMTlH1DN/bumMFxfXDkY9PFHlzV1Mn3vb9BxKTaP88hJsWk7JqgniqUF7EWAc0EhHMbJct2gC0pDc95z4Yy9391n7/XWJErhIdYon1Ukds5+a43xFXoy76gR4LuMDpzzCnutMjhC2yDuGaZx/DfkPBb5JFU7SHtTKj05zb73Moogi7qqbH8jwcwoSfogAKyrIAWTcAgvJ2LVnRzwdsiLTc6MEagiM=
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@ name: "3rd-party"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
|
||||||
- /^release-.*$/
|
- /^release-.*$/
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|
||||||
|
|
@ -14,15 +13,23 @@ jobs:
|
||||||
dependency-check:
|
dependency-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
SCRIPT_DEPENDENCY: hugegraph-dist/scripts/dependency
|
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||||
|
SCRIPT_DEPENDENCY: hugegraph-server/hugegraph-dist/scripts/dependency
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
|
|
||||||
|
- name: use staged maven repo settings
|
||||||
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
- name: mvn install
|
- name: mvn install
|
||||||
run: |
|
run: |
|
||||||
mvn install -DskipTests=true -ntp
|
mvn install -DskipTests=true -ntp
|
||||||
|
|
@ -37,7 +44,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: 'Checkout Repository'
|
- name: 'Checkout Repository'
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: 'Dependency Review'
|
- name: 'Dependency Review'
|
||||||
uses: actions/dependency-review-action@v3
|
uses: actions/dependency-review-action@v3
|
||||||
# Refer: https://github.com/actions/dependency-review-action
|
# Refer: https://github.com/actions/dependency-review-action
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,15 @@ on:
|
||||||
push:
|
push:
|
||||||
branches: [ master, release-* ]
|
branches: [ master, release-* ]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
# branches: [ master ] # enable in all PR
|
# branches: [ master ] # enable in all PRs
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '33 0 * * 5'
|
- cron: '33 0 * * 5'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
|
env:
|
||||||
|
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||||
name: Analyze
|
name: Analyze
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
|
|
@ -25,7 +27,7 @@ jobs:
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Java JDK
|
- name: Setup Java JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
|
|
@ -33,6 +35,12 @@ jobs:
|
||||||
distribution: 'zulu'
|
distribution: 'zulu'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
|
|
||||||
|
- name: use staged maven repo settings
|
||||||
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v2
|
uses: github/codeql-action/init@v2
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,10 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
check-license:
|
check-license:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Check License Header
|
- name: Check License Header
|
||||||
uses: apache/skywalking-eyes@main
|
uses: apache/skywalking-eyes@main
|
||||||
|
|
@ -22,12 +24,7 @@ jobs:
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
config: .licenserc.yaml
|
config: .licenserc.yaml
|
||||||
|
|
||||||
- uses: actions/setup-java@v3
|
- name: License Check (RAT)
|
||||||
with:
|
|
||||||
java-version: '11'
|
|
||||||
distribution: 'adopt'
|
|
||||||
|
|
||||||
- name: License check(RAT)
|
|
||||||
run: |
|
run: |
|
||||||
mvn apache-rat:check -ntp
|
mvn apache-rat:check -ntp
|
||||||
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
|
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,217 @@
|
||||||
|
name: "hugegraph-pd-store-ci"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- 'release-*'
|
||||||
|
- 'test-*'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
# TODO: consider merge to one ci.yml file
|
||||||
|
jobs:
|
||||||
|
pd:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
# TODO: avoid duplicated env setup in pd & store
|
||||||
|
USE_STAGE: 'false' # Whether to include the stage repository.
|
||||||
|
# TODO: remove outdated env
|
||||||
|
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||||
|
REPORT_DIR: target/site/jacoco
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Cache Maven packages
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: ${{ runner.os }}-m2
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 5
|
||||||
|
|
||||||
|
- name: use staged maven repo settings
|
||||||
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp
|
||||||
|
|
||||||
|
- name: Run common test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test
|
||||||
|
|
||||||
|
- name: Run core test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test
|
||||||
|
|
||||||
|
# The above tests do not require starting a PD instance.
|
||||||
|
- name: Prepare env and service
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/start-pd.sh
|
||||||
|
|
||||||
|
- name: Run client test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-client-test
|
||||||
|
|
||||||
|
- name: Run rest test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-rest-test
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3.0.0
|
||||||
|
with:
|
||||||
|
file: ${{ env.REPORT_DIR }}/*.xml
|
||||||
|
|
||||||
|
store:
|
||||||
|
# TODO: avoid duplicated env setup
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
USE_STAGE: 'false' # Whether to include the stage repository.
|
||||||
|
# TODO: remove outdated env
|
||||||
|
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||||
|
REPORT_DIR: target/site/jacoco
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Cache Maven packages
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: ${{ runner.os }}-m2
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 5
|
||||||
|
|
||||||
|
- name: use staged maven repo settings
|
||||||
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp
|
||||||
|
|
||||||
|
- name: Prepare env and service
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/start-pd.sh
|
||||||
|
$TRAVIS_DIR/start-store.sh
|
||||||
|
|
||||||
|
- name: Run client test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-client-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Run core test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-core-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Run common test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-common-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Run rocksdb test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-rocksdb-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Run server test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-server-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Run raftcore test
|
||||||
|
run: |
|
||||||
|
mvn test -pl hugegraph-store/hg-store-test -am -P store-raftcore-test -Dmaven.test.failure.ignore=true
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3.0.0
|
||||||
|
with:
|
||||||
|
file: ${{ env.REPORT_DIR }}/*.xml
|
||||||
|
|
||||||
|
hstore:
|
||||||
|
# TODO: avoid duplicated env setup
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||||
|
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||||
|
REPORT_DIR: target/site/jacoco
|
||||||
|
BACKEND: hstore
|
||||||
|
RELEASE_BRANCH: ${{ startsWith(github.ref_name, 'release-') || startsWith(github.ref_name, 'test-') || startsWith(github.base_ref, 'release-') }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Cache Maven packages
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.m2
|
||||||
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
|
restore-keys: ${{ runner.os }}-m2
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
- name: use staged maven repo settings
|
||||||
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
|
run: |
|
||||||
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
mv -vf .github/configs/settings.xml $HOME/.m2/settings.xml
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
run: |
|
||||||
|
mvn clean package -U -Dmaven.javadoc.skip=true -Dmaven.test.skip=true -ntp
|
||||||
|
|
||||||
|
- name: Prepare env and service
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/install-backend.sh $BACKEND
|
||||||
|
|
||||||
|
- name: Run unit test
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/run-unit-test.sh $BACKEND
|
||||||
|
|
||||||
|
- name: Run core test
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/run-core-test.sh $BACKEND
|
||||||
|
|
||||||
|
- name: Run api test
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
|
||||||
|
|
||||||
|
- name: Run raft test
|
||||||
|
if: ${{ env.BACKEND == 'rocksdb' }}
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/run-api-test-for-raft.sh $BACKEND $REPORT_DIR
|
||||||
|
|
||||||
|
- name: Run TinkerPop test
|
||||||
|
if: ${{ env.RELEASE_BRANCH == 'true' }}
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND tinkerpop
|
||||||
|
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v3.0.0
|
||||||
|
with:
|
||||||
|
file: ${{ env.REPORT_DIR }}/*.xml
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
name: "hugegraph-ci"
|
name: "hugegraph-server-ci"
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
|
@ -10,25 +10,44 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
# TODO: we need test & replace it to ubuntu-24.04 or ubuntu-latest
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
env:
|
env:
|
||||||
TRAVIS_DIR: hugegraph-dist/src/assembly/travis
|
USE_STAGE: 'false' # Whether to include the stage repository.
|
||||||
|
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||||
REPORT_DIR: target/site/jacoco
|
REPORT_DIR: target/site/jacoco
|
||||||
BACKEND: ${{ matrix.BACKEND }}
|
BACKEND: ${{ matrix.BACKEND }}
|
||||||
TRIGGER_BRANCH_NAME: ${{ github.ref_name }}
|
TRIGGER_BRANCH_NAME: ${{ github.ref_name }}
|
||||||
HEAD_BRANCH_NAME: ${{ github.head_ref }}
|
HEAD_BRANCH_NAME: ${{ github.head_ref }}
|
||||||
BASE_BRANCH_NAME: ${{ github.base_ref }}
|
BASE_BRANCH_NAME: ${{ github.base_ref }}
|
||||||
TARGET_BRANCH_NAME: ${{ github.base_ref != '' && github.base_ref || github.ref_name }}
|
TARGET_BRANCH_NAME: ${{ github.base_ref != '' && github.base_ref || github.ref_name }}
|
||||||
RELEASE_BRANCH: ${{ startsWith(github.ref_name, 'release-') || startsWith(github.ref_name, 'test-') || startsWith(github.base_ref, 'release-') }}
|
RELEASE_BRANCH: ${{ startsWith(github.ref_name, 'release-') || startsWith(github.ref_name, 'test-') }}
|
||||||
|
RAFT_MODE: ${{ startsWith(github.head_ref, 'test') || startsWith(github.head_ref, 'raft') }}
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
BACKEND: [ memory, cassandra, scylladb, hbase, rocksdb, mysql, postgresql ]
|
BACKEND: [ memory, rocksdb, hbase, cassandra, mysql, postgresql, scylladb ]
|
||||||
JAVA_VERSION: [ '8', '11' ]
|
JAVA_VERSION: [ '11' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install JDK ${{ matrix.JAVA_VERSION }}
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 5
|
||||||
|
|
||||||
|
# TODO: Remove this step after install-backend.sh updated
|
||||||
|
- name: Install Java8 for backend
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Prepare backend environment
|
||||||
|
run: |
|
||||||
|
$TRAVIS_DIR/install-backend.sh $BACKEND && jps -l
|
||||||
|
|
||||||
|
- name: Install Java ${{ matrix.JAVA_VERSION }}
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.JAVA_VERSION }}
|
java-version: ${{ matrix.JAVA_VERSION }}
|
||||||
|
|
@ -41,30 +60,16 @@ jobs:
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
restore-keys: ${{ runner.os }}-m2
|
restore-keys: ${{ runner.os }}-m2
|
||||||
|
|
||||||
- name: Checkout
|
- name: Use staged maven repo settings
|
||||||
uses: actions/checkout@v3
|
if: ${{ env.USE_STAGE == 'true' }}
|
||||||
with:
|
run: |
|
||||||
fetch-depth: 2
|
cp $HOME/.m2/settings.xml /tmp/settings.xml
|
||||||
|
cp -vf .github/configs/settings.xml $HOME/.m2/settings.xml && cat $HOME/.m2/settings.xml
|
||||||
|
|
||||||
- name: Compile
|
- name: Compile
|
||||||
run: |
|
run: |
|
||||||
mvn clean compile -U -Dmaven.javadoc.skip=true -ntp
|
mvn clean compile -U -Dmaven.javadoc.skip=true -ntp
|
||||||
|
|
||||||
- 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
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.JAVA_VERSION }}
|
|
||||||
distribution: 'zulu'
|
|
||||||
|
|
||||||
- name: Run unit test
|
- name: Run unit test
|
||||||
run: |
|
run: |
|
||||||
$TRAVIS_DIR/run-unit-test.sh $BACKEND
|
$TRAVIS_DIR/run-unit-test.sh $BACKEND
|
||||||
|
|
@ -77,8 +82,9 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
|
$TRAVIS_DIR/run-api-test.sh $BACKEND $REPORT_DIR
|
||||||
|
|
||||||
|
# TODO: disable raft test in normal PR due to the always timeout problem
|
||||||
- name: Run raft test
|
- name: Run raft test
|
||||||
if: ${{ env.BACKEND == 'rocksdb' }}
|
if: ${{ env.RAFT_MODE == 'true' && env.BACKEND == 'rocksdb' }}
|
||||||
run: |
|
run: |
|
||||||
$TRAVIS_DIR/run-api-test-for-raft.sh $BACKEND $REPORT_DIR
|
$TRAVIS_DIR/run-api-test-for-raft.sh $BACKEND $REPORT_DIR
|
||||||
|
|
||||||
|
|
@ -88,6 +94,7 @@ jobs:
|
||||||
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND tinkerpop
|
$TRAVIS_DIR/run-tinkerpop-test.sh $BACKEND tinkerpop
|
||||||
|
|
||||||
- name: Upload coverage to Codecov
|
- name: Upload coverage to Codecov
|
||||||
uses: codecov/codecov-action@v3.0.0
|
uses: codecov/codecov-action@v3
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
file: ${{ env.REPORT_DIR }}/*.xml
|
file: ${{ env.REPORT_DIR }}/*.xml
|
||||||
|
|
@ -29,7 +29,7 @@ jobs:
|
||||||
days-before-pr-stale: 30
|
days-before-pr-stale: 30
|
||||||
days-before-pr-close: 180
|
days-before-pr-close: 180
|
||||||
operations-per-run: 10
|
operations-per-run: 10
|
||||||
start-date: '2017-10-01T00:00:00Z'
|
start-date: '2016-10-01T00:00:00Z'
|
||||||
|
|
||||||
exempt-all-assignees: true
|
exempt-all-assignees: true
|
||||||
remove-stale-when-updated: true
|
remove-stale-when-updated: true
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,9 @@ gen-java
|
||||||
.svn
|
.svn
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
### IntelliJ IDEA ###
|
||||||
.idea
|
.idea/*
|
||||||
.idea/
|
!.idea/vcs.xml
|
||||||
|
!.idea/icon.png
|
||||||
*.iws
|
*.iws
|
||||||
*.iml
|
*.iml
|
||||||
*.ipr
|
*.ipr
|
||||||
|
|
@ -83,3 +84,6 @@ hs_err_pid*
|
||||||
.mtj.tmp/
|
.mtj.tmp/
|
||||||
# blueJ files
|
# blueJ files
|
||||||
*.ctxt
|
*.ctxt
|
||||||
|
|
||||||
|
# docker volumes ignore
|
||||||
|
hugegraph-server/hugegraph-dist/docker/data/
|
||||||
|
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?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 version="4">
|
||||||
|
<component name="IssueNavigationConfiguration">
|
||||||
|
<option name="links">
|
||||||
|
<list>
|
||||||
|
<IssueNavigationLink>
|
||||||
|
<option name="issueRegexp" value="#(\d+)" />
|
||||||
|
<!--
|
||||||
|
GitHub share the sequence number of issues and pull requests, and it will redirect to
|
||||||
|
the right place when the the sequence number not match kind.
|
||||||
|
-->
|
||||||
|
<option name="linkRegexp" value="https://github.com/apache/hugegraph/pull/$1" />
|
||||||
|
</IssueNavigationLink>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
@ -26,7 +26,9 @@ header: # `header` section is configurations for source codes license header.
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
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
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
|
@ -34,20 +36,20 @@ header: # `header` section is configurations for source codes license header.
|
||||||
limitations under the License.
|
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` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
|
||||||
pattern: |
|
pattern: |
|
||||||
Licensed to the Apache Software Foundation under one or more contributor
|
Licensed to the Apache Software Foundation \(ASF\) under one or more
|
||||||
license agreements. See the NOTICE file distributed with
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
this work for additional information regarding copyright
|
this work for additional information regarding copyright ownership.
|
||||||
ownership. The Apache Software Foundation licenses this file to you under
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
the Apache License, Version 2.0 \(the "License"\); you may
|
\(the "License"\); you may not use this file except in compliance with
|
||||||
not use this file except in compliance with the License.
|
the License. You may obtain a copy of the License at
|
||||||
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
|
Unless required by applicable law or agreed to in writing, software
|
||||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
KIND, either express or implied. See the License for the
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
specific language governing permissions and limitations
|
See the License for the specific language governing permissions and
|
||||||
under the License.
|
limitations under the License.
|
||||||
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
|
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
|
||||||
- '**'
|
- '**'
|
||||||
|
|
||||||
|
|
@ -68,7 +70,7 @@ header: # `header` section is configurations for source codes license header.
|
||||||
- '**/*.properties'
|
- '**/*.properties'
|
||||||
- '**/RaftRequests.java'
|
- '**/RaftRequests.java'
|
||||||
- 'dist/**/*'
|
- 'dist/**/*'
|
||||||
- 'hugegraph-dist'
|
- 'hugegraph-server/hugegraph-dist'
|
||||||
- '**/assembly/static/bin/hugegraph.service'
|
- '**/assembly/static/bin/hugegraph.service'
|
||||||
- 'scripts/dev/reviewers'
|
- 'scripts/dev/reviewers'
|
||||||
- 'scripts/dev/reviewers'
|
- 'scripts/dev/reviewers'
|
||||||
|
|
@ -89,13 +91,19 @@ header: # `header` section is configurations for source codes license header.
|
||||||
- '**/META-INF/MANIFEST.MF'
|
- '**/META-INF/MANIFEST.MF'
|
||||||
- '.repository/**'
|
- '.repository/**'
|
||||||
- '**/.flattened-pom.xml'
|
- '**/.flattened-pom.xml'
|
||||||
- 'hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/SnowflakeIdGenerator.java'
|
# TODO: temporarily added to the ignore list, need handle them before releases ( ↓ )
|
||||||
- '**/optimize/HugeScriptTraversal.java'
|
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/SnowflakeIdGenerator.java'
|
||||||
- '**/type/Nameable.java'
|
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java'
|
||||||
- '**/define/Cardinality.java'
|
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java'
|
||||||
- '**/util/StringEncoding.java'
|
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java'
|
||||||
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java'
|
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java'
|
||||||
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java'
|
- 'hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/ProcessBasicSuite.java'
|
||||||
|
- 'hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java'
|
||||||
|
- 'hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java'
|
||||||
|
- 'hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/ProcfsEntry.java'
|
||||||
|
- 'hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/ProcfsReader.java'
|
||||||
|
- 'hugegraph-store/hg-store-node/src/main/java/org/apache/hugegraph/store/node/metrics/ProcfsSmaps.java'
|
||||||
|
# TODO: temporarily added to the ignore list, need handle them before releases ( ↑ )
|
||||||
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
|
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,
|
# license-location-threshold specifies the index threshold where the license header can be located,
|
||||||
|
|
|
||||||
37
BUILDING.md
37
BUILDING.md
|
|
@ -1,28 +1,35 @@
|
||||||
Building hugegraph
|
Building HugeGraph
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Required:
|
Required:
|
||||||
|
|
||||||
* Java 8/11
|
* Java 11
|
||||||
* Maven
|
* Maven 3.5+
|
||||||
|
|
||||||
|
To build without executing tests: `mvn clean package -DskipTests`
|
||||||
|
|
||||||
|
## Building in IDEA
|
||||||
|
|
||||||
To build without executing tests:
|
To build without executing tests:
|
||||||
|
|
||||||
```
|
1. Click on "File" -> "Open", choose your project location.
|
||||||
mvn clean
|
2. Open maven view by click "View" -> "Tool Windows" -> "Maven Projects".
|
||||||
mvn package -DskipTests
|
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 a project.
|
||||||
|
|
||||||
## Building on Eclipse IDE
|
Could also refer [Dev-In-IDEA](https://hugegraph.apache.org/docs/contribution-guidelines/hugegraph-server-idea-setup/) for more details.
|
||||||
Note that this has only been tested on Eclipse Neon.2 Release (4.6.2) with m2e (1.7.0.20160603-1933) and m2e-wtp (1.3.1.20160831-1005) plugin.
|
|
||||||
|
|
||||||
|
## Building in Eclipse
|
||||||
|
|
||||||
|
> Note: this has only been tested on Eclipse Neon.2 Release (4.6.2) with m2e (1.7.0.20160603-1933) and m2e-wtp (1.3.1.20160831-1005) plugin.
|
||||||
|
|
||||||
To build without executing tests:
|
To build without executing tests:
|
||||||
|
|
||||||
1. Right-click on your project -> "Run As..." -> "Run Configurations..."
|
1. Right-click on your project -> "Run As..." -> "Run Configurations..."
|
||||||
2. On "Goals", populate with `install`
|
2. On "Goals", populate with `install`
|
||||||
3. Select the options `Update Snapshots` and `Skip Tests`
|
3. Select the options `Update Snapshots` and `Skip Tests`
|
||||||
4. Before clicking "Run", make sure that Eclipse knows where `JAVA_HOME` is. On same window, go to "Environment" tab and click "New".
|
4. Before clicking "Run", make sure that Eclipse knows where `JAVA_HOME` is. In the same window, go to "Environment" tab and click "New".
|
||||||
5. Under "Name:", add `JAVA_HOME`
|
5. Under "Name:", add `JAVA_HOME`
|
||||||
6. Under "Value:", add the path where `java` is located
|
6. Under "Value:", add the path where `java` is located
|
||||||
7. Click "OK"
|
7. Click "OK"
|
||||||
|
|
@ -32,13 +39,3 @@ To find the Java binary in your environment, run the appropriate command for you
|
||||||
* Linux/macOS: `which java`
|
* Linux/macOS: `which java`
|
||||||
* Windows: `for %i in (java.exe) do @echo. %~$PATH:i`
|
* Windows: `for %i in (java.exe) do @echo. %~$PATH:i`
|
||||||
|
|
||||||
## Building on IDEA
|
|
||||||
|
|
||||||
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".
|
|
||||||
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.
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
# How to Contribute to HugeGraph
|
# 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,
|
> Refer [website-doc](https://hugegraph.apache.org/docs/contribution-guidelines/) for the latest information.
|
||||||
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 being contributed from everyone, and we are also grateful to all the contributors.
|
||||||
|
|
||||||
The following is a contribution guide for HugeGraph:
|
The following is a contribution guide for HugeGraph:
|
||||||
|
|
||||||
|
|
@ -15,7 +17,7 @@ We can contribute by reporting issues, submitting code patches or any other feed
|
||||||
|
|
||||||
Before submitting the code, we need to do some preparation:
|
Before submitting the code, we need to do some preparation:
|
||||||
|
|
||||||
1. Sign up or login to GitHub: [https://github.com](https://github.com)
|
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/apache/incubator-hugegraph/fork](https://github.com/apache/incubator-hugegraph/fork)
|
||||||
|
|
||||||
|
|
@ -64,26 +66,26 @@ Assume that we need to modify some files like "HugeGraph.java" and "HugeFactory.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# modify code to fix a bug
|
# modify code to fix a bug
|
||||||
vim hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
vim hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
||||||
vim hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
vim hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||||
# run test locally (optional)
|
# run test locally (optional)
|
||||||
mvn test -Pcore-test,memory
|
mvn test -Pcore-test,memory
|
||||||
```
|
```
|
||||||
Note: In order to be consistent with the code style easily, if you use [IDEA](https://www.jetbrains.com/idea/) as your IDE, you can directly [import](https://www.jetbrains.com/help/idea/configuring-code-style.html) our code style [configuration file](./hugegraph-style.xml).
|
Note: To be consistent with the code style easily, if you use [IDEA](https://www.jetbrains.com/idea/) as your IDE, you can directly [import](https://www.jetbrains.com/help/idea/configuring-code-style.html) our code style [configuration file](./hugegraph-style.xml).
|
||||||
|
|
||||||
##### 3.2.1 Check licenses
|
##### 3.2.1 Check licenses
|
||||||
If we want to add new third-party dependencies to the `HugeGraph` project, we need to do the following things:
|
If we want to add new third-party dependencies to the `HugeGraph` project, we need to do the following things:
|
||||||
1. Find the third-party dependent repository, put the dependent `license` file into [./hugegraph-dist/release-docs/licenses/](https://github.com/apache/incubator-hugegraph/tree/master/hugegraph-dist/release-docs/licenses) path.
|
1. Find the third-party dependent repository, put the dependent `license` file into [./hugegraph-dist/release-docs/licenses/](https://github.com/apache/incubator-hugegraph/tree/master/hugegraph-dist/release-docs/licenses) path.
|
||||||
2. Declare the dependency in [./hugegraph-dist/release-docs/LICENSE](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-dist/release-docs/LICENSE) `LICENSE` information.
|
2. Declare the dependency in [./hugegraph-server/hugegraph-dist/release-docs/LICENSE](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/release-docs/LICENSE) `LICENSE` information.
|
||||||
3. Find the NOTICE file in the repository and append it to [./hugegraph-dist/release-docs/NOTICE](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-dist/release-docs/NOTICE) file (skip this step if there is no NOTICE file).
|
3. Find the NOTICE file in the repository and append it to [./hugegraph-server/hugegraph-dist/release-docs/NOTICE](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/release-docs/NOTICE) file (skip this step if there is no NOTICE file).
|
||||||
4. Execute locally [./hugegraph-dist/scripts/dependency/regenerate_known_dependencies.sh](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-dist/scripts/dependency/regenerate_known_dependencies.sh) to update the dependency list [known-dependencies.txt](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-dist/scripts/dependency/known-dependencies.txt) (or manually update) .
|
4. Execute locally [./hugegraph-server/hugegraph-dist/scripts/dependency/regenerate_known_dependencies.sh](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/scripts/dependency/regenerate_known_dependencies.sh) to update the dependency list [known-dependencies.txt](https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/scripts/dependency/known-dependencies.txt) (or manually update).
|
||||||
|
|
||||||
**Example**: A new third-party dependency is introduced into the project -> `ant-1.9.1.jar`
|
**Example**: A new third-party dependency is introduced into the project -> `ant-1.9.1.jar`
|
||||||
- The project source code is located at: https://github.com/apache/ant/tree/rel/1.9.1
|
- The project source code is located at: https://github.com/apache/ant/tree/rel/1.9.1
|
||||||
- LICENSE file: https://github.com/apache/ant/blob/rel/1.9.1/LICENSE
|
- LICENSE file: https://github.com/apache/ant/blob/rel/1.9.1/LICENSE
|
||||||
- NOTICE file: https://github.com/apache/ant/blob/rel/1.9.1/NOTICE
|
- NOTICE file: https://github.com/apache/ant/blob/rel/1.9.1/NOTICE
|
||||||
|
|
||||||
The license information of `ant-1.9.1.jar` needs to be specified in the LICENSE file, and the notice information needs to be specified in the NOTICE file. The detailed LICENSE file corresponding to ant-1.9.1.jar needs to be copied to our licenses/ directory. Finally update the known-dependencies.txt file.
|
The license information of `ant-1.9.1.jar` needs to be specified in the LICENSE file, and the notice information needs to be specified in the NOTICE file. The detailed LICENSE file corresponding to ant-1.9.1.jar needs to be copied to our licenses/ directory. Finally, update the known-dependencies.txt file.
|
||||||
|
|
||||||
#### 3.3 Commit changes to git repo
|
#### 3.3 Commit changes to git repo
|
||||||
|
|
||||||
|
|
@ -91,8 +93,8 @@ After the code has been completed, we submit them to the local git repo:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# add files to local git index
|
# add files to local git index
|
||||||
git add hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
git add hugegraph-server/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-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||||
# commit to local git repo
|
# commit to local git repo
|
||||||
git commit
|
git commit
|
||||||
```
|
```
|
||||||
|
|
@ -105,7 +107,7 @@ Fix bug: run deploy multiple times
|
||||||
fix #ISSUE_ID
|
fix #ISSUE_ID
|
||||||
```
|
```
|
||||||
|
|
||||||
> Please remember to fill in the issue id, which was generated by GitHub after issue creation.
|
> Please remember to fill in the issue id, which GitHub generated after issue creation.
|
||||||
|
|
||||||
#### 3.4 Push commit to GitHub fork repo
|
#### 3.4 Push commit to GitHub fork repo
|
||||||
|
|
||||||
|
|
@ -121,7 +123,7 @@ Note that since GitHub requires submitting code through `username + token` (inst
|
||||||
|
|
||||||
## 4. Create a Pull Request
|
## 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.
|
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, click the button "Compare & pull request" to do it. Then edit the description for proposed changes, which can just be copied from the commit message.
|
||||||
|
|
||||||
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:
|
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">
|
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/9625821/163522445-2a50a72a-dea2-434f-9868-3a0d40d0d037.png">
|
||||||
|
|
@ -131,7 +133,7 @@ Note: please make sure the email address you used to submit the code is bound to
|
||||||
Maintainers will start the code review after all the **automatic** checks are passed:
|
Maintainers will start the code review after all the **automatic** checks are passed:
|
||||||
|
|
||||||
- Check: Contributor License Agreement is signed
|
- Check: Contributor License Agreement is signed
|
||||||
- Check: Travis CI builds is passed (automatically Test and Deploy)
|
- Check: Travis CI builds are passed (automatically Test and Deploy)
|
||||||
|
|
||||||
The commit will be accepted and merged if there is no problem after review.
|
The commit will be accepted and merged if there is no problem after review.
|
||||||
|
|
||||||
|
|
@ -171,8 +173,8 @@ And push it to GitHub fork repo again:
|
||||||
git push -f origin bugfix-branch:bugfix-branch
|
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, 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/).
|
For Any question, please contact us through [dev@hugegraph.apache.org](mailto:dev@hugegraph.apache.org) ([subscriber](https://hugegraph.apache.org/docs/contribution-guidelines/subscribe/) only)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
18
LICENSE
18
LICENSE
|
|
@ -207,12 +207,12 @@ Apache 2.0 licenses
|
||||||
The following components are provided under the Apache License. See project link for details.
|
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.
|
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-server/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-server/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-server/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-server/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-server/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-server/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-server/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-server/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
|
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java from https://github.com/opencypher/cypher-for-gremlin
|
||||||
|
|
|
||||||
40
NOTICE
40
NOTICE
|
|
@ -1,5 +1,5 @@
|
||||||
Apache HugeGraph(incubating)
|
Apache HugeGraph(incubating)
|
||||||
Copyright 2022-2023 The Apache Software Foundation
|
Copyright 2022-2024 The Apache Software Foundation
|
||||||
|
|
||||||
This product includes software developed at
|
This product includes software developed at
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
The Apache Software Foundation (http://www.apache.org/).
|
||||||
|
|
@ -13,9 +13,6 @@ This product contains code form the Apache TinkerPop Project:
|
||||||
Apache TinkerPop
|
Apache TinkerPop
|
||||||
Copyright 2015-2022 The Apache Software Foundation.
|
Copyright 2015-2022 The Apache Software Foundation.
|
||||||
|
|
||||||
This product includes software developed at
|
|
||||||
The Apache Software Foundation (http://www.apache.org/).
|
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Activiti
|
Activiti
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
|
|
@ -42,7 +39,7 @@ This product contains code form the JanusGraph Project:
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
==============================================================
|
==============================================================
|
||||||
JanusGraph: Distributed Graph Database
|
JanusGraph: Distributed Graph Database
|
||||||
Copyright 2012 and onwards JanusGraph Authors
|
Copyright 2012 with JanusGraph Authors
|
||||||
==============================================================
|
==============================================================
|
||||||
|
|
||||||
This product includes software developed by JanusGraph contributors listed
|
This product includes software developed by JanusGraph contributors listed
|
||||||
|
|
@ -56,36 +53,3 @@ DataStax) and the following individuals:
|
||||||
* Marko A. Rodriguez
|
* Marko A. Rodriguez
|
||||||
* Stephen Mallette
|
* Stephen Mallette
|
||||||
* Pavel Yaskevich
|
* 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/]
|
|
||||||
|
|
|
||||||
37
README.md
37
README.md
|
|
@ -8,18 +8,17 @@
|
||||||
|
|
||||||
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
[](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/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://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml)
|
||||||
[](https://app.codecov.io/gh/apache/incubator-hugegraph)
|
|
||||||
[](https://github.com/apache/hugegraph/releases)
|
[](https://github.com/apache/hugegraph/releases)
|
||||||
[](https://github.com/apache/incubator-hugegraph/stargazers)
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## What is Apache HugeGraph?
|
## What is Apache HugeGraph?
|
||||||
|
|
||||||
[HugeGraph](https://hugegraph.apache.org/) is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database).
|
[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).
|
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
|
||||||
|
achieved through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
|
||||||
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
@ -27,22 +26,28 @@ Billions of vertices and edges can be easily stored into and queried from HugeGr
|
||||||
- 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/), support [Gremlin](https://tinkerpop.apache.org/gremlin.html) & [Cypher](https://en.wikipedia.org/wiki/Cypher) language
|
||||||
- Schema Metadata Management, including VertexLabel, EdgeLabel, PropertyKey and IndexLabel
|
- Schema Metadata Management, including VertexLabel, EdgeLabel, PropertyKey and IndexLabel
|
||||||
- Multi-type Indexes, supporting exact query, range query and complex conditions combination query
|
- 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
|
- Plug-in Backend Store Driver Framework, support `RocksDB`, `Cassandra`, `HBase`, `ScyllaDB`, and `MySQL/Postgre` now and easy to add another backend store driver if needed
|
||||||
- Integration with `Flink/Spark/HDFS`, and friendly to connect other big data platforms
|
- Integration with `Flink/Spark/HDFS`, and friendly to connect other big data platforms
|
||||||
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### 1. Docker Way
|
### 1. Docker Way (Convenient for Test)
|
||||||
|
|
||||||
We can use `docker run -itd --name=graph -p 8080:8080 hugegraph/hugegraph` to quickly start an inner
|
We can use `docker run -itd --name=graph -p 8080:8080 hugegraph/hugegraph` to quickly start an inner
|
||||||
HugeGraph server with `RocksDB` in background.
|
HugeGraph server with `RocksDB` (in backgrounds) for **test/dev**.
|
||||||
|
You can visit [doc page](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#3-deploy) or
|
||||||
|
the [README](hugegraph-server/hugegraph-dist/docker/README.md) for more details. ([Docker Compose](./hugegraph-server/hugegraph-dist/docker/example))
|
||||||
|
|
||||||
Optional: use `docker exec -it graph bash` to enter the container to do some operations.
|
> Note:
|
||||||
|
>
|
||||||
|
> 1. The docker image of hugegraph is a convenience release, but not **official distribution** artifacts. You can find more details from [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub).
|
||||||
|
>
|
||||||
|
> 2. Recommend to use `release tag`(like `1.2.0`) for the stable version. Use `latest` tag to experience the newest functions in development.
|
||||||
|
|
||||||
### 2. Download Way
|
### 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)
|
Visit [Download Page](https://hugegraph.apache.org/docs/download/download/) and refer the [doc](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#32-download-the-binary-tar-tarball)
|
||||||
to download the latest release package and start the server.
|
to download the latest release package and start the server.
|
||||||
|
|
||||||
### 3. Source Building Way
|
### 3. Source Building Way
|
||||||
|
|
@ -54,14 +59,15 @@ The project [doc page](https://hugegraph.apache.org/docs/) contains more informa
|
||||||
and provides detailed documentation for users. (Structure / Usage / API / Configs...)
|
and provides detailed documentation for users. (Structure / Usage / API / Configs...)
|
||||||
|
|
||||||
And here are links of other **HugeGraph** component/repositories:
|
And here are links of other **HugeGraph** component/repositories:
|
||||||
1. [hugegraph-toolchain](https://github.com/apache/incubator-hugegraph-toolchain) (graph **loader/dashboard/tool/client**)
|
1. [hugegraph-toolchain](https://github.com/apache/hugegraph-toolchain) (graph tools **[loader](https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-loader)/[dashboard](https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-hubble)/[tool](https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-tools)/[client](https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-client)**)
|
||||||
2. [hugegraph-computer](https://github.com/apache/incubator-hugegraph-computer) (matched **graph computing** system)
|
2. [hugegraph-computer](https://github.com/apache/hugegraph-computer) (integrated **graph computing** system)
|
||||||
3. [hugegraph-commons](https://github.com/apache/incubator-hugegraph-commons) (**common & rpc** module)
|
3. [hugegraph-commons](https://github.com/apache/hugegraph-commons) (**common & rpc** libs)
|
||||||
4. [hugegraph-website](https://github.com/apache/incubator-hugegraph-doc) (**doc & website** code)
|
4. [hugegraph-website](https://github.com/apache/hugegraph-doc) (**doc & website** code)
|
||||||
|
5. [hugegraph-ai](https://github.com/apache/incubator-hugegraph-ai) (integrated **Graph AI/LLM/KG** system)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
HugeGraph is licensed under Apache 2.0 License.
|
HugeGraph is licensed under [Apache 2.0 License](LICENSE).
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
@ -78,7 +84,8 @@ HugeGraph is licensed under Apache 2.0 License.
|
||||||
HugeGraph relies on the [TinkerPop](http://tinkerpop.apache.org) framework, we refer to the storage structure of Titan and the schema definition of DataStax.
|
HugeGraph relies on the [TinkerPop](http://tinkerpop.apache.org) framework, we refer to the storage structure of Titan and the schema definition of DataStax.
|
||||||
Thanks to TinkerPop, thanks to Titan, thanks to DataStax. Thanks to all other organizations or authors who contributed to the project.
|
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.
|
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
|
## Contact Us
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: hugegraph-pd
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
license:
|
||||||
|
verify-path: ./conf/verify-license.json
|
||||||
|
license-path: ./conf/hugegraph.license
|
||||||
|
grpc:
|
||||||
|
port: 8686
|
||||||
|
host: 127.0.0.1
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8620
|
||||||
|
|
||||||
|
pd:
|
||||||
|
data-path: ./pd_data
|
||||||
|
patrol-interval: 1800
|
||||||
|
initial-store-count: 3
|
||||||
|
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||||
|
|
||||||
|
raft:
|
||||||
|
address: 127.0.0.1:8610
|
||||||
|
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||||
|
|
||||||
|
store:
|
||||||
|
max-down-time: 172800
|
||||||
|
monitor_data_enabled: true
|
||||||
|
monitor_data_interval: 1 minute
|
||||||
|
monitor_data_retention: 1 day
|
||||||
|
initial-store-count: 1
|
||||||
|
|
||||||
|
partition:
|
||||||
|
default-shard-count: 1
|
||||||
|
store-max-shard-count: 12
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: hugegraph-pd
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
license:
|
||||||
|
verify-path: ./conf/verify-license.json
|
||||||
|
license-path: ./conf/hugegraph.license
|
||||||
|
grpc:
|
||||||
|
port: 8687
|
||||||
|
host: 127.0.0.1
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8621
|
||||||
|
|
||||||
|
pd:
|
||||||
|
data-path: ./pd_data
|
||||||
|
patrol-interval: 1800
|
||||||
|
initial-store-count: 3
|
||||||
|
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||||
|
|
||||||
|
raft:
|
||||||
|
address: 127.0.0.1:8611
|
||||||
|
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||||
|
|
||||||
|
store:
|
||||||
|
max-down-time: 172800
|
||||||
|
monitor_data_enabled: true
|
||||||
|
monitor_data_interval: 1 minute
|
||||||
|
monitor_data_retention: 1 day
|
||||||
|
initial-store-count: 1
|
||||||
|
|
||||||
|
partition:
|
||||||
|
default-shard-count: 1
|
||||||
|
store-max-shard-count: 12
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: hugegraph-pd
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
license:
|
||||||
|
verify-path: ./conf/verify-license.json
|
||||||
|
license-path: ./conf/hugegraph.license
|
||||||
|
grpc:
|
||||||
|
port: 8688
|
||||||
|
host: 127.0.0.1
|
||||||
|
|
||||||
|
server:
|
||||||
|
port: 8622
|
||||||
|
|
||||||
|
pd:
|
||||||
|
data-path: ./pd_data
|
||||||
|
patrol-interval: 1800
|
||||||
|
initial-store-count: 3
|
||||||
|
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||||
|
|
||||||
|
raft:
|
||||||
|
address: 127.0.0.1:8612
|
||||||
|
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||||
|
|
||||||
|
store:
|
||||||
|
max-down-time: 172800
|
||||||
|
monitor_data_enabled: true
|
||||||
|
monitor_data_interval: 1 minute
|
||||||
|
monitor_data_retention: 1 day
|
||||||
|
initial-store-count: 1
|
||||||
|
|
||||||
|
partition:
|
||||||
|
default-shard-count: 1
|
||||||
|
store-max-shard-count: 12
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
pdserver:
|
||||||
|
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
grpc:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8500
|
||||||
|
netty-server:
|
||||||
|
max-inbound-message-size: 1000MB
|
||||||
|
raft:
|
||||||
|
disruptorBufferSize: 1024
|
||||||
|
address: 127.0.0.1:8510
|
||||||
|
max-log-file-size: 600000000000
|
||||||
|
snapshotInterval: 1800
|
||||||
|
server:
|
||||||
|
port: 8520
|
||||||
|
|
||||||
|
app:
|
||||||
|
data-path: ./storage
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: store-node-grpc-server
|
||||||
|
profiles:
|
||||||
|
active: default
|
||||||
|
include: pd
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
pdserver:
|
||||||
|
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
grpc:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8501
|
||||||
|
netty-server:
|
||||||
|
max-inbound-message-size: 1000MB
|
||||||
|
raft:
|
||||||
|
disruptorBufferSize: 1024
|
||||||
|
address: 127.0.0.1:8511
|
||||||
|
max-log-file-size: 600000000000
|
||||||
|
snapshotInterval: 1800
|
||||||
|
server:
|
||||||
|
port: 8521
|
||||||
|
|
||||||
|
app:
|
||||||
|
data-path: ./storage
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: store-node-grpc-server
|
||||||
|
profiles:
|
||||||
|
active: default
|
||||||
|
include: pd
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
pdserver:
|
||||||
|
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
management:
|
||||||
|
metrics:
|
||||||
|
export:
|
||||||
|
prometheus:
|
||||||
|
enabled: true
|
||||||
|
endpoints:
|
||||||
|
web:
|
||||||
|
exposure:
|
||||||
|
include: "*"
|
||||||
|
|
||||||
|
grpc:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8502
|
||||||
|
netty-server:
|
||||||
|
max-inbound-message-size: 1000MB
|
||||||
|
raft:
|
||||||
|
disruptorBufferSize: 1024
|
||||||
|
address: 127.0.0.1:8512
|
||||||
|
max-log-file-size: 600000000000
|
||||||
|
snapshotInterval: 1800
|
||||||
|
server:
|
||||||
|
port: 8522
|
||||||
|
|
||||||
|
app:
|
||||||
|
data-path: ./storage
|
||||||
|
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: store-node-grpc-server
|
||||||
|
profiles:
|
||||||
|
active: default
|
||||||
|
include: pd
|
||||||
|
|
||||||
|
logging:
|
||||||
|
config: 'file:./conf/log4j2.xml'
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||||
|
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||||
|
|
||||||
|
# cache config
|
||||||
|
vertex.cache_type=l2
|
||||||
|
edge.cache_type=l2
|
||||||
|
|
||||||
|
store=hugegraph
|
||||||
|
backend=hstore
|
||||||
|
serializer=binary
|
||||||
|
|
||||||
|
# pd config
|
||||||
|
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
# task config
|
||||||
|
task.scheduler_type=local
|
||||||
|
task.schedule_period=10
|
||||||
|
task.retry=0
|
||||||
|
task.wait_timeout=10
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8181
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8181
|
||||||
|
|
||||||
|
# timeout in ms of gremlin query
|
||||||
|
evaluationTimeout: 30000
|
||||||
|
|
||||||
|
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||||
|
# don't set graph at here, this happens after support for dynamically adding graph
|
||||||
|
graphs: {
|
||||||
|
}
|
||||||
|
scriptEngines: {
|
||||||
|
gremlin-groovy: {
|
||||||
|
staticImports: [
|
||||||
|
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||||
|
],
|
||||||
|
plugins: {
|
||||||
|
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||||
|
classImports: [
|
||||||
|
java.lang.Math,
|
||||||
|
org.apache.hugegraph.backend.id.IdGenerator,
|
||||||
|
org.apache.hugegraph.type.define.Directions,
|
||||||
|
org.apache.hugegraph.type.define.NodeRole,
|
||||||
|
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||||
|
org.apache.hugegraph.util.DateUtil,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||||
|
org.apache.hugegraph.traversal.optimize.Text,
|
||||||
|
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate
|
||||||
|
],
|
||||||
|
methodImports: [
|
||||||
|
java.lang.Math#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||||
|
]
|
||||||
|
},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||||
|
files: [scripts/empty-sample.groovy]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serializers:
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
metrics: {
|
||||||
|
consoleReporter: {enabled: false, interval: 180000},
|
||||||
|
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||||
|
jmxReporter: {enabled: false},
|
||||||
|
slf4jReporter: {enabled: false, interval: 180000},
|
||||||
|
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||||
|
graphiteReporter: {enabled: false, interval: 180000}
|
||||||
|
}
|
||||||
|
maxInitialLineLength: 4096
|
||||||
|
maxHeaderSize: 8192
|
||||||
|
maxChunkSize: 8192
|
||||||
|
maxContentLength: 65536
|
||||||
|
maxAccumulationBufferComponents: 1024
|
||||||
|
resultIterationBatchSize: 64
|
||||||
|
writeBufferLowWaterMark: 32768
|
||||||
|
writeBufferHighWaterMark: 65536
|
||||||
|
ssl: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
<!--
|
||||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
contributor license agreements. See the NOTICE file distributed with this
|
contributor license agreements. See the NOTICE file distributed with
|
||||||
work for additional information regarding copyright ownership. The ASF
|
this work for additional information regarding copyright ownership.
|
||||||
licenses this file to You under the Apache License, Version 2.0 (the
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
"License"); you may not use this file except in compliance with the License.
|
(the "License"); you may not use this file except in compliance with
|
||||||
You may obtain a copy of the License at
|
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
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
License for the specific language governing permissions and limitations
|
See the License for the specific language governing permissions and
|
||||||
under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<!-- Config will be auto loaded every 60s -->
|
<!-- Config will be auto loaded every 60s -->
|
||||||
<configuration status="error" monitorInterval="60">
|
<configuration status="error" monitorInterval="60">
|
||||||
|
|
@ -30,14 +30,14 @@
|
||||||
|
|
||||||
<!-- Normal server log config -->
|
<!-- Normal server log config -->
|
||||||
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
||||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
||||||
immediateFlush="false">
|
immediateFlush="false">
|
||||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
<!-- Trigger after exceeding 1day or 50MB -->
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
<Policies>
|
<Policies>
|
||||||
<SizeBasedTriggeringPolicy size="50MB"/>
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
</Policies>
|
</Policies>
|
||||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
<DefaultRolloverStrategy max="5">
|
<DefaultRolloverStrategy max="5">
|
||||||
|
|
@ -45,8 +45,8 @@
|
||||||
<IfFileName glob="*/*.log"/>
|
<IfFileName glob="*/*.log"/>
|
||||||
<!-- Limit log amount & size -->
|
<!-- Limit log amount & size -->
|
||||||
<IfAny>
|
<IfAny>
|
||||||
<IfAccumulatedFileSize exceeds="2GB" />
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
<IfAccumulatedFileCount exceeds="100" />
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
</IfAny>
|
</IfAny>
|
||||||
</Delete>
|
</Delete>
|
||||||
</DefaultRolloverStrategy>
|
</DefaultRolloverStrategy>
|
||||||
|
|
@ -54,15 +54,15 @@
|
||||||
|
|
||||||
<!-- Separate & compress audit log, buffer size is 512KB -->
|
<!-- Separate & compress audit log, buffer size is 512KB -->
|
||||||
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
||||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
||||||
bufferSize="524288" immediateFlush="false">
|
bufferSize="524288" immediateFlush="false">
|
||||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
<!-- Use simple format for audit log to speed up -->
|
<!-- Use simple format for audit log to speed up -->
|
||||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
||||||
<!-- Trigger after exceeding 1hour or 500MB -->
|
<!-- Trigger after exceeding 1hour or 500MB -->
|
||||||
<Policies>
|
<Policies>
|
||||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||||
<TimeBasedTriggeringPolicy interval="1" modulate="true" />
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
</Policies>
|
</Policies>
|
||||||
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
||||||
<DefaultRolloverStrategy max="2">
|
<DefaultRolloverStrategy max="2">
|
||||||
|
|
@ -70,8 +70,32 @@
|
||||||
<IfFileName glob="*/*.gz"/>
|
<IfFileName glob="*/*.gz"/>
|
||||||
<IfLastModified age="60d"/>
|
<IfLastModified age="60d"/>
|
||||||
<IfAny>
|
<IfAny>
|
||||||
<IfAccumulatedFileSize exceeds="5GB" />
|
<IfAccumulatedFileSize exceeds="5GB"/>
|
||||||
<IfAccumulatedFileCount exceeds="500" />
|
<IfAccumulatedFileCount exceeds="500"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
|
<!-- Slow query log config -->
|
||||||
|
<RollingRandomAccessFile name="slowQueryLog" fileName="${LOG_PATH}/slow_query.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/slow_query_log-%d{yyyy-MM-dd}-%i.log"
|
||||||
|
immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
|
<DefaultRolloverStrategy max="5">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.log"/>
|
||||||
|
<!-- Limit log amount & size -->
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
</IfAny>
|
</IfAny>
|
||||||
</Delete>
|
</Delete>
|
||||||
</DefaultRolloverStrategy>
|
</DefaultRolloverStrategy>
|
||||||
|
|
@ -113,5 +137,8 @@
|
||||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||||
<appender-ref ref="audit"/>
|
<appender-ref ref="audit"/>
|
||||||
</AsyncLogger>
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="slowQueryLog"/>
|
||||||
|
</AsyncLogger>
|
||||||
</loggers>
|
</loggers>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8181
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||||
|
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||||
|
ioRegistries: [
|
||||||
|
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||||
|
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8181
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
# bind url
|
||||||
|
restserver.url=http://127.0.0.1:8081
|
||||||
|
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||||
|
gremlinserver.url=http://127.0.0.1:8181
|
||||||
|
|
||||||
|
graphs=./conf/graphs
|
||||||
|
|
||||||
|
# configuration of arthas
|
||||||
|
arthas.telnet_port=8562
|
||||||
|
arthas.http_port=8561
|
||||||
|
arthas.ip=127.0.0.1
|
||||||
|
arthas.disabled_commands=jad
|
||||||
|
|
||||||
|
# authentication configs
|
||||||
|
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||||
|
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||||
|
#auth.authenticator=
|
||||||
|
|
||||||
|
# rpc server configs for multi graph-servers or raft-servers
|
||||||
|
rpc.server_host=127.0.0.1
|
||||||
|
rpc.server_port=8091
|
||||||
|
|
||||||
|
# lightweight load balancing (beta)
|
||||||
|
server.id=server-1
|
||||||
|
server.role=master
|
||||||
|
|
||||||
|
# slow query log
|
||||||
|
log.slow_query_threshold=1000
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||||
|
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||||
|
|
||||||
|
# cache config
|
||||||
|
vertex.cache_type=l2
|
||||||
|
edge.cache_type=l2
|
||||||
|
|
||||||
|
store=hugegraph
|
||||||
|
backend=hstore
|
||||||
|
serializer=binary
|
||||||
|
|
||||||
|
# pd config
|
||||||
|
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
# task config
|
||||||
|
task.scheduler_type=local
|
||||||
|
task.schedule_period=10
|
||||||
|
task.retry=0
|
||||||
|
task.wait_timeout=10
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8182
|
||||||
|
|
||||||
|
# timeout in ms of gremlin query
|
||||||
|
evaluationTimeout: 30000
|
||||||
|
|
||||||
|
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||||
|
# don't set graph at here, this happens after support for dynamically adding graph
|
||||||
|
graphs: {
|
||||||
|
}
|
||||||
|
scriptEngines: {
|
||||||
|
gremlin-groovy: {
|
||||||
|
staticImports: [
|
||||||
|
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||||
|
],
|
||||||
|
plugins: {
|
||||||
|
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||||
|
classImports: [
|
||||||
|
java.lang.Math,
|
||||||
|
org.apache.hugegraph.backend.id.IdGenerator,
|
||||||
|
org.apache.hugegraph.type.define.Directions,
|
||||||
|
org.apache.hugegraph.type.define.NodeRole,
|
||||||
|
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||||
|
org.apache.hugegraph.util.DateUtil,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||||
|
org.apache.hugegraph.traversal.optimize.Text,
|
||||||
|
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate
|
||||||
|
],
|
||||||
|
methodImports: [
|
||||||
|
java.lang.Math#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||||
|
]
|
||||||
|
},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||||
|
files: [scripts/empty-sample.groovy]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serializers:
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
metrics: {
|
||||||
|
consoleReporter: {enabled: false, interval: 180000},
|
||||||
|
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||||
|
jmxReporter: {enabled: false},
|
||||||
|
slf4jReporter: {enabled: false, interval: 180000},
|
||||||
|
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||||
|
graphiteReporter: {enabled: false, interval: 180000}
|
||||||
|
}
|
||||||
|
maxInitialLineLength: 4096
|
||||||
|
maxHeaderSize: 8192
|
||||||
|
maxChunkSize: 8192
|
||||||
|
maxContentLength: 65536
|
||||||
|
maxAccumulationBufferComponents: 1024
|
||||||
|
resultIterationBatchSize: 64
|
||||||
|
writeBufferLowWaterMark: 32768
|
||||||
|
writeBufferHighWaterMark: 65536
|
||||||
|
ssl: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!-- Config will be auto loaded every 60s -->
|
||||||
|
<configuration status="error" monitorInterval="60">
|
||||||
|
<properties>
|
||||||
|
<property name="LOG_PATH">logs</property>
|
||||||
|
<property name="FILE_NAME">hugegraph-server</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<appenders>
|
||||||
|
<Console name="console" target="SYSTEM_OUT">
|
||||||
|
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
<!-- Normal server log config -->
|
||||||
|
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
||||||
|
immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
|
<DefaultRolloverStrategy max="5">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.log"/>
|
||||||
|
<!-- Limit log amount & size -->
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
|
<!-- Separate & compress audit log, buffer size is 512KB -->
|
||||||
|
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
||||||
|
bufferSize="524288" immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<!-- Use simple format for audit log to speed up -->
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1hour or 500MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
||||||
|
<DefaultRolloverStrategy max="2">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.gz"/>
|
||||||
|
<IfLastModified age="60d"/>
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="5GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="500"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
|
<!-- Slow query log config -->
|
||||||
|
<RollingRandomAccessFile name="slowQueryLog" fileName="${LOG_PATH}/slow_query.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/slow_query_log-%d{yyyy-MM-dd}-%i.log"
|
||||||
|
immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
|
<DefaultRolloverStrategy max="5">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.log"/>
|
||||||
|
<!-- Limit log amount & size -->
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
</appenders>
|
||||||
|
|
||||||
|
<loggers>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</root>
|
||||||
|
<logger name="org.apache.cassandra" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.hadoop" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.zookeeper" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="com.datastax.driver" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="com.alipay.sofa" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="io.netty" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.commons" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<!-- Use mixed async way to output logs -->
|
||||||
|
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="audit"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="audit"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="slowQueryLog"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
</loggers>
|
||||||
|
</configuration>
|
||||||
|
|
@ -23,8 +23,8 @@ serializer: {
|
||||||
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||||
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||||
ioRegistries: [
|
ioRegistries: [
|
||||||
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||||
org.apache.hugegraph.io.HugeGraphIoRegistry
|
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
# bind url
|
||||||
|
restserver.url=http://127.0.0.1:8082
|
||||||
|
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||||
|
gremlinserver.url=http://127.0.0.1:8182
|
||||||
|
|
||||||
|
graphs=./conf/graphs
|
||||||
|
|
||||||
|
# configuration of arthas
|
||||||
|
arthas.telnet_port=8572
|
||||||
|
arthas.http_port=8571
|
||||||
|
arthas.ip=127.0.0.1
|
||||||
|
arthas.disabled_commands=jad
|
||||||
|
|
||||||
|
# authentication configs
|
||||||
|
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||||
|
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||||
|
#auth.authenticator=
|
||||||
|
|
||||||
|
# rpc server configs for multi graph-servers or raft-servers
|
||||||
|
rpc.server_host=127.0.0.1
|
||||||
|
rpc.server_port=8092
|
||||||
|
#rpc.server_timeout=30
|
||||||
|
|
||||||
|
# lightweight load balancing (beta)
|
||||||
|
server.id=server-2
|
||||||
|
server.role=worker
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||||
|
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||||
|
|
||||||
|
# cache config
|
||||||
|
vertex.cache_type=l2
|
||||||
|
edge.cache_type=l2
|
||||||
|
|
||||||
|
store=hugegraph
|
||||||
|
backend=hstore
|
||||||
|
serializer=binary
|
||||||
|
|
||||||
|
# pd config
|
||||||
|
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||||
|
|
||||||
|
# task config
|
||||||
|
task.scheduler_type=local
|
||||||
|
task.schedule_period=10
|
||||||
|
task.retry=0
|
||||||
|
task.wait_timeout=10
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8183
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: 8183
|
||||||
|
|
||||||
|
# timeout in ms of gremlin query
|
||||||
|
evaluationTimeout: 30000
|
||||||
|
|
||||||
|
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||||
|
# don't set graph at here, this happens after support for dynamically adding graph
|
||||||
|
graphs: {
|
||||||
|
}
|
||||||
|
scriptEngines: {
|
||||||
|
gremlin-groovy: {
|
||||||
|
staticImports: [
|
||||||
|
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||||
|
],
|
||||||
|
plugins: {
|
||||||
|
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||||
|
classImports: [
|
||||||
|
java.lang.Math,
|
||||||
|
org.apache.hugegraph.backend.id.IdGenerator,
|
||||||
|
org.apache.hugegraph.type.define.Directions,
|
||||||
|
org.apache.hugegraph.type.define.NodeRole,
|
||||||
|
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||||
|
org.apache.hugegraph.util.DateUtil,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||||
|
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||||
|
org.apache.hugegraph.traversal.optimize.Text,
|
||||||
|
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate
|
||||||
|
],
|
||||||
|
methodImports: [
|
||||||
|
java.lang.Math#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||||
|
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||||
|
]
|
||||||
|
},
|
||||||
|
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||||
|
files: [scripts/empty-sample.groovy]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
serializers:
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
metrics: {
|
||||||
|
consoleReporter: {enabled: false, interval: 180000},
|
||||||
|
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||||
|
jmxReporter: {enabled: false},
|
||||||
|
slf4jReporter: {enabled: false, interval: 180000},
|
||||||
|
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||||
|
graphiteReporter: {enabled: false, interval: 180000}
|
||||||
|
}
|
||||||
|
maxInitialLineLength: 4096
|
||||||
|
maxHeaderSize: 8192
|
||||||
|
maxChunkSize: 8192
|
||||||
|
maxContentLength: 65536
|
||||||
|
maxAccumulationBufferComponents: 1024
|
||||||
|
resultIterationBatchSize: 64
|
||||||
|
writeBufferLowWaterMark: 32768
|
||||||
|
writeBufferHighWaterMark: 65536
|
||||||
|
ssl: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
<?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.
|
||||||
|
-->
|
||||||
|
<!-- Config will be auto loaded every 60s -->
|
||||||
|
<configuration status="error" monitorInterval="60">
|
||||||
|
<properties>
|
||||||
|
<property name="LOG_PATH">logs</property>
|
||||||
|
<property name="FILE_NAME">hugegraph-server</property>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<appenders>
|
||||||
|
<Console name="console" target="SYSTEM_OUT">
|
||||||
|
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
</Console>
|
||||||
|
|
||||||
|
<!-- Normal server log config -->
|
||||||
|
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
||||||
|
immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
|
<DefaultRolloverStrategy max="5">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.log"/>
|
||||||
|
<!-- Limit log amount & size -->
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
|
<!-- Separate & compress audit log, buffer size is 512KB -->
|
||||||
|
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
||||||
|
bufferSize="524288" immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<!-- Use simple format for audit log to speed up -->
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1hour or 500MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
||||||
|
<DefaultRolloverStrategy max="2">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.gz"/>
|
||||||
|
<IfLastModified age="60d"/>
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="5GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="500"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
|
||||||
|
<!-- Slow query log config -->
|
||||||
|
<RollingRandomAccessFile name="slowQueryLog" fileName="${LOG_PATH}/slow_query.log"
|
||||||
|
filePattern="${LOG_PATH}/$${date:yyyy-MM}/slow_query_log-%d{yyyy-MM-dd}-%i.log"
|
||||||
|
immediateFlush="false">
|
||||||
|
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||||
|
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||||
|
<!-- Trigger after exceeding 1day or 50MB -->
|
||||||
|
<Policies>
|
||||||
|
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||||
|
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||||
|
</Policies>
|
||||||
|
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||||
|
<DefaultRolloverStrategy max="5">
|
||||||
|
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||||
|
<IfFileName glob="*/*.log"/>
|
||||||
|
<!-- Limit log amount & size -->
|
||||||
|
<IfAny>
|
||||||
|
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||||
|
<IfAccumulatedFileCount exceeds="100"/>
|
||||||
|
</IfAny>
|
||||||
|
</Delete>
|
||||||
|
</DefaultRolloverStrategy>
|
||||||
|
</RollingRandomAccessFile>
|
||||||
|
</appenders>
|
||||||
|
|
||||||
|
<loggers>
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</root>
|
||||||
|
<logger name="org.apache.cassandra" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.hadoop" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.zookeeper" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="com.datastax.driver" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="com.alipay.sofa" level="WARN" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="io.netty" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<logger name="org.apache.commons" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</logger>
|
||||||
|
<!-- Use mixed async way to output logs -->
|
||||||
|
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="file"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="audit"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="audit"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="slowQueryLog"/>
|
||||||
|
</AsyncLogger>
|
||||||
|
</loggers>
|
||||||
|
</configuration>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8183
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||||
|
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||||
|
ioRegistries: [
|
||||||
|
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||||
|
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
hosts: [localhost]
|
||||||
|
port: 8183
|
||||||
|
serializer: {
|
||||||
|
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||||
|
config: {
|
||||||
|
serializeResultToString: false,
|
||||||
|
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
# bind url
|
||||||
|
restserver.url=http://127.0.0.1:8083
|
||||||
|
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||||
|
gremlinserver.url=http://127.0.0.1:8183
|
||||||
|
|
||||||
|
graphs=./conf/graphs
|
||||||
|
|
||||||
|
# configuration of arthas
|
||||||
|
arthas.telnet_port=8582
|
||||||
|
arthas.http_port=8581
|
||||||
|
arthas.ip=127.0.0.1
|
||||||
|
arthas.disabled_commands=jad
|
||||||
|
|
||||||
|
# authentication configs
|
||||||
|
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||||
|
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||||
|
#auth.authenticator=
|
||||||
|
|
||||||
|
# rpc server configs for multi graph-servers or raft-servers
|
||||||
|
rpc.server_host=127.0.0.1
|
||||||
|
rpc.server_port=8093
|
||||||
|
|
||||||
|
# lightweight load balancing (beta)
|
||||||
|
server.id=server-3
|
||||||
|
server.role=worker
|
||||||
|
|
@ -0,0 +1,180 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
# TODO: reuse the configs for same type containers
|
||||||
|
# User could modify the node nums and the port by themselves
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
pd0:
|
||||||
|
image: hugegraph/pd
|
||||||
|
container_name: pd0
|
||||||
|
hostname: pd0
|
||||||
|
network_mode: host
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8620"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-pd0.yml:/hugegraph-pd/conf/application.yml
|
||||||
|
|
||||||
|
pd1:
|
||||||
|
image: hugegraph/pd
|
||||||
|
container_name: pd1
|
||||||
|
hostname: pd1
|
||||||
|
network_mode: host
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8621"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-pd1.yml:/hugegraph-pd/conf/application.yml
|
||||||
|
|
||||||
|
pd2:
|
||||||
|
image: hugegraph/pd
|
||||||
|
container_name: pd2
|
||||||
|
hostname: pd2
|
||||||
|
network_mode: host
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8622"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-pd2.yml:/hugegraph-pd/conf/application.yml
|
||||||
|
|
||||||
|
store0:
|
||||||
|
image: hugegraph/store
|
||||||
|
container_name: store0
|
||||||
|
hostname: store0
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
pd0:
|
||||||
|
condition: service_healthy
|
||||||
|
pd1:
|
||||||
|
condition: service_healthy
|
||||||
|
pd2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8520"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-store0.yml:/hugegraph-store/conf/application.yml
|
||||||
|
|
||||||
|
store1:
|
||||||
|
image: hugegraph/store
|
||||||
|
container_name: store1
|
||||||
|
hostname: store1
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
pd0:
|
||||||
|
condition: service_healthy
|
||||||
|
pd1:
|
||||||
|
condition: service_healthy
|
||||||
|
pd2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8521"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-store1.yml:/hugegraph-store/conf/application.yml
|
||||||
|
|
||||||
|
store2:
|
||||||
|
image: hugegraph/store
|
||||||
|
container_name: store2
|
||||||
|
hostname: store2
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
pd0:
|
||||||
|
condition: service_healthy
|
||||||
|
pd1:
|
||||||
|
condition: service_healthy
|
||||||
|
pd2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8522"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/application-store2.yml:/hugegraph-store/conf/application.yml
|
||||||
|
|
||||||
|
server1:
|
||||||
|
image: hugegraph/server
|
||||||
|
container_name: server1
|
||||||
|
hostname: server1
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
store0:
|
||||||
|
condition: service_healthy
|
||||||
|
store1:
|
||||||
|
condition: service_healthy
|
||||||
|
store2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8081"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/server1-conf:/hugegraph-server/conf
|
||||||
|
|
||||||
|
server2:
|
||||||
|
image: hugegraph/server
|
||||||
|
container_name: server2
|
||||||
|
hostname: server2
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
store0:
|
||||||
|
condition: service_healthy
|
||||||
|
store1:
|
||||||
|
condition: service_healthy
|
||||||
|
store2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8082"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/server2-conf:/hugegraph-server/conf
|
||||||
|
|
||||||
|
server3:
|
||||||
|
image: hugegraph/server
|
||||||
|
container_name: server3
|
||||||
|
hostname: server3
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
store0:
|
||||||
|
condition: service_healthy
|
||||||
|
store1:
|
||||||
|
condition: service_healthy
|
||||||
|
store2:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8083"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
volumes:
|
||||||
|
- ./configs/server3-conf:/hugegraph-server/conf
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
version: "3"
|
||||||
|
|
||||||
|
services:
|
||||||
|
pd:
|
||||||
|
image: hugegraph/pd
|
||||||
|
container_name: pd
|
||||||
|
hostname: pd
|
||||||
|
network_mode: host
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8620"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
store:
|
||||||
|
image: hugegraph/store
|
||||||
|
container_name: store
|
||||||
|
hostname: store
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
pd:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8520"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
||||||
|
server:
|
||||||
|
image: hugegraph/server
|
||||||
|
container_name: server
|
||||||
|
hostname: server
|
||||||
|
network_mode: host
|
||||||
|
depends_on:
|
||||||
|
store:
|
||||||
|
condition: service_healthy
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "curl", "-f", "http://localhost:8080"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 3
|
||||||
|
|
@ -1,76 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.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 org.apache.hugegraph.api.filter.CompressInterceptor;
|
|
||||||
import org.apache.hugegraph.rest.AbstractRestClient;
|
|
||||||
import org.apache.hugegraph.testutil.Whitebox;
|
|
||||||
import org.apache.hugegraph.util.E;
|
|
||||||
|
|
||||||
public class GremlinClient extends AbstractRestClient {
|
|
||||||
|
|
||||||
private final WebTarget webTarget;
|
|
||||||
|
|
||||||
public GremlinClient(String url, int timeout,
|
|
||||||
int maxTotal, int maxPerRoute) {
|
|
||||||
super(url, timeout, maxTotal, maxPerRoute);
|
|
||||||
this.webTarget = Whitebox.getInternalState(this, "target");
|
|
||||||
E.checkNotNull(this.webTarget, "target");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void checkStatus(Response response, Response.Status... statuses) {
|
|
||||||
// pass
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response doPostRequest(String auth, String req) {
|
|
||||||
Entity<?> body = Entity.entity(req, MediaType.APPLICATION_JSON);
|
|
||||||
return this.webTarget.request()
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, auth)
|
|
||||||
.accept(MediaType.APPLICATION_JSON)
|
|
||||||
.acceptEncoding(CompressInterceptor.GZIP)
|
|
||||||
.post(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Response doGetRequest(String auth,
|
|
||||||
MultivaluedMap<String, String> params) {
|
|
||||||
WebTarget target = this.webTarget;
|
|
||||||
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
|
|
||||||
E.checkArgument(entry.getValue().size() == 1,
|
|
||||||
"Invalid query param '%s', can only accept " +
|
|
||||||
"one value, but got %s",
|
|
||||||
entry.getKey(), entry.getValue());
|
|
||||||
target = target.queryParam(entry.getKey(), entry.getValue().get(0));
|
|
||||||
}
|
|
||||||
return target.request()
|
|
||||||
.header(HttpHeaders.AUTHORIZATION, auth)
|
|
||||||
.accept(MediaType.APPLICATION_JSON)
|
|
||||||
.acceptEncoding(CompressInterceptor.GZIP)
|
|
||||||
.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,161 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.api.metrics;
|
|
||||||
|
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
|
||||||
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 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.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);
|
|
||||||
|
|
||||||
private SystemMetrics systemMetrics;
|
|
||||||
|
|
||||||
static {
|
|
||||||
JsonUtil.registerModule(new MetricsModule(SECONDS, MILLISECONDS, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public MetricsAPI() {
|
|
||||||
this.systemMetrics = new SystemMetrics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("system")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String system() {
|
|
||||||
return JsonUtil.toJson(this.systemMetrics.metrics());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("backend")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String backend(@Context GraphManager manager) {
|
|
||||||
Map<String, Map<String, Object>> results = InsertionOrderUtil.newMap();
|
|
||||||
for (String graph : manager.graphs()) {
|
|
||||||
HugeGraph g = manager.graph(graph);
|
|
||||||
Map<String, Object> metrics = InsertionOrderUtil.newMap();
|
|
||||||
metrics.put(BackendMetrics.BACKEND, g.backend());
|
|
||||||
try {
|
|
||||||
metrics.putAll(g.metadata(null, "metrics"));
|
|
||||||
} catch (Throwable e) {
|
|
||||||
metrics.put(BackendMetrics.EXCEPTION, e.toString());
|
|
||||||
LOG.debug("Failed to get backend metrics", e);
|
|
||||||
}
|
|
||||||
results.put(graph, metrics);
|
|
||||||
}
|
|
||||||
return JsonUtil.toJson(results);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String all() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
Map<String, Map<String, ? extends Metric>> result = new LinkedHashMap<>();
|
|
||||||
result.put("gauges", reporter.gauges());
|
|
||||||
result.put("counters", reporter.counters());
|
|
||||||
result.put("histograms", reporter.histograms());
|
|
||||||
result.put("meters", reporter.meters());
|
|
||||||
result.put("timers", reporter.timers());
|
|
||||||
return JsonUtil.toJson(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("gauges")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String gauges() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
return JsonUtil.toJson(reporter.gauges());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("counters")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String counters() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
return JsonUtil.toJson(reporter.counters());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("histograms")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String histograms() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
return JsonUtil.toJson(reporter.histograms());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("meters")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String meters() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
return JsonUtil.toJson(reporter.meters());
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Path("timers")
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
|
||||||
public String timers() {
|
|
||||||
ServerReporter reporter = ServerReporter.instance();
|
|
||||||
return JsonUtil.toJson(reporter.timers());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.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 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 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.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);
|
|
||||||
|
|
||||||
@GET
|
|
||||||
@Timed
|
|
||||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
|
||||||
public String get(@Context GraphManager manager,
|
|
||||||
@PathParam("graph") String graph,
|
|
||||||
@QueryParam("vertex") String vertex,
|
|
||||||
@QueryParam("other") String other,
|
|
||||||
@QueryParam("direction") String direction,
|
|
||||||
@QueryParam("label") String edgeLabel,
|
|
||||||
@QueryParam("max_degree")
|
|
||||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
|
||||||
@QueryParam("limit")
|
|
||||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) int limit) {
|
|
||||||
LOG.debug("Graph [{}] get same neighbors between '{}' and '{}' with " +
|
|
||||||
"direction {}, edge label {}, max degree '{}' and limit '{}'",
|
|
||||||
graph, vertex, other, direction, edgeLabel, maxDegree, limit);
|
|
||||||
|
|
||||||
Id sourceId = VertexAPI.checkAndParseVertexId(vertex);
|
|
||||||
Id targetId = VertexAPI.checkAndParseVertexId(other);
|
|
||||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
|
||||||
|
|
||||||
HugeGraph g = graph(manager, graph);
|
|
||||||
SameNeighborTraverser traverser = new SameNeighborTraverser(g);
|
|
||||||
Set<Id> neighbors = traverser.sameNeighbors(sourceId, targetId, dir,
|
|
||||||
edgeLabel, maxDegree, limit);
|
|
||||||
return manager.serializer(g).writeList("same_neighbors", neighbors);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,61 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.api.traversers;
|
|
||||||
|
|
||||||
import static org.apache.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.fasterxml.jackson.annotation.JsonAlias;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
|
|
||||||
public class TraverserAPI extends API {
|
|
||||||
|
|
||||||
protected static EdgeStep step(HugeGraph graph, Step step) {
|
|
||||||
return new EdgeStep(graph, step.direction, step.labels, step.properties,
|
|
||||||
step.maxDegree, step.skipDegree);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static class Step {
|
|
||||||
|
|
||||||
@JsonProperty("direction")
|
|
||||||
public Directions direction;
|
|
||||||
@JsonProperty("labels")
|
|
||||||
public List<String> labels;
|
|
||||||
@JsonProperty("properties")
|
|
||||||
public Map<String, Object> properties;
|
|
||||||
@JsonAlias("degree")
|
|
||||||
@JsonProperty("max_degree")
|
|
||||||
public long maxDegree = Long.parseLong(DEFAULT_MAX_DEGREE);
|
|
||||||
@JsonProperty("skip_degree")
|
|
||||||
public long skipDegree = 0L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return String.format("Step{direction=%s,labels=%s,properties=%s," +
|
|
||||||
"maxDegree=%s,skipDegree=%s}",
|
|
||||||
this.direction, this.labels, this.properties,
|
|
||||||
this.maxDegree, this.skipDegree);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,333 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.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.configuration2.Configuration;
|
|
||||||
import org.apache.hugegraph.HugeException;
|
|
||||||
import org.apache.hugegraph.HugeFactory;
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.StandardHugeGraph;
|
|
||||||
import org.apache.hugegraph.backend.cache.CacheManager;
|
|
||||||
import org.apache.hugegraph.backend.tx.AbstractTransaction;
|
|
||||||
import org.apache.hugegraph.backend.tx.GraphTransaction;
|
|
||||||
import org.apache.hugegraph.backend.tx.IndexableTransaction;
|
|
||||||
import org.apache.hugegraph.concurrent.LockManager;
|
|
||||||
import org.apache.hugegraph.metrics.ServerReporter;
|
|
||||||
import org.apache.hugegraph.schema.SchemaElement;
|
|
||||||
import org.apache.hugegraph.schema.SchemaManager;
|
|
||||||
import org.apache.hugegraph.schema.builder.AbstractBuilder;
|
|
||||||
import org.apache.hugegraph.schema.builder.EdgeLabelBuilder;
|
|
||||||
import org.apache.hugegraph.schema.builder.IndexLabelBuilder;
|
|
||||||
import org.apache.hugegraph.schema.builder.PropertyKeyBuilder;
|
|
||||||
import org.apache.hugegraph.schema.builder.VertexLabelBuilder;
|
|
||||||
import org.apache.hugegraph.serializer.JsonSerializer;
|
|
||||||
import org.apache.hugegraph.structure.HugeEdge;
|
|
||||||
import org.apache.hugegraph.structure.HugeElement;
|
|
||||||
import org.apache.hugegraph.structure.HugeProperty;
|
|
||||||
import org.apache.hugegraph.structure.HugeVertex;
|
|
||||||
import org.apache.hugegraph.task.HugeTask;
|
|
||||||
import org.apache.hugegraph.task.StandardTaskScheduler;
|
|
||||||
import org.apache.hugegraph.task.TaskCallable;
|
|
||||||
import org.apache.hugegraph.task.TaskCallable.SysTaskCallable;
|
|
||||||
import org.apache.hugegraph.task.TaskManager;
|
|
||||||
import org.apache.hugegraph.traversal.optimize.HugeCountStepStrategy;
|
|
||||||
import org.apache.hugegraph.traversal.optimize.HugeGraphStepStrategy;
|
|
||||||
import org.apache.hugegraph.traversal.optimize.HugeVertexStepStrategy;
|
|
||||||
import org.apache.hugegraph.util.Reflection;
|
|
||||||
import org.apache.hugegraph.variables.HugeVariables;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
|
|
||||||
public final class HugeFactoryAuthProxy {
|
|
||||||
|
|
||||||
public static final String GRAPH_FACTORY =
|
|
||||||
"gremlin.graph=org.apache.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", "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(StandardAuthenticator.class, "graph");
|
|
||||||
Reflection.registerMethodsToFilter(StandardAuthenticator.class, "initAdminUser", "inputPassword", "graph");
|
|
||||||
Reflection.registerFieldsToFilter(ConfigAuthenticator.class, "tokens");
|
|
||||||
Reflection.registerFieldsToFilter(HugeFactoryAuthProxy.class, "PROTECT_METHODS");
|
|
||||||
Reflection.registerMethodsToFilter(HugeFactoryAuthProxy.class, "genRegisterPrivateActions", "registerClass", "registerPrivateActions", "registerPrivateActions", "c");
|
|
||||||
Reflection.registerFieldsToFilter(HugeAuthenticator.User.class, "role", "client");
|
|
||||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser.class, "name");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.class, "LOG", "hugegraph", "taskScheduler", "authManager", "contexts", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(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(HugeGraphAuthProxy.AuthManagerProxy.class, "authManager", "this$0");
|
|
||||||
Reflection.registerMethodsToFilter(HugeGraphAuthProxy.AuthManagerProxy.class, "currentUsername", "updateCreator");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.TaskSchedulerProxy.class, "taskScheduler", "this$0");
|
|
||||||
Reflection.registerMethodsToFilter(HugeGraphAuthProxy.TaskSchedulerProxy.class, "lambda$0", "lambda$1", "lambda$2", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "hasTaskPermission");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.GraphTraversalSourceProxy.class, "this$0");
|
|
||||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.class, "connection", "graph", "strategies", "bytecode");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.TraversalStrategiesProxy.class, "REST_WOEKER", "serialVersionUID", "strategies", "this$0");
|
|
||||||
Reflection.registerMethodsToFilter(HugeGraphAuthProxy.TraversalStrategiesProxy.class, "translate");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.VariablesProxy.class, "variables", "this$0");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.Context.class, "ADMIN", "user");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphAuthProxy.ContextTask.class, "runner", "context");
|
|
||||||
Reflection.registerFieldsToFilter(StandardHugeGraph.class, "LOG", "started", "closed", "mode", "variables", "name", "params", "configuration", "schemaEventHub", "graphEventHub", "indexEventHub", "writeRateLimiter", "readRateLimiter", "taskManager", "authManager", "features", "storeProvider", "tx", "ramtable", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(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(loadClass("org.apache.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "graph", "this$0");
|
|
||||||
Reflection.registerMethodsToFilter(loadClass("org.apache.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "access$1", "graph");
|
|
||||||
Reflection.registerFieldsToFilter(loadClass("org.apache.hugegraph.StandardHugeGraph$TinkerPopTransaction"), "refs", "opened", "transactions", "this$0", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(loadClass("org.apache.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(loadClass("org.apache.hugegraph.StandardHugeGraph$Txs"), "schemaTx", "systemTx", "graphTx", "openedTime", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(loadClass("org.apache.hugegraph.StandardHugeGraph$Txs"), "access$2", "access$1", "access$0");
|
|
||||||
Reflection.registerFieldsToFilter(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(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(IndexableTransaction.class, "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(IndexableTransaction.class, "indexTransaction", "commit2Backend", "reset");
|
|
||||||
Reflection.registerFieldsToFilter(AbstractTransaction.class, "LOG", "ownerThread", "autoCommit", "closed", "committing", "committing2Backend", "graph", "store", "mutation", "serializer", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(AbstractTransaction.class, "beforeWrite", "prepareCommit", "params", "mutation", "commit2Backend", "autoCommit", "beforeRead", "afterWrite", "afterRead", "commitMutation2Backend", "checkOwnerThread", "doAction", "store", "reset");
|
|
||||||
Reflection.registerFieldsToFilter(HugeFactory.class, "LOG", "NAME_REGEX", "graphs");
|
|
||||||
Reflection.registerMethodsToFilter(HugeFactory.class, "lambda$0");
|
|
||||||
Reflection.registerFieldsToFilter(SchemaElement.class, "graph", "id", "name", "userdata", "status");
|
|
||||||
Reflection.registerFieldsToFilter(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(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(HugeElement.class, "EMPTY_MAP", "MAX_PROPERTIES", "graph", "properties", "expiredTime", "removed", "fresh", "propLoaded", "defaultValueUpdated", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality");
|
|
||||||
Reflection.registerMethodsToFilter(HugeElement.class, "removed", "addProperty", "newProperty", "tx", "onUpdateProperty", "ensureFilledProperties", "propLoaded", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality", "getIdValue", "fresh", "updateToDefaultValueIfNone", "copyProperties");
|
|
||||||
Reflection.registerFieldsToFilter(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(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(HugeProperty.class, "owner", "pkey", "value");
|
|
||||||
Reflection.registerFieldsToFilter(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(HugeVariables.class, "createPropertyKey", "queryAllVariableVertices", "queryVariableVertex", "createVariableVertex", "removeVariableVertex", "extractSingleObject", "setProperty");
|
|
||||||
Reflection.registerFieldsToFilter(SchemaManager.class, "transaction", "graph");
|
|
||||||
Reflection.registerMethodsToFilter(SchemaManager.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "checkExists");
|
|
||||||
Reflection.registerFieldsToFilter(PropertyKeyBuilder.class, "id", "name", "dataType", "cardinality", "aggregateType", "checkExist", "userdata", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(PropertyKeyBuilder.class, "lambda$0", "checkStableVars", "checkAggregateType", "hasSameProperties");
|
|
||||||
Reflection.registerFieldsToFilter(AbstractBuilder.class, "transaction", "graph");
|
|
||||||
Reflection.registerMethodsToFilter(AbstractBuilder.class, "rebuildIndex", "graph", "checkSchemaName", "validOrGenerateId", "lockCheckAndCreateSchema", "propertyKeyOrNull", "checkSchemaIdIfRestoringMode", "vertexLabelOrNull", "edgeLabelOrNull", "indexLabelOrNull", "updateSchemaStatus");
|
|
||||||
Reflection.registerFieldsToFilter(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(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(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(EdgeLabelBuilder.class, "lambda$0", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "checkProperties", "checkNullableKeys", "checkSortKeys", "checkRelation", "hasSameProperties", "checkTtl", "checkUserdata", "mapPkId2Name", "mapPkId2Name");
|
|
||||||
Reflection.registerFieldsToFilter(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(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(TaskManager.class, "LOG", "SCHEDULE_PERIOD", "THREADS", "MANAGER", "schedulers", "taskExecutor", "taskDbExecutor", "serverInfoDbExecutor", "schedulerExecutor", "contexts", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(TaskManager.class, "lambda$0", "resetContext", "closeTaskTx", "setContext", "instance", "closeSchedulerTx", "notifyNewTask", "scheduleOrExecuteJob", "scheduleOrExecuteJobForGraph");
|
|
||||||
Reflection.registerFieldsToFilter(StandardTaskScheduler.class, "LOG", "graph", "serverManager", "taskExecutor", "taskDbExecutor", "eventListener", "tasks", "taskTx", "NO_LIMIT", "PAGE_SIZE", "QUERY_INTERVAL", "MAX_PENDING_TASKS", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(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(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(HugeTask.class, "property", "scheduler", "scheduler", "asArray", "checkPropertySize", "checkPropertySize", "checkDependenciesSuccess", "toOrderSet", "done", "callable", "setException", "set", "result", "status");
|
|
||||||
Reflection.registerFieldsToFilter(TaskCallable.class, "LOG", "ERROR_COMMIT", "ERROR_MESSAGES", "task", "graph", "lastSaveTime", "saveInterval");
|
|
||||||
Reflection.registerMethodsToFilter(TaskCallable.class, "graph", "closeTx", "cancelled", "done", "task", "save", "needSaveWithEx");
|
|
||||||
Reflection.registerFieldsToFilter(TaskCallable.SysTaskCallable.class, "params");
|
|
||||||
Reflection.registerMethodsToFilter(TaskCallable.SysTaskCallable.class, "params", "params");
|
|
||||||
Reflection.registerFieldsToFilter(StandardAuthManager.class, "CACHE_EXPIRE", "graph", "eventListener", "usersCache", "users", "groups", "targets", "belong", "access", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(StandardAuthManager.class, "lambda$0", "listenChanges", "unlistenChanges", "invalidCache", "initSchemaIfNeeded", "rolePermission", "rolePermission", "rolePermission", "cache");
|
|
||||||
Reflection.registerFieldsToFilter(SchemaDefine.class, "graph", "label");
|
|
||||||
Reflection.registerMethodsToFilter(SchemaDefine.class, "schema", "createPropertyKey", "createPropertyKey", "createPropertyKey", "existEdgeLabel", "createRangeIndex", "unhideField", "hideField", "existVertexLabel", "initProperties");
|
|
||||||
Reflection.registerFieldsToFilter(EntityManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(EntityManager.class, "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryEntity", "constructVertex", "save", "query");
|
|
||||||
Reflection.registerFieldsToFilter(RelationshipManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
|
||||||
Reflection.registerMethodsToFilter(RelationshipManager.class, "lambda$0", "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryRelationship", "newVertex", "save");
|
|
||||||
Reflection.registerFieldsToFilter(CacheManager.class, "LOG", "INSTANCE", "TIMER_TICK_PERIOD", "LOG_TICK_COST_TIME", "caches", "timer");
|
|
||||||
Reflection.registerMethodsToFilter(CacheManager.class, "access$0", "scheduleTimer", "instance");
|
|
||||||
Reflection.registerFieldsToFilter(org.apache.hugegraph.concurrent.LockManager.class, "INSTANCE", "lockGroupMap");
|
|
||||||
Reflection.registerMethodsToFilter(org.apache.hugegraph.concurrent.LockManager.class, "instance");
|
|
||||||
Reflection.registerFieldsToFilter(ServerReporter.class, "instance", "gauges", "counters", "histograms", "meters", "timers");
|
|
||||||
Reflection.registerMethodsToFilter(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(JsonSerializer.class, "LBUF_SIZE", "INSTANCE");
|
|
||||||
Reflection.registerMethodsToFilter(JsonSerializer.class, "writeIterator", "instance");
|
|
||||||
Reflection.registerFieldsToFilter(HugeVertexStepStrategy.class, "serialVersionUID", "INSTANCE");
|
|
||||||
Reflection.registerMethodsToFilter(HugeVertexStepStrategy.class, "instance");
|
|
||||||
Reflection.registerFieldsToFilter(HugeGraphStepStrategy.class, "serialVersionUID", "INSTANCE");
|
|
||||||
Reflection.registerMethodsToFilter(HugeGraphStepStrategy.class, "instance");
|
|
||||||
Reflection.registerFieldsToFilter(HugeCountStepStrategy.class, "serialVersionUID", "INSTANCE");
|
|
||||||
Reflection.registerMethodsToFilter(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(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()) {
|
|
||||||
// CHECKSTYLE:OFF
|
|
||||||
System.out.println(code);
|
|
||||||
// CHECKSTYLE:ON
|
|
||||||
}
|
|
||||||
|
|
||||||
code = String.format("Reflection.registerMethodsToFilter(%s.class, \"%s\");",
|
|
||||||
clazz.getCanonicalName(), String.join("\", \"", methods));
|
|
||||||
if (!methods.isEmpty()) {
|
|
||||||
// CHECKSTYLE:OFF
|
|
||||||
System.out.println(code);
|
|
||||||
// CHECKSTYLE:ON
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Class<?> loadClass(String clazz) {
|
|
||||||
try {
|
|
||||||
return Class.forName(clazz);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
throw new HugeException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.metrics;
|
|
||||||
|
|
||||||
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
|
|
||||||
|
|
||||||
import com.codahale.metrics.Counter;
|
|
||||||
import com.codahale.metrics.Gauge;
|
|
||||||
import com.codahale.metrics.Histogram;
|
|
||||||
import com.codahale.metrics.Meter;
|
|
||||||
import com.codahale.metrics.MetricRegistry;
|
|
||||||
import com.codahale.metrics.Timer;
|
|
||||||
|
|
||||||
public class MetricsUtil {
|
|
||||||
|
|
||||||
private static final MetricRegistry REGISTRY =
|
|
||||||
MetricManager.INSTANCE.getRegistry();
|
|
||||||
|
|
||||||
public static <T> Gauge<T> registerGauge(Class<?> clazz, String name,
|
|
||||||
Gauge<T> gauge) {
|
|
||||||
return REGISTRY.register(MetricRegistry.name(clazz, name), gauge);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Counter registerCounter(Class<?> clazz, String name) {
|
|
||||||
return REGISTRY.counter(MetricRegistry.name(clazz, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Histogram registerHistogram(Class<?> clazz, String name) {
|
|
||||||
return REGISTRY.histogram(MetricRegistry.name(clazz, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Meter registerMeter(Class<?> clazz, String name) {
|
|
||||||
return REGISTRY.meter(MetricRegistry.name(clazz, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Timer registerTimer(Class<?> clazz, String name) {
|
|
||||||
return REGISTRY.timer(MetricRegistry.name(clazz, name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.analyzer;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface Analyzer {
|
|
||||||
|
|
||||||
Set<String> segment(String text);
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.auth;
|
|
||||||
|
|
||||||
public interface AuthConstant {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fields in token
|
|
||||||
*/
|
|
||||||
String TOKEN_USER_NAME = "user_name";
|
|
||||||
String TOKEN_USER_ID = "user_id";
|
|
||||||
}
|
|
||||||
|
|
@ -1,36 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.backend.cache;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.type.HugeType;
|
|
||||||
|
|
||||||
public interface CacheNotifier extends AutoCloseable {
|
|
||||||
|
|
||||||
void invalid(HugeType type, Id id);
|
|
||||||
|
|
||||||
void invalid2(HugeType type, Object[] ids);
|
|
||||||
|
|
||||||
void clear(HugeType type);
|
|
||||||
|
|
||||||
void reload();
|
|
||||||
|
|
||||||
interface GraphCacheNotifier extends CacheNotifier {}
|
|
||||||
|
|
||||||
interface SchemaCacheNotifier extends CacheNotifier {}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.backend.store;
|
|
||||||
|
|
||||||
public interface MetaHandler<Session extends BackendSession> {
|
|
||||||
|
|
||||||
Object handle(Session session, String meta, Object... args);
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.job;
|
|
||||||
|
|
||||||
public interface Job<V> {
|
|
||||||
|
|
||||||
String type();
|
|
||||||
|
|
||||||
V execute() throws Exception;
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.masterelection;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public interface ClusterRoleStore {
|
|
||||||
|
|
||||||
boolean updateIfNodePresent(ClusterRole clusterRole);
|
|
||||||
|
|
||||||
Optional<ClusterRole> query();
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.masterelection;
|
|
||||||
|
|
||||||
public class GlobalMasterInfo {
|
|
||||||
|
|
||||||
private NodeInfo nodeInfo;
|
|
||||||
private volatile boolean featureSupport;
|
|
||||||
|
|
||||||
public GlobalMasterInfo() {
|
|
||||||
this.featureSupport = false;
|
|
||||||
this.nodeInfo = new NodeInfo(false, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void nodeInfo(boolean isMaster, String url) {
|
|
||||||
// final can avoid instruction rearrangement, visibility can be ignored
|
|
||||||
final NodeInfo tmp = new NodeInfo(isMaster, url);
|
|
||||||
this.nodeInfo = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final NodeInfo nodeInfo() {
|
|
||||||
return this.nodeInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void isFeatureSupport(boolean featureSupport) {
|
|
||||||
this.featureSupport = featureSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFeatureSupport() {
|
|
||||||
return this.featureSupport;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class NodeInfo {
|
|
||||||
|
|
||||||
private final boolean isMaster;
|
|
||||||
private final String url;
|
|
||||||
|
|
||||||
public NodeInfo(boolean isMaster, String url) {
|
|
||||||
this.isMaster = isMaster;
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMaster() {
|
|
||||||
return this.isMaster;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String url() {
|
|
||||||
return this.url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.masterelection;
|
|
||||||
|
|
||||||
public interface RoleElectionStateMachine {
|
|
||||||
|
|
||||||
void shutdown();
|
|
||||||
|
|
||||||
void apply(StateMachineCallback stateMachineCallback);
|
|
||||||
}
|
|
||||||
|
|
@ -1,167 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.schema;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.schema.builder.SchemaBuilder;
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.type.HugeType;
|
|
||||||
import org.apache.hugegraph.type.define.Frequency;
|
|
||||||
import org.apache.hugegraph.util.E;
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
|
|
||||||
public class EdgeLabel extends SchemaLabel {
|
|
||||||
|
|
||||||
public static final EdgeLabel NONE = new EdgeLabel(null, NONE_ID, UNDEF);
|
|
||||||
|
|
||||||
private Id sourceLabel = NONE_ID;
|
|
||||||
private Id targetLabel = NONE_ID;
|
|
||||||
private Frequency frequency;
|
|
||||||
private List<Id> sortKeys;
|
|
||||||
|
|
||||||
public EdgeLabel(final HugeGraph graph, Id id, String name) {
|
|
||||||
super(graph, id, name);
|
|
||||||
this.frequency = Frequency.DEFAULT;
|
|
||||||
this.sortKeys = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HugeType type() {
|
|
||||||
return HugeType.EDGE_LABEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Frequency frequency() {
|
|
||||||
return this.frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void frequency(Frequency frequency) {
|
|
||||||
this.frequency = frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean directed() {
|
|
||||||
// TODO: implement (do we need this method?)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String sourceLabelName() {
|
|
||||||
return this.graph.vertexLabelOrNone(this.sourceLabel).name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Id sourceLabel() {
|
|
||||||
return this.sourceLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sourceLabel(Id id) {
|
|
||||||
E.checkArgument(this.sourceLabel == NONE_ID,
|
|
||||||
"Not allowed to set source label multi times " +
|
|
||||||
"of edge label '%s'", this.name());
|
|
||||||
this.sourceLabel = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String targetLabelName() {
|
|
||||||
return this.graph.vertexLabelOrNone(this.targetLabel).name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Id targetLabel() {
|
|
||||||
return this.targetLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void targetLabel(Id id) {
|
|
||||||
E.checkArgument(this.targetLabel == NONE_ID,
|
|
||||||
"Not allowed to set target label multi times " +
|
|
||||||
"of edge label '%s'", this.name());
|
|
||||||
this.targetLabel = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean linkWithLabel(Id id) {
|
|
||||||
return this.sourceLabel.equals(id) || this.targetLabel.equals(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkLinkEqual(Id sourceLabel, Id targetLabel) {
|
|
||||||
return this.sourceLabel.equals(sourceLabel) &&
|
|
||||||
this.targetLabel.equals(targetLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean existSortKeys() {
|
|
||||||
return this.sortKeys.size() > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Id> sortKeys() {
|
|
||||||
return Collections.unmodifiableList(this.sortKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sortKey(Id id) {
|
|
||||||
this.sortKeys.add(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sortKeys(Id... ids) {
|
|
||||||
this.sortKeys.addAll(Arrays.asList(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSameContent(EdgeLabel other) {
|
|
||||||
return super.hasSameContent(other) &&
|
|
||||||
this.frequency == other.frequency &&
|
|
||||||
Objects.equal(this.sourceLabelName(), other.sourceLabelName()) &&
|
|
||||||
Objects.equal(this.targetLabelName(), other.targetLabelName()) &&
|
|
||||||
Objects.equal(this.graph.mapPkId2Name(this.sortKeys),
|
|
||||||
other.graph.mapPkId2Name(other.sortKeys));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static EdgeLabel undefined(HugeGraph graph, Id id) {
|
|
||||||
return new EdgeLabel(graph, id, UNDEF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Builder extends SchemaBuilder<EdgeLabel> {
|
|
||||||
|
|
||||||
Id rebuildIndex();
|
|
||||||
|
|
||||||
Builder link(String sourceLabel, String targetLabel);
|
|
||||||
|
|
||||||
Builder sourceLabel(String label);
|
|
||||||
|
|
||||||
Builder targetLabel(String label);
|
|
||||||
|
|
||||||
Builder singleTime();
|
|
||||||
|
|
||||||
Builder multiTimes();
|
|
||||||
|
|
||||||
Builder sortKeys(String... keys);
|
|
||||||
|
|
||||||
Builder properties(String... properties);
|
|
||||||
|
|
||||||
Builder nullableKeys(String... keys);
|
|
||||||
|
|
||||||
Builder frequency(Frequency frequency);
|
|
||||||
|
|
||||||
Builder ttl(long ttl);
|
|
||||||
|
|
||||||
Builder ttlStartTime(String ttlStartTime);
|
|
||||||
|
|
||||||
Builder enableLabelIndex(boolean enable);
|
|
||||||
|
|
||||||
Builder userdata(String key, Object value);
|
|
||||||
|
|
||||||
Builder userdata(Map<String, Object> userdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,135 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.schema;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.backend.id.IdGenerator;
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.schema.builder.SchemaBuilder;
|
|
||||||
import org.apache.hugegraph.type.HugeType;
|
|
||||||
import org.apache.hugegraph.type.define.IdStrategy;
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
|
|
||||||
public class VertexLabel extends SchemaLabel {
|
|
||||||
|
|
||||||
public static final VertexLabel NONE = new VertexLabel(null, NONE_ID, UNDEF);
|
|
||||||
|
|
||||||
// OLAP_VL_ID means all of vertex label ids
|
|
||||||
private static final Id OLAP_VL_ID = IdGenerator.of(SchemaLabel.OLAP_VL_ID);
|
|
||||||
// OLAP_VL_NAME means all of vertex label names
|
|
||||||
private static final String OLAP_VL_NAME = "*olap";
|
|
||||||
// OLAP_VL means all of vertex labels
|
|
||||||
public static final VertexLabel OLAP_VL = new VertexLabel(null, OLAP_VL_ID,
|
|
||||||
OLAP_VL_NAME);
|
|
||||||
|
|
||||||
private IdStrategy idStrategy;
|
|
||||||
private List<Id> primaryKeys;
|
|
||||||
|
|
||||||
public VertexLabel(final HugeGraph graph, Id id, String name) {
|
|
||||||
super(graph, id, name);
|
|
||||||
this.idStrategy = IdStrategy.DEFAULT;
|
|
||||||
this.primaryKeys = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HugeType type() {
|
|
||||||
return HugeType.VERTEX_LABEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean olap() {
|
|
||||||
return VertexLabel.OLAP_VL.id().equals(this.id());
|
|
||||||
}
|
|
||||||
|
|
||||||
public IdStrategy idStrategy() {
|
|
||||||
return this.idStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void idStrategy(IdStrategy idStrategy) {
|
|
||||||
this.idStrategy = idStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Id> primaryKeys() {
|
|
||||||
return Collections.unmodifiableList(this.primaryKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void primaryKey(Id id) {
|
|
||||||
this.primaryKeys.add(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void primaryKeys(Id... ids) {
|
|
||||||
this.primaryKeys.addAll(Arrays.asList(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean existsLinkLabel() {
|
|
||||||
return this.graph().existsLinkLabel(this.id());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSameContent(VertexLabel other) {
|
|
||||||
return super.hasSameContent(other) &&
|
|
||||||
this.idStrategy == other.idStrategy &&
|
|
||||||
Objects.equal(this.graph.mapPkId2Name(this.primaryKeys),
|
|
||||||
other.graph.mapPkId2Name(other.primaryKeys));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VertexLabel undefined(HugeGraph graph) {
|
|
||||||
return new VertexLabel(graph, NONE_ID, UNDEF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static VertexLabel undefined(HugeGraph graph, Id id) {
|
|
||||||
return new VertexLabel(graph, id, UNDEF);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface Builder extends SchemaBuilder<VertexLabel> {
|
|
||||||
|
|
||||||
Id rebuildIndex();
|
|
||||||
|
|
||||||
Builder idStrategy(IdStrategy idStrategy);
|
|
||||||
|
|
||||||
Builder useAutomaticId();
|
|
||||||
|
|
||||||
Builder usePrimaryKeyId();
|
|
||||||
|
|
||||||
Builder useCustomizeStringId();
|
|
||||||
|
|
||||||
Builder useCustomizeNumberId();
|
|
||||||
|
|
||||||
Builder useCustomizeUuidId();
|
|
||||||
|
|
||||||
Builder properties(String... properties);
|
|
||||||
|
|
||||||
Builder primaryKeys(String... keys);
|
|
||||||
|
|
||||||
Builder nullableKeys(String... keys);
|
|
||||||
|
|
||||||
Builder ttl(long ttl);
|
|
||||||
|
|
||||||
Builder ttlStartTime(String ttlStartTime);
|
|
||||||
|
|
||||||
Builder enableLabelIndex(boolean enable);
|
|
||||||
|
|
||||||
Builder userdata(String key, Object value);
|
|
||||||
|
|
||||||
Builder userdata(Map<String, Object> userdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.structure;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.type.Nameable;
|
|
||||||
import org.apache.hugegraph.type.Typeable;
|
|
||||||
|
|
||||||
public interface GraphType extends Nameable, Typeable {
|
|
||||||
}
|
|
||||||
|
|
@ -1,147 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.traversal.algorithm;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.HugeException;
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
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.tinkerpop.gremlin.structure.Edge;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.structure.HugeEdge;
|
|
||||||
import org.apache.hugegraph.util.E;
|
|
||||||
|
|
||||||
public class KoutTraverser extends OltpTraverser {
|
|
||||||
|
|
||||||
public KoutTraverser(HugeGraph graph) {
|
|
||||||
super(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Id> kout(Id sourceV, Directions dir, String label,
|
|
||||||
int depth, boolean nearest,
|
|
||||||
long degree, long capacity, long limit) {
|
|
||||||
E.checkNotNull(sourceV, "source vertex id");
|
|
||||||
this.checkVertexExist(sourceV, "source vertex");
|
|
||||||
E.checkNotNull(dir, "direction");
|
|
||||||
checkPositive(depth, "k-out max_depth");
|
|
||||||
checkDegree(degree);
|
|
||||||
checkCapacity(capacity);
|
|
||||||
checkLimit(limit);
|
|
||||||
if (capacity != NO_LIMIT) {
|
|
||||||
// Capacity must > limit because sourceV is counted in capacity
|
|
||||||
E.checkArgument(capacity >= limit && limit != NO_LIMIT,
|
|
||||||
"Capacity can't be less than limit, " +
|
|
||||||
"but got capacity '%s' and limit '%s'",
|
|
||||||
capacity, limit);
|
|
||||||
}
|
|
||||||
|
|
||||||
Id labelId = this.getEdgeLabelId(label);
|
|
||||||
|
|
||||||
Set<Id> latest = newIdSet();
|
|
||||||
latest.add(sourceV);
|
|
||||||
|
|
||||||
Set<Id> all = newIdSet();
|
|
||||||
all.add(sourceV);
|
|
||||||
|
|
||||||
long remaining = capacity == NO_LIMIT ?
|
|
||||||
NO_LIMIT : capacity - latest.size();
|
|
||||||
while (depth-- > 0) {
|
|
||||||
// Just get limit nodes in last layer if limit < remaining capacity
|
|
||||||
if (depth == 0 && limit != NO_LIMIT &&
|
|
||||||
(limit < remaining || remaining == NO_LIMIT)) {
|
|
||||||
remaining = limit;
|
|
||||||
}
|
|
||||||
if (nearest) {
|
|
||||||
latest = this.adjacentVertices(sourceV, latest, dir, labelId,
|
|
||||||
all, degree, remaining);
|
|
||||||
all.addAll(latest);
|
|
||||||
} else {
|
|
||||||
latest = this.adjacentVertices(sourceV, latest, dir, labelId,
|
|
||||||
null, degree, remaining);
|
|
||||||
}
|
|
||||||
if (capacity != NO_LIMIT) {
|
|
||||||
// Update 'remaining' value to record remaining capacity
|
|
||||||
remaining -= latest.size();
|
|
||||||
|
|
||||||
if (remaining <= 0 && depth > 0) {
|
|
||||||
throw new HugeException(
|
|
||||||
"Reach capacity '%s' while remaining depth '%s'",
|
|
||||||
capacity, depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return latest;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KoutRecords customizedKout(Id source, EdgeStep step,
|
|
||||||
int maxDepth, boolean nearest,
|
|
||||||
long capacity, long limit) {
|
|
||||||
E.checkNotNull(source, "source vertex id");
|
|
||||||
this.checkVertexExist(source, "source vertex");
|
|
||||||
checkPositive(maxDepth, "k-out max_depth");
|
|
||||||
checkCapacity(capacity);
|
|
||||||
checkLimit(limit);
|
|
||||||
long[] depth = new long[1];
|
|
||||||
depth[0] = maxDepth;
|
|
||||||
boolean concurrent = maxDepth >= this.concurrentDepth();
|
|
||||||
|
|
||||||
KoutRecords records = new KoutRecords(concurrent, source, nearest);
|
|
||||||
|
|
||||||
Consumer<Id> consumer = v -> {
|
|
||||||
if (this.reachLimit(limit, depth[0], records.size())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Iterator<Edge> edges = edgesOfVertex(v, step);
|
|
||||||
while (!this.reachLimit(limit, depth[0], records.size()) &&
|
|
||||||
edges.hasNext()) {
|
|
||||||
Id target = ((HugeEdge) edges.next()).id().otherVertexId();
|
|
||||||
records.addPath(v, target);
|
|
||||||
this.checkCapacity(capacity, records.accessed(), depth[0]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
while (depth[0]-- > 0) {
|
|
||||||
records.startOneLayer(true);
|
|
||||||
this.traverseIds(records.keys(), consumer, concurrent);
|
|
||||||
records.finishOneLayer();
|
|
||||||
}
|
|
||||||
return records;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkCapacity(long capacity, long accessed, long depth) {
|
|
||||||
if (capacity == NO_LIMIT) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (accessed >= capacity && depth > 0) {
|
|
||||||
throw new HugeException(
|
|
||||||
"Reach capacity '%s' while remaining depth '%s'",
|
|
||||||
capacity, depth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean reachLimit(long limit, long depth, int size) {
|
|
||||||
return limit != NO_LIMIT && depth <= 0 && size >= limit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,178 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.traversal.algorithm;
|
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.config.CoreOptions;
|
|
||||||
import org.apache.hugegraph.util.Consumers;
|
|
||||||
import org.apache.tinkerpop.gremlin.structure.Element;
|
|
||||||
import org.apache.tinkerpop.gremlin.structure.Property;
|
|
||||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
|
||||||
import org.apache.tinkerpop.gremlin.structure.util.CloseableIterator;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.iterator.FilterIterator;
|
|
||||||
|
|
||||||
public abstract class OltpTraverser extends HugeTraverser
|
|
||||||
implements AutoCloseable {
|
|
||||||
|
|
||||||
private static final String EXECUTOR_NAME = "oltp";
|
|
||||||
private static Consumers.ExecutorPool executors;
|
|
||||||
|
|
||||||
protected OltpTraverser(HugeGraph graph) {
|
|
||||||
super(graph);
|
|
||||||
if (executors != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
synchronized (OltpTraverser.class) {
|
|
||||||
if (executors != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int workers = this.graph()
|
|
||||||
.option(CoreOptions.OLTP_CONCURRENT_THREADS);
|
|
||||||
if (workers > 0) {
|
|
||||||
executors = new Consumers.ExecutorPool(EXECUTOR_NAME, workers);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
// pass
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void destroy() {
|
|
||||||
synchronized (OltpTraverser.class) {
|
|
||||||
if (executors != null) {
|
|
||||||
executors.destroy();
|
|
||||||
executors = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected long traversePairs(Iterator<Pair<Id, Id>> pairs,
|
|
||||||
Consumer<Pair<Id, Id>> consumer) {
|
|
||||||
return this.traverse(pairs, consumer, "traverse-pairs");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected long traverseIds(Iterator<Id> ids, Consumer<Id> consumer,
|
|
||||||
boolean concurrent) {
|
|
||||||
if (concurrent) {
|
|
||||||
return this.traverseIds(ids, consumer);
|
|
||||||
} else {
|
|
||||||
long count = 0L;
|
|
||||||
while (ids.hasNext()) {
|
|
||||||
count++;
|
|
||||||
consumer.accept(ids.next());
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected long traverseIds(Iterator<Id> ids, Consumer<Id> consumer) {
|
|
||||||
return this.traverse(ids, consumer, "traverse-ids");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <K> long traverse(Iterator<K> iterator, Consumer<K> consumer,
|
|
||||||
String name) {
|
|
||||||
if (!iterator.hasNext()) {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
Consumers<K> consumers = new Consumers<>(executors.getExecutor(),
|
|
||||||
consumer, null);
|
|
||||||
consumers.start(name);
|
|
||||||
long total = 0L;
|
|
||||||
try {
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
total++;
|
|
||||||
K v = iterator.next();
|
|
||||||
consumers.provide(v);
|
|
||||||
}
|
|
||||||
} catch (Consumers.StopExecution e) {
|
|
||||||
// pass
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw Consumers.wrapException(e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
consumers.await();
|
|
||||||
} catch (Throwable e) {
|
|
||||||
throw Consumers.wrapException(e);
|
|
||||||
} finally {
|
|
||||||
executors.returnExecutor(consumers.executor());
|
|
||||||
CloseableIterator.closeIterator(iterator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return total;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Iterator<Vertex> filter(Iterator<Vertex> vertices,
|
|
||||||
String key, Object value) {
|
|
||||||
return new FilterIterator<>(vertices, vertex -> {
|
|
||||||
return match(vertex, key, value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean match(Element elem, String key, Object value) {
|
|
||||||
// check property key exists
|
|
||||||
this.graph().propertyKey(key);
|
|
||||||
// return true if property value exists & equals to specified value
|
|
||||||
Property<Object> p = elem.property(key);
|
|
||||||
return p.isPresent() && Objects.equal(p.value(), value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ConcurrentMultiValuedMap<K, V>
|
|
||||||
extends ConcurrentHashMap<K, List<V>> {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -7249946839643493614L;
|
|
||||||
|
|
||||||
public ConcurrentMultiValuedMap() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(K key, V value) {
|
|
||||||
List<V> values = this.getValues(key);
|
|
||||||
values.add(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAll(K key, List<V> value) {
|
|
||||||
List<V> values = this.getValues(key);
|
|
||||||
values.addAll(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<V> getValues(K key) {
|
|
||||||
List<V> values = this.get(key);
|
|
||||||
if (values == null) {
|
|
||||||
values = new CopyOnWriteArrayList<>();
|
|
||||||
List<V> old = this.putIfAbsent(key, values);
|
|
||||||
if (old != null) {
|
|
||||||
values = old;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.traversal.algorithm;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.HugeGraph;
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.type.define.Directions;
|
|
||||||
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.util.CollectionUtil;
|
|
||||||
import org.apache.hugegraph.util.E;
|
|
||||||
|
|
||||||
public class SameNeighborTraverser extends HugeTraverser {
|
|
||||||
|
|
||||||
public SameNeighborTraverser(HugeGraph graph) {
|
|
||||||
super(graph);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Id> sameNeighbors(Id vertex, Id other, Directions direction,
|
|
||||||
String label, long degree, int limit) {
|
|
||||||
E.checkNotNull(vertex, "vertex id");
|
|
||||||
E.checkNotNull(other, "the other vertex id");
|
|
||||||
this.checkVertexExist(vertex, "vertex");
|
|
||||||
this.checkVertexExist(other, "other vertex");
|
|
||||||
E.checkNotNull(direction, "direction");
|
|
||||||
checkDegree(degree);
|
|
||||||
checkLimit(limit);
|
|
||||||
|
|
||||||
Id labelId = this.getEdgeLabelId(label);
|
|
||||||
|
|
||||||
Set<Id> sourceNeighbors = IteratorUtils.set(this.adjacentVertices(
|
|
||||||
vertex, direction, labelId, degree));
|
|
||||||
Set<Id> targetNeighbors = IteratorUtils.set(this.adjacentVertices(
|
|
||||||
other, direction, labelId, degree));
|
|
||||||
Set<Id> sameNeighbors = (Set<Id>) CollectionUtil.intersect(
|
|
||||||
sourceNeighbors, targetNeighbors);
|
|
||||||
if (limit != NO_LIMIT) {
|
|
||||||
int end = Math.min(sameNeighbors.size(), limit);
|
|
||||||
sameNeighbors = CollectionUtil.subSet(sameNeighbors, 0, end);
|
|
||||||
}
|
|
||||||
return sameNeighbors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.traversal.algorithm.records;
|
|
||||||
|
|
||||||
import static org.apache.hugegraph.traversal.algorithm.HugeTraverser.NO_LIMIT;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
import org.apache.hugegraph.traversal.algorithm.HugeTraverser.PathSet;
|
|
||||||
import org.apache.hugegraph.traversal.algorithm.records.record.Record;
|
|
||||||
import org.apache.hugegraph.traversal.algorithm.records.record.RecordType;
|
|
||||||
import org.apache.hugegraph.type.define.CollectionType;
|
|
||||||
import org.apache.hugegraph.util.collection.CollectionFactory;
|
|
||||||
import org.apache.hugegraph.util.collection.IntIterator;
|
|
||||||
|
|
||||||
public class KoutRecords extends SingleWayMultiPathsRecords {
|
|
||||||
|
|
||||||
public KoutRecords(boolean concurrent, Id source, boolean nearest) {
|
|
||||||
super(RecordType.INT, concurrent, source, nearest);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return this.currentRecord().size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Id> ids(long limit) {
|
|
||||||
List<Id> ids = CollectionFactory.newList(CollectionType.EC);
|
|
||||||
IntIterator iterator = this.records().peek().keys();
|
|
||||||
while ((limit == NO_LIMIT || limit-- > 0L) && iterator.hasNext()) {
|
|
||||||
ids.add(this.id(iterator.next()));
|
|
||||||
}
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PathSet paths(long limit) {
|
|
||||||
PathSet paths = new PathSet();
|
|
||||||
Stack<Record> records = this.records();
|
|
||||||
IntIterator iterator = records.peek().keys();
|
|
||||||
while ((limit == NO_LIMIT || limit-- > 0L) && iterator.hasNext()) {
|
|
||||||
paths.add(this.linkPath(records.size() - 1, iterator.next()));
|
|
||||||
}
|
|
||||||
return paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,25 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.type;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
|
|
||||||
public interface Idfiable {
|
|
||||||
|
|
||||||
Id id();
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.type;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
|
|
||||||
public interface Indexable {
|
|
||||||
|
|
||||||
Set<Id> indexLabels();
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.type;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.backend.id.Id;
|
|
||||||
|
|
||||||
public interface Propertiable {
|
|
||||||
|
|
||||||
Set<Id> properties();
|
|
||||||
}
|
|
||||||
|
|
@ -1,24 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.type;
|
|
||||||
|
|
||||||
public interface Typeable {
|
|
||||||
|
|
||||||
// Return schema/data type
|
|
||||||
HugeType type();
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.util.collection;
|
|
||||||
|
|
||||||
public interface ObjectIntMapping<V> {
|
|
||||||
|
|
||||||
int object2Code(Object object);
|
|
||||||
|
|
||||||
V code2Object(int code);
|
|
||||||
|
|
||||||
void clear();
|
|
||||||
}
|
|
||||||
|
|
@ -1,43 +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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.hugegraph.version;
|
|
||||||
|
|
||||||
import org.apache.hugegraph.util.VersionUtil;
|
|
||||||
import org.apache.hugegraph.util.VersionUtil.Version;
|
|
||||||
|
|
||||||
public class CoreVersion {
|
|
||||||
|
|
||||||
static {
|
|
||||||
// Check versions of the dependency packages
|
|
||||||
CoreVersion.check();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final String NAME = "hugegraph-core";
|
|
||||||
|
|
||||||
public static final String DEFAULT_VERSION = "1.0.0";
|
|
||||||
|
|
||||||
// The second parameter of Version.of() is for IDE running without JAR
|
|
||||||
public static final Version VERSION = Version.of(CoreVersion.class, DEFAULT_VERSION);
|
|
||||||
|
|
||||||
public static final String GREMLIN_VERSION = "3.4.3";
|
|
||||||
|
|
||||||
public static void check() {
|
|
||||||
// Check version of hugegraph-common
|
|
||||||
VersionUtil.check(CommonVersion.VERSION, "1.0", "1.1", CommonVersion.NAME);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,18 +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.
|
|
||||||
#
|
|
||||||
|
|
||||||
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin
|
|
||||||
|
|
@ -1,18 +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.
|
|
||||||
#
|
|
||||||
|
|
||||||
gremlin.graph=org.apache.hugegraph.HugeFactory
|
|
||||||
|
|
@ -1,218 +0,0 @@
|
||||||
<?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>
|
|
||||||
<artifactId>hugegraph</artifactId>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
<relativePath>../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<name>hugegraph-dist</name>
|
|
||||||
<artifactId>hugegraph-dist</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<assembly.dir>${project.basedir}/src/assembly</assembly.dir>
|
|
||||||
<assembly.descriptor.dir>${assembly.dir}/descriptor</assembly.descriptor.dir>
|
|
||||||
<assembly.static.dir>${assembly.dir}/static</assembly.static.dir>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-core</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>metrics-core</artifactId>
|
|
||||||
<groupId>io.dropwizard.metrics</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-api</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>metrics-core</artifactId>
|
|
||||||
<groupId>com.codahale.metrics</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-cassandra</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>metrics-core</artifactId>
|
|
||||||
<groupId>io.dropwizard.metrics</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-scylladb</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-rocksdb</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-mysql</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-palo</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-hbase</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hugegraph</groupId>
|
|
||||||
<artifactId>hugegraph-postgresql</artifactId>
|
|
||||||
<version>${revision}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.tinkerpop</groupId>
|
|
||||||
<artifactId>gremlin-console</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.github.jeremyh</groupId>
|
|
||||||
<artifactId>jBCrypt</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/src/assembly/static</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/src/main/resources</directory>
|
|
||||||
<filtering>false</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>assembly-hugegraph</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>single</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<attach>false</attach>
|
|
||||||
<appendAssemblyId>false</appendAssemblyId>
|
|
||||||
<outputDirectory>${top.level.dir}
|
|
||||||
</outputDirectory>
|
|
||||||
<descriptor>
|
|
||||||
${assembly.descriptor.dir}/assembly.xml
|
|
||||||
</descriptor>
|
|
||||||
<finalName>${final.name}</finalName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<filesets>
|
|
||||||
<fileset>
|
|
||||||
<directory>${top.level.dir}</directory>
|
|
||||||
<includes>
|
|
||||||
<include>*.tar.gz</include>
|
|
||||||
<include>.flattened-pom.xml</include>
|
|
||||||
<!--<include>${final.name}/**</include>-->
|
|
||||||
</includes>
|
|
||||||
<followSymlinks>false</followSymlinks>
|
|
||||||
</fileset>
|
|
||||||
<fileset>
|
|
||||||
<directory>${final.name}</directory>
|
|
||||||
</fileset>
|
|
||||||
</filesets>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>download-swagger-ui</id>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<tasks>
|
|
||||||
<echo file="${project.basedir}/dist.sh">
|
|
||||||
wget --version 1>/dev/null || exit
|
|
||||||
wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v4.15.5.tar.gz
|
|
||||||
tar zxvf v4.15.5.tar.gz
|
|
||||||
echo "window.onload = function() { window.ui = SwaggerUIBundle({
|
|
||||||
url:'/openapi.json',dom_id:'#swagger-ui',deepLinking:true,layout:'StandaloneLayout',
|
|
||||||
presets:[SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ],
|
|
||||||
plugins:[SwaggerUIBundle.plugins.DownloadUrl]});};" > swagger-ui-4.15.5/dist/swagger-initializer.js
|
|
||||||
cp -r swagger-ui-4.15.5/dist ../${final.name}/swagger-ui
|
|
||||||
</echo>
|
|
||||||
<exec executable="${shell-executable}" dir="${project.basedir}" failonerror="true">
|
|
||||||
<arg line="./dist.sh"/>
|
|
||||||
</exec>
|
|
||||||
</tasks>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>run</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<target>
|
|
||||||
<tar destfile="${final.destfile}" compression="gzip">
|
|
||||||
<tarfileset dir="${top.level.dir}/" filemode="755">
|
|
||||||
<include name="${final.name}/**"/>
|
|
||||||
</tarfileset>
|
|
||||||
</tar>
|
|
||||||
</target>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
This copy of Compress-LZF library is licensed under the
|
|
||||||
Apache (Software) License, version 2.0 ("the License").
|
|
||||||
See the License for details about distribution rights, and the
|
|
||||||
specific rights regarding derivate works.
|
|
||||||
|
|
||||||
You may obtain a copy of the License at:
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
This copy of Jackson JSON processor databind module is licensed under the
|
|
||||||
Apache (Software) License, version 2.0 ("the License").
|
|
||||||
See the License for details about distribution rights, and the
|
|
||||||
specific rights regarding derivate works.
|
|
||||||
|
|
||||||
You may obtain a copy of the License at:
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
This copy of Jackson JSON processor databind module is licensed under the
|
|
||||||
Apache (Software) License, version 2.0 ("the License").
|
|
||||||
See the License for details about distribution rights, and the
|
|
||||||
specific rights regarding derivate works.
|
|
||||||
|
|
||||||
You may obtain a copy of the License at:
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
|
|
||||||
BASE_PATH=$(cd $(dirname $0); pwd)
|
|
||||||
|
|
||||||
# check whether there are new third-party dependencies by diff command,
|
|
||||||
# diff generated 'current-dependencies.txt' file with 'known-dependencies.txt' file.
|
|
||||||
diff -w -B -U0 <(sort < ${BASE_PATH}/known-dependencies.txt) \
|
|
||||||
<(sort < ${BASE_PATH}/current-dependencies.txt) > ${BASE_PATH}/result.txt
|
|
||||||
|
|
||||||
# if has new third-party,the Action will fail and print diff
|
|
||||||
if [ -s ${BASE_PATH}/result.txt ]; then
|
|
||||||
cat ${BASE_PATH}/result.txt
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo 'All third dependencies is known!'
|
|
||||||
fi
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
echo "Start deploy..."
|
|
||||||
echo "Finish deploy."
|
|
||||||
|
|
@ -1,38 +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.
|
|
||||||
-->
|
|
||||||
<settings>
|
|
||||||
<servers>
|
|
||||||
<server>
|
|
||||||
<id>ossrh</id>
|
|
||||||
<username>${env.MAVEN_REPO_USERNAME}</username>
|
|
||||||
<password>${env.MAVEN_REPO_PASSWORD}</password>
|
|
||||||
</server>
|
|
||||||
</servers>
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>release</id>
|
|
||||||
<activation>
|
|
||||||
<activeByDefault>false</activeByDefault>
|
|
||||||
</activation>
|
|
||||||
<properties>
|
|
||||||
<gpg.executable>gpg</gpg.executable>
|
|
||||||
<gpg.keyname>${env.GPG_KEY_ID}</gpg.keyname>
|
|
||||||
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
|
|
||||||
</properties>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
</settings>
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# 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.
|
|
||||||
#
|
|
||||||
set -ev
|
|
||||||
|
|
||||||
BACKEND=$1
|
|
||||||
SUITE=$2
|
|
||||||
|
|
||||||
if [[ "$SUITE" == "structure" || "$SUITE" == "tinkerpop" ]]; then
|
|
||||||
mvn test -P tinkerpop-structure-test,$BACKEND
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$SUITE" == "process" || "$SUITE" == "tinkerpop" ]]; then
|
|
||||||
mvn test -P tinkerpop-process-test,$BACKEND
|
|
||||||
fi
|
|
||||||
|
|
@ -1,18 +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.
|
|
||||||
#
|
|
||||||
|
|
||||||
backends=[cassandra, scylladb, rocksdb, mysql, palo, hbase, postgresql]
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
* text=auto eol=lf
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
/hg-pd-grpc/src/main/java/
|
||||||
|
/.idea/
|
||||||
|
/hg-pd-grpc/target/
|
||||||
|
/dist/
|
||||||
|
**/target/
|
||||||
|
.DS_Store
|
||||||
|
**/tmp/
|
||||||
|
*.log
|
||||||
|
*.iml
|
||||||
|
dist/
|
||||||
|
.flattened-pom.xml
|
||||||
|
|
@ -15,28 +15,32 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Dockerfile for HugeGraph Server
|
# Dockerfile for HugeGraph PD
|
||||||
# 1st stage: build source code
|
# 1st stage: build source code
|
||||||
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
FROM maven:3.9.0-eclipse-temurin-11 AS build
|
||||||
|
|
||||||
COPY . /pkg
|
COPY . /pkg
|
||||||
WORKDIR /pkg
|
WORKDIR /pkg
|
||||||
RUN mvn package -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l
|
ARG MAVEN_ARGS
|
||||||
|
|
||||||
|
RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l && rm \
|
||||||
|
./hugegraph-server/*.tar.gz && rm ./hugegraph-pd/dist/*.tar.gz && rm ./hugegraph-store/dist/*.tar.gz
|
||||||
|
|
||||||
# 2nd stage: runtime env
|
# 2nd stage: runtime env
|
||||||
|
# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13
|
||||||
FROM openjdk:11-slim
|
FROM openjdk:11-slim
|
||||||
# TODO: get the version from the pom.xml
|
|
||||||
ENV version=1.0.0
|
COPY --from=build /pkg/hugegraph-pd/dist/hugegraph-pd-*/ /hugegraph-pd/
|
||||||
COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph
|
|
||||||
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
|
LABEL maintainer="HugeGraph Docker Maintainers <dev@hugegraph.apache.org>"
|
||||||
|
|
||||||
# TODO: use g1gc or zgc as default
|
# TODO: use g1gc or zgc as default
|
||||||
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm"
|
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
|
||||||
|
HUGEGRAPH_HOME="hugegraph-pd"
|
||||||
|
|
||||||
#COPY . /hugegraph/hugegraph-server
|
#COPY . /hugegraph/hugegraph-pd
|
||||||
WORKDIR /hugegraph/
|
WORKDIR /hugegraph-pd/
|
||||||
|
|
||||||
# 1. Install environment
|
# 1. Install environment and init HugeGraph Sever
|
||||||
RUN set -x \
|
RUN set -x \
|
||||||
&& apt-get -q update \
|
&& apt-get -q update \
|
||||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||||
|
|
@ -44,17 +48,19 @@ RUN set -x \
|
||||||
procps \
|
procps \
|
||||||
curl \
|
curl \
|
||||||
lsof \
|
lsof \
|
||||||
|
vim \
|
||||||
|
cron \
|
||||||
&& apt-get clean \
|
&& apt-get clean \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& service cron start \
|
||||||
|
&& pwd && cd /hugegraph-pd/
|
||||||
|
|
||||||
# 2. Init HugeGraph Sever
|
# 2. Init docker script
|
||||||
RUN set -e \
|
COPY hugegraph-pd/hg-pd-dist/docker/docker-entrypoint.sh .
|
||||||
&& pwd && cd /hugegraph/ \
|
RUN chmod 755 ./docker-entrypoint.sh
|
||||||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
|
|
||||||
&& ./bin/init-store.sh
|
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8620
|
||||||
VOLUME /hugegraph
|
VOLUME /hugegraph-pd
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
|
||||||
CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"]
|
CMD ["./docker-entrypoint.sh"]
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# HugeGraph PD
|
||||||
|
|
||||||
|
HugeGraph PD is a meta server responsible for service discovery, partition information storage, and node scheduling.
|
||||||
|
|
||||||
|
> Note: Currently, the contents of this folder are empty. Starting from revision 1.5.0, the code of HugeGraph PD will be adapted to this location (WIP).
|
||||||
Binary file not shown.
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"subject": "hugegraph-license",
|
||||||
|
"public_alias": "publiccert",
|
||||||
|
"store_ticket": "803b6cc3-d144-47e8-948f-ec8b39c8881e",
|
||||||
|
"publickey_path": "/public-certs.store"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.hugegraph</groupId>
|
||||||
|
<artifactId>hugegraph-pd</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<artifactId>hg-pd-client</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.20</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-slf4j-impl</artifactId>
|
||||||
|
<version>2.17.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.hugegraph</groupId>
|
||||||
|
<artifactId>hg-pd-grpc</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.hugegraph</groupId>
|
||||||
|
<artifactId>hg-pd-common</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.8.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
|
<artifactId>snakeyaml</artifactId>
|
||||||
|
<version>1.28</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,265 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.apache.hugegraph.pd.common.KVPair;
|
||||||
|
import org.apache.hugegraph.pd.common.PDException;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Metapb;
|
||||||
|
import org.apache.hugegraph.pd.grpc.PDGrpc;
|
||||||
|
import org.apache.hugegraph.pd.grpc.PDGrpc.PDBlockingStub;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Pdpb;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Pdpb.GetMembersRequest;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Pdpb.GetMembersResponse;
|
||||||
|
|
||||||
|
import io.grpc.Channel;
|
||||||
|
import io.grpc.ClientCall;
|
||||||
|
import io.grpc.ManagedChannel;
|
||||||
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
import io.grpc.MethodDescriptor;
|
||||||
|
import io.grpc.StatusRuntimeException;
|
||||||
|
import io.grpc.stub.AbstractBlockingStub;
|
||||||
|
import io.grpc.stub.AbstractStub;
|
||||||
|
import io.grpc.stub.ClientCalls;
|
||||||
|
import io.grpc.stub.StreamObserver;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public abstract class AbstractClient implements Closeable {
|
||||||
|
|
||||||
|
private static final ConcurrentHashMap<String, ManagedChannel> chs = new ConcurrentHashMap<>();
|
||||||
|
public static Pdpb.ResponseHeader okHeader = Pdpb.ResponseHeader.newBuilder().setError(
|
||||||
|
Pdpb.Error.newBuilder().setType(Pdpb.ErrorType.OK)).build();
|
||||||
|
protected final Pdpb.RequestHeader header;
|
||||||
|
protected final AbstractClientStubProxy stubProxy;
|
||||||
|
protected final PDConfig config;
|
||||||
|
protected ManagedChannel channel = null;
|
||||||
|
protected volatile ConcurrentMap<String, AbstractBlockingStub> stubs = null;
|
||||||
|
|
||||||
|
protected AbstractClient(PDConfig config) {
|
||||||
|
String[] hosts = config.getServerHost().split(",");
|
||||||
|
this.stubProxy = new AbstractClientStubProxy(hosts);
|
||||||
|
this.header = Pdpb.RequestHeader.getDefaultInstance();
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Pdpb.ResponseHeader newErrorHeader(int errorCode, String errorMsg) {
|
||||||
|
Pdpb.ResponseHeader header = Pdpb.ResponseHeader.newBuilder().setError(
|
||||||
|
Pdpb.Error.newBuilder().setTypeValue(errorCode).setMessage(errorMsg)).build();
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void handleErrors(Pdpb.ResponseHeader header) throws PDException {
|
||||||
|
if (header.hasError() && header.getError().getType() != Pdpb.ErrorType.OK) {
|
||||||
|
throw new PDException(header.getError().getTypeValue(),
|
||||||
|
String.format("PD request error, error code = %d, msg = %s",
|
||||||
|
header.getError().getTypeValue(),
|
||||||
|
header.getError().getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractBlockingStub getBlockingStub() throws PDException {
|
||||||
|
if (stubProxy.getBlockingStub() == null) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (stubProxy.getBlockingStub() == null) {
|
||||||
|
String host = resetStub();
|
||||||
|
if (host.isEmpty()) {
|
||||||
|
throw new PDException(Pdpb.ErrorType.PD_UNREACHABLE_VALUE,
|
||||||
|
"PD unreachable, pd.peers=" +
|
||||||
|
config.getServerHost());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (AbstractBlockingStub) stubProxy.getBlockingStub()
|
||||||
|
.withDeadlineAfter(config.getGrpcTimeOut(),
|
||||||
|
TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AbstractStub getStub() throws PDException {
|
||||||
|
if (stubProxy.getStub() == null) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (stubProxy.getStub() == null) {
|
||||||
|
String host = resetStub();
|
||||||
|
if (host.isEmpty()) {
|
||||||
|
throw new PDException(Pdpb.ErrorType.PD_UNREACHABLE_VALUE,
|
||||||
|
"PD unreachable, pd.peers=" +
|
||||||
|
config.getServerHost());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stubProxy.getStub();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract AbstractStub createStub();
|
||||||
|
|
||||||
|
protected abstract AbstractBlockingStub createBlockingStub();
|
||||||
|
|
||||||
|
private String resetStub() {
|
||||||
|
String leaderHost = "";
|
||||||
|
for (int i = 0; i < stubProxy.getHostCount(); i++) {
|
||||||
|
String host = stubProxy.nextHost();
|
||||||
|
channel = ManagedChannelBuilder.forTarget(host).usePlaintext().build();
|
||||||
|
PDBlockingStub blockingStub = PDGrpc.newBlockingStub(channel)
|
||||||
|
.withDeadlineAfter(config.getGrpcTimeOut(),
|
||||||
|
TimeUnit.MILLISECONDS);
|
||||||
|
try {
|
||||||
|
GetMembersRequest request = Pdpb.GetMembersRequest.newBuilder()
|
||||||
|
.setHeader(header).build();
|
||||||
|
GetMembersResponse members = blockingStub.getMembers(request);
|
||||||
|
Metapb.Member leader = members.getLeader();
|
||||||
|
leaderHost = leader.getGrpcUrl();
|
||||||
|
close();
|
||||||
|
channel = ManagedChannelBuilder.forTarget(leaderHost).usePlaintext().build();
|
||||||
|
stubProxy.setBlockingStub(createBlockingStub());
|
||||||
|
stubProxy.setStub(createStub());
|
||||||
|
log.info("PDClient connect to host = {} success", leaderHost);
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("PDClient connect to {} exception {}, {}", host, e.getMessage(),
|
||||||
|
e.getCause() != null ? e.getCause().getMessage() : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return leaderHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <ReqT, RespT, StubT extends AbstractBlockingStub<StubT>> RespT blockingUnaryCall(
|
||||||
|
MethodDescriptor<ReqT, RespT> method, ReqT req) throws PDException {
|
||||||
|
return blockingUnaryCall(method, req, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <ReqT, RespT, StubT extends AbstractBlockingStub<StubT>> RespT blockingUnaryCall(
|
||||||
|
MethodDescriptor<ReqT, RespT> method, ReqT req, int retry) throws PDException {
|
||||||
|
AbstractBlockingStub stub = getBlockingStub();
|
||||||
|
try {
|
||||||
|
RespT resp =
|
||||||
|
ClientCalls.blockingUnaryCall(stub.getChannel(), method, stub.getCallOptions(),
|
||||||
|
req);
|
||||||
|
return resp;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(method.getFullMethodName() + " exception, {}", e.getMessage());
|
||||||
|
if (e instanceof StatusRuntimeException) {
|
||||||
|
if (retry < stubProxy.getHostCount()) {
|
||||||
|
// 网络不通,关掉之前连接,换host重新连接
|
||||||
|
synchronized (this) {
|
||||||
|
stubProxy.setBlockingStub(null);
|
||||||
|
}
|
||||||
|
return blockingUnaryCall(method, req, ++retry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// this.stubs = new ConcurrentHashMap<String,AbstractBlockingStub>(hosts.length);
|
||||||
|
private AbstractBlockingStub getConcurrentBlockingStub(String address) {
|
||||||
|
AbstractBlockingStub stub = stubs.get(address);
|
||||||
|
if (stub != null) {
|
||||||
|
return stub;
|
||||||
|
}
|
||||||
|
Channel ch = ManagedChannelBuilder.forTarget(address).usePlaintext().build();
|
||||||
|
PDBlockingStub blockingStub =
|
||||||
|
PDGrpc.newBlockingStub(ch).withDeadlineAfter(config.getGrpcTimeOut(),
|
||||||
|
TimeUnit.MILLISECONDS);
|
||||||
|
stubs.put(address, blockingStub);
|
||||||
|
return blockingStub;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <ReqT, RespT> KVPair<Boolean, RespT> concurrentBlockingUnaryCall(
|
||||||
|
MethodDescriptor<ReqT, RespT> method, ReqT req, Predicate<RespT> predicate) {
|
||||||
|
LinkedList<String> hostList = this.stubProxy.getHostList();
|
||||||
|
if (this.stubs == null) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (this.stubs == null) {
|
||||||
|
this.stubs = new ConcurrentHashMap<>(hostList.size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Stream<RespT> respTStream = hostList.parallelStream().map((address) -> {
|
||||||
|
AbstractBlockingStub stub = getConcurrentBlockingStub(address);
|
||||||
|
RespT resp = ClientCalls.blockingUnaryCall(stub.getChannel(),
|
||||||
|
method, stub.getCallOptions(), req);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
|
KVPair<Boolean, RespT> pair;
|
||||||
|
AtomicReference<RespT> response = new AtomicReference<>();
|
||||||
|
boolean result = respTStream.anyMatch((r) -> {
|
||||||
|
response.set(r);
|
||||||
|
return predicate.test(r);
|
||||||
|
});
|
||||||
|
if (result) {
|
||||||
|
pair = new KVPair<>(true, null);
|
||||||
|
} else {
|
||||||
|
pair = new KVPair<>(false, response.get());
|
||||||
|
}
|
||||||
|
return pair;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <ReqT, RespT> void streamingCall(MethodDescriptor<ReqT, RespT> method, ReqT request,
|
||||||
|
StreamObserver<RespT> responseObserver,
|
||||||
|
int retry) throws PDException {
|
||||||
|
AbstractStub stub = getStub();
|
||||||
|
try {
|
||||||
|
ClientCall<ReqT, RespT> call = stub.getChannel().newCall(method, stub.getCallOptions());
|
||||||
|
ClientCalls.asyncServerStreamingCall(call, request, responseObserver);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e instanceof StatusRuntimeException) {
|
||||||
|
if (retry < stubProxy.getHostCount()) {
|
||||||
|
synchronized (this) {
|
||||||
|
stubProxy.setStub(null);
|
||||||
|
}
|
||||||
|
streamingCall(method, request, responseObserver, ++retry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.error("rpc call with exception, {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
closeChannel(channel);
|
||||||
|
if (stubs != null) {
|
||||||
|
for (AbstractBlockingStub stub : stubs.values()) {
|
||||||
|
closeChannel((ManagedChannel) stub.getChannel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeChannel(ManagedChannel channel) {
|
||||||
|
try {
|
||||||
|
while (channel != null &&
|
||||||
|
!channel.shutdownNow().awaitTermination(100, TimeUnit.MILLISECONDS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("Close channel with error : ", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import io.grpc.stub.AbstractBlockingStub;
|
||||||
|
import io.grpc.stub.AbstractStub;
|
||||||
|
|
||||||
|
public class AbstractClientStubProxy {
|
||||||
|
|
||||||
|
private final LinkedList<String> hostList = new LinkedList<>();
|
||||||
|
private AbstractBlockingStub blockingStub;
|
||||||
|
private AbstractStub stub;
|
||||||
|
|
||||||
|
public AbstractClientStubProxy(String[] hosts) {
|
||||||
|
for (String host : hosts) {
|
||||||
|
if (!host.isEmpty()) {
|
||||||
|
hostList.offer(host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<String> getHostList() {
|
||||||
|
return hostList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String nextHost() {
|
||||||
|
String host = hostList.poll();
|
||||||
|
hostList.offer(host); //移到尾部
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractBlockingStub getBlockingStub() {
|
||||||
|
return this.blockingStub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockingStub(AbstractBlockingStub stub) {
|
||||||
|
this.blockingStub = stub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHost() {
|
||||||
|
return hostList.peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHostCount() {
|
||||||
|
return hostList.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractStub getStub() {
|
||||||
|
return stub;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStub(AbstractStub stub) {
|
||||||
|
this.stub = stub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import io.grpc.ManagedChannel;
|
||||||
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
|
||||||
|
public class Channels {
|
||||||
|
|
||||||
|
private static final ConcurrentHashMap<String, ManagedChannel> chs = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static ManagedChannel getChannel(String target) {
|
||||||
|
|
||||||
|
ManagedChannel channel;
|
||||||
|
if ((channel = chs.get(target)) == null || channel.isShutdown() || channel.isTerminated()) {
|
||||||
|
synchronized (chs) {
|
||||||
|
if ((channel = chs.get(target)) == null || channel.isShutdown() ||
|
||||||
|
channel.isTerminated()) {
|
||||||
|
channel = ManagedChannelBuilder.forTarget(target).usePlaintext().build();
|
||||||
|
chs.put(target, channel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,345 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import org.apache.hugegraph.pd.common.GraphCache;
|
||||||
|
import org.apache.hugegraph.pd.common.KVPair;
|
||||||
|
import org.apache.hugegraph.pd.common.PDException;
|
||||||
|
import org.apache.hugegraph.pd.common.PartitionUtils;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Metapb;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Metapb.Partition;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Metapb.Shard;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Metapb.ShardGroup;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Pdpb.CachePartitionResponse;
|
||||||
|
import org.apache.hugegraph.pd.grpc.Pdpb.CacheResponse;
|
||||||
|
|
||||||
|
import com.google.common.collect.Range;
|
||||||
|
import com.google.common.collect.RangeMap;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class ClientCache {
|
||||||
|
|
||||||
|
private final AtomicBoolean initialized = new AtomicBoolean(false);
|
||||||
|
private final org.apache.hugegraph.pd.client.PDClient client;
|
||||||
|
private volatile Map<Integer, KVPair<ShardGroup, Shard>> groups;
|
||||||
|
private volatile Map<Long, Metapb.Store> stores;
|
||||||
|
private volatile Map<String, GraphCache> caches = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public ClientCache(org.apache.hugegraph.pd.client.PDClient pdClient) {
|
||||||
|
groups = new ConcurrentHashMap<>();
|
||||||
|
stores = new ConcurrentHashMap<>();
|
||||||
|
client = pdClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GraphCache getGraphCache(String graphName) {
|
||||||
|
GraphCache graph;
|
||||||
|
if ((graph = caches.get(graphName)) == null) {
|
||||||
|
synchronized (caches) {
|
||||||
|
if ((graph = caches.get(graphName)) == null) {
|
||||||
|
graph = new GraphCache();
|
||||||
|
caches.put(graphName, graph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KVPair<Partition, Shard> getPartitionById(String graphName, int partId) {
|
||||||
|
try {
|
||||||
|
GraphCache graph = initGraph(graphName);
|
||||||
|
Partition partition = graph.getPartition(partId);
|
||||||
|
if (partition == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
KVPair<ShardGroup, Shard> group = groups.get(partId);
|
||||||
|
if (group == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Shard shard = group.getValue();
|
||||||
|
if (shard == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new KVPair<>(partition, shard);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private KVPair<Partition, Shard> getPair(int partId, GraphCache graph) {
|
||||||
|
Partition p = graph.getPartition(partId);
|
||||||
|
KVPair<ShardGroup, Shard> pair = groups.get(partId);
|
||||||
|
if (p != null && pair != null) {
|
||||||
|
Shard s = pair.getValue();
|
||||||
|
if (s == null) {
|
||||||
|
pair.setValue(getLeader(partId));
|
||||||
|
return new KVPair<>(p, pair.getValue());
|
||||||
|
} else {
|
||||||
|
return new KVPair<>(p, s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据key的hashcode返回分区信息
|
||||||
|
*
|
||||||
|
* @param graphName
|
||||||
|
* @param code
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public KVPair<Partition, Shard> getPartitionByCode(String graphName, long code) {
|
||||||
|
try {
|
||||||
|
GraphCache graph = initGraph(graphName);
|
||||||
|
RangeMap<Long, Integer> range = graph.getRange();
|
||||||
|
Integer pId = range.get(code);
|
||||||
|
if (pId != null) {
|
||||||
|
return getPair(pId, graph);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (PDException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private GraphCache initGraph(String graphName) throws PDException {
|
||||||
|
initCache();
|
||||||
|
GraphCache graph = getGraphCache(graphName);
|
||||||
|
if (!graph.getInitialized().get()) {
|
||||||
|
synchronized (graph) {
|
||||||
|
if (!graph.getInitialized().get()) {
|
||||||
|
CachePartitionResponse pc = client.getPartitionCache(graphName);
|
||||||
|
RangeMap<Long, Integer> range = graph.getRange();
|
||||||
|
List<Partition> ps = pc.getPartitionsList();
|
||||||
|
HashMap<Integer, Partition> gps = new HashMap<>(ps.size(), 1);
|
||||||
|
for (Partition p : ps) {
|
||||||
|
gps.put(p.getId(), p);
|
||||||
|
range.put(Range.closedOpen(p.getStartKey(), p.getEndKey()), p.getId());
|
||||||
|
}
|
||||||
|
graph.setPartitions(gps);
|
||||||
|
graph.getInitialized().set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initCache() throws PDException {
|
||||||
|
if (!initialized.get()) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (!initialized.get()) {
|
||||||
|
CacheResponse cache = client.getClientCache();
|
||||||
|
List<ShardGroup> shardGroups = cache.getShardsList();
|
||||||
|
for (ShardGroup s : shardGroups) {
|
||||||
|
this.groups.put(s.getId(), new KVPair<>(s, getLeader(s.getId())));
|
||||||
|
}
|
||||||
|
List<Metapb.Store> stores = cache.getStoresList();
|
||||||
|
for (Metapb.Store store : stores) {
|
||||||
|
this.stores.put(store.getId(), store);
|
||||||
|
}
|
||||||
|
List<Metapb.Graph> graphs = cache.getGraphsList();
|
||||||
|
for (Metapb.Graph g : graphs) {
|
||||||
|
GraphCache c = new GraphCache(g);
|
||||||
|
caches.put(g.getGraphName(), c);
|
||||||
|
}
|
||||||
|
initialized.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回key所在的分区信息
|
||||||
|
*
|
||||||
|
* @param key
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public KVPair<Partition, Shard> getPartitionByKey(String graphName, byte[] key) {
|
||||||
|
int code = PartitionUtils.calcHashcode(key);
|
||||||
|
return getPartitionByCode(graphName, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(String graphName, int partId, Partition partition) {
|
||||||
|
GraphCache graph = getGraphCache(graphName);
|
||||||
|
try {
|
||||||
|
Partition p = graph.getPartition(partId);
|
||||||
|
if (p != null && p.equals(partition)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
RangeMap<Long, Integer> range = graph.getRange();
|
||||||
|
graph.addPartition(partId, partition);
|
||||||
|
if (p != null) {
|
||||||
|
// old [1-3) 被 [2-3)覆盖了。当 [1-3) 变成[1-2) 不应该删除原先的[1-3)
|
||||||
|
// 当确认老的 start, end 都是自己的时候,才可以删除老的. (即还没覆盖)
|
||||||
|
if (Objects.equals(partition.getId(), range.get(partition.getStartKey())) &&
|
||||||
|
Objects.equals(partition.getId(), range.get(partition.getEndKey() - 1))) {
|
||||||
|
range.remove(range.getEntry(partition.getStartKey()).getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
range.put(Range.closedOpen(partition.getStartKey(), partition.getEndKey()), partId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePartition(String graphName, int partId) {
|
||||||
|
GraphCache graph = getGraphCache(graphName);
|
||||||
|
Partition p = graph.removePartition(partId);
|
||||||
|
if (p != null) {
|
||||||
|
RangeMap<Long, Integer> range = graph.getRange();
|
||||||
|
if (Objects.equals(p.getId(), range.get(p.getStartKey())) &&
|
||||||
|
Objects.equals(p.getId(), range.get(p.getEndKey() - 1))) {
|
||||||
|
range.remove(range.getEntry(p.getStartKey()).getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove all partitions
|
||||||
|
*/
|
||||||
|
public void removePartitions() {
|
||||||
|
for (Entry<String, GraphCache> entry : caches.entrySet()) {
|
||||||
|
removePartitions(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removePartitions(GraphCache graph) {
|
||||||
|
graph.getState().clear();
|
||||||
|
graph.getRange().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove partition cache of graphName
|
||||||
|
*
|
||||||
|
* @param graphName
|
||||||
|
*/
|
||||||
|
public void removeAll(String graphName) {
|
||||||
|
GraphCache graph = caches.get(graphName);
|
||||||
|
if (graph != null) {
|
||||||
|
removePartitions(graph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateShardGroup(ShardGroup shardGroup) {
|
||||||
|
KVPair<ShardGroup, Shard> old = groups.get(shardGroup.getId());
|
||||||
|
Shard leader = getLeader(shardGroup);
|
||||||
|
if (old != null) {
|
||||||
|
old.setKey(shardGroup);
|
||||||
|
old.setValue(leader);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
groups.put(shardGroup.getId(), new KVPair<>(shardGroup, leader));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteShardGroup(int shardGroupId) {
|
||||||
|
groups.remove(shardGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShardGroup getShardGroup(int groupId) {
|
||||||
|
KVPair<ShardGroup, Shard> pair = groups.get(groupId);
|
||||||
|
if (pair != null) {
|
||||||
|
return pair.getKey();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addStore(Long storeId, Metapb.Store store) {
|
||||||
|
Metapb.Store oldStore = stores.get(storeId);
|
||||||
|
if (oldStore != null && oldStore.equals(store)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
stores.put(storeId, store);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Metapb.Store getStoreById(Long storeId) {
|
||||||
|
return stores.get(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeStore(Long storeId) {
|
||||||
|
stores.remove(storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
groups = new ConcurrentHashMap<>();
|
||||||
|
stores = new ConcurrentHashMap<>();
|
||||||
|
caches = new ConcurrentHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shard getLeader(int partitionId) {
|
||||||
|
KVPair<ShardGroup, Shard> pair = groups.get(partitionId);
|
||||||
|
if (pair != null) {
|
||||||
|
if (pair.getValue() != null) {
|
||||||
|
return pair.getValue();
|
||||||
|
}
|
||||||
|
for (Shard shard : pair.getKey().getShardsList()) {
|
||||||
|
if (shard.getRole() == Metapb.ShardRole.Leader) {
|
||||||
|
pair.setValue(shard);
|
||||||
|
return shard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Shard getLeader(ShardGroup shardGroup) {
|
||||||
|
if (shardGroup != null) {
|
||||||
|
for (Shard shard : shardGroup.getShardsList()) {
|
||||||
|
if (shard.getRole() == Metapb.ShardRole.Leader) {
|
||||||
|
return shard;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLeader(int partitionId, Shard leader) {
|
||||||
|
KVPair<ShardGroup, Shard> pair = groups.get(partitionId);
|
||||||
|
if (pair != null && leader != null) {
|
||||||
|
Shard l = getLeader(partitionId);
|
||||||
|
if (l == null || leader.getStoreId() != l.getStoreId()) {
|
||||||
|
ShardGroup shardGroup = pair.getKey();
|
||||||
|
ShardGroup.Builder builder = ShardGroup.newBuilder(shardGroup).clearShards();
|
||||||
|
for (var shard : shardGroup.getShardsList()) {
|
||||||
|
builder.addShards(
|
||||||
|
Shard.newBuilder()
|
||||||
|
.setStoreId(shard.getStoreId())
|
||||||
|
.setRole(shard.getStoreId() == leader.getStoreId() ?
|
||||||
|
Metapb.ShardRole.Leader : Metapb.ShardRole.Follower)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
pair.setKey(builder.build());
|
||||||
|
pair.setValue(leader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import org.apache.hugegraph.pd.common.Useless;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.Query;
|
||||||
|
|
||||||
|
@Useless
|
||||||
|
public interface Discoverable {
|
||||||
|
|
||||||
|
NodeInfos getNodeInfos(Query query);
|
||||||
|
|
||||||
|
void scheduleTask();
|
||||||
|
|
||||||
|
void cancelTask();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,223 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.hugegraph.pd.client;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Timer;
|
||||||
|
import java.util.TimerTask;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.apache.hugegraph.pd.common.PDException;
|
||||||
|
import org.apache.hugegraph.pd.common.Useless;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.DiscoveryServiceGrpc;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.NodeInfo;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.NodeInfos;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.Query;
|
||||||
|
import org.apache.hugegraph.pd.grpc.discovery.RegisterInfo;
|
||||||
|
|
||||||
|
import io.grpc.ManagedChannel;
|
||||||
|
import io.grpc.ManagedChannelBuilder;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Useless
|
||||||
|
@Slf4j
|
||||||
|
public abstract class DiscoveryClient implements Closeable, Discoverable {
|
||||||
|
|
||||||
|
private final Timer timer = new Timer("serverHeartbeat", true);
|
||||||
|
private final AtomicBoolean requireResetStub = new AtomicBoolean(false);
|
||||||
|
protected int period; //心跳周期
|
||||||
|
LinkedList<String> pdAddresses = new LinkedList<>();
|
||||||
|
ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
||||||
|
private volatile int currentIndex; // 当前在用pd地址位置
|
||||||
|
private int maxTime = 6;
|
||||||
|
private ManagedChannel channel = null;
|
||||||
|
private DiscoveryServiceGrpc.DiscoveryServiceBlockingStub registerStub;
|
||||||
|
private DiscoveryServiceGrpc.DiscoveryServiceBlockingStub blockingStub;
|
||||||
|
|
||||||
|
public DiscoveryClient(String centerAddress, int delay) {
|
||||||
|
String[] addresses = centerAddress.split(",");
|
||||||
|
for (int i = 0; i < addresses.length; i++) {
|
||||||
|
String singleAddress = addresses[i];
|
||||||
|
if (singleAddress == null || singleAddress.length() <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
pdAddresses.add(addresses[i]);
|
||||||
|
}
|
||||||
|
this.period = delay;
|
||||||
|
if (maxTime < addresses.length) {
|
||||||
|
maxTime = addresses.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private <V, R> R tryWithTimes(Function<V, R> function, V v) {
|
||||||
|
R r;
|
||||||
|
Exception ex = null;
|
||||||
|
for (int i = 0; i < maxTime; i++) {
|
||||||
|
try {
|
||||||
|
r = function.apply(v);
|
||||||
|
return r;
|
||||||
|
} catch (Exception e) {
|
||||||
|
requireResetStub.set(true);
|
||||||
|
resetStub();
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ex != null) {
|
||||||
|
log.error("Try discovery method with error: {}", ex.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 按照pd列表重置stub
|
||||||
|
*/
|
||||||
|
private void resetStub() {
|
||||||
|
String errLog = null;
|
||||||
|
for (int i = currentIndex + 1; i <= pdAddresses.size() + currentIndex; i++) {
|
||||||
|
currentIndex = i % pdAddresses.size();
|
||||||
|
String singleAddress = pdAddresses.get(currentIndex);
|
||||||
|
try {
|
||||||
|
if (requireResetStub.get()) {
|
||||||
|
resetChannel(singleAddress);
|
||||||
|
}
|
||||||
|
errLog = null;
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
requireResetStub.set(true);
|
||||||
|
if (errLog == null) {
|
||||||
|
errLog = e.getMessage();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (errLog != null) {
|
||||||
|
log.error(errLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 按照某个pd的地址重置channel和stub
|
||||||
|
* @param singleAddress
|
||||||
|
* @throws PDException
|
||||||
|
*/
|
||||||
|
private void resetChannel(String singleAddress) throws PDException {
|
||||||
|
|
||||||
|
readWriteLock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
if (requireResetStub.get()) {
|
||||||
|
while (channel != null && !channel.shutdownNow().awaitTermination(
|
||||||
|
100, TimeUnit.MILLISECONDS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
channel = ManagedChannelBuilder.forTarget(
|
||||||
|
singleAddress).usePlaintext().build();
|
||||||
|
this.registerStub = DiscoveryServiceGrpc.newBlockingStub(
|
||||||
|
channel);
|
||||||
|
this.blockingStub = DiscoveryServiceGrpc.newBlockingStub(
|
||||||
|
channel);
|
||||||
|
requireResetStub.set(false);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new PDException(-1, String.format(
|
||||||
|
"Reset channel with error : %s.", e.getMessage()));
|
||||||
|
} finally {
|
||||||
|
readWriteLock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 获取注册节点信息
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public NodeInfos getNodeInfos(Query query) {
|
||||||
|
return tryWithTimes((q) -> {
|
||||||
|
this.readWriteLock.readLock().lock();
|
||||||
|
NodeInfos nodes;
|
||||||
|
try {
|
||||||
|
nodes = this.blockingStub.getNodes(q);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
this.readWriteLock.readLock().unlock();
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
|
}, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 启动心跳任务
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void scheduleTask() {
|
||||||
|
timer.schedule(new TimerTask() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NodeInfo nodeInfo = getRegisterNode();
|
||||||
|
tryWithTimes((t) -> {
|
||||||
|
RegisterInfo register;
|
||||||
|
readWriteLock.readLock().lock();
|
||||||
|
try {
|
||||||
|
register = registerStub.register(t);
|
||||||
|
log.debug("Discovery Client work done.");
|
||||||
|
Consumer<RegisterInfo> consumer = getRegisterConsumer();
|
||||||
|
if (consumer != null) {
|
||||||
|
consumer.accept(register);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
readWriteLock.readLock().unlock();
|
||||||
|
}
|
||||||
|
return register;
|
||||||
|
}, nodeInfo);
|
||||||
|
}
|
||||||
|
}, 0, period);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract NodeInfo getRegisterNode();
|
||||||
|
|
||||||
|
abstract Consumer<RegisterInfo> getRegisterConsumer();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelTask() {
|
||||||
|
this.timer.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
this.timer.cancel();
|
||||||
|
readWriteLock.writeLock().lock();
|
||||||
|
try {
|
||||||
|
while (channel != null && !channel.shutdownNow().awaitTermination(
|
||||||
|
100, TimeUnit.MILLISECONDS)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.info("Close channel with error : {}.", e);
|
||||||
|
} finally {
|
||||||
|
readWriteLock.writeLock().unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue