mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-11-25 21:57:05 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98827d68d9 | ||
|
|
ee2fa14dbe | ||
|
|
2bd6fd3bbe | ||
|
|
71056dae07 | ||
|
|
0ea5c087ce | ||
|
|
95c0de285d | ||
|
|
500bcab953 | ||
|
|
590f02179d | ||
|
|
0a406f652e | ||
|
|
68043cfcac | ||
|
|
0fc9ffc603 | ||
|
|
7cfa616843 | ||
|
|
57c770a7b4 | ||
|
|
442e092995 | ||
|
|
b2a72630da | ||
|
|
824e96ffcc | ||
|
|
3e362451d2 | ||
|
|
0d5355c614 | ||
|
|
7d24980840 | ||
|
|
56d8e5b540 | ||
|
|
b3f22a53b0 | ||
|
|
a9990a1dc6 | ||
|
|
a2962604ad | ||
|
|
559dfacdac | ||
|
|
e6333da65a | ||
|
|
7094492428 | ||
|
|
c6a0704019 | ||
|
|
ed3b0f81c6 | ||
|
|
c4f0fd6e1b | ||
|
|
ab966410d2 | ||
|
|
a4dfa00030 | ||
|
|
2251a8e472 | ||
|
|
5a16f17e47 | ||
|
|
e06676f007 | ||
|
|
c32b6f4d9d | ||
|
|
0fbc27b640 | ||
|
|
d7cc0498e0 | ||
|
|
827930e249 | ||
|
|
0880aff224 | ||
|
|
4300ca8142 | ||
|
|
dbba8cb57e | ||
|
|
aa30604cec | ||
|
|
1eec5c8d5d | ||
|
|
fc7baef5bb | ||
|
|
745ee8d8f3 | ||
|
|
a29abd8600 | ||
|
|
8708e7a64d | ||
|
|
c6bd244ebd | ||
|
|
b73ef6aa95 | ||
|
|
dc26012a3b | ||
|
|
81024761cd | ||
|
|
86cdb2a3e5 | ||
|
|
73f934d5de | ||
|
|
5b636b3242 | ||
|
|
15956d8a8e | ||
|
|
de3bdd0651 | ||
|
|
1dd3a6ac36 | ||
|
|
eee3f00559 | ||
|
|
cc62a2c9ac | ||
|
|
6856b0d57e | ||
|
|
4f676aa7d3 | ||
|
|
be2bf1f102 | ||
|
|
e7e3d8df7c | ||
|
|
de277418bf | ||
|
|
2b6fdebd5e | ||
|
|
5779265992 | ||
|
|
63de3ea518 | ||
|
|
e92780b91e | ||
|
|
75887ba2a2 | ||
|
|
549422085b | ||
|
|
5fb8530358 | ||
|
|
baced7b94f | ||
|
|
6cd6ff6962 | ||
|
|
2121eba4cf | ||
|
|
eb0b8cd9d8 | ||
|
|
0dafcf1f5a | ||
|
|
06ee199ef3 | ||
|
|
b132cb893f | ||
|
|
0ae4d7bfdf | ||
|
|
8054ef2310 | ||
|
|
c709059b69 | ||
|
|
d29b787220 | ||
|
|
5448781dfc | ||
|
|
0ecff9521d | ||
|
|
031aa70da6 | ||
|
|
c923170d7c | ||
|
|
85e43b678f | ||
|
|
7d5db73d98 | ||
|
|
a9662d44ac | ||
|
|
e0fcab47c0 | ||
|
|
e1423a83dd | ||
|
|
448475e100 | ||
|
|
9b10d1ac33 | ||
|
|
8750cac090 | ||
|
|
ef908e166b | ||
|
|
4609644658 | ||
|
|
df8d976bb0 | ||
|
|
7192a378cc | ||
|
|
004aa9ca5d | ||
|
|
f7b21973ac | ||
|
|
de86945aeb | ||
|
|
306062b4e7 | ||
|
|
05acc33294 | ||
|
|
9708df47d1 | ||
|
|
10f9f1cc26 | ||
|
|
8826601be1 | ||
|
|
be95f68ca7 | ||
|
|
b9ccaabdcc | ||
|
|
20b967e38c | ||
|
|
d2a4ffdd60 | ||
|
|
46303c36bf | ||
|
|
eb32af25d4 | ||
|
|
7ecbb4b3c9 | ||
|
|
9081ff8e65 | ||
|
|
8a7f5eba99 | ||
|
|
9cc6575ab5 | ||
|
|
c057dd1f64 | ||
|
|
19098f2c2d | ||
|
|
6135cbaa02 | ||
|
|
0cdf172694 | ||
|
|
09a7cb8353 | ||
|
|
0ab72a0904 | ||
|
|
737d6ed650 | ||
|
|
02dc51b1ed | ||
|
|
abff1f67a6 | ||
|
|
202964a09b | ||
|
|
e379fc3658 | ||
|
|
11697ca9fd | ||
|
|
08cbc714f0 | ||
|
|
23a0551c26 | ||
|
|
6560ac6466 | ||
|
|
cf0cd12943 | ||
|
|
4c231054fb | ||
|
|
ba64390555 | ||
|
|
0b68b68ec4 | ||
|
|
47047516d6 | ||
|
|
6f8b426f4f | ||
|
|
22a9ea0512 | ||
|
|
c6d9974fe7 | ||
|
|
b917be7955 | ||
|
|
8a55b7053f | ||
|
|
918546bbdb | ||
|
|
6364d59f92 | ||
|
|
fab01f9d8d | ||
|
|
2a10904d03 | ||
|
|
884db215a1 | ||
|
|
c321378976 | ||
|
|
1ad1b8c4f6 | ||
|
|
326fcdd86b | ||
|
|
2dcc178d0a | ||
|
|
5db46bb0dd | ||
|
|
9ff0490dab | ||
|
|
744c5594da | ||
|
|
3e925faddd | ||
|
|
73d924f1ee | ||
|
|
a67eb1afa1 | ||
|
|
7cc07655d4 | ||
|
|
53c3aad875 | ||
|
|
6da87720eb | ||
|
|
24bf142596 | ||
|
|
432c6f8db3 | ||
|
|
06c15ab35c | ||
|
|
72f6b77dea | ||
|
|
8766ca1b95 | ||
|
|
19026ae55d | ||
|
|
44921220b0 | ||
|
|
283d584141 | ||
|
|
c693c98c15 | ||
|
|
e71463a9eb | ||
|
|
e219c57849 | ||
|
|
f375b93aef | ||
|
|
596d476e3d | ||
|
|
63b0fb54f7 | ||
|
|
27ba0a2be3 | ||
|
|
147d4d23b6 | ||
|
|
91fd311f7a | ||
|
|
bc11d91892 | ||
|
|
10a4a628e9 | ||
|
|
186e42345e | ||
|
|
3239425c19 | ||
|
|
37e282e9a7 | ||
|
|
68c8d496d8 | ||
|
|
c2fb1d2490 | ||
|
|
46cb692d83 | ||
|
|
2fb1fce8a0 | ||
|
|
da36abf033 | ||
|
|
326a4bbaf5 | ||
|
|
16fae84414 | ||
|
|
b7b1eb51b1 | ||
|
|
79690b9cd8 | ||
|
|
9104cfa744 | ||
|
|
e9d40b80b2 | ||
|
|
6c4fb243a7 | ||
|
|
e50eae9ad8 | ||
|
|
e0002f8dd7 | ||
|
|
19772d70d7 | ||
|
|
5b92dfe302 | ||
|
|
fb124f2d4a | ||
|
|
8eaa067da5 | ||
|
|
1b17f71939 | ||
|
|
ef9c32ea0d | ||
|
|
12eafd634d | ||
|
|
0cea84e7ab | ||
|
|
fc689319ae | ||
|
|
71624858af | ||
|
|
29c9fa2ef2 | ||
|
|
2579edbc60 | ||
|
|
e0c8507d93 | ||
|
|
b81359823f | ||
|
|
11716fbf6f | ||
|
|
d75bc62196 | ||
|
|
575d7952a1 | ||
|
|
5179e559f7 | ||
|
|
de044e466e | ||
|
|
e73d6c9526 | ||
|
|
a9a7005687 | ||
|
|
720b1d9b88 | ||
|
|
2bc05cfbc8 | ||
|
|
4ff2ceee33 | ||
|
|
f5ee19e0db | ||
|
|
b5917bf846 | ||
|
|
9884dfc369 | ||
|
|
bd103c143a | ||
|
|
05b5f12f2e | ||
|
|
81cf8d04df | ||
|
|
d90e7ee3cc | ||
|
|
3bf0116de1 | ||
|
|
c31b254248 | ||
|
|
f64252023e | ||
|
|
ad652ffb97 | ||
|
|
20442dc1bc | ||
|
|
59c6422777 | ||
|
|
6e8c2bfdd0 | ||
|
|
3ac77dcc7c | ||
|
|
6c92fa349d | ||
|
|
86528bf973 | ||
|
|
e932262b07 | ||
|
|
b3aa2fab9a | ||
|
|
7fc98da709 | ||
|
|
410b818aa7 | ||
|
|
69f0da5d73 | ||
|
|
da6b9e673b | ||
|
|
b843358d65 | ||
|
|
a47e8f4c06 | ||
|
|
bff99ecc75 | ||
|
|
b7c224cf61 | ||
|
|
459de70a77 | ||
|
|
c0ab458671 | ||
|
|
898db14729 | ||
|
|
09bab17aff | ||
|
|
9d80a3428c | ||
|
|
37f165d743 | ||
|
|
68d39c86f1 | ||
|
|
ee1fc6558a | ||
|
|
06e6341097 | ||
|
|
d598c47136 | ||
|
|
5039aff310 | ||
|
|
ace0ea3d28 | ||
|
|
53207ae0e7 | ||
|
|
b03b51aea4 | ||
|
|
6f501a9f0e | ||
|
|
d59446cbb7 | ||
|
|
dc2e13092d | ||
|
|
e714c28a02 | ||
|
|
c95d3d9dff | ||
|
|
93bcf56514 | ||
|
|
1069b325dd | ||
|
|
0542911e29 | ||
|
|
58fa506491 | ||
|
|
28d4e1a51b | ||
|
|
c127da1219 | ||
|
|
aac4cb1f0c | ||
|
|
9b4f7fed14 | ||
|
|
3f7d1d1bf1 | ||
|
|
b18f21cce1 | ||
|
|
f022aff289 | ||
|
|
cad7fd8775 | ||
|
|
352ff4ba34 | ||
|
|
0209a67ea4 | ||
|
|
4e31ca9507 | ||
|
|
1e07a0b791 | ||
|
|
648044f067 | ||
|
|
b57d435abe | ||
|
|
253323ce6d | ||
|
|
bbd0afd37e | ||
|
|
7704469d29 | ||
|
|
723ae11db4 | ||
|
|
d5fcb0f474 | ||
|
|
ea13e0523b | ||
|
|
d155f907c2 | ||
|
|
9b0e8ef026 | ||
|
|
8a52379ecb | ||
|
|
70af0ec24c | ||
|
|
cff8bb6554 | ||
|
|
8e2f3b510e | ||
|
|
912ef2bc53 | ||
|
|
9449100757 | ||
|
|
d3d3609a03 | ||
|
|
6fc272f913 | ||
|
|
00a75d7c99 | ||
|
|
e1a3ffcdbf | ||
|
|
4a15e9c830 | ||
|
|
76d9b3bf42 | ||
|
|
97f8b67a64 | ||
|
|
6b995d2985 | ||
|
|
6da8eef54f | ||
|
|
5d01dd28a6 | ||
|
|
8d34eb0050 | ||
|
|
6e1f936efd | ||
|
|
b2ee5873fb | ||
|
|
b067853162 | ||
|
|
e1a8e3f900 | ||
|
|
8676db0f6a | ||
|
|
bd8b9b0c2e | ||
|
|
78859e35fc | ||
|
|
9e7a2772b1 | ||
|
|
4882972478 | ||
|
|
d116432775 | ||
|
|
eed492b73b | ||
|
|
ec08a1670b | ||
|
|
62d3d3aea0 | ||
|
|
e91b9c85a2 | ||
|
|
a8624c2e4f | ||
|
|
da4edf3651 | ||
|
|
c543762e23 | ||
|
|
36492c47ec | ||
|
|
8f8e9ddbde | ||
|
|
875ee5c0d4 | ||
|
|
e4f2d9eb4a | ||
|
|
4fc673341f | ||
|
|
6b591b02af | ||
|
|
b597406699 | ||
|
|
702b1cb876 | ||
|
|
b3dd0ba446 | ||
|
|
8c8b8e2835 | ||
|
|
d522df0ecd | ||
|
|
666859f7cd | ||
|
|
bc47835997 | ||
|
|
8d65ad1444 | ||
|
|
692f0614d1 | ||
|
|
707936f482 | ||
|
|
2c20ef72ae | ||
|
|
d77e3c96e9 | ||
|
|
95ffed87c0 | ||
|
|
6fbfe73683 | ||
|
|
dc31b19469 | ||
|
|
f781cce500 | ||
|
|
8c82fb7e5f | ||
|
|
3e0a79ef05 | ||
|
|
9ab98fa912 | ||
|
|
f1e879fe7a | ||
|
|
a1c01d716b | ||
|
|
a34bad2cee | ||
|
|
ed170d8fe6 | ||
|
|
86329bbf2b | ||
|
|
68463e92c1 | ||
|
|
79ab10e300 | ||
|
|
55cb68c09c | ||
|
|
436ab7d811 | ||
|
|
b9887504e8 | ||
|
|
f46eae284e | ||
|
|
75aca5e13d | ||
|
|
e6552b5e1e | ||
|
|
474e2b6ac3 | ||
|
|
c49e2bb9a3 | ||
|
|
62ce85610e | ||
|
|
9ad2dcca2b | ||
|
|
e43d86c796 | ||
|
|
31fc7bb2e1 | ||
|
|
a37535cd9f | ||
|
|
d9545d4d6b | ||
|
|
41be7a4c8f | ||
|
|
4929d0634e | ||
|
|
35f6518c36 | ||
|
|
22049dc2e6 | ||
|
|
402aef8f30 | ||
|
|
8516517c48 | ||
|
|
b1ac324c44 | ||
|
|
ed7816681a | ||
|
|
370a98cf6b | ||
|
|
aee3fd08b9 | ||
|
|
76e24a5660 | ||
|
|
043b063136 | ||
|
|
48c578410f | ||
|
|
dbf5327b98 | ||
|
|
7726965a47 | ||
|
|
0790c6d605 | ||
|
|
1012df7bb5 | ||
|
|
4856bce0ee | ||
|
|
d2d3aec3e1 | ||
|
|
2e9099369e | ||
|
|
2e7c361a0d | ||
|
|
1295347958 | ||
|
|
98e9de6e11 | ||
|
|
324e44d4b3 | ||
|
|
cbca14edc5 | ||
|
|
5e239afdfc | ||
|
|
59e91e9c7e | ||
|
|
c7d7b1a0f6 | ||
|
|
b80a2b3cc9 | ||
|
|
eecd6b5d35 | ||
|
|
0157798ebf | ||
|
|
9b21ec27e4 | ||
|
|
0db149fb5f | ||
|
|
f7a0ccb595 | ||
|
|
f0e325b6fc | ||
|
|
d506080c36 | ||
|
|
8f9f29b773 | ||
|
|
1892677b22 | ||
|
|
85570f27a0 | ||
|
|
a99f63cb4d | ||
|
|
b61d33f251 | ||
|
|
0adbb56cc1 | ||
|
|
3e52329cee | ||
|
|
4a1fe4b8e2 | ||
|
|
bd11f0b3e4 | ||
|
|
8573ac82c6 | ||
|
|
d7bf2390e2 | ||
|
|
ec5b9f1e91 | ||
|
|
658fc2e5b6 | ||
|
|
91e4eca1e9 | ||
|
|
082500151a | ||
|
|
9cdbfc1a49 | ||
|
|
63373a9f9f | ||
|
|
b9c1f3e9de | ||
|
|
289e62a305 | ||
|
|
9a3b564508 | ||
|
|
62563a895a | ||
|
|
c2faab23b6 | ||
|
|
d013d09a9b | ||
|
|
f498c71199 | ||
|
|
fcbc520373 | ||
|
|
56094541c8 | ||
|
|
9cac9c4001 | ||
|
|
7af7380a7e | ||
|
|
dc4d2145ff | ||
|
|
29abe980df | ||
|
|
41d508edfd | ||
|
|
5b40a2690a | ||
|
|
2c21eb1971 | ||
|
|
2cbd1cf121 | ||
|
|
23e9ede068 | ||
|
|
852e5f7cbc | ||
|
|
6544e60bea | ||
|
|
cb427d48fa | ||
|
|
e4e0234998 | ||
|
|
f71f7fcf99 | ||
|
|
5eee4983f3 | ||
|
|
feca07bf96 | ||
|
|
e861a6a3ab | ||
|
|
be54eeb364 | ||
|
|
4d21de63ee | ||
|
|
913a16268d | ||
|
|
c9202c4b3d | ||
|
|
8a0710cb73 | ||
|
|
854007bc98 | ||
|
|
10f9081526 | ||
|
|
684a875876 | ||
|
|
2d3a904a82 | ||
|
|
a595916342 | ||
|
|
103fafe00b | ||
|
|
b5add9b8f9 | ||
|
|
ada996fe55 | ||
|
|
8aaae78dfc | ||
|
|
200fe5c83e | ||
|
|
5d6753fb98 | ||
|
|
1af95c5b76 | ||
|
|
f8fea19669 | ||
|
|
b0c7de186d | ||
|
|
1a7afe7e6a | ||
|
|
f2723c1bc8 | ||
|
|
ba984a4e29 | ||
|
|
446e476a11 | ||
|
|
ea26a98753 | ||
|
|
d15682b4a1 | ||
|
|
c0ee78d2fa | ||
|
|
cd9b89ba55 | ||
|
|
e2c741f76f | ||
|
|
2a0925590c | ||
|
|
3984c3962f | ||
|
|
baa6bdf4d4 | ||
|
|
3eda8d6dfc | ||
|
|
ab201c2798 | ||
|
|
75de7002ff | ||
|
|
9d4bdfcfdf | ||
|
|
1b8094ef75 | ||
|
|
12a8f5294d | ||
|
|
e60b2117c3 | ||
|
|
89a62e8007 | ||
|
|
19537c9d21 | ||
|
|
eaf9fdde99 | ||
|
|
cc5fe6f5ee | ||
|
|
575250438d | ||
|
|
b4f03a0d97 | ||
|
|
2920b396e5 | ||
|
|
dd96e5edb7 | ||
|
|
401ccf1509 | ||
|
|
c9ab8d05fa | ||
|
|
07ec6c89a0 | ||
|
|
5b0676049a | ||
|
|
660d7c0edd | ||
|
|
0d9b858cfb | ||
|
|
9be4e97625 | ||
|
|
719dc43af1 | ||
|
|
72f9d7f047 | ||
|
|
6a5b38c0d4 | ||
|
|
8a1eeadd39 | ||
|
|
56a0e1c54f | ||
|
|
31fb2de957 | ||
|
|
138e5918fb | ||
|
|
2bed15f1dc | ||
|
|
e73f0d4e81 | ||
|
|
3f7fbfddca | ||
|
|
229eeb8301 | ||
|
|
1d6c443b17 | ||
|
|
b183ae54b5 | ||
|
|
47b3f932e4 | ||
|
|
daf0a449f7 | ||
|
|
7f69acd1f2 | ||
|
|
387ab6796f | ||
|
|
4fc0bd1a81 | ||
|
|
5e13bc878c | ||
|
|
d1b816212f | ||
|
|
64a621bcc8 | ||
|
|
c18ea21f7a | ||
|
|
18b98fdb72 | ||
|
|
44b3f2efc8 | ||
|
|
d80538a187 | ||
|
|
1a09bc43d1 | ||
|
|
2b643f477d | ||
|
|
05034aade5 | ||
|
|
432fe3d926 | ||
|
|
d8af6f62df | ||
|
|
4f1b3c08a0 | ||
|
|
5718d33148 | ||
|
|
07f32feed0 | ||
|
|
0af6252b2d | ||
|
|
ac494ff5e8 | ||
|
|
c9f8f25ba5 | ||
|
|
30dc365cbd | ||
|
|
8acd714600 | ||
|
|
d741ed66db | ||
|
|
bba90ff3c8 | ||
|
|
71b0e256c7 | ||
|
|
ca5d8e0d45 | ||
|
|
450cf07505 | ||
|
|
1384ff9a2f | ||
|
|
83080b5e03 | ||
|
|
0ddcc2a8f5 | ||
|
|
46f65a84a6 | ||
|
|
f815fce81b | ||
|
|
44b4ebf0ff | ||
|
|
b8f32bcab9 | ||
|
|
f76a2b2c8a | ||
|
|
798280e980 | ||
|
|
a93d27d1e8 | ||
|
|
1d56ea24ef | ||
|
|
7e1aad0b54 | ||
|
|
68e878adb5 | ||
|
|
23baa3c36c | ||
|
|
0d99a5da3c | ||
|
|
645a4af3db | ||
|
|
ecaa30c408 | ||
|
|
7c770b727c | ||
|
|
05a6e2dc7f | ||
|
|
ed62f52452 | ||
|
|
9ea290aa12 | ||
|
|
06a1188267 | ||
|
|
aa40295f06 | ||
|
|
87d7312bf6 | ||
|
|
72b0a5f1d1 | ||
|
|
2815bbe6c0 | ||
|
|
37234bf3f8 | ||
|
|
e82217f95f | ||
|
|
8e54e34576 | ||
|
|
2b14ae5819 | ||
|
|
d91ec535b3 | ||
|
|
eb7929a971 | ||
|
|
38e06d783d | ||
|
|
dbb10e0f0b | ||
|
|
dd176cdb8b | ||
|
|
97733c3dff | ||
|
|
c8398bdb09 | ||
|
|
8a1c8e41b3 | ||
|
|
f0c89cfacd | ||
|
|
edb9d65e05 | ||
|
|
9a195bebfd | ||
|
|
18b98f9747 | ||
|
|
22f32e75c4 | ||
|
|
a8de332beb | ||
|
|
7f013d77d6 | ||
|
|
60a86cfe04 | ||
|
|
82ea121d09 | ||
|
|
2ea638f865 | ||
|
|
44a56b158e | ||
|
|
408e339c53 | ||
|
|
dd52037c27 | ||
|
|
33d8c6c617 | ||
|
|
e62d7f221f | ||
|
|
22fe4ae573 | ||
|
|
ae84a9ee2e | ||
|
|
a41588279a | ||
|
|
56244fb9a1 | ||
|
|
f2a8574448 | ||
|
|
99ecf63276 | ||
|
|
ef75ce8a34 | ||
|
|
b69cb74c03 | ||
|
|
063c9ddac5 | ||
|
|
ca658a97c5 | ||
|
|
63ad1abcce | ||
|
|
b7a654a318 | ||
|
|
707192f966 | ||
|
|
0be6863c87 | ||
|
|
50f7e2e89f | ||
|
|
6bc618051c | ||
|
|
9dae4e9d3e | ||
|
|
4c1a3187bf | ||
|
|
ab759f0ec2 | ||
|
|
d1cf39f180 | ||
|
|
912d1706e7 | ||
|
|
83012f543a | ||
|
|
fdb59d5968 | ||
|
|
464d4c82ec | ||
|
|
1901f15cd2 | ||
|
|
81e5124faf | ||
|
|
5f55a87101 | ||
|
|
0b301b0b47 | ||
|
|
2cdad77d82 | ||
|
|
81a8aa6581 | ||
|
|
51346a5930 | ||
|
|
c1d1677a28 | ||
|
|
98175548c2 | ||
|
|
f0e50e7b26 | ||
|
|
aee27ccbe1 | ||
|
|
c19245886c | ||
|
|
df816a58fe | ||
|
|
77393d3d30 | ||
|
|
d60bcbf08a | ||
|
|
5e6b714836 | ||
|
|
42ddbcc3a2 | ||
|
|
b0d6330cf4 | ||
|
|
f48567c5c6 | ||
|
|
c45ba5d7d4 | ||
|
|
e455eb8891 | ||
|
|
3ccfa4c6ad | ||
|
|
3b4b1d4a77 | ||
|
|
839634097f | ||
|
|
c27e18aa6a | ||
|
|
a78772d5ea | ||
|
|
ae9bc4a508 | ||
|
|
ed4b43b419 | ||
|
|
9f1e0aeef5 | ||
|
|
99d05f758c | ||
|
|
fe01191b5b | ||
|
|
6ccd7f0a4d | ||
|
|
c026eb0592 | ||
|
|
7e91ae592c | ||
|
|
51ecb49db3 | ||
|
|
ee11d98650 | ||
|
|
332caf0cd7 | ||
|
|
6a92f0bc7a | ||
|
|
618b2f6829 | ||
|
|
208849702d | ||
|
|
1fcd083db3 | ||
|
|
3e5339337a | ||
|
|
85001cbec7 | ||
|
|
0ca45a5cbc | ||
|
|
cd43738245 | ||
|
|
ecb3ce46be | ||
|
|
30fe424469 | ||
|
|
1b68ba953b | ||
|
|
56fbd2c211 | ||
|
|
09e126bae5 | ||
|
|
be4d42b8e2 | ||
|
|
0625e63648 | ||
|
|
0be4b6e7f0 | ||
|
|
97e54a80d4 | ||
|
|
abdaf9958d | ||
|
|
9d46c7bc78 | ||
|
|
4ccfdaeb4d | ||
|
|
60158a23b3 | ||
|
|
24c8e6bcb4 | ||
|
|
f5837b7000 | ||
|
|
2ac27616bc | ||
|
|
48ed7f8a32 | ||
|
|
ff200398bb | ||
|
|
f5d6b8b777 | ||
|
|
13bfe5deef | ||
|
|
4ceeba9e70 | ||
|
|
e72953dff7 | ||
|
|
627b081b67 | ||
|
|
22e5132b3a | ||
|
|
ee0f92a6be | ||
|
|
2ba817afac | ||
|
|
20e0bae5d1 | ||
|
|
cb2adbf5a6 | ||
|
|
6111b265e7 | ||
|
|
4a77f0820a | ||
|
|
8c9e6eaacd | ||
|
|
b71df82292 | ||
|
|
1d9ea30b72 | ||
|
|
aec7f32b02 | ||
|
|
5d80fc2ec7 | ||
|
|
e0bfd3161a | ||
|
|
003d48da21 | ||
|
|
6ee8d952d2 | ||
|
|
3e1395b767 | ||
|
|
a22ee30596 | ||
|
|
24bfd26719 | ||
|
|
0d60e67816 | ||
|
|
5b43bddf20 | ||
|
|
c647deace1 | ||
|
|
c03bb180eb | ||
|
|
eb493283dd | ||
|
|
a7f669044e | ||
|
|
edfa73782f | ||
|
|
0983060a90 | ||
|
|
090612492c | ||
|
|
d43129d27f | ||
|
|
f735d579d3 | ||
|
|
8824a9755c | ||
|
|
83cad3da79 | ||
|
|
152a6cbc2b | ||
|
|
f1b40567e3 | ||
|
|
25fbff5d52 | ||
|
|
6a93e26fc3 | ||
|
|
e74dc4e4bc | ||
|
|
4f195a54ca | ||
|
|
f86c7d911a | ||
|
|
9ecc1170a3 | ||
|
|
3f4aff5dde | ||
|
|
5850f49c90 | ||
|
|
9ca011e3ca | ||
|
|
b231f7bdab | ||
|
|
a457c308ad | ||
|
|
2d3b355fb6 | ||
|
|
67f134ebd7 | ||
|
|
dc9fc01254 | ||
|
|
33a9e5e2d1 | ||
|
|
6769d07604 | ||
|
|
29a4c3944e | ||
|
|
40334bc28d | ||
|
|
d892cad15d |
No files matched your search
@@ -34,4 +34,4 @@ jobs:
|
||||
run: cd weed; go build -v .
|
||||
|
||||
- name: Test
|
||||
run: cd weed; go test -v .
|
||||
run: cd weed; go test -v ./...
|
||||
@@ -0,0 +1,41 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Go Release Binaries
|
||||
uses: wangyoucao577/go-release-action@v1.10
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: linux # default is
|
||||
goarch: amd64 # default is
|
||||
release_tag: dev
|
||||
overwrite: true
|
||||
build_flags: -tags 5BytesOffset # optional, default is
|
||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||
# Where to run `go build .`
|
||||
project_path: weed
|
||||
binary_name: weed-large-disk
|
||||
- name: Go Release Binaries
|
||||
uses: wangyoucao577/go-release-action@v1.10
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
goos: linux # default is
|
||||
goarch: amd64 # default is
|
||||
release_tag: dev
|
||||
overwrite: true
|
||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||
# Where to run `go build .`
|
||||
project_path: weed
|
||||
binary_name: weed
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
sudo: false
|
||||
language: go
|
||||
go:
|
||||
- 1.12.x
|
||||
- 1.13.x
|
||||
- 1.14.x
|
||||
- 1.15.x
|
||||
|
||||
before_install:
|
||||
- export PATH=/home/travis/gopath/bin:$PATH
|
||||
@@ -45,4 +44,4 @@ deploy:
|
||||
on:
|
||||
tags: true
|
||||
repo: chrislusf/seaweedfs
|
||||
go: 1.14.x
|
||||
go: 1.15.x
|
||||
@@ -36,6 +36,9 @@ deps:
|
||||
build: deps
|
||||
go build $(GO_FLAGS) -ldflags "$(LDFLAGS)" -o $(BINARY) $(SOURCE_DIR)
|
||||
|
||||
install: deps
|
||||
go install $(GO_FLAGS) -ldflags "$(LDFLAGS)" $(SOURCE_DIR)
|
||||
|
||||
linux: deps
|
||||
mkdir -p linux
|
||||
GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) -ldflags "$(LDFLAGS)" -o linux/$(BINARY) $(SOURCE_DIR)
|
||||
|
||||
@@ -58,11 +58,12 @@ Your support will be really appreciated by me and other supporters!
|
||||
Table of Contents
|
||||
=================
|
||||
|
||||
* [Quick Start](#quick-start)
|
||||
* [Introduction](#introduction)
|
||||
* [Features](#features)
|
||||
* [Additional Features](#additional-features)
|
||||
* [Filer Features](#filer-features)
|
||||
* [Example Usage](#example-usage)
|
||||
* [Example: Using Seaweed Object Store](#example-Using-Seaweed-Object-Store)
|
||||
* [Architecture](#architecture)
|
||||
* [Compared to Other File Systems](#compared-to-other-file-systems)
|
||||
* [Compared to HDFS](#compared-to-hdfs)
|
||||
@@ -75,6 +76,13 @@ Table of Contents
|
||||
* [Benchmark](#Benchmark)
|
||||
* [License](#license)
|
||||
|
||||
|
||||
## Quick Start ##
|
||||
* Download the latest binary from https://github.com/chrislusf/seaweedfs/releases and unzip a single binary file `weed` or `weed.exe`
|
||||
* Run `weed server -dir=/some/data/dir -s3` to start one master, one volume server, one filer, and one S3 gateway.
|
||||
|
||||
Also, to increase capacity, just add more volume servers by `weed volume -dir="/some/data/dir2" -mserver="<master_host>:9333" -port=8081` locally or a different machine. That is it!
|
||||
|
||||
## Introduction ##
|
||||
|
||||
SeaweedFS is a simple and highly scalable distributed file system. There are two objectives:
|
||||
@@ -90,7 +98,7 @@ There is only 40 bytes of disk storage overhead for each file's metadata. It is
|
||||
|
||||
SeaweedFS started by implementing [Facebook's Haystack design paper](http://www.usenix.org/event/osdi10/tech/full_papers/Beaver.pdf). Also, SeaweedFS implements erasure coding with ideas from [f4: Facebook’s Warm BLOB Storage System](https://www.usenix.org/system/files/conference/osdi14/osdi14-paper-muralidhar.pdf)
|
||||
|
||||
On top of the object store, optional [Filer] can support directories and POSIX attributes. Filer is a separate linearly-scalable stateless server with customizable metadata stores, e.g., MySql, Postgres, Mongodb, Redis, Etcd, Cassandra, LevelDB, MemSql, TiDB, TiKV, CockroachDB, etc.
|
||||
On top of the object store, optional [Filer] can support directories and POSIX attributes. Filer is a separate linearly-scalable stateless server with customizable metadata stores, e.g., MySql, Postgres, Mongodb, Redis, Cassandra, Elastic Search, LevelDB, MemSql, TiDB, Etcd, CockroachDB, etc.
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
@@ -101,7 +109,7 @@ On top of the object store, optional [Filer] can support directories and POSIX a
|
||||
* Automatic compaction to reclaim disk space after deletion or update.
|
||||
* [Automatic entry TTL expiration][VolumeServerTTL].
|
||||
* Any server with some disk spaces can add to the total storage space.
|
||||
* Adding/Removing servers does **not** cause any data re-balancing.
|
||||
* Adding/Removing servers does **not** cause any data re-balancing unless triggered by admin commands.
|
||||
* Optional picture resizing.
|
||||
* Support ETag, Accept-Range, Last-Modified, etc.
|
||||
* Support in-memory/leveldb/readonly mode tuning for memory/performance balance.
|
||||
@@ -112,22 +120,23 @@ On top of the object store, optional [Filer] can support directories and POSIX a
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
## Filer Features ##
|
||||
* [Filer server][Filer] provide "normal" directories and files via http.
|
||||
* [Filer server][Filer] provides "normal" directories and files via http.
|
||||
* [Super Large Files][SuperLargeFiles] stores large or super large files in tens of TB.
|
||||
* [Mount filer][Mount] to read and write files directly as a local directory via FUSE.
|
||||
* [Amazon S3 compatible API][AmazonS3API] to access files with S3 tooling.
|
||||
* [Hadoop Compatible File System][Hadoop] to access files from Hadoop/Spark/Flink/etc jobs.
|
||||
* [Async Backup To Cloud][BackupToCloud] has extremely fast local access and backups to Amazon S3, Google Cloud Storage, Azure, BackBlaze.
|
||||
* [WebDAV] access as a mapped drive on Mac and Windows, or from mobile devices.
|
||||
* [Mount filer][Mount] reads and writes files directly as a local directory via FUSE.
|
||||
* [Active-Active Replication][ActiveActiveAsyncReplication] enables asynchronous one-way or two-way cross cluster continuous replication.
|
||||
* [Amazon S3 compatible API][AmazonS3API] accesses files with S3 tooling.
|
||||
* [Hadoop Compatible File System][Hadoop] accesses files from Hadoop/Spark/Flink/etc or even runs HBase.
|
||||
* [Async Replication To Cloud][BackupToCloud] has extremely fast local access and backups to Amazon S3, Google Cloud Storage, Azure, BackBlaze.
|
||||
* [WebDAV] accesses as a mapped drive on Mac and Windows, or from mobile devices.
|
||||
* [AES256-GCM Encrypted Storage][FilerDataEncryption] safely stores the encrypted data.
|
||||
* [File TTL][FilerTTL] automatically purge file metadata and actual file data.
|
||||
* [File TTL][FilerTTL] automatically purges file metadata and actual file data.
|
||||
* [Kubernetes CSI Driver][SeaweedFsCsiDriver] A Container Storage Interface (CSI) Driver. [](https://hub.docker.com/r/chrislusf/seaweedfs-csi-driver/)
|
||||
|
||||
[Filer]: https://github.com/chrislusf/seaweedfs/wiki/Directories-and-Files
|
||||
[SuperLargeFiles]: https://github.com/chrislusf/seaweedfs/wiki/Data-Structure-for-Large-Files
|
||||
[Mount]: https://github.com/chrislusf/seaweedfs/wiki/FUSE-Mount
|
||||
[AmazonS3API]: https://github.com/chrislusf/seaweedfs/wiki/Amazon-S3-API
|
||||
[BackupToCloud]: https://github.com/chrislusf/seaweedfs/wiki/Backup-to-Cloud
|
||||
[BackupToCloud]: https://github.com/chrislusf/seaweedfs/wiki/Async-Replication-to-Cloud
|
||||
[Hadoop]: https://github.com/chrislusf/seaweedfs/wiki/Hadoop-Compatible-File-System
|
||||
[WebDAV]: https://github.com/chrislusf/seaweedfs/wiki/WebDAV
|
||||
[ErasureCoding]: https://github.com/chrislusf/seaweedfs/wiki/Erasure-coding-for-warm-storage
|
||||
@@ -136,10 +145,11 @@ On top of the object store, optional [Filer] can support directories and POSIX a
|
||||
[FilerTTL]: https://github.com/chrislusf/seaweedfs/wiki/Filer-Stores
|
||||
[VolumeServerTTL]: https://github.com/chrislusf/seaweedfs/wiki/Store-file-with-a-Time-To-Live
|
||||
[SeaweedFsCsiDriver]: https://github.com/seaweedfs/seaweedfs-csi-driver
|
||||
[ActiveActiveAsyncReplication]: https://github.com/chrislusf/seaweedfs/wiki/Filer-Active-Active-cross-cluster-continuous-synchronization
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
## Example Usage ##
|
||||
## Example: Using Seaweed Object Store ##
|
||||
|
||||
By default, the master node runs on port 9333, and the volume nodes run on port 8080.
|
||||
Let's start one master node, and two volume nodes on port 8080 and 8081. Ideally, they should be started from different machines. We'll use localhost as an example.
|
||||
@@ -347,6 +357,8 @@ Most other distributed file systems seem more complicated than necessary.
|
||||
|
||||
SeaweedFS is meant to be fast and simple, in both setup and operation. If you do not understand how it works when you reach here, we've failed! Please raise an issue with any questions or update this file with clarifications.
|
||||
|
||||
SeaweedFS is constantly moving forward. Same with other systems. These comparisons can be outdated quickly. Please help to keep them updated.
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
### Compared to HDFS ###
|
||||
@@ -365,16 +377,17 @@ The architectures are mostly the same. SeaweedFS aims to store and read files fa
|
||||
|
||||
* SeaweedFS optimizes for small files, ensuring O(1) disk seek operation, and can also handle large files.
|
||||
* SeaweedFS statically assigns a volume id for a file. Locating file content becomes just a lookup of the volume id, which can be easily cached.
|
||||
* SeaweedFS Filer metadata store can be any well-known and proven data stores, e.g., Cassandra, Mongodb, Redis, Etcd, MySql, Postgres, MemSql, TiDB, CockroachDB, etc, and is easy to customized.
|
||||
* SeaweedFS Filer metadata store can be any well-known and proven data stores, e.g., Cassandra, Mongodb, Redis, Elastic Search, MySql, Postgres, MemSql, TiDB, CockroachDB, Etcd etc, and is easy to customized.
|
||||
* SeaweedFS Volume server also communicates directly with clients via HTTP, supporting range queries, direct uploads, etc.
|
||||
|
||||
| System | File Meta | File Content Read| POSIX | REST API | Optimized for small files |
|
||||
| System | File Metadata | File Content Read| POSIX | REST API | Optimized for large number of small files |
|
||||
| ------------- | ------------------------------- | ---------------- | ------ | -------- | ------------------------- |
|
||||
| SeaweedFS | lookup volume id, cacheable | O(1) disk seek | | Yes | Yes |
|
||||
| SeaweedFS Filer| Linearly Scalable, Customizable | O(1) disk seek | FUSE | Yes | Yes |
|
||||
| GlusterFS | hashing | | FUSE, NFS | | |
|
||||
| Ceph | hashing + rules | | FUSE | Yes | |
|
||||
| MooseFS | in memory | | FUSE | | No |
|
||||
| MinIO | separate meta file for each file | | | Yes | No |
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
@@ -406,7 +419,7 @@ Ceph uses CRUSH hashing to automatically manage the data placement. SeaweedFS pl
|
||||
|
||||
SeaweedFS is optimized for small files. Small files are stored as one continuous block of content, with at most 8 unused bytes between files. Small file access is O(1) disk read.
|
||||
|
||||
SeaweedFS Filer uses off-the-shelf stores, such as MySql, Postgres, Mongodb, Redis, Etcd, Cassandra, MemSql, TiDB, CockroachCB, to manage file directories. These stores are proven, scalable, and easier to manage.
|
||||
SeaweedFS Filer uses off-the-shelf stores, such as MySql, Postgres, Mongodb, Redis, Elastic Search, Cassandra, MemSql, TiDB, CockroachCB, Etcd, to manage file directories. These stores are proven, scalable, and easier to manage.
|
||||
|
||||
| SeaweedFS | comparable to Ceph | advantage |
|
||||
| ------------- | ------------- | ---------------- |
|
||||
@@ -416,19 +429,33 @@ SeaweedFS Filer uses off-the-shelf stores, such as MySql, Postgres, Mongodb, Red
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
### Compared to MinIO ###
|
||||
|
||||
MinIO follows AWS S3 closely and is ideal for testing for S3 API. It has good UI, policies, versionings, etc. SeaweedFS is trying to catch up here. It is also possible to put MinIO as a gateway in front of SeaweedFS later.
|
||||
|
||||
MinIO metadata are in simple files. Each file write will incur extra writes to corresponding meta file.
|
||||
|
||||
MinIO does not have optimization for lots of small files. The files are simply stored as is to local disks.
|
||||
Plus the extra meta file and shards for erasure coding, it only amplifies the LOSF problem.
|
||||
|
||||
MinIO has multiple disk IO to read one file. SeaweedFS has O(1) disk reads, even for erasure coded files.
|
||||
|
||||
MinIO has full-time erasure coding. SeaweedFS uses replication on hot data for faster speed and optionally applies erasure coding on warm data.
|
||||
|
||||
MinIO does not have POSIX-like API support.
|
||||
|
||||
MinIO has specific requirements on storage layout. It is not flexible to adjust capacity. In SeaweedFS, just start one volume server pointing to the master. That's all.
|
||||
|
||||
## Dev Plan ##
|
||||
|
||||
More tools and documentation, on how to maintain and scale the system. For example, how to move volumes, automatically balancing data, how to grow volumes, how to check system status, etc.
|
||||
Other key features include: Erasure Encoding, JWT security.
|
||||
* More tools and documentation, on how to manage and scale the system. For example, how to move volumes, automatically balancing data, how to grow volumes, how to check system status, etc.
|
||||
* Integrate with Kubernetes. build [SeaweedFS Operator](https://github.com/seaweedfs/seaweedfs-operator).
|
||||
* Add ftp server.
|
||||
* Read and write stream data.
|
||||
* Support structured data.
|
||||
|
||||
This is a super exciting project! And we need helpers and [support](https://www.patreon.com/seaweedfs)!
|
||||
|
||||
BTW, We suggest run the code style check script `util/gostd` before you push your branch to remote, it will make SeaweedFS easy to review, maintain and develop:
|
||||
|
||||
```
|
||||
$ ./util/gostd
|
||||
```
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
## Installation Guide ##
|
||||
@@ -442,30 +469,18 @@ https://golang.org/doc/install
|
||||
make sure you set up your $GOPATH
|
||||
|
||||
|
||||
Step 2: also you may need to install Mercurial by following the instructions at:
|
||||
|
||||
http://mercurial.selenic.com/downloads
|
||||
|
||||
Step 2: checkout this repo:
|
||||
```bash
|
||||
git clone https://github.com/chrislusf/seaweedfs.git
|
||||
```
|
||||
Step 3: download, compile, and install the project by executing the following command
|
||||
|
||||
```bash
|
||||
go get github.com/chrislusf/seaweedfs/weed
|
||||
make install
|
||||
```
|
||||
|
||||
Once this is done, you will find the executable "weed" in your `$GOPATH/bin` directory
|
||||
|
||||
Note:
|
||||
* If you got into this problem, try to `rm -Rf $GOPATH/src/go.etcd.io/etcd/vendor/golang.org/x/net/trace` and build again.
|
||||
```
|
||||
panic: /debug/requests is already registered. You may have two independent copies of golang.org/x/net/trace in your binary, trying to maintain separate state. This may involve a vendored copy of golang.org/x/net/trace.
|
||||
```
|
||||
|
||||
Step 4: after you modify your code locally, you could start a local build by calling `go install` under
|
||||
|
||||
```
|
||||
$GOPATH/src/github.com/chrislusf/seaweedfs/weed
|
||||
```
|
||||
|
||||
[Back to TOC](#table-of-contents)
|
||||
|
||||
## Disk Related Topics ##
|
||||
|
||||
@@ -2,7 +2,9 @@ FROM frolvlad/alpine-glibc as builder
|
||||
RUN apk add git go g++
|
||||
RUN mkdir -p /go/src/github.com/chrislusf/
|
||||
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
||||
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed && go install
|
||||
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
|
||||
&& export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
|
||||
&& go install -ldflags "${LDFLAGS}"
|
||||
|
||||
FROM alpine AS final
|
||||
LABEL author="Chris Lu"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
FROM frolvlad/alpine-glibc as builder
|
||||
RUN apk add git go g++
|
||||
RUN mkdir -p /go/src/github.com/chrislusf/
|
||||
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
||||
RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
|
||||
&& export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
|
||||
&& go install -tags 5BytesOffset -ldflags "${LDFLAGS}"
|
||||
|
||||
FROM alpine AS final
|
||||
LABEL author="Chris Lu"
|
||||
COPY --from=builder /root/go/bin/weed /usr/bin/
|
||||
RUN mkdir -p /etc/seaweedfs
|
||||
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/filer.toml /etc/seaweedfs/filer.toml
|
||||
COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/entrypoint.sh /entrypoint.sh
|
||||
|
||||
# volume server gprc port
|
||||
EXPOSE 18080
|
||||
# volume server http port
|
||||
EXPOSE 8080
|
||||
# filer server gprc port
|
||||
EXPOSE 18888
|
||||
# filer server http port
|
||||
EXPOSE 8888
|
||||
# master server shared gprc port
|
||||
EXPOSE 19333
|
||||
# master server shared http port
|
||||
EXPOSE 9333
|
||||
# s3 server http port
|
||||
EXPOSE 8333
|
||||
|
||||
RUN mkdir -p /data/filerldb2
|
||||
|
||||
VOLUME /data
|
||||
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -12,6 +12,9 @@ build:
|
||||
dev: build
|
||||
docker-compose -f local-dev-compose.yml -p seaweedfs up
|
||||
|
||||
dev_registry: build
|
||||
docker-compose -f local-registry-compose.yml -p seaweedfs up
|
||||
|
||||
cluster: build
|
||||
docker-compose -f local-cluster-compose.yml -p seaweedfs up
|
||||
|
||||
|
||||
+31
-7
@@ -1,36 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
isArgPassed() {
|
||||
arg="$1"
|
||||
argWithEqualSign="$1="
|
||||
shift
|
||||
while [ $# -gt 0 ]; do
|
||||
passedArg="$1"
|
||||
shift
|
||||
case $passedArg in
|
||||
$arg)
|
||||
return 0
|
||||
;;
|
||||
$argWithEqualSign*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
||||
'master')
|
||||
ARGS="-mdir=/data -volumePreallocate -volumeSizeLimitMB=1024"
|
||||
exec /usr/bin/weed $@ $ARGS
|
||||
shift
|
||||
exec /usr/bin/weed master $ARGS $@
|
||||
;;
|
||||
|
||||
'volume')
|
||||
ARGS="-dir=/data -max=0"
|
||||
if [[ $@ == *"-max="* ]]; then
|
||||
if isArgPassed "-max" "$@"; then
|
||||
ARGS="-dir=/data"
|
||||
fi
|
||||
exec /usr/bin/weed $@ $ARGS
|
||||
shift
|
||||
exec /usr/bin/weed volume $ARGS $@
|
||||
;;
|
||||
|
||||
'server')
|
||||
ARGS="-dir=/data -volume.max=0 -master.volumePreallocate -master.volumeSizeLimitMB=1024"
|
||||
if [[ $@ == *"-volume.max="* ]]; then
|
||||
if isArgPassed "-volume.max" "$@"; then
|
||||
ARGS="-dir=/data -master.volumePreallocate -master.volumeSizeLimitMB=1024"
|
||||
fi
|
||||
exec /usr/bin/weed $@ $ARGS
|
||||
shift
|
||||
exec /usr/bin/weed server $ARGS $@
|
||||
;;
|
||||
|
||||
'filer')
|
||||
ARGS=""
|
||||
exec /usr/bin/weed $@ $ARGS
|
||||
shift
|
||||
exec /usr/bin/weed filer $ARGS $@
|
||||
;;
|
||||
|
||||
's3')
|
||||
ARGS="-domainName=$S3_DOMAIN_NAME -key.file=$S3_KEY_FILE -cert.file=$S3_CERT_FILE"
|
||||
exec /usr/bin/weed $@ $ARGS
|
||||
shift
|
||||
exec /usr/bin/weed s3 $ARGS $@
|
||||
;;
|
||||
|
||||
'cronjob')
|
||||
|
||||
@@ -6,25 +6,25 @@ services:
|
||||
ports:
|
||||
- 9333:9333
|
||||
- 19333:19333
|
||||
command: "master -ip=master0 -port=9333 -peers=master0:9333,master1:9334,master2:9335"
|
||||
command: "master -ip=master0 -port=9333 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m1"
|
||||
master1:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 9334:9334
|
||||
- 19334:19334
|
||||
command: "master -ip=master1 -port=9334 -peers=master0:9333,master1:9334,master2:9335"
|
||||
command: "master -ip=master1 -port=9334 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m2"
|
||||
master2:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 9335:9335
|
||||
- 19335:19335
|
||||
command: "master -ip=master2 -port=9335 -peers=master0:9333,master1:9334,master2:9335"
|
||||
command: "master -ip=master2 -port=9335 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m3"
|
||||
volume:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 18080:18080
|
||||
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume'
|
||||
command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume -publicUrl=localhost:8080'
|
||||
depends_on:
|
||||
- master0
|
||||
- master1
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
version: '2'
|
||||
|
||||
services:
|
||||
master:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 9333:9333
|
||||
- 19333:19333
|
||||
command: "master -ip=master -volumeSizeLimitMB=1024"
|
||||
volume:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 18080:18080
|
||||
command: "volume -mserver=master:9333 -port=8080 -ip=volume -max=0 -preStopSeconds=1"
|
||||
volumes:
|
||||
- type: bind
|
||||
source: /Volumes/mobile_disk/data
|
||||
target: /data
|
||||
depends_on:
|
||||
- master
|
||||
filer:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 8888:8888
|
||||
- 18888:18888
|
||||
command: 'filer -master="master:9333"'
|
||||
depends_on:
|
||||
- master
|
||||
- volume
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:local
|
||||
ports:
|
||||
- 8333:8333
|
||||
command: '-v 9 s3 -filer="filer:8888"'
|
||||
depends_on:
|
||||
- master
|
||||
- volume
|
||||
- filer
|
||||
minio:
|
||||
image: minio/minio
|
||||
ports:
|
||||
- 9000:9000
|
||||
command: 'minio server /data'
|
||||
environment:
|
||||
MINIO_ACCESS_KEY: "some_access_key1"
|
||||
MINIO_SECRET_KEY: "some_secret_key1"
|
||||
depends_on:
|
||||
- master
|
||||
registry1:
|
||||
image: registry:2
|
||||
environment:
|
||||
REGISTRY_HTTP_ADDR: "0.0.0.0:5001" # seaweedfs s3
|
||||
REGISTRY_LOG_LEVEL: "debug"
|
||||
REGISTRY_STORAGE: "s3"
|
||||
REGISTRY_STORAGE_S3_REGION: "us-east-1"
|
||||
REGISTRY_STORAGE_S3_REGIONENDPOINT: "http://s3:8333"
|
||||
REGISTRY_STORAGE_S3_BUCKET: "registry"
|
||||
REGISTRY_STORAGE_S3_ACCESSKEY: "some_access_key1"
|
||||
REGISTRY_STORAGE_S3_SECRETKEY: "some_secret_key1"
|
||||
REGISTRY_STORAGE_S3_V4AUTH: "true"
|
||||
REGISTRY_STORAGE_S3_SECURE: "false"
|
||||
REGISTRY_STORAGE_S3_SKIPVERIFY: "true"
|
||||
REGISTRY_STORAGE_S3_ROOTDIRECTORY: "/"
|
||||
REGISTRY_STORAGE_DELETE_ENABLED: "true"
|
||||
REGISTRY_STORAGE_REDIRECT_DISABLE: "true"
|
||||
REGISTRY_VALIDATION_DISABLED: "true"
|
||||
ports:
|
||||
- 5001:5001
|
||||
depends_on:
|
||||
- s3
|
||||
- minio
|
||||
registry2:
|
||||
image: registry:2
|
||||
environment:
|
||||
REGISTRY_HTTP_ADDR: "0.0.0.0:5002" # minio
|
||||
REGISTRY_LOG_LEVEL: "debug"
|
||||
REGISTRY_STORAGE: "s3"
|
||||
REGISTRY_STORAGE_S3_REGION: "us-east-1"
|
||||
REGISTRY_STORAGE_S3_REGIONENDPOINT: "http://minio:9000"
|
||||
REGISTRY_STORAGE_S3_BUCKET: "registry"
|
||||
REGISTRY_STORAGE_S3_ACCESSKEY: "some_access_key1"
|
||||
REGISTRY_STORAGE_S3_SECRETKEY: "some_secret_key1"
|
||||
REGISTRY_STORAGE_S3_V4AUTH: "true"
|
||||
REGISTRY_STORAGE_S3_SECURE: "false"
|
||||
REGISTRY_STORAGE_S3_SKIPVERIFY: "true"
|
||||
REGISTRY_STORAGE_S3_ROOTDIRECTORY: "/"
|
||||
REGISTRY_STORAGE_DELETE_ENABLED: "true"
|
||||
REGISTRY_STORAGE_REDIRECT_DISABLE: "true"
|
||||
REGISTRY_VALIDATION_DISABLED: "true"
|
||||
ports:
|
||||
- 5002:5002
|
||||
depends_on:
|
||||
- s3
|
||||
- minio
|
||||
@@ -8,10 +8,10 @@ require (
|
||||
github.com/Azure/azure-storage-blob-go v0.8.0
|
||||
github.com/OneOfOne/xxhash v1.2.2
|
||||
github.com/Shopify/sarama v1.23.1
|
||||
github.com/aws/aws-sdk-go v1.23.13
|
||||
github.com/aws/aws-sdk-go v1.33.5
|
||||
github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72
|
||||
github.com/cespare/xxhash v1.1.0
|
||||
github.com/chrislusf/raft v1.0.1
|
||||
github.com/chrislusf/raft v1.0.3
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/disintegration/imaging v1.6.2
|
||||
@@ -22,20 +22,22 @@ require (
|
||||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
|
||||
github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
|
||||
github.com/fclairamb/ftpserverlib v0.8.0
|
||||
github.com/frankban/quicktest v1.7.2 // indirect
|
||||
github.com/go-errors/errors v1.1.1 // indirect
|
||||
github.com/go-redis/redis v6.15.7+incompatible
|
||||
github.com/go-sql-driver/mysql v1.4.1
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/gocql/gocql v0.0.0-20190829130954-e163eff7a8c6
|
||||
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6
|
||||
github.com/golang/protobuf v1.4.2
|
||||
github.com/google/btree v1.0.0
|
||||
github.com/google/uuid v1.1.1
|
||||
github.com/gorilla/mux v1.7.4
|
||||
github.com/gorilla/websocket v1.4.1 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.11.0 // indirect
|
||||
github.com/hashicorp/golang-lru v0.5.3 // indirect
|
||||
github.com/jcmturner/gofork v1.0.0 // indirect
|
||||
github.com/json-iterator/go v1.1.10
|
||||
github.com/karlseguin/ccache v2.0.3+incompatible
|
||||
github.com/karlseguin/expect v1.0.1 // indirect
|
||||
github.com/klauspost/compress v1.10.9
|
||||
@@ -44,29 +46,32 @@ require (
|
||||
github.com/klauspost/reedsolomon v1.9.2
|
||||
github.com/kurin/blazer v0.5.3
|
||||
github.com/lib/pq v1.2.0
|
||||
github.com/lunixbochs/vtclean v1.0.0 // indirect
|
||||
github.com/magiconair/properties v1.8.1 // indirect
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190805055040-f9202b1cfdeb // indirect
|
||||
github.com/mattn/go-runewidth v0.0.4 // indirect
|
||||
github.com/nats-io/nats-server/v2 v2.0.4 // indirect
|
||||
github.com/olivere/elastic/v7 v7.0.19
|
||||
github.com/onsi/ginkgo v1.10.1 // indirect
|
||||
github.com/onsi/gomega v1.7.0 // indirect
|
||||
github.com/peterh/liner v1.1.0
|
||||
github.com/pierrec/lz4 v2.2.7+incompatible // indirect
|
||||
github.com/prometheus/client_golang v1.1.0
|
||||
github.com/prometheus/procfs v0.0.4 // indirect
|
||||
github.com/prometheus/client_golang v1.3.0
|
||||
github.com/rakyll/statik v0.1.7
|
||||
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563 // indirect
|
||||
github.com/seaweedfs/fuse v0.0.0-20190510212405-310228904eff
|
||||
github.com/seaweedfs/fuse v1.0.7
|
||||
github.com/seaweedfs/goexif v1.0.2
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.2.2 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/viper v1.4.0
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 // indirect
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/stretchr/testify v1.6.1
|
||||
github.com/syndtr/goleveldb v1.0.0
|
||||
github.com/tidwall/gjson v1.3.2
|
||||
github.com/tidwall/match v1.0.1
|
||||
github.com/valyala/bytebufferpool v1.0.0
|
||||
github.com/viant/assertly v0.5.4 // indirect
|
||||
github.com/viant/ptrie v0.3.0
|
||||
github.com/viant/toolbox v0.33.2 // indirect
|
||||
github.com/willf/bitset v1.1.10 // indirect
|
||||
github.com/willf/bloom v2.0.3+incompatible
|
||||
github.com/wsxiaoys/terminal v0.0.0-20160513160801-0940f3fc43a0 // indirect
|
||||
@@ -76,9 +81,10 @@ require (
|
||||
gocloud.dev/pubsub/natspubsub v0.16.0
|
||||
gocloud.dev/pubsub/rabbitpubsub v0.16.0
|
||||
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
|
||||
golang.org/x/sync v0.0.0-20200930132711-30421366ff76 // indirect
|
||||
golang.org/x/sys v0.0.0-20201022201747-fb209a7c41cd
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114
|
||||
google.golang.org/api v0.9.0
|
||||
google.golang.org/appengine v1.6.2 // indirect
|
||||
google.golang.org/grpc v1.29.1
|
||||
@@ -89,4 +95,7 @@ require (
|
||||
gopkg.in/karlseguin/expect.v1 v1.0.1 // indirect
|
||||
)
|
||||
|
||||
// replace github.com/seaweedfs/fuse => /Users/chris/go/src/github.com/seaweedfs/fuse
|
||||
// replace github.com/chrislusf/raft => /Users/chris/go/src/github.com/chrislusf/raft
|
||||
|
||||
replace go.etcd.io/etcd => go.etcd.io/etcd v0.5.0-alpha.5.0.20200425165423-262c93980547
|
||||
@@ -33,20 +33,35 @@ github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym
|
||||
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 h1:2T/jmrHeTezcCM58lvEQXs0UpQJCo5SoGAcg+mbSTIg=
|
||||
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
|
||||
github.com/GoogleCloudPlatform/cloudsql-proxy v0.0.0-20190605020000-c4ba1fdf4d36/go.mod h1:aJ4qN3TfrelA6NZ6AXsXRfmEVaYin3EDbSPJrKS8OXo=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
|
||||
github.com/Shopify/sarama v1.23.1 h1:XxJBCZEoWJtoWjf/xRbmGUpAmTZGnuuF0ON0EvxxBrs=
|
||||
github.com/Shopify/sarama v1.23.1/go.mod h1:XLH1GYJnLVE0XCr6KdJGVJRTwY30moWNJ4sERjXX6fs=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
|
||||
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
|
||||
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c=
|
||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
|
||||
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
|
||||
github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
|
||||
github.com/aws/aws-sdk-go v1.19.18/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go v1.19.45/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go v1.23.13 h1:l/NG+mgQFRGG3dsFzEj0jw9JIs/zYdtU6MXhY1WIDmM=
|
||||
github.com/aws/aws-sdk-go v1.23.13/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
|
||||
github.com/aws/aws-sdk-go v1.33.5 h1:p2fr1ryvNTU6avUWLI+/H7FGv0TBIjzVM5WDgXBBv4U=
|
||||
github.com/aws/aws-sdk-go v1.33.5/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
|
||||
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0 h1:HWo1m869IqiPhD389kmkxeTalrjNbbJTC8LXupb+sl0=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
@@ -59,18 +74,24 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72 h1:fUmDBbSvv1uOzo/t8WaxZMVb7BxJ8JECo5lGoR9c5bA=
|
||||
github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OEE5igu/CDjGegM1Jn6ZMo7R6LlV/JChAkjfQQIRLpg=
|
||||
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.0 h1:LzQXZOgg4CQfE6bFvXGM30YZL1WW/M337pXml+GrcZ4=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chrislusf/raft v1.0.1 h1:Wa4ffkmkysW7cX3T/gMC/Mk3PhnOXhsqOVwQJcMndhw=
|
||||
github.com/chrislusf/raft v1.0.1/go.mod h1:Ep5DP+mJSosjfKiix1uU7Lc2Df/SX4oGJEpZlXH5l68=
|
||||
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chrislusf/raft v1.0.3 h1:11YrnzJtVa5z7m9lhY2p8VcPHoUlC1UswyoAo+U1m1k=
|
||||
github.com/chrislusf/raft v1.0.3/go.mod h1:Ep5DP+mJSosjfKiix1uU7Lc2Df/SX4oGJEpZlXH5l68=
|
||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y=
|
||||
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
|
||||
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
|
||||
github.com/coreos/bbolt v1.3.2 h1:wZwiHHUieZCquLkDL0B8UhzreNWsPHooDAG3q34zk0s=
|
||||
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
|
||||
github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=
|
||||
@@ -85,6 +106,7 @@ github.com/coreos/go-systemd/v22 v22.0.0 h1:XJIw/+VlJ+87J+doOxznsAWIdmWuViOVhkQa
|
||||
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
@@ -107,6 +129,8 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 h1:YEetp8
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
|
||||
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
|
||||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
|
||||
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
@@ -122,22 +146,37 @@ github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4/go.mod h1:vsJz7uE
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
|
||||
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fclairamb/ftpserverlib v0.8.0 h1:ZsWUQ8Vg3Y8LIWRUAzVnFXY982Yztz2odDdK/UVJtik=
|
||||
github.com/fclairamb/ftpserverlib v0.8.0/go.mod h1:xF4cy07oCHA9ZorKehsFGqA/1UHYaonmqHK2g3P1X8U=
|
||||
github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
|
||||
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
|
||||
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
|
||||
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
|
||||
github.com/frankban/quicktest v1.7.2 h1:2QxQoC1TS09S7fhCPsrvqYdvP1H5M1P1ih5ABm3BTYk=
|
||||
github.com/frankban/quicktest v1.7.2/go.mod h1:jaStnuzAqU1AJdCO0l53JDCJrVDKcS03DbaAcR7Ks/o=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-errors/errors v1.1.1 h1:ljK/pL5ltg3qoN+OtN6yCv9HWSfMwxSx90GJCZQxYNg=
|
||||
github.com/go-errors/errors v1.1.1/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
|
||||
github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||
github.com/go-kit/kit v0.10.0 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo=
|
||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||
github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-redis/redis v6.15.7+incompatible h1:3skhDh95XQMpnqeqNftPkQD9jL9e5e36z/1SUm6dy1U=
|
||||
github.com/go-redis/redis v6.15.7+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA=
|
||||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0=
|
||||
@@ -167,7 +206,9 @@ github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY9
|
||||
github.com/gocql/gocql v0.0.0-20190829130954-e163eff7a8c6 h1:P66kRWyEoIx6URKgAC3ijx9jo9gEid7bEhLQ/Z0G65A=
|
||||
github.com/gocql/gocql v0.0.0-20190829130954-e163eff7a8c6/go.mod h1:Q7Sru5153KG8D9zwueuQJB3ccJf9/bIwF/x8b3oKgT8=
|
||||
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/gogo/protobuf v1.2.2-0.20190730201129-28a6bbf47e48 h1:X+zN6RZXsvnrSJaAIQhZezPfAfvsqihKKR8oiLHid34=
|
||||
@@ -210,6 +251,8 @@ github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
|
||||
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-replayers/grpcreplay v0.1.0 h1:eNb1y9rZFmY4ax45uEEECSa8fsxGRU+8Bil52ASAwic=
|
||||
github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE=
|
||||
github.com/google/go-replayers/httpreplay v0.1.0 h1:AX7FUb4BjrrzNvblr/OlgwrmFiep6soj5K2QSDW7BGk=
|
||||
@@ -232,6 +275,10 @@ github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
||||
github.com/gorilla/mux v1.7.4 h1:VuZ8uybHlWmqV03+zRzdwKL4tUnIp1MAQtp1mIFE1bc=
|
||||
github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
|
||||
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||
@@ -254,18 +301,35 @@ github.com/grpc-ecosystem/grpc-gateway v1.11.0 h1:aT5ISUniaOTErogCQ+4pGoYNBB6rm6
|
||||
github.com/grpc-ecosystem/grpc-gateway v1.11.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
|
||||
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
|
||||
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
|
||||
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
|
||||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
|
||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk=
|
||||
github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjLBdCp5PRlCFijNjvcYANOZXzCfXwCM=
|
||||
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
|
||||
github.com/jcmturner/gofork v1.0.0 h1:J7uCkflzTEhUZ64xqKnkDxq3kzc96ajM1Gli5ktUem8=
|
||||
@@ -273,13 +337,19 @@ github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/U
|
||||
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
|
||||
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
|
||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||
github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
|
||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||
github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo=
|
||||
github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
|
||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||
github.com/karlseguin/ccache v2.0.3+incompatible h1:j68C9tWOROiOLWTS/kCGg9IcJG+ACqn5+0+t8Oh83UU=
|
||||
github.com/karlseguin/ccache v2.0.3+incompatible/go.mod h1:CM9tNPzT6EdRh14+jiW8mEF9mkNZuuE51qmgGYUB93w=
|
||||
@@ -304,6 +374,7 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGi
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
@@ -315,10 +386,17 @@ github.com/kurin/blazer v0.5.3/go.mod h1:4FCXMUWo9DllR2Do4TtBd377ezyAJ51vB5uTBjt
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
|
||||
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
|
||||
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
|
||||
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
||||
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
|
||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8=
|
||||
github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs=
|
||||
github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE=
|
||||
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
@@ -328,6 +406,7 @@ github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HN
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190805055040-f9202b1cfdeb h1:hXqqXzQtJbENrsb+rsIqkVqcg4FUJL0SQFGw08Dgivw=
|
||||
github.com/mattn/go-ieproxy v0.0.0-20190805055040-f9202b1cfdeb/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
@@ -337,7 +416,14 @@ github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/
|
||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
|
||||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
|
||||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@@ -349,21 +435,30 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nats-io/jwt v0.2.6/go.mod h1:mQxQ0uHQ9FhEVPIcTSKwx2lqZEpXWWcCgA7R6NrWvvY=
|
||||
github.com/nats-io/jwt v0.2.14 h1:wA50KvFz/JXGXMHRygTWsRGh/ixxgC5E3kHvmtGLNf4=
|
||||
github.com/nats-io/jwt v0.2.14/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||
github.com/nats-io/jwt v0.3.2 h1:+RB5hMpXUUA2dfxuhBTEkMOrYmM+gKIZYS1KjSostMI=
|
||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||
github.com/nats-io/nats-server/v2 v2.0.0/go.mod h1:RyVdsHHvY4B6c9pWG+uRLpZ0h0XsqiuKp2XCTurP5LI=
|
||||
github.com/nats-io/nats-server/v2 v2.0.4 h1:XOMeQRbhl1lGNTIctPhih6pTa15NGif54Uas6ZW5q7g=
|
||||
github.com/nats-io/nats-server/v2 v2.0.4/go.mod h1:AWdGEVbjKRS9ZIx4DSP5eKW48nfFm7q3uiSkP/1KD7M=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2 h1:i2Ly0B+1+rzNZHHWtD4ZwKi+OU5l+uQo1iDHZ2PmiIc=
|
||||
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
|
||||
github.com/nats-io/nats.go v1.8.1 h1:6lF/f1/NN6kzUDBz6pyvQDEXO39jqXcWRLu/tKjtOUQ=
|
||||
github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM=
|
||||
github.com/nats-io/nats.go v1.9.1 h1:ik3HbLhZ0YABLto7iX80pZLPw/6dx3T+++MZJwLnMrQ=
|
||||
github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w=
|
||||
github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M=
|
||||
github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4=
|
||||
github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4=
|
||||
github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nkeys v0.1.3 h1:6JrEfig+HzTH85yxzhSVbjHRJv9cn0p6n3IngIcM5/k=
|
||||
github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w=
|
||||
github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw=
|
||||
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
|
||||
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olivere/elastic/v7 v7.0.19 h1:w4F6JpqOISadhYf/n0NR1cNj73xHqh4pzPwD1Gkidts=
|
||||
github.com/olivere/elastic/v7 v7.0.19/go.mod h1:4Jqt5xvjqpjCqgnTcHwl3j8TLs8mvoOK8NYgo/qEOu4=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
@@ -373,45 +468,70 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
|
||||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
|
||||
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
|
||||
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
|
||||
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA=
|
||||
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
|
||||
github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
|
||||
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
|
||||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
|
||||
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
|
||||
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg=
|
||||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
|
||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||
github.com/peterh/liner v1.1.0 h1:f+aAedNJA6uk7+6rXsYBnhdo4Xux7ESLe+kcuVUF5os=
|
||||
github.com/peterh/liner v1.1.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
|
||||
github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pierrec/lz4 v2.2.7+incompatible h1:Eerk9aiqeZo2QzsbWOAsELUf9ddvAxEdMY9LYze/DEc=
|
||||
github.com/pierrec/lz4 v2.2.7+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
|
||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||
github.com/prometheus/client_golang v1.0.0 h1:vrDKnkGzuGvhNAL56c7DBz29ZL+KxnoR0x7enabFceM=
|
||||
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
github.com/prometheus/client_golang v1.1.0 h1:BQ53HtBmfOitExawJ6LokA4x8ov/z0SYYb0+HxJfRI8=
|
||||
github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g=
|
||||
github.com/prometheus/client_golang v1.3.0 h1:miYCvYqFXtl/J9FIy8eNpBfYthAEFg+Ys0XyUVEcDsc=
|
||||
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
|
||||
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 h1:S/YWwWx/RA8rT8tKFRuGUZhuA90OyIBpPCXkcbwU8DE=
|
||||
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.1.0 h1:ElTg5tNp4DqfV7UQjDqv2+RJlNzsDtvNAWccbItceIE=
|
||||
github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
||||
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.4.1 h1:K0MGApIoQvMw27RTdJkPbr3JZ7DNbtxQNyi5STVM6Kw=
|
||||
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
|
||||
github.com/prometheus/common v0.6.0 h1:kRhiuYSXR3+uv2IbVbZhUxK5zVD/2pp3Gd2PpvPkpEo=
|
||||
github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc=
|
||||
github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY=
|
||||
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
|
||||
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.2 h1:6LJUbpNm42llc4HRCuvApCSWB/WfhuNo9K98Q9sNGfs=
|
||||
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/prometheus/procfs v0.0.4 h1:w8DjqFMJDjuVwdZBQoOozr4MVWOnwF7RcL/7uxBjY78=
|
||||
github.com/prometheus/procfs v0.0.4/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
|
||||
github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8=
|
||||
github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A=
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ=
|
||||
github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc=
|
||||
@@ -423,25 +543,40 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
|
||||
github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/seaweedfs/fuse v0.0.0-20190510212405-310228904eff h1:uLd5zBvf5OA67wcVRePHrFt60bR4LSskaVhgVwyk0Jg=
|
||||
github.com/seaweedfs/fuse v0.0.0-20190510212405-310228904eff/go.mod h1:cubdLmQFqEUZ9vNJrznhgc3m3VMAJi/nY2Ix2axXkG0=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/seaweedfs/fuse v1.0.7 h1:tESMXhI3gXzN+dlWsCUrkIZDiWA4dZX18rQMoqmvazw=
|
||||
github.com/seaweedfs/fuse v1.0.7/go.mod h1:W7ubwr1l7KQsMeUpxFFOFOSxUL/ucTRMAlVYs4xdfQ8=
|
||||
github.com/seaweedfs/goexif v1.0.2 h1:p+rTXYdQ2mgxd+1JaTrQ9N8DvYuw9UH9xgYmJ+Bb29E=
|
||||
github.com/seaweedfs/goexif v1.0.2/go.mod h1:MrKs5LK0HXdffrdCZrW3OIMegL2xXpC6ThLyXMyjdrk=
|
||||
github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a h1:C6IhVTxNkhlb0tlCB6JfHOUv1f0xHPK7V8X4HlJZEJw=
|
||||
github.com/secsy/goftp v0.0.0-20190720192957-f31499d7c79a/go.mod h1:MnkX001NG75g3p8bhFycnyIjeQoOjGL6CEIsdE/nKSY=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0=
|
||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/smartystreets/gunit v1.3.4/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
|
||||
github.com/soheilhy/cmux v0.1.4 h1:0HKaf1o97UwFjHH9o5XsHUOF+tqmdA7KEzXLpiyaw0E=
|
||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||
github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
|
||||
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
|
||||
github.com/spf13/afero v1.3.1 h1:GPTpEAuNr98px18yNQ66JllNil98wfRZ/5Ukny8FeQA=
|
||||
github.com/spf13/afero v1.3.1/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
|
||||
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
|
||||
@@ -458,6 +593,7 @@ github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94 h1:0ngsPmuP6XIjiFRN
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271 h1:WhxRHzgeVGETMlmVfqhRn8RIeeNoPr2Czh33I4Zdccw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@@ -468,6 +604,10 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
|
||||
@@ -482,6 +622,15 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1
|
||||
github.com/ugorji/go v1.1.4 h1:j4s+tAvLfL3bZyefP2SEWmhBzmuIlH/eqNuPdFPgngw=
|
||||
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
|
||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/viant/assertly v0.5.4 h1:5Hh4U3pLZa6uhCFAGpYOxck/8l9TZczEzoHNfJAhHEQ=
|
||||
github.com/viant/assertly v0.5.4/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
||||
github.com/viant/ptrie v0.3.0 h1:SDaRd7Gqr1+ItCNz0GpTxRdK21nOfqjV6YtBm9jGlMY=
|
||||
github.com/viant/ptrie v0.3.0/go.mod h1:VguMnbGfz95Zw+V5VarYSqtqslDxJbOv++xLzxkMhec=
|
||||
github.com/viant/toolbox v0.33.2 h1:Av844IIeGz81gT672qZemyptGfbrcxqGymA5RFnIPjE=
|
||||
github.com/viant/toolbox v0.33.2/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
||||
github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc=
|
||||
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
|
||||
github.com/willf/bloom v2.0.3+incompatible h1:QDacWdqcAUI1MPOwIQZRy9kOR7yxfyEmxX8Wdm2/JPA=
|
||||
@@ -505,21 +654,29 @@ go.etcd.io/etcd v0.5.0-alpha.5.0.20200425165423-262c93980547/go.mod h1:YoUyTScD3
|
||||
go.mongodb.org/mongo-driver v1.3.2 h1:IYppNjEV/C+/3VPbhHVxQ4t04eVW0cLp0/pNdW++6Ug=
|
||||
go.mongodb.org/mongo-driver v1.3.2/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE=
|
||||
go.opencensus.io v0.15.0/go.mod h1:UffZAU+4sDEINUGP/B7UfBBkq4fqLu9zXAX7ke6CHW0=
|
||||
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0 h1:Ezj3JGmsOnG1MoRWQkPBsKLe9DwWD9QeXzTRzzldNVk=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0 h1:KCa4XfM8CWFCpxXRGok+Q0SS/0XBhMDbHHGABQLvD2A=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
go.uber.org/zap v1.14.1 h1:nYDKopTbvAPq/NrUVZwT15y2lpROBiLLyoRTbXOYWOo=
|
||||
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
|
||||
gocloud.dev v0.16.0 h1:hWeaQWxamGerwsU7B9xSWvUjx0p7TwG8fcHro2TzbbM=
|
||||
@@ -529,6 +686,7 @@ gocloud.dev/pubsub/natspubsub v0.16.0/go.mod h1:0n7pT7PkLMClBUHDrOkHfOFVr/o/6kaw
|
||||
gocloud.dev/pubsub/rabbitpubsub v0.16.0 h1:Bkv2njMSl2tmT3tGbvbwpiIDAXBIpqzP9dmts+rhD4E=
|
||||
gocloud.dev/pubsub/rabbitpubsub v0.16.0/go.mod h1:JJVdUUIqwgaaMJg/1xHQza0g4sI/4KHHSNiGE+pn4JM=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
@@ -538,8 +696,11 @@ golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8U
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5 h1:58fnuSXlxZmFdJyvtTFVmVhcMLU6v5fEb/ok4wyqtNU=
|
||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc h1:c0o/qxkaO2LF5t6fQrT4b5hzyggAkLLlCUjqfRxd8Q4=
|
||||
golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067 h1:KYGJGHOQy8oSi1fDlSpcZF0+juKwk/hEMv5SiwHogR0=
|
||||
@@ -556,12 +717,16 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
@@ -573,8 +738,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20190619014844-b5b0513f8c1b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b h1:XfVGCX+0T4WOStkaOsJRllbsiImhB2jgVBGc9L0lPGc=
|
||||
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
@@ -587,11 +752,17 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200930132711-30421366ff76 h1:JnxiSYT3Nm0BT2a8CyvYyM6cnrWpidecD1UuSYbhKm0=
|
||||
golang.org/x/sync v0.0.0-20200930132711-30421366ff76/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -607,9 +778,11 @@ golang.org/x/sys v0.0.0-20190620070143-6f217b454f45/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 h1:HyfiK1WMnHj5FXFXatD+Qs1A/xC2Run6RzeW1SyHxpc=
|
||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201022201747-fb209a7c41cd h1:WgqgiQvkiZWz7XLhphjt2GI2GcGCTIZs9jqXMWmH+oc=
|
||||
golang.org/x/sys v0.0.0-20201022201747-fb209a7c41cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
@@ -618,7 +791,10 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
@@ -626,6 +802,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
@@ -640,11 +817,15 @@ golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgw
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.5.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.6.0/go.mod h1:btoxGiFvQNVUZQ8W08zLtrVS08CNpINPEfxXxgJL1Q4=
|
||||
@@ -654,6 +835,7 @@ google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEn
|
||||
google.golang.org/api v0.9.0 h1:jbyannxz0XFD3zdjgrSUsaJbgpH4eTrkdhRChkHPfO8=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I=
|
||||
@@ -673,10 +855,13 @@ google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2El
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.23.0 h1:AzbTB6ux+okLTzP8Ru1Xs41C303zdcfEht7MQnYJt5A=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
@@ -704,9 +889,12 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/dutchcoders/goftp.v1 v1.0.0-20170301105846-ed59a591ce14 h1:tHqNpm9sPaE6BSuMLXBzgTwukQLdBEt4OYU2coQjEQQ=
|
||||
gopkg.in/dutchcoders/goftp.v1 v1.0.0-20170301105846-ed59a591ce14/go.mod h1:nzmlZQ+UqB5+55CRTV/dOaiK8OrPl6Co96Ob8lH4Wxw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
|
||||
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
|
||||
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
||||
gopkg.in/jcmturner/aescts.v1 v1.0.1 h1:cVVZBK2b1zY26haWB4vbBiZrfFQnfbTVrE3xZq6hrEw=
|
||||
@@ -726,10 +914,14 @@ gopkg.in/karlseguin/expect.v1 v1.0.1/go.mod h1:uB7QIJBcclvYbwlUDkSCsGjAOMis3fP28
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@@ -740,3 +932,4 @@ pack.ag/amqp v0.11.2/go.mod h1:4/cbmt4EJXSKlG6LCfWHoqmN0uFdy5i/+YFz+fTfhV4=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: v1
|
||||
description: SeaweedFS
|
||||
name: seaweedfs
|
||||
version: 1.88
|
||||
version: 2.11
|
||||
File diff suppressed because it is too large.
Load diff
@@ -111,4 +111,18 @@ Inject extra environment vars in the format key:value, if populated
|
||||
{{- $tag := .Values.global.imageTag | toString -}}
|
||||
{{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Return the proper cronjob image */}}
|
||||
{{- define "cronjob.image" -}}
|
||||
{{- if .Values.cronjob.imageOverride -}}
|
||||
{{- $imageOverride := .Values.cronjob.imageOverride -}}
|
||||
{{- printf "%s" $imageOverride -}}
|
||||
{{- else -}}
|
||||
{{- $registryName := default .Values.image.registry .Values.global.localRegistry | toString -}}
|
||||
{{- $repositoryName := .Values.image.repository | toString -}}
|
||||
{{- $name := .Values.global.imageName | toString -}}
|
||||
{{- $tag := .Values.global.imageTag | toString -}}
|
||||
{{- printf "%s%s%s:%s" $registryName $repositoryName $name $tag -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,54 @@
|
||||
{{- if .Values.cronjob }}
|
||||
{{- if .Values.cronjob.enabled }}
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: {{ include "seaweedfs.fullname" . }}-cronjob
|
||||
spec:
|
||||
schedule: "{{ .Values.cronjob.schedule }}"
|
||||
concurrencyPolicy: Forbid
|
||||
failedJobsHistoryLimit: 2
|
||||
successfulJobsHistoryLimit: 2
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 2
|
||||
template:
|
||||
spec:
|
||||
{{- with .Values.cronjob.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- with .Values.cronjob.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 12 }}
|
||||
{{- end }}
|
||||
restartPolicy: OnFailure
|
||||
containers:
|
||||
- name: shell
|
||||
image: {{ template "cronjob.image" . }}
|
||||
imagePullPolicy: {{ default "IfNotPresent" .Values.global.imagePullPolicy }}
|
||||
resources:
|
||||
{{- toYaml .Values.cronjob.resources| nindent 16 }}
|
||||
command:
|
||||
- sh
|
||||
- -c
|
||||
- |
|
||||
set -ex
|
||||
echo -e "lock\n\
|
||||
volume.balance -force\
|
||||
{{ if .Values.volume.dataCenter }} -dataCenter {{ .Values.volume.dataCenter }}{{ end }}\
|
||||
{{ if .Values.cronjob.collection }} -collection {{ .Values.cronjob.collection }}{{ end }}\n\
|
||||
volume.fix.replication\nunlock\n" | \
|
||||
/usr/bin/weed shell \
|
||||
{{- if .Values.cronjob.master }}
|
||||
-master {{ .Values.cronjob.master }} \
|
||||
{{- else }}
|
||||
-master {{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}.svc:{{ .Values.master.port }} \
|
||||
{{- end }}
|
||||
{{- if .Values.cronjob.filer }}
|
||||
-filer {{ .Values.cronjob.filer }}
|
||||
{{- else }}
|
||||
-filer {{ template "seaweedfs.name" . }}-filer.{{ .Release.Namespace }}.svc:{{ .Values.filer.port }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -17,6 +17,12 @@ spec:
|
||||
port: {{ .Values.filer.grpcPort }}
|
||||
targetPort: {{ .Values.filer.grpcPort }}
|
||||
protocol: TCP
|
||||
{{- if .Values.filer.metricsPort }}
|
||||
- name: "swfs-filer-metrics"
|
||||
port: {{ .Values.filer.metricsPort }}
|
||||
targetPort: {{ .Values.filer.metricsPort }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: filer
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- if .Values.filer.metricsPort }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "seaweedfs.name" . }}-filer
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: filer
|
||||
spec:
|
||||
endpoints:
|
||||
- interval: 30s
|
||||
port: swfs-filer-metrics
|
||||
scrapeTimeout: 5s
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: filer
|
||||
{{- end }}
|
||||
@@ -99,6 +99,12 @@ spec:
|
||||
{{- end }}
|
||||
filer \
|
||||
-port={{ .Values.filer.port }} \
|
||||
{{- if .Values.filer.metricsPort }}
|
||||
-metricsPort {{ .Values.filer.metricsPort }} \
|
||||
{{- end }}
|
||||
{{- if .Values.filer.redirectOnRead }}
|
||||
-redirectOnRead \
|
||||
{{- end }}
|
||||
{{- if .Values.filer.disableHttp }}
|
||||
-disableHttp \
|
||||
{{- end }}
|
||||
@@ -106,7 +112,24 @@ spec:
|
||||
-disableDirListing \
|
||||
{{- end }}
|
||||
-dirListLimit={{ .Values.filer.dirListLimit }} \
|
||||
{{- if .Values.global.enableReplication }}
|
||||
-defaultReplicaPlacement={{ .Values.global.replicationPlacment }} \
|
||||
{{- else }}
|
||||
-defaultReplicaPlacement={{ .Values.filer.defaultReplicaPlacement }} \
|
||||
{{- end }}
|
||||
{{- if .Values.filer.disableDirListing }}
|
||||
-disableDirListing \
|
||||
{{- end }}
|
||||
{{- if .Values.filer.maxMB }}
|
||||
-maxMB={{ .Values.filer.maxMB }} \
|
||||
{{- end }}
|
||||
{{- if .Values.filer.encryptVolumeData }}
|
||||
-encryptVolumeData \
|
||||
{{- end }}
|
||||
-ip=${POD_IP} \
|
||||
{{- if gt (.Values.filer.replicas | int) 1 }}
|
||||
-peers={{ range $index := until (.Values.filer.replicas | int) }}${SEAWEEDFS_FULLNAME}-filer-{{ $index }}.${SEAWEEDFS_FULLNAME}-filer:{{ $.Values.filer.port }}{{ if lt $index (sub ($.Values.filer.replicas | int) 1) }},{{ end }}{{ end }}
|
||||
{{- end }}
|
||||
-master={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}
|
||||
{{- if or (.Values.global.enableSecurity) (.Values.filer.extraVolumeMounts) }}
|
||||
volumeMounts:
|
||||
@@ -149,6 +172,7 @@ spec:
|
||||
periodSeconds: 15
|
||||
successThreshold: 1
|
||||
failureThreshold: 100
|
||||
timeoutSeconds: 3
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
@@ -158,6 +182,7 @@ spec:
|
||||
periodSeconds: 30
|
||||
successThreshold: 1
|
||||
failureThreshold: 5
|
||||
timeoutSeconds: 3
|
||||
{{- if .Values.filer.resources }}
|
||||
resources:
|
||||
{{ tpl .Values.filer.resources . | nindent 12 | trim }}
|
||||
|
||||
@@ -70,6 +70,12 @@ spec:
|
||||
fieldPath: metadata.namespace
|
||||
- name: SEAWEEDFS_FULLNAME
|
||||
value: "{{ template "seaweedfs.name" . }}"
|
||||
{{- if .Values.master.extraEnvironmentVars }}
|
||||
{{- range $key, $value := .Values.master.extraEnvironmentVars }}
|
||||
- name: {{ $key }}
|
||||
value: {{ $value | quote }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
command:
|
||||
- "/bin/sh"
|
||||
- "-ec"
|
||||
@@ -84,6 +90,11 @@ spec:
|
||||
-port={{ .Values.master.port }} \
|
||||
-mdir=/data \
|
||||
-ip.bind={{ .Values.master.ipBind }} \
|
||||
{{- if .Values.global.enableReplication }}
|
||||
-defaultReplication={{ .Values.global.replicationPlacment }} \
|
||||
{{- else }}
|
||||
-defaultReplication={{ .Values.master.defaultReplication }} \
|
||||
{{- end }}
|
||||
{{- if .Values.master.volumePreallocate }}
|
||||
-volumePreallocate \
|
||||
{{- end }}
|
||||
@@ -94,6 +105,15 @@ spec:
|
||||
{{- if .Values.master.disableHttp }}
|
||||
-disableHttp \
|
||||
{{- end }}
|
||||
{{- if .Values.master.pulseSeconds }}
|
||||
-pulseSeconds={{ .Values.master.pulseSeconds }} \
|
||||
{{- end }}
|
||||
{{- if .Values.master.garbageThreshold }}
|
||||
-garbageThreshold={{ .Values.master.garbageThreshold }} \
|
||||
{{- end }}
|
||||
{{- if .Values.master.metricsIntervalSec }}
|
||||
-metrics.intervalSeconds={{ .Values.master.metricsIntervalSec }} \
|
||||
{{- end }}
|
||||
-ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-master \
|
||||
-peers={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}
|
||||
volumeMounts:
|
||||
@@ -133,19 +153,21 @@ spec:
|
||||
path: /cluster/status
|
||||
port: {{ .Values.master.port }}
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 15
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 45
|
||||
successThreshold: 2
|
||||
failureThreshold: 100
|
||||
timeoutSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /cluster/status
|
||||
port: {{ .Values.master.port }}
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
periodSeconds: 30
|
||||
successThreshold: 1
|
||||
failureThreshold: 6
|
||||
failureThreshold: 4
|
||||
timeoutSeconds: 5
|
||||
{{- if .Values.master.resources }}
|
||||
resources:
|
||||
{{ tpl .Values.master.resources . | nindent 12 | trim }}
|
||||
|
||||
@@ -71,6 +71,9 @@ spec:
|
||||
{{- end }}
|
||||
s3 \
|
||||
-port={{ .Values.s3.port }} \
|
||||
{{- if .Values.s3.metricsPort }}
|
||||
-metricsPort {{ .Values.s3.metricsPort }} \
|
||||
{{- end }}
|
||||
{{- if .Values.global.enableSecurity }}
|
||||
-cert.file=/usr/local/share/ca-certificates/client/tls.crt \
|
||||
-key.file=/usr/local/share/ca-certificates/client/tls.key \
|
||||
@@ -116,6 +119,7 @@ spec:
|
||||
periodSeconds: 15
|
||||
successThreshold: 1
|
||||
failureThreshold: 100
|
||||
timeoutSeconds: 3
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
@@ -125,6 +129,7 @@ spec:
|
||||
periodSeconds: 60
|
||||
successThreshold: 1
|
||||
failureThreshold: 20
|
||||
timeoutSeconds: 3
|
||||
{{- if .Values.s3.resources }}
|
||||
resources:
|
||||
{{ tpl .Values.s3.resources . | nindent 12 | trim }}
|
||||
|
||||
@@ -12,6 +12,12 @@ spec:
|
||||
port: {{ .Values.s3.port }}
|
||||
targetPort: {{ .Values.s3.port }}
|
||||
protocol: TCP
|
||||
{{- if .Values.s3.metricsPort }}
|
||||
- name: "swfs-s3-metrics"
|
||||
port: {{ .Values.s3.metricsPort }}
|
||||
targetPort: {{ .Values.s3.metricsPort }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: s3
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- if .Values.s3.metricsPort }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "seaweedfs.name" . }}-s3
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: s3
|
||||
spec:
|
||||
endpoints:
|
||||
- interval: 30s
|
||||
port: swfs-s3-metrics
|
||||
scrapeTimeout: 5s
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: s3
|
||||
{{- end }}
|
||||
@@ -0,0 +1,20 @@
|
||||
{{- if .Values.global.monitoring.enabled }}
|
||||
{{- $files := .Files.Glob "dashboards/*.json" }}
|
||||
{{- if $files }}
|
||||
apiVersion: v1
|
||||
kind: ConfigMapList
|
||||
items:
|
||||
{{- range $path, $fileContents := $files }}
|
||||
{{- $dashboardName := regexReplaceAll "(^.*/)(.*)\\.json$" $path "${2}" }}
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ printf "%s" $dashboardName | lower | replace "_" "-" }}
|
||||
namespace: {{ $.Release.Namespace }}
|
||||
labels:
|
||||
grafana_dashboard: "1"
|
||||
data:
|
||||
{{ $dashboardName }}.json: {{ $.Files.Get $path | toJson }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -17,6 +17,12 @@ spec:
|
||||
port: {{ .Values.volume.grpcPort }}
|
||||
targetPort: {{ .Values.volume.grpcPort }}
|
||||
protocol: TCP
|
||||
selector:
|
||||
{{- if .Values.volume.metricsPort }}
|
||||
- name: "swfs-volume-metrics"
|
||||
port: {{ .Values.volume.metricsPort }}
|
||||
targetPort: {{ .Values.volume.metricsPort }}
|
||||
protocol: TCP
|
||||
{{- end }}
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: volume
|
||||
@@ -0,0 +1,18 @@
|
||||
{{- if .Values.volume.metricsPort }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "seaweedfs.name" . }}-volume
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: volume
|
||||
spec:
|
||||
endpoints:
|
||||
- interval: 30s
|
||||
port: swfs-volume-metrics
|
||||
scrapeTimeout: 5s
|
||||
selector:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
component: volume
|
||||
{{- end }}
|
||||
@@ -12,6 +12,7 @@ metadata:
|
||||
spec:
|
||||
serviceName: {{ template "seaweedfs.name" . }}-volume
|
||||
replicas: {{ .Values.volume.replicas }}
|
||||
podManagementPolicy: Parallel
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ template "seaweedfs.name" . }}
|
||||
@@ -33,7 +34,7 @@ spec:
|
||||
restartPolicy: {{ default .Values.global.restartPolicy .Values.volume.restartPolicy }}
|
||||
{{- if .Values.volume.tolerations }}
|
||||
tolerations:
|
||||
{{ tpl .Values.volume.tolerations . | nindent 8 | trim }}
|
||||
{{ tpl .Values.volume.tolerations . | nindent 8 | trim }}
|
||||
{{- end }}
|
||||
{{- if .Values.global.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
@@ -62,7 +63,7 @@ spec:
|
||||
fieldRef:
|
||||
fieldPath: status.hostIP
|
||||
- name: SEAWEEDFS_FULLNAME
|
||||
value: "{{ template "seaweedfs.name" . }}"
|
||||
value: "{{ template "seaweedfs.name" . }}"
|
||||
command:
|
||||
- "/bin/sh"
|
||||
- "-ec"
|
||||
@@ -75,6 +76,9 @@ spec:
|
||||
{{- end }}
|
||||
volume \
|
||||
-port={{ .Values.volume.port }} \
|
||||
{{- if .Values.volume.metricsPort }}
|
||||
-metricsPort {{ .Values.volume.metricsPort }} \
|
||||
{{- end }}
|
||||
-dir={{ .Values.volume.dir }} \
|
||||
-max={{ .Values.volume.maxVolumes }} \
|
||||
{{- if .Values.volume.rack }}
|
||||
@@ -91,6 +95,16 @@ spec:
|
||||
{{- if .Values.volume.imagesFixOrientation }}
|
||||
-images.fix.orientation \
|
||||
{{- end }}
|
||||
{{- if .Values.volume.pulseSeconds }}
|
||||
-pulseSeconds={{ .Values.volume.pulseSeconds }} \
|
||||
{{- end }}
|
||||
{{- if .Values.volume.index }}
|
||||
-index={{ .Values.volume.index }} \
|
||||
{{- end }}
|
||||
{{- if .Values.volume.fileSizeLimitMB }}
|
||||
-fileSizeLimitMB={{ .Values.volume.fileSizeLimitMB }} \
|
||||
{{- end }}
|
||||
-minFreeSpacePercent={{ .Values.volume.minFreeSpacePercent }} \
|
||||
-ip=${POD_NAME}.${SEAWEEDFS_FULLNAME}-volume \
|
||||
-compactionMBps={{ .Values.volume.compactionMBps }} \
|
||||
-mserver={{ range $index := until (.Values.master.replicas | int) }}${SEAWEEDFS_FULLNAME}-master-{{ $index }}.${SEAWEEDFS_FULLNAME}-master:{{ $.Values.master.port }}{{ if lt $index (sub ($.Values.master.replicas | int) 1) }},{{ end }}{{ end }}
|
||||
@@ -131,19 +145,21 @@ spec:
|
||||
path: /status
|
||||
port: {{ .Values.volume.port }}
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 15
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 90
|
||||
successThreshold: 1
|
||||
failureThreshold: 100
|
||||
timeoutSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /status
|
||||
port: {{ .Values.volume.port }}
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 30
|
||||
periodSeconds: 90
|
||||
successThreshold: 1
|
||||
failureThreshold: 10
|
||||
failureThreshold: 4
|
||||
timeoutSeconds: 5
|
||||
{{- if .Values.volume.resources }}
|
||||
resources:
|
||||
{{ tpl .Values.volume.resources . | nindent 12 | trim }}
|
||||
|
||||
@@ -4,7 +4,7 @@ global:
|
||||
registry: ""
|
||||
repository: ""
|
||||
imageName: chrislusf/seaweedfs
|
||||
imageTag: "1.88"
|
||||
imageTag: "2.11"
|
||||
imagePullPolicy: IfNotPresent
|
||||
imagePullSecrets: imagepullsecret
|
||||
restartPolicy: Always
|
||||
@@ -14,6 +14,13 @@ global:
|
||||
enabled: false
|
||||
gatewayHost: null
|
||||
gatewayPort: null
|
||||
# if enabled will use global.replicationPlacment and override master & filer defaultReplicaPlacement config
|
||||
enableReplication: false
|
||||
# replication type is XYZ:
|
||||
# X number of replica in other data centers
|
||||
# Y number of replica in other racks in the same data center
|
||||
# Z number of replica in other servers in the same rack
|
||||
replicationPlacment: "001"
|
||||
|
||||
image:
|
||||
registry: ""
|
||||
@@ -31,8 +38,20 @@ master:
|
||||
grpcPort: 19333
|
||||
ipBind: "0.0.0.0"
|
||||
volumePreallocate: false
|
||||
#Master stops directing writes to oversized volumes
|
||||
volumeSizeLimitMB: 30000
|
||||
loggingOverrideLevel: null
|
||||
#number of seconds between heartbeats, default 5
|
||||
pulseSeconds: null
|
||||
#threshold to vacuum and reclaim spaces, default 0.3 (30%)
|
||||
garbageThreshold: null
|
||||
#Prometheus push interval in seconds, default 15
|
||||
metricsIntervalSec: 15
|
||||
# replication type is XYZ:
|
||||
# X number of replica in other data centers
|
||||
# Y number of replica in other racks in the same data center
|
||||
# Z number of replica in other servers in the same rack
|
||||
defaultReplication: "000"
|
||||
|
||||
# Disable http request, only gRpc operations are allowed
|
||||
disableHttp: false
|
||||
@@ -87,6 +106,11 @@ master:
|
||||
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
|
||||
priorityClassName: ""
|
||||
|
||||
extraEnvironmentVars:
|
||||
WEED_MASTER_VOLUME_GROWTH_COPY_1: 7
|
||||
WEED_MASTER_VOLUME_GROWTH_COPY_2: 6
|
||||
WEED_MASTER_VOLUME_GROWTH_COPY_3: 3
|
||||
WEED_MASTER_VOLUME_GROWTH_COPY_OTHER: 1
|
||||
|
||||
volume:
|
||||
enabled: true
|
||||
@@ -97,12 +121,22 @@ volume:
|
||||
restartPolicy: null
|
||||
port: 8080
|
||||
grpcPort: 18080
|
||||
metricsPort: 9327
|
||||
ipBind: "0.0.0.0"
|
||||
replicas: 1
|
||||
loggingOverrideLevel: null
|
||||
# number of seconds between heartbeats, must be smaller than or equal to the master's setting
|
||||
pulseSeconds: null
|
||||
# Choose [memory|leveldb|leveldbMedium|leveldbLarge] mode for memory~performance balance., default memory
|
||||
index: null
|
||||
# limit file size to avoid out of memory, default 256mb
|
||||
fileSizeLimitMB: null
|
||||
# minimum free disk space(in percents). If free disk space lower this value - all volumes marks as ReadOnly
|
||||
minFreeSpacePercent: 1
|
||||
|
||||
|
||||
# limit background compaction or copying speed in mega bytes per second
|
||||
compactionMBps: "40"
|
||||
compactionMBps: "50"
|
||||
|
||||
# Directories to store data files. dir[,dir]... (default "/tmp")
|
||||
dir: "/data"
|
||||
@@ -176,7 +210,22 @@ filer:
|
||||
replicas: 1
|
||||
port: 8888
|
||||
grpcPort: 18888
|
||||
metricsPort: 9327
|
||||
loggingOverrideLevel: null
|
||||
# replication type is XYZ:
|
||||
# X number of replica in other data centers
|
||||
# Y number of replica in other racks in the same data center
|
||||
# Z number of replica in other servers in the same rack
|
||||
defaultReplicaPlacement: "000"
|
||||
# turn off directory listing
|
||||
disableDirListing: false
|
||||
# split files larger than the limit, default 32
|
||||
maxMB: null
|
||||
# encrypt data on volume servers
|
||||
encryptVolumeData: false
|
||||
|
||||
# Whether proxy or redirect to volume server during file GET request
|
||||
redirectOnRead: false
|
||||
|
||||
# Limit sub dir listing size (default 100000)
|
||||
dirListLimit: 100000
|
||||
@@ -237,11 +286,6 @@ filer:
|
||||
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
|
||||
priorityClassName: ""
|
||||
|
||||
dbSchema:
|
||||
imageName: db-schema
|
||||
imageTag: "development"
|
||||
imageOverride: ""
|
||||
|
||||
# extraEnvVars is a list of extra enviroment variables to set with the stateful set.
|
||||
extraEnvironmentVars:
|
||||
WEED_MYSQL_ENABLED: "true"
|
||||
@@ -260,6 +304,8 @@ filer:
|
||||
WEED_FILER_BUCKETS_FOLDER: "/buckets"
|
||||
# directories under this folder will be store message queue data
|
||||
WEED_FILER_QUEUES_FOLDER: "/queues"
|
||||
# WEED_FILER_OPTIONS_BUCKETS_FSYNC a list of buckets names with all write requests fsync=true
|
||||
WEED_FILER_OPTIONS_BUCKETS_FSYNC: []
|
||||
|
||||
s3:
|
||||
enabled: true
|
||||
@@ -269,6 +315,7 @@ s3:
|
||||
restartPolicy: null
|
||||
replicas: 1
|
||||
port: 8333
|
||||
metricsPort: 9327
|
||||
loggingOverrideLevel: null
|
||||
|
||||
# Suffix of the host name, {bucket}.{domainName}
|
||||
@@ -300,6 +347,19 @@ s3:
|
||||
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/
|
||||
priorityClassName: ""
|
||||
|
||||
cronjob:
|
||||
enabled: false
|
||||
schedule: "*/7 * * * *"
|
||||
resources: null
|
||||
# balance all volumes among volume servers
|
||||
# ALL|EACH_COLLECTION|<collection_name>
|
||||
collection: ""
|
||||
master: ""
|
||||
filer: ""
|
||||
tolerations: ""
|
||||
nodeSelector: |
|
||||
sw-backend: "true"
|
||||
|
||||
certificates:
|
||||
commonName: "SeaweedFS CA"
|
||||
ipAddresses: []
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
<artifactId>seaweedfs-client</artifactId>
|
||||
<version>1.4.4</version>
|
||||
<version>1.5.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
@@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
<artifactId>seaweedfs-client</artifactId>
|
||||
<version>1.4.4</version>
|
||||
<version>1.5.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
<artifactId>seaweedfs-client</artifactId>
|
||||
<version>1.4.4</version>
|
||||
<version>1.5.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
@@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -15,7 +15,6 @@ public class ChunkCache {
|
||||
}
|
||||
this.cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(maxEntries)
|
||||
.weakValues()
|
||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class FileChunkManifest {
|
||||
}
|
||||
|
||||
public static List<FilerProto.FileChunk> maybeManifestize(
|
||||
final FilerGrpcClient filerGrpcClient, List<FilerProto.FileChunk> inputChunks) throws IOException {
|
||||
final FilerGrpcClient filerGrpcClient, List<FilerProto.FileChunk> inputChunks, String parentDirectory) throws IOException {
|
||||
// the return variable
|
||||
List<FilerProto.FileChunk> chunks = new ArrayList<>();
|
||||
|
||||
@@ -101,7 +101,7 @@ public class FileChunkManifest {
|
||||
|
||||
int remaining = dataChunks.size();
|
||||
for (int i = 0; i + mergeFactor < dataChunks.size(); i += mergeFactor) {
|
||||
FilerProto.FileChunk chunk = mergeIntoManifest(filerGrpcClient, dataChunks.subList(i, i + mergeFactor));
|
||||
FilerProto.FileChunk chunk = mergeIntoManifest(filerGrpcClient, dataChunks.subList(i, i + mergeFactor), parentDirectory);
|
||||
chunks.add(chunk);
|
||||
remaining -= mergeFactor;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class FileChunkManifest {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
private static FilerProto.FileChunk mergeIntoManifest(final FilerGrpcClient filerGrpcClient, List<FilerProto.FileChunk> dataChunks) throws IOException {
|
||||
private static FilerProto.FileChunk mergeIntoManifest(final FilerGrpcClient filerGrpcClient, List<FilerProto.FileChunk> dataChunks, String parentDirectory) throws IOException {
|
||||
// create and serialize the manifest
|
||||
dataChunks = FilerClient.beforeEntrySerialization(dataChunks);
|
||||
FilerProto.FileChunkManifest.Builder m = FilerProto.FileChunkManifest.newBuilder().addAllChunks(dataChunks);
|
||||
@@ -130,7 +130,7 @@ public class FileChunkManifest {
|
||||
filerGrpcClient.getReplication(),
|
||||
filerGrpcClient,
|
||||
minOffset,
|
||||
data, 0, data.length);
|
||||
data, 0, data.length, parentDirectory);
|
||||
manifestChunk.setIsChunkManifest(true);
|
||||
manifestChunk.setSize(maxOffset - minOffset);
|
||||
return manifestChunk.build();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package seaweedfs.client;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -272,15 +273,20 @@ public class FilerClient {
|
||||
|
||||
public boolean createEntry(String parent, FilerProto.Entry entry) {
|
||||
try {
|
||||
filerGrpcClient.getBlockingStub().createEntry(FilerProto.CreateEntryRequest.newBuilder()
|
||||
.setDirectory(parent)
|
||||
.setEntry(entry)
|
||||
.build());
|
||||
FilerProto.CreateEntryResponse createEntryResponse =
|
||||
filerGrpcClient.getBlockingStub().createEntry(FilerProto.CreateEntryRequest.newBuilder()
|
||||
.setDirectory(parent)
|
||||
.setEntry(entry)
|
||||
.build());
|
||||
if (Strings.isNullOrEmpty(createEntryResponse.getError())) {
|
||||
return true;
|
||||
}
|
||||
LOG.warn("createEntry {}/{} error: {}", parent, entry.getName(), createEntryResponse.getError());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
LOG.warn("createEntry {}/{}: {}", parent, entry.getName(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean updateEntry(String parent, FilerProto.Entry entry) {
|
||||
@@ -290,7 +296,7 @@ public class FilerClient {
|
||||
.setEntry(entry)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
LOG.warn("createEntry {}/{}: {}", parent, entry.getName(), e);
|
||||
LOG.warn("updateEntry {}/{}: {}", parent, entry.getName(), e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -327,4 +333,13 @@ public class FilerClient {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Iterator<FilerProto.SubscribeMetadataResponse> watch(String prefix, String clientName, long sinceNs) {
|
||||
return filerGrpcClient.getBlockingStub().subscribeMetadata(FilerProto.SubscribeMetadataRequest.newBuilder()
|
||||
.setPathPrefix(prefix)
|
||||
.setClientName(clientName)
|
||||
.setSinceNs(sinceNs)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,47 +19,73 @@ public class SeaweedRead {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SeaweedRead.class);
|
||||
|
||||
static ChunkCache chunkCache = new ChunkCache(4);
|
||||
static VolumeIdCache volumeIdCache = new VolumeIdCache(4 * 1024);
|
||||
|
||||
// returns bytesRead
|
||||
public static long read(FilerGrpcClient filerGrpcClient, List<VisibleInterval> visibleIntervals,
|
||||
final long position, final byte[] buffer, final int bufferOffset,
|
||||
final int bufferLength) throws IOException {
|
||||
final int bufferLength, final long fileSize) throws IOException {
|
||||
|
||||
List<ChunkView> chunkViews = viewFromVisibles(visibleIntervals, position, bufferLength);
|
||||
|
||||
FilerProto.LookupVolumeRequest.Builder lookupRequest = FilerProto.LookupVolumeRequest.newBuilder();
|
||||
for (ChunkView chunkView : chunkViews) {
|
||||
String vid = parseVolumeId(chunkView.fileId);
|
||||
lookupRequest.addVolumeIds(vid);
|
||||
if (volumeIdCache.getLocations(vid)==null){
|
||||
lookupRequest.addVolumeIds(vid);
|
||||
}
|
||||
}
|
||||
|
||||
FilerProto.LookupVolumeResponse lookupResponse = filerGrpcClient
|
||||
.getBlockingStub().lookupVolume(lookupRequest.build());
|
||||
|
||||
Map<String, FilerProto.Locations> vid2Locations = lookupResponse.getLocationsMapMap();
|
||||
if (lookupRequest.getVolumeIdsCount()>0){
|
||||
FilerProto.LookupVolumeResponse lookupResponse = filerGrpcClient
|
||||
.getBlockingStub().lookupVolume(lookupRequest.build());
|
||||
Map<String, FilerProto.Locations> vid2Locations = lookupResponse.getLocationsMapMap();
|
||||
for (Map.Entry<String,FilerProto.Locations> entry : vid2Locations.entrySet()) {
|
||||
volumeIdCache.setLocations(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO parallel this
|
||||
long readCount = 0;
|
||||
int startOffset = bufferOffset;
|
||||
long startOffset = position;
|
||||
for (ChunkView chunkView : chunkViews) {
|
||||
FilerProto.Locations locations = vid2Locations.get(parseVolumeId(chunkView.fileId));
|
||||
|
||||
if (startOffset < chunkView.logicOffset) {
|
||||
long gap = chunkView.logicOffset - startOffset;
|
||||
LOG.debug("zero [{},{})", startOffset, startOffset + gap);
|
||||
readCount += gap;
|
||||
startOffset += gap;
|
||||
}
|
||||
|
||||
FilerProto.Locations locations = volumeIdCache.getLocations(parseVolumeId(chunkView.fileId));
|
||||
if (locations == null || locations.getLocationsCount() == 0) {
|
||||
LOG.error("failed to locate {}", chunkView.fileId);
|
||||
// log here!
|
||||
return 0;
|
||||
}
|
||||
|
||||
int len = readChunkView(position, buffer, startOffset, chunkView, locations);
|
||||
int len = readChunkView(startOffset, buffer, bufferOffset + readCount, chunkView, locations);
|
||||
|
||||
LOG.debug("read [{},{}) {} size {}", startOffset, startOffset + len, chunkView.fileId, chunkView.size);
|
||||
|
||||
readCount += len;
|
||||
startOffset += len;
|
||||
|
||||
}
|
||||
|
||||
long limit = Math.min(bufferOffset + bufferLength, fileSize);
|
||||
|
||||
if (startOffset < limit) {
|
||||
long gap = limit - startOffset;
|
||||
LOG.debug("zero2 [{},{})", startOffset, startOffset + gap);
|
||||
readCount += gap;
|
||||
startOffset += gap;
|
||||
}
|
||||
|
||||
return readCount;
|
||||
}
|
||||
|
||||
private static int readChunkView(long position, byte[] buffer, int startOffset, ChunkView chunkView, FilerProto.Locations locations) throws IOException {
|
||||
private static int readChunkView(long startOffset, byte[] buffer, long bufOffset, ChunkView chunkView, FilerProto.Locations locations) throws IOException {
|
||||
|
||||
byte[] chunkData = chunkCache.getChunk(chunkView.fileId);
|
||||
|
||||
@@ -69,17 +95,51 @@ public class SeaweedRead {
|
||||
}
|
||||
|
||||
int len = (int) chunkView.size;
|
||||
LOG.debug("readChunkView fid:{} chunkData.length:{} chunkView.offset:{} buffer.length:{} startOffset:{} len:{}",
|
||||
chunkView.fileId, chunkData.length, chunkView.offset, buffer.length, startOffset, len);
|
||||
System.arraycopy(chunkData, (int) chunkView.offset, buffer, startOffset, len);
|
||||
LOG.debug("readChunkView fid:{} chunkData.length:{} chunkView.offset:{} chunkView[{};{}) buf[{},{})/{} startOffset:{}",
|
||||
chunkView.fileId, chunkData.length, chunkView.offset, chunkView.logicOffset, chunkView.logicOffset + chunkView.size, bufOffset, bufOffset + len, buffer.length, startOffset);
|
||||
System.arraycopy(chunkData, (int) (startOffset - chunkView.logicOffset + chunkView.offset), buffer, (int) bufOffset, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
public static byte[] doFetchFullChunkData(ChunkView chunkView, FilerProto.Locations locations) throws IOException {
|
||||
|
||||
HttpGet request = new HttpGet(
|
||||
String.format("http://%s/%s", locations.getLocations(0).getUrl(), chunkView.fileId));
|
||||
byte[] data = null;
|
||||
IOException lastException = null;
|
||||
for (long waitTime = 1000L; waitTime < 10 * 1000; waitTime += waitTime / 2) {
|
||||
for (FilerProto.Location location : locations.getLocationsList()) {
|
||||
String url = String.format("http://%s/%s", location.getUrl(), chunkView.fileId);
|
||||
try {
|
||||
data = doFetchOneFullChunkData(chunkView, url);
|
||||
lastException = null;
|
||||
break;
|
||||
} catch (IOException ioe) {
|
||||
LOG.debug("doFetchFullChunkData {} :{}", url, ioe);
|
||||
lastException = ioe;
|
||||
}
|
||||
}
|
||||
if (data != null) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(waitTime);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (lastException != null) {
|
||||
throw lastException;
|
||||
}
|
||||
|
||||
LOG.debug("doFetchFullChunkData fid:{} chunkData.length:{}", chunkView.fileId, data.length);
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
public static byte[] doFetchOneFullChunkData(ChunkView chunkView, String url) throws IOException {
|
||||
|
||||
HttpGet request = new HttpGet(url);
|
||||
|
||||
request.setHeader(HttpHeaders.ACCEPT_ENCODING, "gzip");
|
||||
|
||||
@@ -93,7 +153,7 @@ public class SeaweedRead {
|
||||
Header contentEncodingHeader = entity.getContentEncoding();
|
||||
|
||||
if (contentEncodingHeader != null) {
|
||||
HeaderElement[] encodings =contentEncodingHeader.getElements();
|
||||
HeaderElement[] encodings = contentEncodingHeader.getElements();
|
||||
for (int i = 0; i < encodings.length; i++) {
|
||||
if (encodings[i].getName().equalsIgnoreCase("gzip")) {
|
||||
entity = new GzipDecompressingEntity(entity);
|
||||
@@ -123,7 +183,7 @@ public class SeaweedRead {
|
||||
data = Gzip.decompress(data);
|
||||
}
|
||||
|
||||
LOG.debug("doFetchFullChunkData fid:{} chunkData.length:{}", chunkView.fileId, data.length);
|
||||
LOG.debug("doFetchOneFullChunkData url:{} chunkData.length:{}", url, data.length);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -134,18 +194,19 @@ public class SeaweedRead {
|
||||
|
||||
long stop = offset + size;
|
||||
for (VisibleInterval chunk : visibleIntervals) {
|
||||
if (chunk.start <= offset && offset < chunk.stop && offset < stop) {
|
||||
long chunkStart = Math.max(offset, chunk.start);
|
||||
long chunkStop = Math.min(stop, chunk.stop);
|
||||
if (chunkStart < chunkStop) {
|
||||
boolean isFullChunk = chunk.isFullChunk && chunk.start == offset && chunk.stop <= stop;
|
||||
views.add(new ChunkView(
|
||||
chunk.fileId,
|
||||
offset - chunk.start,
|
||||
Math.min(chunk.stop, stop) - offset,
|
||||
offset,
|
||||
chunkStart - chunk.start + chunk.chunkOffset,
|
||||
chunkStop - chunkStart,
|
||||
chunkStart,
|
||||
isFullChunk,
|
||||
chunk.cipherKey,
|
||||
chunk.isCompressed
|
||||
));
|
||||
offset = Math.min(chunk.stop, stop);
|
||||
}
|
||||
}
|
||||
return views;
|
||||
@@ -160,7 +221,13 @@ public class SeaweedRead {
|
||||
Arrays.sort(chunks, new Comparator<FilerProto.FileChunk>() {
|
||||
@Override
|
||||
public int compare(FilerProto.FileChunk a, FilerProto.FileChunk b) {
|
||||
return (int) (a.getMtime() - b.getMtime());
|
||||
// if just a.getMtime() - b.getMtime(), it will overflow!
|
||||
if (a.getMtime() < b.getMtime()) {
|
||||
return -1;
|
||||
} else if (a.getMtime() > b.getMtime()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -181,6 +248,7 @@ public class SeaweedRead {
|
||||
chunk.getOffset() + chunk.getSize(),
|
||||
chunk.getFileId(),
|
||||
chunk.getMtime(),
|
||||
0,
|
||||
true,
|
||||
chunk.getCipherKey().toByteArray(),
|
||||
chunk.getIsCompressed()
|
||||
@@ -203,6 +271,7 @@ public class SeaweedRead {
|
||||
chunk.getOffset(),
|
||||
v.fileId,
|
||||
v.modifiedTime,
|
||||
v.chunkOffset,
|
||||
false,
|
||||
v.cipherKey,
|
||||
v.isCompressed
|
||||
@@ -215,6 +284,7 @@ public class SeaweedRead {
|
||||
v.stop,
|
||||
v.fileId,
|
||||
v.modifiedTime,
|
||||
v.chunkOffset + (chunkStop - v.start),
|
||||
false,
|
||||
v.cipherKey,
|
||||
v.isCompressed
|
||||
@@ -247,6 +317,10 @@ public class SeaweedRead {
|
||||
return fileId;
|
||||
}
|
||||
|
||||
public static long fileSize(FilerProto.Entry entry) {
|
||||
return Math.max(totalSize(entry.getChunksList()), entry.getAttributes().getFileSize());
|
||||
}
|
||||
|
||||
public static long totalSize(List<FilerProto.FileChunk> chunksList) {
|
||||
long size = 0;
|
||||
for (FilerProto.FileChunk chunk : chunksList) {
|
||||
@@ -263,15 +337,17 @@ public class SeaweedRead {
|
||||
public final long stop;
|
||||
public final long modifiedTime;
|
||||
public final String fileId;
|
||||
public final long chunkOffset;
|
||||
public final boolean isFullChunk;
|
||||
public final byte[] cipherKey;
|
||||
public final boolean isCompressed;
|
||||
|
||||
public VisibleInterval(long start, long stop, String fileId, long modifiedTime, boolean isFullChunk, byte[] cipherKey, boolean isCompressed) {
|
||||
public VisibleInterval(long start, long stop, String fileId, long modifiedTime, long chunkOffset, boolean isFullChunk, byte[] cipherKey, boolean isCompressed) {
|
||||
this.start = start;
|
||||
this.stop = stop;
|
||||
this.modifiedTime = modifiedTime;
|
||||
this.fileId = fileId;
|
||||
this.chunkOffset = chunkOffset;
|
||||
this.isFullChunk = isFullChunk;
|
||||
this.cipherKey = cipherKey;
|
||||
this.isCompressed = isCompressed;
|
||||
|
||||
@@ -26,9 +26,10 @@ public class SeaweedWrite {
|
||||
final FilerGrpcClient filerGrpcClient,
|
||||
final long offset,
|
||||
final byte[] bytes,
|
||||
final long bytesOffset, final long bytesLength) throws IOException {
|
||||
final long bytesOffset, final long bytesLength,
|
||||
final String path) throws IOException {
|
||||
FilerProto.FileChunk.Builder chunkBuilder = writeChunk(
|
||||
replication, filerGrpcClient, offset, bytes, bytesOffset, bytesLength);
|
||||
replication, filerGrpcClient, offset, bytes, bytesOffset, bytesLength, path);
|
||||
synchronized (entry) {
|
||||
entry.addChunks(chunkBuilder);
|
||||
}
|
||||
@@ -39,13 +40,15 @@ public class SeaweedWrite {
|
||||
final long offset,
|
||||
final byte[] bytes,
|
||||
final long bytesOffset,
|
||||
final long bytesLength) throws IOException {
|
||||
final long bytesLength,
|
||||
final String path) throws IOException {
|
||||
FilerProto.AssignVolumeResponse response = filerGrpcClient.getBlockingStub().assignVolume(
|
||||
FilerProto.AssignVolumeRequest.newBuilder()
|
||||
.setCollection(filerGrpcClient.getCollection())
|
||||
.setReplication(replication == null ? filerGrpcClient.getReplication() : replication)
|
||||
.setDataCenter("")
|
||||
.setTtlSec(0)
|
||||
.setPath(path)
|
||||
.build());
|
||||
String fileId = response.getFileId();
|
||||
String url = response.getUrl();
|
||||
@@ -77,7 +80,7 @@ public class SeaweedWrite {
|
||||
final FilerProto.Entry.Builder entry) throws IOException {
|
||||
|
||||
synchronized (entry) {
|
||||
List<FilerProto.FileChunk> chunks = FileChunkManifest.maybeManifestize(filerGrpcClient, entry.getChunksList());
|
||||
List<FilerProto.FileChunk> chunks = FileChunkManifest.maybeManifestize(filerGrpcClient, entry.getChunksList(), parentDirectory);
|
||||
entry.clearChunks();
|
||||
entry.addAllChunks(chunks);
|
||||
filerGrpcClient.getBlockingStub().createEntry(
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package seaweedfs.client;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class VolumeIdCache {
|
||||
|
||||
private Cache<String, FilerProto.Locations> cache = null;
|
||||
|
||||
public VolumeIdCache(int maxEntries) {
|
||||
if (maxEntries == 0) {
|
||||
return;
|
||||
}
|
||||
this.cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(maxEntries)
|
||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||
.build();
|
||||
}
|
||||
|
||||
public FilerProto.Locations getLocations(String volumeId) {
|
||||
if (this.cache == null) {
|
||||
return null;
|
||||
}
|
||||
return this.cache.getIfPresent(volumeId);
|
||||
}
|
||||
|
||||
public void setLocations(String volumeId, FilerProto.Locations locations) {
|
||||
if (this.cache == null) {
|
||||
return;
|
||||
}
|
||||
this.cache.put(volumeId, locations);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,6 +37,9 @@ service SeaweedFiler {
|
||||
rpc LookupVolume (LookupVolumeRequest) returns (LookupVolumeResponse) {
|
||||
}
|
||||
|
||||
rpc CollectionList (CollectionListRequest) returns (CollectionListResponse) {
|
||||
}
|
||||
|
||||
rpc DeleteCollection (DeleteCollectionRequest) returns (DeleteCollectionResponse) {
|
||||
}
|
||||
|
||||
@@ -58,6 +61,12 @@ service SeaweedFiler {
|
||||
rpc LocateBroker (LocateBrokerRequest) returns (LocateBrokerResponse) {
|
||||
}
|
||||
|
||||
rpc KvGet (KvGetRequest) returns (KvGetResponse) {
|
||||
}
|
||||
|
||||
rpc KvPut (KvPutRequest) returns (KvPutResponse) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
@@ -89,6 +98,8 @@ message Entry {
|
||||
repeated FileChunk chunks = 3;
|
||||
FuseAttributes attributes = 4;
|
||||
map<string, bytes> extended = 5;
|
||||
bytes hard_link_id = 7;
|
||||
int32 hard_link_counter = 8; // only exists in hard link meta data
|
||||
}
|
||||
|
||||
message FullEntry {
|
||||
@@ -102,6 +113,7 @@ message EventNotification {
|
||||
bool delete_chunks = 3;
|
||||
string new_parent_path = 4;
|
||||
bool is_from_other_cluster = 5;
|
||||
repeated int32 signatures = 6;
|
||||
}
|
||||
|
||||
message FileChunk {
|
||||
@@ -150,6 +162,7 @@ message CreateEntryRequest {
|
||||
Entry entry = 2;
|
||||
bool o_excl = 3;
|
||||
bool is_from_other_cluster = 4;
|
||||
repeated int32 signatures = 5;
|
||||
}
|
||||
|
||||
message CreateEntryResponse {
|
||||
@@ -160,6 +173,7 @@ message UpdateEntryRequest {
|
||||
string directory = 1;
|
||||
Entry entry = 2;
|
||||
bool is_from_other_cluster = 3;
|
||||
repeated int32 signatures = 4;
|
||||
}
|
||||
message UpdateEntryResponse {
|
||||
}
|
||||
@@ -180,6 +194,7 @@ message DeleteEntryRequest {
|
||||
bool is_recursive = 5;
|
||||
bool ignore_recursive_error = 6;
|
||||
bool is_from_other_cluster = 7;
|
||||
repeated int32 signatures = 8;
|
||||
}
|
||||
|
||||
message DeleteEntryResponse {
|
||||
@@ -202,7 +217,8 @@ message AssignVolumeRequest {
|
||||
string replication = 3;
|
||||
int32 ttl_sec = 4;
|
||||
string data_center = 5;
|
||||
string parent_path = 6;
|
||||
string path = 6;
|
||||
string rack = 7;
|
||||
}
|
||||
|
||||
message AssignVolumeResponse {
|
||||
@@ -232,6 +248,16 @@ message LookupVolumeResponse {
|
||||
map<string, Locations> locations_map = 1;
|
||||
}
|
||||
|
||||
message Collection {
|
||||
string name = 1;
|
||||
}
|
||||
message CollectionListRequest {
|
||||
bool include_normal_volumes = 1;
|
||||
bool include_ec_volumes = 2;
|
||||
}
|
||||
message CollectionListResponse {
|
||||
repeated Collection collections = 1;
|
||||
}
|
||||
message DeleteCollectionRequest {
|
||||
string collection = 1;
|
||||
}
|
||||
@@ -262,12 +288,16 @@ message GetFilerConfigurationResponse {
|
||||
uint32 max_mb = 4;
|
||||
string dir_buckets = 5;
|
||||
bool cipher = 7;
|
||||
int32 signature = 8;
|
||||
string metrics_address = 9;
|
||||
int32 metrics_interval_sec = 10;
|
||||
}
|
||||
|
||||
message SubscribeMetadataRequest {
|
||||
string client_name = 1;
|
||||
string path_prefix = 2;
|
||||
int64 since_ns = 3;
|
||||
int32 signature = 4;
|
||||
}
|
||||
message SubscribeMetadataResponse {
|
||||
string directory = 1;
|
||||
@@ -302,3 +332,37 @@ message LocateBrokerResponse {
|
||||
}
|
||||
repeated Resource resources = 2;
|
||||
}
|
||||
|
||||
// Key-Value operations
|
||||
message KvGetRequest {
|
||||
bytes key = 1;
|
||||
}
|
||||
message KvGetResponse {
|
||||
bytes value = 1;
|
||||
string error = 2;
|
||||
}
|
||||
message KvPutRequest {
|
||||
bytes key = 1;
|
||||
bytes value = 2;
|
||||
}
|
||||
message KvPutResponse {
|
||||
string error = 1;
|
||||
}
|
||||
|
||||
// path-based configurations
|
||||
message FilerConf {
|
||||
int32 version = 1;
|
||||
message PathConf {
|
||||
string location_prefix = 1;
|
||||
string collection = 2;
|
||||
string replication = 3;
|
||||
string ttl = 4;
|
||||
enum DiskType {
|
||||
HDD = 0;
|
||||
SSD = 1;
|
||||
}
|
||||
DiskType disk_type = 5;
|
||||
bool fsync = 6;
|
||||
}
|
||||
repeated PathConf locations = 2;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>unzip</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
<artifactId>seaweedfs-client</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
<artifactId>seaweedfs-hadoop2-client</artifactId>
|
||||
<version>1.5.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.seaweedfs.examples;
|
||||
|
||||
import seaweed.hdfs.SeaweedInputStream;
|
||||
import seaweedfs.client.FilerClient;
|
||||
import seaweedfs.client.FilerGrpcClient;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class UnzipFile {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
FilerGrpcClient filerGrpcClient = new FilerGrpcClient("localhost", 18888);
|
||||
FilerClient filerClient = new FilerClient(filerGrpcClient);
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
parseZip("/Users/chris/tmp/test.zip");
|
||||
|
||||
long startTime2 = System.currentTimeMillis();
|
||||
|
||||
long localProcessTime = startTime2 - startTime;
|
||||
|
||||
SeaweedInputStream seaweedInputStream = new SeaweedInputStream(
|
||||
filerGrpcClient,
|
||||
new org.apache.hadoop.fs.FileSystem.Statistics(""),
|
||||
"/",
|
||||
filerClient.lookupEntry("/", "test.zip")
|
||||
);
|
||||
parseZip(seaweedInputStream);
|
||||
|
||||
long swProcessTime = System.currentTimeMillis() - startTime2;
|
||||
|
||||
System.out.println("Local time: " + localProcessTime);
|
||||
System.out.println("SeaweedFS time: " + swProcessTime);
|
||||
|
||||
}
|
||||
|
||||
public static void parseZip(String filename) throws IOException {
|
||||
FileInputStream fileInputStream = new FileInputStream(filename);
|
||||
parseZip(fileInputStream);
|
||||
}
|
||||
|
||||
public static void parseZip(InputStream is) throws IOException {
|
||||
ZipInputStream zin = new ZipInputStream(is);
|
||||
ZipEntry ze;
|
||||
while ((ze = zin.getNextEntry()) != null) {
|
||||
System.out.println(ze.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.seaweedfs.examples;
|
||||
|
||||
import seaweedfs.client.FilerClient;
|
||||
import seaweedfs.client.FilerProto;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class WatchFiles {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
|
||||
FilerClient filerClient = new FilerClient("localhost", 18888);
|
||||
|
||||
long sinceNs = (System.currentTimeMillis() - 3600 * 1000) * 1000000L;
|
||||
|
||||
Iterator<FilerProto.SubscribeMetadataResponse> watch = filerClient.watch(
|
||||
"/buckets",
|
||||
"exampleClientName",
|
||||
sinceNs
|
||||
);
|
||||
|
||||
System.out.println("Connected to filer, subscribing from " + new Date());
|
||||
|
||||
while (watch.hasNext()) {
|
||||
FilerProto.SubscribeMetadataResponse event = watch.next();
|
||||
FilerProto.EventNotification notification = event.getEventNotification();
|
||||
if (!event.getDirectory().equals(notification.getNewParentPath())) {
|
||||
// move an entry to a new directory, possibly with a new name
|
||||
if (notification.hasOldEntry() && notification.hasNewEntry()) {
|
||||
System.out.println("moved " + event.getDirectory() + "/" + notification.getOldEntry().getName() + " to " + notification.getNewParentPath() + "/" + notification.getNewEntry().getName());
|
||||
} else {
|
||||
System.out.println("this should not happen.");
|
||||
}
|
||||
} else if (notification.hasNewEntry() && !notification.hasOldEntry()) {
|
||||
System.out.println("created entry " + event.getDirectory() + "/" + notification.getNewEntry().getName());
|
||||
} else if (!notification.hasNewEntry() && notification.hasOldEntry()) {
|
||||
System.out.println("deleted entry " + event.getDirectory() + "/" + notification.getOldEntry().getName());
|
||||
} else if (notification.hasNewEntry() && notification.hasOldEntry()) {
|
||||
System.out.println("updated entry " + event.getDirectory() + "/" + notification.getNewEntry().getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,180 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-hdfs-client</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-mapreduce-client-app</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-yarn-api</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-mapreduce-client-core</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-mapreduce-client-jobclient</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-annotations</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<groupId>commons-cli</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>xmlenc</artifactId>
|
||||
<groupId>xmlenc</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<groupId>commons-net</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>commons-collections</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty</artifactId>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-sslengine</artifactId>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jets3t</artifactId>
|
||||
<groupId>net.java.dev.jets3t</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<groupId>commons-configuration</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>avro</artifactId>
|
||||
<groupId>org.apache.avro</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-auth</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsch</artifactId>
|
||||
<groupId>com.jcraft</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>curator-client</artifactId>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>curator-recipes</artifactId>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>htrace-core4</artifactId>
|
||||
<groupId>org.apache.htrace</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>stax2-api</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-annotations</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
@@ -127,7 +301,7 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<seaweedfs.client.version>1.4.4</seaweedfs.client.version>
|
||||
<seaweedfs.client.version>1.5.4</seaweedfs.client.version>
|
||||
<hadoop.version>2.9.2</hadoop.version>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<seaweedfs.client.version>1.4.4</seaweedfs.client.version>
|
||||
<seaweedfs.client.version>1.5.4</seaweedfs.client.version>
|
||||
<hadoop.version>2.9.2</hadoop.version>
|
||||
</properties>
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
<version>${hadoop.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
@@ -157,6 +158,7 @@
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
<version>${hadoop.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.apache.hadoop.fs.*;
|
||||
import org.apache.hadoop.fs.permission.AclEntry;
|
||||
import org.apache.hadoop.fs.permission.AclStatus;
|
||||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.security.AccessControlException;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.util.Progressable;
|
||||
import org.slf4j.Logger;
|
||||
@@ -14,20 +13,19 @@ import seaweedfs.client.FilerProto;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY;
|
||||
|
||||
public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
public static final int FS_SEAWEED_DEFAULT_PORT = 8888;
|
||||
public static final String FS_SEAWEED_FILER_HOST = "fs.seaweed.filer.host";
|
||||
public static final String FS_SEAWEED_FILER_PORT = "fs.seaweed.filer.port";
|
||||
public static final int FS_SEAWEED_DEFAULT_PORT = 8888;
|
||||
public static final String FS_SEAWEED_BUFFER_SIZE = "fs.seaweed.buffer.size";
|
||||
public static final int FS_SEAWEED_DEFAULT_BUFFER_SIZE = 4 * 1024 * 1024;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SeaweedFileSystem.class);
|
||||
|
||||
@@ -63,10 +61,16 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
setConf(conf);
|
||||
this.uri = uri;
|
||||
|
||||
seaweedFileSystemStore = new SeaweedFileSystemStore(host, port);
|
||||
seaweedFileSystemStore = new SeaweedFileSystemStore(host, port, conf);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
this.seaweedFileSystemStore.close();
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
|
||||
|
||||
@@ -75,8 +79,9 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
path = qualify(path);
|
||||
|
||||
try {
|
||||
FSInputStream inputStream = seaweedFileSystemStore.openFileForRead(path, statistics, bufferSize);
|
||||
return new FSDataInputStream(new BufferedFSInputStream(inputStream, 16 * 1024 * 1024));
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
FSInputStream inputStream = seaweedFileSystemStore.openFileForRead(path, statistics);
|
||||
return new FSDataInputStream(new BufferedFSInputStream(inputStream, 4 * seaweedBufferSize));
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("open path: {} bufferSize:{}", path, bufferSize, ex);
|
||||
return null;
|
||||
@@ -93,7 +98,8 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
try {
|
||||
String replicaPlacement = String.format("%03d", replication - 1);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, overwrite, permission, bufferSize, replicaPlacement);
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, overwrite, permission, seaweedBufferSize, replicaPlacement);
|
||||
return new FSDataOutputStream(outputStream, statistics);
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("create path: {} bufferSize:{} blockSize:{}", path, bufferSize, blockSize, ex);
|
||||
@@ -103,8 +109,9 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws FileNotFoundException if the parent directory is not present -or
|
||||
* is not a directory.
|
||||
* is not a directory.
|
||||
*/
|
||||
@Override
|
||||
public FSDataOutputStream createNonRecursive(Path path,
|
||||
@@ -121,9 +128,10 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
throw new FileAlreadyExistsException("Not a directory: " + parent);
|
||||
}
|
||||
}
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
return create(path, permission,
|
||||
flags.contains(CreateFlag.OVERWRITE), bufferSize,
|
||||
replication, blockSize, progress);
|
||||
replication, seaweedBufferSize, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +141,8 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
path = qualify(path);
|
||||
try {
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, false, null, bufferSize, "");
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, false, null, seaweedBufferSize, "");
|
||||
return new FSDataOutputStream(outputStream, statistics);
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("append path: {} bufferSize:{}", path, bufferSize, ex);
|
||||
@@ -338,9 +347,7 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public void createSymlink(final Path target, final Path link,
|
||||
final boolean createParent) throws AccessControlException,
|
||||
FileAlreadyExistsException, FileNotFoundException,
|
||||
ParentNotDirectoryException, UnsupportedFileSystemException,
|
||||
final boolean createParent) throws
|
||||
IOException {
|
||||
// Supporting filesystems should override this method
|
||||
throw new UnsupportedOperationException(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package seaweed.hdfs;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSInputStream;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
@@ -8,30 +9,39 @@ import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seaweedfs.client.FilerClient;
|
||||
import seaweedfs.client.FilerGrpcClient;
|
||||
import seaweedfs.client.FilerProto;
|
||||
import seaweedfs.client.SeaweedRead;
|
||||
import seaweedfs.client.*;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static seaweed.hdfs.SeaweedFileSystem.FS_SEAWEED_BUFFER_SIZE;
|
||||
import static seaweed.hdfs.SeaweedFileSystem.FS_SEAWEED_DEFAULT_BUFFER_SIZE;
|
||||
|
||||
public class SeaweedFileSystemStore {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SeaweedFileSystemStore.class);
|
||||
|
||||
private FilerGrpcClient filerGrpcClient;
|
||||
private FilerClient filerClient;
|
||||
private Configuration conf;
|
||||
|
||||
public SeaweedFileSystemStore(String host, int port) {
|
||||
public SeaweedFileSystemStore(String host, int port, Configuration conf) {
|
||||
int grpcPort = 10000 + port;
|
||||
filerGrpcClient = new FilerGrpcClient(host, grpcPort);
|
||||
filerClient = new FilerClient(filerGrpcClient);
|
||||
this.conf = conf;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
this.filerGrpcClient.shutdown();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getParentDirectory(Path path) {
|
||||
@@ -124,10 +134,10 @@ public class SeaweedFileSystemStore {
|
||||
|
||||
private FileStatus doGetFileStatus(Path path, FilerProto.Entry entry) {
|
||||
FilerProto.FuseAttributes attributes = entry.getAttributes();
|
||||
long length = SeaweedRead.totalSize(entry.getChunksList());
|
||||
long length = SeaweedRead.fileSize(entry);
|
||||
boolean isDir = entry.getIsDirectory();
|
||||
int block_replication = 1;
|
||||
int blocksize = 512;
|
||||
int blocksize = this.conf.getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
long modification_time = attributes.getMtime() * 1000; // milliseconds
|
||||
long access_time = 0;
|
||||
FsPermission permission = FsPermission.createImmutable((short) attributes.getFileMode());
|
||||
@@ -185,7 +195,7 @@ public class SeaweedFileSystemStore {
|
||||
entry.mergeFrom(existingEntry);
|
||||
entry.getAttributesBuilder().setMtime(now);
|
||||
LOG.debug("createFile merged entry path:{} entry:{} from:{}", path, entry, existingEntry);
|
||||
writePosition = SeaweedRead.totalSize(existingEntry.getChunksList());
|
||||
writePosition = SeaweedRead.fileSize(existingEntry);
|
||||
replication = existingEntry.getAttributes().getReplication();
|
||||
}
|
||||
}
|
||||
@@ -202,16 +212,16 @@ public class SeaweedFileSystemStore {
|
||||
.clearGroupName()
|
||||
.addAllGroupName(Arrays.asList(userGroupInformation.getGroupNames()))
|
||||
);
|
||||
SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);
|
||||
}
|
||||
|
||||
return new SeaweedOutputStream(filerGrpcClient, path, entry, writePosition, bufferSize, replication);
|
||||
|
||||
}
|
||||
|
||||
public FSInputStream openFileForRead(final Path path, FileSystem.Statistics statistics,
|
||||
int bufferSize) throws IOException {
|
||||
public FSInputStream openFileForRead(final Path path, FileSystem.Statistics statistics) throws IOException {
|
||||
|
||||
LOG.debug("openFileForRead path:{} bufferSize:{}", path, bufferSize);
|
||||
LOG.debug("openFileForRead path:{}", path);
|
||||
|
||||
FilerProto.Entry entry = lookupEntry(path);
|
||||
|
||||
@@ -222,8 +232,7 @@ public class SeaweedFileSystemStore {
|
||||
return new SeaweedInputStream(filerGrpcClient,
|
||||
statistics,
|
||||
path.toUri().getPath(),
|
||||
entry,
|
||||
bufferSize);
|
||||
entry);
|
||||
}
|
||||
|
||||
public void setOwner(Path path, String owner, String group) {
|
||||
|
||||
@@ -25,7 +25,6 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
private final FilerProto.Entry entry;
|
||||
private final List<SeaweedRead.VisibleInterval> visibleIntervalList;
|
||||
private final long contentLength;
|
||||
private final int bufferSize; // default buffer size
|
||||
|
||||
private long position = 0; // cursor of the file
|
||||
|
||||
@@ -35,14 +34,12 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
final FilerGrpcClient filerGrpcClient,
|
||||
final Statistics statistics,
|
||||
final String path,
|
||||
final FilerProto.Entry entry,
|
||||
final int bufferSize) throws IOException {
|
||||
final FilerProto.Entry entry) throws IOException {
|
||||
this.filerGrpcClient = filerGrpcClient;
|
||||
this.statistics = statistics;
|
||||
this.path = path;
|
||||
this.entry = entry;
|
||||
this.contentLength = SeaweedRead.totalSize(entry.getChunksList());
|
||||
this.bufferSize = bufferSize;
|
||||
this.contentLength = SeaweedRead.fileSize(entry);
|
||||
|
||||
this.visibleIntervalList = SeaweedRead.nonOverlappingVisibleIntervals(filerGrpcClient, entry.getChunksList());
|
||||
|
||||
@@ -87,7 +84,7 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
throw new IllegalArgumentException("requested read length is more than will fit after requested offset in buffer");
|
||||
}
|
||||
|
||||
long bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len);
|
||||
long bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len, SeaweedRead.fileSize(entry));
|
||||
if (bytesRead > Integer.MAX_VALUE) {
|
||||
throw new IOException("Unexpected Content-Length");
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public class SeaweedOutputStream extends OutputStream {
|
||||
}
|
||||
final Future<Void> job = completionService.submit(() -> {
|
||||
// System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
|
||||
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit());
|
||||
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit(), path.toUri().getPath());
|
||||
// System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
|
||||
ByteBufferPool.release(bufferToWrite);
|
||||
return null;
|
||||
|
||||
@@ -120,6 +120,188 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-hdfs-client</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-yarn-api</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-yarn-client</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-mapreduce-client-core</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-mapreduce-client-jobclient</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-annotations</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<groupId>commons-cli</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-net</artifactId>
|
||||
<groupId>commons-net</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<groupId>commons-collections</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<groupId>javax.servlet</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-util</artifactId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsp-api</artifactId>
|
||||
<groupId>javax.servlet.jsp</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-core</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-servlet</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-json</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>log4j</artifactId>
|
||||
<groupId>log4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>avro</artifactId>
|
||||
<groupId>org.apache.avro</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>re2j</artifactId>
|
||||
<groupId>com.google.re2j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-auth</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jsch</artifactId>
|
||||
<groupId>com.jcraft</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>curator-client</artifactId>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>curator-recipes</artifactId>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>htrace-core4</artifactId>
|
||||
<groupId>org.apache.htrace</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-compress</artifactId>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>kerb-simplekdc</artifactId>
|
||||
<groupId>org.apache.kerby</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>stax2-api</artifactId>
|
||||
<groupId>org.codehaus.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>woodstox-core</artifactId>
|
||||
<groupId>com.fasterxml.woodstox</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>hadoop-annotations</artifactId>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
@@ -127,7 +309,7 @@
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<seaweedfs.client.version>1.4.4</seaweedfs.client.version>
|
||||
<seaweedfs.client.version>1.5.4</seaweedfs.client.version>
|
||||
<hadoop.version>3.1.1</hadoop.version>
|
||||
</properties>
|
||||
</project>
|
||||
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<seaweedfs.client.version>1.4.4</seaweedfs.client.version>
|
||||
<seaweedfs.client.version>1.5.4</seaweedfs.client.version>
|
||||
<hadoop.version>3.1.1</hadoop.version>
|
||||
</properties>
|
||||
|
||||
@@ -147,6 +147,7 @@
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
<version>${hadoop.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.chrislusf</groupId>
|
||||
@@ -157,6 +158,7 @@
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-common</artifactId>
|
||||
<version>${hadoop.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.apache.hadoop.fs.*;
|
||||
import org.apache.hadoop.fs.permission.AclEntry;
|
||||
import org.apache.hadoop.fs.permission.AclStatus;
|
||||
import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.security.AccessControlException;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.util.Progressable;
|
||||
import org.slf4j.Logger;
|
||||
@@ -14,20 +13,19 @@ import seaweedfs.client.FilerProto;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URI;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY;
|
||||
|
||||
public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
public static final int FS_SEAWEED_DEFAULT_PORT = 8888;
|
||||
public static final String FS_SEAWEED_FILER_HOST = "fs.seaweed.filer.host";
|
||||
public static final String FS_SEAWEED_FILER_PORT = "fs.seaweed.filer.port";
|
||||
public static final int FS_SEAWEED_DEFAULT_PORT = 8888;
|
||||
public static final String FS_SEAWEED_BUFFER_SIZE = "fs.seaweed.buffer.size";
|
||||
public static final int FS_SEAWEED_DEFAULT_BUFFER_SIZE = 4 * 1024 * 1024;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SeaweedFileSystem.class);
|
||||
|
||||
@@ -63,10 +61,16 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
setConf(conf);
|
||||
this.uri = uri;
|
||||
|
||||
seaweedFileSystemStore = new SeaweedFileSystemStore(host, port);
|
||||
seaweedFileSystemStore = new SeaweedFileSystemStore(host, port, conf);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
this.seaweedFileSystemStore.close();
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FSDataInputStream open(Path path, int bufferSize) throws IOException {
|
||||
|
||||
@@ -75,8 +79,9 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
path = qualify(path);
|
||||
|
||||
try {
|
||||
FSInputStream inputStream = seaweedFileSystemStore.openFileForRead(path, statistics, bufferSize);
|
||||
return new FSDataInputStream(new BufferedFSInputStream(inputStream, 16 * 1024 * 1024));
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
FSInputStream inputStream = seaweedFileSystemStore.openFileForRead(path, statistics);
|
||||
return new FSDataInputStream(new BufferedFSInputStream(inputStream, 4 * seaweedBufferSize));
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("open path: {} bufferSize:{}", path, bufferSize, ex);
|
||||
return null;
|
||||
@@ -93,7 +98,8 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
try {
|
||||
String replicaPlacement = String.format("%03d", replication - 1);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, overwrite, permission, bufferSize, replicaPlacement);
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, overwrite, permission, seaweedBufferSize, replicaPlacement);
|
||||
return new FSDataOutputStream(outputStream, statistics);
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("create path: {} bufferSize:{} blockSize:{}", path, bufferSize, blockSize, ex);
|
||||
@@ -103,8 +109,9 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws FileNotFoundException if the parent directory is not present -or
|
||||
* is not a directory.
|
||||
* is not a directory.
|
||||
*/
|
||||
@Override
|
||||
public FSDataOutputStream createNonRecursive(Path path,
|
||||
@@ -121,9 +128,10 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
throw new FileAlreadyExistsException("Not a directory: " + parent);
|
||||
}
|
||||
}
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
return create(path, permission,
|
||||
flags.contains(CreateFlag.OVERWRITE), bufferSize,
|
||||
replication, blockSize, progress);
|
||||
replication, seaweedBufferSize, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,7 +141,8 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
path = qualify(path);
|
||||
try {
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, false, null, bufferSize, "");
|
||||
int seaweedBufferSize = this.getConf().getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
OutputStream outputStream = seaweedFileSystemStore.createFile(path, false, null, seaweedBufferSize, "");
|
||||
return new FSDataOutputStream(outputStream, statistics);
|
||||
} catch (Exception ex) {
|
||||
LOG.warn("append path: {} bufferSize:{}", path, bufferSize, ex);
|
||||
@@ -338,9 +347,7 @@ public class SeaweedFileSystem extends FileSystem {
|
||||
|
||||
@Override
|
||||
public void createSymlink(final Path target, final Path link,
|
||||
final boolean createParent) throws AccessControlException,
|
||||
FileAlreadyExistsException, FileNotFoundException,
|
||||
ParentNotDirectoryException, UnsupportedFileSystemException,
|
||||
final boolean createParent) throws
|
||||
IOException {
|
||||
// Supporting filesystems should override this method
|
||||
throw new UnsupportedOperationException(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package seaweed.hdfs;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FSInputStream;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
@@ -8,30 +9,39 @@ import org.apache.hadoop.fs.permission.FsPermission;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import seaweedfs.client.FilerClient;
|
||||
import seaweedfs.client.FilerGrpcClient;
|
||||
import seaweedfs.client.FilerProto;
|
||||
import seaweedfs.client.SeaweedRead;
|
||||
import seaweedfs.client.*;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static seaweed.hdfs.SeaweedFileSystem.FS_SEAWEED_BUFFER_SIZE;
|
||||
import static seaweed.hdfs.SeaweedFileSystem.FS_SEAWEED_DEFAULT_BUFFER_SIZE;
|
||||
|
||||
public class SeaweedFileSystemStore {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SeaweedFileSystemStore.class);
|
||||
|
||||
private FilerGrpcClient filerGrpcClient;
|
||||
private FilerClient filerClient;
|
||||
private Configuration conf;
|
||||
|
||||
public SeaweedFileSystemStore(String host, int port) {
|
||||
public SeaweedFileSystemStore(String host, int port, Configuration conf) {
|
||||
int grpcPort = 10000 + port;
|
||||
filerGrpcClient = new FilerGrpcClient(host, grpcPort);
|
||||
filerClient = new FilerClient(filerGrpcClient);
|
||||
this.conf = conf;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
try {
|
||||
this.filerGrpcClient.shutdown();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getParentDirectory(Path path) {
|
||||
@@ -124,10 +134,10 @@ public class SeaweedFileSystemStore {
|
||||
|
||||
private FileStatus doGetFileStatus(Path path, FilerProto.Entry entry) {
|
||||
FilerProto.FuseAttributes attributes = entry.getAttributes();
|
||||
long length = SeaweedRead.totalSize(entry.getChunksList());
|
||||
long length = SeaweedRead.fileSize(entry);
|
||||
boolean isDir = entry.getIsDirectory();
|
||||
int block_replication = 1;
|
||||
int blocksize = 512;
|
||||
int blocksize = this.conf.getInt(FS_SEAWEED_BUFFER_SIZE, FS_SEAWEED_DEFAULT_BUFFER_SIZE);
|
||||
long modification_time = attributes.getMtime() * 1000; // milliseconds
|
||||
long access_time = 0;
|
||||
FsPermission permission = FsPermission.createImmutable((short) attributes.getFileMode());
|
||||
@@ -185,7 +195,7 @@ public class SeaweedFileSystemStore {
|
||||
entry.mergeFrom(existingEntry);
|
||||
entry.getAttributesBuilder().setMtime(now);
|
||||
LOG.debug("createFile merged entry path:{} entry:{} from:{}", path, entry, existingEntry);
|
||||
writePosition = SeaweedRead.totalSize(existingEntry.getChunksList());
|
||||
writePosition = SeaweedRead.fileSize(existingEntry);
|
||||
replication = existingEntry.getAttributes().getReplication();
|
||||
}
|
||||
}
|
||||
@@ -202,16 +212,16 @@ public class SeaweedFileSystemStore {
|
||||
.clearGroupName()
|
||||
.addAllGroupName(Arrays.asList(userGroupInformation.getGroupNames()))
|
||||
);
|
||||
SeaweedWrite.writeMeta(filerGrpcClient, getParentDirectory(path), entry);
|
||||
}
|
||||
|
||||
return new SeaweedOutputStream(filerGrpcClient, path, entry, writePosition, bufferSize, replication);
|
||||
|
||||
}
|
||||
|
||||
public FSInputStream openFileForRead(final Path path, FileSystem.Statistics statistics,
|
||||
int bufferSize) throws IOException {
|
||||
public FSInputStream openFileForRead(final Path path, FileSystem.Statistics statistics) throws IOException {
|
||||
|
||||
LOG.debug("openFileForRead path:{} bufferSize:{}", path, bufferSize);
|
||||
LOG.debug("openFileForRead path:{}", path);
|
||||
|
||||
FilerProto.Entry entry = lookupEntry(path);
|
||||
|
||||
@@ -222,8 +232,7 @@ public class SeaweedFileSystemStore {
|
||||
return new SeaweedInputStream(filerGrpcClient,
|
||||
statistics,
|
||||
path.toUri().getPath(),
|
||||
entry,
|
||||
bufferSize);
|
||||
entry);
|
||||
}
|
||||
|
||||
public void setOwner(Path path, String owner, String group) {
|
||||
|
||||
@@ -25,7 +25,6 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
private final FilerProto.Entry entry;
|
||||
private final List<SeaweedRead.VisibleInterval> visibleIntervalList;
|
||||
private final long contentLength;
|
||||
private final int bufferSize; // default buffer size
|
||||
|
||||
private long position = 0; // cursor of the file
|
||||
|
||||
@@ -35,14 +34,12 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
final FilerGrpcClient filerGrpcClient,
|
||||
final Statistics statistics,
|
||||
final String path,
|
||||
final FilerProto.Entry entry,
|
||||
final int bufferSize) throws IOException {
|
||||
final FilerProto.Entry entry) throws IOException {
|
||||
this.filerGrpcClient = filerGrpcClient;
|
||||
this.statistics = statistics;
|
||||
this.path = path;
|
||||
this.entry = entry;
|
||||
this.contentLength = SeaweedRead.totalSize(entry.getChunksList());
|
||||
this.bufferSize = bufferSize;
|
||||
this.contentLength = SeaweedRead.fileSize(entry);
|
||||
|
||||
this.visibleIntervalList = SeaweedRead.nonOverlappingVisibleIntervals(filerGrpcClient, entry.getChunksList());
|
||||
|
||||
@@ -87,7 +84,7 @@ public class SeaweedInputStream extends FSInputStream {
|
||||
throw new IllegalArgumentException("requested read length is more than will fit after requested offset in buffer");
|
||||
}
|
||||
|
||||
long bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len);
|
||||
long bytesRead = SeaweedRead.read(this.filerGrpcClient, this.visibleIntervalList, this.position, b, off, len, SeaweedRead.fileSize(entry));
|
||||
if (bytesRead > Integer.MAX_VALUE) {
|
||||
throw new IOException("Unexpected Content-Length");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@@ -232,7 +231,7 @@ public class SeaweedOutputStream extends OutputStream implements Syncable, Strea
|
||||
}
|
||||
final Future<Void> job = completionService.submit(() -> {
|
||||
// System.out.println(path + " is going to save [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
|
||||
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit());
|
||||
SeaweedWrite.writeData(entry, replication, filerGrpcClient, writePosition, bufferToWrite.array(), bufferToWrite.position(), bufferToWrite.limit(), path.toUri().getPath());
|
||||
// System.out.println(path + " saved [" + (writePosition) + "," + ((writePosition) + bytesLength) + ")");
|
||||
ByteBufferPool.release(bufferToWrite);
|
||||
return null;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.seaweedfs.test</groupId>
|
||||
<artifactId>random_access</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<guava.version>28.0-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.esotericsoftware.kryo</groupId>
|
||||
<artifactId>kryo</artifactId>
|
||||
<version>2.24.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.6.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+753
@@ -0,0 +1,753 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import seaweedfs.client.btree.serialize.Serializer;
|
||||
import seaweedfs.client.btree.serialize.kryo.KryoBackedDecoder;
|
||||
import seaweedfs.client.btree.serialize.kryo.KryoBackedEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
// todo - stream serialised value to file
|
||||
// todo - handle hash collisions (properly, this time)
|
||||
// todo - don't store null links to child blocks in leaf index blocks
|
||||
// todo - align block boundaries
|
||||
// todo - thread safety control
|
||||
// todo - merge small values into a single data block
|
||||
// todo - discard when file corrupt
|
||||
// todo - include data directly in index entry when serializer can guarantee small fixed sized data
|
||||
// todo - free list leaks disk space
|
||||
// todo - merge adjacent free blocks
|
||||
// todo - use more efficient lookup for free block with nearest size
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BTreePersistentIndexedCache<K, V> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BTreePersistentIndexedCache.class);
|
||||
private final File cacheFile;
|
||||
private final KeyHasher<K> keyHasher;
|
||||
private final Serializer<V> serializer;
|
||||
private final short maxChildIndexEntries;
|
||||
private final int minIndexChildNodes;
|
||||
private final StateCheckBlockStore store;
|
||||
private HeaderBlock header;
|
||||
|
||||
public BTreePersistentIndexedCache(File cacheFile, Serializer<K> keySerializer, Serializer<V> valueSerializer) {
|
||||
this(cacheFile, keySerializer, valueSerializer, (short) 512, 512);
|
||||
}
|
||||
|
||||
public BTreePersistentIndexedCache(File cacheFile, Serializer<K> keySerializer, Serializer<V> valueSerializer,
|
||||
short maxChildIndexEntries, int maxFreeListEntries) {
|
||||
this.cacheFile = cacheFile;
|
||||
this.keyHasher = new KeyHasher<K>(keySerializer);
|
||||
this.serializer = valueSerializer;
|
||||
this.maxChildIndexEntries = maxChildIndexEntries;
|
||||
this.minIndexChildNodes = maxChildIndexEntries / 2;
|
||||
BlockStore cachingStore = new CachingBlockStore(new FileBackedBlockStore(cacheFile), ImmutableSet.of(IndexBlock.class, FreeListBlockStore.FreeListBlock.class));
|
||||
this.store = new StateCheckBlockStore(new FreeListBlockStore(cachingStore, maxFreeListEntries));
|
||||
try {
|
||||
open();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(String.format("Could not open %s.", this), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "cache " + cacheFile.getName() + " (" + cacheFile + ")";
|
||||
}
|
||||
|
||||
private void open() throws Exception {
|
||||
LOGGER.debug("Opening {}", this);
|
||||
try {
|
||||
doOpen();
|
||||
} catch (CorruptedCacheException e) {
|
||||
rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
private void doOpen() throws Exception {
|
||||
BlockStore.Factory factory = new BlockStore.Factory() {
|
||||
@Override
|
||||
public Object create(Class<? extends BlockPayload> type) {
|
||||
if (type == HeaderBlock.class) {
|
||||
return new HeaderBlock();
|
||||
}
|
||||
if (type == IndexBlock.class) {
|
||||
return new IndexBlock();
|
||||
}
|
||||
if (type == DataBlock.class) {
|
||||
return new DataBlock();
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
Runnable initAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
header = new HeaderBlock();
|
||||
store.write(header);
|
||||
header.index.newRoot();
|
||||
store.flush();
|
||||
}
|
||||
};
|
||||
|
||||
store.open(initAction, factory);
|
||||
header = store.readFirst(HeaderBlock.class);
|
||||
}
|
||||
|
||||
public V get(K key) {
|
||||
try {
|
||||
try {
|
||||
DataBlock block = header.getRoot().get(key);
|
||||
if (block != null) {
|
||||
return block.getValue();
|
||||
}
|
||||
return null;
|
||||
} catch (CorruptedCacheException e) {
|
||||
rebuild();
|
||||
return null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(String.format("Could not read entry '%s' from %s.", key, this), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(K key, V value) {
|
||||
try {
|
||||
long hashCode = keyHasher.getHashCode(key);
|
||||
Lookup lookup = header.getRoot().find(hashCode);
|
||||
DataBlock newBlock = null;
|
||||
if (lookup.entry != null) {
|
||||
DataBlock block = store.read(lookup.entry.dataBlock, DataBlock.class);
|
||||
DataBlockUpdateResult updateResult = block.useNewValue(value);
|
||||
if (updateResult.isFailed()) {
|
||||
store.remove(block);
|
||||
newBlock = new DataBlock(value, updateResult.getSerializedValue());
|
||||
}
|
||||
} else {
|
||||
newBlock = new DataBlock(value);
|
||||
}
|
||||
if (newBlock != null) {
|
||||
store.write(newBlock);
|
||||
lookup.indexBlock.put(hashCode, newBlock.getPos());
|
||||
}
|
||||
store.flush();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(String.format("Could not add entry '%s' to %s.", key, this), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(K key) {
|
||||
try {
|
||||
Lookup lookup = header.getRoot().find(key);
|
||||
if (lookup.entry == null) {
|
||||
return;
|
||||
}
|
||||
lookup.indexBlock.remove(lookup.entry);
|
||||
DataBlock block = store.read(lookup.entry.dataBlock, DataBlock.class);
|
||||
store.remove(block);
|
||||
store.flush();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(String.format("Could not remove entry '%s' from %s.", key, this), e);
|
||||
}
|
||||
}
|
||||
|
||||
private IndexBlock load(BlockPointer pos, IndexRoot root, IndexBlock parent, int index) {
|
||||
IndexBlock block = store.read(pos, IndexBlock.class);
|
||||
block.root = root;
|
||||
block.parent = parent;
|
||||
block.parentEntryIndex = index;
|
||||
return block;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
close();
|
||||
try {
|
||||
open();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
LOGGER.debug("Closing {}", this);
|
||||
try {
|
||||
store.close();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return store.isOpen();
|
||||
}
|
||||
|
||||
private void rebuild() {
|
||||
LOGGER.warn("{} is corrupt. Discarding.", this);
|
||||
try {
|
||||
clear();
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("{} couldn't be rebuilt. Closing.", this);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
public void verify() {
|
||||
try {
|
||||
doVerify();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(String.format("Some problems were found when checking the integrity of %s.",
|
||||
this), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void doVerify() throws Exception {
|
||||
List<BlockPayload> blocks = new ArrayList<BlockPayload>();
|
||||
|
||||
HeaderBlock header = store.readFirst(HeaderBlock.class);
|
||||
blocks.add(header);
|
||||
verifyTree(header.getRoot(), "", blocks, Long.MAX_VALUE, true);
|
||||
|
||||
Collections.sort(blocks, new Comparator<BlockPayload>() {
|
||||
@Override
|
||||
public int compare(BlockPayload block, BlockPayload block1) {
|
||||
return block.getPos().compareTo(block1.getPos());
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < blocks.size() - 1; i++) {
|
||||
Block b1 = blocks.get(i).getBlock();
|
||||
Block b2 = blocks.get(i + 1).getBlock();
|
||||
if (b1.getPos().getPos() + b1.getSize() > b2.getPos().getPos()) {
|
||||
throw new IOException(String.format("%s overlaps with %s", b1, b2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyTree(IndexBlock current, String prefix, Collection<BlockPayload> blocks, long maxValue,
|
||||
boolean loadData) throws Exception {
|
||||
blocks.add(current);
|
||||
|
||||
if (!prefix.equals("") && current.entries.size() < maxChildIndexEntries / 2) {
|
||||
throw new IOException(String.format("Too few entries found in %s", current));
|
||||
}
|
||||
if (current.entries.size() > maxChildIndexEntries) {
|
||||
throw new IOException(String.format("Too many entries found in %s", current));
|
||||
}
|
||||
|
||||
boolean isLeaf = current.entries.size() == 0 || current.entries.get(0).childIndexBlock.isNull();
|
||||
if (isLeaf ^ current.tailPos.isNull()) {
|
||||
throw new IOException(String.format("Mismatched leaf/tail-node in %s", current));
|
||||
}
|
||||
|
||||
long min = Long.MIN_VALUE;
|
||||
for (IndexEntry entry : current.entries) {
|
||||
if (isLeaf ^ entry.childIndexBlock.isNull()) {
|
||||
throw new IOException(String.format("Mismatched leaf/non-leaf entry in %s", current));
|
||||
}
|
||||
if (entry.hashCode >= maxValue || entry.hashCode <= min) {
|
||||
throw new IOException(String.format("Out-of-order key in %s", current));
|
||||
}
|
||||
min = entry.hashCode;
|
||||
if (!entry.childIndexBlock.isNull()) {
|
||||
IndexBlock child = store.read(entry.childIndexBlock, IndexBlock.class);
|
||||
verifyTree(child, " " + prefix, blocks, entry.hashCode, loadData);
|
||||
}
|
||||
if (loadData) {
|
||||
DataBlock block = store.read(entry.dataBlock, DataBlock.class);
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
if (!current.tailPos.isNull()) {
|
||||
IndexBlock tail = store.read(current.tailPos, IndexBlock.class);
|
||||
verifyTree(tail, " " + prefix, blocks, maxValue, loadData);
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
store.clear();
|
||||
close();
|
||||
try {
|
||||
doOpen();
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private class IndexRoot {
|
||||
private BlockPointer rootPos = BlockPointer.start();
|
||||
private HeaderBlock owner;
|
||||
|
||||
private IndexRoot(HeaderBlock owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public void setRootPos(BlockPointer rootPos) {
|
||||
this.rootPos = rootPos;
|
||||
store.write(owner);
|
||||
}
|
||||
|
||||
public IndexBlock getRoot() {
|
||||
return load(rootPos, this, null, 0);
|
||||
}
|
||||
|
||||
public IndexBlock newRoot() {
|
||||
IndexBlock block = new IndexBlock();
|
||||
store.write(block);
|
||||
setRootPos(block.getPos());
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
||||
private class HeaderBlock extends BlockPayload {
|
||||
private IndexRoot index;
|
||||
|
||||
private HeaderBlock() {
|
||||
index = new IndexRoot(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte getType() {
|
||||
return 0x55;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return Block.LONG_SIZE + Block.SHORT_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(DataInputStream instr) throws Exception {
|
||||
index.rootPos = BlockPointer.pos(instr.readLong());
|
||||
|
||||
short actualChildIndexEntries = instr.readShort();
|
||||
if (actualChildIndexEntries != maxChildIndexEntries) {
|
||||
throw blockCorruptedException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(DataOutputStream outstr) throws Exception {
|
||||
outstr.writeLong(index.rootPos.getPos());
|
||||
outstr.writeShort(maxChildIndexEntries);
|
||||
}
|
||||
|
||||
public IndexBlock getRoot() throws Exception {
|
||||
return index.getRoot();
|
||||
}
|
||||
}
|
||||
|
||||
private class IndexBlock extends BlockPayload {
|
||||
private final List<IndexEntry> entries = new ArrayList<IndexEntry>();
|
||||
private BlockPointer tailPos = BlockPointer.start();
|
||||
// Transient fields
|
||||
private IndexBlock parent;
|
||||
private int parentEntryIndex;
|
||||
private IndexRoot root;
|
||||
|
||||
@Override
|
||||
protected byte getType() {
|
||||
return 0x77;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return Block.INT_SIZE + Block.LONG_SIZE + (3 * Block.LONG_SIZE) * maxChildIndexEntries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream instr) throws IOException {
|
||||
int count = instr.readInt();
|
||||
entries.clear();
|
||||
for (int i = 0; i < count; i++) {
|
||||
IndexEntry entry = new IndexEntry();
|
||||
entry.hashCode = instr.readLong();
|
||||
entry.dataBlock = BlockPointer.pos(instr.readLong());
|
||||
entry.childIndexBlock = BlockPointer.pos(instr.readLong());
|
||||
entries.add(entry);
|
||||
}
|
||||
tailPos = BlockPointer.pos(instr.readLong());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream outstr) throws IOException {
|
||||
outstr.writeInt(entries.size());
|
||||
for (IndexEntry entry : entries) {
|
||||
outstr.writeLong(entry.hashCode);
|
||||
outstr.writeLong(entry.dataBlock.getPos());
|
||||
outstr.writeLong(entry.childIndexBlock.getPos());
|
||||
}
|
||||
outstr.writeLong(tailPos.getPos());
|
||||
}
|
||||
|
||||
public void put(long hashCode, BlockPointer pos) throws Exception {
|
||||
int index = Collections.binarySearch(entries, new IndexEntry(hashCode));
|
||||
IndexEntry entry;
|
||||
if (index >= 0) {
|
||||
entry = entries.get(index);
|
||||
} else {
|
||||
assert tailPos.isNull();
|
||||
entry = new IndexEntry();
|
||||
entry.hashCode = hashCode;
|
||||
entry.childIndexBlock = BlockPointer.start();
|
||||
index = -index - 1;
|
||||
entries.add(index, entry);
|
||||
}
|
||||
|
||||
entry.dataBlock = pos;
|
||||
store.write(this);
|
||||
|
||||
maybeSplit();
|
||||
}
|
||||
|
||||
private void maybeSplit() throws Exception {
|
||||
if (entries.size() > maxChildIndexEntries) {
|
||||
int splitPos = entries.size() / 2;
|
||||
IndexEntry splitEntry = entries.remove(splitPos);
|
||||
if (parent == null) {
|
||||
parent = root.newRoot();
|
||||
}
|
||||
IndexBlock sibling = new IndexBlock();
|
||||
store.write(sibling);
|
||||
List<IndexEntry> siblingEntries = entries.subList(splitPos, entries.size());
|
||||
sibling.entries.addAll(siblingEntries);
|
||||
siblingEntries.clear();
|
||||
sibling.tailPos = tailPos;
|
||||
tailPos = splitEntry.childIndexBlock;
|
||||
splitEntry.childIndexBlock = BlockPointer.start();
|
||||
parent.add(this, splitEntry, sibling);
|
||||
}
|
||||
}
|
||||
|
||||
private void add(IndexBlock left, IndexEntry entry, IndexBlock right) throws Exception {
|
||||
int index = left.parentEntryIndex;
|
||||
if (index < entries.size()) {
|
||||
IndexEntry parentEntry = entries.get(index);
|
||||
assert parentEntry.childIndexBlock.equals(left.getPos());
|
||||
parentEntry.childIndexBlock = right.getPos();
|
||||
} else {
|
||||
assert index == entries.size() && (tailPos.isNull() || tailPos.equals(left.getPos()));
|
||||
tailPos = right.getPos();
|
||||
}
|
||||
entries.add(index, entry);
|
||||
entry.childIndexBlock = left.getPos();
|
||||
store.write(this);
|
||||
|
||||
maybeSplit();
|
||||
}
|
||||
|
||||
public DataBlock get(K key) throws Exception {
|
||||
Lookup lookup = find(key);
|
||||
if (lookup.entry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return store.read(lookup.entry.dataBlock, DataBlock.class);
|
||||
}
|
||||
|
||||
public Lookup find(K key) throws Exception {
|
||||
long checksum = keyHasher.getHashCode(key);
|
||||
return find(checksum);
|
||||
}
|
||||
|
||||
private Lookup find(long hashCode) throws Exception {
|
||||
int index = Collections.binarySearch(entries, new IndexEntry(hashCode));
|
||||
if (index >= 0) {
|
||||
return new Lookup(this, entries.get(index));
|
||||
}
|
||||
|
||||
index = -index - 1;
|
||||
BlockPointer childBlockPos;
|
||||
if (index == entries.size()) {
|
||||
childBlockPos = tailPos;
|
||||
} else {
|
||||
childBlockPos = entries.get(index).childIndexBlock;
|
||||
}
|
||||
if (childBlockPos.isNull()) {
|
||||
return new Lookup(this, null);
|
||||
}
|
||||
|
||||
IndexBlock childBlock = load(childBlockPos, root, this, index);
|
||||
return childBlock.find(hashCode);
|
||||
}
|
||||
|
||||
public void remove(IndexEntry entry) throws Exception {
|
||||
int index = entries.indexOf(entry);
|
||||
assert index >= 0;
|
||||
entries.remove(index);
|
||||
store.write(this);
|
||||
|
||||
if (entry.childIndexBlock.isNull()) {
|
||||
maybeMerge();
|
||||
} else {
|
||||
// Not a leaf node. Move up an entry from a leaf node, then possibly merge the leaf node
|
||||
IndexBlock leafBlock = load(entry.childIndexBlock, root, this, index);
|
||||
leafBlock = leafBlock.findHighestLeaf();
|
||||
IndexEntry highestEntry = leafBlock.entries.remove(leafBlock.entries.size() - 1);
|
||||
highestEntry.childIndexBlock = entry.childIndexBlock;
|
||||
entries.add(index, highestEntry);
|
||||
store.write(leafBlock);
|
||||
leafBlock.maybeMerge();
|
||||
}
|
||||
}
|
||||
|
||||
private void maybeMerge() throws Exception {
|
||||
if (parent == null) {
|
||||
// This is the root block. Can have any number of children <= maxChildIndexEntries
|
||||
if (entries.size() == 0 && !tailPos.isNull()) {
|
||||
// This is an empty root block, discard it
|
||||
header.index.setRootPos(tailPos);
|
||||
store.remove(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// This is not the root block. Must have children >= minIndexChildNodes
|
||||
if (entries.size() >= minIndexChildNodes) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Attempt to merge with the left sibling
|
||||
IndexBlock left = parent.getPrevious(this);
|
||||
if (left != null) {
|
||||
assert entries.size() + left.entries.size() <= maxChildIndexEntries * 2;
|
||||
if (left.entries.size() > minIndexChildNodes) {
|
||||
// There are enough entries in this block and the left sibling to make up 2 blocks, so redistribute
|
||||
// the entries evenly between them
|
||||
left.mergeFrom(this);
|
||||
left.maybeSplit();
|
||||
return;
|
||||
} else {
|
||||
// There are only enough entries to make up 1 block, so move the entries of the left sibling into
|
||||
// this block and discard the left sibling. Might also need to merge the parent
|
||||
left.mergeFrom(this);
|
||||
parent.maybeMerge();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to merge with the right sibling
|
||||
IndexBlock right = parent.getNext(this);
|
||||
if (right != null) {
|
||||
assert entries.size() + right.entries.size() <= maxChildIndexEntries * 2;
|
||||
if (right.entries.size() > minIndexChildNodes) {
|
||||
// There are enough entries in this block and the right sibling to make up 2 blocks, so redistribute
|
||||
// the entries evenly between them
|
||||
mergeFrom(right);
|
||||
maybeSplit();
|
||||
return;
|
||||
} else {
|
||||
// There are only enough entries to make up 1 block, so move the entries of the right sibling into
|
||||
// this block and discard this block. Might also need to merge the parent
|
||||
mergeFrom(right);
|
||||
parent.maybeMerge();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Should not happen
|
||||
throw new IllegalStateException(String.format("%s does not have any siblings.", getBlock()));
|
||||
}
|
||||
|
||||
private void mergeFrom(IndexBlock right) throws Exception {
|
||||
IndexEntry newChildEntry = parent.entries.remove(parentEntryIndex);
|
||||
if (right.getPos().equals(parent.tailPos)) {
|
||||
parent.tailPos = getPos();
|
||||
} else {
|
||||
IndexEntry newParentEntry = parent.entries.get(parentEntryIndex);
|
||||
assert newParentEntry.childIndexBlock.equals(right.getPos());
|
||||
newParentEntry.childIndexBlock = getPos();
|
||||
}
|
||||
entries.add(newChildEntry);
|
||||
entries.addAll(right.entries);
|
||||
newChildEntry.childIndexBlock = tailPos;
|
||||
tailPos = right.tailPos;
|
||||
store.write(parent);
|
||||
store.write(this);
|
||||
store.remove(right);
|
||||
}
|
||||
|
||||
private IndexBlock getNext(IndexBlock indexBlock) throws Exception {
|
||||
int index = indexBlock.parentEntryIndex + 1;
|
||||
if (index > entries.size()) {
|
||||
return null;
|
||||
}
|
||||
if (index == entries.size()) {
|
||||
return load(tailPos, root, this, index);
|
||||
}
|
||||
return load(entries.get(index).childIndexBlock, root, this, index);
|
||||
}
|
||||
|
||||
private IndexBlock getPrevious(IndexBlock indexBlock) throws Exception {
|
||||
int index = indexBlock.parentEntryIndex - 1;
|
||||
if (index < 0) {
|
||||
return null;
|
||||
}
|
||||
return load(entries.get(index).childIndexBlock, root, this, index);
|
||||
}
|
||||
|
||||
private IndexBlock findHighestLeaf() throws Exception {
|
||||
if (tailPos.isNull()) {
|
||||
return this;
|
||||
}
|
||||
return load(tailPos, root, this, entries.size()).findHighestLeaf();
|
||||
}
|
||||
}
|
||||
|
||||
private static class IndexEntry implements Comparable<IndexEntry> {
|
||||
long hashCode;
|
||||
BlockPointer dataBlock;
|
||||
BlockPointer childIndexBlock;
|
||||
|
||||
private IndexEntry() {
|
||||
}
|
||||
|
||||
private IndexEntry(long hashCode) {
|
||||
this.hashCode = hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(IndexEntry indexEntry) {
|
||||
if (hashCode > indexEntry.hashCode) {
|
||||
return 1;
|
||||
}
|
||||
if (hashCode < indexEntry.hashCode) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private class Lookup {
|
||||
final IndexBlock indexBlock;
|
||||
final IndexEntry entry;
|
||||
|
||||
private Lookup(IndexBlock indexBlock, IndexEntry entry) {
|
||||
this.indexBlock = indexBlock;
|
||||
this.entry = entry;
|
||||
}
|
||||
}
|
||||
|
||||
private class DataBlock extends BlockPayload {
|
||||
private int size;
|
||||
private StreamByteBuffer buffer;
|
||||
private V value;
|
||||
|
||||
private DataBlock() {
|
||||
}
|
||||
|
||||
public DataBlock(V value) throws Exception {
|
||||
this.value = value;
|
||||
setValue(value);
|
||||
size = buffer.totalBytesUnread();
|
||||
}
|
||||
|
||||
public DataBlock(V value, StreamByteBuffer buffer) throws Exception {
|
||||
this.value = value;
|
||||
this.buffer = buffer;
|
||||
size = buffer.totalBytesUnread();
|
||||
}
|
||||
|
||||
public void setValue(V value) throws Exception {
|
||||
buffer = StreamByteBuffer.createWithChunkSizeInDefaultRange(size);
|
||||
KryoBackedEncoder encoder = new KryoBackedEncoder(buffer.getOutputStream());
|
||||
serializer.write(encoder, value);
|
||||
encoder.flush();
|
||||
}
|
||||
|
||||
public V getValue() throws Exception {
|
||||
if (value == null) {
|
||||
value = serializer.read(new KryoBackedDecoder(buffer.getInputStream()));
|
||||
buffer = null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte getType() {
|
||||
return 0x33;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return 2 * Block.INT_SIZE + size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream instr) throws Exception {
|
||||
size = instr.readInt();
|
||||
int bytes = instr.readInt();
|
||||
buffer = StreamByteBuffer.of(instr, bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream outstr) throws Exception {
|
||||
outstr.writeInt(size);
|
||||
outstr.writeInt(buffer.totalBytesUnread());
|
||||
buffer.writeTo(outstr);
|
||||
buffer = null;
|
||||
}
|
||||
|
||||
public DataBlockUpdateResult useNewValue(V value) throws Exception {
|
||||
setValue(value);
|
||||
boolean ok = buffer.totalBytesUnread() <= size;
|
||||
if (ok) {
|
||||
this.value = value;
|
||||
store.write(this);
|
||||
return DataBlockUpdateResult.success();
|
||||
} else {
|
||||
return DataBlockUpdateResult.failed(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class DataBlockUpdateResult {
|
||||
private static final DataBlockUpdateResult SUCCESS = new DataBlockUpdateResult(true, null);
|
||||
private final boolean success;
|
||||
private final StreamByteBuffer serializedValue;
|
||||
|
||||
private DataBlockUpdateResult(boolean success, StreamByteBuffer serializedValue) {
|
||||
this.success = success;
|
||||
this.serializedValue = serializedValue;
|
||||
}
|
||||
|
||||
static DataBlockUpdateResult success() {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static DataBlockUpdateResult failed(StreamByteBuffer serializedValue) {
|
||||
return new DataBlockUpdateResult(false, serializedValue);
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return !success;
|
||||
}
|
||||
|
||||
public StreamByteBuffer getSerializedValue() {
|
||||
return serializedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
public abstract class Block {
|
||||
static final int LONG_SIZE = 8;
|
||||
static final int INT_SIZE = 4;
|
||||
static final int SHORT_SIZE = 2;
|
||||
|
||||
private BlockPayload payload;
|
||||
|
||||
protected Block(BlockPayload payload) {
|
||||
this.payload = payload;
|
||||
payload.setBlock(this);
|
||||
}
|
||||
|
||||
public BlockPayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
protected void detach() {
|
||||
payload.setBlock(null);
|
||||
payload = null;
|
||||
}
|
||||
|
||||
public abstract BlockPointer getPos();
|
||||
|
||||
public abstract int getSize();
|
||||
|
||||
public abstract RuntimeException blockCorruptedException();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return payload.getClass().getSimpleName() + " " + getPos();
|
||||
}
|
||||
|
||||
public BlockPointer getNextPos() {
|
||||
return BlockPointer.pos(getPos().getPos() + getSize());
|
||||
}
|
||||
|
||||
public abstract boolean hasPos();
|
||||
|
||||
public abstract void setPos(BlockPointer pos);
|
||||
|
||||
public abstract void setSize(int size);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
|
||||
public abstract class BlockPayload {
|
||||
private Block block;
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public BlockPointer getPos() {
|
||||
return getBlock().getPos();
|
||||
}
|
||||
|
||||
public BlockPointer getNextPos() {
|
||||
return getBlock().getNextPos();
|
||||
}
|
||||
|
||||
protected abstract int getSize();
|
||||
|
||||
protected abstract byte getType();
|
||||
|
||||
protected abstract void read(DataInputStream inputStream) throws Exception;
|
||||
|
||||
protected abstract void write(DataOutputStream outputStream) throws Exception;
|
||||
|
||||
protected RuntimeException blockCorruptedException() {
|
||||
return getBlock().blockCorruptedException();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
|
||||
public class BlockPointer implements Comparable<BlockPointer> {
|
||||
|
||||
private static final BlockPointer NULL = new BlockPointer(-1);
|
||||
|
||||
public static BlockPointer start() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public static BlockPointer pos(long pos) {
|
||||
if (pos < -1) {
|
||||
throw new CorruptedCacheException("block pointer must be >= -1, but was" + pos);
|
||||
}
|
||||
if (pos == -1) {
|
||||
return NULL;
|
||||
}
|
||||
return new BlockPointer(pos);
|
||||
}
|
||||
|
||||
private final long pos;
|
||||
|
||||
private BlockPointer(long pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
public boolean isNull() {
|
||||
return pos < 0;
|
||||
}
|
||||
|
||||
public long getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null || obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
BlockPointer other = (BlockPointer) obj;
|
||||
return pos == other.pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Longs.hashCode(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(BlockPointer o) {
|
||||
return Longs.compare(pos, o.pos);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
public interface BlockStore {
|
||||
/**
|
||||
* Opens this store, calling the given action if the store is empty.
|
||||
*/
|
||||
void open(Runnable initAction, Factory factory);
|
||||
|
||||
/**
|
||||
* Closes this store.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Discards all blocks from this store.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Removes the given block from this store.
|
||||
*/
|
||||
void remove(BlockPayload block);
|
||||
|
||||
/**
|
||||
* Reads the first block from this store.
|
||||
*/
|
||||
<T extends BlockPayload> T readFirst(Class<T> payloadType);
|
||||
|
||||
/**
|
||||
* Reads a block from this store.
|
||||
*/
|
||||
<T extends BlockPayload> T read(BlockPointer pos, Class<T> payloadType);
|
||||
|
||||
/**
|
||||
* Writes a block to this store, adding the block if required.
|
||||
*/
|
||||
void write(BlockPayload block);
|
||||
|
||||
/**
|
||||
* Adds a new block to this store. Allocates space for the block, but does not write the contents of the block
|
||||
* until {@link #write(BlockPayload)} is called.
|
||||
*/
|
||||
void attach(BlockPayload block);
|
||||
|
||||
/**
|
||||
* Flushes any pending updates for this store.
|
||||
*/
|
||||
void flush();
|
||||
|
||||
interface Factory {
|
||||
Object create(Class<? extends BlockPayload> type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class BufferCaster {
|
||||
/**
|
||||
* Without this cast, when the code compiled by Java 9+ is executed on Java 8, it will throw
|
||||
* java.lang.NoSuchMethodError: Method flip()Ljava/nio/ByteBuffer; does not exist in class java.nio.ByteBuffer
|
||||
*/
|
||||
@SuppressWarnings("RedundantCast")
|
||||
public static <T extends Buffer> Buffer cast(T byteBuffer) {
|
||||
return (Buffer) byteBuffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import com.google.common.io.CountingInputStream;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* Allows a stream of bytes to be read from a particular location of some backing byte stream.
|
||||
*/
|
||||
class ByteInput {
|
||||
private final RandomAccessFile file;
|
||||
private final ResettableBufferedInputStream bufferedInputStream;
|
||||
private CountingInputStream countingInputStream;
|
||||
|
||||
public ByteInput(RandomAccessFile file) {
|
||||
this.file = file;
|
||||
bufferedInputStream = new ResettableBufferedInputStream(new RandomAccessFileInputStream(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts reading from the given offset.
|
||||
*/
|
||||
public DataInputStream start(long offset) throws IOException {
|
||||
file.seek(offset);
|
||||
bufferedInputStream.clear();
|
||||
countingInputStream = new CountingInputStream(bufferedInputStream);
|
||||
return new DataInputStream(countingInputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes read since {@link #start(long)} was called.
|
||||
*/
|
||||
public long getBytesRead() {
|
||||
return countingInputStream.getCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes reading, resetting any buffered state.
|
||||
*/
|
||||
public void done() {
|
||||
countingInputStream = null;
|
||||
}
|
||||
|
||||
private static class ResettableBufferedInputStream extends BufferedInputStream {
|
||||
ResettableBufferedInputStream(InputStream input) {
|
||||
super(input);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
count = 0;
|
||||
pos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import com.google.common.io.CountingOutputStream;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* Allows a stream of bytes to be written to a particular location of some backing byte stream.
|
||||
*/
|
||||
class ByteOutput {
|
||||
private final RandomAccessFile file;
|
||||
private final ResettableBufferedOutputStream bufferedOutputStream;
|
||||
private CountingOutputStream countingOutputStream;
|
||||
|
||||
public ByteOutput(RandomAccessFile file) {
|
||||
this.file = file;
|
||||
bufferedOutputStream = new ResettableBufferedOutputStream(new RandomAccessFileOutputStream(file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts writing to the given offset. Can be beyond the current length of the file.
|
||||
*/
|
||||
public DataOutputStream start(long offset) throws IOException {
|
||||
file.seek(offset);
|
||||
bufferedOutputStream.clear();
|
||||
countingOutputStream = new CountingOutputStream(bufferedOutputStream);
|
||||
return new DataOutputStream(countingOutputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of byte written since {@link #start(long)} was called.
|
||||
*/
|
||||
public long getBytesWritten() {
|
||||
return countingOutputStream.getCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes writing, flushing and resetting any buffered state
|
||||
*/
|
||||
public void done() throws IOException {
|
||||
countingOutputStream.flush();
|
||||
countingOutputStream = null;
|
||||
}
|
||||
|
||||
private static class ResettableBufferedOutputStream extends BufferedOutputStream {
|
||||
ResettableBufferedOutputStream(OutputStream output) {
|
||||
super(output);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CachingBlockStore implements BlockStore {
|
||||
private final BlockStore store;
|
||||
private final Map<BlockPointer, BlockPayload> dirty = new LinkedHashMap<BlockPointer, BlockPayload>();
|
||||
private final Cache<BlockPointer, BlockPayload> indexBlockCache = CacheBuilder.newBuilder().maximumSize(100).concurrencyLevel(1).build();
|
||||
private final ImmutableSet<Class<? extends BlockPayload>> cacheableBlockTypes;
|
||||
|
||||
public CachingBlockStore(BlockStore store, Collection<Class<? extends BlockPayload>> cacheableBlockTypes) {
|
||||
this.store = store;
|
||||
this.cacheableBlockTypes = ImmutableSet.copyOf(cacheableBlockTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(Runnable initAction, Factory factory) {
|
||||
store.open(initAction, factory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
flush();
|
||||
indexBlockCache.invalidateAll();
|
||||
store.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
dirty.clear();
|
||||
indexBlockCache.invalidateAll();
|
||||
store.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
Iterator<BlockPayload> iterator = dirty.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
BlockPayload block = iterator.next();
|
||||
iterator.remove();
|
||||
store.write(block);
|
||||
}
|
||||
store.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(BlockPayload block) {
|
||||
store.attach(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(BlockPayload block) {
|
||||
dirty.remove(block.getPos());
|
||||
if (isCacheable(block)) {
|
||||
indexBlockCache.invalidate(block.getPos());
|
||||
}
|
||||
store.remove(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T readFirst(Class<T> payloadType) {
|
||||
T block = store.readFirst(payloadType);
|
||||
maybeCache(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T read(BlockPointer pos, Class<T> payloadType) {
|
||||
T block = payloadType.cast(dirty.get(pos));
|
||||
if (block != null) {
|
||||
return block;
|
||||
}
|
||||
block = maybeGetFromCache(pos, payloadType);
|
||||
if (block != null) {
|
||||
return block;
|
||||
}
|
||||
block = store.read(pos, payloadType);
|
||||
maybeCache(block);
|
||||
return block;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T extends BlockPayload> T maybeGetFromCache(BlockPointer pos, Class<T> payloadType) {
|
||||
if (cacheableBlockTypes.contains(payloadType)) {
|
||||
return payloadType.cast(indexBlockCache.getIfPresent(pos));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BlockPayload block) {
|
||||
store.attach(block);
|
||||
maybeCache(block);
|
||||
dirty.put(block.getPos(), block);
|
||||
}
|
||||
|
||||
private <T extends BlockPayload> void maybeCache(T block) {
|
||||
if (isCacheable(block)) {
|
||||
indexBlockCache.put(block.getPos(), block);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends BlockPayload> boolean isCacheable(T block) {
|
||||
return cacheableBlockTypes.contains(block.getClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
class CorruptedCacheException extends RuntimeException {
|
||||
CorruptedCacheException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class FileBackedBlockStore implements BlockStore {
|
||||
private final File cacheFile;
|
||||
private RandomAccessFile file;
|
||||
private ByteOutput output;
|
||||
private ByteInput input;
|
||||
private long nextBlock;
|
||||
private Factory factory;
|
||||
private long currentFileSize;
|
||||
|
||||
public FileBackedBlockStore(File cacheFile) {
|
||||
this.cacheFile = cacheFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "cache '" + cacheFile + "'";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(Runnable runnable, Factory factory) {
|
||||
this.factory = factory;
|
||||
try {
|
||||
cacheFile.getParentFile().mkdirs();
|
||||
file = openRandomAccessFile();
|
||||
output = new ByteOutput(file);
|
||||
input = new ByteInput(file);
|
||||
currentFileSize = file.length();
|
||||
nextBlock = currentFileSize;
|
||||
if (currentFileSize == 0) {
|
||||
runnable.run();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private RandomAccessFile openRandomAccessFile() throws FileNotFoundException {
|
||||
try {
|
||||
return randomAccessFile("rw");
|
||||
} catch (FileNotFoundException e) {
|
||||
return randomAccessFile("r");
|
||||
}
|
||||
}
|
||||
|
||||
private RandomAccessFile randomAccessFile(String mode) throws FileNotFoundException {
|
||||
return new RandomAccessFile(cacheFile, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
try {
|
||||
file.close();
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
try {
|
||||
file.setLength(0);
|
||||
currentFileSize = 0;
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
nextBlock = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(BlockPayload block) {
|
||||
if (block.getBlock() == null) {
|
||||
block.setBlock(new BlockImpl(block));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(BlockPayload block) {
|
||||
BlockImpl blockImpl = (BlockImpl) block.getBlock();
|
||||
blockImpl.detach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T readFirst(Class<T> payloadType) {
|
||||
return read(BlockPointer.pos(0), payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T read(BlockPointer pos, Class<T> payloadType) {
|
||||
assert !pos.isNull();
|
||||
try {
|
||||
T payload = payloadType.cast(factory.create(payloadType));
|
||||
BlockImpl block = new BlockImpl(payload, pos);
|
||||
block.read();
|
||||
return payload;
|
||||
} catch (CorruptedCacheException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BlockPayload block) {
|
||||
BlockImpl blockImpl = (BlockImpl) block.getBlock();
|
||||
try {
|
||||
blockImpl.write();
|
||||
} catch (CorruptedCacheException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private long alloc(long length) {
|
||||
long pos = nextBlock;
|
||||
nextBlock += length;
|
||||
return pos;
|
||||
}
|
||||
|
||||
private final class BlockImpl extends Block {
|
||||
private static final int HEADER_SIZE = 1 + INT_SIZE; // type, payload size
|
||||
private static final int TAIL_SIZE = INT_SIZE;
|
||||
|
||||
private BlockPointer pos;
|
||||
private int payloadSize;
|
||||
|
||||
private BlockImpl(BlockPayload payload, BlockPointer pos) {
|
||||
this(payload);
|
||||
setPos(pos);
|
||||
}
|
||||
|
||||
public BlockImpl(BlockPayload payload) {
|
||||
super(payload);
|
||||
pos = null;
|
||||
payloadSize = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPos() {
|
||||
return pos != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPointer getPos() {
|
||||
if (pos == null) {
|
||||
pos = BlockPointer.pos(alloc(getSize()));
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(BlockPointer pos) {
|
||||
assert this.pos == null && !pos.isNull();
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
if (payloadSize < 0) {
|
||||
payloadSize = getPayload().getSize();
|
||||
}
|
||||
return payloadSize + HEADER_SIZE + TAIL_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSize(int size) {
|
||||
int newPayloadSize = size - HEADER_SIZE - TAIL_SIZE;
|
||||
assert newPayloadSize >= payloadSize;
|
||||
payloadSize = newPayloadSize;
|
||||
}
|
||||
|
||||
public void write() throws Exception {
|
||||
long pos = getPos().getPos();
|
||||
|
||||
DataOutputStream outputStream = output.start(pos);
|
||||
|
||||
BlockPayload payload = getPayload();
|
||||
|
||||
// Write header
|
||||
outputStream.writeByte(payload.getType());
|
||||
outputStream.writeInt(payloadSize);
|
||||
long finalSize = pos + HEADER_SIZE + TAIL_SIZE + payloadSize;
|
||||
|
||||
// Write body
|
||||
payload.write(outputStream);
|
||||
|
||||
// Write count
|
||||
long bytesWritten = output.getBytesWritten();
|
||||
if (bytesWritten > Integer.MAX_VALUE) {
|
||||
throw new IllegalArgumentException("Block payload exceeds maximum size");
|
||||
}
|
||||
outputStream.writeInt((int) bytesWritten);
|
||||
output.done();
|
||||
|
||||
// System.out.println(String.format("wrote [%d,%d)", pos, pos + bytesWritten + 4));
|
||||
|
||||
// Pad
|
||||
if (currentFileSize < finalSize) {
|
||||
// System.out.println(String.format("pad length %d => %d", currentFileSize, finalSize));
|
||||
file.setLength(finalSize);
|
||||
currentFileSize = finalSize;
|
||||
}
|
||||
}
|
||||
|
||||
public void read() throws Exception {
|
||||
long pos = getPos().getPos();
|
||||
assert pos >= 0;
|
||||
if (pos + HEADER_SIZE >= currentFileSize) {
|
||||
throw blockCorruptedException();
|
||||
}
|
||||
|
||||
DataInputStream inputStream = input.start(pos);
|
||||
|
||||
BlockPayload payload = getPayload();
|
||||
|
||||
// Read header
|
||||
byte type = inputStream.readByte();
|
||||
if (type != payload.getType()) {
|
||||
throw blockCorruptedException();
|
||||
}
|
||||
|
||||
// Read body
|
||||
payloadSize = inputStream.readInt();
|
||||
if (pos + HEADER_SIZE + TAIL_SIZE + payloadSize > currentFileSize) {
|
||||
throw blockCorruptedException();
|
||||
}
|
||||
payload.read(inputStream);
|
||||
|
||||
// Read and verify count
|
||||
long actualCount = input.getBytesRead();
|
||||
long count = inputStream.readInt();
|
||||
if (actualCount != count) {
|
||||
System.out.println(String.format("read expected %d actual %d, pos %d payloadSize %d currentFileSize %d", count, actualCount, pos, payloadSize, currentFileSize));
|
||||
throw blockCorruptedException();
|
||||
}
|
||||
input.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeException blockCorruptedException() {
|
||||
return new CorruptedCacheException(String.format("Corrupted %s found in %s.", this,
|
||||
FileBackedBlockStore.this));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,283 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class FreeListBlockStore implements BlockStore {
|
||||
private final BlockStore store;
|
||||
private final BlockStore freeListStore;
|
||||
private final int maxBlockEntries;
|
||||
private FreeListBlock freeListBlock;
|
||||
|
||||
public FreeListBlockStore(BlockStore store, int maxBlockEntries) {
|
||||
this.store = store;
|
||||
freeListStore = this;
|
||||
this.maxBlockEntries = maxBlockEntries;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(final Runnable initAction, final Factory factory) {
|
||||
Runnable freeListInitAction = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
freeListBlock = new FreeListBlock();
|
||||
store.write(freeListBlock);
|
||||
store.flush();
|
||||
initAction.run();
|
||||
}
|
||||
};
|
||||
Factory freeListFactory = new Factory() {
|
||||
@Override
|
||||
public Object create(Class<? extends BlockPayload> type) {
|
||||
if (type == FreeListBlock.class) {
|
||||
return new FreeListBlock();
|
||||
}
|
||||
return factory.create(type);
|
||||
}
|
||||
};
|
||||
|
||||
store.open(freeListInitAction, freeListFactory);
|
||||
freeListBlock = store.readFirst(FreeListBlock.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
freeListBlock = null;
|
||||
store.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
store.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(BlockPayload block) {
|
||||
Block container = block.getBlock();
|
||||
store.remove(block);
|
||||
freeListBlock.add(container.getPos(), container.getSize());
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T readFirst(Class<T> payloadType) {
|
||||
return store.read(freeListBlock.getNextPos(), payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T read(BlockPointer pos, Class<T> payloadType) {
|
||||
return store.read(pos, payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BlockPayload block) {
|
||||
attach(block);
|
||||
store.write(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(BlockPayload block) {
|
||||
store.attach(block);
|
||||
freeListBlock.alloc(block.getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
store.flush();
|
||||
}
|
||||
|
||||
private void verify() {
|
||||
FreeListBlock block = store.readFirst(FreeListBlock.class);
|
||||
verify(block, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
private void verify(FreeListBlock block, int maxValue) {
|
||||
if (block.largestInNextBlock > maxValue) {
|
||||
throw new RuntimeException("corrupt free list");
|
||||
}
|
||||
int current = 0;
|
||||
for (FreeListEntry entry : block.entries) {
|
||||
if (entry.size > maxValue) {
|
||||
throw new RuntimeException("corrupt free list");
|
||||
}
|
||||
if (entry.size < block.largestInNextBlock) {
|
||||
throw new RuntimeException("corrupt free list");
|
||||
}
|
||||
if (entry.size < current) {
|
||||
throw new RuntimeException("corrupt free list");
|
||||
}
|
||||
current = entry.size;
|
||||
}
|
||||
if (!block.nextBlock.isNull()) {
|
||||
verify(store.read(block.nextBlock, FreeListBlock.class), block.largestInNextBlock);
|
||||
}
|
||||
}
|
||||
|
||||
public class FreeListBlock extends BlockPayload {
|
||||
private List<FreeListEntry> entries = new ArrayList<FreeListEntry>();
|
||||
private int largestInNextBlock;
|
||||
private BlockPointer nextBlock = BlockPointer.start();
|
||||
// Transient fields
|
||||
private FreeListBlock prev;
|
||||
private FreeListBlock next;
|
||||
|
||||
@Override
|
||||
protected int getSize() {
|
||||
return Block.LONG_SIZE + Block.INT_SIZE + Block.INT_SIZE + maxBlockEntries * (Block.LONG_SIZE
|
||||
+ Block.INT_SIZE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected byte getType() {
|
||||
return 0x44;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void read(DataInputStream inputStream) throws Exception {
|
||||
nextBlock = BlockPointer.pos(inputStream.readLong());
|
||||
largestInNextBlock = inputStream.readInt();
|
||||
int count = inputStream.readInt();
|
||||
for (int i = 0; i < count; i++) {
|
||||
BlockPointer pos = BlockPointer.pos(inputStream.readLong());
|
||||
int size = inputStream.readInt();
|
||||
entries.add(new FreeListEntry(pos, size));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void write(DataOutputStream outputStream) throws Exception {
|
||||
outputStream.writeLong(nextBlock.getPos());
|
||||
outputStream.writeInt(largestInNextBlock);
|
||||
outputStream.writeInt(entries.size());
|
||||
for (FreeListEntry entry : entries) {
|
||||
outputStream.writeLong(entry.pos.getPos());
|
||||
outputStream.writeInt(entry.size);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(BlockPointer pos, int size) {
|
||||
assert !pos.isNull() && size >= 0;
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (size < largestInNextBlock) {
|
||||
FreeListBlock next = getNextBlock();
|
||||
next.add(pos, size);
|
||||
return;
|
||||
}
|
||||
|
||||
FreeListEntry entry = new FreeListEntry(pos, size);
|
||||
int index = Collections.binarySearch(entries, entry);
|
||||
if (index < 0) {
|
||||
index = -index - 1;
|
||||
}
|
||||
entries.add(index, entry);
|
||||
|
||||
if (entries.size() > maxBlockEntries) {
|
||||
FreeListBlock newBlock = new FreeListBlock();
|
||||
newBlock.largestInNextBlock = largestInNextBlock;
|
||||
newBlock.nextBlock = nextBlock;
|
||||
newBlock.prev = this;
|
||||
newBlock.next = next;
|
||||
next = newBlock;
|
||||
|
||||
List<FreeListEntry> newBlockEntries = entries.subList(0, entries.size() / 2);
|
||||
newBlock.entries.addAll(newBlockEntries);
|
||||
newBlockEntries.clear();
|
||||
largestInNextBlock = newBlock.entries.get(newBlock.entries.size() - 1).size;
|
||||
freeListStore.write(newBlock);
|
||||
nextBlock = newBlock.getPos();
|
||||
}
|
||||
|
||||
freeListStore.write(this);
|
||||
}
|
||||
|
||||
private FreeListBlock getNextBlock() {
|
||||
if (next == null) {
|
||||
next = freeListStore.read(nextBlock, FreeListBlock.class);
|
||||
next.prev = this;
|
||||
}
|
||||
return next;
|
||||
}
|
||||
|
||||
public void alloc(Block block) {
|
||||
if (block.hasPos()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int requiredSize = block.getSize();
|
||||
|
||||
if (entries.isEmpty() || requiredSize <= largestInNextBlock) {
|
||||
if (nextBlock.isNull()) {
|
||||
return;
|
||||
}
|
||||
getNextBlock().alloc(block);
|
||||
return;
|
||||
}
|
||||
|
||||
int index = Collections.binarySearch(entries, new FreeListEntry(null, requiredSize));
|
||||
if (index < 0) {
|
||||
index = -index - 1;
|
||||
}
|
||||
if (index == entries.size()) {
|
||||
// Largest free block is too small
|
||||
return;
|
||||
}
|
||||
|
||||
FreeListEntry entry = entries.remove(index);
|
||||
block.setPos(entry.pos);
|
||||
block.setSize(entry.size);
|
||||
freeListStore.write(this);
|
||||
|
||||
if (entries.size() == 0 && prev != null) {
|
||||
prev.nextBlock = nextBlock;
|
||||
prev.largestInNextBlock = largestInNextBlock;
|
||||
prev.next = next;
|
||||
if (next != null) {
|
||||
next.prev = prev;
|
||||
}
|
||||
freeListStore.write(prev);
|
||||
freeListStore.remove(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class FreeListEntry implements Comparable<FreeListEntry> {
|
||||
final BlockPointer pos;
|
||||
final int size;
|
||||
|
||||
private FreeListEntry(BlockPointer pos, int size) {
|
||||
this.pos = pos;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(FreeListEntry o) {
|
||||
if (size > o.size) {
|
||||
return 1;
|
||||
}
|
||||
if (size < o.size) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import seaweedfs.client.btree.serialize.Serializer;
|
||||
import seaweedfs.client.btree.serialize.kryo.KryoBackedEncoder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
class KeyHasher<K> {
|
||||
private final Serializer<K> serializer;
|
||||
private final MessageDigestStream digestStream = new MessageDigestStream();
|
||||
private final KryoBackedEncoder encoder = new KryoBackedEncoder(digestStream);
|
||||
|
||||
public KeyHasher(Serializer<K> serializer) {
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
long getHashCode(K key) throws Exception {
|
||||
serializer.write(encoder, key);
|
||||
encoder.flush();
|
||||
return digestStream.getChecksum();
|
||||
}
|
||||
|
||||
private static class MessageDigestStream extends OutputStream {
|
||||
MessageDigest messageDigest;
|
||||
|
||||
private MessageDigestStream() {
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw UncheckedException.throwAsUncheckedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
messageDigest.update((byte) b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b) throws IOException {
|
||||
messageDigest.update(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
messageDigest.update(b, off, len);
|
||||
}
|
||||
|
||||
long getChecksum() {
|
||||
byte[] digest = messageDigest.digest();
|
||||
assert digest.length == 16;
|
||||
return new BigInteger(digest).longValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* Reads from a {@link RandomAccessFile}. Each operation reads from and advances the current position of the file.
|
||||
*
|
||||
* <p>Closing this stream does not close the underlying file.
|
||||
*/
|
||||
public class RandomAccessFileInputStream extends InputStream {
|
||||
private final RandomAccessFile file;
|
||||
|
||||
public RandomAccessFileInputStream(RandomAccessFile file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
file.seek(file.getFilePointer() + n);
|
||||
return n;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] bytes) throws IOException {
|
||||
return file.read(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return file.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] bytes, int offset, int length) throws IOException {
|
||||
return file.read(bytes, offset, length);
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
/**
|
||||
* Writes to a {@link RandomAccessFile}. Each operation writes to and advances the current position of the file.
|
||||
*
|
||||
* <p>Closing this stream does not close the underlying file. Flushing this stream does nothing.
|
||||
*/
|
||||
public class RandomAccessFileOutputStream extends OutputStream {
|
||||
private final RandomAccessFile file;
|
||||
|
||||
public RandomAccessFileOutputStream(RandomAccessFile file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int i) throws IOException {
|
||||
file.write(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] bytes) throws IOException {
|
||||
file.write(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] bytes, int offset, int length) throws IOException {
|
||||
file.write(bytes, offset, length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
public class StateCheckBlockStore implements BlockStore {
|
||||
private final BlockStore blockStore;
|
||||
private boolean open;
|
||||
|
||||
public StateCheckBlockStore(BlockStore blockStore) {
|
||||
this.blockStore = blockStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(Runnable initAction, Factory factory) {
|
||||
assert !open;
|
||||
open = true;
|
||||
blockStore.open(initAction, factory);
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (!open) {
|
||||
return;
|
||||
}
|
||||
open = false;
|
||||
blockStore.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
assert open;
|
||||
blockStore.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(BlockPayload block) {
|
||||
assert open;
|
||||
blockStore.remove(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T readFirst(Class<T> payloadType) {
|
||||
assert open;
|
||||
return blockStore.readFirst(payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockPayload> T read(BlockPointer pos, Class<T> payloadType) {
|
||||
assert open;
|
||||
return blockStore.read(pos, payloadType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(BlockPayload block) {
|
||||
assert open;
|
||||
blockStore.write(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(BlockPayload block) {
|
||||
assert open;
|
||||
blockStore.attach(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
assert open;
|
||||
blockStore.flush();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,526 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* An in-memory buffer that provides OutputStream and InputStream interfaces.
|
||||
*
|
||||
* This is more efficient than using ByteArrayOutputStream/ByteArrayInputStream
|
||||
*
|
||||
* Reading the buffer will clear the buffer.
|
||||
* This is not thread-safe, it is intended to be used by a single Thread.
|
||||
*/
|
||||
public class StreamByteBuffer {
|
||||
private static final int DEFAULT_CHUNK_SIZE = 4096;
|
||||
private static final int MAX_CHUNK_SIZE = 1024 * 1024;
|
||||
private LinkedList<StreamByteBufferChunk> chunks = new LinkedList<StreamByteBufferChunk>();
|
||||
private StreamByteBufferChunk currentWriteChunk;
|
||||
private StreamByteBufferChunk currentReadChunk;
|
||||
private int chunkSize;
|
||||
private int nextChunkSize;
|
||||
private int maxChunkSize;
|
||||
private StreamByteBufferOutputStream output;
|
||||
private StreamByteBufferInputStream input;
|
||||
private int totalBytesUnreadInList;
|
||||
|
||||
public StreamByteBuffer() {
|
||||
this(DEFAULT_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
public StreamByteBuffer(int chunkSize) {
|
||||
this.chunkSize = chunkSize;
|
||||
this.nextChunkSize = chunkSize;
|
||||
this.maxChunkSize = Math.max(chunkSize, MAX_CHUNK_SIZE);
|
||||
currentWriteChunk = new StreamByteBufferChunk(nextChunkSize);
|
||||
output = new StreamByteBufferOutputStream();
|
||||
input = new StreamByteBufferInputStream();
|
||||
}
|
||||
|
||||
public static StreamByteBuffer of(InputStream inputStream) throws IOException {
|
||||
StreamByteBuffer buffer = new StreamByteBuffer(chunkSizeInDefaultRange(inputStream.available()));
|
||||
buffer.readFully(inputStream);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static StreamByteBuffer of(InputStream inputStream, int len) throws IOException {
|
||||
StreamByteBuffer buffer = new StreamByteBuffer(chunkSizeInDefaultRange(len));
|
||||
buffer.readFrom(inputStream, len);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static StreamByteBuffer createWithChunkSizeInDefaultRange(int value) {
|
||||
return new StreamByteBuffer(chunkSizeInDefaultRange(value));
|
||||
}
|
||||
|
||||
static int chunkSizeInDefaultRange(int value) {
|
||||
return valueInRange(value, DEFAULT_CHUNK_SIZE, MAX_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
private static int valueInRange(int value, int min, int max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
public OutputStream getOutputStream() {
|
||||
return output;
|
||||
}
|
||||
|
||||
public InputStream getInputStream() {
|
||||
return input;
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream target) throws IOException {
|
||||
while (prepareRead() != -1) {
|
||||
currentReadChunk.writeTo(target);
|
||||
}
|
||||
}
|
||||
|
||||
public void readFrom(InputStream inputStream, int len) throws IOException {
|
||||
int bytesLeft = len;
|
||||
while (bytesLeft > 0) {
|
||||
int spaceLeft = allocateSpace();
|
||||
int limit = Math.min(spaceLeft, bytesLeft);
|
||||
int readBytes = currentWriteChunk.readFrom(inputStream, limit);
|
||||
if (readBytes == -1) {
|
||||
throw new EOFException("Unexpected EOF");
|
||||
}
|
||||
bytesLeft -= readBytes;
|
||||
}
|
||||
}
|
||||
|
||||
public void readFully(InputStream inputStream) throws IOException {
|
||||
while (true) {
|
||||
int len = allocateSpace();
|
||||
int readBytes = currentWriteChunk.readFrom(inputStream, len);
|
||||
if (readBytes == -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] readAsByteArray() {
|
||||
byte[] buf = new byte[totalBytesUnread()];
|
||||
input.readImpl(buf, 0, buf.length);
|
||||
return buf;
|
||||
}
|
||||
|
||||
public List<byte[]> readAsListOfByteArrays() {
|
||||
List<byte[]> listOfByteArrays = new ArrayList<byte[]>(chunks.size() + 1);
|
||||
byte[] buf;
|
||||
while ((buf = input.readNextBuffer()) != null) {
|
||||
if (buf.length > 0) {
|
||||
listOfByteArrays.add(buf);
|
||||
}
|
||||
}
|
||||
return listOfByteArrays;
|
||||
}
|
||||
|
||||
public String readAsString(String encoding) {
|
||||
Charset charset = Charset.forName(encoding);
|
||||
return readAsString(charset);
|
||||
}
|
||||
|
||||
public String readAsString() {
|
||||
return readAsString(Charset.defaultCharset());
|
||||
}
|
||||
|
||||
public String readAsString(Charset charset) {
|
||||
try {
|
||||
return doReadAsString(charset);
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String doReadAsString(Charset charset) throws CharacterCodingException {
|
||||
int unreadSize = totalBytesUnread();
|
||||
if (unreadSize > 0) {
|
||||
return readAsCharBuffer(charset).toString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private CharBuffer readAsCharBuffer(Charset charset) throws CharacterCodingException {
|
||||
CharsetDecoder decoder = charset.newDecoder().onMalformedInput(
|
||||
CodingErrorAction.REPLACE).onUnmappableCharacter(
|
||||
CodingErrorAction.REPLACE);
|
||||
CharBuffer charbuffer = CharBuffer.allocate(totalBytesUnread());
|
||||
ByteBuffer buf = null;
|
||||
boolean wasUnderflow = false;
|
||||
ByteBuffer nextBuf = null;
|
||||
boolean needsFlush = false;
|
||||
while (hasRemaining(nextBuf) || hasRemaining(buf) || prepareRead() != -1) {
|
||||
if (hasRemaining(buf)) {
|
||||
// handle decoding underflow, multi-byte unicode character at buffer chunk boundary
|
||||
if (!wasUnderflow) {
|
||||
throw new IllegalStateException("Unexpected state. Buffer has remaining bytes without underflow in decoding.");
|
||||
}
|
||||
if (!hasRemaining(nextBuf) && prepareRead() != -1) {
|
||||
nextBuf = currentReadChunk.readToNioBuffer();
|
||||
}
|
||||
// copy one by one until the underflow has been resolved
|
||||
buf = ByteBuffer.allocate(buf.remaining() + 1).put(buf);
|
||||
buf.put(nextBuf.get());
|
||||
BufferCaster.cast(buf).flip();
|
||||
} else {
|
||||
if (hasRemaining(nextBuf)) {
|
||||
buf = nextBuf;
|
||||
} else if (prepareRead() != -1) {
|
||||
buf = currentReadChunk.readToNioBuffer();
|
||||
if (!hasRemaining(buf)) {
|
||||
throw new IllegalStateException("Unexpected state. Buffer is empty.");
|
||||
}
|
||||
}
|
||||
nextBuf = null;
|
||||
}
|
||||
boolean endOfInput = !hasRemaining(nextBuf) && prepareRead() == -1;
|
||||
int bufRemainingBefore = buf.remaining();
|
||||
CoderResult result = decoder.decode(buf, charbuffer, false);
|
||||
if (bufRemainingBefore > buf.remaining()) {
|
||||
needsFlush = true;
|
||||
}
|
||||
if (endOfInput) {
|
||||
result = decoder.decode(ByteBuffer.allocate(0), charbuffer, true);
|
||||
if (!result.isUnderflow()) {
|
||||
result.throwException();
|
||||
}
|
||||
break;
|
||||
}
|
||||
wasUnderflow = result.isUnderflow();
|
||||
}
|
||||
if (needsFlush) {
|
||||
CoderResult result = decoder.flush(charbuffer);
|
||||
if (!result.isUnderflow()) {
|
||||
result.throwException();
|
||||
}
|
||||
}
|
||||
clear();
|
||||
// push back remaining bytes of multi-byte unicode character
|
||||
while (hasRemaining(buf)) {
|
||||
byte b = buf.get();
|
||||
try {
|
||||
getOutputStream().write(b);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
BufferCaster.cast(charbuffer).flip();
|
||||
return charbuffer;
|
||||
}
|
||||
|
||||
private boolean hasRemaining(ByteBuffer nextBuf) {
|
||||
return nextBuf != null && nextBuf.hasRemaining();
|
||||
}
|
||||
|
||||
public int totalBytesUnread() {
|
||||
int total = totalBytesUnreadInList;
|
||||
if (currentReadChunk != null) {
|
||||
total += currentReadChunk.bytesUnread();
|
||||
}
|
||||
if (currentWriteChunk != currentReadChunk && currentWriteChunk != null) {
|
||||
total += currentWriteChunk.bytesUnread();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
protected int allocateSpace() {
|
||||
int spaceLeft = currentWriteChunk.spaceLeft();
|
||||
if (spaceLeft == 0) {
|
||||
addChunk(currentWriteChunk);
|
||||
currentWriteChunk = new StreamByteBufferChunk(nextChunkSize);
|
||||
if (nextChunkSize < maxChunkSize) {
|
||||
nextChunkSize = Math.min(nextChunkSize * 2, maxChunkSize);
|
||||
}
|
||||
spaceLeft = currentWriteChunk.spaceLeft();
|
||||
}
|
||||
return spaceLeft;
|
||||
}
|
||||
|
||||
protected int prepareRead() {
|
||||
int bytesUnread = (currentReadChunk != null) ? currentReadChunk.bytesUnread() : 0;
|
||||
if (bytesUnread == 0) {
|
||||
if (!chunks.isEmpty()) {
|
||||
currentReadChunk = chunks.removeFirst();
|
||||
bytesUnread = currentReadChunk.bytesUnread();
|
||||
totalBytesUnreadInList -= bytesUnread;
|
||||
} else if (currentReadChunk != currentWriteChunk) {
|
||||
currentReadChunk = currentWriteChunk;
|
||||
bytesUnread = currentReadChunk.bytesUnread();
|
||||
} else {
|
||||
bytesUnread = -1;
|
||||
}
|
||||
}
|
||||
return bytesUnread;
|
||||
}
|
||||
|
||||
public static StreamByteBuffer of(List<byte[]> listOfByteArrays) {
|
||||
StreamByteBuffer buffer = new StreamByteBuffer();
|
||||
buffer.addChunks(listOfByteArrays);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private void addChunks(List<byte[]> listOfByteArrays) {
|
||||
for (byte[] buf : listOfByteArrays) {
|
||||
addChunk(new StreamByteBufferChunk(buf));
|
||||
}
|
||||
}
|
||||
|
||||
private void addChunk(StreamByteBufferChunk chunk) {
|
||||
chunks.add(chunk);
|
||||
totalBytesUnreadInList += chunk.bytesUnread();
|
||||
}
|
||||
|
||||
static class StreamByteBufferChunk {
|
||||
private int pointer;
|
||||
private byte[] buffer;
|
||||
private int size;
|
||||
private int used;
|
||||
|
||||
public StreamByteBufferChunk(int size) {
|
||||
this.size = size;
|
||||
buffer = new byte[size];
|
||||
}
|
||||
|
||||
public StreamByteBufferChunk(byte[] buf) {
|
||||
this.size = buf.length;
|
||||
this.buffer = buf;
|
||||
this.used = buf.length;
|
||||
}
|
||||
|
||||
public ByteBuffer readToNioBuffer() {
|
||||
if (pointer < used) {
|
||||
ByteBuffer result;
|
||||
if (pointer > 0 || used < size) {
|
||||
result = ByteBuffer.wrap(buffer, pointer, used - pointer);
|
||||
} else {
|
||||
result = ByteBuffer.wrap(buffer);
|
||||
}
|
||||
pointer = used;
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean write(byte b) {
|
||||
if (used < size) {
|
||||
buffer[used++] = b;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void write(byte[] b, int off, int len) {
|
||||
System.arraycopy(b, off, buffer, used, len);
|
||||
used = used + len;
|
||||
}
|
||||
|
||||
public void read(byte[] b, int off, int len) {
|
||||
System.arraycopy(buffer, pointer, b, off, len);
|
||||
pointer = pointer + len;
|
||||
}
|
||||
|
||||
public void writeTo(OutputStream target) throws IOException {
|
||||
if (pointer < used) {
|
||||
target.write(buffer, pointer, used - pointer);
|
||||
pointer = used;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
pointer = 0;
|
||||
}
|
||||
|
||||
public int bytesUsed() {
|
||||
return used;
|
||||
}
|
||||
|
||||
public int bytesUnread() {
|
||||
return used - pointer;
|
||||
}
|
||||
|
||||
public int read() {
|
||||
if (pointer < used) {
|
||||
return buffer[pointer++] & 0xff;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int spaceLeft() {
|
||||
return size - used;
|
||||
}
|
||||
|
||||
public int readFrom(InputStream inputStream, int len) throws IOException {
|
||||
int readBytes = inputStream.read(buffer, used, len);
|
||||
if(readBytes > 0) {
|
||||
used += readBytes;
|
||||
}
|
||||
return readBytes;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
used = pointer = 0;
|
||||
}
|
||||
|
||||
public byte[] readBuffer() {
|
||||
if (used == buffer.length && pointer == 0) {
|
||||
pointer = used;
|
||||
return buffer;
|
||||
} else if (pointer < used) {
|
||||
byte[] buf = new byte[used - pointer];
|
||||
read(buf, 0, used - pointer);
|
||||
return buf;
|
||||
} else {
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StreamByteBufferOutputStream extends OutputStream {
|
||||
private boolean closed;
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if ((off < 0) || (off > b.length) || (len < 0)
|
||||
|| ((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int bytesLeft = len;
|
||||
int currentOffset = off;
|
||||
while (bytesLeft > 0) {
|
||||
int spaceLeft = allocateSpace();
|
||||
int writeBytes = Math.min(spaceLeft, bytesLeft);
|
||||
currentWriteChunk.write(b, currentOffset, writeBytes);
|
||||
bytesLeft -= writeBytes;
|
||||
currentOffset += writeBytes;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
closed = true;
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
return closed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
allocateSpace();
|
||||
currentWriteChunk.write((byte) b);
|
||||
}
|
||||
|
||||
public StreamByteBuffer getBuffer() {
|
||||
return StreamByteBuffer.this;
|
||||
}
|
||||
}
|
||||
|
||||
class StreamByteBufferInputStream extends InputStream {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
prepareRead();
|
||||
return currentReadChunk.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
return readImpl(b, off, len);
|
||||
}
|
||||
|
||||
int readImpl(byte[] b, int off, int len) {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if ((off < 0) || (off > b.length) || (len < 0)
|
||||
|| ((off + len) > b.length) || ((off + len) < 0)) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
}
|
||||
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bytesLeft = len;
|
||||
int currentOffset = off;
|
||||
int bytesUnread = prepareRead();
|
||||
int totalBytesRead = 0;
|
||||
while (bytesLeft > 0 && bytesUnread != -1) {
|
||||
int readBytes = Math.min(bytesUnread, bytesLeft);
|
||||
currentReadChunk.read(b, currentOffset, readBytes);
|
||||
bytesLeft -= readBytes;
|
||||
currentOffset += readBytes;
|
||||
totalBytesRead += readBytes;
|
||||
bytesUnread = prepareRead();
|
||||
}
|
||||
if (totalBytesRead > 0) {
|
||||
return totalBytesRead;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
return totalBytesUnread();
|
||||
}
|
||||
|
||||
public StreamByteBuffer getBuffer() {
|
||||
return StreamByteBuffer.this;
|
||||
}
|
||||
|
||||
public byte[] readNextBuffer() {
|
||||
if (prepareRead() != -1) {
|
||||
return currentReadChunk.readBuffer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
chunks.clear();
|
||||
currentReadChunk = null;
|
||||
totalBytesUnreadInList = 0;
|
||||
currentWriteChunk.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Wraps a checked exception. Carries no other context.
|
||||
*/
|
||||
public final class UncheckedException extends RuntimeException {
|
||||
private UncheckedException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
private UncheckedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: always throws the failure in some form. The return value is to keep the compiler happy.
|
||||
*/
|
||||
public static RuntimeException throwAsUncheckedException(Throwable t) {
|
||||
return throwAsUncheckedException(t, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: always throws the failure in some form. The return value is to keep the compiler happy.
|
||||
*/
|
||||
public static RuntimeException throwAsUncheckedException(Throwable t, boolean preserveMessage) {
|
||||
if (t instanceof InterruptedException) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
if (t instanceof RuntimeException) {
|
||||
throw (RuntimeException) t;
|
||||
}
|
||||
if (t instanceof Error) {
|
||||
throw (Error) t;
|
||||
}
|
||||
if (t instanceof IOException) {
|
||||
if (preserveMessage) {
|
||||
throw new UncheckedIOException(t.getMessage(), t);
|
||||
} else {
|
||||
throw new UncheckedIOException(t);
|
||||
}
|
||||
}
|
||||
if (preserveMessage) {
|
||||
throw new UncheckedException(t.getMessage(), t);
|
||||
} else {
|
||||
throw new UncheckedException(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T callUnchecked(Callable<T> callable) {
|
||||
try {
|
||||
return callable.call();
|
||||
} catch (Exception e) {
|
||||
throw throwAsUncheckedException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unwraps passed InvocationTargetException hence making the stack of exceptions cleaner without losing information.
|
||||
*
|
||||
* Note: always throws the failure in some form. The return value is to keep the compiler happy.
|
||||
*
|
||||
* @param e to be unwrapped
|
||||
* @return an instance of RuntimeException based on the target exception of the parameter.
|
||||
*/
|
||||
public static RuntimeException unwrapAndRethrow(InvocationTargetException e) {
|
||||
return UncheckedException.throwAsUncheckedException(e.getTargetException());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
/**
|
||||
* <code>UncheckedIOException</code> is used to wrap an {@link java.io.IOException} into an unchecked exception.
|
||||
*/
|
||||
public class UncheckedIOException extends RuntimeException {
|
||||
public UncheckedIOException() {
|
||||
}
|
||||
|
||||
public UncheckedIOException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UncheckedIOException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public UncheckedIOException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public abstract class AbstractDecoder implements Decoder {
|
||||
private DecoderStream stream;
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
if (stream == null) {
|
||||
stream = new DecoderStream();
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] buffer) throws IOException {
|
||||
readBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] readBinary() throws EOFException, IOException {
|
||||
int size = readSmallInt();
|
||||
byte[] result = new byte[size];
|
||||
readBytes(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readSmallInt() throws EOFException, IOException {
|
||||
return readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readSmallLong() throws EOFException, IOException {
|
||||
return readLong();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Integer readNullableSmallInt() throws IOException {
|
||||
if (readBoolean()) {
|
||||
return readSmallInt();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readNullableString() throws EOFException, IOException {
|
||||
if (readBoolean()) {
|
||||
return readString();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipBytes(long count) throws EOFException, IOException {
|
||||
long remaining = count;
|
||||
while (remaining > 0) {
|
||||
long skipped = maybeSkip(remaining);
|
||||
if (skipped <= 0) {
|
||||
break;
|
||||
}
|
||||
remaining -= skipped;
|
||||
}
|
||||
if (remaining > 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T decodeChunked(DecodeAction<Decoder, T> decodeAction) throws EOFException, Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipChunked() throws EOFException, IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
protected abstract int maybeReadBytes(byte[] buffer, int offset, int count) throws IOException;
|
||||
|
||||
protected abstract long maybeSkip(long count) throws IOException;
|
||||
|
||||
private class DecoderStream extends InputStream {
|
||||
byte[] buffer = new byte[1];
|
||||
|
||||
@Override
|
||||
public long skip(long n) throws IOException {
|
||||
return maybeSkip(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
int read = maybeReadBytes(buffer, 0, 1);
|
||||
if (read <= 0) {
|
||||
return read;
|
||||
}
|
||||
return buffer[0] & 0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer) throws IOException {
|
||||
return maybeReadBytes(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer, int offset, int count) throws IOException {
|
||||
return maybeReadBytes(buffer, offset, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public abstract class AbstractEncoder implements Encoder {
|
||||
private EncoderStream stream;
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
if (stream == null) {
|
||||
stream = new EncoderStream();
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] bytes) throws IOException {
|
||||
writeBytes(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBinary(byte[] bytes) throws IOException {
|
||||
writeBinary(bytes, 0, bytes.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBinary(byte[] bytes, int offset, int count) throws IOException {
|
||||
writeSmallInt(count);
|
||||
writeBytes(bytes, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeChunked(EncodeAction<Encoder> writeAction) throws Exception {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallInt(int value) throws IOException {
|
||||
writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallLong(long value) throws IOException {
|
||||
writeLong(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNullableSmallInt(@Nullable Integer value) throws IOException {
|
||||
if (value == null) {
|
||||
writeBoolean(false);
|
||||
} else {
|
||||
writeBoolean(true);
|
||||
writeSmallInt(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNullableString(@Nullable CharSequence value) throws IOException {
|
||||
if (value == null) {
|
||||
writeBoolean(false);
|
||||
} else {
|
||||
writeBoolean(true);
|
||||
writeString(value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private class EncoderStream extends OutputStream {
|
||||
@Override
|
||||
public void write(byte[] buffer) throws IOException {
|
||||
writeBytes(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) throws IOException {
|
||||
writeBytes(buffer, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
writeByte((byte) b);
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* This abstract class provide a sensible default implementation for {@code Serializer} equality. This equality
|
||||
* implementation is required to enable cache instance reuse within the same Gradle runtime. Serializers are used
|
||||
* as cache parameter which need to be compared to determine compatible cache.
|
||||
*/
|
||||
public abstract class AbstractSerializer<T> implements Serializer<T> {
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Objects.equal(obj.getClass(), getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getClass());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class Cast {
|
||||
|
||||
/**
|
||||
* Casts the given object to the given type, providing a better error message than the default.
|
||||
*
|
||||
* The standard {@link Class#cast(Object)} method produces unsatisfactory error messages on some platforms
|
||||
* when it fails. All this method does is provide a better, consistent, error message.
|
||||
*
|
||||
* This should be used whenever there is a chance the cast could fail. If in doubt, use this.
|
||||
*
|
||||
* @param outputType The type to cast the input to
|
||||
* @param object The object to be cast (must not be {@code null})
|
||||
* @param <O> The type to be cast to
|
||||
* @param <I> The type of the object to be vast
|
||||
* @return The input object, cast to the output type
|
||||
*/
|
||||
public static <O, I> O cast(Class<O> outputType, I object) {
|
||||
try {
|
||||
return outputType.cast(object);
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(String.format(
|
||||
"Failed to cast object %s of type %s to target type %s", object, object.getClass().getName(), outputType.getName()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts the given object to the given type, providing a better error message than the default.
|
||||
*
|
||||
* The standard {@link Class#cast(Object)} method produces unsatisfactory error messages on some platforms
|
||||
* when it fails. All this method does is provide a better, consistent, error message.
|
||||
*
|
||||
* This should be used whenever there is a chance the cast could fail. If in doubt, use this.
|
||||
*
|
||||
* @param outputType The type to cast the input to
|
||||
* @param object The object to be cast
|
||||
* @param <O> The type to be cast to
|
||||
* @param <I> The type of the object to be vast
|
||||
* @return The input object, cast to the output type
|
||||
*/
|
||||
@Nullable
|
||||
public static <O, I> O castNullable(Class<O> outputType, @Nullable I object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
return cast(outputType, object);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> T uncheckedCast(@Nullable Object object) {
|
||||
return (T) object;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T uncheckedNonnullCast(Object object) {
|
||||
return (T) object;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
|
||||
public class ClassLoaderObjectInputStream extends ObjectInputStream {
|
||||
private final ClassLoader loader;
|
||||
|
||||
public ClassLoaderObjectInputStream(InputStream in, ClassLoader loader) throws IOException {
|
||||
super(in);
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return loader;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
|
||||
try {
|
||||
return Class.forName(desc.getName(), false, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return super.resolveClass(desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Provides a way to decode structured data from a backing byte stream. Implementations may buffer incoming bytes read
|
||||
* from the backing stream prior to decoding.
|
||||
*/
|
||||
public interface Decoder {
|
||||
/**
|
||||
* Returns an InputStream which can be used to read raw bytes.
|
||||
*/
|
||||
InputStream getInputStream();
|
||||
|
||||
/**
|
||||
* Reads a signed 64 bit long value. Can read any value that was written using {@link Encoder#writeLong(long)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the long value can be fully read.
|
||||
*/
|
||||
long readLong() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a signed 64 bit int value. Can read any value that was written using {@link Encoder#writeSmallLong(long)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the int value can be fully read.
|
||||
*/
|
||||
long readSmallLong() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a signed 32 bit int value. Can read any value that was written using {@link Encoder#writeInt(int)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the int value can be fully read.
|
||||
*/
|
||||
int readInt() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a signed 32 bit int value. Can read any value that was written using {@link Encoder#writeSmallInt(int)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the int value can be fully read.
|
||||
*/
|
||||
int readSmallInt() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a nullable signed 32 bit int value.
|
||||
*
|
||||
* @see #readSmallInt()
|
||||
*/
|
||||
@Nullable
|
||||
Integer readNullableSmallInt() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a boolean value. Can read any value that was written using {@link Encoder#writeBoolean(boolean)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the boolean value can be fully read.
|
||||
*/
|
||||
boolean readBoolean() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a non-null string value. Can read any value that was written using {@link Encoder#writeString(CharSequence)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the string can be fully read.
|
||||
*/
|
||||
String readString() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a nullable string value. Can reads any value that was written using {@link Encoder#writeNullableString(CharSequence)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the string can be fully read.
|
||||
*/
|
||||
@Nullable
|
||||
String readNullableString() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a byte value. Can read any byte value that was written using one of the raw byte methods on {@link Encoder}, such as {@link Encoder#writeByte(byte)} or {@link Encoder#getOutputStream()}
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached.
|
||||
*/
|
||||
byte readByte() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads bytes into the given buffer, filling the buffer. Can read any byte values that were written using one of the raw byte methods on {@link Encoder}, such as {@link
|
||||
* Encoder#writeBytes(byte[])} or {@link Encoder#getOutputStream()}
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the buffer is full.
|
||||
*/
|
||||
void readBytes(byte[] buffer) throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads the specified number of bytes into the given buffer. Can read any byte values that were written using one of the raw byte methods on {@link Encoder}, such as {@link
|
||||
* Encoder#writeBytes(byte[])} or {@link Encoder#getOutputStream()}
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the specified number of bytes were read.
|
||||
*/
|
||||
void readBytes(byte[] buffer, int offset, int count) throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a byte array. Can read any byte array written using {@link Encoder#writeBinary(byte[])} or {@link Encoder#writeBinary(byte[], int, int)}.
|
||||
*
|
||||
* @throws EOFException when the end of the byte stream is reached before the byte array was fully read.
|
||||
*/
|
||||
byte[] readBinary() throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Skips the given number of bytes. Can skip over any byte values that were written using one of the raw byte methods on {@link Encoder}.
|
||||
*/
|
||||
void skipBytes(long count) throws EOFException, IOException;
|
||||
|
||||
/**
|
||||
* Reads a byte stream written using {@link Encoder#encodeChunked(Encoder.EncodeAction)}.
|
||||
*/
|
||||
<T> T decodeChunked(DecodeAction<Decoder, T> decodeAction) throws EOFException, Exception;
|
||||
|
||||
/**
|
||||
* Skips over a byte stream written using {@link Encoder#encodeChunked(Encoder.EncodeAction)}, discarding its content.
|
||||
*/
|
||||
void skipChunked() throws EOFException, IOException;
|
||||
|
||||
interface DecodeAction<IN, OUT> {
|
||||
OUT read(IN source) throws Exception;
|
||||
}
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
public class DefaultSerializer<T> extends AbstractSerializer<T> {
|
||||
private ClassLoader classLoader;
|
||||
|
||||
public DefaultSerializer() {
|
||||
classLoader = getClass().getClassLoader();
|
||||
}
|
||||
|
||||
public DefaultSerializer(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader != null ? classLoader : getClass().getClassLoader();
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(Decoder decoder) throws Exception {
|
||||
try {
|
||||
return Cast.uncheckedNonnullCast(new ClassLoaderObjectInputStream(decoder.getInputStream(), classLoader).readObject());
|
||||
} catch (StreamCorruptedException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Encoder encoder, T value) throws IOException {
|
||||
ObjectOutputStream objectStr = new ObjectOutputStream(encoder.getOutputStream());
|
||||
objectStr.writeObject(value);
|
||||
objectStr.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DefaultSerializer<?> rhs = (DefaultSerializer<?>) obj;
|
||||
return Objects.equal(classLoader, rhs.classLoader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(super.hashCode(), classLoader);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Provides a way to encode structured data to a backing byte stream. Implementations may buffer outgoing encoded bytes prior
|
||||
* to writing to the backing byte stream.
|
||||
*/
|
||||
public interface Encoder {
|
||||
/**
|
||||
* Returns an {@link OutputStream) that can be used to write raw bytes to the stream.
|
||||
*/
|
||||
OutputStream getOutputStream();
|
||||
|
||||
/**
|
||||
* Writes a raw byte value to the stream.
|
||||
*/
|
||||
void writeByte(byte value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the given raw bytes to the stream. Does not encode any length information.
|
||||
*/
|
||||
void writeBytes(byte[] bytes) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the given raw bytes to the stream. Does not encode any length information.
|
||||
*/
|
||||
void writeBytes(byte[] bytes, int offset, int count) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the given byte array to the stream. Encodes the bytes and length information.
|
||||
*/
|
||||
void writeBinary(byte[] bytes) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the given byte array to the stream. Encodes the bytes and length information.
|
||||
*/
|
||||
void writeBinary(byte[] bytes, int offset, int count) throws IOException;
|
||||
|
||||
/**
|
||||
* Appends an encoded stream to this stream. Encodes the stream as a series of chunks with length information.
|
||||
*/
|
||||
void encodeChunked(EncodeAction<Encoder> writeAction) throws Exception;
|
||||
|
||||
/**
|
||||
* Writes a signed 64 bit long value. The implementation may encode the value as a variable number of bytes, not necessarily as 8 bytes.
|
||||
*/
|
||||
void writeLong(long value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a signed 64 bit long value whose value is likely to be small and positive but may not be. The implementation may encode the value in a way that is more efficient for small positive
|
||||
* values.
|
||||
*/
|
||||
void writeSmallLong(long value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a signed 32 bit int value. The implementation may encode the value as a variable number of bytes, not necessarily as 4 bytes.
|
||||
*/
|
||||
void writeInt(int value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a signed 32 bit int value whose value is likely to be small and positive but may not be. The implementation may encode the value in a way that
|
||||
* is more efficient for small positive values.
|
||||
*/
|
||||
void writeSmallInt(int value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a nullable signed 32 bit int value whose value is likely to be small and positive but may not be.
|
||||
*
|
||||
* @see #writeSmallInt(int)
|
||||
*/
|
||||
void writeNullableSmallInt(@Nullable Integer value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a boolean value.
|
||||
*/
|
||||
void writeBoolean(boolean value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a non-null string value.
|
||||
*/
|
||||
void writeString(CharSequence value) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes a nullable string value.
|
||||
*/
|
||||
void writeNullableString(@Nullable CharSequence value) throws IOException;
|
||||
|
||||
interface EncodeAction<T> {
|
||||
void write(T target) throws Exception;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import java.io.Flushable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Represents an {@link Encoder} that buffers encoded data prior to writing to the backing stream.
|
||||
*/
|
||||
public interface FlushableEncoder extends Encoder, Flushable {
|
||||
/**
|
||||
* Ensures that all buffered data has been written to the backing stream. Does not flush the backing stream.
|
||||
*/
|
||||
@Override
|
||||
void flush() throws IOException;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import java.io.EOFException;
|
||||
|
||||
public interface ObjectReader<T> {
|
||||
/**
|
||||
* Reads the next object from the stream.
|
||||
*
|
||||
* @throws EOFException When the next object cannot be fully read due to reaching the end of stream.
|
||||
*/
|
||||
T read() throws EOFException, Exception;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
public interface ObjectWriter<T> {
|
||||
void write(T value) throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2009 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
import java.io.EOFException;
|
||||
|
||||
public interface Serializer<T> {
|
||||
/**
|
||||
* Reads the next object from the given stream. The implementation must not perform any buffering, so that it reads only those bytes from the input stream that are
|
||||
* required to deserialize the next object.
|
||||
*
|
||||
* @throws EOFException When the next object cannot be fully read due to reaching the end of stream.
|
||||
*/
|
||||
T read(Decoder decoder) throws EOFException, Exception;
|
||||
|
||||
/**
|
||||
* Writes the given object to the given stream. The implementation must not perform any buffering.
|
||||
*/
|
||||
void write(Encoder encoder, T value) throws Exception;
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize;
|
||||
|
||||
/**
|
||||
* Implementations must allow concurrent reading and writing, so that a thread can read and a thread can write at the same time.
|
||||
* Implementations do not need to support multiple read threads or multiple write threads.
|
||||
*/
|
||||
public interface StatefulSerializer<T> {
|
||||
/**
|
||||
* Should not perform any buffering
|
||||
*/
|
||||
ObjectReader<T> newReader(Decoder decoder);
|
||||
|
||||
/**
|
||||
* Should not perform any buffering
|
||||
*/
|
||||
ObjectWriter<T> newWriter(Encoder encoder);
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize.kryo;
|
||||
|
||||
import com.esotericsoftware.kryo.KryoException;
|
||||
import com.esotericsoftware.kryo.io.Input;
|
||||
import seaweedfs.client.btree.serialize.AbstractDecoder;
|
||||
import seaweedfs.client.btree.serialize.Decoder;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Note that this decoder uses buffering, so will attempt to read beyond the end of the encoded data. This means you should use this type only when this decoder will be used to decode the entire
|
||||
* stream.
|
||||
*/
|
||||
public class KryoBackedDecoder extends AbstractDecoder implements Decoder, Closeable {
|
||||
private final Input input;
|
||||
private final InputStream inputStream;
|
||||
private long extraSkipped;
|
||||
private KryoBackedDecoder nested;
|
||||
|
||||
public KryoBackedDecoder(InputStream inputStream) {
|
||||
this(inputStream, 4096);
|
||||
}
|
||||
|
||||
public KryoBackedDecoder(InputStream inputStream, int bufferSize) {
|
||||
this.inputStream = inputStream;
|
||||
input = new Input(this.inputStream, bufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maybeReadBytes(byte[] buffer, int offset, int count) {
|
||||
return input.read(buffer, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long maybeSkip(long count) throws IOException {
|
||||
// Work around some bugs in Input.skip()
|
||||
int remaining = input.limit() - input.position();
|
||||
if (remaining == 0) {
|
||||
long skipped = inputStream.skip(count);
|
||||
if (skipped > 0) {
|
||||
extraSkipped += skipped;
|
||||
}
|
||||
return skipped;
|
||||
} else if (count <= remaining) {
|
||||
input.setPosition(input.position() + (int) count);
|
||||
return count;
|
||||
} else {
|
||||
input.setPosition(input.limit());
|
||||
return remaining;
|
||||
}
|
||||
}
|
||||
|
||||
private RuntimeException maybeEndOfStream(KryoException e) throws EOFException {
|
||||
if (e.getMessage().equals("Buffer underflow.")) {
|
||||
throw (EOFException) (new EOFException().initCause(e));
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte readByte() throws EOFException {
|
||||
try {
|
||||
return input.readByte();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] buffer, int offset, int count) throws EOFException {
|
||||
try {
|
||||
input.readBytes(buffer, offset, count);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLong() throws EOFException {
|
||||
try {
|
||||
return input.readLong();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readSmallLong() throws EOFException, IOException {
|
||||
try {
|
||||
return input.readLong(true);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInt() throws EOFException {
|
||||
try {
|
||||
return input.readInt();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readSmallInt() throws EOFException {
|
||||
try {
|
||||
return input.readInt(true);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readBoolean() throws EOFException {
|
||||
try {
|
||||
return input.readBoolean();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readString() throws EOFException {
|
||||
return readNullableString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readNullableString() throws EOFException {
|
||||
try {
|
||||
return input.readString();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipChunked() throws EOFException, IOException {
|
||||
while (true) {
|
||||
int count = readSmallInt();
|
||||
if (count == 0) {
|
||||
break;
|
||||
}
|
||||
skipBytes(count);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T decodeChunked(DecodeAction<Decoder, T> decodeAction) throws EOFException, Exception {
|
||||
if (nested == null) {
|
||||
nested = new KryoBackedDecoder(new InputStream() {
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] buffer, int offset, int length) throws IOException {
|
||||
int count = readSmallInt();
|
||||
if (count == 0) {
|
||||
// End of stream has been reached
|
||||
return -1;
|
||||
}
|
||||
if (count > length) {
|
||||
// For now, assume same size buffers used to read and write
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
readBytes(buffer, offset, count);
|
||||
return count;
|
||||
}
|
||||
});
|
||||
}
|
||||
T value = decodeAction.read(nested);
|
||||
if (readSmallInt() != 0) {
|
||||
throw new IllegalStateException("Expecting the end of nested stream.");
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of bytes consumed by this decoder. Some additional bytes may also be buffered by this decoder but have not been consumed.
|
||||
*/
|
||||
public long getReadPosition() {
|
||||
return input.total() + extraSkipped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize.kryo;
|
||||
|
||||
import com.esotericsoftware.kryo.io.Output;
|
||||
import seaweedfs.client.btree.serialize.AbstractEncoder;
|
||||
import seaweedfs.client.btree.serialize.Encoder;
|
||||
import seaweedfs.client.btree.serialize.FlushableEncoder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
public class KryoBackedEncoder extends AbstractEncoder implements FlushableEncoder, Closeable {
|
||||
private final Output output;
|
||||
private KryoBackedEncoder nested;
|
||||
|
||||
public KryoBackedEncoder(OutputStream outputStream) {
|
||||
this(outputStream, 4096);
|
||||
}
|
||||
|
||||
public KryoBackedEncoder(OutputStream outputStream, int bufferSize) {
|
||||
output = new Output(outputStream, bufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(byte value) {
|
||||
output.writeByte(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] bytes, int offset, int count) {
|
||||
output.writeBytes(bytes, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(long value) {
|
||||
output.writeLong(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallLong(long value) {
|
||||
output.writeLong(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(int value) {
|
||||
output.writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallInt(int value) {
|
||||
output.writeInt(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBoolean(boolean value) {
|
||||
output.writeBoolean(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeString(CharSequence value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Cannot encode a null string.");
|
||||
}
|
||||
output.writeString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNullableString(@Nullable CharSequence value) {
|
||||
output.writeString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encodeChunked(EncodeAction<Encoder> writeAction) throws Exception {
|
||||
if (nested == null) {
|
||||
nested = new KryoBackedEncoder(new OutputStream() {
|
||||
@Override
|
||||
public void write(byte[] buffer, int offset, int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
}
|
||||
writeSmallInt(length);
|
||||
writeBytes(buffer, offset, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] buffer) throws IOException {
|
||||
write(buffer, 0, buffer.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
});
|
||||
}
|
||||
writeAction.write(nested);
|
||||
nested.flush();
|
||||
writeSmallInt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of bytes written by this encoder, some of which may still be buffered.
|
||||
*/
|
||||
public long getWritePosition() {
|
||||
return output.total();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
output.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
output.close();
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize.kryo;
|
||||
|
||||
import com.esotericsoftware.kryo.KryoException;
|
||||
import com.esotericsoftware.kryo.io.Input;
|
||||
import seaweedfs.client.btree.serialize.AbstractDecoder;
|
||||
import seaweedfs.client.btree.serialize.Decoder;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Note that this decoder uses buffering, so will attempt to read beyond the end of the encoded data. This means you should use this type only when this decoder will be used to decode the entire
|
||||
* stream.
|
||||
*/
|
||||
public class StringDeduplicatingKryoBackedDecoder extends AbstractDecoder implements Decoder, Closeable {
|
||||
public static final int INITIAL_CAPACITY = 32;
|
||||
private final Input input;
|
||||
private final InputStream inputStream;
|
||||
private String[] strings;
|
||||
private long extraSkipped;
|
||||
|
||||
public StringDeduplicatingKryoBackedDecoder(InputStream inputStream) {
|
||||
this(inputStream, 4096);
|
||||
}
|
||||
|
||||
public StringDeduplicatingKryoBackedDecoder(InputStream inputStream, int bufferSize) {
|
||||
this.inputStream = inputStream;
|
||||
input = new Input(this.inputStream, bufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int maybeReadBytes(byte[] buffer, int offset, int count) {
|
||||
return input.read(buffer, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected long maybeSkip(long count) throws IOException {
|
||||
// Work around some bugs in Input.skip()
|
||||
int remaining = input.limit() - input.position();
|
||||
if (remaining == 0) {
|
||||
long skipped = inputStream.skip(count);
|
||||
if (skipped > 0) {
|
||||
extraSkipped += skipped;
|
||||
}
|
||||
return skipped;
|
||||
} else if (count <= remaining) {
|
||||
input.setPosition(input.position() + (int) count);
|
||||
return count;
|
||||
} else {
|
||||
input.setPosition(input.limit());
|
||||
return remaining;
|
||||
}
|
||||
}
|
||||
|
||||
private RuntimeException maybeEndOfStream(KryoException e) throws EOFException {
|
||||
if (e.getMessage().equals("Buffer underflow.")) {
|
||||
throw (EOFException) (new EOFException().initCause(e));
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte readByte() throws EOFException {
|
||||
try {
|
||||
return input.readByte();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] buffer, int offset, int count) throws EOFException {
|
||||
try {
|
||||
input.readBytes(buffer, offset, count);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readLong() throws EOFException {
|
||||
try {
|
||||
return input.readLong();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long readSmallLong() throws EOFException, IOException {
|
||||
try {
|
||||
return input.readLong(true);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInt() throws EOFException {
|
||||
try {
|
||||
return input.readInt();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readSmallInt() throws EOFException {
|
||||
try {
|
||||
return input.readInt(true);
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readBoolean() throws EOFException {
|
||||
try {
|
||||
return input.readBoolean();
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readString() throws EOFException {
|
||||
return readNullableString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readNullableString() throws EOFException {
|
||||
try {
|
||||
int idx = readInt();
|
||||
if (idx == -1) {
|
||||
return null;
|
||||
}
|
||||
if (strings == null) {
|
||||
strings = new String[INITIAL_CAPACITY];
|
||||
}
|
||||
String string = null;
|
||||
if (idx >= strings.length) {
|
||||
String[] grow = new String[strings.length * 3 / 2];
|
||||
System.arraycopy(strings, 0, grow, 0, strings.length);
|
||||
strings = grow;
|
||||
} else {
|
||||
string = strings[idx];
|
||||
}
|
||||
if (string == null) {
|
||||
string = input.readString();
|
||||
strings[idx] = string;
|
||||
}
|
||||
return string;
|
||||
} catch (KryoException e) {
|
||||
throw maybeEndOfStream(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of bytes consumed by this decoder. Some additional bytes may also be buffered by this decoder but have not been consumed.
|
||||
*/
|
||||
public long getReadPosition() {
|
||||
return input.total() + extraSkipped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
strings = null;
|
||||
input.close();
|
||||
}
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright 2018 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize.kryo;
|
||||
|
||||
import com.esotericsoftware.kryo.io.Output;
|
||||
import com.google.common.collect.Maps;
|
||||
import seaweedfs.client.btree.serialize.AbstractEncoder;
|
||||
import seaweedfs.client.btree.serialize.FlushableEncoder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.Closeable;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Map;
|
||||
|
||||
public class StringDeduplicatingKryoBackedEncoder extends AbstractEncoder implements FlushableEncoder, Closeable {
|
||||
private Map<String, Integer> strings;
|
||||
|
||||
private final Output output;
|
||||
|
||||
public StringDeduplicatingKryoBackedEncoder(OutputStream outputStream) {
|
||||
this(outputStream, 4096);
|
||||
}
|
||||
|
||||
public StringDeduplicatingKryoBackedEncoder(OutputStream outputStream, int bufferSize) {
|
||||
output = new Output(outputStream, bufferSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeByte(byte value) {
|
||||
output.writeByte(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] bytes, int offset, int count) {
|
||||
output.writeBytes(bytes, offset, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeLong(long value) {
|
||||
output.writeLong(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallLong(long value) {
|
||||
output.writeLong(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInt(int value) {
|
||||
output.writeInt(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSmallInt(int value) {
|
||||
output.writeInt(value, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBoolean(boolean value) {
|
||||
output.writeBoolean(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeString(CharSequence value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Cannot encode a null string.");
|
||||
}
|
||||
writeNullableString(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeNullableString(@Nullable CharSequence value) {
|
||||
if (value == null) {
|
||||
output.writeInt(-1);
|
||||
return;
|
||||
} else {
|
||||
if (strings == null) {
|
||||
strings = Maps.newHashMapWithExpectedSize(1024);
|
||||
}
|
||||
}
|
||||
String key = value.toString();
|
||||
Integer index = strings.get(key);
|
||||
if (index == null) {
|
||||
index = strings.size();
|
||||
output.writeInt(index);
|
||||
strings.put(key, index);
|
||||
output.writeString(key);
|
||||
} else {
|
||||
output.writeInt(index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of bytes written by this encoder, some of which may still be buffered.
|
||||
*/
|
||||
public long getWritePosition() {
|
||||
return output.total();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
output.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
output.close();
|
||||
}
|
||||
|
||||
public void done() {
|
||||
strings = null;
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2012 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree.serialize.kryo;
|
||||
|
||||
import seaweedfs.client.btree.serialize.*;
|
||||
|
||||
public class TypeSafeSerializer<T> implements StatefulSerializer<Object> {
|
||||
private final Class<T> type;
|
||||
private final StatefulSerializer<T> serializer;
|
||||
|
||||
public TypeSafeSerializer(Class<T> type, StatefulSerializer<T> serializer) {
|
||||
this.type = type;
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectReader<Object> newReader(Decoder decoder) {
|
||||
final ObjectReader<T> reader = serializer.newReader(decoder);
|
||||
return new ObjectReader<Object>() {
|
||||
@Override
|
||||
public Object read() throws Exception {
|
||||
return reader.read();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectWriter<Object> newWriter(Encoder encoder) {
|
||||
final ObjectWriter<T> writer = serializer.newWriter(encoder);
|
||||
return new ObjectWriter<Object>() {
|
||||
@Override
|
||||
public void write(Object value) throws Exception {
|
||||
writer.write(type.cast(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+476
@@ -0,0 +1,476 @@
|
||||
/*
|
||||
* Copyright 2010 the original author or authors.
|
||||
*
|
||||
* Licensed 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 seaweedfs.client.btree;
|
||||
|
||||
import seaweedfs.client.btree.serialize.DefaultSerializer;
|
||||
import seaweedfs.client.btree.serialize.Serializer;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class BTreePersistentIndexedCacheTest {
|
||||
private final Serializer<String> stringSerializer = new DefaultSerializer<String>();
|
||||
private final Serializer<Integer> integerSerializer = new DefaultSerializer<Integer>();
|
||||
private BTreePersistentIndexedCache<String, Integer> cache;
|
||||
private File cacheFile;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
cacheFile = tmpDirFile("cache.bin");
|
||||
}
|
||||
|
||||
public File tmpDirFile(String filename) {
|
||||
File f = new File("/Users/chris/tmp/mm/dev/btree_test");
|
||||
// File f = new File("/tmp/btree_test");
|
||||
f.mkdirs();
|
||||
return new File(f, filename);
|
||||
}
|
||||
|
||||
private void createCache() {
|
||||
cache = new BTreePersistentIndexedCache<String, Integer>(cacheFile, stringSerializer, integerSerializer, (short) 4, 100);
|
||||
}
|
||||
|
||||
private void verifyAndCloseCache() {
|
||||
cache.verify();
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getReturnsNullWhenEntryDoesNotExist() {
|
||||
createCache();
|
||||
assertNull(cache.get("unknown"));
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsAddedEntries() {
|
||||
createCache();
|
||||
checkAdds(1, 2, 3, 4, 5);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsAddedEntriesInReverseOrder() {
|
||||
createCache();
|
||||
checkAdds(5, 4, 3, 2, 1);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsAddedEntriesOverMultipleIndexBlocks() {
|
||||
createCache();
|
||||
checkAdds(3, 2, 11, 5, 7, 1, 10, 8, 9, 4, 6, 0);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsUpdates() {
|
||||
createCache();
|
||||
checkUpdates(3, 2, 11, 5, 7, 1, 10, 8, 9, 4, 6, 0);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesUpdatesWhenBlockSizeDecreases() {
|
||||
BTreePersistentIndexedCache<String, List<Integer>> cache =
|
||||
new BTreePersistentIndexedCache<String, List<Integer>>(
|
||||
tmpDirFile("listcache.bin"), stringSerializer,
|
||||
new DefaultSerializer<List<Integer>>(), (short) 4, 100);
|
||||
|
||||
List<Integer> values = Arrays.asList(3, 2, 11, 5, 7, 1, 10, 8, 9, 4, 6, 0);
|
||||
Map<Integer, List<Integer>> updated = new LinkedHashMap<Integer, List<Integer>>();
|
||||
|
||||
for (int i = 10; i > 0; i--) {
|
||||
for (Integer value : values) {
|
||||
String key = String.format("key_%d", value);
|
||||
List<Integer> newValue = new ArrayList<Integer>(i);
|
||||
for (int j = 0; j < i * 2; j++) {
|
||||
newValue.add(j);
|
||||
}
|
||||
cache.put(key, newValue);
|
||||
updated.put(value, newValue);
|
||||
}
|
||||
|
||||
checkListEntries(cache, updated);
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
|
||||
checkListEntries(cache, updated);
|
||||
|
||||
cache.verify();
|
||||
cache.close();
|
||||
}
|
||||
|
||||
private void checkListEntries(BTreePersistentIndexedCache<String, List<Integer>> cache, Map<Integer, List<Integer>> updated) {
|
||||
for (Map.Entry<Integer, List<Integer>> entry : updated.entrySet()) {
|
||||
String key = String.format("key_%d", entry.getKey());
|
||||
assertThat(cache.get(key), equalTo(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesUpdatesWhenBlockSizeIncreases() {
|
||||
BTreePersistentIndexedCache<String, List<Integer>> cache =
|
||||
new BTreePersistentIndexedCache<String, List<Integer>>(
|
||||
tmpDirFile("listcache.bin"), stringSerializer,
|
||||
new DefaultSerializer<List<Integer>>(), (short) 4, 100);
|
||||
|
||||
List<Integer> values = Arrays.asList(3, 2, 11, 5, 7, 1, 10, 8, 9, 4, 6, 0);
|
||||
Map<Integer, List<Integer>> updated = new LinkedHashMap<Integer, List<Integer>>();
|
||||
|
||||
for (int i = 1; i < 10; i++) {
|
||||
for (Integer value : values) {
|
||||
String key = String.format("key_%d", value);
|
||||
List<Integer> newValue = new ArrayList<Integer>(i);
|
||||
for (int j = 0; j < i * 2; j++) {
|
||||
newValue.add(j);
|
||||
}
|
||||
cache.put(key, newValue);
|
||||
updated.put(value, newValue);
|
||||
}
|
||||
|
||||
checkListEntries(cache, updated);
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
|
||||
checkListEntries(cache, updated);
|
||||
|
||||
cache.verify();
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsAddedEntriesAfterReopen() {
|
||||
createCache();
|
||||
|
||||
checkAdds(1, 2, 3, 4);
|
||||
|
||||
cache.reset();
|
||||
|
||||
checkAdds(5, 6, 7, 8);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsReplacedEntries() {
|
||||
createCache();
|
||||
|
||||
cache.put("key_1", 1);
|
||||
cache.put("key_2", 2);
|
||||
cache.put("key_3", 3);
|
||||
cache.put("key_4", 4);
|
||||
cache.put("key_5", 5);
|
||||
|
||||
cache.put("key_1", 1);
|
||||
cache.put("key_4", 12);
|
||||
|
||||
assertThat(cache.get("key_1"), equalTo(1));
|
||||
assertThat(cache.get("key_2"), equalTo(2));
|
||||
assertThat(cache.get("key_3"), equalTo(3));
|
||||
assertThat(cache.get("key_4"), equalTo(12));
|
||||
assertThat(cache.get("key_5"), equalTo(5));
|
||||
|
||||
cache.reset();
|
||||
|
||||
assertThat(cache.get("key_1"), equalTo(1));
|
||||
assertThat(cache.get("key_2"), equalTo(2));
|
||||
assertThat(cache.get("key_3"), equalTo(3));
|
||||
assertThat(cache.get("key_4"), equalTo(12));
|
||||
assertThat(cache.get("key_5"), equalTo(5));
|
||||
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reusesEmptySpaceWhenPuttingEntries() {
|
||||
BTreePersistentIndexedCache<String, String> cache = new BTreePersistentIndexedCache<String, String>(cacheFile, stringSerializer, stringSerializer, (short) 4, 100);
|
||||
|
||||
long beforeLen = cacheFile.length();
|
||||
if (beforeLen>0){
|
||||
System.out.println(String.format("cache %s: %s", "key_new", cache.get("key_new")));
|
||||
}
|
||||
|
||||
cache.put("key_1", "abcd");
|
||||
cache.put("key_2", "abcd");
|
||||
cache.put("key_3", "abcd");
|
||||
cache.put("key_4", "abcd");
|
||||
cache.put("key_5", "abcd");
|
||||
|
||||
long len = cacheFile.length();
|
||||
assertTrue(len > 0L);
|
||||
|
||||
System.out.println(String.format("cache file size %d => %d", beforeLen, len));
|
||||
|
||||
cache.put("key_1", "1234");
|
||||
assertThat(cacheFile.length(), equalTo(len));
|
||||
|
||||
cache.remove("key_1");
|
||||
cache.put("key_new", "a1b2");
|
||||
assertThat(cacheFile.length(), equalTo(len));
|
||||
|
||||
cache.put("key_new", "longer value assertThat(cacheFile.length(), equalTo(len))");
|
||||
System.out.println(String.format("cache file size %d beforeLen %d", cacheFile.length(), len));
|
||||
// assertTrue(cacheFile.length() > len);
|
||||
len = cacheFile.length();
|
||||
|
||||
cache.put("key_1", "1234");
|
||||
assertThat(cacheFile.length(), equalTo(len));
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canHandleLargeNumberOfEntries() {
|
||||
createCache();
|
||||
int count = 2000;
|
||||
List<Integer> values = new ArrayList<Integer>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
values.add(i);
|
||||
}
|
||||
|
||||
checkAddsAndRemoves(null, values);
|
||||
|
||||
long len = cacheFile.length();
|
||||
|
||||
checkAddsAndRemoves(Collections.reverseOrder(), values);
|
||||
|
||||
// need to make this better
|
||||
assertTrue(cacheFile.length() < (long)(1.4 * len));
|
||||
|
||||
checkAdds(values);
|
||||
|
||||
// need to make this better
|
||||
assertTrue(cacheFile.length() < (long) (1.4 * 1.4 * len));
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsRemovalOfEntries() {
|
||||
createCache();
|
||||
checkAddsAndRemoves(1, 2, 3, 4, 5);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsRemovalOfEntriesInReverse() {
|
||||
createCache();
|
||||
checkAddsAndRemoves(Collections.<Integer>reverseOrder(), 1, 2, 3, 4, 5);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistsRemovalOfEntriesOverMultipleIndexBlocks() {
|
||||
createCache();
|
||||
checkAddsAndRemoves(4, 12, 9, 1, 3, 10, 11, 7, 8, 2, 5, 6);
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removalRedistributesRemainingEntriesWithLeftSibling() {
|
||||
createCache();
|
||||
// Ends up with: 1 2 3 -> 4 <- 5 6
|
||||
checkAdds(1, 2, 5, 6, 4, 3);
|
||||
cache.verify();
|
||||
cache.remove("key_5");
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removalMergesRemainingEntriesIntoLeftSibling() {
|
||||
createCache();
|
||||
// Ends up with: 1 2 -> 3 <- 4 5
|
||||
checkAdds(1, 2, 4, 5, 3);
|
||||
cache.verify();
|
||||
cache.remove("key_4");
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removalRedistributesRemainingEntriesWithRightSibling() {
|
||||
createCache();
|
||||
// Ends up with: 1 2 -> 3 <- 4 5 6
|
||||
checkAdds(1, 2, 4, 5, 3, 6);
|
||||
cache.verify();
|
||||
cache.remove("key_2");
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removalMergesRemainingEntriesIntoRightSibling() {
|
||||
createCache();
|
||||
// Ends up with: 1 2 -> 3 <- 4 5
|
||||
checkAdds(1, 2, 4, 5, 3);
|
||||
cache.verify();
|
||||
cache.remove("key_2");
|
||||
verifyAndCloseCache();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesOpeningATruncatedCacheFile() throws IOException {
|
||||
BTreePersistentIndexedCache<String, Integer> cache = new BTreePersistentIndexedCache<String, Integer>(cacheFile, stringSerializer, integerSerializer);
|
||||
|
||||
assertNull(cache.get("key_1"));
|
||||
cache.put("key_1", 99);
|
||||
|
||||
RandomAccessFile file = new RandomAccessFile(cacheFile, "rw");
|
||||
file.setLength(file.length() - 10);
|
||||
file.close();
|
||||
|
||||
cache.reset();
|
||||
|
||||
assertNull(cache.get("key_1"));
|
||||
cache.verify();
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canUseFileAsKey() {
|
||||
BTreePersistentIndexedCache<File, Integer> cache = new BTreePersistentIndexedCache<File, Integer>(cacheFile, new DefaultSerializer<File>(), integerSerializer);
|
||||
|
||||
cache.put(new File("file"), 1);
|
||||
cache.put(new File("dir/file"), 2);
|
||||
cache.put(new File("File"), 3);
|
||||
|
||||
assertThat(cache.get(new File("file")), equalTo(1));
|
||||
assertThat(cache.get(new File("dir/file")), equalTo(2));
|
||||
assertThat(cache.get(new File("File")), equalTo(3));
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handlesKeysWithSameHashCode() {
|
||||
createCache();
|
||||
|
||||
String key1 = new String(new byte[]{2, 31});
|
||||
String key2 = new String(new byte[]{1, 62});
|
||||
cache.put(key1, 1);
|
||||
cache.put(key2, 2);
|
||||
|
||||
assertThat(cache.get(key1), equalTo(1));
|
||||
assertThat(cache.get(key2), equalTo(2));
|
||||
|
||||
cache.close();
|
||||
}
|
||||
|
||||
private void checkAdds(Integer... values) {
|
||||
checkAdds(Arrays.asList(values));
|
||||
}
|
||||
|
||||
private Map<String, Integer> checkAdds(Iterable<Integer> values) {
|
||||
Map<String, Integer> added = new LinkedHashMap<String, Integer>();
|
||||
|
||||
for (Integer value : values) {
|
||||
String key = String.format("key_%d", value);
|
||||
cache.put(key, value);
|
||||
added.put(String.format("key_%d", value), value);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Integer> entry : added.entrySet()) {
|
||||
assertThat(cache.get(entry.getKey()), equalTo(entry.getValue()));
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
|
||||
for (Map.Entry<String, Integer> entry : added.entrySet()) {
|
||||
assertThat(cache.get(entry.getKey()), equalTo(entry.getValue()));
|
||||
}
|
||||
|
||||
return added;
|
||||
}
|
||||
|
||||
private void checkUpdates(Integer... values) {
|
||||
checkUpdates(Arrays.asList(values));
|
||||
}
|
||||
|
||||
private Map<Integer, Integer> checkUpdates(Iterable<Integer> values) {
|
||||
Map<Integer, Integer> updated = new LinkedHashMap<Integer, Integer>();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
for (Integer value : values) {
|
||||
String key = String.format("key_%d", value);
|
||||
int newValue = value + (i * 100);
|
||||
cache.put(key, newValue);
|
||||
updated.put(value, newValue);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Integer> entry : updated.entrySet()) {
|
||||
String key = String.format("key_%d", entry.getKey());
|
||||
assertThat(cache.get(key), equalTo(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
|
||||
for (Map.Entry<Integer, Integer> entry : updated.entrySet()) {
|
||||
String key = String.format("key_%d", entry.getKey());
|
||||
assertThat(cache.get(key), equalTo(entry.getValue()));
|
||||
}
|
||||
|
||||
return updated;
|
||||
}
|
||||
|
||||
private void checkAddsAndRemoves(Integer... values) {
|
||||
checkAddsAndRemoves(null, values);
|
||||
}
|
||||
|
||||
private void checkAddsAndRemoves(Comparator<Integer> comparator, Integer... values) {
|
||||
checkAddsAndRemoves(comparator, Arrays.asList(values));
|
||||
}
|
||||
|
||||
private void checkAddsAndRemoves(Comparator<Integer> comparator, Collection<Integer> values) {
|
||||
checkAdds(values);
|
||||
|
||||
List<Integer> deleteValues = new ArrayList<Integer>(values);
|
||||
Collections.sort(deleteValues, comparator);
|
||||
for (Integer value : deleteValues) {
|
||||
String key = String.format("key_%d", value);
|
||||
assertThat(cache.get(key), notNullValue());
|
||||
cache.remove(key);
|
||||
assertThat(cache.get(key), nullValue());
|
||||
}
|
||||
|
||||
cache.reset();
|
||||
cache.verify();
|
||||
|
||||
for (Integer value : deleteValues) {
|
||||
String key = String.format("key_%d", value);
|
||||
assertThat(cache.get(key), nullValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package seaweedfs.file;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
|
||||
public class MmapFileTest {
|
||||
|
||||
static File dir = new File("/Users/chris/tmp/mm/dev");
|
||||
|
||||
@Test
|
||||
public void testMmap() {
|
||||
try {
|
||||
System.out.println("starting ...");
|
||||
|
||||
File f = new File(dir, "mmap_file.txt");
|
||||
RandomAccessFile raf = new RandomAccessFile(f, "rw");
|
||||
FileChannel fc = raf.getChannel();
|
||||
MappedByteBuffer mbf = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
|
||||
fc.close();
|
||||
raf.close();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
fos.write("abcdefg".getBytes());
|
||||
fos.close();
|
||||
System.out.println("completed!");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBigMmap() throws IOException {
|
||||
/*
|
||||
|
||||
// new file
|
||||
I0817 09:48:02 25175 dir.go:147] create /dev/mmap_big.txt: OpenReadWrite+OpenCreate
|
||||
I0817 09:48:02 25175 wfs.go:116] AcquireHandle /dev/mmap_big.txt uid=502 gid=20
|
||||
I0817 09:48:02 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 0
|
||||
I0817 09:48:02 25175 meta_cache_subscribe.go:32] creating /dev/mmap_big.txt
|
||||
|
||||
//get channel
|
||||
I0817 09:48:26 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 0
|
||||
|
||||
I0817 09:48:32 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 0
|
||||
I0817 09:48:32 25175 wfs.go:116] AcquireHandle /dev/mmap_big.txt uid=0 gid=0
|
||||
I0817 09:48:32 25175 filehandle.go:160] Release /dev/mmap_big.txt fh 14968871991130164560
|
||||
|
||||
//fileChannel.map
|
||||
I0817 09:49:18 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 0
|
||||
I0817 09:49:18 25175 file.go:112] /dev/mmap_big.txt file setattr set size=262144 chunks=0
|
||||
I0817 09:49:18 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
I0817 09:49:18 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
I0817 09:49:18 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
|
||||
// buffer.put
|
||||
I0817 09:49:49 25175 filehandle.go:57] /dev/mmap_big.txt read fh 14968871991130164560: [0,32768) size 32768 resp.Data len=0 cap=32768
|
||||
I0817 09:49:49 25175 reader_at.go:113] zero2 [0,32768)
|
||||
I0817 09:49:50 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
|
||||
I0817 09:49:53 25175 file.go:233] /dev/mmap_big.txt fsync file Fsync [ID=0x4 Node=0xe Uid=0 Gid=0 Pid=0] Handle 0x2 Flags 1
|
||||
|
||||
//close
|
||||
I0817 09:50:14 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
I0817 09:50:14 25175 dirty_page.go:130] saveToStorage /dev/mmap_big.txt 1,315b69812039e5 [0,4096) of 262144 bytes
|
||||
I0817 09:50:14 25175 file.go:274] /dev/mmap_big.txt existing 0 chunks adds 1 more
|
||||
I0817 09:50:14 25175 filehandle.go:218] /dev/mmap_big.txt set chunks: 1
|
||||
I0817 09:50:14 25175 filehandle.go:220] /dev/mmap_big.txt chunks 0: 1,315b69812039e5 [0,4096)
|
||||
I0817 09:50:14 25175 meta_cache_subscribe.go:23] deleting /dev/mmap_big.txt
|
||||
I0817 09:50:14 25175 meta_cache_subscribe.go:32] creating /dev/mmap_big.txt
|
||||
|
||||
// end of test
|
||||
I0817 09:50:41 25175 file.go:62] file Attr /dev/mmap_big.txt, open:1, size: 262144
|
||||
I0817 09:50:41 25175 filehandle.go:160] Release /dev/mmap_big.txt fh 14968871991130164560
|
||||
|
||||
*/
|
||||
// Create file object
|
||||
File file = new File(dir, "mmap_big.txt");
|
||||
|
||||
try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
|
||||
// Get file channel in read-write mode
|
||||
FileChannel fileChannel = randomAccessFile.getChannel();
|
||||
|
||||
// Get direct byte buffer access using channel.map() operation
|
||||
MappedByteBuffer buffer = fileChannel.map(FileChannel.MapMode.READ_WRITE, 0, 4096 * 8 * 8);
|
||||
|
||||
//Write the content using put methods
|
||||
buffer.put("howtodoinjava.com".getBytes());
|
||||
}
|
||||
|
||||
/*
|
||||
> meta.cat /dev/mmap_big.txt
|
||||
{
|
||||
"name": "mmap_big.txt",
|
||||
"isDirectory": false,
|
||||
"chunks": [
|
||||
{
|
||||
"fileId": "1,315b69812039e5",
|
||||
"offset": "0",
|
||||
"size": "4096",
|
||||
"mtime": "1597683014026365000",
|
||||
"eTag": "985ab0ac",
|
||||
"sourceFileId": "",
|
||||
"fid": {
|
||||
"volumeId": 1,
|
||||
"fileKey": "3234665",
|
||||
"cookie": 2166372837
|
||||
},
|
||||
"sourceFid": null,
|
||||
"cipherKey": null,
|
||||
"isCompressed": true,
|
||||
"isChunkManifest": false
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"fileSize": "262144",
|
||||
"mtime": "1597683014",
|
||||
"fileMode": 420,
|
||||
"uid": 502,
|
||||
"gid": 20,
|
||||
"crtime": "1597682882",
|
||||
"mime": "application/octet-stream",
|
||||
"replication": "",
|
||||
"collection": "",
|
||||
"ttlSec": 0,
|
||||
"userName": "",
|
||||
"groupName": [
|
||||
],
|
||||
"symlinkTarget": "",
|
||||
"md5": null
|
||||
},
|
||||
"extended": {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package seaweedfs.file;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomeAccessFileTest {
|
||||
|
||||
@Test
|
||||
public void testRandomWriteAndRead() throws IOException {
|
||||
|
||||
File f = new File(MmapFileTest.dir, "mmap_file.txt");
|
||||
|
||||
RandomAccessFile af = new RandomAccessFile(f, "rw");
|
||||
af.setLength(0);
|
||||
af.close();
|
||||
|
||||
Random r = new Random();
|
||||
|
||||
int maxLength = 5000;
|
||||
|
||||
byte[] data = new byte[maxLength];
|
||||
byte[] readData = new byte[maxLength];
|
||||
|
||||
for (int i = 4096; i < maxLength; i++) {
|
||||
|
||||
RandomAccessFile raf = new RandomAccessFile(f, "rw");
|
||||
long fileSize = raf.length();
|
||||
|
||||
raf.readFully(readData, 0, (int)fileSize);
|
||||
|
||||
for (int x=0;x<fileSize;x++){
|
||||
Assert.assertEquals(data[x], readData[x]);
|
||||
}
|
||||
|
||||
int start = r.nextInt(i);
|
||||
int stop = r.nextInt(i);
|
||||
if (start > stop) {
|
||||
int t = stop;
|
||||
stop = start;
|
||||
start = t;
|
||||
}
|
||||
if (stop > fileSize) {
|
||||
fileSize = stop;
|
||||
raf.setLength(fileSize);
|
||||
}
|
||||
|
||||
randomize(r, data, start, stop);
|
||||
raf.seek(start);
|
||||
raf.write(data, start, stop-start);
|
||||
|
||||
raf.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void randomize(Random r, byte[] bytes, int start, int stop) {
|
||||
for (int i = start; i < stop; i++) {
|
||||
int rnd = r.nextInt();
|
||||
bytes[i] = (byte) rnd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestCreateBucket(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestListBuckets(t *testing.T) {
|
||||
func TestPutObject(t *testing.T) {
|
||||
|
||||
input := &s3.PutObjectInput{
|
||||
ACL: aws.String("authenticated-read"),
|
||||
@@ -89,7 +89,7 @@ func TestListBuckets(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestPutObject(t *testing.T) {
|
||||
func TestListBucket(t *testing.T) {
|
||||
|
||||
result, err := svc.ListBuckets(nil)
|
||||
if err != nil {
|
||||
@@ -105,6 +105,23 @@ func TestPutObject(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestListObjectV2(t *testing.T) {
|
||||
|
||||
listObj, err := svc.ListObjectsV2(&s3.ListObjectsV2Input{
|
||||
Bucket: aws.String(Bucket),
|
||||
Prefix: aws.String("foo"),
|
||||
Delimiter: aws.String("/"),
|
||||
})
|
||||
if err != nil {
|
||||
exitErrorf("Unable to list objects, %v", err)
|
||||
}
|
||||
for _, content := range listObj.Contents {
|
||||
fmt.Println(aws.StringValue(content.Key))
|
||||
}
|
||||
fmt.Printf("list: %s\n", listObj)
|
||||
|
||||
}
|
||||
|
||||
func exitErrorf(msg string, args ...interface{}) {
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args...)
|
||||
os.Exit(1)
|
||||
|
||||
Loaded 100 of 395 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user