Compare commits

...

140 Commits

Author SHA1 Message Date
V_Galaxy e1bd70831a
feat(dist): support docker deployment for PD and Store (#2529)
Co-authored-by: imbajin <jin@apache.org>
2024-05-18 23:18:26 +08:00
Hongjun Li 4c6eda8409 chore: config *.md max length (#2525) 2024-04-20 16:14:34 +08:00
Emmanuel Ferdman 4ba5c9dedd fix: update resource references (#2522) 2024-04-20 16:14:30 +08:00
Liu Xiao a534417dd9 chore: make IDEA support IssueNavigationLink and add icon (#2521) 2024-04-20 16:14:27 +08:00
V_Galaxy 9affa6ecd2 fix(server): avoid overriding backend config in gremlin example script (#2519) 2024-04-20 16:14:22 +08:00
V_Galaxy 1d47fd38e2 fix(server): switch rocksdb backend to memory when executing gremlin example (#2518) 2024-04-20 16:14:19 +08:00
imbajin 3ea3fa6623 fix: maven rat plugin exist partial failure
fix: maven rat plugin exist partial failure
2024-04-20 16:14:10 +08:00
V_Galaxy 4d11dd5e05
fix(pd-store): reset previous unexpected cherry-pick for `TaskManager` (#2511) 2024-04-07 19:33:54 +08:00
Peng Junzhi 301e99b008 chore: remove required ci with java8 (#2503) 2024-04-03 23:20:40 +08:00
Simon Cheung 7aedba253a chore: add swagger-ui LICENSE relative files (#2495)
* Create LICENSE-swagger-ui.txt
* Update NOTICE
2024-04-03 21:05:47 +08:00
imbajin 2843d4c78e chore: upgrade to 1.3.0 (last major version support Java8)
fix
2024-04-03 21:05:41 +08:00
V_Galaxy 50ae4dee72
chore(pd): refactor and fix pd tests (#2492)
* fix: StoreServiceTest
2024-04-03 19:06:37 +08:00
imbajin 08e0f6486a refact: enhance auth logic
fix
2024-03-22 16:03:53 +08:00
imbajin dcc335fc3e fix: multi graph error in rocksdb with same path/fd 2024-03-22 16:03:50 +08:00
SunnyBoy-WYH 6d04e9b5cb chore(server): clear context after req done (#2470)
Co-authored-by: vaughn.zhang <vaughn.zhang@zoom.us>
Co-authored-by: imbajin <jin@apache.org>
2024-03-19 17:45:24 +08:00
V_Galaxy 67aba571cc
fix(pd-store): intro `Useless` annotation & refactor and mark the failed tests in `hg-pd-test` (#2480)
* add value for Useless annotation

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-19 15:58:56 +08:00
V_Galaxy f34b528885
feat(pd-store): added the OpenTelemetry trace support for pd-store (#2479) 2024-03-16 20:14:09 +08:00
Bond d56ad10105 feat: added the OpenTelemetry trace support (#2477)
TODO: we need enhance our shell experience
---------

Co-authored-by: imbajin <jin@apache.org>
Co-authored-by: VGalaxies <vgalaxies@apache.org>
2024-03-15 20:31:30 +08:00
vaughn f4edfe3692 fix(auth): enhance the URL check (#2422)
Co-authored-by: imbajin <jin@apache.org>
2024-03-09 21:09:33 +08:00
V_Galaxy bdb64767ca fix(server): 'serverStarted' error when execute gremlin example (#2473) 2024-03-05 16:00:44 +08:00
SunnyBoy-WYH c74ec03a27 fix(server): fix the bug which promtheus cant collect hg metric (#2462) 2024-03-05 14:03:00 +08:00
SunnyBoy-WYH 6565a22137 fix(server): add tip for gremlin api NPE with empty query (#2467)
fix #2426
2024-03-02 01:24:23 +08:00
sheli00 a199534b89
fix(pd-store): fix hstore backend api tests failure (#2463) 2024-03-01 17:16:12 +08:00
Hongjun Li 044fd091a6 chore: Add a newline formatting configuration and a comment for warning (#2464)
- Add a newline formatting configuration
- Add a comment for the IDEA unsupported warning about `continuation_indent_size`
2024-02-29 20:39:20 +08:00
Peng Junzhi 6db8b08f14
fix(pd-store): fix hstore backend core tests failure (#2431)
After this commit, the core tests of hstore expect the following tests to fail:

```text
Failures:
  EdgeCoreTest.testScanEdgeInPaging:5214 expected:<18> but was:<0>
  MultiGraphsTest.testCopySchemaWithMultiGraphs:121
  VertexCoreTest.testAddOlapRangeAndOlapSecondaryProperties:2491 expected:<1> but was:<0>
  VertexCoreTest.testAddOlapRangeProperties:2344 expected:<1> but was:<0>
  VertexCoreTest.testAddOlapSecondaryProperties:2254 expected:<1> but was:<0>
  VertexCoreTest.testQueryOlapRangeAndRegularSecondaryProperties:2638 expected:<1> but was:<0>
  VertexCoreTest.testQueryOlapWithUpdates:2725 expected:<1> but was:<0>
  VertexCoreTest.testScanVertexInPaging:7606 expected:<10> but was:<1>
Errors:
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithMoreFields:3912 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithMoreFieldsInPage:4131 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithPrefix:3704 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithPrefixInPage:3800 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithRange:3607 » HgStoreClient ...
  MultiGraphsTest.testCreateGraphWithSameNameDifferentBackends:289->openGraphWithBackend:381 » Runtime
  RamTableTest.testReloadAndQuery:112 » Huge Failed to load ramtable
  RamTableTest.testReloadAndQueryWithBigVertex:369 » Huge Failed to load ramtabl...
  RamTableTest.testReloadAndQueryWithMultiEdges:239 » Huge Failed to load ramtab...
  RamTableTest.testReloadAndQueryWithProperty:444 » Huge Failed to load ramtable
  RamTableTest.testReloadFromFileAndQuery:159 » Huge Failed to load ramtable
  VertexCoreTest.testQueryByPropertyInPageWithLimitGtPageSize:8337 » IllegalArgument
  VertexCoreTest.testQueryByRangeIndexInPage:8568 » IllegalArgument Undefined in...
  VertexCoreTest.testQueryBySingleRangePropertyInPage:8423 » IllegalArgument Und...
```

---------

Co-authored-by: VGalaxies <vgalaxies@apache.org>
2024-02-27 17:42:59 +08:00
Hongjun Li 198f7004ae chore: refine the hg-style.xml specification (#2457)
- Change the maximum wrap text length for XML to 120 (via `hg-style.xml`)
- Add a blank line between method definitions, inner class definitions, and static code blocks (via `hg-style.xml`)
- Add `<p>` tags to Javadoc blank lines (via `hg-style.xml`)
- `.xml` file leaves a blank line at the end (via `.editorconfig`)
- Class declaration requires a blank line before and after each line (via `hg-style.xml`)
- Javadoc line comment not in line (via `hg-style.xml`)
- `.properties` file leaves empty lines (via `hg-style.xml`)
- `.yaml` file braces `{}`, brackets `[]` remove spaces (via `hg-style.xml`)
2024-02-27 12:55:17 +08:00
Z-HUANT 3b9507001e feat(api): optimize adjacent-edges query (#2408)
Relevant issue: #2255

Gremlin Query: For adjacency edge queries, if a vertex does not belong to the adjacent vertices of this edge, filter out that vertex.

---------

Co-authored-by: imbajin <jin@apache.org>
2024-02-26 18:25:41 +08:00
Jermy Li 74cf3109ec chore: unify to call SchemaLabel.getLabelId() (#2458)
Change-Id: I31bcc0d1ee99f3c443f8f4f0d458e06ca89977ef
2024-02-25 15:08:07 +08:00
M 02c9b4eac0 fix(server): remove extra blank lines (#2459)
* remove extra blank lines in api

* remove extra blank lines in core

* remove extra blank lines in scylladb
2024-02-25 15:07:28 +08:00
V_Galaxy 9fc3788d9c chore: improve license header checker confs and pre-check header when validating (#2445)
* improve license header checker confs

* typo

* verify -> validate

* update rat exclude files

* empty commit

* update rat exclude files

* update rat exclude files
2024-02-23 16:58:01 +08:00
V_Galaxy 168cf69ac7 fix: protobuf file header (#2448) 2024-02-23 16:46:52 +08:00
M b7f8b56730 fix(server): clean up the code (#2456)
- replace `size() == 0` with `isEmpty()`
- remove unnecessary unboxing
- remove unnecessary boxing
- replace for loop with enhanced for loop
- replace lambda with method reference
2024-02-22 17:28:43 +08:00
M 5551ec17f2 fix: format and clean code in modules (#2439)
Format & clean code in submodels:

1. API
2. Scylladb
3. Postgresql
4. Rocksdb
5. Palo
6. Mysql
7. Hbase
8. Cassandra
9. Test

---------

Co-authored-by: imbajin <jin@apache.org>
2024-02-20 21:55:19 +08:00
M 960b7330fd fix: format and clean code in core module (#2440) 2024-02-20 21:54:58 +08:00
M 721111d11a fix: format and clean code in dist and example modules (#2441) 2024-02-20 18:55:58 +08:00
V_Galaxy d61aaae44f
fix(pd-store): correct license in hugegraph-pd (#2446)
* fix: correct license in hugegraph-pd

* minor fix

* add header for protobuf files
2024-02-20 18:28:35 +08:00
V_Galaxy e4bd6446f0
fix(pd-store): correct license in hugegraph-store (#2447)
* fix: correct license in hugegraph-store

* add header for protobuf files

* remove mvnw
2024-02-20 18:25:48 +08:00
M 92f2ecb5e7 fix(server): unify the license headers (#2438)
subtask of #2435

---------

Co-authored-by: imbajin <jin@apache.org>
Co-authored-by: VGalaxies <vgalaxies@apache.org>
2024-02-07 13:41:00 +08:00
VGalaxies 7b14857828 fix: construct PdMetaDriver and pd-store log confs 2024-02-04 11:37:39 +08:00
V_Galaxy bc9c1e7ac9
chore(pd-store): minor improvement (#2443) 2024-02-04 11:17:06 +08:00
VGalaxies d4a20a120a chore: sync adapted code to internal 4.0 version
only the code within hugegraph-core module
2024-02-03 22:04:21 +08:00
Peng Junzhi b06779aed6 fix(server): make CacheManager constructor private to satisfy the singleton pattern (#2432) 2024-02-03 22:03:14 +08:00
SunnyBoy-WYH ec3779c709 chore(server): update swagger info for default server profile (#2423) 2024-01-29 23:25:22 +08:00
Dandelion 70150ad448 fix(chore): remove zgc in dockerfile for ARM env (#2421)
* remove zgc

* Apply suggestions from code review

Co-authored-by: imbajin <jin@apache.org>

* add comment for hugegraph-server.sh

* fix enable-auth.sh

* init store in entrypoint

* use flag file to skip re-init

* delete tar.gz

* simply dockerfile

* mvn optimize

* simply dockerfile

* add init log in docker

---------

Co-authored-by: imbajin <jin@apache.org>
2024-01-29 23:24:25 +08:00
V_Galaxy 46cb612eb5
fix(pd-store): partially fix hstore backend core tests failure (#2424)
Some tests that are currently failing (not addressed in this PR):

1. Tests related to **olap** in `VertexCoreTest`: Not adapted yet.
2. Tests related to **paging** in `VertexCoreTest` and `EdgeCoreTest`: Inconsistency in the definition of `position` between RocksDB scan iterator and Hstore.
3. Some `RamTableTest` test cases: The ramtable feature is not supported by the hstore backend.
2024-01-29 22:49:48 +08:00
Peng Junzhi 499f8e74b5
fix(server): starting error of server (#2419)
1. When starting hugegrpah-server in idea, we will encounter an error: `java.lang.ClassNotFoundException: io.grpc.stub.AbstractBlockingStub`. We should remove the `<scope>` line in pom to avoid that.

2. Add dependency support for arm-architecture machine
2024-01-18 12:15:26 +08:00
Z-HUANT 12ff9154ab fix(server): reinitialize the progress to set up graph auth friendly (#2411) 2024-01-17 23:56:27 +08:00
Dandelion 94a79326ea feat: support docker use the auth when starting (#2403)
- allow user to set env for docker to set auth mode
- download keystore when package
- fix a curl error (also use curl first in `function` download)

---------

Co-authored-by: imbajin <jin@apache.org>
2024-01-16 02:00:49 +08:00
V_Galaxy e11dc8e5f3
chore(pd-store): cherry-pick commits from master for synchronization & some modifications for passing partial hstore tests (#2414) 2024-01-16 01:21:27 +08:00
VGalaxies dd44f701f5 fix: TaskScheduler.delete test caller sets the force parameter to false 2023-11-10 19:45:41 +08:00
V_Galaxy 8b3624aa03 refact: adjust project structure for merge PD & Store[Breaking Change] (#2338)
Subtask of #2265.

Adjust the project structure of this repository to include three sub-modules: hugegraph-server, hugegraph-pd, hugegraph-store at the root level.

Roll back to the moment when https://github.com/apache/incubator-hugegraph/pull/2266 was merged on `pd-store` and incorporate the latest changes in `master`.

For more detailed information, please refer to https://github.com/apache/incubator-hugegraph/pull/2266#issue-1834369489.

---------

Co-authored-by: M <87920097+msgui@users.noreply.github.com>
2023-11-10 19:45:41 +08:00
SunnyBoy-WYH 896d943538 feat(api): support recording slow query log (#2327)
* chore(api): code style for cr

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
SunnyBoy-WYH 73bf6607fd chore(api): add swagger desc for Arthas & Metric & Cypher & White API (#2337)
add swagger belong for arthas API

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
lzyxx ee0299e6d3 feat(cassandra): adapt cassandra from 3.11.12 to 4.0.10 (#2300) 2023-11-10 19:45:41 +08:00
VGalaxies 785d387294 chore: move RamIntObjectMapTest.java 2023-11-10 19:45:41 +08:00
conghuhu e705740e1e fix(core): handle schema Cache expandCapacity concurrent problem (#2332) 2023-11-10 19:45:41 +08:00
Wu Chencan 94edfcd720 feat(core): support batch+parallel edges traverse (#2312)
- Enhance Consumers.java, supporting ExceptionHandle and `Future` to handle InterruptedException when awaiting
- Add Nested Iterator Edge and support batch execution
- Support batch execution & thread parallel in KoutTraverser and Kneighbor
2023-11-10 19:45:41 +08:00
Dandelion 263bb2feb4 fix: always wait for storage if rocksdb is selected (#2333) 2023-11-10 19:45:41 +08:00
Dandelion 87509b8a99 feat: support Cassandra with docker-compose in server (#2307)
1. change the dockerfile, adding the shell to wait for storage backend and use a docker-entrypoint.sh to manage the starting process.
2. delete a deprecated class in  gremlin-console.sh (reference: [doc of ScriptExecutor](https://tinkerpop.apache.org/javadocs/3.2.3/full/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptExecutor.html))
3. add a healthy check in docker-compose
4. add an example folder where we can put all the template docker-compose.yml here
5. add `*swagger-ui*` in gitignore, which appears after you compile the source code locally.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
Dandelion 785afe05ba doc: README.md tiny improve (#2331) 2023-11-10 19:45:41 +08:00
SunnyBoy-WYH 8115325d9a feat(api): support embedded arthas agent in hugegraph-server (#2278) 2023-11-10 19:45:41 +08:00
Jermy Li 5a064de05a README.md tiny improve (#2320) 2023-11-10 19:45:41 +08:00
SunnyBoy-WYH 176637c47a feat(api): support metric API Prometheus format & add statistic metric api (#2286) 2023-11-10 19:45:41 +08:00
SunnyBoy-WYH 4bb48814bb feat: support White IP List (#2299)
tips:
- this feat works when auth mode was set.
- this feat works when white ip status was enabled.

because now PD is unavailable,just use java list; when pd ready , we can checkout pd.
2023-11-10 19:45:41 +08:00
Dandelion b116fc8a21 doc: update README about start server with example graph (#2315) 2023-11-10 19:45:41 +08:00
M 10c570d368 fix: base-ref/head-ref missed in dependency-review on master (#2308) 2023-11-10 19:45:41 +08:00
Wu Chencan 9c2d3ad6d3 feat(api-core): support label & property filtering for both edge and vertex & support kout dfs mode (#2295)
- Support label & property filtering for both edge and vertex and the filtering is implemented in Kout Post and Kneighbor - Post Apis, reducing unnecessary graph searches through pruning
- Support Kout dfs mode in Kout Post Api

Originally only edge label filtering was supported, now label and property filtering for edge and vertex is supported.
- add classes VEStepEntity and VEStep to support serialization in request
- add class Steps to support filtering of edge and vertex in runtime(core)
- add new method edgesOfVertex(Id source, Steps steps) to support label and property filtering for both edge and vertex in HugeTraverser.java

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
Dandelion 4ad54181b4 fix(dist): avoid var PRELOAD cover environmnet vars (#2302)
Update hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
Chong Shen 51df7ec871 fix(core): close flat mapper iterator after usage (#2281)
close [Bug] FlatMapperIterator should be closed after usage #2280
2023-11-10 19:45:41 +08:00
Dandelion 1bac480710 feat(dist): support pre-load test graph data in docker container (#2241)
- Provide the related conf and groovy for user to pre load some data.
- Change the start-hugegraph.sh to get the environment variables to decide to pre-load or not.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
V_Galaxy d5fa5c8e33 chore(dist): replace wget to curl to download swagger-ui (#2277)
Main Changes:
1. replace `wget` by `curl` when downloading `swagger-ui`
2. silence the output of `curl` and `tar` commands
3. reuse the existing `v4.15.5.tar.gz` before downloading
4. avoid downloading `swagger-ui` in non-Linux platforms to prevent build failures (there might be a cross-platform build approach available 🤔)
5. wrapp the script content within `<![CDATA[ ... ]]>` blocks ensures that the script retains its original format when generating the `dist.sh` script (also suppresses automatic indentation)
6. remove intermediate files at the end of the script

**An alternative approach**, during the generation of the `dist.sh` script, only the `${final.name}` property from the build process is utilized. It might be possible to separately store a `dist.sh` script within hugegraph-dist, then use `sed` during the build process to replace the value of `${final.name}`, **thereby avoiding the need to embed script content within the pom file**.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-11-10 19:45:41 +08:00
lzyxx 07b7243efe fix checkstyle: Update StandardStateMachineCallback.java (#2290)
During the compilation of your code, an informational message was displayed indicating an issue with the file /home/lzy/hugegraph/hugegraph-core/src/main/java/org/apache/hugegraph/masterelection/StandardStateMachineCallback.java at line 36. The specific problem was that the length of this line exceeded 100 characters, with a total of 101 characters.

To address this issue, I have made modifications to this class. I have split the originally long line into multiple lines to ensure that each line's length adheres to the coding standards' specified limits. This action not only aligns with the requirements of the code style, but also improves the readability and maintainability of the code.
2023-11-10 19:45:41 +08:00
DanGuge c7054e0704 feat(api&core): in oltp apis, add statistics info and support full info about vertices and edges (#2262)
* chore: improve gitignore file

* feat: add ApiMeasure to collect runtime data

ApiMeasure will count the number of vertices and edges traversed at runtime, and the time the api takes to execute

* feat: Add ApiMeasure to JsonSerializer and Modify the Serializer interface

* JsonSerializer: return measure information in api response

* Serializer: fit the feature that returns complete information about vertices and edges

* refactor: format code based on hugegraph-style.xml

* feat: Add statistics information in all oltp restful apis response and Support full information about vertices and edges

Statistics information:

* add vertexIterCounter and edgeIterCounter in HugeTraverser.java to track traversed vertices and edges at run time

* modify all oltp restful apis to add statistics information in response

Full information about vertices and edges:

* add 'with_vertex' and 'with_edge' parameter option in apis

* modify oltp apis to support vertex and edge information in api response

* add EdgeRecord in HugeTraverser.java to record edges at run time and generate the edge information returned in api response

* modify Path and PathSet in HugeTraverser.java to support full edge information storage

* modify all traversers to support track of edge information at run time

* fix: numeric cast

* fix: Jaccard Similarity api test

* fix: adjust the code style and naming convention

* Empty commit

* Empty commit

* fix:
1. change System.currentTimeMillis() to System.nanoTime();
2. modify addCount()

* fix: rollback change in .gitignore

* fix: rollback ServerOptions.java code style

* fix: rollback API.java code style and add exception in else branch

* fix: fix code style

* fix: name style & code style
* rename edgeRecord to edgeResults
* fix Request class code style in SameNeighborsAPI.java
2023-11-10 19:45:41 +08:00
V_Galaxy c13b4e2b3a
fix: check leader role before setPdConfig (#2341) 2023-11-03 17:09:45 +08:00
Simon Cheung 823b1902eb
fix(pd): log4j version conflict & follower NPE (#2339)
* fix: log4j version conflict

* Update RaftRpcClient.java
2023-10-30 16:32:59 +08:00
V_Galaxy fe7697e9a7
chore: enhance a string of problems to pass CI (#2321)
## Main Changes

- fix license header (from https://github.com/apache/incubator-hugegraph/pull/2303)
	- remove maven wrapper in pd and store
- remove java 8 CI in `ci.yml` (not support java 8 in HugeGraph 1.5.0)
- add `pd-store.yml` for pd, store, hstore UT
- collect the test files from pd into the `hg-pd-test` module, the same for store
	- except for `hg-pd-service`, `hg-store-node`, `hg-store-rocksdb`

## TODO

- [ ] dependency-check (update the `known-dependencies.txt` file in `hugegraph-server/hugegraph-dist/scripts/dependency/`)
	- [ ] With the change in project structure, some scripts in `hugegraph-server/hugegraph-dist` may need to be relocated to the appropriate locations. 🤔
- [ ] `hugegraph-server/hugegraph-dist/src/assembly/jenkins/`
2023-10-16 16:01:10 +08:00
V_Galaxy f34743b5fb
feat: preliminary support for distributed task scheduler (#2319)
* chore: migrate DistributedTaskScheduler

* fix: basic setup for DistributedTaskScheduler

* chore: set default scheduler type to local

* chore: code style

* chore: code style

* fix: impl checkRequirement for DistributedTaskScheduler

* chore: add comment for task server id

* fix: task result vertex type

* chore: review

* fix: StandardClusterRoleStore queryVertex

* chore: add comment

duplicated commit in hstore for clusterRole
2023-10-16 11:22:50 +08:00
V_Galaxy b670c01002
feat: preliminary support for hstore backend (#2301)
* chore: move hugegraph-hstore

* chore: simple adapt

* chore: register hstore

* build: intro grpc dep

* chore: migrate org.apache.hugegraph.meta

* chore: migrate org.apache.hugegraph.space

* chore: adapt meta schema

* chore: migrate SchemaTransactionV2

* chore: adapt SchemaTransactionV2

* refact: intro ISchemaTransaction for adaptation

* fix: init meta server

* fix: avoid typecast from UnmodifiableRandomAccessList

class java.util.Collections cannot be cast to class java.util.ArrayList

* refact: query task and server info by graph tx

* fix: register task and server table for rocksdb BE

* chore: add example for hstore BE scanning tables

* fix: register task and server table for other BEs

* build: remove system dependency to hugegraph-core in hg-store-core

* chore: remove author comments

* chore: remove AbstractDistributedLock class and lock method

* chore: replace HashMap with ImmutableMap

* chore: code review

* chore: load driver version in graph store for hstore

* fix: index serialization and deserialization logic

* fix: convertTaskOrServerToVertex for other BEs

* chore: init meta server in ctor of StandardHugeGraph

* chore: add comments for lock module

---------

Co-authored-by: heiyan <heiyan2020@gmail.com>
2023-09-18 17:17:37 +08:00
M 0903e900e4
feat: support visit of stage repository (#2305)
* add: stage repository

* feat: enable user access to stage repo

* feat: support jdk8 compilation, exclude jdk11-only modules

* fix:  jdk version

* fix:apply suggestions

Co-authored-by: imbajin <jin@apache.org>

* Update pom.xml

---------

Co-authored-by: imbajin <jin@apache.org>
2023-09-06 22:22:27 +08:00
V_Galaxy c70a2944b0
fix: assemble executable jar for pd and store (#2289)
Due to the change of hugegraph-pd's parent from spring-boot-starter-parent to hugegraph, and hugegraph's parent being apache, along with modifications to the artifactId of certain sub-modules (for example, hugegraph-pd to hg-pd-service), the following steps need to be taken:

Modify the descriptor of the maven-assembly-plugin, which involves adjusting the collected jar package names accordingly.
- Update the corresponding jar package names in the startup script.
- Since hugegraph-pd is started using Spring Boot, the spring-boot-maven-plugin needs to be reconfigured.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-08-29 18:43:36 +08:00
M d6a2548427
fix(server): github ci for submodule "server" (#2288) 2023-08-21 19:15:00 +08:00
Yuexuan Zhang b19aa30454
refact: adjust pom structure for directly compiling from root (#2275)
* build: remove unused deps in hugegraph-pd

* chore: add compiled hugegraph-core.jar as dependency

* chore: remove unused dependency.

* fix: change hugegraph-core scope type in hg-store-node

* build: unify revision to 1.5.0.1

* chore: clean swagger files

---------

Co-authored-by: V_Galaxy <1904821183@qq.com>
Co-authored-by: imbajin <jin@apache.org>
2023-08-11 18:36:53 +08:00
V_Galaxy dfd3c6700e
refact: merge store into hugegraph (#2272)
also fix maven-clean-plugin dist dir clean
2023-08-08 17:41:36 +08:00
imbajin 7e9b8afbc6
refact(store): merge branch 'pr/2272' into pd-store 2023-08-08 17:20:34 +08:00
imbajin 4f34d01eb2
refact(pd): merge branch 'pr/2270' into pd-store 2023-08-08 17:11:46 +08:00
imbajin eb76bc62a0
chore: allow merge for a string of commits/PR 2023-08-08 10:41:58 +08:00
imbajin c72bda6237
Merge branch 'pd-store' into merge-store 2023-08-07 23:26:28 +08:00
V_Galaxy a891780c36
refact: merge pd into hugegraph (#2270)
* init(pd): history merged until 2023.5.6

* refact: unify LF line separator

Change-Id: I3f38685af534468a51b79b7f45d24fdb30a74f34

* refact: add header & format in test & service & grpc & dist modules

Change-Id: Id2fa1374d7fa85635906a7e75655e7dad56f1807

* refact: add header/format in core & common & clitools & client modules

Change-Id: Id8ec0a0d754f646c59f7251158dd89de669b2016

* refact: format root/parent modules & pd-service package name & rearrange code

Change-Id: Id8ec0a0d754f646c59f7251158dd89de669b2016

* chore: search & replace to "org.apache" manually

- also replace "a/b/c" regrex
- replace pom version to ${revision}

Change-Id: Ia3a9ce891fcff58cef4a5a1f95adb44ef8ee8049

* chore: fix some code problems

- lack this with instance filed
- lack {} in 'if/while/for'

Change-Id: I37d21f1ab94529a8122f4598636fbe02b2264904

* refact: update code to Jun2 2023

GraphPlatform-2020 fix cache bug when direct put

Change-Id: I52428d8d5d4bb977ee7796c0fe1e4ced07aff12d

GraphPlatform-2020 fix cache bug when direct put

Change-Id: Id57427a94732e12f2d96429a2b677d5c5f71e8ff

GraphPlatform-1771 update code

Change-Id: Ic3b95ca22900453adbc3571734e1da2c97e28355

* build: add flatten plugin and fix dependency version

1. Added the
[flatten](https://github.com/apache/incubator-hugegraph/pull/2004)
plugin.
2. Unified the global version to 1.5.0.
3. Modified the version of `jraft-core`.

---------

Co-authored-by: imbajin <jin@apache.org>

* build: fix build for community edition compatibility (WIP)

Please refer to
https://hugegraph.feishu.cn/wiki/Y6d2wys9KiWf24kpzNKct0Yknnr for
detailed fix documentation.

---------

Co-authored-by: imbajin <jin@apache.org>

* refact: adapt for jraft v1.3.13

* refact: GP-2141 handle low speed import - 6.9

from inner commit 0a95b1e587e65ea6a0a06774d53c80868f36af5b

---------

Co-authored-by: V_Galaxy <1904821183@qq.com>

* refact: GP-2141 handle low speed import - Compile OK

from inner commit 0a95b1e587e65ea6a0a06774d53c80868f36af5b

fix store compile problem
https://hugegraph.feishu.cn/wiki/Y6d2wys9KiWf24kpzNKct0Yknnr

---------
Co-authored-by: V_Galaxy <1904821183@qq.com>

* chore: enhance pom & start file

---------

Co-authored-by: V_Galaxy <1904821183@qq.com>

* refact: prepare before merge

* chore: fix pom for submodules in hugegraph-pd

* chore: add apache-rat-plugin for hugegraph-pd

and add some license headers

* chore: clean some comment/code

---------

Co-authored-by: imbajin <jin@apache.org>
Co-authored-by: What is broken can be reforged <34939118+GYXkeep@users.noreply.github.com>
2023-08-07 23:15:28 +08:00
V_Galaxy 84273f2093
chore: clean some comment/code 2023-08-07 18:07:00 +08:00
V_Galaxy 497d62eefe chore: clean some comment/code 2023-08-07 17:07:26 +08:00
V_Galaxy 1234c110e7 chore: add apache-rat-plugin for hugegraph-pd
and add some license headers
2023-08-07 16:09:32 +08:00
V_Galaxy cbdd65a06f chore: fix pom for submodules in hugegraph-pd 2023-08-07 16:08:57 +08:00
V_Galaxy e78eb82b6a chore: add apache-rat-plugin for hugegraph-store
and add some license headers
2023-08-07 15:31:25 +08:00
V_Galaxy 02c36d848e chore: fix pom for submodules in hugegraph-store 2023-08-07 15:22:14 +08:00
V_Galaxy 51ca58746d Merge branch 'store' into merge-store 2023-08-07 15:06:00 +08:00
V_Galaxy 8923b5d6e0 refact: prepare before merge 2023-08-07 15:02:59 +08:00
V_Galaxy 84d8beb7e0 fix: mismatch table name when parsing BatchEntry
fix https://github.com/hugegraph/store/pull/4

When the server uses hstore as the backend, taking writing a vertex as
an example. The server will construct an `HgStoreSession` using
graphspace and graph, like `DEFAULT/hugegraph/g`.

Then it calls the `put` method of `HgStoreSession`, passing the
corresponding table (here it is `g+v`), key, and value.

```java
@Override
public void put(String table, byte[] ownerKey, byte[] key, byte[] value) {
    prepare();
    this.graph.put(table, HgOwnerKey.of(ownerKey, key), value);
}
```

The store client will encapsulate this write operation as an RPC request
in the following format:

```protobuf
message BatchEntry {
  OpType op_type = 1;
  int32 table = 2; // NOTE HERE
  Key start_key = 3;
  Key end_key = 4;
  bytes value = 5;
}
```

https://github.com/hugegraph/store/pull/4 actually fixes the logic that
maps `g+v` to the corresponding code.

However, after receiving `BatchEntry`, the store still needs to parse
the corresponding table name based on the code.

```java
default void doBatch(String graph, int partId, List<BatchEntry> entryList) {
    BusinessHandler.TxBuilder builder = txBuilder(graph, partId);
    try {
        for (BatchEntry b : entryList) {
            Key start = b.getStartKey();
            String table = tables[b.getTable()]; // NOTE HERE
```

This step was ignored in https://github.com/hugegraph/store/pull/4,
resulting in the actual table being written into the store as `vertex`
(the old table name).
2023-08-07 14:55:03 +08:00
imbajin 61a8bedd70 refact(dist): enhance start-hugegraph-store.sh 2023-08-07 14:55:03 +08:00
imbajin 28bb45d60c fix(client): mismatch store table name when put data
`prepareBatchEntry()` throws NPE, refer
https://hugegraph.feishu.cn/wiki/O07Bw2jnPiJGZbkE9utcw65Xntc

thanks @VGalaxies to fix this problem

Co-authored-by: V_Galaxy <1904821183@qq.com>
2023-08-07 14:55:00 +08:00
imbajin 7b56c40650 fix: update pom config & start script 2023-08-07 14:55:00 +08:00
V_Galaxy cffa495446 build: fix build for community edition compatibility (WIP)
Please refer to
https://hugegraph.feishu.cn/wiki/Y6d2wys9KiWf24kpzNKct0Yknnr for
detailed fix documentation.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-08-07 14:54:55 +08:00
What is broken can be reforged 0cad1fdb45 refact: adopt jraft to open source version
address the
[jraft-doc](https://hugegraph.feishu.cn/wiki/JGy0wPlCsih9XMkjrNMcNfhxnBb)
2023-08-07 14:54:51 +08:00
V_Galaxy 8c03d72744 chore: add flatten plugin and fix dependency version
* build: add flatten plugin and fix dependency version

* Update pom.xml

---------

Co-authored-by: imbajin <jin@apache.org>
2023-08-07 14:54:17 +08:00
V_Galaxy 3910af8f5b Merge branch 'pd' into merge-pd 2023-08-05 23:42:56 +08:00
V_Galaxy 49a1acf3b2 fix: fix parent of submodules in hugegraph-server
modify pom description as well
2023-08-05 23:24:33 +08:00
V_Galaxy fd161f2f15 refact: init root pom for all modules 2023-08-05 23:24:33 +08:00
V_Galaxy 9068cef7e8 refact: create dirs for hugegraph-pd and hugegraph-store 2023-08-05 23:24:33 +08:00
V_Galaxy 3559aced8c refact: move dirs into hugegraph-server 2023-08-05 23:24:33 +08:00
V_Galaxy 7c325c5efd refact: prepare before merge 2023-08-03 19:56:42 +08:00
imbajin a37177207c chore: enhance pom & start file
---------

Co-authored-by: V_Galaxy <1904821183@qq.com>
2023-08-03 19:56:36 +08:00
imbajin ec0b0e006b refact: GP-2141 handle low speed import - Compile OK
from inner commit 0a95b1e587e65ea6a0a06774d53c80868f36af5b

fix store compile problem
https://hugegraph.feishu.cn/wiki/Y6d2wys9KiWf24kpzNKct0Yknnr

---------
Co-authored-by: V_Galaxy <1904821183@qq.com>
2023-08-03 19:56:28 +08:00
imbajin 3ea878c3a8 refact: GP-2141 handle low speed import - 6.9
from inner commit 0a95b1e587e65ea6a0a06774d53c80868f36af5b

---------

Co-authored-by: zhangyingjie02 <zhangyingjie02@baidu.com>
Co-authored-by: V_Galaxy <1904821183@qq.com>
2023-08-03 19:56:21 +08:00
What is broken can be reforged 6092dc0fc1 refact: adapt for jraft v1.3.13 2023-08-03 19:56:15 +08:00
V_Galaxy ed00d4eb29 build: fix build for community edition compatibility (WIP)
Please refer to
https://hugegraph.feishu.cn/wiki/Y6d2wys9KiWf24kpzNKct0Yknnr for
detailed fix documentation.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-08-03 19:56:03 +08:00
V_Galaxy 8ddf8291af build: add flatten plugin and fix dependency version
1. Added the
[flatten](https://github.com/apache/incubator-hugegraph/pull/2004)
plugin.
2. Unified the global version to 1.5.0.
3. Modified the version of `jraft-core`.

---------

Co-authored-by: imbajin <jin@apache.org>
2023-08-03 19:55:52 +08:00
imbajin 6a813d2c06 update code to Jun2 2023
Change-Id: I9a21c17a07c96c42eafc5ffeedfc70b2a77563d2

GraphPlatform-2120 检查channel

Change-Id: I9135b19b2a3bd66f31dcdbcf9169b1884ae934c2

GraphPlatform-2120 处理加锁

Change-Id: I64441d02221e96aa21027faafe90c8b7e04b15d1

GraphPlatform-1749 修复可能导致的死锁问题

Change-Id: Ie5ab9fd62746bfcd77edcaf8881671abee678d31

GraphPlatform-1749 修正pd raft

Change-Id: I31064fa2ce31b677cf044a85645e7244cbbbff26

GraphPlatform-2120 控制pd线程池大小

Change-Id: Ie505f5525bcff79f84c0cd674b92c6abf3a2c03f

GraphPlatform-1749 优化partition cache

Change-Id: I5cafd9078ccc91b7f0b4d9157a3913049c38d8cb

GraphPlatform-1657 rest接口转发到leader

Change-Id: Ib5db654a35733ddead7972d5e4b08b981a89fb31

GraphPlatform-2020 fix cache bug when direct put

Change-Id: I52428d8d5d4bb977ee7796c0fe1e4ced07aff12d

GraphPlatform-2020 fix cache bug when direct put

Change-Id: Id57427a94732e12f2d96429a2b677d5c5f71e8ff

GraphPlatform-1771 update code

Change-Id: Ic3b95ca22900453adbc3571734e1da2c97e28355
2023-06-20 19:51:09 +08:00
imbajin 1252f5097c refact: update the code to 2023.6.19
Change-Id: Ib861b47cab873322d9427d6a1f654f5cae92ddb6

GraphPlatform-1749 修复显示的版本号

Change-Id: I09b072b802d60bf1820f5a6dd18e2570eee4835b

GraphPlatform-1657 修改grpc消息大小参数设置

Change-Id: Ifb51b841c5be7690407cc90b34a72d4b2bdea360

GraphPlatform-1595 调整ci及减少锁粒度

Change-Id: I496c814cac580a51125e382b538eaf57445121dc

FIN GraphPlatform-2141 增加按表查询接口

Change-Id: Iee2d3503d2a7fd4815ecf7dec828afa28a24e46a

GraphPlatform-2147 迭代完成及时释放rocksdb迭代器,部分并发控制改进

Change-Id: I69f3985fd7a29b718f10eb6718488d63e6a1a077

GraphPlatform-2161 PD leader变更,客户端重连

Change-Id: Ibfeb837e94ecc9dfc19e6fdc85b421df725a6cb7

FIN GraphPlatform-2147 处理并发

Change-Id: I7a41969a8689eb216d2a7537a7a2f94846427c0e

FIN GraphPlatform-2140 修改并发控制

Change-Id: I89cbee229c111716b092a6df903aa692be03b9bb

FIN GraphPlatform-2140 并发控制改进

Change-Id: Ie9c7755b330d2df653c7e93b5592a514bb7aa099

GraphPlatform-2119 修改线程默认配置

Change-Id: Ia6107168b381562a767e34443328391e5da1e1a0
2023-06-20 19:07:36 +08:00
imbajin 9ccbeb7de7 fix: delete duplicate file in common commit & fix org name
Change-Id: I8279b2548a7f16599e61f42281f5aea7ceae51a8
2023-05-09 23:56:32 +08:00
chengxin05 33749fddaf GraphPlatform-2060 更改store依赖common更改为开源的org.apache.hugegraph.common包
Change-Id: Ie3997bad153358f251b242cae8de13ff8022976e
2023-05-09 23:45:28 +08:00
imbajin bd3d313a1b chore: fix some code problems
- lack this with instance filed
- lack {} in 'if/while/for'

Change-Id: I37d21f1ab94529a8122f4598636fbe02b2264904
2023-05-06 20:04:30 +08:00
imbajin 4166b6f8ff chore: search & replace to "org.apache" manually
- also replace "a/b/c" regrex
- replace pom version to ${revision}

Change-Id: Ia3a9ce891fcff58cef4a5a1f95adb44ef8ee8049
2023-05-06 19:57:29 +08:00
imbajin fd13bb436b refact: format root/parent modules & pd-service package name & rearrange code
Change-Id: Id8ec0a0d754f646c59f7251158dd89de669b2016
2023-05-06 19:50:02 +08:00
imbajin 61ecb66e8f refact: add header/format in core & common & clitools & client modules
Change-Id: Id8ec0a0d754f646c59f7251158dd89de669b2016
2023-05-06 19:44:31 +08:00
imbajin dd49f3f54b refact: add header & format in test & service & grpc & dist modules
Change-Id: Id2fa1374d7fa85635906a7e75655e7dad56f1807
2023-05-06 19:41:10 +08:00
imbajin 08f560f388 refact: unify LF line separator
Change-Id: I3f38685af534468a51b79b7f45d24fdb30a74f34
2023-05-06 19:21:16 +08:00
V_Galaxy d97ba4cb51 history merged until 2023.5.6 2023-05-06 18:24:23 +08:00
imbajin e79d5f63a1 fix(sec): upgrade version for super high CVE on springboot & mark license TODO
Change-Id: Id30547444de6bea148efd88d51e88cc866f44047
2023-05-05 14:35:22 +08:00
imbajin 7175358fa6 chore: add .gitattributes file to unify line separator & clean pom
Change-Id: I303c98351c2dafda4fbb279dd8dc1056164b8f70
2023-05-05 13:48:09 +08:00
imbajin 34d7516618 refact: remove inner info
Change-Id: I72b468d3aa247ba969eb28a155576a773f2ea084
2023-04-26 13:18:42 +08:00
imbajin a90fc30cde refact: rearrange code position
Change-Id: I3d559de5acadb1815f10622120f1b4f27a740ff1
2023-04-26 13:00:11 +08:00
imbajin c4f4a3c877 fix: lack override annotations & explicit type & CONSTANTs
Change-Id: Iabac67f3beb848567e940647ffc578af56936c7d
2023-04-26 12:50:38 +08:00
imbajin 082d3399de fix: lack brace for if statement & rearrange code
Change-Id: I2ca0b6d5d30740b41a3bcb9db11e50feb32335cd
2023-04-26 12:14:55 +08:00
imbajin 6bce8990af refact: fix all CRLF files to LF together (Breaking Change)
GraphPlatform-1906 梳理入库与查询流程

Change-Id: I5e7f57893c904e50be320e263a01283b147545a8
2023-04-26 11:12:02 +08:00
imbajin 740563bc61 doc: add LICENSE & NOTICE file in root & dist module
Change-Id: I278a4b7bc669270286548959a0952389a49e3371
2023-04-26 11:10:22 +08:00
imbajin 4ec8c3a0f6 refact: add license header for root files & protobuf files
Change-Id: Id277df46c88cc75029b0b3510274df14f732faba
2023-04-26 11:10:09 +08:00
imbajin 0a60f24f9c refact: full search & replace package name
Change-Id: I8f9780523f1e6d022e66f29d36c3deb12be23845
2023-04-26 11:09:41 +08:00
imbajin 7b5c5f87b7 refact: rename pkg for client & common & core & pom.xml
Change-Id: Ieef748324b11b9d125dca915262f80a5954f5f98
2023-04-26 11:09:24 +08:00
imbajin bb081bcfc2 refact: rename package for cli & dist & node & rocksdb & test modules
TODO: some files need update manully
Change-Id: If83118e2dd123a7a88f9c5f7b33fbc7cf1b55de7
2023-04-26 11:08:51 +08:00
imbajin d62386b5a3 refact: handle rpc package alone for other modules
Change-Id: Icd740de03f9572d8d515c3d2237c2c6cb8318af3
2023-04-26 11:08:15 +08:00
V_Galaxy 03b6d3761b history merged until 2023.4.23 2023-04-23 10:41:18 +08:00
1736 changed files with 141899 additions and 18311 deletions

View File

@ -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

View File

@ -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

View File

@ -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

43
.github/configs/settings.xml vendored Normal file
View File

@ -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>

View File

@ -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=

View File

@ -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

View File

@ -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

View File

@ -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

217
.github/workflows/pd-store-ci.yml vendored Normal file
View File

@ -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

View File

@ -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

View File

@ -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

8
.gitignore vendored
View File

@ -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/

BIN
.idea/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

37
.idea/vcs.xml Normal file
View File

@ -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>

View File

@ -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,

View File

@ -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.

View File

@ -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
View File

@ -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
View File

@ -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/]

View File

@ -8,18 +8,17 @@
[![License](https://img.shields.io/badge/license-Apache%202-0E78BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) [![License](https://img.shields.io/badge/license-Apache%202-0E78BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![HugeGraph-CI](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml) [![HugeGraph-CI](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml/badge.svg)](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml)
[![CodeQL](https://github.com/apache/incubator-hugegraph/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/apache/incubator-hugegraph/actions/workflows/codeql-analysis.yml)
[![License checker](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml/badge.svg)](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml) [![License checker](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml/badge.svg)](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml)
[![Codecov](https://codecov.io/gh/apache/incubator-hugegraph/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/incubator-hugegraph)
[![GitHub Releases Downloads](https://img.shields.io/github/downloads/apache/hugegraph/total.svg)](https://github.com/apache/hugegraph/releases) [![GitHub Releases Downloads](https://img.shields.io/github/downloads/apache/hugegraph/total.svg)](https://github.com/apache/hugegraph/releases)
[![stars](https://img.shields.io/github/stars/apache/hugegraph)](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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]
}
}

View File

@ -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
}

View File

@ -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>

View File

@ -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
]
}
}

View File

@ -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]
}
}

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -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>

View File

@ -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
] ]
} }
} }

View File

@ -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

View File

@ -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

View File

@ -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]
}
}

View File

@ -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
}

View File

@ -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>

View File

@ -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
]
}
}

View File

@ -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]
}
}

View File

@ -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

View File

@ -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

58
docker/docker-compose.yml Normal file
View File

@ -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

View File

@ -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();
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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));
}
}

View File

@ -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);
}

View File

@ -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";
}

View File

@ -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 {}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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;
}
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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 {
}

View File

@ -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;
}
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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."

View File

@ -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>

View File

@ -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

View File

@ -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]

1
hugegraph-pd/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=auto eol=lf

11
hugegraph-pd/.gitignore vendored Normal file
View File

@ -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

View File

@ -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"]

5
hugegraph-pd/README.md Normal file
View File

@ -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.

View File

@ -0,0 +1,6 @@
{
"subject": "hugegraph-license",
"public_alias": "publiccert",
"store_ticket": "803b6cc3-d144-47e8-948f-ec8b39c8881e",
"publickey_path": "/public-certs.store"
}

View File

@ -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>

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}
}
}

View File

@ -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();
}

View File

@ -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