forked from hugegraph/hugegraph-sync
Compare commits
651 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0b794c9ab9 | |
|
|
7be8e6b1dd | |
|
|
0b24aca3cd | |
|
|
f88fad4711 | |
|
|
a767d73182 | |
|
|
0a0f2c3bfa | |
|
|
7dc6a86a7d | |
|
|
b087f085c1 | |
|
|
58f58ee094 | |
|
|
ba5b89e374 | |
|
|
1c577de9ba | |
|
|
4f0e4442ab | |
|
|
a038d2341c | |
|
|
df921e915d | |
|
|
7df736a77c | |
|
|
c231a6fddb | |
|
|
2e27c583b4 | |
|
|
459d4413b4 | |
|
|
dc3070f45b | |
|
|
162a104ebd | |
|
|
91f5b33bac | |
|
|
53f0e18216 | |
|
|
3427f42b81 | |
|
|
24ebe9da26 | |
|
|
7b9fd21d2a | |
|
|
d36e05ece8 | |
|
|
9baef8b255 | |
|
|
86e1003c16 | |
|
|
edb59ebaeb | |
|
|
73a4c9d028 | |
|
|
d6bc24e0f2 | |
|
|
5dfcc3f694 | |
|
|
899dc8e0f0 | |
|
|
85e096698a | |
|
|
bd83741f24 | |
|
|
882f3b7d65 | |
|
|
03b40a5244 | |
|
|
cedc000215 | |
|
|
9f89afc39a | |
|
|
37e71c4858 | |
|
|
e82a91ca1a | |
|
|
1e9752109e | |
|
|
506850caea | |
|
|
1a8959575c | |
|
|
ac93deebc6 | |
|
|
93c2e08780 | |
|
|
b056c5facd | |
|
|
c1e8ea5aba | |
|
|
253b8d38b8 | |
|
|
2b3bc4f28b | |
|
|
43cae1d2e3 | |
|
|
b4bc1f066a | |
|
|
7d335b2c72 | |
|
|
543bbfeb74 | |
|
|
906112c080 | |
|
|
6be756919b | |
|
|
3783247c74 | |
|
|
1228dec04d | |
|
|
d0a3ccc045 | |
|
|
6c72ca5f63 | |
|
|
f0d9d12ca7 | |
|
|
e605f732e2 | |
|
|
52f3d64b6a | |
|
|
3a1618faa2 | |
|
|
bd1d9db77b | |
|
|
b5d9dd2f02 | |
|
|
a560a6efee | |
|
|
37e4405c04 | |
|
|
483bca52ef | |
|
|
27cf52b007 | |
|
|
6a4041e21c | |
|
|
713d88d1fd | |
|
|
ef8f6128a3 | |
|
|
277f76ef03 | |
|
|
7b33574fd0 | |
|
|
c883f56a4e | |
|
|
0cfd8daed3 | |
|
|
c09982b0df | |
|
|
eb6570c992 | |
|
|
6861ed5e94 | |
|
|
3f127f01f1 | |
|
|
2e3adcde02 | |
|
|
47a68f098a | |
|
|
d0f63c8ac3 | |
|
|
dfee5bf6aa | |
|
|
eef3b355f6 | |
|
|
bc421bb197 | |
|
|
f6da2ee6cb | |
|
|
e79f1a5e73 | |
|
|
5cb9aad6ee | |
|
|
0b70e897f0 | |
|
|
0ee9a9b788 | |
|
|
75867796b7 | |
|
|
3f7dc2a8b2 | |
|
|
1d4532cd62 | |
|
|
b980df8697 | |
|
|
1dd0580d30 | |
|
|
de5904a600 | |
|
|
57cd0e8dd7 | |
|
|
7965aac70d | |
|
|
cf9ba8b310 | |
|
|
7635c67865 | |
|
|
965d6c137a | |
|
|
cb4427d9f1 | |
|
|
33fa9ed45d | |
|
|
4346b44f80 | |
|
|
2c6fcdc719 | |
|
|
44f99e968c | |
|
|
b52517cc47 | |
|
|
bd5d68f0f2 | |
|
|
bfe9fae150 | |
|
|
c997f35b04 | |
|
|
47aa8be850 | |
|
|
e8fb2696d6 | |
|
|
dcf3752515 | |
|
|
10f0a87c7b | |
|
|
20d1e5228e | |
|
|
8c93652de7 | |
|
|
ed493f3093 | |
|
|
d376b02dc5 | |
|
|
197e8a00ed | |
|
|
0c01475843 | |
|
|
c0ea21eed6 | |
|
|
5ad55fb82f | |
|
|
12b4940563 | |
|
|
25301f6228 | |
|
|
a6e1f232c2 | |
|
|
a7ad7ea100 | |
|
|
a9445ca3c3 | |
|
|
bce6d058f5 | |
|
|
69e6b461ad | |
|
|
4d5f4195db | |
|
|
70ab14e3e6 | |
|
|
e90489f361 | |
|
|
8db0a9b195 | |
|
|
b43526da60 | |
|
|
d4b95ca323 | |
|
|
73329ce4f5 | |
|
|
869fc81811 | |
|
|
45636a0489 | |
|
|
fc9bc2866e | |
|
|
30ef2f7c6b | |
|
|
d7c1c2149c | |
|
|
b49be05171 | |
|
|
4ceef1ab0c | |
|
|
8e99d85d33 | |
|
|
1d0969dede | |
|
|
aaf67cf81c | |
|
|
8a515f20db | |
|
|
77c76124af | |
|
|
4d7ad86776 | |
|
|
d12f5734e6 | |
|
|
b02c2bdaa7 | |
|
|
7927335303 | |
|
|
c922b10c31 | |
|
|
c31a53641f | |
|
|
5df28fa2ca | |
|
|
23776a7686 | |
|
|
8ee3d32b4f | |
|
|
5227248799 | |
|
|
80a4cd6877 | |
|
|
324cbb2c1f | |
|
|
258d1812ff | |
|
|
b836426db0 | |
|
|
b4e67e1dfb | |
|
|
b8c7743616 | |
|
|
bcf2a395cf | |
|
|
a946ad1de4 | |
|
|
e1d9607410 | |
|
|
f23c648937 | |
|
|
0f2faf48dc | |
|
|
297e491232 | |
|
|
267ff6d3a8 | |
|
|
7b6a4bd136 | |
|
|
6997a87d0c | |
|
|
9e4fb9647e | |
|
|
4b74ab6cec | |
|
|
6409d9277d | |
|
|
82c7e78a8c | |
|
|
901da45e59 | |
|
|
31c6c6df13 | |
|
|
a0f34d5973 | |
|
|
d968deb124 | |
|
|
6c0d596eac | |
|
|
76fa64498a | |
|
|
1d524760eb | |
|
|
271d72c9f3 | |
|
|
614d47159d | |
|
|
82f2a6539f | |
|
|
f9593d494b | |
|
|
c8e0f0c3e1 | |
|
|
6aa01af49e | |
|
|
6f9493a517 | |
|
|
effedb0c23 | |
|
|
eed6103359 | |
|
|
e1cb3eb16c | |
|
|
e4633e1cdb | |
|
|
fc6e3702da | |
|
|
91a616bb38 | |
|
|
f49b2b808d | |
|
|
f6018d1071 | |
|
|
958193d797 | |
|
|
3427625379 | |
|
|
8724b12032 | |
|
|
1f64e8afb0 | |
|
|
c28f8c8977 | |
|
|
e339fed6c9 | |
|
|
04112774d4 | |
|
|
e400e4d22b | |
|
|
b385c45c35 | |
|
|
c37556919b | |
|
|
62d52a20ba | |
|
|
52807b0aa0 | |
|
|
b3949997fd | |
|
|
7efcf879c1 | |
|
|
93614cf29d | |
|
|
80bd82bde1 | |
|
|
0239a1e174 | |
|
|
fb48e831f7 | |
|
|
eb7a65c440 | |
|
|
6c3170c496 | |
|
|
fc27f2c200 | |
|
|
8047fe7d9e | |
|
|
9463119a67 | |
|
|
85499f389b | |
|
|
9cbb61862c | |
|
|
73bf516630 | |
|
|
7d84f01a31 | |
|
|
a40774e484 | |
|
|
ea888d11d8 | |
|
|
510b12ed6e | |
|
|
c86e38a8ac | |
|
|
627a028dab | |
|
|
d01c8737d7 | |
|
|
2251adf073 | |
|
|
927b67324e | |
|
|
37e221a712 | |
|
|
be6ee386b9 | |
|
|
df05b2b1b0 | |
|
|
ccade5ac47 | |
|
|
3b44568e8b | |
|
|
6c9fe3a874 | |
|
|
5bc993fe79 | |
|
|
d340420341 | |
|
|
67a689c86c | |
|
|
44bea37187 | |
|
|
7acd496e0b | |
|
|
4c232a6167 | |
|
|
aa0d8dac47 | |
|
|
57462b057e | |
|
|
109495e9be | |
|
|
b79a690cd4 | |
|
|
833ce2f0b7 | |
|
|
020b7dc00a | |
|
|
4dbe157ecb | |
|
|
b1b12098fe | |
|
|
75e004a4e3 | |
|
|
c3e9f8ec06 | |
|
|
b4fa2a16ac | |
|
|
f63f056034 | |
|
|
476477bb7b | |
|
|
6c5e204c38 | |
|
|
f1ad2e5623 | |
|
|
708ace7deb | |
|
|
71f6e81796 | |
|
|
9926fc6e05 | |
|
|
4caf261216 | |
|
|
37bd251708 | |
|
|
148d6250dc | |
|
|
eb6398c4b7 | |
|
|
7ef0305da7 | |
|
|
353d90698f | |
|
|
0d6b871aba | |
|
|
53025bd43b | |
|
|
6ef3c0e291 | |
|
|
8385db2177 | |
|
|
31ae32b67a | |
|
|
71109cffde | |
|
|
464d99080f | |
|
|
beda055142 | |
|
|
4763e876bc | |
|
|
9c9c26c3cb | |
|
|
bc9822d7bb | |
|
|
7a72d7df60 | |
|
|
fa3ace6865 | |
|
|
c96d4e94e1 | |
|
|
c89b0690dd | |
|
|
9e4e33f41a | |
|
|
caa4b26a98 | |
|
|
8869c9ea4a | |
|
|
0dfb124314 | |
|
|
89ebbfdffb | |
|
|
952975a3c7 | |
|
|
2fc8869347 | |
|
|
7347b17a47 | |
|
|
09619597d6 | |
|
|
16602cc839 | |
|
|
19ef0ac203 | |
|
|
66b167422f | |
|
|
c1d32a8bd0 | |
|
|
cc80d27745 | |
|
|
3a22263621 | |
|
|
1fbd5ffcb5 | |
|
|
4361a51d9d | |
|
|
07810249a5 | |
|
|
88a8d782b8 | |
|
|
8abf3d5524 | |
|
|
dc3e9e2bbd | |
|
|
ae54f28308 | |
|
|
9b5950e4be | |
|
|
b783da5bde | |
|
|
be72d20f8a | |
|
|
99d4481e94 | |
|
|
7621aa71d2 | |
|
|
767bdfc397 | |
|
|
b699c5cd62 | |
|
|
8f4e95d3ec | |
|
|
51d29ac3a0 | |
|
|
e85ab38c6b | |
|
|
3b1bcb1a99 | |
|
|
42ef9c4d95 | |
|
|
4c8069dbaa | |
|
|
5172f773a8 | |
|
|
7274a5f67d | |
|
|
2f11ea530f | |
|
|
6861f12662 | |
|
|
70cf9d0234 | |
|
|
1d4b834c59 | |
|
|
4702cea415 | |
|
|
a1055fe866 | |
|
|
b54fba6bd1 | |
|
|
3328964ff6 | |
|
|
8afca00690 | |
|
|
09b18191ed | |
|
|
dadbc7b59a | |
|
|
98dc91efef | |
|
|
bc43e5e943 | |
|
|
745bd861af | |
|
|
2af01bc92d | |
|
|
b9266b2f23 | |
|
|
1118418585 | |
|
|
4af14a9998 | |
|
|
589ee2ca10 | |
|
|
88d71e75b1 | |
|
|
335f0ea4f0 | |
|
|
8609968e66 | |
|
|
bb88c36976 | |
|
|
239b06e8b0 | |
|
|
664eb260ce | |
|
|
cd09304f39 | |
|
|
97694063c1 | |
|
|
2d25938370 | |
|
|
d4304b635c | |
|
|
f6f8c3eda6 | |
|
|
f2bdedd43f | |
|
|
8d4b1eea8c | |
|
|
58f08d5e58 | |
|
|
cf767dc2d2 | |
|
|
c128b4a25c | |
|
|
2e313e0a52 | |
|
|
6328b8d691 | |
|
|
c9714df75c | |
|
|
044a15e569 | |
|
|
db84121d5d | |
|
|
deac513c43 | |
|
|
0ed2e3b807 | |
|
|
be7c0838a5 | |
|
|
b991b6a13d | |
|
|
44847756b4 | |
|
|
5b48b3b4ba | |
|
|
85b01b2333 | |
|
|
e6a24fc6a4 | |
|
|
9a8259ef3f | |
|
|
7d46524b1c | |
|
|
8d52abb2a0 | |
|
|
28ed873360 | |
|
|
d85ee50d5f | |
|
|
1f5d502e0e | |
|
|
74c0e2dc8a | |
|
|
9ec3c3c66c | |
|
|
345c4c3101 | |
|
|
c904dcbbbd | |
|
|
7438511faf | |
|
|
c3c9f2a8b8 | |
|
|
ad24359417 | |
|
|
734d55436e | |
|
|
73a1f1f8e5 | |
|
|
0a3599db5d | |
|
|
f2e838443d | |
|
|
d778eb1383 | |
|
|
4a2c2d28e9 | |
|
|
7acd4fc0e4 | |
|
|
035a03e1df | |
|
|
ed1d6f88e1 | |
|
|
0cc02e47b0 | |
|
|
5368f3205e | |
|
|
d0e5971c7e | |
|
|
b591f7d8b3 | |
|
|
88d2f897ed | |
|
|
91f1cec07d | |
|
|
14eb6cbfeb | |
|
|
0ca54c4097 | |
|
|
58b3ebe589 | |
|
|
856dc0d0ad | |
|
|
5bb860f2d2 | |
|
|
6856cc21b0 | |
|
|
730f33263d | |
|
|
05fe7a4c92 | |
|
|
5cdf77043a | |
|
|
88c7abdbb1 | |
|
|
9eb55e58be | |
|
|
72baa123b1 | |
|
|
5c51a69ded | |
|
|
cadeade476 | |
|
|
848b8fb178 | |
|
|
4b21e94ad2 | |
|
|
1e83e37c01 | |
|
|
e9cef7425d | |
|
|
ace60537d0 | |
|
|
ee905d6598 | |
|
|
60672b2fcc | |
|
|
6924f36346 | |
|
|
132582af6f | |
|
|
f19acccbf1 | |
|
|
8fe485d118 | |
|
|
8eea685f02 | |
|
|
08bb09ed8d | |
|
|
26413a8327 | |
|
|
dee538ad34 | |
|
|
1d031c5905 | |
|
|
0580bae3e5 | |
|
|
b6abf96040 | |
|
|
d213166eb2 | |
|
|
2dd2d7c3fd | |
|
|
ece4c5a587 | |
|
|
ac974b6c7f | |
|
|
47aa1c946f | |
|
|
cd4fc6abee | |
|
|
40a85ed41d | |
|
|
d695bd494d | |
|
|
68e3467e1f | |
|
|
922a4f6334 | |
|
|
d0dce7efa5 | |
|
|
3c9b2c25c6 | |
|
|
a6e6247e3c | |
|
|
8f0f2ba012 | |
|
|
997353dbee | |
|
|
942a05a0c5 | |
|
|
4a1926fe40 | |
|
|
fbb743afeb | |
|
|
3b8933c3d3 | |
|
|
a0ffdc47fb | |
|
|
9f50e67983 | |
|
|
a25b6e6dab | |
|
|
b1cec5a751 | |
|
|
59f0ce97e1 | |
|
|
cd226043da | |
|
|
f6a492c567 | |
|
|
9978ad1f9b | |
|
|
0200dc6034 | |
|
|
f5383d5541 | |
|
|
ee08712120 | |
|
|
3b623bcc3a | |
|
|
24c3390379 | |
|
|
83180fb720 | |
|
|
5aab8b411c | |
|
|
0789b1c8c1 | |
|
|
c572c2bedd | |
|
|
5bd37d8688 | |
|
|
03fb380083 | |
|
|
5021b115d2 | |
|
|
b5c4d1ccfd | |
|
|
c0653d103b | |
|
|
b3468c78e8 | |
|
|
6d7f5ccc9d | |
|
|
2dcfbfafab | |
|
|
299449b1ac | |
|
|
d9b70d7c4e | |
|
|
417c73c870 | |
|
|
cc509f9061 | |
|
|
21f99291f4 | |
|
|
43b8ae7bff | |
|
|
ec81e760e2 | |
|
|
1d27452994 | |
|
|
0b80d77006 | |
|
|
d540040cd9 | |
|
|
4b4b4b6e24 | |
|
|
eef1f8b124 | |
|
|
7512587747 | |
|
|
53c6503cde | |
|
|
8eb7d0fcf8 | |
|
|
2a95f9fce6 | |
|
|
f529c62226 | |
|
|
c11667d0e4 | |
|
|
0dc7b27183 | |
|
|
69ac3cc072 | |
|
|
89f7554610 | |
|
|
cba3c23d7f | |
|
|
634e4f9f84 | |
|
|
c088acaf2b | |
|
|
3881b86697 | |
|
|
49e8599d8f | |
|
|
535ae072f4 | |
|
|
efa8e97c4f | |
|
|
9101842200 | |
|
|
27dfd9d5a2 | |
|
|
74b954acf2 | |
|
|
f72fac400f | |
|
|
185a926a94 | |
|
|
aecaf4e86a | |
|
|
fe190141cc | |
|
|
d51efb6120 | |
|
|
6c800388a1 | |
|
|
159143c04d | |
|
|
265f74bb5f | |
|
|
98844d8c2a | |
|
|
3914813fb8 | |
|
|
1114e94924 | |
|
|
42e5260ba5 | |
|
|
ccc4d3bd6a | |
|
|
cde7763cc2 | |
|
|
c80f959579 | |
|
|
f4e861b3a8 | |
|
|
37de7be0ee | |
|
|
9962e0c9c9 | |
|
|
2d4a8eebf8 | |
|
|
630e19f8bc | |
|
|
9f329f5f3a | |
|
|
544599e316 | |
|
|
b4fb1f7443 | |
|
|
034e1a2513 | |
|
|
c2c5ba4689 | |
|
|
0d90ae4331 | |
|
|
fffccf1b2f | |
|
|
0a71d120f9 | |
|
|
4bd64ce8b5 | |
|
|
24b8a33e9c | |
|
|
8268b755ef | |
|
|
d78b728aa2 | |
|
|
49bff5eadc | |
|
|
4eda6313eb | |
|
|
0ff4b0e234 | |
|
|
41bc25ce85 | |
|
|
f8e65f83bd | |
|
|
cc463411ea | |
|
|
0436a14591 | |
|
|
ce75fb96e0 | |
|
|
88d8838209 | |
|
|
b525aef026 | |
|
|
85a6b7e24d | |
|
|
48a39fcef8 | |
|
|
2f453c0af9 | |
|
|
64bd1543e8 | |
|
|
1a66a60897 | |
|
|
0822dd93f6 | |
|
|
5ea077f13e | |
|
|
194ed53b85 | |
|
|
1eb2414134 | |
|
|
87c5826480 | |
|
|
306b4f1829 | |
|
|
95530cc4b3 | |
|
|
5bac575b29 | |
|
|
5f6012cbe4 | |
|
|
bbbc8e70f5 | |
|
|
6f20cb8bdc | |
|
|
476bb78315 | |
|
|
146e4bc362 | |
|
|
904f4260b9 | |
|
|
16fbcb354d | |
|
|
591d3f3834 | |
|
|
07793f9971 | |
|
|
1c7c839d45 | |
|
|
a4121451ce | |
|
|
553cd60b8f | |
|
|
1db56cfd86 | |
|
|
9db431015a | |
|
|
eed956d931 | |
|
|
50c7738056 | |
|
|
92ad62a9fb | |
|
|
4aae65cd4d | |
|
|
8c76d5b0cf | |
|
|
daa967d74d | |
|
|
544b94c919 | |
|
|
140cf845b5 | |
|
|
9346717bde | |
|
|
d6d92e4896 | |
|
|
aa222c4893 | |
|
|
c2db8f55d6 | |
|
|
887a4d5a9a | |
|
|
5183fb054a | |
|
|
1bf8d9e4c0 | |
|
|
56a60dca53 | |
|
|
12c65918b3 | |
|
|
cb33bbd436 | |
|
|
154e03054e | |
|
|
8d8333980c | |
|
|
fde9c72a0f | |
|
|
749a2d9d1f | |
|
|
2ae8e1571b | |
|
|
8219a10e74 | |
|
|
9f994b33de | |
|
|
fe8b51d072 | |
|
|
24ff820174 | |
|
|
8a44989e32 | |
|
|
7789bc87d8 | |
|
|
65032356e9 | |
|
|
1804fa7ee1 | |
|
|
3d3da162de | |
|
|
b01f3a35df | |
|
|
094f8bb56b | |
|
|
d8d4b3eba5 | |
|
|
5e003a7f2f | |
|
|
5195740642 | |
|
|
12c53cc17b | |
|
|
4d6c421358 | |
|
|
281aab85f2 | |
|
|
ca0a9832a6 | |
|
|
b4a6cc9ab4 | |
|
|
c24069ee26 | |
|
|
504069e17f | |
|
|
705c27b986 | |
|
|
f6cdc8a3ca | |
|
|
8bdac2c758 | |
|
|
a200deab56 | |
|
|
5cda854e8d | |
|
|
f33c09385d | |
|
|
dec8fe9a84 | |
|
|
dfd3190392 | |
|
|
b76e0eaeab | |
|
|
6052985c15 | |
|
|
e05d13098a | |
|
|
9faea02296 | |
|
|
5252a7e481 | |
|
|
0c580690cc | |
|
|
315000a600 | |
|
|
d3960c1da4 | |
|
|
9778a8b4b3 | |
|
|
171e723f50 | |
|
|
9a1417f3dc | |
|
|
9cc9cad29a | |
|
|
e88f54a21e | |
|
|
ec2599db9a | |
|
|
d592690cf7 | |
|
|
36959044a1 | |
|
|
7bdf878dd4 | |
|
|
5603b9c6a3 | |
|
|
cccef5d575 | |
|
|
db55e237a5 | |
|
|
3e5f626d11 | |
|
|
5f305526d7 | |
|
|
a5fa9016ec |
|
|
@ -0,0 +1,60 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
github:
|
||||
features:
|
||||
# Enable issue management
|
||||
issues: true
|
||||
# Enable wiki for documentation
|
||||
wiki: true
|
||||
# Enable projects for project management boards
|
||||
projects: true
|
||||
description: A graph database that supports more than 100+ billion data, high performance and scalability (Include OLTP Engine & REST-API & Backends)
|
||||
homepage: https://hugegraph.apache.org
|
||||
del_branch_on_merge: true
|
||||
#labels:
|
||||
enabled_merge_buttons:
|
||||
merge: false
|
||||
rebase: true
|
||||
squash: true
|
||||
protected_branches:
|
||||
master:
|
||||
required_status_checks:
|
||||
# strict means "Require PR to be up-to-date before merging". (enable when branch unstable)
|
||||
strict: false
|
||||
# contexts are the names of checks that must pass (now only enable the basic check)
|
||||
contexts:
|
||||
- Analyze (java)
|
||||
- CodeQL
|
||||
- check-license
|
||||
- build-server (memory, 11)
|
||||
- build-commons (11)
|
||||
required_pull_request_reviews:
|
||||
dismiss_stale_reviews: true
|
||||
require_code_owner_reviews: false
|
||||
required_approving_review_count: 2
|
||||
|
||||
# refer https://cwiki.apache.org/confluence/display/INFRA/Git+-+.asf.yaml+features#Git.asf.yamlfeatures-Notificationsettingsforrepositories
|
||||
notifications:
|
||||
# use https://selfserve.apache.org to manage it
|
||||
pullrequests_status: issues@hugegraph.apache.org
|
||||
pullrequests_comment: issues@hugegraph.apache.org
|
||||
pullrequests_bot_dependabot: issues@hugegraph.apache.org
|
||||
issues: issues@hugegraph.apache.org
|
||||
issues_status: dev@hugegraph.apache.org
|
||||
issues_comment: issues@hugegraph.apache.org
|
||||
discussions: dev@hugegraph.apache.org
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
max_line_length = 100
|
||||
ij_wrap_on_typing = true
|
||||
ij_visual_guides = 100
|
||||
|
||||
|
||||
[*.{java,xml,py}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.{java,xml}]
|
||||
# Ignore the IDEA unsupported warning & it works well (indeed)
|
||||
continuation_indent_size = 8
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
|
||||
[*.java]
|
||||
ij_java_doc_add_p_tag_on_empty_lines = true
|
||||
ij_java_doc_do_not_wrap_if_one_line = true
|
||||
ij_java_annotation_parameter_wrap = normal
|
||||
ij_java_align_multiline_annotation_parameters = true
|
||||
ij_java_class_count_to_use_import_on_demand = 100
|
||||
ij_java_names_count_to_use_import_on_demand = 100
|
||||
ij_java_imports_layout = $*, |, java.**, |, javax.**, |, org.**, |, com.**, |, *
|
||||
|
||||
ij_java_line_comment_at_first_column = false
|
||||
ij_java_align_multiline_chained_methods = true
|
||||
ij_java_align_multiline_parameters_in_calls = true
|
||||
ij_java_align_multiline_binary_operation = true
|
||||
ij_java_align_multiline_assignment = true
|
||||
ij_java_align_multiline_ternary_operation = true
|
||||
ij_java_align_multiline_throws_list = true
|
||||
ij_java_align_multiline_extends_list = true
|
||||
ij_java_align_multiline_array_initializer_expression = true
|
||||
|
||||
ij_java_call_parameters_wrap = normal
|
||||
ij_java_method_parameters_wrap = normal
|
||||
ij_java_resource_list_wrap = normal
|
||||
ij_java_extends_list_wrap = normal
|
||||
ij_java_throws_list_wrap = normal
|
||||
ij_java_method_call_chain_wrap = normal
|
||||
ij_java_binary_operation_wrap = normal
|
||||
ij_java_ternary_operation_wrap = normal
|
||||
ij_java_for_statement_wrap = normal
|
||||
ij_java_array_initializer_wrap = normal
|
||||
ij_java_assignment_wrap = normal
|
||||
ij_java_assert_statement_wrap = normal
|
||||
ij_java_if_brace_force = if_multiline
|
||||
ij_java_do_while_brace_force = always
|
||||
ij_java_while_brace_force = if_multiline
|
||||
ij_java_for_brace_force = if_multiline
|
||||
ij_java_wrap_long_lines = true
|
||||
ij_java_parameter_annotation_wrap = normal
|
||||
ij_java_enum_constants_wrap = split_into_lines
|
||||
|
||||
ij_java_keep_blank_lines_in_declarations = 1
|
||||
ij_java_keep_blank_lines_in_code = 1
|
||||
ij_java_keep_blank_lines_between_package_declaration_and_header = 1
|
||||
ij_java_keep_blank_lines_before_right_brace = 1
|
||||
ij_java_blank_lines_around_class = 1
|
||||
ij_java_blank_lines_after_class_header = 1
|
||||
|
||||
ij_smart_tabs = true
|
||||
|
||||
[*.xml]
|
||||
max_line_length = 120
|
||||
ij_visual_guides = 120
|
||||
ij_xml_text_wrap = off
|
||||
ij_xml_space_inside_empty_tag = true
|
||||
|
||||
[.yaml]
|
||||
ij_yaml_spaces_within_braces = false
|
||||
ij_yaml_spaces_within_brackets = false
|
||||
|
||||
[.properties]
|
||||
ij_properties_keep_blank_lines = true
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
# ignored file when package to source.tgz
|
||||
.gitattributes export-ignore
|
||||
.gitignore export-ignore
|
||||
.asf.yaml export-ignore
|
||||
apache-release.sh export-ignore
|
||||
.licenserc.yaml export-ignore
|
||||
.editorconfig export-ignore
|
||||
hugegraph-store/hg-store-dist/src/assembly/static/bin/libjemalloc.so export-ignore
|
||||
hugegraph-store/hg-store-dist/src/assembly/static/bin/libjemalloc_aarch64.so export-ignore
|
||||
|
||||
# ignored directory
|
||||
.github/ export-ignore
|
||||
.idea/ export-ignore
|
||||
install-dist/scripts/ export-ignore
|
||||
hugegraph-commons/hugegraph-dist/ export-ignore
|
||||
docker/ export-ignore
|
||||
|
|
@ -10,18 +10,18 @@ body:
|
|||
value: >-
|
||||
### Note (特别注意) :
|
||||
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/hugegraph/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有与您相同
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有与您相同
|
||||
/ 相关的问题 (请勿重复提交)
|
||||
|
||||
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
|
||||
会**越快**被响应和处理
|
||||
|
||||
> 3. Issue 标题请保持原有模板分类(例如:`[Bug]`), 长段描述之间可以增加`空行`或使用`序号`标记, 保持排版清晰
|
||||
> 3. Issue 标题请保留原有分类标签 (例如:`[Bug]`), 长段描述请增加`空行`并使用`序号`标记, 保持排版清晰
|
||||
|
||||
> 4. 请在对应的模块提交 issue, 缺乏有效信息 / 长时间 (> 14 天) 没有回复的 issue 可能会被 **关闭**
|
||||
(更新时会再开启)
|
||||
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Bug Type (问题类型)
|
||||
|
|
@ -31,36 +31,38 @@ body:
|
|||
- other exception / error (其他异常报错)
|
||||
- server status (启动/运行异常)
|
||||
- logic (逻辑设计问题)
|
||||
- performence (性能下降)
|
||||
- performance (性能下降)
|
||||
- others (please edit later)
|
||||
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Before submit
|
||||
options:
|
||||
- label: 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题
|
||||
- label: '我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed
|
||||
and searched that there are no similar problems in the historical issue and documents)'
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment (环境信息)
|
||||
description: |
|
||||
> server version could get from [rest-api](https://hugegraph.github.io/hugegraph-doc/clients/restful-api/other.html) (http://localhost:8080/versions)
|
||||
> server version could get from [rest-api](https://hugegraph.apache.org/docs/clients/restful-api/) (http://localhost:8080/versions)
|
||||
value: |
|
||||
- Server Version: v0.11.x
|
||||
- Server Version: 1.0.0 (Apache Release Version)
|
||||
- Backend: RocksDB x nodes, HDD or SSD
|
||||
- OS: xx CPUs, xx G RAM, Centos 7.x
|
||||
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
|
||||
- Data Size: xx vertices, xx edges <!-- (like 1000W 点, 9000W 边) -->
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected & Actual behavior (期望与实际表现)
|
||||
description: |
|
||||
> we can refer [How to create a minimal reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) (如何提供最简的可复现用例)
|
||||
> if possible, please provide screenshots or GIF (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
> if possible, please provide **screenshots** / Pic or `GIF` (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
type the main problem here
|
||||
|
||||
```java
|
||||
|
|
@ -69,7 +71,7 @@ body:
|
|||
```
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Vertex/Edge example (问题点 / 边数据举例)
|
||||
|
|
@ -84,7 +86,7 @@ body:
|
|||
"vertex": { "id": "xxx" }
|
||||
}
|
||||
render: javascript
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ blank_issues_enabled: false
|
|||
|
||||
# 设置提 issue 前的参考文档
|
||||
contact_links:
|
||||
- name: HugeGraph Server Doc
|
||||
url: https://hugegraph.github.io/hugegraph-doc/quickstart/hugegraph-server.html
|
||||
- name: HugeGraph Server Doc (EN/CN)
|
||||
url: https://hugegraph.apache.org/docs/quickstart/hugegraph-server/
|
||||
about: Please search question here before opening a new issue
|
||||
- name: HugeGraph API Doc
|
||||
url: https://hugegraph.github.io/hugegraph-doc/clients/hugegraph-api.html
|
||||
- name: HugeGraph API Doc (EN/CN)
|
||||
url: https://hugegraph.apache.org/docs/clients/
|
||||
about: Please search usage here before opening a new issue
|
||||
|
|
|
|||
|
|
@ -10,6 +10,6 @@ body:
|
|||
label: Feature Description (功能描述)
|
||||
description: |
|
||||
> 请简要描述新功能 / 需求的使用场景或上下文, 最好能给个具体的例子说明
|
||||
placeholder: type the feature description here
|
||||
placeholder: type the feature description here
|
||||
validations:
|
||||
required: true
|
||||
|
|
|
|||
|
|
@ -8,18 +8,18 @@ body:
|
|||
value: >-
|
||||
### Note (特别注意) :
|
||||
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/hugegraph/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有与您相同
|
||||
> 1. 请先**搜索**现有的[Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有与您相同
|
||||
/ 相关的问题 (请勿重复提交)
|
||||
|
||||
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
|
||||
会**越快**被响应和处理
|
||||
|
||||
> 3. Issue 标题请保持原有模板分类(例如:`[Bug]`), 长段描述之间可以增加`空行`或使用`序号`标记, 保持排版清晰
|
||||
> 3. Issue 标题请保留原有分类标签 (例如:`[Bug]`), 长段描述请增加`空行`并使用`序号`标记, 保持排版清晰
|
||||
|
||||
> 4. 请在对应的模块提交 issue, 缺乏有效信息 / 长时间 (> 14 天) 没有回复的 issue 可能会被 **关闭**
|
||||
(更新时会再开启)
|
||||
|
||||
|
||||
- type: dropdown
|
||||
attributes:
|
||||
label: Problem Type (问题类型)
|
||||
|
|
@ -29,37 +29,40 @@ body:
|
|||
- server status (启动/运行异常)
|
||||
- configs (配置项 / 文档相关)
|
||||
- struct / logic (架构 / 逻辑设计问题)
|
||||
- performence (性能优化)
|
||||
- performance (性能优化)
|
||||
- other exception / error (其他异常报错)
|
||||
- others (please edit later)
|
||||
|
||||
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Before submit
|
||||
options:
|
||||
- label: 我已经确认现有的 [Issues](https://github.com/hugegraph/hugegraph/issues) 与 [FAQ](https://hugegraph.github.io/hugegraph-doc/guides/faq.html) 中没有相同 / 重复问题
|
||||
- label: '我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与
|
||||
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed
|
||||
and searched that there are no similar problems in the historical issue and documents)'
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment (环境信息)
|
||||
description: |
|
||||
> server version could get from [rest-api](https://hugegraph.github.io/hugegraph-doc/clients/restful-api/other.html) (http://localhost:8080/versions)
|
||||
> server version could get from [rest-api](https://hugegraph.apache.org/docs/clients/restful-api/) (http://localhost:8080/versions)
|
||||
value: |
|
||||
- Server Version: v0.11.x
|
||||
- Server Version: 1.0.0 (Apache Release Version)
|
||||
- Backend: RocksDB x nodes, HDD or SSD
|
||||
- OS: xx CPUs, xx G RAM, Centos 7.x
|
||||
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
|
||||
- Data Size: xx vertices, xx edges <!-- (like 1000W 点, 9000W 边) -->
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Your Question (问题描述)
|
||||
description: |
|
||||
> 图使用 / 配置相关问题,请优先参考 [REST-API 文档](https://hugegraph.github.io/hugegraph-doc/clients/hugegraph-api.html), 以及 [Server 配置文档](https://hugegraph.github.io/hugegraph-doc/config/config-option.html)
|
||||
> if possible, please provide screenshots or GIF (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
> 图使用 / 配置相关问题,请优先参考 [REST-API 文档](https://hugegraph.apache.org/docs/clients/restful-api/),
|
||||
> 以及 [Server 配置文档](https://hugegraph.apache.org/docs/config/)
|
||||
> if possible, please provide **screenshots** / Pic or `GIF` (请提供清晰的截图, 动图录屏更佳)
|
||||
placeholder: |
|
||||
type the main problem here
|
||||
|
||||
```java
|
||||
|
|
@ -68,7 +71,7 @@ body:
|
|||
```
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Vertex/Edge example (问题点 / 边数据举例)
|
||||
|
|
@ -83,7 +86,7 @@ body:
|
|||
"vertex": { "id": "xxx" }
|
||||
}
|
||||
render: javascript
|
||||
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
<!--
|
||||
Thank you very much for contributing to Apache HugeGraph, we are happy that you want to help us improve it!
|
||||
|
||||
Here are some tips for you:
|
||||
1. If this is your first time, please read the [contributing guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
|
||||
|
||||
2. If a PR fix/close an issue, type the message "close xxx" (xxx is the link of related
|
||||
issue) in the content, GitHub will auto link it (Required)
|
||||
|
||||
3. Name the PR title in "Google Commit Format", start with "feat | fix | perf | refactor | doc | chore",
|
||||
such like: "feat(core): support the PageRank algorithm" or "fix: wrong break in the compute loop" (module is optional)
|
||||
skip it if you are unsure about which is the best component.
|
||||
|
||||
4. One PR address one issue, better not to mix up multiple issues.
|
||||
|
||||
5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click it directly after
|
||||
published)
|
||||
-->
|
||||
|
||||
## Purpose of the PR
|
||||
|
||||
- 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.
|
||||
e.g:
|
||||
- If you propose a new API, clarify the use case for a new API.
|
||||
- If you fix a bug, you can clarify why it is a bug, and should be associated with an issue.
|
||||
-->
|
||||
|
||||
## 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 and faster reviews.)
|
||||
|
||||
For example:
|
||||
|
||||
- If you introduce a new feature, please show detailed design here or add the link of design documentation.
|
||||
- If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
|
||||
- If there is a discussion in the mailing list, please add the link. -->
|
||||
|
||||
## Verifying these changes
|
||||
|
||||
<!-- Please pick the proper options below -->
|
||||
|
||||
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
|
||||
- [ ] Already covered by existing tests, such as *(please modify tests here)*.
|
||||
- [ ] Need tests and can be verified as follows:
|
||||
- xxx
|
||||
|
||||
## Does this PR potentially affect the following parts?
|
||||
|
||||
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
|
||||
|
||||
- [ ] 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) -->
|
||||
- [ ] Modify configurations
|
||||
- [ ] The public API
|
||||
- [ ] Other affects (typed here)
|
||||
- [ ] Nope
|
||||
|
||||
|
||||
## Documentation Status
|
||||
|
||||
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
|
||||
|
||||
- [ ] `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
|
||||
- [ ] `Doc - Done` <!-- Related docs have been already added or updated -->
|
||||
- [ ] `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
<servers>
|
||||
<server>
|
||||
<id>github</id>
|
||||
<username>${env.GITHUB_ACTOR}</username>
|
||||
<password>${env.GITHUB_TOKEN}</password>
|
||||
</server>
|
||||
</servers>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>local-repo</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>staged-releases</id>
|
||||
<url>https://repository.apache.org/content/groups/staging/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>staged-releases</id>
|
||||
<url>https://repository.apache.org/content/groups/staging/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<activeProfiles>
|
||||
<activeProfile>local-repo</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
||||
|
|
@ -115,7 +115,7 @@ env:
|
|||
global:
|
||||
- RELEASE_BRANCH=^release-.*$
|
||||
- RELEASE_TAG=^v[0-9]\..*$
|
||||
- TRAVIS_DIR=hugegraph-dist/src/assembly/travis
|
||||
- TRAVIS_DIR=hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||
- 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: XbX6AX5zDPc2PcWYAMW+6fazqRRUqpgQkt4eXUugLuVIYZBmJ0WqncEhJ4+mdwOGPIhnP2HsOaSeK2eE/O+iLY2XpBFbugoBgm9VaZlCC4CY1gRNHaanYg64Lrm3NPY3n08IHRMazHqMpJwUqNO+OG/6QwkepULQLj5Rluf716AoXHa7IEJhAIrwr+OXQvdEaJdUXlS1lRycXVeYtOewl7qYxCO4dD4RMhPlNykh9KEK7fd5wnPkiUsp1SwF4g5XsaLvGXmT/qQ1nj8oa9Caej/iaj6HMKG3BO057mq4KK5JDxTPWhBueNpEkUwldAnrMhYWLRnNf4IyjUsaB/Pmi6HspzcaiORPLYwPmdvLGGSnYwbtO+fAHebgpgOnj/vGmRmY4YtIkYdFtbPBI0HpbGB77tqNRFCe/5deLrjx0hXJBfoKTy7d42SI1eBhNR0svZYUHkSfuXwly6hMTlH1DN/bumMFxfXDkY9PFHlzV1Mn3vb9BxKTaP88hJsWk7JqgniqUF7EWAc0EhHMbJct2gC0pDc95z4Yy9391n7/XWJErhIdYon1Ukds5+a43xFXoy76gR4LuMDpzzCnutMjhC2yDuGaZx/DfkPBb5JFU7SHtTKj05zb73Moogi7qqbH8jwcwoSfogAKyrIAWTcAgvJ2LVnRzwdsiLTc6MEagiM=
|
||||
|
|
@ -0,0 +1,318 @@
|
|||
# [New Podling Proposal of HugeGraph](https://cwiki.apache.org/confluence/display/INCUBATOR/New+Podling+Proposal)
|
||||
|
||||
## Abstract
|
||||
|
||||
HugeGraph is a high-performance scalable graph database.
|
||||
|
||||
## Proposal
|
||||
|
||||
HugeGraph is a large-scale and easy-to-use graph database. In the cases of 100+ billion data (vertices and edges), HugeGraph has complete HTAP capabilities built into its internal system. The design goal of HugeGraph is to achieve a balance between availability, performance, and cost.
|
||||
|
||||
We believe that the HugeGraph project will benefit the open-source community if HugeGraph is introduced into the Apache Software Foundation.
|
||||
|
||||
### Background
|
||||
|
||||
HugeGraph graph database was initially developed at Baidu, the leading search engine company in China. HugeGraph was designed to solve the large-scale graph analysis requirements for the task of anti-fraud. Relational databases are usually at a disadvantage in dealing with relational analysis, due to slow join performance, especially in the case of a large-scale graph with multiple dimensions and deep association relationships. Graph databases are in general considered a good alternative in dealing with large-scale relational analysis.
|
||||
|
||||
### Rationale
|
||||
|
||||
Generally, most graph databases can only process up to 1-billion-scale graphs, but it lacks a system to process 100-billion-scale graphs. Some graph databases may only support online query (OLTP), and some graph platforms only support graph computing (OLAP). HugeGraph is designed to support both online query and graph computing in the scenarios of 100+ billion data.
|
||||
|
||||
### Initial Goals
|
||||
|
||||
Although most of the main development of HugeGraph has been completed, there are several areas that still need future development. Some areas we want to focus on in the Apache incubation stage include:
|
||||
|
||||
- Higher graph computing loading performance: the current architecture (especially the separation of computing and storage) brings greater flexibility and cost savings, but with some performance overhead, which needs to be improved.
|
||||
- RocksDB-based sharding storage development, based on the affinity architecture of query and storage. Since RocksDB is known for its good performance, but currently HugeGraph only supports the raft-based replication mode, we plan to support scale-out and distributed atomic transactions for RocksDB-based storage.
|
||||
- Parallel OLTP query: at present, HugeGraph can perform parallel OLAP graph-computing, but the OLTP query only supports parallel execution on a single machine. In certain scenarios, the OLTP query needs to be implemented in parallel on multiple machines.
|
||||
- Higher-performance queries: such as supporting faster query optimization, parallel primitive collections, and fine-grained caching strategies.
|
||||
- Better usability: more OLTP/OLAP algorithms, APIs and toolchains, rich UI, etc...
|
||||
- More language clients: such as supporting Python and Go languages.
|
||||
- Some other optimizations: such as supporting pre-sorting graph loading.
|
||||
|
||||
### Current Status
|
||||
|
||||
#### Meritocracy
|
||||
|
||||
HugeGraph was incubated at Baidu in 2016 and open-sourced on [GitHub](https://github.com/hugegraph/hugegraph) in 2018. The project (including sub-projects) now has 30+ contributors from many companies. Some of these contributors become committers, and the project has hundreds of known users around the world. We will follow Apache's Meritocracy way to re-organize the community roles. We have set up the PPMC Team and Committer Team. Of course, contributions are welcomed and highly valued. New contributors are guided and reviewed by existing PMC members. When an active contributor has submitted enough good patches, PMC will start a vote to promote him/her to become a member of the Committer Team or PMC Team.
|
||||
|
||||
#### Community
|
||||
|
||||
Baidu has been building a community around HugeGraph users and developers for the last 3 years, and now we make use of GitHub as code hosting and community communication. The most of core developers are from Baidu. Besides, there are 10+ contributors from other companies such as NetEase, 360, Iflytek, and Huya. We hope to grow the base of contributors by inviting all those who offer contributions through The Apache Way.
|
||||
|
||||
#### Core Developers
|
||||
|
||||
The core developers are all experienced open-source developers. They have operated the HugeGraph Community for 3 years, and they are contributors to Linux kernel, OpenStack, Ceph, RocksDB, Apache TinkerPop, Apache Hadoop, and Apache Groovy.
|
||||
|
||||
#### Alignment
|
||||
|
||||
HugeGraph implements the API of [Apache TinkerPop](https://tinkerpop.apache.org/), which defines the [Gremlin](https://tinkerpop.apache.org/gremlin.html). Gremlin is a powerful graph traversal language, and various complicated graph queries can be accomplished through Gremlin. The TinkerPop ecosystem based on Java is relatively mature in terms of graph databases. We use Java language, which is developed efficient and stable, to develop upper-level components like graph engine, graph computing, graph API, and graph tools; and we manage storage through JNI which is able to freely manage memory and execute efficiently.
|
||||
|
||||
### Known Risks
|
||||
|
||||
#### Project Name
|
||||
|
||||
We have checked and believe the name is [suitable](https://github.com/hugegraph/hugegraph/issues/1646) and the project has legal permission to continue using its current name. There are no other projects found using this name through Google Search.
|
||||
|
||||
#### Relationship with Titan/Janus Graph
|
||||
|
||||
In the early stage of the project, we referred to the storage structure of Titan/Janus Graph, some folks thought that HugeGraph was forked from Titan/Janus. In fact, HugeGraph is not based on these projects. HugeGraph is developed completely from scratch and in the process it addressed many new challenges. Certainly, the project was inspired by Titan/Janus and we are really grateful for these inspirations.
|
||||
|
||||
### Orphaned products
|
||||
|
||||
Due to a small and limited number of committers, the project has a relatively small risk of becoming an orphan project. However, the committers have been operating the HugeGraph Community for 3 years in the spirit of open-source, and continue to develop new contributors to participate.
|
||||
|
||||
#### Inexperience with Open-Source
|
||||
|
||||
HugeGraph has been open-sourced on GitHub for 3 years, during which committers submitted code and documents in full compliance with open-source specifications and requirements.
|
||||
|
||||
#### Length of Incubation
|
||||
|
||||
Expect to enter incubation in 4 months and graduate in about 2 years.
|
||||
|
||||
#### Homogenous Developers
|
||||
|
||||
The developers on the current list come from several different companies plus many independent volunteers, but the most of committers are from Baidu. The developers are geographically concentrated in China now. They are experienced with working in a distributed environment in other open-source projects, e.g. OpenStack.
|
||||
|
||||
#### Reliance on Salaried Developers
|
||||
|
||||
Most of the developers are paid by their employer to contribute to this project. Given some volunteer developers and the committers' sense of ownership for the code, the project could continue even if no salaried developers contributed to the project.
|
||||
|
||||
#### Relationships with Other Apache Products
|
||||
|
||||
HugeGraph follows the Apache TinkerPop specification, uses Apache Commons, Apache HttpClient, and Apache HttpCore to implement the basic functions. Users can choose Apache Cassandra or Apache HBase as one of the storage backends of HugeGraph.
|
||||
|
||||
#### An Excessive Fascination with the Apache Brand
|
||||
|
||||
Although we expect that the Apache brand may help attract more contributors, our interest in starting this project is based on the factors mentioned in the fundamentals section. We are interested in joining ASF to increase our connections in the open-source world. Based on extensive collaboration, it is possible to build a community of developers and committers that live longer than the founder.
|
||||
|
||||
### Documentation
|
||||
|
||||
HugeGraph documentation is provided on https://hugegraph.github.io/hugegraph-doc/ in Simplified Chinese, the complete English version of the documentation is being prepared.
|
||||
|
||||
### Initial Source
|
||||
|
||||
This project consists of 2 core sub-projects and 2 other sub-projects, all of which are hosted by [GitHub hugegraph organization](https://github.com/orgs/hugegraph/repositories) since 2018. The codes are already under Apache License Version 2.0. The git address of sub-project repositories are as follows:
|
||||
|
||||
1. The graph database repository `hugegraph`, core sub-project, including graph server, graph engine, and graph storage: https://github.com/hugegraph/hugegraph
|
||||
2. The graph computing repository `hugegraph-computer`, core sub-project, including graph computing and graph algorithms: https://github.com/hugegraph/hugegraph-computer
|
||||
3. The common functions repository `hugegraph-commons`: https://github.com/hugegraph/hugegraph-commons
|
||||
4. The ecosystem repository `hugegraph-toolchain`, including `hugegraph-client`, `hugegraph-loader`, `hugegraph-tools`, `hugegraph-hubble`, `hugegraph-test`, `hugegraph-doc`: https://github.com/hugegraph/hugegraph-toolchain
|
||||
|
||||
### Source and Intellectual Property Submission Plan
|
||||
|
||||
The code is currently under Apache License Version 2.0, and it was verified there were no intellectual property or license issues when it was open-sourced by Baidu in 2018. Baidu will provide SGA and all committers will sign ICLA after HugeGraph is accepted into the Incubator.
|
||||
|
||||
#### External Dependencies
|
||||
|
||||
As all dependencies are managed by Apache Maven, none of the external libraries need to be packaged in a source distribution. All dependencies have Apache compatible licenses except for 4 dependencies: MySQL Connector (GPL), word (GPL), JBoss Logging 3 (LGPL), and jnr-posix (LGPL+GPL), we will remove these dependencies in the future.
|
||||
|
||||
HugeGraph has the following external [dependencies](https://github.com/hugegraph/hugegraph/issues/1632):
|
||||
|
||||
- Apache License
|
||||
|
||||
- HttpClient
|
||||
- HttpCore
|
||||
|
||||
- Apache License 2.0
|
||||
|
||||
- Annotations for Metrics
|
||||
- ansj_seg
|
||||
- Apache Cassandra
|
||||
- Apache Commons
|
||||
- Apache Groovy
|
||||
- Apache HttpClient
|
||||
- Apache HttpCore
|
||||
- Apache Ivy
|
||||
- Apache Log4j
|
||||
- Apache Thrift
|
||||
- Apache TinkerPop
|
||||
- Apache Yetus
|
||||
- Bean Validation API
|
||||
- Caffeine cache
|
||||
- CLI
|
||||
- Sofa
|
||||
- ConcurrentLinkedHashMap
|
||||
- Data Mapper for Jackson
|
||||
- DataStax Java Driver for Apache Cassandra
|
||||
- Disruptor Framework
|
||||
- error-prone annotations
|
||||
- exp4j
|
||||
- fastutil
|
||||
- Findbugs
|
||||
- Google Android Annotations Library
|
||||
- Gson
|
||||
- Guava
|
||||
- Hibernate Validator Engine
|
||||
- HPPC Collections
|
||||
- htrace-core4
|
||||
- IKAnalyzer
|
||||
- io.grpc
|
||||
- J2ObjC Annotations
|
||||
- Jackson
|
||||
- Java Agent for Memory Measurements
|
||||
- Java Concurrency Tools Core Library
|
||||
- JavaPoet
|
||||
- javatuples
|
||||
- jcseg-core
|
||||
- jffi
|
||||
- JJWT
|
||||
- jnr
|
||||
- Joda
|
||||
- jraft
|
||||
- JSON.simple
|
||||
- JVM Integration for Metrics
|
||||
- Lucene
|
||||
- LZ4 and xxHash
|
||||
- Metrics
|
||||
- mmseg4j-core
|
||||
- Netty
|
||||
- Ning-compress-LZF
|
||||
- nlp-lang
|
||||
- Objenesis
|
||||
- OHC core
|
||||
- OpenTracing
|
||||
- perfmark
|
||||
- picocli
|
||||
- proto-google-common-protos
|
||||
- sigar
|
||||
- snappy-java
|
||||
- stream-lib
|
||||
- swagger
|
||||
- Thrift Server implementation backed by LMAX Disruptor
|
||||
- jieba for java
|
||||
- Java Native Access
|
||||
- HanLP
|
||||
- SnakeYAML
|
||||
|
||||
- Apache License 2.0 + GPLv2 License
|
||||
|
||||
- RocksDB JNI
|
||||
|
||||
- BSD License
|
||||
|
||||
- ANTLR 3
|
||||
- ASM
|
||||
- Chinese to Pinyin
|
||||
- Hamcrest
|
||||
- JLine
|
||||
- jcabi
|
||||
- PostgreSQL JDBC Driver - JDBC 4.2
|
||||
- Protocol Buffers
|
||||
- StringTemplate
|
||||
|
||||
- CDDL + GPL License
|
||||
|
||||
- Grizzly
|
||||
- Jersey
|
||||
|
||||
- CDDL + GPLv2 License
|
||||
|
||||
- glassfish
|
||||
- Java Servlet API
|
||||
- javax.ws.rs-api
|
||||
- jersey-inject-hk2
|
||||
- JSR 353 (JSON Processing) Default Provider
|
||||
|
||||
- Eclipse Distribution License
|
||||
|
||||
- Eclipse Collections
|
||||
- JUnit
|
||||
|
||||
- ISC/BSD License
|
||||
|
||||
- jBCrypt
|
||||
|
||||
- LGPL License
|
||||
|
||||
- JBoss Logging 3
|
||||
|
||||
- LGPL + GPL License
|
||||
|
||||
- jnr-posix
|
||||
|
||||
- LGPL 2.1 + MPL 1.1 + Apache License 2.0
|
||||
|
||||
- Javassist
|
||||
|
||||
- MIT License
|
||||
|
||||
- Animal Sniffer Annotations
|
||||
- Mockito
|
||||
- SLF4J
|
||||
- Jedis
|
||||
- high-scale-lib
|
||||
- jnr-x86asm
|
||||
|
||||
- GPL + MIT License
|
||||
|
||||
- Checker Qual
|
||||
|
||||
- GPL License
|
||||
|
||||
- MySQL Connector/J
|
||||
- word
|
||||
|
||||
#### Cryptography
|
||||
|
||||
None
|
||||
|
||||
### Required Resources
|
||||
|
||||
#### Mailing lists
|
||||
|
||||
- hugegraph-dev: [dev@hugegraph.incubator.apache.org](mailto:dev@hugegraph.incubator.apache.org) for development and users discussions.
|
||||
- hugegraph-private: [private@hugegraph.incubator.apache.org](mailto:private@hugegraph.incubator.apache.org) for PPMC discussions.
|
||||
- hugegraph-commits: [commits@hugegraph.incubator.apache.org](mailto:commits@hugegraph.incubator.apache.org) for commits / [pull requests](https://github.com/hugegraph/hugegraph/pulls) and other notifications like code review comments.
|
||||
|
||||
#### Subversion Directory
|
||||
|
||||
None
|
||||
|
||||
#### Git Repositories
|
||||
|
||||
1. `hugegraph`: https://github.com/hugegraph/hugegraph.git
|
||||
2. `hugegraph-computer`: https://github.com/hugegraph/hugegraph-computer.git
|
||||
3. `hugegraph-commons`: https://github.com/hugegraph/hugegraph-commons.git
|
||||
4. `hugegraph-toolchain`: https://github.com/hugegraph/hugegraph-toolchain.git
|
||||
|
||||
#### Issue Tracking
|
||||
|
||||
The community would like to continue using [GitHub Issues](https://github.com/hugegraph/hugegraph/issues) (but will move to github.com/apache/).
|
||||
|
||||
#### Other Resources
|
||||
|
||||
- The community has already chosen [GitHub actions](https://github.com/hugegraph/hugegraph/actions) as continuous integration tools.
|
||||
- The community has already used [codecov](https://github.com/marketplace/codecov) to check code coverage.
|
||||
- The community has already used [mvn repository](https://mvnrepository.com/search?q=hugegraph) as binary package release platform.
|
||||
|
||||
### Initial Committers
|
||||
|
||||
- Jermy Li (javaloveme at gmail dot com)
|
||||
- Linary (liningrui at vip dot qq dot com)
|
||||
- Zhoney (zhangyi89817 at 126 dot com)
|
||||
- Imbajin (0x00 at imbajin.com)
|
||||
- Vaughn (1318247699 at qq dot com)
|
||||
- LiuNanke (liunanke at baidu dot com)
|
||||
- Coderzc (zc1217zc at 126 dot com)
|
||||
- ShouJing (1075185785 at qq dot com)
|
||||
- Xiaobiao Li (13703287619 at 163 dot com)
|
||||
- Haiping Huang (954872405 at qq dot com)
|
||||
- Kidleaf Jiang (kidleaf at 163 dot com)
|
||||
|
||||
### Sponsors
|
||||
|
||||
#### Champion
|
||||
|
||||
- Willem Ning Jiang (ningjiang at apache dot org)
|
||||
|
||||
#### Nominated Mentors
|
||||
|
||||
- Trista Pan (panjuan at apache dot org)
|
||||
- Lidong Dai (lidongdai at apache dot org)
|
||||
- Xiangdong Huang (hxd at apache dot org)
|
||||
- Yu Li (liyu at apache dot org)
|
||||
|
||||
#### Sponsoring Entity
|
||||
|
||||
We are expecting the Apache Incubator could sponsor this project.
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
name: "CLA Assistant"
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_target:
|
||||
types: [opened,closed,synchronize]
|
||||
|
||||
jobs:
|
||||
CLAssistant:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "CLA Assistant"
|
||||
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
|
||||
uses: cla-assistant/github-action@v2.1.3-beta
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
# the below token should have repo scope and must be manually added by you in the repository's secret
|
||||
PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
||||
with:
|
||||
path-to-signatures: '.github/cla-signatures/cla.json'
|
||||
path-to-document: 'https://github.com/hugegraph/hugegraph-doc/blob/master/CLA.md' # e.g. a CLA or a DCO document
|
||||
custom-allsigned-prcomment: '**Good**! All Contributors have signed the [CLA](https://github.com/hugegraph/hugegraph-doc/blob/master/CLA.md).'
|
||||
# branch should not be protected
|
||||
branch: 'cla-assist'
|
||||
allowlist: bot*
|
||||
lock-pullrequest-aftermerge: false
|
||||
|
||||
# the following are the optional inputs - If the optional inputs are not given, then default values will be taken
|
||||
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
|
||||
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
|
||||
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
|
||||
#signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
|
||||
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
|
||||
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
|
||||
#use-dco-flag: true - If you are using DCO instead of CLA
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
name: release package
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [ published ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }}
|
||||
steps:
|
||||
- name: Install JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
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: Package
|
||||
run: |
|
||||
mvn clean package -DskipTests -ntp
|
||||
|
||||
- name: Rename file
|
||||
if: contains(env.TAG_NAME, "-")
|
||||
run: mv "$(find hugegraph-*.tar.gz | head -1)" hugegraph-${TAG_NAME/#v/}.tar.gz
|
||||
|
||||
- name: Upload to GitHub
|
||||
uses: xresloader/upload-to-github-release@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
file: "hugegraph-*.tar.gz"
|
||||
tag_name: ${{ github.ref_name }}
|
||||
overwrite: true
|
||||
verbose: true
|
||||
draft: false
|
||||
update_latest_release: true
|
||||
|
||||
- name: Release Maven package
|
||||
uses: samuelmeuli/action-maven-publish@v1
|
||||
with:
|
||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
|
||||
nexus_username: ${{ secrets.NEXUS_USERNAME }}
|
||||
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
|
||||
server_id: sonatype-nexus-staging
|
||||
maven_profiles: "release"
|
||||
maven_args: >
|
||||
-Dmaven.test.skip=true
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
name: "3rd-party"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- /^release-.*$/
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
dependency-check:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||
SCRIPT_DEPENDENCY: install-dist/scripts/dependency
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up JDK 11
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '11'
|
||||
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
|
||||
run: |
|
||||
mvn install -Dmaven.test.skip=true -ntp
|
||||
- name: generate current dependencies
|
||||
run: |
|
||||
bash $SCRIPT_DEPENDENCY/regenerate_known_dependencies.sh current-dependencies.txt
|
||||
- name: check third dependencies
|
||||
run: |
|
||||
bash $SCRIPT_DEPENDENCY/check_dependencies.sh
|
||||
|
||||
dependency-review:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 'Checkout Repository'
|
||||
uses: actions/checkout@v4
|
||||
- name: 'Dependency Review'
|
||||
uses: actions/dependency-review-action@v3
|
||||
# Refer: https://github.com/actions/dependency-review-action
|
||||
with:
|
||||
# TODO: reset critical to low before releasing
|
||||
fail-on-severity: critical
|
||||
# Action will fail if dependencies don't match the list
|
||||
#allow-licenses: Apache-2.0, MIT
|
||||
#deny-licenses: GPL-3.0, AGPL-1.0, AGPL-3.0, LGPL-2.0, CC-BY-3.0
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
name: hugegraph ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- /^release-.*$/
|
||||
- /^test-.*$/
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- /^release-.*$/
|
||||
- /^test-.*$/
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-16.04
|
||||
env:
|
||||
TRAVIS_DIR: hugegraph-dist/src/assembly/travis
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
BACKEND: [memory, cassandra, scylladb, hbase, rocksdb]
|
||||
steps:
|
||||
- name: Install JDK 8
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '8'
|
||||
distribution: 'adopt'
|
||||
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Compile
|
||||
run: |
|
||||
mvn compile -Dmaven.javadoc.skip=true | grep -v "Downloading\|Downloaded"
|
||||
|
||||
- name: Prepare env and service
|
||||
run: |
|
||||
$TRAVIS_DIR/install-backend.sh ${{ matrix.BACKEND }}
|
||||
|
||||
- name: Run test
|
||||
run: |
|
||||
mvn test -P core-test,${{ matrix.BACKEND }}
|
||||
$TRAVIS_DIR/run-api-test.sh ${{ matrix.BACKEND }}
|
||||
$TRAVIS_DIR/run-unit-test.sh ${{ matrix.BACKEND }}
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
file: target/site/jacoco/jacoco.xml
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, release-* ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
# branches: [ master ] # enable in all PRs
|
||||
schedule:
|
||||
- cron: '33 0 * * 5'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
env:
|
||||
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
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.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
name: "HugeGraph-Commons CI"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- /^release-.*$/
|
||||
- /^test-.*$/
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build-commons:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# TODO: reset use stage to false later
|
||||
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
JAVA_VERSION: ['11']
|
||||
|
||||
steps:
|
||||
- name: Install JDK ${{ matrix.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: ${{ matrix.JAVA_VERSION }}
|
||||
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
|
||||
cp -vf .github/configs/settings.xml $HOME/.m2/settings.xml && cat $HOME/.m2/settings.xml
|
||||
|
||||
- name: Compile
|
||||
run: |
|
||||
mvn compile -Dmaven.javadoc.skip=true -ntp
|
||||
|
||||
- name: Run common test
|
||||
run: |
|
||||
mvn test -pl hugegraph-commons/hugegraph-common -Dtest=UnitTestSuite
|
||||
|
||||
- name: Run rpc test
|
||||
run: |
|
||||
mvn test -pl hugegraph-commons/hugegraph-rpc -Dtest=UnitTestSuite
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v3.0.0
|
||||
with:
|
||||
file: target/jacoco.xml
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
name: "License Checker"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'release-*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check-license:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Check License Header
|
||||
uses: apache/skywalking-eyes@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
log: info
|
||||
token: ${{ github.token }}
|
||||
config: .licenserc.yaml
|
||||
|
||||
- name: License Check (RAT)
|
||||
run: |
|
||||
mvn apache-rat:check -ntp
|
||||
find ./ -name rat.txt -print0 | xargs -0 -I file cat file > merged-rat.txt
|
||||
grep "Binaries" merged-rat.txt -C 3 && cat merged-rat.txt
|
||||
|
|
@ -0,0 +1,219 @@
|
|||
name: "HugeGraph-PD & Store & Hstore 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
|
||||
# TODO: reset use stage to false later
|
||||
USE_STAGE: 'true' # 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: Run common test
|
||||
run: |
|
||||
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-common-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run core test
|
||||
run: |
|
||||
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test -DskipCommonsTests=true
|
||||
|
||||
# The above tests do not require starting a PD instance.
|
||||
|
||||
- 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
|
||||
|
||||
- name: Run client test
|
||||
run: |
|
||||
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-client-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run rest test
|
||||
run: |
|
||||
mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-rest-test -DskipCommonsTests=true
|
||||
|
||||
- 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: 'true' # 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 common test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-common-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run client test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-client-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run core test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-core-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run rocksdb test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-rocksdb-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run server test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-server-test -DskipCommonsTests=true
|
||||
|
||||
- name: Run raft-core test
|
||||
run: |
|
||||
mvn test -pl hugegraph-store/hg-store-test -am -P store-raftcore-test -DskipCommonsTests=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
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
name: "HugeGraph-Server CI"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- 'release-*'
|
||||
- 'test-*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build-server:
|
||||
# TODO: we need test & replace it to ubuntu-24.04 or ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
# TODO: reset use stage to false later
|
||||
USE_STAGE: 'true' # Whether to include the stage repository.
|
||||
TRAVIS_DIR: hugegraph-server/hugegraph-dist/src/assembly/travis
|
||||
REPORT_DIR: target/site/jacoco
|
||||
BACKEND: ${{ matrix.BACKEND }}
|
||||
TRIGGER_BRANCH_NAME: ${{ github.ref_name }}
|
||||
HEAD_BRANCH_NAME: ${{ github.head_ref }}
|
||||
BASE_BRANCH_NAME: ${{ github.base_ref }}
|
||||
TARGET_BRANCH_NAME: ${{ github.base_ref != '' && github.base_ref || github.ref_name }}
|
||||
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:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
BACKEND: [ memory, rocksdb, hbase, cassandra, mysql, postgresql, scylladb ]
|
||||
JAVA_VERSION: [ '11' ]
|
||||
|
||||
steps:
|
||||
- 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
|
||||
with:
|
||||
java-version: ${{ matrix.JAVA_VERSION }}
|
||||
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: Use staged maven repo settings
|
||||
if: ${{ env.USE_STAGE == 'true' }}
|
||||
run: |
|
||||
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
|
||||
run: |
|
||||
mvn clean compile -U -Dmaven.javadoc.skip=true -ntp
|
||||
|
||||
- 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
|
||||
|
||||
# TODO: disable raft test in normal PR due to the always timeout problem
|
||||
- name: Run raft test
|
||||
if: ${{ env.RAFT_MODE == 'true' && 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
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ${{ env.REPORT_DIR }}/*.xml
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: Mark stale issues and pull requests
|
||||
name: "Mark stale issues and pull requests"
|
||||
|
||||
on:
|
||||
schedule:
|
||||
|
|
@ -20,14 +20,16 @@ jobs:
|
|||
stale-pr-message: 'Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label'
|
||||
stale-issue-label: 'inactive'
|
||||
stale-pr-label: 'inactive'
|
||||
exempt-issue-labels: 'feature,bug,enhancement,improvement,wontfix,todo'
|
||||
exempt-issue-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
|
||||
exempt-pr-labels: 'feature,bug,enhancement,improvement,todo,guide,doc,help wanted,security'
|
||||
exempt-all-milestones: true
|
||||
|
||||
days-before-issue-stale: 15
|
||||
days-before-issue-close: 20
|
||||
days-before-pr-stale: 30
|
||||
days-before-pr-close: 180
|
||||
operations-per-run: 10
|
||||
start-date: '2018-10-01T00:00:00Z'
|
||||
start-date: '2016-10-01T00:00:00Z'
|
||||
|
||||
exempt-all-assignees: true
|
||||
remove-stale-when-updated: true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,51 @@
|
|||
.DS_Store
|
||||
*.iml
|
||||
target/
|
||||
**.db
|
||||
logs/
|
||||
ui
|
||||
node_modules
|
||||
upload-files/
|
||||
demo*
|
||||
gen-java
|
||||
*.class
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
.svn
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/*
|
||||
!.idea/vcs.xml
|
||||
!.idea/icon.png
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
dist/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*/.DS_Store
|
||||
**/*.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
*.orig
|
||||
*.rej
|
||||
**/.keep
|
||||
|
|
@ -10,12 +55,35 @@
|
|||
*.swp
|
||||
*.log
|
||||
*.pyc
|
||||
.idea
|
||||
.svn
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
target
|
||||
gen-java
|
||||
build
|
||||
node*
|
||||
|
||||
# maven ignore
|
||||
apache-hugegraph-*/
|
||||
output/
|
||||
*.war
|
||||
*.zip
|
||||
*.tar
|
||||
*.tar.gz*
|
||||
tree.txt
|
||||
*.versionsBackup
|
||||
.flattened-pom.xml
|
||||
|
||||
|
||||
# eclipse ignore
|
||||
.settings/
|
||||
|
||||
# temp ignore
|
||||
*.cache
|
||||
*.diff
|
||||
*.patch
|
||||
*.tmp
|
||||
|
||||
# system ignore
|
||||
Thumbs.db
|
||||
hs_err_pid*
|
||||
# mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
# blueJ files
|
||||
*.ctxt
|
||||
|
||||
# docker volumes ignore
|
||||
hugegraph-server/hugegraph-dist/docker/data/
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 8.3 KiB |
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<project version="4">
|
||||
<component name="IssueNavigationConfiguration">
|
||||
<option name="links">
|
||||
<list>
|
||||
<IssueNavigationLink>
|
||||
<option name="issueRegexp" value="#(\d+)" />
|
||||
<!--
|
||||
GitHub share the sequence number of issues and pull requests, and it will redirect to
|
||||
the right place when the the sequence number not match kind.
|
||||
-->
|
||||
<option name="linkRegexp" value="https://github.com/apache/hugegraph/pull/$1" />
|
||||
</IssueNavigationLink>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
header: # `header` section is configurations for source codes license header.
|
||||
license:
|
||||
spdx-id: Apache-2.0 # the spdx id of the license, it's convenient when your license is standard SPDX license.
|
||||
copyright-owner: Apache Software Foundation # the copyright owner to replace the [owner] in the `spdx-id` template.
|
||||
content: | # `license` will be used as the content when `fix` command needs to insert a license header.
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
# `pattern` is optional regexp if all the file headers are the same as `license` or the license of `spdx-id` and `copyright-owner`.
|
||||
pattern: |
|
||||
Licensed to the Apache Software Foundation \(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.
|
||||
paths: # `paths` are the path list that will be checked (and fixed) by license-eye, default is ['**'].
|
||||
- '**'
|
||||
|
||||
paths-ignore: # `paths-ignore` are the path list that will be ignored by license-eye.
|
||||
- '.gitignore'
|
||||
- '.gitattributes'
|
||||
- 'LICENSE'
|
||||
- 'NOTICE'
|
||||
- 'DISCLAIMER'
|
||||
- '**/*.versionsBackup'
|
||||
- '**/*.versionsBackup'
|
||||
- '**/*.proto'
|
||||
- '**/*.log'
|
||||
- '**/*.txt'
|
||||
- '**/*.json'
|
||||
- '**/*.conf'
|
||||
- '**/*.map'
|
||||
- '**/*.properties'
|
||||
- '**/RaftRequests.java'
|
||||
- 'dist/**/*'
|
||||
- 'hugegraph-server/hugegraph-dist'
|
||||
- '**/assembly/static/bin/hugegraph.service'
|
||||
- 'scripts/dev/reviewers'
|
||||
- 'scripts/dev/reviewers'
|
||||
- '**/*.md'
|
||||
- '**/dependency-reduced-pom.xml'
|
||||
- '**/logs/*.log'
|
||||
- '**/META-INF/**/*'
|
||||
- '**/target/*'
|
||||
- 'style/*'
|
||||
- 'ChangeLog'
|
||||
- 'CONFIG.ini'
|
||||
- 'GROUPS'
|
||||
- 'OWNERS'
|
||||
- '.github/**/*'
|
||||
- '**/*.iml'
|
||||
- '**/*.iws'
|
||||
- '**/*.ipr'
|
||||
- '**/META-INF/MANIFEST.MF'
|
||||
- '.repository/**'
|
||||
- '**/.flattened-pom.xml'
|
||||
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/id/SnowflakeIdGenerator.java'
|
||||
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java'
|
||||
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java'
|
||||
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java'
|
||||
- 'hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java'
|
||||
- 'hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/ProcessBasicSuite.java'
|
||||
- 'hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/StructureBasicSuite.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'
|
||||
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
|
||||
|
||||
# license-location-threshold specifies the index threshold where the license header can be located,
|
||||
# after all, a "header" cannot be TOO far from the file start.
|
||||
license-location-threshold: 80
|
||||
38
BUILDING.md
38
BUILDING.md
|
|
@ -1,28 +1,35 @@
|
|||
Building hugegraph
|
||||
Building HugeGraph
|
||||
--------------
|
||||
|
||||
Required:
|
||||
|
||||
* Java 8 (0.9 and later)
|
||||
* Maven
|
||||
* Java 11
|
||||
* Maven 3.5+
|
||||
|
||||
To build without executing tests: `mvn clean package -Dmaven.test.skip=true`
|
||||
|
||||
## Building in IDEA
|
||||
|
||||
To build without executing tests:
|
||||
|
||||
```
|
||||
mvn clean
|
||||
mvn package -DskipTests
|
||||
```
|
||||
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 a project.
|
||||
|
||||
## Building on Eclipse IDE
|
||||
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.
|
||||
Could also refer [Dev-In-IDEA](https://hugegraph.apache.org/docs/contribution-guidelines/hugegraph-server-idea-setup/) for more details.
|
||||
|
||||
## 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:
|
||||
|
||||
1. Right-click on your project -> "Run As..." -> "Run Configurations..."
|
||||
2. On "Goals", populate with `install`
|
||||
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`
|
||||
6. Under "Value:", add the path where `java` is located
|
||||
7. Click "OK"
|
||||
|
|
@ -32,14 +39,3 @@ To find the Java binary in your environment, run the appropriate command for you
|
|||
* Linux/macOS: `which java`
|
||||
* 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 Porjects".
|
||||
3. Choose root module "hugegraph: Distributed Graph Database", unfold the
|
||||
menu of "Lifecycle".
|
||||
4. Click the "Toggle 'Skip Tests' Mode" button which is located on the top
|
||||
navibar of "Maven Projects" window to skip tests.
|
||||
5. Double click "package" or "install" to build project.
|
||||
|
|
@ -1,24 +1,31 @@
|
|||
# How to Contribute to HugeGraph
|
||||
|
||||
Thanks for taking the time to contribute! As an open source project, HugeGraph is looking forward to be contributed from everyone, and we are also grateful to all of the contributors.
|
||||
> Refer [website-doc](https://hugegraph.apache.org/docs/contribution-guidelines/) for the latest information.
|
||||
|
||||
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:
|
||||
|
||||
<img width="884" alt="image" src="https://user-images.githubusercontent.com/9625821/159643158-8bf72c0a-93c3-4a58-8912-7b2ab20ced1d.png">
|
||||
|
||||
## 1. Preparation
|
||||
|
||||
**Recommended**: You can use [GitHub desktop](https://desktop.github.com/) to greatly simplify the PR process.
|
||||
|
||||
We can contribute by reporting issues, submitting code patches or any other feedback.
|
||||
|
||||
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/hugegraph/hugegraph/fork](https://github.com/hugegraph/hugegraph/fork)
|
||||
2. Fork HugeGraph repo from GitHub: [https://github.com/apache/incubator-hugegraph/fork](https://github.com/apache/incubator-hugegraph/fork)
|
||||
|
||||
3. Clone code from fork repo to local: [https://github.com/${GITHUB_USER_NAME}/hugegraph](https://github.com/${GITHUB_USER_NAME}/hugegraph)
|
||||
3. Clone code from fork repo to local: [https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph](https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph)
|
||||
|
||||
```shell
|
||||
# clone code from remote to local repo
|
||||
git clone https://github.com/${GITHUB_USER_NAME}/hugegraph
|
||||
git clone https://github.com/${GITHUB_USER_NAME}/incubator-hugegraph.git hugegraph
|
||||
```
|
||||
|
||||
4. Configure local HugeGraph repo
|
||||
|
|
@ -27,26 +34,22 @@ Before submitting the code, we need to do some preparation:
|
|||
cd hugegraph
|
||||
|
||||
# add upstream to synchronize the latest code
|
||||
git remote add hugegraph https://github.com/hugegraph/hugegraph
|
||||
git remote add hugegraph https://github.com/apache/incubator-hugegraph
|
||||
|
||||
# set name and email to push code to github
|
||||
git config user.name "{full-name}" # like "Jermy Li"
|
||||
git config user.email "{email-address-of-github}" # like "jermy@gmail.com"
|
||||
git config user.email "{email-address-of-github}" # like "jermy@apache.org"
|
||||
```
|
||||
|
||||
5. Sign the HugeGraph CLA: [https://cla-assistant.io/hugegraph/hugegraph](https://cla-assistant.io/hugegraph/hugegraph)
|
||||
|
||||
Optional: You can use [Github desktop](https://desktop.github.com/) to greatly simplify the commit and update process.
|
||||
|
||||
## 2. Create an Issue on GitHub
|
||||
|
||||
If you encounter bugs or have any questions, please go to [GitHub Issues](https://github.com/hugegraph/hugegraph/issues) to report them and feel free to [create an issue](https://github.com/hugegraph/hugegraph/issues/new).
|
||||
If you encounter bugs or have any questions, please go to [GitHub Issues](https://github.com/apache/incubator-hugegraph/issues) to report them and feel free to [create an issue](https://github.com/apache/incubator-hugegraph/issues/new).
|
||||
|
||||
## 3. Make changes of code locally
|
||||
|
||||
#### 3.1 Create a new branch
|
||||
|
||||
Please don't use master branch for development. Instead we should create a new branch:
|
||||
Please don't use master branch for development. Instead, we should create a new branch:
|
||||
|
||||
```shell
|
||||
# checkout master branch
|
||||
|
|
@ -63,12 +66,26 @@ Assume that we need to modify some files like "HugeGraph.java" and "HugeFactory.
|
|||
|
||||
```shell
|
||||
# modify code to fix a bug
|
||||
vim hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java
|
||||
vim hugegraph-core/src/main/java/com/baidu/hugegraph/HugeFactory.java
|
||||
vim hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
||||
vim hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||
# run test locally (optional)
|
||||
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
|
||||
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.
|
||||
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-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-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`
|
||||
- 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
|
||||
- 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.
|
||||
|
||||
#### 3.3 Commit changes to git repo
|
||||
|
||||
|
|
@ -76,8 +93,8 @@ After the code has been completed, we submit them to the local git repo:
|
|||
|
||||
```shell
|
||||
# add files to local git index
|
||||
git add hugegraph-core/src/main/java/com/baidu/hugegraph/HugeGraph.java
|
||||
git add hugegraph-core/src/main/java/com/baidu/hugegraph/HugeFactory.java
|
||||
git add hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeGraph.java
|
||||
git add hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/HugeFactory.java
|
||||
# commit to local git repo
|
||||
git commit
|
||||
```
|
||||
|
|
@ -90,7 +107,7 @@ Fix bug: run deploy multiple times
|
|||
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
|
||||
|
||||
|
|
@ -101,16 +118,22 @@ Push the local commit to GitHub fork repo:
|
|||
git push origin bugfix-branch:bugfix-branch
|
||||
```
|
||||
|
||||
Note that since GitHub requires submitting code through `username + token` (instead of using `username + password` directly), you need to create a GitHub token from https://github.com/settings/tokens:
|
||||
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/9625821/163524204-7fe0e6bf-9c8b-4b1a-ac65-6a0ac423eb16.png">
|
||||
|
||||
## 4. Create a Pull Request
|
||||
|
||||
Go to the web page of GitHub fork repo, there would be a chance to create a Pull Request after pushing to a new branch, just click button "Compare & pull request" to do it. Then edit the description for proposed changes, which can just be copied from the commit message.
|
||||
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:
|
||||
<img width="1280" alt="image" src="https://user-images.githubusercontent.com/9625821/163522445-2a50a72a-dea2-434f-9868-3a0d40d0d037.png">
|
||||
|
||||
## 5. Code review
|
||||
|
||||
Maintainers will start the code review after all the **automatic** checks are passed:
|
||||
|
||||
- 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.
|
||||
|
||||
|
|
@ -125,9 +148,11 @@ If we have not passed the review, don't be discouraged. Usually a commit needs t
|
|||
After the further changes, we submit them to the local repo:
|
||||
|
||||
```shell
|
||||
# commit all updated files in amend mode
|
||||
# instead of creating a new commit
|
||||
git commit -a --amend
|
||||
# commit all updated files in a new commit,
|
||||
# please feel free to enter any appropriate commit message, note that
|
||||
# we will squash all commits in the pull request as one commit when
|
||||
# merging into the master branch.
|
||||
git commit -a
|
||||
```
|
||||
|
||||
> If there are conflicts that prevent the code from being merged, we need to rebase on master branch:
|
||||
|
|
@ -148,8 +173,8 @@ And push it to GitHub fork repo again:
|
|||
git push -f origin bugfix-branch:bugfix-branch
|
||||
```
|
||||
|
||||
Github will automatically update the Pull Request after we push it, just wait for code review.
|
||||
GitHub will automatically update the Pull Request after we push it, 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)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
Apache HugeGraph (incubating) is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator PMC.
|
||||
|
||||
Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications,
|
||||
and decision making process have stabilized in a manner consistent with other successful ASF projects.
|
||||
|
||||
While incubation status is not necessarily a reflection of the completeness or stability of the code,
|
||||
it does indicate that the project has yet to be fully endorsed by the ASF.
|
||||
51
Dockerfile
51
Dockerfile
|
|
@ -1,51 +0,0 @@
|
|||
FROM ubuntu:xenial
|
||||
|
||||
LABEL maintainer="HugeGraph Docker Maintainers <hugegraph@googlegroups.com>"
|
||||
|
||||
ENV PKG_URL https://github.com/hugegraph
|
||||
|
||||
# 1. Install needed dependencies of GraphServer & RocksDB
|
||||
RUN set -x \
|
||||
&& apt-get -q update \
|
||||
&& apt-get -q install -y --no-install-recommends --no-install-suggests \
|
||||
curl \
|
||||
lsof \
|
||||
g++ \
|
||||
gcc \
|
||||
openjdk-8-jdk \
|
||||
&& apt-get clean
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 2. Init HugeGraph Sever
|
||||
# (Optional) You can set the ip of github to speed up the local build
|
||||
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
|
||||
ENV SERVER_VERSION 0.10.4
|
||||
RUN set -e \
|
||||
&& mkdir -p /root/hugegraph-server \
|
||||
&& curl -L -S ${PKG_URL}/hugegraph/releases/download/v${SERVER_VERSION}/hugegraph-${SERVER_VERSION}.tar.gz -o /root/server.tar.gz \
|
||||
&& tar xzf /root/server.tar.gz --strip-components 1 -C /root/hugegraph-server \
|
||||
&& rm /root/server.tar.gz \
|
||||
&& cd /root/hugegraph-server/ \
|
||||
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
|
||||
&& sed -n '63p' ./bin/start-hugegraph.sh | grep "&" > /dev/null && sed -i 63{s/\&$/#/g} ./bin/start-hugegraph.sh \
|
||||
&& sed -n '74p' ./bin/start-hugegraph.sh | grep "exit" > /dev/null && sed -i 74{s/^/#/g} ./bin/start-hugegraph.sh \
|
||||
&& ./bin/init-store.sh
|
||||
|
||||
# 3. Prepare for HugeGraph Studio
|
||||
ENV STUDIO_VERSION 0.10.0
|
||||
# (Optional) You can set the ip of github to speed up the local build
|
||||
# && echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
|
||||
RUN set -e \
|
||||
&& mkdir -p /root/hugegraph-studio \
|
||||
&& curl -L -S ${PKG_URL}/hugegraph-studio/releases/download/v${STUDIO_VERSION}/hugegraph-studio-${STUDIO_VERSION}.tar.gz -o /root/studio.tar.gz \
|
||||
&& tar xzf /root/studio.tar.gz --strip-components 1 -C /root/hugegraph-studio \
|
||||
&& rm /root/studio.tar.gz \
|
||||
&& cd /root/hugegraph-studio/ \
|
||||
&& sed -i "s/^studio.server.host.*$/studio.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties \
|
||||
&& sed -i "s/^graph.server.host.*$/graph.server.host=0.0.0.0/g" ./conf/hugegraph-studio.properties
|
||||
|
||||
EXPOSE 8080 8088
|
||||
WORKDIR /root
|
||||
VOLUME /root
|
||||
|
||||
ENTRYPOINT ["./hugegraph-server/bin/start-hugegraph.sh"]
|
||||
18
LICENSE
18
LICENSE
|
|
@ -1,4 +1,4 @@
|
|||
Apache License
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
|
|
@ -200,3 +200,19 @@ Apache License
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
========================================================================
|
||||
Apache 2.0 licenses
|
||||
========================================================================
|
||||
|
||||
The following components are provided under the Apache License. See project link for details.
|
||||
The text of each license is the standard Apache 2.0 license.
|
||||
|
||||
hugegraph-server/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/ProcessBasicSuite.java from https://github.com/apache/tinkerpop
|
||||
hugegraph-server/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/traversal/optimize/HugeScriptTraversal.java from https://github.com/apache/tinkerpop
|
||||
hugegraph-server/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/define/Cardinality.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-server/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/CypherPlugin.java from https://github.com/opencypher/cypher-for-gremlin
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
Apache HugeGraph(incubating)
|
||||
Copyright 2022-2024 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
|
||||
The initial codebase was donated to the ASF by HugeGraph Authors, copyright 2017-2021.
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
This product contains code form the Apache TinkerPop Project:
|
||||
-----------------------------------------------------------------------
|
||||
Apache TinkerPop
|
||||
Copyright 2015-2022 The Apache Software Foundation.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Activiti
|
||||
------------------------------------------------------------------------
|
||||
Activiti BPM Platform
|
||||
Copyright 2010-2014 Alfresco Software, Ltd.
|
||||
|
||||
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLWriterHelper.java
|
||||
contains DelegatingXMLStreamWriter.java and IndentingXMLStreamWriter.java from
|
||||
https://github.com/Activiti/Activiti/tree/activiti-5.16/modules/activiti-bpmn-converter/src/main/java/org/activiti/bpmn/converter
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Apache Kerby
|
||||
------------------------------------------------------------------------
|
||||
Apache Kerby
|
||||
Copyright 2015-2017 The Apache Software Foundation
|
||||
|
||||
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/auth/JaasKrbUtil.java
|
||||
from
|
||||
https://github.com/apache/directory-kerby/blob/kerby-all-1.0.0/kerby-kerb/kerb-simplekdc/src/main/java/org/apache/kerby/kerberos/kerb/client/JaasKrbUtil.java
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
This product contains code form the JanusGraph Project:
|
||||
-----------------------------------------------------------------------
|
||||
==============================================================
|
||||
JanusGraph: Distributed Graph Database
|
||||
Copyright 2012 with JanusGraph Authors
|
||||
==============================================================
|
||||
|
||||
This product includes software developed by JanusGraph contributors listed
|
||||
in CONTRIBUTORS.txt; JanusGraph copyright holders are listed in AUTHORS.txt.
|
||||
|
||||
This product is based on Titan, originally developed by Aurelius (acquired by
|
||||
DataStax) and the following individuals:
|
||||
|
||||
* Matthias Broecheler
|
||||
* Dan LaRocque
|
||||
* Marko A. Rodriguez
|
||||
* Stephen Mallette
|
||||
* Pavel Yaskevich
|
||||
90
README.md
90
README.md
|
|
@ -1,34 +1,98 @@
|
|||
# HugeGraph
|
||||
<h1 align="center">
|
||||
<img width="720" alt="hugegraph-logo" src="https://github.com/apache/incubator-hugegraph/assets/38098239/e02ffaed-4562-486b-ba8f-e68d02bb0ea6" style="zoom:100%;" />
|
||||
</h1>
|
||||
|
||||
<h3 align="center">A graph database that supports more than 10 billion data, high performance and scalability</h3>
|
||||
|
||||
<div align="center">
|
||||
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
[](https://github.com/hugegraph/hugegraph/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/hugegraph/hugegraph)
|
||||
[](https://github.com/apache/incubator-hugegraph/actions/workflows/ci.yml)
|
||||
[](https://github.com/apache/incubator-hugegraph/actions/workflows/licence-checker.yml)
|
||||
[](https://github.com/apache/hugegraph/releases)
|
||||
|
||||
</div>
|
||||
|
||||
## 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).
|
||||
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).
|
||||
|
||||
HugeGraph is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database). Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language).
|
||||
|
||||
## Features
|
||||
|
||||
- Compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/), supporting [Gremlin](https://tinkerpop.apache.org/gremlin.html)
|
||||
- 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
|
||||
- Multi-type Indexes, supporting exact query, range query and complex conditions combination query
|
||||
- Plug-in Backend Store Driver Framework, supporting RocksDB, Cassandra, ScyllaDB, HBase and MySQL now and easy to add other backend store driver if needed
|
||||
- Integration with Hadoop/Spark
|
||||
- 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
|
||||
|
||||
## Learn More
|
||||
|
||||
The [project homepage](https://hugegraph.github.io/hugegraph-doc/) contains more information on HugeGraph and provides links to documentation, getting-started guides and release downloads.
|
||||
## Quick Start
|
||||
|
||||
## Contributing
|
||||
### 1. Docker Way (Convenient for Test)
|
||||
|
||||
Welcome to contribute to HugeGraph, please see [`How to Contribute`](CONTRIBUTING.md) for more information.
|
||||
We can use `docker run -itd --name=graph -p 8080:8080 hugegraph/hugegraph` to quickly start an inner
|
||||
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))
|
||||
|
||||
> 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
|
||||
|
||||
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.
|
||||
|
||||
### 3. Source Building Way
|
||||
|
||||
Visit [Source Building Page](https://hugegraph.apache.org/docs/quickstart/hugegraph-server/#33-source-code-compilation) and follow the
|
||||
steps to build the source code and start the server.
|
||||
|
||||
The project [doc page](https://hugegraph.apache.org/docs/) contains more information on HugeGraph
|
||||
and provides detailed documentation for users. (Structure / Usage / API / Configs...)
|
||||
|
||||
And here are links of other **HugeGraph** component/repositories:
|
||||
1. [hugegraph-toolchain](https://github.com/apache/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/hugegraph-computer) (integrated **graph computing** system)
|
||||
3. [hugegraph-commons](https://github.com/apache/hugegraph-commons) (**common & rpc** libs)
|
||||
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
|
||||
|
||||
HugeGraph is licensed under Apache 2.0 License.
|
||||
HugeGraph is licensed under [Apache 2.0 License](LICENSE).
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
- Welcome to contribute to HugeGraph, please see [`How to Contribute`](CONTRIBUTING.md) & [Guidelines](https://hugegraph.apache.org/docs/contribution-guidelines/) for more information.
|
||||
- Note: It's recommended to use [GitHub Desktop](https://desktop.github.com/) to greatly simplify the PR and commit process.
|
||||
- Thank you to all the people who already contributed to HugeGraph!
|
||||
|
||||
[](https://github.com/apache/incubator-hugegraph/graphs/contributors)
|
||||
|
||||
|
||||
## Thanks
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
- [GitHub Issues](https://github.com/apache/incubator-hugegraph/issues): Feedback on usage issues and functional requirements (quick response)
|
||||
- Feedback Email: [dev@hugegraph.apache.org](mailto:dev@hugegraph.apache.org) ([subscriber](https://hugegraph.apache.org/docs/contribution-guidelines/subscribe/) only)
|
||||
- WeChat public account: Apache HugeGraph, welcome to scan this QR code to follow us.
|
||||
|
||||
<img src="https://github.com/apache/incubator-hugegraph-doc/blob/master/assets/images/wechat.png?raw=true" alt="QR png" width="300"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: hugegraph-pd
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
license:
|
||||
verify-path: ./conf/verify-license.json
|
||||
license-path: ./conf/hugegraph.license
|
||||
grpc:
|
||||
port: 8686
|
||||
host: 127.0.0.1
|
||||
|
||||
server:
|
||||
port: 8620
|
||||
|
||||
pd:
|
||||
data-path: ./pd_data
|
||||
patrol-interval: 1800
|
||||
initial-store-count: 3
|
||||
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||
|
||||
raft:
|
||||
address: 127.0.0.1:8610
|
||||
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||
|
||||
store:
|
||||
max-down-time: 172800
|
||||
monitor_data_enabled: true
|
||||
monitor_data_interval: 1 minute
|
||||
monitor_data_retention: 1 day
|
||||
initial-store-count: 1
|
||||
|
||||
partition:
|
||||
default-shard-count: 1
|
||||
store-max-shard-count: 12
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: hugegraph-pd
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
license:
|
||||
verify-path: ./conf/verify-license.json
|
||||
license-path: ./conf/hugegraph.license
|
||||
grpc:
|
||||
port: 8687
|
||||
host: 127.0.0.1
|
||||
|
||||
server:
|
||||
port: 8621
|
||||
|
||||
pd:
|
||||
data-path: ./pd_data
|
||||
patrol-interval: 1800
|
||||
initial-store-count: 3
|
||||
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||
|
||||
raft:
|
||||
address: 127.0.0.1:8611
|
||||
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||
|
||||
store:
|
||||
max-down-time: 172800
|
||||
monitor_data_enabled: true
|
||||
monitor_data_interval: 1 minute
|
||||
monitor_data_retention: 1 day
|
||||
initial-store-count: 1
|
||||
|
||||
partition:
|
||||
default-shard-count: 1
|
||||
store-max-shard-count: 12
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: hugegraph-pd
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
license:
|
||||
verify-path: ./conf/verify-license.json
|
||||
license-path: ./conf/hugegraph.license
|
||||
grpc:
|
||||
port: 8688
|
||||
host: 127.0.0.1
|
||||
|
||||
server:
|
||||
port: 8622
|
||||
|
||||
pd:
|
||||
data-path: ./pd_data
|
||||
patrol-interval: 1800
|
||||
initial-store-count: 3
|
||||
initial-store-list: 127.0.0.1:8500,127.0.0.1:8501,127.0.0.1:8502
|
||||
|
||||
raft:
|
||||
address: 127.0.0.1:8612
|
||||
peers-list: 127.0.0.1:8610,127.0.0.1:8611,127.0.0.1:8612
|
||||
|
||||
store:
|
||||
max-down-time: 172800
|
||||
monitor_data_enabled: true
|
||||
monitor_data_interval: 1 minute
|
||||
monitor_data_retention: 1 day
|
||||
initial-store-count: 1
|
||||
|
||||
partition:
|
||||
default-shard-count: 1
|
||||
store-max-shard-count: 12
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
pdserver:
|
||||
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
grpc:
|
||||
host: 127.0.0.1
|
||||
port: 8500
|
||||
netty-server:
|
||||
max-inbound-message-size: 1000MB
|
||||
raft:
|
||||
disruptorBufferSize: 1024
|
||||
address: 127.0.0.1:8510
|
||||
max-log-file-size: 600000000000
|
||||
snapshotInterval: 1800
|
||||
server:
|
||||
port: 8520
|
||||
|
||||
app:
|
||||
data-path: ./storage
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: store-node-grpc-server
|
||||
profiles:
|
||||
active: default
|
||||
include: pd
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
level:
|
||||
root: info
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
pdserver:
|
||||
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
grpc:
|
||||
host: 127.0.0.1
|
||||
port: 8501
|
||||
netty-server:
|
||||
max-inbound-message-size: 1000MB
|
||||
raft:
|
||||
disruptorBufferSize: 1024
|
||||
address: 127.0.0.1:8511
|
||||
max-log-file-size: 600000000000
|
||||
snapshotInterval: 1800
|
||||
server:
|
||||
port: 8521
|
||||
|
||||
app:
|
||||
data-path: ./storage
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: store-node-grpc-server
|
||||
profiles:
|
||||
active: default
|
||||
include: pd
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
level:
|
||||
root: info
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
pdserver:
|
||||
address: 127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
prometheus:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: "*"
|
||||
|
||||
grpc:
|
||||
host: 127.0.0.1
|
||||
port: 8502
|
||||
netty-server:
|
||||
max-inbound-message-size: 1000MB
|
||||
raft:
|
||||
disruptorBufferSize: 1024
|
||||
address: 127.0.0.1:8512
|
||||
max-log-file-size: 600000000000
|
||||
snapshotInterval: 1800
|
||||
server:
|
||||
port: 8522
|
||||
|
||||
app:
|
||||
data-path: ./storage
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: store-node-grpc-server
|
||||
profiles:
|
||||
active: default
|
||||
include: pd
|
||||
|
||||
logging:
|
||||
config: 'file:./conf/log4j2.xml'
|
||||
level:
|
||||
root: info
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||
|
||||
# cache config
|
||||
vertex.cache_type=l2
|
||||
edge.cache_type=l2
|
||||
|
||||
store=hugegraph
|
||||
backend=hstore
|
||||
serializer=binary
|
||||
|
||||
# pd config
|
||||
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
# task config
|
||||
task.scheduler_type=local
|
||||
task.schedule_period=10
|
||||
task.retry=0
|
||||
task.wait_timeout=10
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8181
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||
host: 127.0.0.1
|
||||
port: 8181
|
||||
|
||||
# timeout in ms of gremlin query
|
||||
evaluationTimeout: 30000
|
||||
|
||||
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||
# don't set graph at here, this happens after support for dynamically adding graph
|
||||
graphs: {
|
||||
}
|
||||
scriptEngines: {
|
||||
gremlin-groovy: {
|
||||
staticImports: [
|
||||
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||
],
|
||||
plugins: {
|
||||
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||
classImports: [
|
||||
java.lang.Math,
|
||||
org.apache.hugegraph.backend.id.IdGenerator,
|
||||
org.apache.hugegraph.type.define.Directions,
|
||||
org.apache.hugegraph.type.define.NodeRole,
|
||||
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||
org.apache.hugegraph.util.DateUtil,
|
||||
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||
org.apache.hugegraph.traversal.optimize.Text,
|
||||
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate
|
||||
],
|
||||
methodImports: [
|
||||
java.lang.Math#*,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||
]
|
||||
},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||
files: [scripts/empty-sample.groovy]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serializers:
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
metrics: {
|
||||
consoleReporter: {enabled: false, interval: 180000},
|
||||
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||
jmxReporter: {enabled: false},
|
||||
slf4jReporter: {enabled: false, interval: 180000},
|
||||
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||
graphiteReporter: {enabled: false, interval: 180000}
|
||||
}
|
||||
maxInitialLineLength: 4096
|
||||
maxHeaderSize: 8192
|
||||
maxChunkSize: 8192
|
||||
maxContentLength: 65536
|
||||
maxAccumulationBufferComponents: 1024
|
||||
resultIterationBatchSize: 64
|
||||
writeBufferLowWaterMark: 32768
|
||||
writeBufferHighWaterMark: 65536
|
||||
ssl: {
|
||||
enabled: false
|
||||
}
|
||||
|
|
@ -1,5 +1,20 @@
|
|||
<?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>
|
||||
|
|
@ -15,14 +30,14 @@
|
|||
|
||||
<!-- 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">
|
||||
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" />
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||
<DefaultRolloverStrategy max="5">
|
||||
|
|
@ -30,8 +45,8 @@
|
|||
<IfFileName glob="*/*.log"/>
|
||||
<!-- Limit log amount & size -->
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="2GB" />
|
||||
<IfAccumulatedFileCount exceeds="100" />
|
||||
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||
<IfAccumulatedFileCount exceeds="100"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
|
|
@ -39,15 +54,15 @@
|
|||
|
||||
<!-- 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">
|
||||
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" />
|
||||
<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">
|
||||
|
|
@ -55,8 +70,32 @@
|
|||
<IfFileName glob="*/*.gz"/>
|
||||
<IfLastModified age="60d"/>
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="5GB" />
|
||||
<IfAccumulatedFileCount exceeds="500" />
|
||||
<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>
|
||||
|
|
@ -89,17 +128,17 @@
|
|||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<!-- Use mixed async way to output logs -->
|
||||
<AsyncLogger name="com.baidu.hugegraph" level="INFO" additivity="false">
|
||||
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="com.baidu.hugegraph.auth" level="INFO" additivity="false">
|
||||
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="com.baidu.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.tikv.common.operation.KVErrorHandler" level="ERROR" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="slowQueryLog"/>
|
||||
</AsyncLogger>
|
||||
</loggers>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8181
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||
ioRegistries: [
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8181
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
# bind url
|
||||
restserver.url=http://127.0.0.1:8081
|
||||
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||
gremlinserver.url=http://127.0.0.1:8181
|
||||
|
||||
graphs=./conf/graphs
|
||||
|
||||
# configuration of arthas
|
||||
arthas.telnet_port=8562
|
||||
arthas.http_port=8561
|
||||
arthas.ip=127.0.0.1
|
||||
arthas.disabled_commands=jad
|
||||
|
||||
# authentication configs
|
||||
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||
#auth.authenticator=
|
||||
|
||||
# rpc server configs for multi graph-servers or raft-servers
|
||||
rpc.server_host=127.0.0.1
|
||||
rpc.server_port=8091
|
||||
|
||||
# lightweight load balancing (beta)
|
||||
server.id=server-1
|
||||
server.role=master
|
||||
|
||||
# slow query log
|
||||
log.slow_query_threshold=1000
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||
|
||||
# cache config
|
||||
vertex.cache_type=l2
|
||||
edge.cache_type=l2
|
||||
|
||||
store=hugegraph
|
||||
backend=hstore
|
||||
serializer=binary
|
||||
|
||||
# pd config
|
||||
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
# task config
|
||||
task.scheduler_type=local
|
||||
task.schedule_period=10
|
||||
task.retry=0
|
||||
task.wait_timeout=10
|
||||
|
|
@ -0,0 +1,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: 8182
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||
host: 127.0.0.1
|
||||
port: 8182
|
||||
|
||||
# timeout in ms of gremlin query
|
||||
evaluationTimeout: 30000
|
||||
|
||||
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||
# don't set graph at here, this happens after support for dynamically adding graph
|
||||
graphs: {
|
||||
}
|
||||
scriptEngines: {
|
||||
gremlin-groovy: {
|
||||
staticImports: [
|
||||
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||
],
|
||||
plugins: {
|
||||
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||
classImports: [
|
||||
java.lang.Math,
|
||||
org.apache.hugegraph.backend.id.IdGenerator,
|
||||
org.apache.hugegraph.type.define.Directions,
|
||||
org.apache.hugegraph.type.define.NodeRole,
|
||||
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||
org.apache.hugegraph.util.DateUtil,
|
||||
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||
org.apache.hugegraph.traversal.optimize.Text,
|
||||
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate
|
||||
],
|
||||
methodImports: [
|
||||
java.lang.Math#*,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||
]
|
||||
},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||
files: [scripts/empty-sample.groovy]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serializers:
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
metrics: {
|
||||
consoleReporter: {enabled: false, interval: 180000},
|
||||
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||
jmxReporter: {enabled: false},
|
||||
slf4jReporter: {enabled: false, interval: 180000},
|
||||
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||
graphiteReporter: {enabled: false, interval: 180000}
|
||||
}
|
||||
maxInitialLineLength: 4096
|
||||
maxHeaderSize: 8192
|
||||
maxChunkSize: 8192
|
||||
maxContentLength: 65536
|
||||
maxAccumulationBufferComponents: 1024
|
||||
resultIterationBatchSize: 64
|
||||
writeBufferLowWaterMark: 32768
|
||||
writeBufferHighWaterMark: 65536
|
||||
ssl: {
|
||||
enabled: false
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- Config will be auto loaded every 60s -->
|
||||
<configuration status="error" monitorInterval="60">
|
||||
<properties>
|
||||
<property name="LOG_PATH">logs</property>
|
||||
<property name="FILE_NAME">hugegraph-server</property>
|
||||
</properties>
|
||||
|
||||
<appenders>
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
</Console>
|
||||
|
||||
<!-- Normal server log config -->
|
||||
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
||||
immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1day or 50MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||
<DefaultRolloverStrategy max="5">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.log"/>
|
||||
<!-- Limit log amount & size -->
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||
<IfAccumulatedFileCount exceeds="100"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
|
||||
<!-- Separate & compress audit log, buffer size is 512KB -->
|
||||
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
||||
bufferSize="524288" immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<!-- Use simple format for audit log to speed up -->
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1hour or 500MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
||||
<DefaultRolloverStrategy max="2">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.gz"/>
|
||||
<IfLastModified age="60d"/>
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="5GB"/>
|
||||
<IfAccumulatedFileCount exceeds="500"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
|
||||
<!-- Slow query log config -->
|
||||
<RollingRandomAccessFile name="slowQueryLog" fileName="${LOG_PATH}/slow_query.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/slow_query_log-%d{yyyy-MM-dd}-%i.log"
|
||||
immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1day or 50MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||
<DefaultRolloverStrategy max="5">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.log"/>
|
||||
<!-- Limit log amount & size -->
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||
<IfAccumulatedFileCount exceeds="100"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
<logger name="org.apache.cassandra" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.hadoop" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.zookeeper" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="com.datastax.driver" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="com.alipay.sofa" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="io.netty" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.commons" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<!-- Use mixed async way to output logs -->
|
||||
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="slowQueryLog"/>
|
||||
</AsyncLogger>
|
||||
</loggers>
|
||||
</configuration>
|
||||
|
|
@ -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: 8182
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||
ioRegistries: [
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8182
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# bind url
|
||||
restserver.url=http://127.0.0.1:8082
|
||||
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||
gremlinserver.url=http://127.0.0.1:8182
|
||||
|
||||
graphs=./conf/graphs
|
||||
|
||||
# configuration of arthas
|
||||
arthas.telnet_port=8572
|
||||
arthas.http_port=8571
|
||||
arthas.ip=127.0.0.1
|
||||
arthas.disabled_commands=jad
|
||||
|
||||
# authentication configs
|
||||
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||
#auth.authenticator=
|
||||
|
||||
# rpc server configs for multi graph-servers or raft-servers
|
||||
rpc.server_host=127.0.0.1
|
||||
rpc.server_port=8092
|
||||
#rpc.server_timeout=30
|
||||
|
||||
# lightweight load balancing (beta)
|
||||
server.id=server-2
|
||||
server.role=worker
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# auth config: org.apache.hugegraph.auth.HugeFactoryAuthProxy
|
||||
gremlin.graph=org.apache.hugegraph.HugeFactory
|
||||
|
||||
# cache config
|
||||
vertex.cache_type=l2
|
||||
edge.cache_type=l2
|
||||
|
||||
store=hugegraph
|
||||
backend=hstore
|
||||
serializer=binary
|
||||
|
||||
# pd config
|
||||
pd.peers=127.0.0.1:8686,127.0.0.1:8687,127.0.0.1:8688
|
||||
|
||||
# task config
|
||||
task.scheduler_type=local
|
||||
task.schedule_period=10
|
||||
task.retry=0
|
||||
task.wait_timeout=10
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8183
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# host and port of gremlin server, need to be consistent with host and port in rest-server.properties
|
||||
host: 127.0.0.1
|
||||
port: 8183
|
||||
|
||||
# timeout in ms of gremlin query
|
||||
evaluationTimeout: 30000
|
||||
|
||||
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
|
||||
# don't set graph at here, this happens after support for dynamically adding graph
|
||||
graphs: {
|
||||
}
|
||||
scriptEngines: {
|
||||
gremlin-groovy: {
|
||||
staticImports: [
|
||||
org.opencypher.gremlin.process.traversal.CustomPredicates.*',
|
||||
org.opencypher.gremlin.traversal.CustomFunctions.*
|
||||
],
|
||||
plugins: {
|
||||
org.apache.hugegraph.plugin.HugeGraphGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
|
||||
classImports: [
|
||||
java.lang.Math,
|
||||
org.apache.hugegraph.backend.id.IdGenerator,
|
||||
org.apache.hugegraph.type.define.Directions,
|
||||
org.apache.hugegraph.type.define.NodeRole,
|
||||
org.apache.hugegraph.masterelection.GlobalMasterInfo,
|
||||
org.apache.hugegraph.util.DateUtil,
|
||||
org.apache.hugegraph.traversal.algorithm.CollectionPathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CountTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.CustomizePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.HugeTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KneighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.KoutTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.NeighborRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.PersonalRankTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SameNeighborTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.ShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.SubGraphTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.TemplatePathsTraverser,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.EdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
|
||||
org.apache.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
|
||||
org.apache.hugegraph.traversal.optimize.ConditionP,
|
||||
org.apache.hugegraph.traversal.optimize.Text,
|
||||
org.apache.hugegraph.traversal.optimize.TraversalUtil,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate
|
||||
],
|
||||
methodImports: [
|
||||
java.lang.Math#*,
|
||||
org.opencypher.gremlin.traversal.CustomPredicate#*,
|
||||
org.opencypher.gremlin.traversal.CustomFunctions#*
|
||||
]
|
||||
},
|
||||
org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {
|
||||
files: [scripts/empty-sample.groovy]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
serializers:
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV2d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
- {className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
metrics: {
|
||||
consoleReporter: {enabled: false, interval: 180000},
|
||||
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
|
||||
jmxReporter: {enabled: false},
|
||||
slf4jReporter: {enabled: false, interval: 180000},
|
||||
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
|
||||
graphiteReporter: {enabled: false, interval: 180000}
|
||||
}
|
||||
maxInitialLineLength: 4096
|
||||
maxHeaderSize: 8192
|
||||
maxChunkSize: 8192
|
||||
maxContentLength: 65536
|
||||
maxAccumulationBufferComponents: 1024
|
||||
resultIterationBatchSize: 64
|
||||
writeBufferLowWaterMark: 32768
|
||||
writeBufferHighWaterMark: 65536
|
||||
ssl: {
|
||||
enabled: false
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
contributor license agreements. See the NOTICE file distributed with
|
||||
this work for additional information regarding copyright ownership.
|
||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!-- Config will be auto loaded every 60s -->
|
||||
<configuration status="error" monitorInterval="60">
|
||||
<properties>
|
||||
<property name="LOG_PATH">logs</property>
|
||||
<property name="FILE_NAME">hugegraph-server</property>
|
||||
</properties>
|
||||
|
||||
<appenders>
|
||||
<Console name="console" target="SYSTEM_OUT">
|
||||
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
</Console>
|
||||
|
||||
<!-- Normal server log config -->
|
||||
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
|
||||
immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1day or 50MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||
<DefaultRolloverStrategy max="5">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.log"/>
|
||||
<!-- Limit log amount & size -->
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||
<IfAccumulatedFileCount exceeds="100"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
|
||||
<!-- Separate & compress audit log, buffer size is 512KB -->
|
||||
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
|
||||
bufferSize="524288" immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<!-- Use simple format for audit log to speed up -->
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1hour or 500MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="500MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 2 files per hour & auto delete [after 60 days] or [over 5GB or 500 files] -->
|
||||
<DefaultRolloverStrategy max="2">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.gz"/>
|
||||
<IfLastModified age="60d"/>
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="5GB"/>
|
||||
<IfAccumulatedFileCount exceeds="500"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
|
||||
<!-- Slow query log config -->
|
||||
<RollingRandomAccessFile name="slowQueryLog" fileName="${LOG_PATH}/slow_query.log"
|
||||
filePattern="${LOG_PATH}/$${date:yyyy-MM}/slow_query_log-%d{yyyy-MM-dd}-%i.log"
|
||||
immediateFlush="false">
|
||||
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
|
||||
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
|
||||
<!-- Trigger after exceeding 1day or 50MB -->
|
||||
<Policies>
|
||||
<SizeBasedTriggeringPolicy size="50MB"/>
|
||||
<TimeBasedTriggeringPolicy interval="1" modulate="true"/>
|
||||
</Policies>
|
||||
<!-- Keep 5 files per day & auto delete after over 2GB or 100 files -->
|
||||
<DefaultRolloverStrategy max="5">
|
||||
<Delete basePath="${LOG_PATH}" maxDepth="2">
|
||||
<IfFileName glob="*/*.log"/>
|
||||
<!-- Limit log amount & size -->
|
||||
<IfAny>
|
||||
<IfAccumulatedFileSize exceeds="2GB"/>
|
||||
<IfAccumulatedFileCount exceeds="100"/>
|
||||
</IfAny>
|
||||
</Delete>
|
||||
</DefaultRolloverStrategy>
|
||||
</RollingRandomAccessFile>
|
||||
</appenders>
|
||||
|
||||
<loggers>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
<logger name="org.apache.cassandra" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.hadoop" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.zookeeper" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="com.datastax.driver" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="com.alipay.sofa" level="WARN" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="io.netty" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<logger name="org.apache.commons" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</logger>
|
||||
<!-- Use mixed async way to output logs -->
|
||||
<AsyncLogger name="org.apache.hugegraph" level="INFO" additivity="false">
|
||||
<appender-ref ref="file"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.auth" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AuthenticationFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="audit"/>
|
||||
</AsyncLogger>
|
||||
<AsyncLogger name="org.apache.hugegraph.api.filter.AccessLogFilter" level="INFO" additivity="false">
|
||||
<appender-ref ref="slowQueryLog"/>
|
||||
</AsyncLogger>
|
||||
</loggers>
|
||||
</configuration>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8183
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
# The duplication of HugeGraphIoRegistry is meant to fix a bug in the
|
||||
# 'org.apache.tinkerpop.gremlin.driver.Settings:from(Configuration)' method.
|
||||
ioRegistries: [
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry,
|
||||
org.apache.hugegraph.io.HugeGraphIoRegistry
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
hosts: [localhost]
|
||||
port: 8183
|
||||
serializer: {
|
||||
className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0,
|
||||
config: {
|
||||
serializeResultToString: false,
|
||||
ioRegistries: [org.apache.hugegraph.io.HugeGraphIoRegistry]
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# bind url
|
||||
restserver.url=http://127.0.0.1:8083
|
||||
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
|
||||
gremlinserver.url=http://127.0.0.1:8183
|
||||
|
||||
graphs=./conf/graphs
|
||||
|
||||
# configuration of arthas
|
||||
arthas.telnet_port=8582
|
||||
arthas.http_port=8581
|
||||
arthas.ip=127.0.0.1
|
||||
arthas.disabled_commands=jad
|
||||
|
||||
# authentication configs
|
||||
# choose 'org.apache.hugegraph.auth.StandardAuthenticator' or
|
||||
# 'org.apache.hugegraph.auth.ConfigAuthenticator'
|
||||
#auth.authenticator=
|
||||
|
||||
# rpc server configs for multi graph-servers or raft-servers
|
||||
rpc.server_host=127.0.0.1
|
||||
rpc.server_port=8093
|
||||
|
||||
# lightweight load balancing (beta)
|
||||
server.id=server-3
|
||||
server.role=worker
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# TODO: reuse the configs for same type containers
|
||||
# User could modify the node nums and the port by themselves
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
pd0:
|
||||
image: hugegraph/pd
|
||||
container_name: pd0
|
||||
hostname: pd0
|
||||
network_mode: host
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8620"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-pd0.yml:/hugegraph-pd/conf/application.yml
|
||||
|
||||
pd1:
|
||||
image: hugegraph/pd
|
||||
container_name: pd1
|
||||
hostname: pd1
|
||||
network_mode: host
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8621"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-pd1.yml:/hugegraph-pd/conf/application.yml
|
||||
|
||||
pd2:
|
||||
image: hugegraph/pd
|
||||
container_name: pd2
|
||||
hostname: pd2
|
||||
network_mode: host
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8622"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-pd2.yml:/hugegraph-pd/conf/application.yml
|
||||
|
||||
store0:
|
||||
image: hugegraph/store
|
||||
container_name: store0
|
||||
hostname: store0
|
||||
network_mode: host
|
||||
depends_on:
|
||||
pd0:
|
||||
condition: service_healthy
|
||||
pd1:
|
||||
condition: service_healthy
|
||||
pd2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8520"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-store0.yml:/hugegraph-store/conf/application.yml
|
||||
|
||||
store1:
|
||||
image: hugegraph/store
|
||||
container_name: store1
|
||||
hostname: store1
|
||||
network_mode: host
|
||||
depends_on:
|
||||
pd0:
|
||||
condition: service_healthy
|
||||
pd1:
|
||||
condition: service_healthy
|
||||
pd2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8521"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-store1.yml:/hugegraph-store/conf/application.yml
|
||||
|
||||
store2:
|
||||
image: hugegraph/store
|
||||
container_name: store2
|
||||
hostname: store2
|
||||
network_mode: host
|
||||
depends_on:
|
||||
pd0:
|
||||
condition: service_healthy
|
||||
pd1:
|
||||
condition: service_healthy
|
||||
pd2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8522"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/application-store2.yml:/hugegraph-store/conf/application.yml
|
||||
|
||||
server1:
|
||||
image: hugegraph/server
|
||||
container_name: server1
|
||||
hostname: server1
|
||||
network_mode: host
|
||||
depends_on:
|
||||
store0:
|
||||
condition: service_healthy
|
||||
store1:
|
||||
condition: service_healthy
|
||||
store2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8081"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/server1-conf:/hugegraph-server/conf
|
||||
|
||||
server2:
|
||||
image: hugegraph/server
|
||||
container_name: server2
|
||||
hostname: server2
|
||||
network_mode: host
|
||||
depends_on:
|
||||
store0:
|
||||
condition: service_healthy
|
||||
store1:
|
||||
condition: service_healthy
|
||||
store2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8082"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/server2-conf:/hugegraph-server/conf
|
||||
|
||||
server3:
|
||||
image: hugegraph/server
|
||||
container_name: server3
|
||||
hostname: server3
|
||||
network_mode: host
|
||||
depends_on:
|
||||
store0:
|
||||
condition: service_healthy
|
||||
store1:
|
||||
condition: service_healthy
|
||||
store2:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8083"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
volumes:
|
||||
- ./configs/server3-conf:/hugegraph-server/conf
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
pd:
|
||||
image: hugegraph/pd
|
||||
container_name: pd
|
||||
hostname: pd
|
||||
network_mode: host
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8620"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
|
||||
store:
|
||||
image: hugegraph/store
|
||||
container_name: store
|
||||
hostname: store
|
||||
network_mode: host
|
||||
depends_on:
|
||||
pd:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8520"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
|
||||
server:
|
||||
image: hugegraph/server
|
||||
container_name: server
|
||||
hostname: server
|
||||
network_mode: host
|
||||
depends_on:
|
||||
store:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.NotSupportedException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.define.Checkable;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
public static final String CHARSET = "UTF-8";
|
||||
|
||||
public static final String APPLICATION_JSON = MediaType.APPLICATION_JSON;
|
||||
public static final String APPLICATION_JSON_WITH_CHARSET =
|
||||
APPLICATION_JSON + ";charset=" + CHARSET;
|
||||
public static final String JSON = MediaType.APPLICATION_JSON_TYPE
|
||||
.getSubtype();
|
||||
|
||||
public static final String ACTION_APPEND = "append";
|
||||
public static final String ACTION_ELIMINATE = "eliminate";
|
||||
public static final String ACTION_CLEAR = "clear";
|
||||
|
||||
private static final Meter succeedMeter =
|
||||
MetricsUtil.registerMeter(API.class, "commit-succeed");
|
||||
private static final Meter illegalArgErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "illegal-arg");
|
||||
private static final Meter expectedErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "expected-error");
|
||||
private static final Meter unknownErrorMeter =
|
||||
MetricsUtil.registerMeter(API.class, "unknown-error");
|
||||
|
||||
public static HugeGraph graph(GraphManager manager, String graph) {
|
||||
HugeGraph g = manager.graph(graph);
|
||||
if (g == null) {
|
||||
throw new NotFoundException(String.format(
|
||||
"Graph '%s' does not exist", graph));
|
||||
}
|
||||
return g;
|
||||
}
|
||||
|
||||
public static HugeGraph graph4admin(GraphManager manager, String graph) {
|
||||
return graph(manager, graph).hugegraph();
|
||||
}
|
||||
|
||||
public static <R> R commit(HugeGraph g, Callable<R> callable) {
|
||||
Consumer<Throwable> rollback = (error) -> {
|
||||
if (error != null) {
|
||||
LOG.error("Failed to commit", error);
|
||||
}
|
||||
try {
|
||||
g.tx().rollback();
|
||||
} catch (Throwable e) {
|
||||
LOG.error("Failed to rollback", e);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
R result = callable.call();
|
||||
g.tx().commit();
|
||||
succeedMeter.mark();
|
||||
return result;
|
||||
} catch (IllegalArgumentException | NotFoundException |
|
||||
ForbiddenException e) {
|
||||
illegalArgErrorMeter.mark();
|
||||
rollback.accept(null);
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
expectedErrorMeter.mark();
|
||||
rollback.accept(e);
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
unknownErrorMeter.mark();
|
||||
rollback.accept(e);
|
||||
// TODO: throw the origin exception 'e'
|
||||
throw new HugeException("Failed to commit", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void commit(HugeGraph g, Runnable runnable) {
|
||||
commit(g, () -> {
|
||||
runnable.run();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public static Object[] properties(Map<String, Object> properties) {
|
||||
Object[] list = new Object[properties.size() * 2];
|
||||
int i = 0;
|
||||
for (Map.Entry<String, Object> prop : properties.entrySet()) {
|
||||
list[i++] = prop.getKey();
|
||||
list[i++] = prop.getValue();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
protected static void checkCreatingBody(Checkable body) {
|
||||
E.checkArgumentNotNull(body, "The request body can't be empty");
|
||||
body.checkCreate(false);
|
||||
}
|
||||
|
||||
protected static void checkUpdatingBody(Checkable body) {
|
||||
E.checkArgumentNotNull(body, "The request body can't be empty");
|
||||
body.checkUpdate();
|
||||
}
|
||||
|
||||
protected static void checkCreatingBody(
|
||||
Collection<? extends Checkable> bodys) {
|
||||
E.checkArgumentNotNull(bodys, "The request body can't be empty");
|
||||
for (Checkable body : bodys) {
|
||||
E.checkArgument(body != null,
|
||||
"The batch body can't contain null record");
|
||||
body.checkCreate(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void checkUpdatingBody(
|
||||
Collection<? extends Checkable> bodys) {
|
||||
E.checkArgumentNotNull(bodys, "The request body can't be empty");
|
||||
for (Checkable body : bodys) {
|
||||
E.checkArgumentNotNull(body,
|
||||
"The batch body can't contain null record");
|
||||
body.checkUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected static Map<String, Object> parseProperties(String properties) {
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
Map<String, Object> props = null;
|
||||
try {
|
||||
props = JsonUtil.fromJson(properties, Map.class);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
// If properties is the string "null", props will be null
|
||||
E.checkArgument(props != null,
|
||||
"Invalid request with properties: %s", properties);
|
||||
return props;
|
||||
}
|
||||
|
||||
public static boolean checkAndParseAction(String action) {
|
||||
E.checkArgumentNotNull(action, "The action param can't be empty");
|
||||
if (action.equals(ACTION_APPEND)) {
|
||||
return true;
|
||||
} else if (action.equals(ACTION_ELIMINATE)) {
|
||||
return false;
|
||||
} else {
|
||||
throw new NotSupportedException(
|
||||
String.format("Not support action '%s'", action));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.filter;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerResponseContext;
|
||||
import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import com.baidu.hugegraph.define.WorkLoad;
|
||||
|
||||
@Provider
|
||||
@Singleton
|
||||
public class LoadReleaseFilter implements ContainerResponseFilter {
|
||||
|
||||
@Context
|
||||
private javax.inject.Provider<WorkLoad> loadProvider;
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext,
|
||||
ContainerResponseContext responseContext) {
|
||||
if (LoadDetectFilter.isWhiteAPI(requestContext)) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorkLoad load = this.loadProvider.get();
|
||||
load.decrementAndGet();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.gremlin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.exception.HugeGremlinException;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.codahale.metrics.Histogram;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@Path("gremlin")
|
||||
@Singleton
|
||||
public class GremlinAPI extends API {
|
||||
|
||||
private static final Histogram gremlinInputHistogram =
|
||||
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-input");
|
||||
private static final Histogram gremlinOutputHistogram =
|
||||
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-output");
|
||||
|
||||
private static final Set<String> FORBIDDEN_REQUEST_EXCEPTIONS =
|
||||
ImmutableSet.of("java.lang.SecurityException",
|
||||
"javax.ws.rs.ForbiddenException");
|
||||
private static final Set<String> BAD_REQUEST_EXCEPTIONS = ImmutableSet.of(
|
||||
"java.lang.IllegalArgumentException",
|
||||
"java.util.concurrent.TimeoutException",
|
||||
"groovy.lang.",
|
||||
"org.codehaus.",
|
||||
"com.baidu.hugegraph."
|
||||
);
|
||||
|
||||
@Context
|
||||
private javax.inject.Provider<HugeConfig> configProvider;
|
||||
|
||||
private GremlinClient client;
|
||||
|
||||
public GremlinClient client() {
|
||||
if (this.client != null) {
|
||||
return this.client;
|
||||
}
|
||||
HugeConfig config = this.configProvider.get();
|
||||
String url = config.get(ServerOptions.GREMLIN_SERVER_URL);
|
||||
int timeout = config.get(ServerOptions.GREMLIN_SERVER_TIMEOUT) * 1000;
|
||||
int maxRoutes = config.get(ServerOptions.GREMLIN_SERVER_MAX_ROUTE);
|
||||
this.client = new GremlinClient(url, timeout, maxRoutes, maxRoutes);
|
||||
return this.client;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Compress
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public Response post(@Context HugeConfig conf,
|
||||
@Context HttpHeaders headers,
|
||||
String request) {
|
||||
/* The following code is reserved for forwarding request */
|
||||
// context.getRequestDispatcher(location).forward(request, response);
|
||||
// return Response.seeOther(UriBuilder.fromUri(location).build())
|
||||
// .build();
|
||||
// Response.temporaryRedirect(UriBuilder.fromUri(location).build())
|
||||
// .build();
|
||||
String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION);
|
||||
Response response = this.client().doPostRequest(auth, request);
|
||||
gremlinInputHistogram.update(request.length());
|
||||
gremlinOutputHistogram.update(response.getLength());
|
||||
return transformResponseIfNeeded(response);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Compress(buffer=(1024 * 40))
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public Response get(@Context HugeConfig conf,
|
||||
@Context HttpHeaders headers,
|
||||
@Context UriInfo uriInfo) {
|
||||
String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION);
|
||||
String query = uriInfo.getRequestUri().getRawQuery();
|
||||
MultivaluedMap<String, String> params = uriInfo.getQueryParameters();
|
||||
Response response = this.client().doGetRequest(auth, params);
|
||||
gremlinInputHistogram.update(query.length());
|
||||
gremlinOutputHistogram.update(response.getLength());
|
||||
return transformResponseIfNeeded(response);
|
||||
}
|
||||
|
||||
private static Response transformResponseIfNeeded(Response response) {
|
||||
MediaType mediaType = response.getMediaType();
|
||||
if (mediaType != null) {
|
||||
// Append charset
|
||||
assert MediaType.APPLICATION_JSON_TYPE.equals(mediaType);
|
||||
response.getHeaders().putSingle(HttpHeaders.CONTENT_TYPE,
|
||||
mediaType.withCharset(CHARSET));
|
||||
}
|
||||
|
||||
Response.StatusType status = response.getStatusInfo();
|
||||
if (status.getStatusCode() < 400) {
|
||||
// No need to transform if normal response without error
|
||||
return response;
|
||||
}
|
||||
|
||||
if (mediaType == null || !JSON.equals(mediaType.getSubtype())) {
|
||||
String message = response.readEntity(String.class);
|
||||
throw new HugeGremlinException(status.getStatusCode(),
|
||||
ImmutableMap.of("message", message));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> map = response.readEntity(Map.class);
|
||||
String exClassName = (String) map.get("Exception-Class");
|
||||
if (FORBIDDEN_REQUEST_EXCEPTIONS.contains(exClassName)) {
|
||||
status = Response.Status.FORBIDDEN;
|
||||
} else if (matchBadRequestException(exClassName)) {
|
||||
status = Response.Status.BAD_REQUEST;
|
||||
}
|
||||
throw new HugeGremlinException(status.getStatusCode(), map);
|
||||
}
|
||||
|
||||
private static boolean matchBadRequestException(String exClass) {
|
||||
if (exClass == null) {
|
||||
return false;
|
||||
}
|
||||
if (BAD_REQUEST_EXCEPTIONS.contains(exClass)) {
|
||||
return true;
|
||||
}
|
||||
return BAD_REQUEST_EXCEPTIONS.stream().anyMatch(exClass::startsWith);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.gremlin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.client.Entity;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.HttpHeaders;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.baidu.hugegraph.api.filter.CompressInterceptor;
|
||||
import com.baidu.hugegraph.rest.AbstractRestClient;
|
||||
import com.baidu.hugegraph.testutil.Whitebox;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
|
||||
public class GremlinClient extends AbstractRestClient {
|
||||
|
||||
private final WebTarget webTarget;
|
||||
|
||||
public GremlinClient(String url, int timeout,
|
||||
int maxTotal, int maxPerRoute) {
|
||||
super(url, timeout, maxTotal, maxPerRoute);
|
||||
this.webTarget = Whitebox.getInternalState(this, "target");
|
||||
E.checkNotNull(this.webTarget, "target");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkStatus(Response response, Response.Status... statuses) {
|
||||
// pass
|
||||
}
|
||||
|
||||
public Response doPostRequest(String auth, String req) {
|
||||
Entity<?> body = Entity.entity(req, MediaType.APPLICATION_JSON);
|
||||
return this.webTarget.request()
|
||||
.header(HttpHeaders.AUTHORIZATION, auth)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.acceptEncoding(CompressInterceptor.GZIP)
|
||||
.post(body);
|
||||
}
|
||||
|
||||
public Response doGetRequest(String auth,
|
||||
MultivaluedMap<String, String> params) {
|
||||
WebTarget target = this.webTarget;
|
||||
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
|
||||
E.checkArgument(entry.getValue().size() == 1,
|
||||
"Invalid query param '%s', can only accept " +
|
||||
"one value, but got %s",
|
||||
entry.getKey(), entry.getValue());
|
||||
target = target.queryParam(entry.getKey(), entry.getValue().get(0));
|
||||
}
|
||||
return target.request()
|
||||
.header(HttpHeaders.AUTHORIZATION, auth)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.acceptEncoding(CompressInterceptor.GZIP)
|
||||
.get();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,161 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.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 javax.annotation.security.RolesAllowed;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.backend.store.BackendMetrics;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.metrics.MetricsModule;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.metrics.SystemMetrics;
|
||||
import com.baidu.hugegraph.util.InsertionOrderUtil;
|
||||
import com.baidu.hugegraph.util.JsonUtil;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.Metric;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Singleton
|
||||
@Path("metrics")
|
||||
public class MetricsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(MetricsAPI.class);
|
||||
|
||||
private SystemMetrics systemMetrics;
|
||||
|
||||
static {
|
||||
JsonUtil.registerModule(new MetricsModule(SECONDS, MILLISECONDS, false));
|
||||
}
|
||||
|
||||
public MetricsAPI() {
|
||||
this.systemMetrics = new SystemMetrics();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("system")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String system() {
|
||||
return JsonUtil.toJson(this.systemMetrics.metrics());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("backend")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String backend(@Context GraphManager manager) {
|
||||
Map<String, Map<String, Object>> results = InsertionOrderUtil.newMap();
|
||||
for (String graph : manager.graphs()) {
|
||||
HugeGraph g = manager.graph(graph);
|
||||
Map<String, Object> metrics = InsertionOrderUtil.newMap();
|
||||
metrics.put(BackendMetrics.BACKEND, g.backend());
|
||||
try {
|
||||
metrics.putAll(g.metadata(null, "metrics"));
|
||||
} catch (Throwable e) {
|
||||
metrics.put(BackendMetrics.EXCEPTION, e.toString());
|
||||
LOG.debug("Failed to get backend metrics", e);
|
||||
}
|
||||
results.put(graph, metrics);
|
||||
}
|
||||
return JsonUtil.toJson(results);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String all() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
Map<String, Map<String, ? extends Metric>> result = new LinkedHashMap<>();
|
||||
result.put("gauges", reporter.gauges());
|
||||
result.put("counters", reporter.counters());
|
||||
result.put("histograms", reporter.histograms());
|
||||
result.put("meters", reporter.meters());
|
||||
result.put("timers", reporter.timers());
|
||||
return JsonUtil.toJson(result);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("gauges")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String gauges() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
return JsonUtil.toJson(reporter.gauges());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("counters")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String counters() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
return JsonUtil.toJson(reporter.counters());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("histograms")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String histograms() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
return JsonUtil.toJson(reporter.histograms());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("meters")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String meters() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
return JsonUtil.toJson(reporter.meters());
|
||||
}
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Path("timers")
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@RolesAllowed({"admin", "$owner= $action=metrics_read"})
|
||||
public String timers() {
|
||||
ServerReporter reporter = ServerReporter.instance();
|
||||
return JsonUtil.toJson(reporter.timers());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.profile;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.security.PermitAll;
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.version.ApiVersion;
|
||||
import com.baidu.hugegraph.version.CoreVersion;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
@Path("versions")
|
||||
@Singleton
|
||||
public class VersionAPI extends API {
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
@PermitAll
|
||||
public Object list() {
|
||||
Map<String, String> versions = ImmutableMap.of("version", "v1",
|
||||
"core", CoreVersion.VERSION.toString(),
|
||||
"gremlin", CoreVersion.GREMLIN_VERSION,
|
||||
"api", ApiVersion.VERSION.toString());
|
||||
return ImmutableMap.of("versions", versions);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/allshortestpaths")
|
||||
@Singleton
|
||||
public class AllShortestPathsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("target") String target,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("skip_degree")
|
||||
@DefaultValue("0") long skipDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity) {
|
||||
LOG.debug("Graph [{}] get shortest path from '{}', to '{}' with " +
|
||||
"direction {}, edge label {}, max depth '{}', " +
|
||||
"max degree '{}', skipped degree '{}' and capacity '{}'",
|
||||
graph, source, target, direction, edgeLabel, depth,
|
||||
maxDegree, skipDegree, capacity);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(target);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
ShortestPathTraverser traverser = new ShortestPathTraverser(g);
|
||||
List<String> edgeLabels = edgeLabel == null ? ImmutableList.of() :
|
||||
ImmutableList.of(edgeLabel);
|
||||
HugeTraverser.PathSet paths = traverser.allShortestPaths(
|
||||
sourceId, targetId, dir, edgeLabels,
|
||||
depth, maxDegree, skipDegree, capacity);
|
||||
return manager.serializer(g).writePaths("paths", paths, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/crosspoints")
|
||||
@Singleton
|
||||
public class CrosspointsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("target") String target,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get crosspoints with paths from '{}', to '{}' " +
|
||||
"with direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
graph, source, target, direction, edgeLabel,
|
||||
depth, maxDegree, capacity, limit);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(target);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
PathsTraverser traverser = new PathsTraverser(g);
|
||||
HugeTraverser.PathSet paths = traverser.paths(sourceId, dir, targetId,
|
||||
dir, edgeLabel, depth,
|
||||
maxDegree, capacity, limit);
|
||||
return manager.serializer(g).writePaths("crosspoints", paths, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,190 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.Query;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.KneighborTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.records.KneighborRecords;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/kneighbor")
|
||||
@Singleton
|
||||
public class KneighborAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String sourceV,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get k-neighbor from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}' and limit '{}'",
|
||||
graph, sourceV, direction, edgeLabel, depth,
|
||||
maxDegree, limit);
|
||||
|
||||
Id source = VertexAPI.checkAndParseVertexId(sourceV);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
Set<Id> ids;
|
||||
try (KneighborTraverser traverser = new KneighborTraverser(g)) {
|
||||
ids = traverser.kneighbor(source, dir, edgeLabel,
|
||||
depth, maxDegree, limit);
|
||||
}
|
||||
return manager.serializer(g).writeList("vertices", ids);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
Request request) {
|
||||
E.checkArgumentNotNull(request, "The request body can't be null");
|
||||
E.checkArgumentNotNull(request.source,
|
||||
"The source of request can't be null");
|
||||
E.checkArgument(request.step != null,
|
||||
"The steps of request can't be null");
|
||||
if (request.countOnly) {
|
||||
E.checkArgument(!request.withVertex && !request.withPath,
|
||||
"Can't return vertex or path when count only");
|
||||
}
|
||||
|
||||
LOG.debug("Graph [{}] get customized kneighbor from source vertex " +
|
||||
"'{}', with step '{}', limit '{}', count_only '{}', " +
|
||||
"with_vertex '{}' and with_path '{}'",
|
||||
graph, request.source, request.step, request.limit,
|
||||
request.countOnly, request.withVertex, request.withPath);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
Id sourceId = HugeVertex.getIdValue(request.source);
|
||||
|
||||
EdgeStep step = step(g, request.step);
|
||||
|
||||
KneighborRecords results;
|
||||
try (KneighborTraverser traverser = new KneighborTraverser(g)) {
|
||||
results = traverser.customizedKneighbor(sourceId, step,
|
||||
request.maxDepth,
|
||||
request.limit);
|
||||
}
|
||||
|
||||
long size = results.size();
|
||||
if (request.limit != Query.NO_LIMIT && size > request.limit) {
|
||||
size = request.limit;
|
||||
}
|
||||
List<Id> neighbors = request.countOnly ?
|
||||
ImmutableList.of() : results.ids(request.limit);
|
||||
|
||||
HugeTraverser.PathSet paths = new HugeTraverser.PathSet();
|
||||
if (request.withPath) {
|
||||
paths.addAll(results.paths(request.limit));
|
||||
}
|
||||
Iterator<Vertex> iter = QueryResults.emptyIterator();
|
||||
if (request.withVertex && !request.countOnly) {
|
||||
Set<Id> ids = new HashSet<>(neighbors);
|
||||
if (request.withPath) {
|
||||
for (HugeTraverser.Path p : paths) {
|
||||
ids.addAll(p.vertices());
|
||||
}
|
||||
}
|
||||
if (!ids.isEmpty()) {
|
||||
iter = g.vertices(ids.toArray());
|
||||
}
|
||||
}
|
||||
return manager.serializer(g).writeNodesWithPath("kneighbor", neighbors,
|
||||
size, paths, iter);
|
||||
}
|
||||
|
||||
private static class Request {
|
||||
|
||||
@JsonProperty("source")
|
||||
public Object source;
|
||||
@JsonProperty("step")
|
||||
public TraverserAPI.Step step;
|
||||
@JsonProperty("max_depth")
|
||||
public int maxDepth;
|
||||
@JsonProperty("limit")
|
||||
public long limit = Long.parseLong(DEFAULT_ELEMENTS_LIMIT);
|
||||
@JsonProperty("count_only")
|
||||
public boolean countOnly = false;
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
@JsonProperty("with_path")
|
||||
public boolean withPath = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("PathRequest{source=%s,step=%s,maxDepth=%s" +
|
||||
"limit=%s,countOnly=%s,withVertex=%s," +
|
||||
"withPath=%s}", this.source, this.step,
|
||||
this.maxDepth, this.limit, this.countOnly,
|
||||
this.withVertex, this.withPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.Query;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.KoutTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.records.KoutRecords;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/kout")
|
||||
@Singleton
|
||||
public class KoutAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("nearest")
|
||||
@DefaultValue("true") boolean nearest,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_ELEMENTS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get k-out from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', nearest " +
|
||||
"'{}', max degree '{}', capacity '{}' and limit '{}'",
|
||||
graph, source, direction, edgeLabel, depth, nearest,
|
||||
maxDegree, capacity, limit);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
Set<Id> ids;
|
||||
try (KoutTraverser traverser = new KoutTraverser(g)) {
|
||||
ids = traverser.kout(sourceId, dir, edgeLabel, depth,
|
||||
nearest, maxDegree, capacity, limit);
|
||||
}
|
||||
return manager.serializer(g).writeList("vertices", ids);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
Request request) {
|
||||
E.checkArgumentNotNull(request, "The request body can't be null");
|
||||
E.checkArgumentNotNull(request.source,
|
||||
"The source of request can't be null");
|
||||
E.checkArgument(request.step != null,
|
||||
"The steps of request can't be null");
|
||||
if (request.countOnly) {
|
||||
E.checkArgument(!request.withVertex && !request.withPath,
|
||||
"Can't return vertex or path when count only");
|
||||
}
|
||||
|
||||
LOG.debug("Graph [{}] get customized kout from source vertex '{}', " +
|
||||
"with step '{}', max_depth '{}', nearest '{}', " +
|
||||
"count_only '{}', capacity '{}', limit '{}', " +
|
||||
"with_vertex '{}' and with_path '{}'",
|
||||
graph, request.source, request.step, request.maxDepth,
|
||||
request.nearest, request.countOnly, request.capacity,
|
||||
request.limit, request.withVertex, request.withPath);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
Id sourceId = HugeVertex.getIdValue(request.source);
|
||||
|
||||
EdgeStep step = step(g, request.step);
|
||||
|
||||
KoutRecords results;
|
||||
try (KoutTraverser traverser = new KoutTraverser(g)) {
|
||||
results = traverser.customizedKout(sourceId, step,
|
||||
request.maxDepth,
|
||||
request.nearest,
|
||||
request.capacity,
|
||||
request.limit);
|
||||
}
|
||||
|
||||
long size = results.size();
|
||||
if (request.limit != Query.NO_LIMIT && size > request.limit) {
|
||||
size = request.limit;
|
||||
}
|
||||
List<Id> neighbors = request.countOnly ?
|
||||
ImmutableList.of() : results.ids(request.limit);
|
||||
|
||||
HugeTraverser.PathSet paths = new HugeTraverser.PathSet();
|
||||
if (request.withPath) {
|
||||
paths.addAll(results.paths(request.limit));
|
||||
}
|
||||
Iterator<Vertex> iter = QueryResults.emptyIterator();
|
||||
if (request.withVertex && !request.countOnly) {
|
||||
Set<Id> ids = new HashSet<>(neighbors);
|
||||
if (request.withPath) {
|
||||
for (HugeTraverser.Path p : paths) {
|
||||
ids.addAll(p.vertices());
|
||||
}
|
||||
}
|
||||
if (!ids.isEmpty()) {
|
||||
iter = g.vertices(ids.toArray());
|
||||
}
|
||||
}
|
||||
return manager.serializer(g).writeNodesWithPath("kout", neighbors,
|
||||
size, paths, iter);
|
||||
}
|
||||
|
||||
private static class Request {
|
||||
|
||||
@JsonProperty("source")
|
||||
public Object source;
|
||||
@JsonProperty("step")
|
||||
public TraverserAPI.Step step;
|
||||
@JsonProperty("max_depth")
|
||||
public int maxDepth;
|
||||
@JsonProperty("nearest")
|
||||
public boolean nearest = true;
|
||||
@JsonProperty("count_only")
|
||||
public boolean countOnly = false;
|
||||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public long limit = Long.parseLong(DEFAULT_ELEMENTS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
@JsonProperty("with_path")
|
||||
public boolean withPath = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("KoutRequest{source=%s,step=%s,maxDepth=%s" +
|
||||
"nearest=%s,countOnly=%s,capacity=%s," +
|
||||
"limit=%s,withVertex=%s,withPath=%s}",
|
||||
this.source, this.step, this.maxDepth,
|
||||
this.nearest, this.countOnly, this.capacity,
|
||||
this.limit, this.withVertex, this.withPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/multinodeshortestpath")
|
||||
@Singleton
|
||||
public class MultiNodeShortestPathAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
Request request) {
|
||||
E.checkArgumentNotNull(request, "The request body can't be null");
|
||||
E.checkArgumentNotNull(request.vertices,
|
||||
"The vertices of request can't be null");
|
||||
E.checkArgument(request.step != null,
|
||||
"The steps of request can't be null");
|
||||
|
||||
LOG.debug("Graph [{}] get multiple node shortest path from " +
|
||||
"vertices '{}', with step '{}', max_depth '{}', capacity " +
|
||||
"'{}' and with_vertex '{}'",
|
||||
graph, request.vertices, request.step, request.maxDepth,
|
||||
request.capacity, request.withVertex);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
Iterator<Vertex> vertices = request.vertices.vertices(g);
|
||||
|
||||
EdgeStep step = step(g, request.step);
|
||||
|
||||
List<HugeTraverser.Path> paths;
|
||||
try (MultiNodeShortestPathTraverser traverser =
|
||||
new MultiNodeShortestPathTraverser(g)) {
|
||||
paths = traverser.multiNodeShortestPath(vertices, step,
|
||||
request.maxDepth,
|
||||
request.capacity);
|
||||
}
|
||||
|
||||
if (!request.withVertex) {
|
||||
return manager.serializer(g).writePaths("paths", paths, false);
|
||||
}
|
||||
|
||||
Set<Id> ids = new HashSet<>();
|
||||
for (HugeTraverser.Path p : paths) {
|
||||
ids.addAll(p.vertices());
|
||||
}
|
||||
Iterator<Vertex> iter = QueryResults.emptyIterator();
|
||||
if (!ids.isEmpty()) {
|
||||
iter = g.vertices(ids.toArray());
|
||||
}
|
||||
return manager.serializer(g).writePaths("paths", paths, false, iter);
|
||||
}
|
||||
|
||||
private static class Request {
|
||||
|
||||
@JsonProperty("vertices")
|
||||
public Vertices vertices;
|
||||
@JsonProperty("step")
|
||||
public Step step;
|
||||
@JsonProperty("max_depth")
|
||||
public int maxDepth;
|
||||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Request{vertices=%s,step=%s,maxDepth=%s" +
|
||||
"capacity=%s,withVertex=%s}",
|
||||
this.vertices, this.step, this.maxDepth,
|
||||
this.capacity, this.withVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CollectionPathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.PathsTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@Path("graphs/{graph}/traversers/paths")
|
||||
@Singleton
|
||||
public class PathsAPI extends TraverserAPI {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("target") String target,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get paths from '{}', to '{}' with " +
|
||||
"direction {}, edge label {}, max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
graph, source, target, direction, edgeLabel, depth,
|
||||
maxDegree, capacity, limit);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(target);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
PathsTraverser traverser = new PathsTraverser(g);
|
||||
HugeTraverser.PathSet paths = traverser.paths(sourceId, dir, targetId,
|
||||
dir.opposite(), edgeLabel,
|
||||
depth, maxDegree, capacity,
|
||||
limit);
|
||||
return manager.serializer(g).writePaths("paths", paths, false);
|
||||
}
|
||||
|
||||
@POST
|
||||
@Timed
|
||||
@Consumes(APPLICATION_JSON)
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String post(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
Request request) {
|
||||
E.checkArgumentNotNull(request, "The request body can't be null");
|
||||
E.checkArgumentNotNull(request.sources,
|
||||
"The sources of request can't be null");
|
||||
E.checkArgumentNotNull(request.targets,
|
||||
"The targets of request can't be null");
|
||||
E.checkArgumentNotNull(request.step,
|
||||
"The step of request can't be null");
|
||||
E.checkArgument(request.depth > 0,
|
||||
"The depth of request must be > 0, but got: %s",
|
||||
request.depth);
|
||||
|
||||
LOG.debug("Graph [{}] get paths from source vertices '{}', target " +
|
||||
"vertices '{}', with step '{}', max depth '{}', " +
|
||||
"capacity '{}', limit '{}' and with_vertex '{}'",
|
||||
graph, request.sources, request.targets, request.step,
|
||||
request.depth, request.capacity, request.limit,
|
||||
request.withVertex);
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
Iterator<Vertex> sources = request.sources.vertices(g);
|
||||
Iterator<Vertex> targets = request.targets.vertices(g);
|
||||
EdgeStep step = step(g, request.step);
|
||||
|
||||
CollectionPathsTraverser traverser = new CollectionPathsTraverser(g);
|
||||
Collection<HugeTraverser.Path> paths;
|
||||
paths = traverser.paths(sources, targets, step, request.depth,
|
||||
request.nearest, request.capacity,
|
||||
request.limit);
|
||||
|
||||
if (!request.withVertex) {
|
||||
return manager.serializer(g).writePaths("paths", paths, false);
|
||||
}
|
||||
|
||||
Set<Id> ids = new HashSet<>();
|
||||
for (HugeTraverser.Path p : paths) {
|
||||
ids.addAll(p.vertices());
|
||||
}
|
||||
Iterator<Vertex> iter = QueryResults.emptyIterator();
|
||||
if (!ids.isEmpty()) {
|
||||
iter = g.vertices(ids.toArray());
|
||||
}
|
||||
return manager.serializer(g).writePaths("paths", paths, false, iter);
|
||||
}
|
||||
|
||||
private static class Request {
|
||||
|
||||
@JsonProperty("sources")
|
||||
public Vertices sources;
|
||||
@JsonProperty("targets")
|
||||
public Vertices targets;
|
||||
@JsonProperty("step")
|
||||
public TraverserAPI.Step step;
|
||||
@JsonProperty("max_depth")
|
||||
public int depth;
|
||||
@JsonProperty("nearest")
|
||||
public boolean nearest = false;
|
||||
@JsonProperty("capacity")
|
||||
public long capacity = Long.parseLong(DEFAULT_CAPACITY);
|
||||
@JsonProperty("limit")
|
||||
public long limit = Long.parseLong(DEFAULT_PATHS_LIMIT);
|
||||
@JsonProperty("with_vertex")
|
||||
public boolean withVertex = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("PathRequest{sources=%s,targets=%s,step=%s," +
|
||||
"maxDepth=%s,nearest=%s,capacity=%s," +
|
||||
"limit=%s,withVertex=%s}", this.sources,
|
||||
this.targets, this.step, this.depth,
|
||||
this.nearest, this.capacity,
|
||||
this.limit, this.withVertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/rays")
|
||||
@Singleton
|
||||
public class RaysAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String sourceV,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get rays paths from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"max degree '{}', capacity '{}' and limit '{}'",
|
||||
graph, sourceV, direction, edgeLabel, depth, maxDegree,
|
||||
capacity, limit);
|
||||
|
||||
Id source = VertexAPI.checkAndParseVertexId(sourceV);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
SubGraphTraverser traverser = new SubGraphTraverser(g);
|
||||
HugeTraverser.PathSet paths = traverser.rays(source, dir, edgeLabel,
|
||||
depth, maxDegree,
|
||||
capacity, limit);
|
||||
return manager.serializer(g).writePaths("rays", paths, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/rings")
|
||||
@Singleton
|
||||
public class RingsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String sourceV,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("source_in_ring")
|
||||
@DefaultValue("true") boolean sourceInRing,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit) {
|
||||
LOG.debug("Graph [{}] get rings paths reachable from '{}' with " +
|
||||
"direction '{}', edge label '{}', max depth '{}', " +
|
||||
"source in ring '{}', max degree '{}', capacity '{}' " +
|
||||
"and limit '{}'",
|
||||
graph, sourceV, direction, edgeLabel, depth, sourceInRing,
|
||||
maxDegree, capacity, limit);
|
||||
|
||||
Id source = VertexAPI.checkAndParseVertexId(sourceV);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
SubGraphTraverser traverser = new SubGraphTraverser(g);
|
||||
HugeTraverser.PathSet paths = traverser.rings(source, dir, edgeLabel,
|
||||
depth, sourceInRing,
|
||||
maxDegree, capacity, limit);
|
||||
return manager.serializer(g).writePaths("rings", paths, false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_ELEMENTS_LIMIT;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/sameneighbors")
|
||||
@Singleton
|
||||
public class SameNeighborsAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.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) long limit) {
|
||||
LOG.debug("Graph [{}] get same neighbors between '{}' and '{}' with " +
|
||||
"direction {}, edge label {}, max degree '{}' and limit '{}'",
|
||||
graph, vertex, other, direction, edgeLabel, maxDegree, limit);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(vertex);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(other);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
SameNeighborTraverser traverser = new SameNeighborTraverser(g);
|
||||
Set<Id> neighbors = traverser.sameNeighbors(sourceId, targetId, dir,
|
||||
edgeLabel, maxDegree, limit);
|
||||
return manager.serializer(g).writeList("same_neighbors", neighbors);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Path("graphs/{graph}/traversers/shortestpath")
|
||||
@Singleton
|
||||
public class ShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("target") String target,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("max_depth") int depth,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("skip_degree")
|
||||
@DefaultValue("0") long skipDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity) {
|
||||
LOG.debug("Graph [{}] get shortest path from '{}', to '{}' with " +
|
||||
"direction {}, edge label {}, max depth '{}', " +
|
||||
"max degree '{}', skipped maxDegree '{}' and capacity '{}'",
|
||||
graph, source, target, direction, edgeLabel, depth,
|
||||
maxDegree, skipDegree, capacity);
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(target);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
|
||||
ShortestPathTraverser traverser = new ShortestPathTraverser(g);
|
||||
|
||||
List<String> edgeLabels = edgeLabel == null ? ImmutableList.of() :
|
||||
ImmutableList.of(edgeLabel);
|
||||
HugeTraverser.Path path = traverser.shortestPath(sourceId, targetId,
|
||||
dir, edgeLabels, depth,
|
||||
maxDegree, skipDegree,
|
||||
capacity);
|
||||
return manager.serializer(g).writeList("path", path.vertices());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_PATHS_LIMIT;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.WeightedPaths;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/singlesourceshortestpath")
|
||||
@Singleton
|
||||
public class SingleSourceShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("weight") String weight,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("skip_degree")
|
||||
@DefaultValue("0") long skipDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("limit")
|
||||
@DefaultValue(DEFAULT_PATHS_LIMIT) long limit,
|
||||
@QueryParam("with_vertex") boolean withVertex) {
|
||||
LOG.debug("Graph [{}] get single source shortest path from '{}' " +
|
||||
"with direction {}, edge label {}, weight property {}, " +
|
||||
"max degree '{}', limit '{}' and with vertex '{}'",
|
||||
graph, source, direction, edgeLabel,
|
||||
weight, maxDegree, withVertex);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
SingleSourceShortestPathTraverser traverser =
|
||||
new SingleSourceShortestPathTraverser(g);
|
||||
WeightedPaths paths = traverser.singleSourceShortestPaths(
|
||||
sourceId, dir, edgeLabel, weight,
|
||||
maxDegree, skipDegree, capacity, limit);
|
||||
Iterator<Vertex> iterator = QueryResults.emptyIterator();
|
||||
assert paths != null;
|
||||
if (!paths.isEmpty() && withVertex) {
|
||||
iterator = g.vertices(paths.vertices().toArray());
|
||||
}
|
||||
return manager.serializer(g).writeWeightedPaths(paths, iterator);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class TraverserAPI extends API {
|
||||
|
||||
protected static EdgeStep step(HugeGraph graph, Step step) {
|
||||
return new EdgeStep(graph, step.direction, step.labels, step.properties,
|
||||
step.maxDegree, step.skipDegree);
|
||||
}
|
||||
|
||||
protected static class Step {
|
||||
|
||||
@JsonProperty("direction")
|
||||
public Directions direction;
|
||||
@JsonProperty("labels")
|
||||
public List<String> labels;
|
||||
@JsonProperty("properties")
|
||||
public Map<String, Object> properties;
|
||||
@JsonAlias("degree")
|
||||
@JsonProperty("max_degree")
|
||||
public long maxDegree = Long.parseLong(DEFAULT_MAX_DEGREE);
|
||||
@JsonProperty("skip_degree")
|
||||
public long skipDegree = 0L;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("Step{direction=%s,labels=%s,properties=%s," +
|
||||
"maxDegree=%s,skipDegree=%s}",
|
||||
this.direction, this.labels, this.properties,
|
||||
this.maxDegree, this.skipDegree);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.api.traversers;
|
||||
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_CAPACITY;
|
||||
import static com.baidu.hugegraph.traversal.algorithm.HugeTraverser.DEFAULT_MAX_DEGREE;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Context;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.api.API;
|
||||
import com.baidu.hugegraph.api.graph.EdgeAPI;
|
||||
import com.baidu.hugegraph.api.graph.VertexAPI;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.backend.query.QueryResults;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.NodeWithWeight;
|
||||
import com.baidu.hugegraph.type.define.Directions;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
|
||||
@Path("graphs/{graph}/traversers/weightedshortestpath")
|
||||
@Singleton
|
||||
public class WeightedShortestPathAPI extends API {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
@GET
|
||||
@Timed
|
||||
@Produces(APPLICATION_JSON_WITH_CHARSET)
|
||||
public String get(@Context GraphManager manager,
|
||||
@PathParam("graph") String graph,
|
||||
@QueryParam("source") String source,
|
||||
@QueryParam("target") String target,
|
||||
@QueryParam("direction") String direction,
|
||||
@QueryParam("label") String edgeLabel,
|
||||
@QueryParam("weight") String weight,
|
||||
@QueryParam("max_degree")
|
||||
@DefaultValue(DEFAULT_MAX_DEGREE) long maxDegree,
|
||||
@QueryParam("skip_degree")
|
||||
@DefaultValue("0") long skipDegree,
|
||||
@QueryParam("capacity")
|
||||
@DefaultValue(DEFAULT_CAPACITY) long capacity,
|
||||
@QueryParam("with_vertex") boolean withVertex) {
|
||||
LOG.debug("Graph [{}] get weighted shortest path between '{}' and " +
|
||||
"'{}' with direction {}, edge label {}, weight property {}, " +
|
||||
"max degree '{}', skip degree '{}', capacity '{}', " +
|
||||
"and with vertex '{}'",
|
||||
graph, source, target, direction, edgeLabel, weight,
|
||||
maxDegree, skipDegree, capacity, withVertex);
|
||||
|
||||
Id sourceId = VertexAPI.checkAndParseVertexId(source);
|
||||
Id targetId = VertexAPI.checkAndParseVertexId(target);
|
||||
Directions dir = Directions.convert(EdgeAPI.parseDirection(direction));
|
||||
E.checkArgumentNotNull(weight, "The weight property can't be null");
|
||||
|
||||
HugeGraph g = graph(manager, graph);
|
||||
SingleSourceShortestPathTraverser traverser =
|
||||
new SingleSourceShortestPathTraverser(g);
|
||||
|
||||
NodeWithWeight path = traverser.weightedShortestPath(
|
||||
sourceId, targetId, dir, edgeLabel, weight,
|
||||
maxDegree, skipDegree, capacity);
|
||||
Iterator<Vertex> iterator = QueryResults.emptyIterator();
|
||||
if (path != null && withVertex) {
|
||||
assert !path.node().path().isEmpty();
|
||||
iterator = g.vertices(path.node().path().toArray());
|
||||
}
|
||||
return manager.serializer(g).writeWeightedPath(path, iterator);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
|
||||
import org.apache.tinkerpop.gremlin.server.GraphManager;
|
||||
import org.apache.tinkerpop.gremlin.server.GremlinServer;
|
||||
import org.apache.tinkerpop.gremlin.server.Settings;
|
||||
import org.apache.tinkerpop.gremlin.server.util.ThreadFactoryUtil;
|
||||
import org.apache.tinkerpop.gremlin.structure.Graph;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy.ContextThreadPoolExecutor;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
|
||||
/**
|
||||
* GremlinServer with custom ServerGremlinExecutor, which can pass Context
|
||||
*/
|
||||
public class ContextGremlinServer extends GremlinServer {
|
||||
|
||||
public ContextGremlinServer(final Settings settings) {
|
||||
/*
|
||||
* pass custom Executor https://github.com/apache/tinkerpop/pull/813
|
||||
*/
|
||||
super(settings, newGremlinExecutorService(settings));
|
||||
}
|
||||
|
||||
public void injectAuthGraph() {
|
||||
HugeGraphAuthProxy.setContext(Context.admin());
|
||||
|
||||
GraphManager manager = this.getServerGremlinExecutor()
|
||||
.getGraphManager();
|
||||
for (String name : manager.getGraphNames()) {
|
||||
Graph graph = manager.getGraph(name);
|
||||
graph = new HugeGraphAuthProxy((HugeGraph) graph);
|
||||
manager.putGraph(name, graph);
|
||||
}
|
||||
}
|
||||
|
||||
public void injectTraversalSource(String prefix) {
|
||||
GraphManager manager = this.getServerGremlinExecutor()
|
||||
.getGraphManager();
|
||||
for (String graph : manager.getGraphNames()) {
|
||||
GraphTraversalSource g = manager.getGraph(graph).traversal();
|
||||
String gName = prefix + graph;
|
||||
if (manager.getTraversalSource(gName) != null) {
|
||||
throw new HugeException(
|
||||
"Found existing name '%s' in global bindings, " +
|
||||
"it may lead to gremlin query error.", gName);
|
||||
}
|
||||
// Add a traversal source for all graphs with customed rule.
|
||||
manager.putTraversalSource(gName, g);
|
||||
}
|
||||
}
|
||||
|
||||
static ExecutorService newGremlinExecutorService(Settings settings) {
|
||||
if (settings.gremlinPool == 0) {
|
||||
settings.gremlinPool = CoreOptions.CPUS;
|
||||
}
|
||||
int size = settings.gremlinPool;
|
||||
ThreadFactory factory = ThreadFactoryUtil.create("exec-%d");
|
||||
return new ContextThreadPoolExecutor(size, size, factory);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.configuration.Configuration;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeFactory;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.StandardHugeGraph;
|
||||
import com.baidu.hugegraph.backend.cache.CacheManager;
|
||||
import com.baidu.hugegraph.backend.tx.AbstractTransaction;
|
||||
import com.baidu.hugegraph.concurrent.LockManager;
|
||||
import com.baidu.hugegraph.license.LicenseVerifier;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.SchemaManager;
|
||||
import com.baidu.hugegraph.schema.builder.EdgeLabelBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.IndexLabelBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.PropertyKeyBuilder;
|
||||
import com.baidu.hugegraph.schema.builder.VertexLabelBuilder;
|
||||
import com.baidu.hugegraph.serializer.JsonSerializer;
|
||||
import com.baidu.hugegraph.structure.HugeEdge;
|
||||
import com.baidu.hugegraph.structure.HugeProperty;
|
||||
import com.baidu.hugegraph.structure.HugeVertex;
|
||||
import com.baidu.hugegraph.task.HugeTask;
|
||||
import com.baidu.hugegraph.task.StandardTaskScheduler;
|
||||
import com.baidu.hugegraph.task.TaskCallable;
|
||||
import com.baidu.hugegraph.task.TaskCallable.SysTaskCallable;
|
||||
import com.baidu.hugegraph.task.TaskManager;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy;
|
||||
import com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy;
|
||||
import com.baidu.hugegraph.variables.HugeVariables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
public final class HugeFactoryAuthProxy {
|
||||
|
||||
public static final String GRAPH_FACTORY =
|
||||
"gremlin.graph=com.baidu.hugegraph.auth.HugeFactoryAuthProxy";
|
||||
|
||||
private static final Set<String> PROTECT_METHODS = ImmutableSet.of(
|
||||
"instance");
|
||||
|
||||
private static final Map<HugeGraph, HugeGraph> graphs = new HashMap<>();
|
||||
|
||||
static {
|
||||
HugeGraphAuthProxy.setContext(HugeGraphAuthProxy.Context.admin());
|
||||
HugeFactoryAuthProxy.registerPrivateActions();
|
||||
}
|
||||
|
||||
public static synchronized HugeGraph open(Configuration config) {
|
||||
/*
|
||||
* Inject authentication (replace HugeGraph with HugeGraphAuthProxy)
|
||||
* TODO: Add verify to StandardHugeGraph() to prevent dynamic creation
|
||||
*/
|
||||
HugeGraph graph = HugeFactory.open(config);
|
||||
HugeGraph proxy = graphs.get(graph);
|
||||
if (proxy == null) {
|
||||
proxy = new HugeGraphAuthProxy(graph);
|
||||
graphs.put(graph, proxy);
|
||||
}
|
||||
return proxy;
|
||||
}
|
||||
|
||||
private static void registerPrivateActions() {
|
||||
// Thread
|
||||
Reflection.registerFieldsToFilter(java.lang.Thread.class, "name", "priority", "threadQ", "eetop", "single_step", "daemon", "stillborn", "target", "group", "contextClassLoader", "inheritedAccessControlContext", "threadInitNumber", "threadLocals", "inheritableThreadLocals", "stackSize", "nativeParkEventPointer", "tid", "threadSeqNumber", "threadStatus", "parkBlocker", "blocker", "blockerLock", "EMPTY_STACK_TRACE", "SUBCLASS_IMPLEMENTATION_PERMISSION", "uncaughtExceptionHandler", "defaultUncaughtExceptionHandler", "threadLocalRandomSeed", "threadLocalRandomProbe", "threadLocalRandomSecondarySeed");
|
||||
Reflection.registerMethodsToFilter(java.lang.Thread.class, "exit", "dispatchUncaughtException", "clone", "isInterrupted", "registerNatives", "init", "init", "nextThreadNum", "nextThreadID", "blockedOn", "start0", "isCCLOverridden", "auditSubclass", "dumpThreads", "getThreads", "processQueue", "setPriority0", "stop0", "suspend0", "resume0", "interrupt0", "setNativeName");
|
||||
Reflection.registerFieldsToFilter(java.lang.ThreadLocal.class, "threadLocalHashCode", "nextHashCode", "HASH_INCREMENT");
|
||||
Reflection.registerMethodsToFilter(java.lang.ThreadLocal.class, "access$400", "createInheritedMap", "nextHashCode", "initialValue", "setInitialValue", "getMap", "createMap", "childValue");
|
||||
Reflection.registerMethodsToFilter(java.lang.InheritableThreadLocal.class, "getMap", "createMap", "childValue");
|
||||
|
||||
// HugeGraph
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.StandardAuthenticator.class, "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.StandardAuthenticator.class, "initAdminUser", "inputPassword", "graph");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.ConfigAuthenticator.class, "tokens");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeFactoryAuthProxy.class, "PROTECT_METHODS");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeFactoryAuthProxy.class, "genRegisterPrivateActions", "registerClass", "registerPrivateActions", "registerPrivateActions", "c");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeAuthenticator.User.class, "role", "client");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.server.auth.AuthenticatedUser.class, "name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.class, "LOG", "hugegraph", "taskScheduler", "authManager", "contexts", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.class, "lambda$0", "access$3", "access$4", "access$2", "access$5", "resetContext", "logUser", "verifyAdminPermission", "verifyStatusPermission", "verifyPermission", "verifySchemaPermission", "verifySchemaPermission", "verifySchemaPermission", "verifySchemaPermission", "verifyNamePermission", "verifyNameExistsPermission", "verifyElemPermission", "verifyElemPermission", "verifyElemPermission", "verifyElemPermission", "verifyResPermission", "verifyResPermission", "verifyUserPermission", "verifyUserPermission", "verifyUserPermission", "getContextString", "access$6", "access$7", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "lambda$8", "lambda$9", "lambda$10", "lambda$11", "lambda$12", "lambda$13", "lambda$14", "lambda$15", "lambda$16", "lambda$17", "lambda$18", "lambda$19", "lambda$20", "lambda$21", "lambda$22", "lambda$23", "lambda$24", "access$8", "access$9", "access$10", "setContext", "getContext");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.AuthManagerProxy.class, "authManager", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.AuthManagerProxy.class, "currentUsername", "updateCreator");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TaskSchedulerProxy.class, "taskScheduler", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TaskSchedulerProxy.class, "lambda$0", "lambda$1", "lambda$2", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "verifyTaskPermission", "hasTaskPermission");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.GraphTraversalSourceProxy.class, "this$0");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.class, "connection", "graph", "strategies", "bytecode");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TraversalStrategiesProxy.class, "REST_WOEKER", "serialVersionUID", "strategies", "this$0");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.TraversalStrategiesProxy.class, "translate");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.VariablesProxy.class, "variables", "this$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.Context.class, "ADMIN", "user");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.HugeGraphAuthProxy.ContextTask.class, "runner", "context");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.StandardHugeGraph.class, "LOG", "started", "closed", "mode", "variables", "name", "params", "configuration", "schemaEventHub", "graphEventHub", "indexEventHub", "writeRateLimiter", "readRateLimiter", "taskManager", "authManager", "features", "storeProvider", "tx", "ramtable", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.StandardHugeGraph.class, "lambda$0", "access$3", "access$4", "access$2", "access$5", "access$6", "access$7", "waitUntilAllTasksCompleted", "access$8", "loadStoreProvider", "graphTransaction", "schemaTransaction", "openSchemaTransaction", "checkGraphNotClosed", "openSystemTransaction", "openGraphTransaction", "systemTransaction", "access$9", "access$10", "access$11", "access$12", "access$13", "access$14", "access$15", "access$16", "access$17", "access$18", "serializer", "loadSchemaStore", "loadSystemStore", "loadGraphStore", "closeTx", "analyzer", "serverInfoManager", "reloadRamtable", "reloadRamtable", "access$19", "access$20", "access$21");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "graph", "this$0");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$StandardHugeGraphParams"), "access$1", "graph");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction"), "refs", "opened", "transactions", "this$0", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$TinkerPopTransaction"), "lambda$0", "access$3", "access$2", "lambda$1", "graphTransaction", "schemaTransaction", "systemTransaction", "access$1", "setOpened", "doCommit", "verifyOpened", "doRollback", "doClose", "destroyTransaction", "doOpen", "setClosed", "getOrNewTransaction", "access$0", "resetState");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractThreadLocalTransaction.class, "readWriteConsumerInternal", "closeConsumerInternal", "transactionListeners");
|
||||
Reflection.registerMethodsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractThreadLocalTransaction.class, "doClose", "fireOnCommit", "fireOnRollback", "doReadWrite", "lambda$fireOnRollback$1", "lambda$fireOnCommit$0");
|
||||
Reflection.registerFieldsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.class, "g");
|
||||
Reflection.registerMethodsToFilter(org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.class, "doCommit", "doRollback", "doClose", "doOpen", "fireOnCommit", "fireOnRollback", "doReadWrite");
|
||||
Reflection.registerFieldsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$Txs"), "schemaTx", "systemTx", "graphTx", "openedTime", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(c("com.baidu.hugegraph.StandardHugeGraph$Txs"), "access$2", "access$1", "access$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.GraphTransaction.class, "indexTx", "addedVertices", "removedVertices", "addedEdges", "removedEdges", "addedProps", "removedProps", "updatedVertices", "updatedEdges", "updatedOldestProps", "locksTable", "checkCustomVertexExist", "checkAdjacentVertexExist", "lazyLoadAdjacentVertex", "ignoreInvalidEntry", "commitPartOfAdjacentEdges", "batchSize", "pageSize", "verticesCapacity", "edgesCapacity", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.GraphTransaction.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "lambda$8", "lambda$9", "lambda$10", "lambda$11", "lambda$12", "lambda$13", "lambda$14", "lambda$15", "lambda$16", "lambda$17", "lambda$18", "lambda$19", "access$1", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "indexTransaction", "indexTransaction", "beforeWrite", "prepareCommit", "verticesInTxSize", "edgesInTxSize", "checkTxVerticesCapacity", "checkTxEdgesCapacity", "verticesInTxUpdated", "verticesInTxRemoved", "removingEdgeOwner", "prepareDeletions", "prepareDeletions", "prepareUpdates", "prepareAdditions", "checkVertexExistIfCustomizedId", "checkAggregateProperty", "checkAggregateProperty", "checkNonnullProperty", "queryEdgesFromBackend", "commitPartOfEdgeDeletions", "optimizeQueries", "checkVertexLabel", "checkId", "queryVerticesFromBackend", "joinTxVertices", "joinTxEdges", "lockForUpdateProperty", "optimizeQuery", "verifyVerticesConditionQuery", "verifyEdgesConditionQuery", "indexQuery", "joinTxRecords", "propertyUpdated", "parseEntry", "traverseByLabel", "reset", "queryVerticesByIds", "filterUnmatchedRecords", "skipOffsetOrStopLimit", "filterExpiredResultFromFromBackend", "queryEdgesByIds", "matchEdgeSortKeys", "rightResultFromIndexQuery");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.IndexableTransaction.class, "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.IndexableTransaction.class, "indexTransaction", "commit2Backend", "reset");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.tx.AbstractTransaction.class, "LOG", "ownerThread", "autoCommit", "closed", "committing", "committing2Backend", "graph", "store", "mutation", "serializer", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.tx.AbstractTransaction.class, "beforeWrite", "prepareCommit", "params", "mutation", "commit2Backend", "autoCommit", "beforeRead", "afterWrite", "afterRead", "commitMutation2Backend", "checkOwnerThread", "doAction", "store", "reset");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.HugeFactory.class, "LOG", "NAME_REGEX", "graphs");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.HugeFactory.class, "lambda$0");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.SchemaElement.class, "graph", "id", "name", "userdata", "status");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeVertex.class, "EMPTY_SET", "id", "label", "edges", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeVertex.class, "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "newProperty", "newProperty", "tx", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "checkIdLength", "onUpdateProperty", "ensureFilledProperties", "clone", "clone");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeElement.class, "EMPTY_MAP", "MAX_PROPERTIES", "graph", "properties", "expiredTime", "removed", "fresh", "propLoaded", "defaultValueUpdated", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeElement.class, "removed", "addProperty", "newProperty", "tx", "onUpdateProperty", "ensureFilledProperties", "propLoaded", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Cardinality", "getIdValue", "fresh", "updateToDefaultValueIfNone", "copyProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeEdge.class, "id", "label", "name", "sourceVertex", "targetVertex", "isOutEdge", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "$SWITCH_TABLE$org$apache$tinkerpop$gremlin$structure$Direction");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.structure.HugeEdge.class, "checkAdjacentVertexExist", "newProperty", "newProperty", "tx", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$HugeKeys", "onUpdateProperty", "ensureFilledProperties", "$SWITCH_TABLE$org$apache$tinkerpop$gremlin$structure$Direction", "clone", "clone");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.structure.HugeProperty.class, "owner", "pkey", "value");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.variables.HugeVariables.class, "LOG", "VARIABLES", "VARIABLE_KEY", "VARIABLE_TYPE", "BYTE_VALUE", "BOOLEAN_VALUE", "INTEGER_VALUE", "LONG_VALUE", "FLOAT_VALUE", "DOUBLE_VALUE", "STRING_VALUE", "LIST", "SET", "TYPES", "params", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.variables.HugeVariables.class, "createPropertyKey", "queryAllVariableVertices", "queryVariableVertex", "createVariableVertex", "removeVariableVertex", "extractSingleObject", "setProperty");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.SchemaManager.class, "transaction", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.SchemaManager.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "checkExists");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.PropertyKeyBuilder.class, "id", "name", "dataType", "cardinality", "aggregateType", "checkExist", "userdata", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.PropertyKeyBuilder.class, "lambda$0", "checkStableVars", "checkAggregateType", "hasSameProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.AbstractBuilder.class, "transaction", "graph");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.AbstractBuilder.class, "rebuildIndex", "graph", "checkSchemaName", "validOrGenerateId", "lockCheckAndCreateSchema", "propertyKeyOrNull", "checkSchemaIdIfRestoringMode", "vertexLabelOrNull", "edgeLabelOrNull", "indexLabelOrNull", "updateSchemaStatus");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.VertexLabelBuilder.class, "id", "name", "idStrategy", "properties", "primaryKeys", "nullableKeys", "ttl", "ttlStartTime", "enableLabelIndex", "userdata", "checkExist", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.VertexLabelBuilder.class, "lambda$0", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IdStrategy", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "checkProperties", "checkNullableKeys", "checkIdStrategy", "checkPrimaryKeys", "hasSameProperties", "checkTtl", "checkUserdata", "mapPkId2Name", "mapPkId2Name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.EdgeLabelBuilder.class, "id", "name", "sourceLabel", "targetLabel", "frequency", "properties", "sortKeys", "nullableKeys", "ttl", "ttlStartTime", "enableLabelIndex", "userdata", "checkExist", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.EdgeLabelBuilder.class, "lambda$0", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$Action", "checkProperties", "checkNullableKeys", "checkSortKeys", "checkRelation", "hasSameProperties", "checkTtl", "checkUserdata", "mapPkId2Name", "mapPkId2Name");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.schema.builder.IndexLabelBuilder.class, "id", "name", "baseType", "baseValue", "indexType", "indexFields", "userdata", "checkExist", "rebuild", "$assertionsDisabled", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$DataType", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IndexType");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.schema.builder.IndexLabelBuilder.class, "lambda$0", "checkStableVars", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$DataType", "$SWITCH_TABLE$com$baidu$hugegraph$type$define$IndexType", "checkBaseType", "checkIndexType", "checkFields4Range", "loadElement", "checkFields", "checkRepeatIndex", "checkRepeatIndex", "checkRepeatIndex", "checkPrimaryKeyIndex", "checkRepeatRangeIndex", "checkRepeatSearchIndex", "checkRepeatSecondaryIndex", "checkRepeatShardIndex", "checkRepeatUniqueIndex", "removeSubIndex", "hasSubIndex", "allStringIndex", "oneNumericField", "hasSameProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskManager.class, "LOG", "SCHEDULE_PERIOD", "THREADS", "MANAGER", "schedulers", "taskExecutor", "taskDbExecutor", "serverInfoDbExecutor", "schedulerExecutor", "contexts", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskManager.class, "lambda$0", "resetContext", "closeTaskTx", "setContext", "instance", "closeSchedulerTx", "notifyNewTask", "scheduleOrExecuteJob", "scheduleOrExecuteJobForGraph");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.StandardTaskScheduler.class, "LOG", "graph", "serverManager", "taskExecutor", "taskDbExecutor", "eventListener", "tasks", "taskTx", "NO_LIMIT", "PAGE_SIZE", "QUERY_INTERVAL", "MAX_PENDING_TASKS", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.StandardTaskScheduler.class, "lambda$0", "lambda$1", "lambda$2", "lambda$3", "lambda$4", "lambda$5", "lambda$6", "lambda$7", "tx", "listenChanges", "unlistenChanges", "submitTask", "queryTask", "queryTask", "queryTask", "call", "call", "remove", "sleep", "taskDone", "serverManager", "supportsPaging", "restore", "checkOnMasterNode", "waitUntilTaskCompleted", "scheduleTasks", "executeTasksOnWorker", "cancelTasksOnWorker");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.HugeTask.class, "LOG", "DECOMPRESS_RATIO", "scheduler", "callable", "type", "name", "id", "parent", "dependencies", "description", "context", "create", "server", "load", "status", "progress", "update", "retries", "input", "result", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.HugeTask.class, "property", "scheduler", "scheduler", "asArray", "checkPropertySize", "checkPropertySize", "checkDependenciesSuccess", "toOrderSet", "done", "callable", "setException", "set", "result", "status");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskCallable.class, "LOG", "ERROR_COMMIT", "ERROR_MESSAGES", "task", "graph", "lastSaveTime", "saveInterval");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskCallable.class, "graph", "closeTx", "cancelled", "done", "task", "save", "needSaveWithEx");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.task.TaskCallable.SysTaskCallable.class, "params");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.task.TaskCallable.SysTaskCallable.class, "params", "params");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.StandardAuthManager.class, "CACHE_EXPIRE", "graph", "eventListener", "usersCache", "users", "groups", "targets", "belong", "access", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.StandardAuthManager.class, "lambda$0", "listenChanges", "unlistenChanges", "invalidCache", "initSchemaIfNeeded", "rolePermission", "rolePermission", "rolePermission", "cache");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.SchemaDefine.class, "graph", "label");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.SchemaDefine.class, "schema", "createPropertyKey", "createPropertyKey", "createPropertyKey", "existEdgeLabel", "createRangeIndex", "unhideField", "hideField", "existVertexLabel", "initProperties");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.EntityManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.EntityManager.class, "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryEntity", "constructVertex", "save", "query");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.auth.RelationshipManager.class, "graph", "label", "deser", "NO_LIMIT", "$assertionsDisabled");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.auth.RelationshipManager.class, "lambda$0", "toList", "graph", "tx", "commitOrRollback", "unhideLabel", "queryById", "queryRelationship", "newVertex", "save");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.backend.cache.CacheManager.class, "LOG", "INSTANCE", "TIMER_TICK_PERIOD", "LOG_TICK_COST_TIME", "caches", "timer");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.backend.cache.CacheManager.class, "access$0", "scheduleTimer", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.concurrent.LockManager.class, "INSTANCE", "lockGroupMap");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.concurrent.LockManager.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.license.LicenseVerifier.class, "LOG", "LICENSE_PARAM_PATH", "INSTANCE", "CHECK_INTERVAL", "lastCheckTime", "verifyParam", "manager");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.license.LicenseVerifier.class, "buildVerifyParam", "initLicenseParam", "verifyPublicCert", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.metrics.ServerReporter.class, "instance", "gauges", "counters", "histograms", "meters", "timers");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.metrics.ServerReporter.class, "instance", "instance");
|
||||
Reflection.registerFieldsToFilter(com.codahale.metrics.ScheduledReporter.class, "LOG", "FACTORY_ID", "registry", "executor", "shutdownExecutorOnStop", "disabledMetricAttributes", "scheduledFuture", "filter", "durationFactor", "durationUnit", "rateFactor", "rateUnit");
|
||||
Reflection.registerMethodsToFilter(com.codahale.metrics.ScheduledReporter.class, "convertDuration", "convertRate", "getRateUnit", "getDurationUnit", "isShutdownExecutorOnStop", "getDisabledMetricAttributes", "calculateRateUnit", "createDefaultExecutor", "lambda$start$0", "start");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.serializer.JsonSerializer.class, "LBUF_SIZE", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.serializer.JsonSerializer.class, "writeIterator", "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeVertexStepStrategy.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeGraphStepStrategy.class, "instance");
|
||||
Reflection.registerFieldsToFilter(com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy.class, "serialVersionUID", "INSTANCE");
|
||||
Reflection.registerMethodsToFilter(com.baidu.hugegraph.traversal.optimize.HugeCountStepStrategy.class, "lambda$0", "instance");
|
||||
|
||||
// Enable this line to generate registration statement
|
||||
//genRegisterPrivateActions();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void genRegisterPrivateActions() {
|
||||
registerPrivateActions(Thread.class);
|
||||
registerPrivateActions(ThreadLocal.class);
|
||||
registerPrivateActions(InheritableThreadLocal.class);
|
||||
|
||||
registerPrivateActions(StandardAuthenticator.class);
|
||||
registerPrivateActions(ConfigAuthenticator.class);
|
||||
registerPrivateActions(HugeFactoryAuthProxy.class);
|
||||
registerPrivateActions(HugeAuthenticator.User.class);
|
||||
|
||||
registerPrivateActions(HugeGraphAuthProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.AuthManagerProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.TaskSchedulerProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.GraphTraversalSourceProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.TraversalStrategiesProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.VariablesProxy.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.Context.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.ContextThreadPoolExecutor.class);
|
||||
registerPrivateActions(HugeGraphAuthProxy.ContextTask.class);
|
||||
|
||||
for (Class<?> clazz : StandardHugeGraph.PROTECT_CLASSES) {
|
||||
registerPrivateActions(clazz);
|
||||
}
|
||||
|
||||
registerPrivateActions(HugeFactory.class);
|
||||
registerPrivateActions(AbstractTransaction.class);
|
||||
|
||||
registerPrivateActions(SchemaElement.class);
|
||||
registerPrivateActions(HugeVertex.class);
|
||||
registerPrivateActions(HugeEdge.class);
|
||||
registerPrivateActions(HugeProperty.class);
|
||||
registerPrivateActions(HugeVariables.class);
|
||||
|
||||
registerPrivateActions(SchemaManager.class);
|
||||
registerPrivateActions(PropertyKeyBuilder.class);
|
||||
registerPrivateActions(VertexLabelBuilder.class);
|
||||
registerPrivateActions(EdgeLabelBuilder.class);
|
||||
registerPrivateActions(IndexLabelBuilder.class);
|
||||
|
||||
registerPrivateActions(TaskManager.class);
|
||||
registerPrivateActions(StandardTaskScheduler.class);
|
||||
registerPrivateActions(HugeTask.class);
|
||||
registerPrivateActions(TaskCallable.class);
|
||||
registerPrivateActions(SysTaskCallable.class);
|
||||
|
||||
registerPrivateActions(StandardAuthManager.class);
|
||||
registerPrivateActions(SchemaDefine.class);
|
||||
registerPrivateActions(EntityManager.class);
|
||||
registerPrivateActions(RelationshipManager.class);
|
||||
|
||||
// Don't shield them because need to access by auth RPC
|
||||
//registerPrivateActions(HugeUser.class);
|
||||
//registerPrivateActions(RolePermission.class);
|
||||
//registerPrivateActions(HugeResource.class);
|
||||
|
||||
registerPrivateActions(CacheManager.class);
|
||||
registerPrivateActions(LockManager.class);
|
||||
registerPrivateActions(LicenseVerifier.class);
|
||||
registerPrivateActions(ServerReporter.class);
|
||||
registerPrivateActions(JsonSerializer.class);
|
||||
registerPrivateActions(HugeVertexStepStrategy.class);
|
||||
registerPrivateActions(HugeGraphStepStrategy.class);
|
||||
registerPrivateActions(HugeCountStepStrategy.class);
|
||||
}
|
||||
|
||||
private static void registerPrivateActions(Class<?> clazz) {
|
||||
while (clazz != Object.class) {
|
||||
List<String> fields = new ArrayList<>();
|
||||
for (Field field : clazz.getDeclaredFields()) {
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
fields.add(field.getName());
|
||||
}
|
||||
}
|
||||
List<String> methods = new ArrayList<>();
|
||||
for (Method method : clazz.getDeclaredMethods()) {
|
||||
if (!Modifier.isPublic(method.getModifiers()) ||
|
||||
PROTECT_METHODS.contains(method.getName())) {
|
||||
methods.add(method.getName());
|
||||
}
|
||||
}
|
||||
registerClass(clazz, fields, methods);
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean registerClass(Class<?> clazz,
|
||||
List<String> fields,
|
||||
List<String> methods) {
|
||||
if (clazz.getName().startsWith("java") ||
|
||||
fields.isEmpty() && methods.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
final String[] array = new String[fields.size()];
|
||||
try {
|
||||
Reflection.registerFieldsToFilter(clazz, fields.toArray(array));
|
||||
Reflection.registerMethodsToFilter(clazz, methods.toArray(array));
|
||||
} catch (IllegalArgumentException e) {
|
||||
if (e.getMessage().contains("Filter already registered: class")) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
String code;
|
||||
code = String.format("Reflection.registerFieldsToFilter(%s.class, \"%s\");",
|
||||
clazz.getCanonicalName(), String.join("\", \"", fields));
|
||||
if (!fields.isEmpty()) {
|
||||
System.out.println(code);
|
||||
}
|
||||
|
||||
code = String.format("Reflection.registerMethodsToFilter(%s.class, \"%s\");",
|
||||
clazz.getCanonicalName(), String.join("\", \"", methods));
|
||||
if (!methods.isEmpty()) {
|
||||
System.out.println(code);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Class<?> c(String clazz) {
|
||||
try {
|
||||
return Class.forName(clazz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new HugeException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,184 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.auth;
|
||||
|
||||
import java.io.Console;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
|
||||
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.rpc.RpcClientProviderWithAuth;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.StringEncoding;
|
||||
|
||||
public class StandardAuthenticator implements HugeAuthenticator {
|
||||
|
||||
private static final String INITING_STORE = "initing_store";
|
||||
|
||||
private HugeGraph graph = null;
|
||||
|
||||
private HugeGraph graph() {
|
||||
E.checkState(this.graph != null, "Must setup Authenticator first");
|
||||
return this.graph;
|
||||
}
|
||||
|
||||
private void initAdminUser() throws Exception {
|
||||
if (this.requireInitAdminUser()) {
|
||||
this.initAdminUser(this.inputPassword());
|
||||
}
|
||||
this.graph.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAdminUser(String password) {
|
||||
// Not allowed to call by non main thread
|
||||
String caller = Thread.currentThread().getName();
|
||||
E.checkState("main".equals(caller), "Invalid caller '%s'", caller);
|
||||
|
||||
AuthManager authManager = this.graph().hugegraph().authManager();
|
||||
// Only init user when local mode and user has not been initialized
|
||||
if (this.requireInitAdminUser()) {
|
||||
HugeUser admin = new HugeUser(HugeAuthenticator.USER_ADMIN);
|
||||
admin.password(StringEncoding.hashPassword(password));
|
||||
admin.creator(HugeAuthenticator.USER_SYSTEM);
|
||||
authManager.createUser(admin);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean requireInitAdminUser() {
|
||||
AuthManager authManager = this.graph().hugegraph().authManager();
|
||||
return StandardAuthManager.isLocal(authManager) &&
|
||||
authManager.findUser(HugeAuthenticator.USER_ADMIN) == null;
|
||||
}
|
||||
|
||||
private String inputPassword() {
|
||||
String inputPrompt = "Please input the admin password:";
|
||||
String notEmptyPrompt = "The admin password can't be empty";
|
||||
Console console = System.console();
|
||||
while (true) {
|
||||
String password = "";
|
||||
if (console != null) {
|
||||
char[] chars = console.readPassword(inputPrompt);
|
||||
password = new String(chars);
|
||||
} else {
|
||||
System.out.print(inputPrompt);
|
||||
@SuppressWarnings("resource") // just wrapper of System.in
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
password = scanner.nextLine();
|
||||
}
|
||||
if (!password.isEmpty()) {
|
||||
return password;
|
||||
}
|
||||
System.out.println(notEmptyPrompt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup(HugeConfig config) {
|
||||
String graphName = config.get(ServerOptions.AUTH_GRAPH_STORE);
|
||||
String graphPath = config.getMap(ServerOptions.GRAPHS).get(graphName);
|
||||
E.checkArgument(graphPath != null,
|
||||
"Can't find graph name '%s' in config '%s' at " +
|
||||
"'rest-server.properties' to store auth information, " +
|
||||
"please ensure the value of '%s' matches it correctly",
|
||||
graphName, ServerOptions.GRAPHS,
|
||||
ServerOptions.AUTH_GRAPH_STORE.name());
|
||||
|
||||
HugeConfig graphConfig = new HugeConfig(graphPath);
|
||||
if (config.getProperty(INITING_STORE) != null &&
|
||||
config.getBoolean(INITING_STORE)) {
|
||||
// Forced set RAFT_MODE to false when initializing backend
|
||||
graphConfig.setProperty(CoreOptions.RAFT_MODE.name(), "false");
|
||||
}
|
||||
this.graph = (HugeGraph) GraphFactory.open(graphConfig);
|
||||
|
||||
String remoteUrl = config.get(ServerOptions.AUTH_REMOTE_URL);
|
||||
if (StringUtils.isNotEmpty(remoteUrl)) {
|
||||
RpcClientProviderWithAuth clientProvider =
|
||||
new RpcClientProviderWithAuth(config);
|
||||
this.graph.switchAuthManager(clientProvider.authManager());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if a user is legal
|
||||
* @param username the username for authentication
|
||||
* @param password the password for authentication
|
||||
* @param token the token for authentication
|
||||
* @return String No permission if return ROLE_NONE else return a role
|
||||
*/
|
||||
@Override
|
||||
public UserWithRole authenticate(String username, String password,
|
||||
String token) {
|
||||
UserWithRole userWithRole;
|
||||
if (StringUtils.isNotEmpty(token)) {
|
||||
userWithRole = this.authManager().validateUser(token);
|
||||
} else {
|
||||
E.checkArgumentNotNull(username,
|
||||
"The username parameter can't be null");
|
||||
E.checkArgumentNotNull(password,
|
||||
"The password parameter can't be null");
|
||||
userWithRole = this.authManager().validateUser(username, password);
|
||||
}
|
||||
|
||||
RolePermission role = userWithRole.role();
|
||||
if (role == null) {
|
||||
role = ROLE_NONE;
|
||||
} else if (USER_ADMIN.equals(userWithRole.username())) {
|
||||
role = ROLE_ADMIN;
|
||||
} else {
|
||||
return userWithRole;
|
||||
}
|
||||
|
||||
return new UserWithRole(userWithRole.userId(),
|
||||
userWithRole.username(), role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthManager authManager() {
|
||||
return this.graph().authManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SaslNegotiator newSaslNegotiator(InetAddress remoteAddress) {
|
||||
throw new NotImplementedException("SaslNegotiator is unsupported");
|
||||
}
|
||||
|
||||
public static void initAdminUserIfNeeded(String confFile) throws Exception {
|
||||
StandardAuthenticator auth = new StandardAuthenticator();
|
||||
HugeConfig config = new HugeConfig(confFile);
|
||||
String authClass = config.get(ServerOptions.AUTHENTICATOR);
|
||||
if (authClass.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
config.addProperty(INITING_STORE, true);
|
||||
auth.setup(config);
|
||||
if (auth.graph().backendStoreFeatures().supportsPersistence()) {
|
||||
auth.initAdminUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,365 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.core;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.server.auth.AuthenticationException;
|
||||
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
|
||||
import org.apache.tinkerpop.gremlin.structure.Graph;
|
||||
import org.apache.tinkerpop.gremlin.structure.Transaction;
|
||||
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeFactory;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.auth.AuthManager;
|
||||
import com.baidu.hugegraph.auth.HugeAuthenticator;
|
||||
import com.baidu.hugegraph.auth.HugeFactoryAuthProxy;
|
||||
import com.baidu.hugegraph.auth.HugeGraphAuthProxy;
|
||||
import com.baidu.hugegraph.backend.BackendException;
|
||||
import com.baidu.hugegraph.backend.cache.Cache;
|
||||
import com.baidu.hugegraph.backend.cache.CacheManager;
|
||||
import com.baidu.hugegraph.backend.id.IdGenerator;
|
||||
import com.baidu.hugegraph.backend.store.BackendStoreSystemInfo;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.exception.NotSupportException;
|
||||
import com.baidu.hugegraph.license.LicenseVerifier;
|
||||
import com.baidu.hugegraph.metrics.MetricsUtil;
|
||||
import com.baidu.hugegraph.metrics.ServerReporter;
|
||||
import com.baidu.hugegraph.rpc.RpcClientProvider;
|
||||
import com.baidu.hugegraph.rpc.RpcConsumerConfig;
|
||||
import com.baidu.hugegraph.rpc.RpcProviderConfig;
|
||||
import com.baidu.hugegraph.rpc.RpcServer;
|
||||
import com.baidu.hugegraph.serializer.JsonSerializer;
|
||||
import com.baidu.hugegraph.serializer.Serializer;
|
||||
import com.baidu.hugegraph.server.RestServer;
|
||||
import com.baidu.hugegraph.task.TaskManager;
|
||||
import com.baidu.hugegraph.type.define.NodeRole;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
|
||||
public final class GraphManager {
|
||||
|
||||
private static final Logger LOG = Log.logger(RestServer.class);
|
||||
|
||||
private final Map<String, Graph> graphs;
|
||||
private final HugeAuthenticator authenticator;
|
||||
private final RpcServer rpcServer;
|
||||
private final RpcClientProvider rpcClient;
|
||||
|
||||
public GraphManager(HugeConfig conf) {
|
||||
this.graphs = new ConcurrentHashMap<>();
|
||||
this.authenticator = HugeAuthenticator.loadAuthenticator(conf);
|
||||
this.rpcServer = new RpcServer(conf);
|
||||
this.rpcClient = new RpcClientProvider(conf);
|
||||
|
||||
this.loadGraphs(conf.getMap(ServerOptions.GRAPHS));
|
||||
// this.installLicense(conf, "");
|
||||
// Raft will load snapshot firstly then launch election and replay log
|
||||
this.waitGraphsStarted();
|
||||
this.checkBackendVersionOrExit(conf);
|
||||
this.startRpcServer();
|
||||
this.serverStarted(conf);
|
||||
this.addMetrics(conf);
|
||||
}
|
||||
|
||||
public void loadGraphs(final Map<String, String> graphConfs) {
|
||||
for (Map.Entry<String, String> conf : graphConfs.entrySet()) {
|
||||
String name = conf.getKey();
|
||||
String path = conf.getValue();
|
||||
HugeFactory.checkGraphName(name, "rest-server.properties");
|
||||
try {
|
||||
this.loadGraph(name, path);
|
||||
} catch (RuntimeException e) {
|
||||
LOG.error("Graph '{}' can't be loaded: '{}'", name, path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void waitGraphsStarted() {
|
||||
this.graphs.keySet().forEach(name -> {
|
||||
HugeGraph graph = this.graph(name);
|
||||
graph.waitStarted();
|
||||
});
|
||||
}
|
||||
|
||||
public Set<String> graphs() {
|
||||
return Collections.unmodifiableSet(this.graphs.keySet());
|
||||
}
|
||||
|
||||
public HugeGraph graph(String name) {
|
||||
Graph graph = this.graphs.get(name);
|
||||
if (graph == null) {
|
||||
return null;
|
||||
} else if (graph instanceof HugeGraph) {
|
||||
return (HugeGraph) graph;
|
||||
}
|
||||
throw new NotSupportException("graph instance of %s", graph.getClass());
|
||||
}
|
||||
|
||||
public Serializer serializer(Graph g) {
|
||||
return JsonSerializer.instance();
|
||||
}
|
||||
|
||||
public void rollbackAll() {
|
||||
this.graphs.values().forEach(graph -> {
|
||||
if (graph.features().graph().supportsTransactions() &&
|
||||
graph.tx().isOpen()) {
|
||||
graph.tx().rollback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void rollback(final Set<String> graphSourceNamesToCloseTxOn) {
|
||||
closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.ROLLBACK);
|
||||
}
|
||||
|
||||
public void commitAll() {
|
||||
this.graphs.values().forEach(graph -> {
|
||||
if (graph.features().graph().supportsTransactions() &&
|
||||
graph.tx().isOpen()) {
|
||||
graph.tx().commit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void commit(final Set<String> graphSourceNamesToCloseTxOn) {
|
||||
closeTx(graphSourceNamesToCloseTxOn, Transaction.Status.COMMIT);
|
||||
}
|
||||
|
||||
public boolean requireAuthentication() {
|
||||
if (this.authenticator == null) {
|
||||
return false;
|
||||
}
|
||||
return this.authenticator.requireAuthentication();
|
||||
}
|
||||
|
||||
public HugeAuthenticator.User authenticate(Map<String, String> credentials)
|
||||
throws AuthenticationException {
|
||||
return this.authenticator().authenticate(credentials);
|
||||
}
|
||||
|
||||
public AuthManager authManager() {
|
||||
return this.authenticator().authManager();
|
||||
}
|
||||
|
||||
public void close() {
|
||||
this.destroyRpcServer();
|
||||
}
|
||||
|
||||
private void startRpcServer() {
|
||||
if (!this.rpcServer.enabled()) {
|
||||
LOG.info("RpcServer is not enabled, skip starting rpc service");
|
||||
return;
|
||||
}
|
||||
|
||||
RpcProviderConfig serverConfig = this.rpcServer.config();
|
||||
|
||||
// Start auth rpc service if authenticator enabled
|
||||
if (this.authenticator != null) {
|
||||
serverConfig.addService(AuthManager.class,
|
||||
this.authenticator.authManager());
|
||||
}
|
||||
|
||||
// Start graph rpc service if RPC_REMOTE_URL enabled
|
||||
if (this.rpcClient.enabled()) {
|
||||
RpcConsumerConfig clientConfig = this.rpcClient.config();
|
||||
|
||||
for (Graph graph : this.graphs.values()) {
|
||||
HugeGraph hugegraph = (HugeGraph) graph;
|
||||
hugegraph.registerRpcServices(serverConfig, clientConfig);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
this.rpcServer.exportAll();
|
||||
} catch (Throwable e) {
|
||||
this.rpcServer.destroy();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void destroyRpcServer() {
|
||||
try {
|
||||
this.rpcClient.destroy();
|
||||
} finally {
|
||||
this.rpcServer.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
private HugeAuthenticator authenticator() {
|
||||
E.checkState(this.authenticator != null, "Unconfigured authenticator");
|
||||
return this.authenticator;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void installLicense(HugeConfig config, String md5) {
|
||||
LicenseVerifier.instance().install(config, this, md5);
|
||||
}
|
||||
|
||||
private void closeTx(final Set<String> graphSourceNamesToCloseTxOn,
|
||||
final Transaction.Status tx) {
|
||||
final Set<Graph> graphsToCloseTxOn = new HashSet<>();
|
||||
|
||||
graphSourceNamesToCloseTxOn.forEach(name -> {
|
||||
if (this.graphs.containsKey(name)) {
|
||||
graphsToCloseTxOn.add(this.graphs.get(name));
|
||||
}
|
||||
});
|
||||
|
||||
graphsToCloseTxOn.forEach(graph -> {
|
||||
if (graph.features().graph().supportsTransactions() &&
|
||||
graph.tx().isOpen()) {
|
||||
if (tx == Transaction.Status.COMMIT) {
|
||||
graph.tx().commit();
|
||||
} else {
|
||||
graph.tx().rollback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadGraph(String name, String path) {
|
||||
final Graph graph = GraphFactory.open(path);
|
||||
this.graphs.put(name, graph);
|
||||
LOG.info("Graph '{}' was successfully configured via '{}'", name, path);
|
||||
|
||||
if (this.requireAuthentication() &&
|
||||
!(graph instanceof HugeGraphAuthProxy)) {
|
||||
LOG.warn("You may need to support access control for '{}' with {}",
|
||||
path, HugeFactoryAuthProxy.GRAPH_FACTORY);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkBackendVersionOrExit(HugeConfig config) {
|
||||
for (String graph : this.graphs()) {
|
||||
// TODO: close tx from main thread
|
||||
HugeGraph hugegraph = this.graph(graph);
|
||||
if (!hugegraph.backendStoreFeatures().supportsPersistence()) {
|
||||
hugegraph.initBackend();
|
||||
if (this.requireAuthentication()) {
|
||||
String token = config.get(ServerOptions.AUTH_ADMIN_TOKEN);
|
||||
try {
|
||||
this.authenticator.initAdminUser(token);
|
||||
} catch (Exception e) {
|
||||
throw new BackendException(
|
||||
"The backend store of '%s' can't " +
|
||||
"initialize admin user", hugegraph.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
BackendStoreSystemInfo info = hugegraph.backendStoreSystemInfo();
|
||||
if (!info.exists()) {
|
||||
throw new BackendException(
|
||||
"The backend store of '%s' has not been initialized",
|
||||
hugegraph.name());
|
||||
}
|
||||
if (!info.checkVersion()) {
|
||||
throw new BackendException(
|
||||
"The backend store version is inconsistent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void serverStarted(HugeConfig config) {
|
||||
String server = config.get(ServerOptions.SERVER_ID);
|
||||
String role = config.get(ServerOptions.SERVER_ROLE);
|
||||
E.checkArgument(server != null && !server.isEmpty(),
|
||||
"The server name can't be null or empty");
|
||||
E.checkArgument(role != null && !role.isEmpty(),
|
||||
"The server role can't be null or empty");
|
||||
NodeRole nodeRole = NodeRole.valueOf(role.toUpperCase());
|
||||
for (String graph : this.graphs()) {
|
||||
HugeGraph hugegraph = this.graph(graph);
|
||||
assert hugegraph != null;
|
||||
hugegraph.serverStarted(IdGenerator.of(server), nodeRole);
|
||||
}
|
||||
}
|
||||
|
||||
private void addMetrics(HugeConfig config) {
|
||||
final MetricManager metric = MetricManager.INSTANCE;
|
||||
// Force to add server reporter
|
||||
ServerReporter reporter = ServerReporter.instance(metric.getRegistry());
|
||||
reporter.start(60L, TimeUnit.SECONDS);
|
||||
|
||||
// Add metrics for MAX_WRITE_THREADS
|
||||
int maxWriteThreads = config.get(ServerOptions.MAX_WRITE_THREADS);
|
||||
MetricsUtil.registerGauge(RestServer.class, "max-write-threads", () -> {
|
||||
return maxWriteThreads;
|
||||
});
|
||||
|
||||
// Add metrics for caches
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
Map<String, Cache<?, ?>> caches = (Map) CacheManager.instance()
|
||||
.caches();
|
||||
registerCacheMetrics(caches);
|
||||
final AtomicInteger lastCachesSize = new AtomicInteger(caches.size());
|
||||
MetricsUtil.registerGauge(Cache.class, "instances", () -> {
|
||||
int count = caches.size();
|
||||
if (count != lastCachesSize.get()) {
|
||||
// Update if caches changed (effect in the next report period)
|
||||
registerCacheMetrics(caches);
|
||||
lastCachesSize.set(count);
|
||||
}
|
||||
return count;
|
||||
});
|
||||
|
||||
// Add metrics for task
|
||||
MetricsUtil.registerGauge(TaskManager.class, "workers", () -> {
|
||||
return TaskManager.instance().workerPoolSize();
|
||||
});
|
||||
MetricsUtil.registerGauge(TaskManager.class, "pending-tasks", () -> {
|
||||
return TaskManager.instance().pendingTasks();
|
||||
});
|
||||
}
|
||||
|
||||
private static void registerCacheMetrics(Map<String, Cache<?, ?>> caches) {
|
||||
Set<String> names = MetricManager.INSTANCE.getRegistry().getNames();
|
||||
for (Map.Entry<String, Cache<?, ?>> entry : caches.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Cache<?, ?> cache = entry.getValue();
|
||||
|
||||
String hits = String.format("%s.%s", key, "hits");
|
||||
String miss = String.format("%s.%s", key, "miss");
|
||||
String exp = String.format("%s.%s", key, "expire");
|
||||
String size = String.format("%s.%s", key, "size");
|
||||
String cap = String.format("%s.%s", key, "capacity");
|
||||
|
||||
// Avoid registering multiple times
|
||||
if (names.stream().anyMatch(name -> name.endsWith(hits))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MetricsUtil.registerGauge(Cache.class, hits, () -> cache.hits());
|
||||
MetricsUtil.registerGauge(Cache.class, miss, () -> cache.miss());
|
||||
MetricsUtil.registerGauge(Cache.class, exp, () -> cache.expire());
|
||||
MetricsUtil.registerGauge(Cache.class, size, () -> cache.size());
|
||||
MetricsUtil.registerGauge(Cache.class, cap, () -> cache.capacity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
package com.baidu.hugegraph.define;
|
||||
|
||||
public interface Checkable {
|
||||
|
||||
public void checkCreate(boolean isBatch);
|
||||
|
||||
public default void checkUpdate() {
|
||||
this.checkCreate(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.license;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.HugeGraph;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import de.schlichtherle.license.CipherParam;
|
||||
import de.schlichtherle.license.DefaultCipherParam;
|
||||
import de.schlichtherle.license.DefaultKeyStoreParam;
|
||||
import de.schlichtherle.license.DefaultLicenseParam;
|
||||
import de.schlichtherle.license.KeyStoreParam;
|
||||
import de.schlichtherle.license.LicenseContent;
|
||||
import de.schlichtherle.license.LicenseParam;
|
||||
|
||||
public class LicenseVerifier {
|
||||
|
||||
private static final Logger LOG = Log.logger(HugeGraph.class);
|
||||
|
||||
private static final String LICENSE_PARAM_PATH = "/verify-license.json";
|
||||
|
||||
private static volatile LicenseVerifier INSTANCE = null;
|
||||
|
||||
private static final Duration CHECK_INTERVAL = Duration.ofMinutes(10);
|
||||
private volatile Instant lastCheckTime = Instant.now();
|
||||
|
||||
private final LicenseVerifyParam verifyParam;
|
||||
private final LicenseVerifyManager manager;
|
||||
|
||||
private LicenseVerifier() {
|
||||
this.verifyParam = buildVerifyParam(LICENSE_PARAM_PATH);
|
||||
LicenseParam licenseParam = this.initLicenseParam(this.verifyParam);
|
||||
this.manager = new LicenseVerifyManager(licenseParam);
|
||||
}
|
||||
|
||||
public static LicenseVerifier instance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized(LicenseVerifier.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new LicenseVerifier();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void verifyIfNeeded() {
|
||||
Instant now = Instant.now();
|
||||
Duration interval = Duration.between(this.lastCheckTime, now);
|
||||
if (!interval.minus(CHECK_INTERVAL).isNegative()) {
|
||||
this.verify();
|
||||
this.lastCheckTime = now;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void install(HugeConfig config,
|
||||
GraphManager graphManager,
|
||||
String md5) {
|
||||
this.manager.config(config);
|
||||
this.manager.graphManager(graphManager);
|
||||
try {
|
||||
this.manager.uninstall();
|
||||
File licenseFile = new File(this.verifyParam.licensePath());
|
||||
this.verifyPublicCert(md5);
|
||||
LicenseContent content = this.manager.install(licenseFile);
|
||||
LOG.info("The license is successfully installed, valid for {} - {}",
|
||||
content.getNotBefore(), content.getNotAfter());
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to install license", e);
|
||||
throw new HugeException("Failed to install license", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
try {
|
||||
LicenseContent content = this.manager.verify();
|
||||
LOG.info("The license verification passed, valid for {} - {}",
|
||||
content.getNotBefore(), content.getNotAfter());
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to verify license", e);
|
||||
throw new HugeException("Failed to verify license", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyPublicCert(String expectMD5) {
|
||||
String path = this.verifyParam.publicKeyPath();
|
||||
try (InputStream is = LicenseVerifier.class.getResourceAsStream(path)) {
|
||||
String actualMD5 = DigestUtils.md5Hex(is);
|
||||
if (!actualMD5.equals(expectMD5)) {
|
||||
throw new HugeException("Invalid public cert");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to read public cert", e);
|
||||
throw new HugeException("Failed to read public cert", e);
|
||||
}
|
||||
}
|
||||
|
||||
private LicenseParam initLicenseParam(LicenseVerifyParam param) {
|
||||
Preferences preferences = Preferences.userNodeForPackage(
|
||||
LicenseVerifier.class);
|
||||
CipherParam cipherParam = new DefaultCipherParam(
|
||||
param.storePassword());
|
||||
KeyStoreParam keyStoreParam = new DefaultKeyStoreParam(
|
||||
LicenseVerifier.class,
|
||||
param.publicKeyPath(),
|
||||
param.publicAlias(),
|
||||
param.storePassword(),
|
||||
null);
|
||||
return new DefaultLicenseParam(param.subject(), preferences,
|
||||
keyStoreParam, cipherParam);
|
||||
}
|
||||
|
||||
private static LicenseVerifyParam buildVerifyParam(String path) {
|
||||
// NOTE: can't use JsonUtil due to it bind tinkerpop jackson
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try (InputStream stream =
|
||||
LicenseVerifier.class.getResourceAsStream(path)) {
|
||||
return mapper.readValue(stream, LicenseVerifyParam.class);
|
||||
} catch (IOException e) {
|
||||
throw new HugeException("Failed to read json stream to %s",
|
||||
LicenseVerifyParam.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,282 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.license;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.baidu.hugegraph.HugeException;
|
||||
import com.baidu.hugegraph.config.CoreOptions;
|
||||
import com.baidu.hugegraph.config.HugeConfig;
|
||||
import com.baidu.hugegraph.config.ServerOptions;
|
||||
import com.baidu.hugegraph.core.GraphManager;
|
||||
import com.baidu.hugegraph.util.Bytes;
|
||||
import com.baidu.hugegraph.util.E;
|
||||
import com.baidu.hugegraph.util.Log;
|
||||
import com.baidu.hugegraph.util.VersionUtil;
|
||||
import com.baidu.hugegraph.version.CoreVersion;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.sun.management.OperatingSystemMXBean;
|
||||
|
||||
import de.schlichtherle.license.LicenseContent;
|
||||
import de.schlichtherle.license.LicenseContentException;
|
||||
import de.schlichtherle.license.LicenseParam;
|
||||
|
||||
public class LicenseVerifyManager extends CommonLicenseManager {
|
||||
|
||||
private static final Logger LOG = Log.logger(LicenseVerifyManager.class);
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
private static final int NO_LIMIT = -1;
|
||||
|
||||
private HugeConfig config;
|
||||
private GraphManager graphManager;
|
||||
private final MachineInfo machineInfo;
|
||||
|
||||
public LicenseVerifyManager(LicenseParam param) {
|
||||
super(param);
|
||||
this.machineInfo = new MachineInfo();
|
||||
}
|
||||
|
||||
public void config(HugeConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
public HugeConfig config() {
|
||||
E.checkState(this.config != null,
|
||||
"License verify manager has not been installed");
|
||||
return this.config;
|
||||
}
|
||||
|
||||
public void graphManager(GraphManager graphManager) {
|
||||
this.graphManager = graphManager;
|
||||
}
|
||||
|
||||
public GraphManager graphManager() {
|
||||
E.checkState(this.graphManager != null,
|
||||
"License verify manager has not been installed");
|
||||
return this.graphManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized void validate(LicenseContent content) {
|
||||
// Call super validate firstly to verify the common license parameters
|
||||
try {
|
||||
super.validate(content);
|
||||
} catch (LicenseContentException e) {
|
||||
LOG.error("Failed to verify license", e);
|
||||
throw new HugeException("Failed to verify license", e);
|
||||
}
|
||||
|
||||
// Verify the customized license parameters.
|
||||
List<ExtraParam> extraParams;
|
||||
try {
|
||||
TypeReference<List<ExtraParam>> type;
|
||||
type = new TypeReference<List<ExtraParam>>() {};
|
||||
extraParams = MAPPER.readValue((String) content.getExtra(), type);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to read extra params", e);
|
||||
throw new HugeException("Failed to read extra params", e);
|
||||
}
|
||||
|
||||
String serverId = this.getServerId();
|
||||
LOG.debug("server id is {}", serverId);
|
||||
ExtraParam param = this.matchParam(serverId, extraParams);
|
||||
if (param == null) {
|
||||
throw new HugeException("The current server's id is not authorized");
|
||||
}
|
||||
|
||||
this.checkVersion(param);
|
||||
this.checkGraphs(param);
|
||||
this.checkIpAndMac(param);
|
||||
this.checkCpu(param);
|
||||
this.checkRam(param);
|
||||
this.checkThreads(param);
|
||||
this.checkMemory(param);
|
||||
}
|
||||
|
||||
private String getServerId() {
|
||||
return this.config().get(ServerOptions.SERVER_ID);
|
||||
}
|
||||
|
||||
private ExtraParam matchParam(String id, List<ExtraParam> extraParams) {
|
||||
for (ExtraParam param : extraParams) {
|
||||
if (param.id().equals(id)) {
|
||||
return param;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkVersion(ExtraParam param) {
|
||||
String expectVersion = param.version();
|
||||
if (StringUtils.isEmpty(expectVersion)) {
|
||||
return;
|
||||
}
|
||||
VersionUtil.Version acutalVersion = CoreVersion.VERSION;
|
||||
if (acutalVersion.compareTo(VersionUtil.Version.of(expectVersion)) > 0) {
|
||||
throw newLicenseException(
|
||||
"The server's version '%s' exceeded the authorized '%s'",
|
||||
acutalVersion.get(), expectVersion);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGraphs(ExtraParam param) {
|
||||
int expectGraphs = param.graphs();
|
||||
if (expectGraphs == NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualGraphs = this.graphManager().graphs().size();
|
||||
if (actualGraphs > expectGraphs) {
|
||||
throw newLicenseException(
|
||||
"The server's graphs '%s' exceeded the authorized '%s'",
|
||||
actualGraphs, expectGraphs);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIpAndMac(ExtraParam param) {
|
||||
String expectIp = param.ip();
|
||||
boolean matched = false;
|
||||
List<String> actualIps = this.machineInfo.getIpAddress();
|
||||
for (String actualIp : actualIps) {
|
||||
if (StringUtils.isEmpty(expectIp) ||
|
||||
actualIp.equalsIgnoreCase(expectIp)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
throw newLicenseException(
|
||||
"The server's ip '%s' doesn't match the authorized '%s'",
|
||||
actualIps, expectIp);
|
||||
}
|
||||
|
||||
String expectMac = param.mac();
|
||||
if (StringUtils.isEmpty(expectMac)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The mac must be not empty here
|
||||
if (!StringUtils.isEmpty(expectIp)) {
|
||||
String actualMac;
|
||||
try {
|
||||
actualMac = this.machineInfo.getMacByInetAddress(
|
||||
InetAddress.getByName(expectIp));
|
||||
} catch (UnknownHostException e) {
|
||||
throw newLicenseException(
|
||||
"Failed to get mac address for ip '%s'", expectIp);
|
||||
}
|
||||
String expectFormatMac = expectMac.replaceAll(":", "-");
|
||||
String actualFormatMac = actualMac.replaceAll(":", "-");
|
||||
if (!actualFormatMac.equalsIgnoreCase(expectFormatMac)) {
|
||||
throw newLicenseException(
|
||||
"The server's mac '%s' doesn't match the authorized '%s'",
|
||||
actualMac, expectMac);
|
||||
}
|
||||
} else {
|
||||
String expectFormatMac = expectMac.replaceAll(":", "-");
|
||||
List<String> actualMacs = this.machineInfo.getMacAddress();
|
||||
matched = false;
|
||||
for (String actualMac : actualMacs) {
|
||||
String actualFormatMac = actualMac.replaceAll(":", "-");
|
||||
if (actualFormatMac.equalsIgnoreCase(expectFormatMac)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
throw newLicenseException(
|
||||
"The server's macs %s don't match the authorized '%s'",
|
||||
actualMacs, expectMac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkCpu(ExtraParam param) {
|
||||
int expectCpus = param.cpus();
|
||||
if (expectCpus == NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualCpus = CoreOptions.CPUS;
|
||||
if (actualCpus > expectCpus) {
|
||||
throw newLicenseException(
|
||||
"The server's cpus '%s' exceeded the limit '%s'",
|
||||
actualCpus, expectCpus);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkRam(ExtraParam param) {
|
||||
// Unit MB
|
||||
int expectRam = param.ram();
|
||||
if (expectRam == NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
OperatingSystemMXBean mxBean = (OperatingSystemMXBean) ManagementFactory
|
||||
.getOperatingSystemMXBean();
|
||||
long actualRam = mxBean.getTotalPhysicalMemorySize() / Bytes.MB;
|
||||
if (actualRam > expectRam) {
|
||||
throw newLicenseException(
|
||||
"The server's ram(MB) '%s' exceeded the limit(MB) '%s'",
|
||||
actualRam, expectRam);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkThreads(ExtraParam param) {
|
||||
int expectThreads = param.threads();
|
||||
if (expectThreads == NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
int actualThreads = this.config().get(ServerOptions.MAX_WORKER_THREADS);
|
||||
if (actualThreads > expectThreads) {
|
||||
throw newLicenseException(
|
||||
"The server's max threads '%s' exceeded limit '%s'",
|
||||
actualThreads, expectThreads);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkMemory(ExtraParam param) {
|
||||
// Unit MB
|
||||
int expectMemory = param.memory();
|
||||
if (expectMemory == NO_LIMIT) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* NOTE: this max memory will be slightly smaller than XMX,
|
||||
* because only one survivor will be used
|
||||
*/
|
||||
long actualMemory = Runtime.getRuntime().maxMemory() / Bytes.MB;
|
||||
if (actualMemory > expectMemory) {
|
||||
throw newLicenseException(
|
||||
"The server's max heap memory(MB) '%s' exceeded the " +
|
||||
"limit(MB) '%s'", actualMemory, expectMemory);
|
||||
}
|
||||
}
|
||||
|
||||
private HugeException newLicenseException(String message, Object... args) {
|
||||
return new HugeException(message, args);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* Copyright 2017 HugeGraph Authors
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package com.baidu.hugegraph.serializer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.tinkerpop.gremlin.structure.Edge;
|
||||
import org.apache.tinkerpop.gremlin.structure.Vertex;
|
||||
|
||||
import com.baidu.hugegraph.auth.SchemaDefine.AuthElement;
|
||||
import com.baidu.hugegraph.backend.id.Id;
|
||||
import com.baidu.hugegraph.schema.EdgeLabel;
|
||||
import com.baidu.hugegraph.schema.IndexLabel;
|
||||
import com.baidu.hugegraph.schema.PropertyKey;
|
||||
import com.baidu.hugegraph.schema.SchemaElement;
|
||||
import com.baidu.hugegraph.schema.VertexLabel;
|
||||
import com.baidu.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser.CrosspointsPaths;
|
||||
import com.baidu.hugegraph.traversal.algorithm.FusiformSimilarityTraverser.SimilarsMap;
|
||||
import com.baidu.hugegraph.traversal.algorithm.HugeTraverser;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.NodeWithWeight;
|
||||
import com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser.WeightedPaths;
|
||||
|
||||
public interface Serializer {
|
||||
|
||||
public String writeMap(Map<?, ?> map);
|
||||
|
||||
public String writeList(String label, Collection<?> list);
|
||||
|
||||
public String writePropertyKey(PropertyKey propertyKey);
|
||||
|
||||
public String writePropertyKeys(List<PropertyKey> propertyKeys);
|
||||
|
||||
public String writeVertexLabel(VertexLabel vertexLabel);
|
||||
|
||||
public String writeVertexLabels(List<VertexLabel> vertexLabels);
|
||||
|
||||
public String writeEdgeLabel(EdgeLabel edgeLabel);
|
||||
|
||||
public String writeEdgeLabels(List<EdgeLabel> edgeLabels);
|
||||
|
||||
public String writeIndexlabel(IndexLabel indexLabel);
|
||||
|
||||
public String writeIndexlabels(List<IndexLabel> indexLabels);
|
||||
|
||||
public String writeTaskWithSchema(SchemaElement.TaskWithSchema tws);
|
||||
|
||||
public String writeVertex(Vertex v);
|
||||
|
||||
public String writeVertices(Iterator<Vertex> vertices, boolean paging);
|
||||
|
||||
public String writeEdge(Edge e);
|
||||
|
||||
public String writeEdges(Iterator<Edge> edges, boolean paging);
|
||||
|
||||
public String writeIds(List<Id> ids);
|
||||
|
||||
public String writeAuthElement(AuthElement elem);
|
||||
|
||||
public <V extends AuthElement> String writeAuthElements(String label,
|
||||
List<V> users);
|
||||
|
||||
public String writePaths(String name, Collection<HugeTraverser.Path> paths,
|
||||
boolean withCrossPoint, Iterator<Vertex> vertices);
|
||||
|
||||
public default String writePaths(String name,
|
||||
Collection<HugeTraverser.Path> paths,
|
||||
boolean withCrossPoint) {
|
||||
return this.writePaths(name, paths, withCrossPoint, null);
|
||||
}
|
||||
|
||||
public String writeCrosspoints(CrosspointsPaths paths,
|
||||
Iterator<Vertex> iterator, boolean withPath);
|
||||
|
||||
public String writeSimilars(SimilarsMap similars,
|
||||
Iterator<Vertex> vertices);
|
||||
|
||||
public String writeWeightedPath(NodeWithWeight path,
|
||||
Iterator<Vertex> vertices);
|
||||
|
||||
public String writeWeightedPaths(WeightedPaths paths,
|
||||
Iterator<Vertex> vertices);
|
||||
|
||||
public String writeNodesWithPath(String name, List<Id> nodes, long size,
|
||||
Collection<HugeTraverser.Path> paths,
|
||||
Iterator<Vertex> vertices);
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
# hugegraph-commons
|
||||
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
[](https://codecov.io/gh/hugegraph/hugegraph-common)
|
||||
[](https://mvnrepository.com/artifact/org.apache.hugegraph/hugegraph-common)
|
||||
[](https://github.com/apache/incubator-hugegraph-commons/actions/workflows/codeql-analysis.yml)
|
||||
[](https://github.com/apache/incubator-hugegraph-commons/actions/workflows/ci.yml)
|
||||
|
||||
|
||||
hugegraph-commons is a common module for [HugeGraph](https://github.com/apache/hugegraph) and its peripheral components.
|
||||
hugegraph-commons encapsulates locks, configurations, events, iterators, rest and some
|
||||
numeric or collection util classes to simplify the development of HugeGraph and its components.
|
||||
|
||||
## Components
|
||||
|
||||
- Lock: atomic lock, key lock, lock group and lock manger
|
||||
- Config: register and load config option with security check
|
||||
- Event: listening and notification, do something asynchronously
|
||||
- Iterator: some iterators with extra functions, map, filter, extend, etc.
|
||||
- Rest: RESTful client implemented on OkHttp, POST, PUT, GET and DELETE
|
||||
- Util: performance analyzer, version checker, numeric and Collection utils, log and exception utils, etc.
|
||||
- Rpc: rpc component for inner module communication, currently it's based on [Sofa-RPC](https://github.com/sofastack/sofa-rpc)
|
||||
|
||||
You could use import the dependencies in `maven` like this:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.apache.hugegraph</groupId>
|
||||
<artifactId>hugegraph-common</artifactId>
|
||||
<version>1.2.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
## Learn More
|
||||
|
||||
The [doc page](https://hugegraph.apache.org/docs/) contains more information about hugegraph modules.
|
||||
|
||||
And here are links of other repositories:
|
||||
1. [hugegraph-server](https://github.com/apache/hugegraph) (graph's core component - OLTP server)
|
||||
2. [hugegraph-toolchain](https://github.com/apache/hugegraph-toolchain) (include loader/dashboard/tool/client)
|
||||
3. [hugegraph-computer](https://github.com/apache/hugegraph-computer) (graph processing system - OLAP)
|
||||
4. [hugegraph-website/doc](https://github.com/apache/hugegraph-doc) (include doc & website code)
|
||||
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
- Welcome to contribute to HugeGraph, please see [How to Contribute](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/) for more information.
|
||||
- Note: It's recommended to use [GitHub Desktop](https://desktop.github.com/) to greatly simplify the PR and commit process.
|
||||
- Thank you to all the people who already contributed to HugeGraph!
|
||||
|
||||
[](https://github.com/apache/incubator-hugegraph-commons/graphs/contributors)
|
||||
|
||||
## Licence
|
||||
|
||||
Same as HugeGraph, hugegraph-commons are also licensed under [Apache 2.0](./LICENSE) License.
|
||||
|
||||
### Contact Us
|
||||
|
||||
---
|
||||
|
||||
- [GitHub Issues](https://github.com/apache/incubator-hugegraph-commons/issues): Feedback on usage issues and functional requirements (quick response)
|
||||
- Feedback Email: [dev@hugegraph.apache.org](mailto:dev@hugegraph.apache.org) ([subscriber](https://hugegraph.apache.org/docs/contribution-guidelines/subscribe/) only)
|
||||
- WeChat public account: Apache HugeGraph, welcome to scan this QR code to follow us.
|
||||
|
||||
<img src="https://raw.githubusercontent.com/apache/incubator-hugegraph-doc/master/assets/images/wechat.png" alt="QR png" width="350"/>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# hugegraph-common
|
||||
|
||||
[](https://www.apache.org/licenses/LICENSE-2.0.html)
|
||||
[](https://travis-ci.org/hugegraph/hugegraph-common)
|
||||
[](https://codecov.io/gh/hugegraph/hugegraph-common)
|
||||
[](https://mvnrepository.com/artifact/org.apache.hugegraph/hugegraph-common)
|
||||
|
||||
hugegraph-common is a common module for [HugeGraph](https://github.com/hugegraph/hugegraph) and its peripheral components.
|
||||
hugegraph-common encapsulates locks, configurations, events, iterators, rest and some
|
||||
numeric or collection util classes to simplify the development of HugeGraph and
|
||||
its components.
|
||||
|
||||
## Components
|
||||
|
||||
- Lock: atomic lock, key lock, lock group and lock manger
|
||||
- Config: register and load config option with security check
|
||||
- Event: listening and notification, do something asynchronously
|
||||
- Iterator: some iterators with extra functions, map, filter, extend, etc.
|
||||
- Rest: RESTful client implemented on Jersey, POST, PUT, GET and DELETE
|
||||
- Util: Performance analyzer, version checker, numeric and Collection utils, log and exception utils, etc.
|
||||
|
||||
## Licence
|
||||
The same as HugeGraph, hugegraph-common is also licensed under Apache 2.0 License.
|
||||
|
|
@ -20,5 +20,4 @@ export MAVEN_HOME=/home/scmtools/buildkit/maven/apache-maven-3.3.9/
|
|||
export JAVA_HOME=/home/scmtools/buildkit/java/jdk1.8.0_25/
|
||||
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
|
||||
|
||||
mvn clean compile
|
||||
|
||||
mvn clean test -Dtest=UnitTestSuite
|
||||
|
|
@ -0,0 +1,302 @@
|
|||
<?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-commons</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>hugegraph-common</artifactId>
|
||||
<name>${project.artifactId}</name>
|
||||
<url>https://github.com/apache/incubator-hugegraph-commons/tree/master/hugegraph-common</url>
|
||||
<description>
|
||||
hugegraph-common is a common module for HugeGraph and its peripheral components.
|
||||
hugegraph-common encapsulates locks, configurations, events, iterators, rest and some
|
||||
numeric or collection util classes to simplify the development of HugeGraph and its
|
||||
components.
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<!-- Use parent params -->
|
||||
<lombok.version>1.18.8</lombok.version>
|
||||
<okhttp.version>4.10.0</okhttp.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j2.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>${log4j2.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Utility -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>javax.json</artifactId>
|
||||
<version>${javax.json.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>${commons.configuration.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<version>${commons.configuration2.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons.lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<version>${commons.beanutils.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons.io.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<version>${commons.collections.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${commons.codec.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>${jsr305.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.10.8</version>
|
||||
</dependency>
|
||||
|
||||
<!-- javassist -->
|
||||
<dependency>
|
||||
<groupId>org.javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>${javassist.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- jackson -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-jaxb-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-base</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.jaxrs</groupId>
|
||||
<artifactId>jackson-jaxrs-json-provider</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>${sun.xml.version}</version>
|
||||
<scope>runtime</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>logging-interceptor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp-bom</artifactId>
|
||||
<version>${okhttp.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>pre-unit-test</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.parent.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>apache-release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class AtomicLock {
|
||||
|
||||
private static final Logger LOG = Log.logger(LockManager.class);
|
||||
|
||||
private String name;
|
||||
private AtomicReference<Thread> sign;
|
||||
|
||||
public AtomicLock(String name) {
|
||||
this.name = name;
|
||||
this.sign = new AtomicReference<>();
|
||||
}
|
||||
|
||||
public boolean tryLock() {
|
||||
Thread current = Thread.currentThread();
|
||||
return this.sign.compareAndSet(null, current);
|
||||
}
|
||||
|
||||
public void unlock() {
|
||||
if (this.sign.get() == null) {
|
||||
return;
|
||||
}
|
||||
Thread current = Thread.currentThread();
|
||||
if (!this.sign.compareAndSet(current, null)) {
|
||||
throw new RuntimeException(String.format(
|
||||
"Thread '%s' trying to unlock '%s' " +
|
||||
"which is held by other threads now.",
|
||||
current.getName(), this.name));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean lock(int retries) {
|
||||
// The interval between retries is exponential growth, most wait
|
||||
// interval is 2^(retries-1)s. If retries=0, don't retry.
|
||||
if (retries < 0 || retries > 10) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Locking retry times should be in [0, 10], but got %d",
|
||||
retries));
|
||||
}
|
||||
|
||||
boolean isLocked = false;
|
||||
try {
|
||||
for (int i = 0; !(isLocked = this.tryLock()) && i < retries; i++) {
|
||||
Thread.sleep(1000 * (1L << i));
|
||||
}
|
||||
} catch (InterruptedException ignored) {
|
||||
LOG.info("Thread sleep is interrupted.");
|
||||
}
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void name(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
|
||||
public class BarrierEvent {
|
||||
|
||||
private final Lock lock = new ReentrantLock();
|
||||
private final Condition cond = lock.newCondition();
|
||||
private volatile boolean signaled = false;
|
||||
|
||||
/**
|
||||
* Wait forever until the signal is received.
|
||||
* @throws InterruptedException if interrupted.
|
||||
*/
|
||||
public void await() throws InterruptedException {
|
||||
this.lock.lock();
|
||||
try {
|
||||
while (!this.signaled) {
|
||||
this.cond.await();
|
||||
}
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait specified time in milliseconds.
|
||||
* @param timeout: the time in millisecond to wait.
|
||||
* @return true if signal is received, false if time out.
|
||||
* @throws InterruptedException if interrupted.
|
||||
*/
|
||||
public boolean await(long timeout) throws InterruptedException {
|
||||
E.checkArgument(timeout >= 0L,
|
||||
"The time must be >= 0, but got '%d'.",
|
||||
timeout);
|
||||
long deadline = System.currentTimeMillis() + timeout;
|
||||
this.lock.lock();
|
||||
try {
|
||||
while (!this.signaled) {
|
||||
timeout = deadline - System.currentTimeMillis();
|
||||
if (timeout > 0) {
|
||||
this.cond.await(timeout, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
if (System.currentTimeMillis() >= deadline) {
|
||||
return this.signaled;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.lock.lock();
|
||||
try {
|
||||
this.signaled = false;
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void signal() {
|
||||
this.lock.lock();
|
||||
try {
|
||||
this.signaled = true;
|
||||
this.cond.signal();
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void signalAll() {
|
||||
this.lock.lock();
|
||||
try {
|
||||
this.signaled = true;
|
||||
this.cond.signalAll();
|
||||
} finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.Striped;
|
||||
|
||||
/**
|
||||
* KeyLock provide an interface of segment lock
|
||||
*/
|
||||
public class KeyLock {
|
||||
|
||||
private Striped<Lock> locks;
|
||||
|
||||
public KeyLock() {
|
||||
// The default size is availableProcessors() * 4
|
||||
this(Runtime.getRuntime().availableProcessors() << 2);
|
||||
}
|
||||
|
||||
public KeyLock(int size) {
|
||||
this.locks = Striped.lock(size);
|
||||
}
|
||||
|
||||
private int indexOf(Lock lock) {
|
||||
for (int i = 0; i < this.locks.size(); i++) {
|
||||
if (this.locks.getAt(i) == lock) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock an object
|
||||
* @param key The object to lock
|
||||
* @return The lock(locked) of passed key
|
||||
*/
|
||||
public final Lock lock(Object key) {
|
||||
E.checkArgument(key != null, "Lock key can't be null");
|
||||
Lock lock = this.locks.get(key);
|
||||
lock.lock();
|
||||
return lock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock an object
|
||||
* @param key The object to unlock
|
||||
*/
|
||||
public final void unlock(Object key) {
|
||||
E.checkArgument(key != null, "Unlock key can't be null");
|
||||
this.locks.get(key).unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock a list of object with sorted order
|
||||
* @param keys The objects to lock
|
||||
* @return The locks(locked) of keys
|
||||
*/
|
||||
public final List<Lock> lockAll(Object... keys) {
|
||||
E.checkArgument(keys != null && keys.length > 0,
|
||||
"Lock keys can't be null or empty");
|
||||
List<Lock> locks = new ArrayList<>(keys.length);
|
||||
for (Object key : keys) {
|
||||
E.checkArgument(key != null, "Lock key can't be null");
|
||||
Lock lock = this.locks.get(key);
|
||||
locks.add(lock);
|
||||
}
|
||||
locks.sort((a, b) -> {
|
||||
int diff = a.hashCode() - b.hashCode();
|
||||
if (diff == 0 && a != b) {
|
||||
diff = this.indexOf(a) - this.indexOf(b);
|
||||
assert diff != 0;
|
||||
}
|
||||
return diff;
|
||||
});
|
||||
for (Lock lock : locks) {
|
||||
lock.lock();
|
||||
}
|
||||
return Collections.unmodifiableList(locks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock two objects with sorted order
|
||||
* NOTE: This is to optimize the performance of lockAll(keys)
|
||||
* @param key1 The first object
|
||||
* @param key2 The second object
|
||||
* @return locks for the two objects
|
||||
*/
|
||||
public List<Lock> lockAll(Object key1, Object key2) {
|
||||
E.checkArgument(key1 != null, "Lock key can't be null");
|
||||
E.checkArgument(key2 != null, "Lock key can't be null");
|
||||
Lock lock1 = this.locks.get(key1);
|
||||
Lock lock2 = this.locks.get(key2);
|
||||
|
||||
int diff = lock1.hashCode() - lock2.hashCode();
|
||||
if (diff == 0 && lock1 != lock2) {
|
||||
diff = this.indexOf(lock1) - this.indexOf(lock2);
|
||||
assert diff != 0;
|
||||
}
|
||||
|
||||
List<Lock> locks = diff > 0 ?
|
||||
ImmutableList.of(lock2, lock1) :
|
||||
ImmutableList.of(lock1, lock2);
|
||||
|
||||
for (Lock lock : locks) {
|
||||
lock.lock();
|
||||
}
|
||||
|
||||
return locks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock a list of object
|
||||
* @param locks The locks to unlock
|
||||
*/
|
||||
public final void unlockAll(List<Lock> locks) {
|
||||
E.checkArgument(locks != null, "Unlock locks can't be null");
|
||||
for (int i = locks.size(); i > 0; i--) {
|
||||
assert this.indexOf(locks.get(i - 1)) != -1;
|
||||
locks.get(i - 1).unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class LockGroup {
|
||||
|
||||
private final String name;
|
||||
private final Map<String, Object> locksMap;
|
||||
|
||||
public LockGroup(String lockGroup) {
|
||||
this.name = lockGroup;
|
||||
this.locksMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public Lock lock(String lockName) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new ReentrantLock());
|
||||
}
|
||||
return (Lock) this.locksMap.get(lockName);
|
||||
}
|
||||
|
||||
public AtomicLock atomicLock(String lockName) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new AtomicLock(lockName));
|
||||
}
|
||||
return (AtomicLock) this.locksMap.get(lockName);
|
||||
}
|
||||
|
||||
public ReadWriteLock readWriteLock(String lockName) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new ReentrantReadWriteLock());
|
||||
}
|
||||
return (ReadWriteLock) this.locksMap.get(lockName);
|
||||
}
|
||||
|
||||
public KeyLock keyLock(String lockName) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new KeyLock());
|
||||
}
|
||||
return (KeyLock) this.locksMap.get(lockName);
|
||||
}
|
||||
|
||||
public KeyLock keyLock(String lockName, int size) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new KeyLock(size));
|
||||
}
|
||||
return (KeyLock) this.locksMap.get(lockName);
|
||||
}
|
||||
|
||||
public <K extends Comparable<K>> RowLock<K> rowLock(String lockName) {
|
||||
if (!this.locksMap.containsKey(lockName)) {
|
||||
this.locksMap.putIfAbsent(lockName, new RowLock<>());
|
||||
}
|
||||
Object value = this.locksMap.get(lockName);
|
||||
@SuppressWarnings("unchecked")
|
||||
RowLock<K> lock = (RowLock<K>) value;
|
||||
return lock;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class LockManager {
|
||||
|
||||
private static final LockManager INSTANCE = new LockManager();
|
||||
|
||||
public static LockManager instance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Map<String, LockGroup> lockGroupMap;
|
||||
|
||||
private LockManager() {
|
||||
this.lockGroupMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public boolean exists(String group) {
|
||||
return this.lockGroupMap.containsKey(group);
|
||||
}
|
||||
|
||||
public LockGroup create(String group) {
|
||||
if (exists(group)) {
|
||||
throw new RuntimeException(String.format(
|
||||
"LockGroup '%s' already exists", group));
|
||||
}
|
||||
LockGroup lockGroup = new LockGroup(group);
|
||||
LockGroup previous = this.lockGroupMap.putIfAbsent(group, lockGroup);
|
||||
if (previous != null) {
|
||||
return previous;
|
||||
}
|
||||
return lockGroup;
|
||||
}
|
||||
|
||||
public LockGroup get(String group) {
|
||||
LockGroup lockGroup = this.lockGroupMap.get(group);
|
||||
if (lockGroup == null) {
|
||||
throw new RuntimeException(String.format(
|
||||
"LockGroup '%s' does not exists", group));
|
||||
}
|
||||
return lockGroup;
|
||||
}
|
||||
|
||||
public void destroy(String group) {
|
||||
if (this.exists(group)) {
|
||||
this.lockGroupMap.remove(group);
|
||||
} else {
|
||||
throw new RuntimeException(String.format(
|
||||
"LockGroup '%s' does not exists", group));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.apache.hugegraph.util.Log;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class PausableScheduledThreadPool extends ScheduledThreadPoolExecutor {
|
||||
|
||||
private static final Logger LOG = Log.logger(PausableScheduledThreadPool.class);
|
||||
|
||||
private volatile boolean paused = false;
|
||||
|
||||
public PausableScheduledThreadPool(int corePoolSize,
|
||||
ThreadFactory factory) {
|
||||
super(corePoolSize, factory);
|
||||
}
|
||||
|
||||
public synchronized void pauseSchedule() {
|
||||
this.paused = true;
|
||||
LOG.info("PausableScheduledThreadPool was paused");
|
||||
}
|
||||
|
||||
public synchronized void resumeSchedule() {
|
||||
this.paused = false;
|
||||
this.notifyAll();
|
||||
LOG.info("PausableScheduledThreadPool was resumed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void beforeExecute(Thread t, Runnable r) {
|
||||
synchronized (this) {
|
||||
while (this.paused) {
|
||||
try {
|
||||
this.wait();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.warn("PausableScheduledThreadPool was interrupted");
|
||||
}
|
||||
}
|
||||
}
|
||||
super.beforeExecute(t, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (this.paused) {
|
||||
this.resumeSchedule();
|
||||
}
|
||||
super.shutdown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Runnable> shutdownNow() {
|
||||
if (this.paused) {
|
||||
this.resumeSchedule();
|
||||
}
|
||||
return super.shutdownNow();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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.concurrent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
|
||||
public class RowLock<K extends Comparable<K>> {
|
||||
|
||||
private final Map<K, Lock> locks = new ConcurrentHashMap<>();
|
||||
private final ThreadLocal<Map<K, LocalLock>> localLocks =
|
||||
ThreadLocal.withInitial(HashMap::new);
|
||||
|
||||
public void lock(K key) {
|
||||
E.checkArgument(key != null, "Lock key can't be null");
|
||||
LocalLock localLock = this.localLocks.get().get(key);
|
||||
if (localLock != null) {
|
||||
localLock.lockCount++;
|
||||
} else {
|
||||
Lock current = new ReentrantLock();
|
||||
Lock previous = this.locks.putIfAbsent(key, current);
|
||||
if (previous != null) {
|
||||
current = previous;
|
||||
}
|
||||
current.lock();
|
||||
this.localLocks.get().put(key, new LocalLock(current));
|
||||
}
|
||||
}
|
||||
|
||||
public void unlock(K key) {
|
||||
E.checkArgument(key != null, "Unlock key can't be null");
|
||||
LocalLock localLock = this.localLocks.get().get(key);
|
||||
if (localLock == null) {
|
||||
return;
|
||||
}
|
||||
if (--localLock.lockCount == 0) {
|
||||
this.locks.remove(key, localLock.current);
|
||||
this.localLocks.get().remove(key);
|
||||
localLock.current.unlock();
|
||||
}
|
||||
E.checkState(localLock.lockCount >= 0,
|
||||
"The lock count must be >= 0, but got %s",
|
||||
localLock.lockCount);
|
||||
}
|
||||
|
||||
public void lockAll(Set<K> keys) {
|
||||
E.checkArgument(keys != null && keys.size() > 0,
|
||||
"Lock keys can't be null or empty");
|
||||
List<K> list = new ArrayList<>(keys);
|
||||
Collections.sort(list);
|
||||
for (K key : list) {
|
||||
this.lock(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void unlockAll(Set<K> keys) {
|
||||
E.checkArgument(keys != null && keys.size() > 0,
|
||||
"Unlock keys can't be null or empty");
|
||||
for (K key : keys) {
|
||||
this.unlock(key);
|
||||
}
|
||||
}
|
||||
|
||||
private static class LocalLock {
|
||||
|
||||
private final Lock current;
|
||||
private int lockCount;
|
||||
|
||||
private LocalLock(Lock current) {
|
||||
this.current = current;
|
||||
this.lockCount = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with this
|
||||
* work for additional information regarding copyright ownership. The ASF
|
||||
* licenses this file to You under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hugegraph.config;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.hugegraph.util.E;
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
public class ConfigConvOption<T, R> extends TypedOption<T, R> {
|
||||
|
||||
private final Function<T, R> converter;
|
||||
|
||||
public ConfigConvOption(String name, String desc, Predicate<T> pred,
|
||||
Function<T, R> convert, T value) {
|
||||
this(name, false, desc, pred, convert, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ConfigConvOption(String name, boolean required, String desc,
|
||||
Predicate<T> pred, Function<T, R> convert,
|
||||
T value) {
|
||||
super(name, required, desc, pred, (Class<T>) value.getClass(), value);
|
||||
E.checkNotNull(convert, "convert");
|
||||
this.converter = convert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R convert(T value) {
|
||||
return this.converter.apply(value);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue