mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
100c654ec3 | ||
|
|
947fe4cc97 | ||
|
|
7bf891c00a | ||
|
|
1f75f1f9dc | ||
|
|
3abbaccb70 | ||
|
|
177129013c | ||
|
|
4d388b9782 | ||
|
|
5eb905a5d1 | ||
|
|
043a1337df | ||
|
|
bef9c2943b | ||
|
|
79a1903021 | ||
|
|
12d9108bb4 | ||
|
|
cef2718ede | ||
|
|
9668b15f38 | ||
|
|
563a74a9eb | ||
|
|
dbb8003ce3 | ||
|
|
c387fe957b | ||
|
|
835e2d2ddf | ||
|
|
42f4aa824b | ||
|
|
b0b2a03ea7 | ||
|
|
641ce36f6f | ||
|
|
22f75177bf | ||
|
|
c77c0de418 | ||
|
|
a7eee8b14b | ||
|
|
1d4a61af5e | ||
|
|
c683409e92 | ||
|
|
5018b22f36 | ||
|
|
59d1435d65 | ||
|
|
5c99b8acc3 | ||
|
|
00fdab1284 | ||
|
|
4729a57cc0 | ||
|
|
d9dd72ea56 | ||
|
|
73a03cd965 | ||
|
|
5cf332357b | ||
|
|
244841f080 | ||
|
|
6e999f1176 | ||
|
|
a8b0f8864d | ||
|
|
55973e8572 | ||
|
|
c4e22b5a9a | ||
|
|
751a7073e3 | ||
|
|
e0fc2898e9 | ||
|
|
04663c3611 | ||
|
|
330d1fde7f | ||
|
|
12e6692dac | ||
|
|
84bb8e7365 | ||
|
|
4b9c42996a | ||
|
|
5ea86ef1da | ||
|
|
314c32514b | ||
|
|
7348d2ae63 | ||
|
|
00ae965d8d | ||
|
|
b485c905d4 | ||
|
|
77f90ae288 | ||
|
|
35c37562bc | ||
|
|
3c245c69d3 | ||
|
|
6fb6480a3b | ||
|
|
af71ae11aa | ||
|
|
ab97b17e62 | ||
|
|
e66865a8c5 | ||
|
|
0c8dea9de8 | ||
|
|
5160eb08f7 | ||
|
|
18bfbf62fc | ||
|
|
e1ab8b01d0 | ||
|
|
b25661c6df | ||
|
|
1b90d60765 | ||
|
|
794375ca0a |
No files matched your search
@@ -37,14 +37,14 @@ jobs:
|
|||||||
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
|
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
|
||||||
|
|
||||||
- name: Go Release Binaries Large Disk
|
- name: Go Release Binaries Large Disk
|
||||||
uses: wangyoucao577/go-release-action@v1.20
|
uses: wangyoucao577/go-release-action@bugfix/upload-fail
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
release_tag: dev
|
release_tag: dev
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -53,14 +53,14 @@ jobs:
|
|||||||
asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
||||||
|
|
||||||
- name: Go Release Binaries Normal Volume Size
|
- name: Go Release Binaries Normal Volume Size
|
||||||
uses: wangyoucao577/go-release-action@v1.20
|
uses: wangyoucao577/go-release-action@bugfix/upload-fail
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
release_tag: dev
|
release_tag: dev
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
project_path: weed
|
project_path: weed
|
||||||
@@ -84,14 +84,14 @@ jobs:
|
|||||||
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
|
run: echo BUILD_TIME=$(date -u +%Y%m%d-%H%M) >> ${GITHUB_ENV}
|
||||||
|
|
||||||
- name: Go Release Binaries Large Disk
|
- name: Go Release Binaries Large Disk
|
||||||
uses: wangyoucao577/go-release-action@v1.20
|
uses: wangyoucao577/go-release-action@bugfix/upload-fail
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
release_tag: dev
|
release_tag: dev
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -100,14 +100,14 @@ jobs:
|
|||||||
asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
asset_name: "weed-large-disk-${{ env.BUILD_TIME }}-${{ matrix.goos }}-${{ matrix.goarch }}"
|
||||||
|
|
||||||
- name: Go Release Binaries Normal Volume Size
|
- name: Go Release Binaries Normal Volume Size
|
||||||
uses: wangyoucao577/go-release-action@v1.20
|
uses: wangyoucao577/go-release-action@bugfix/upload-fail
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
release_tag: dev
|
release_tag: dev
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
project_path: weed
|
project_path: weed
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
# build_flags: -tags 5BytesOffset # optional, default is
|
# build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
# build_flags: -tags 5BytesOffset # optional, default is
|
# build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
# build_flags: -tags 5BytesOffset # optional, default is
|
# build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
# build_flags: -tags 5BytesOffset # optional, default is
|
# build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
@@ -45,7 +45,7 @@ jobs:
|
|||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
overwrite: true
|
overwrite: true
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0 && export GODEBUG=http2client=0
|
||||||
build_flags: -tags 5BytesOffset # optional, default is
|
build_flags: -tags 5BytesOffset # optional, default is
|
||||||
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
ldflags: -extldflags -static -X github.com/chrislusf/seaweedfs/weed/util.COMMIT=${{github.sha}}
|
||||||
# Where to run `go build .`
|
# Where to run `go build .`
|
||||||
|
|||||||
+6
-2
@@ -5,12 +5,16 @@
|
|||||||
|
|
||||||
<h2 align="center">Generous Backers ($50+)</h2>
|
<h2 align="center">Generous Backers ($50+)</h2>
|
||||||
|
|
||||||
- [4Sight Imaging](https://www.4sightimaging.com/)
|
|
||||||
- [Evercam Camera Management Software](https://evercam.io/)
|
- [Evercam Camera Management Software](https://evercam.io/)
|
||||||
- [Admiral](https://getadmiral.com)
|
|
||||||
|
|
||||||
<h2 align="center">Backers</h2>
|
<h2 align="center">Backers</h2>
|
||||||
|
|
||||||
- [ColorfulClouds Tech Co. Ltd.](https://caiyunai.com/)
|
- [ColorfulClouds Tech Co. Ltd.](https://caiyunai.com/)
|
||||||
- [Haravan - Ecommerce Platform](https://www.haravan.com)
|
- [Haravan - Ecommerce Platform](https://www.haravan.com)
|
||||||
- PeterCxy - Creator of Shelter App
|
- PeterCxy - Creator of Shelter App
|
||||||
|
- [Hive Games](https://playhive.com/)
|
||||||
|
- Flowm
|
||||||
|
- Yoni Nakache
|
||||||
|
- Catalin Constantin
|
||||||
|
- MingLi Yuan
|
||||||
|
- Leroy van Logchem
|
||||||
@@ -48,6 +48,7 @@ EXPOSE 7333
|
|||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filerldb2
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
COPY filer.toml /etc/seaweedfs/filer.toml
|
COPY filer.toml /etc/seaweedfs/filer.toml
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ EXPOSE 7333
|
|||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filerldb2
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM amd64/golang:1.17-alpine as builder
|
FROM golang:1.17-alpine as builder
|
||||||
RUN apk add git g++ fuse
|
RUN apk add git g++ fuse
|
||||||
RUN mkdir -p /go/src/github.com/chrislusf/
|
RUN mkdir -p /go/src/github.com/chrislusf/
|
||||||
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
||||||
@@ -36,6 +36,7 @@ EXPOSE 7333
|
|||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filerldb2
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
FROM amd64/golang:1.17-alpine as builder
|
FROM golang:1.17-alpine as builder
|
||||||
RUN apk add git g++ fuse
|
RUN apk add git g++ fuse
|
||||||
RUN mkdir -p /go/src/github.com/chrislusf/
|
RUN mkdir -p /go/src/github.com/chrislusf/
|
||||||
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
|
||||||
@@ -36,6 +36,7 @@ EXPOSE 7333
|
|||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filerldb2
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ EXPOSE 7333
|
|||||||
RUN mkdir -p /data/filerldb2
|
RUN mkdir -p /data/filerldb2
|
||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,8 @@ RUN mkdir -p /data/filerldb2
|
|||||||
|
|
||||||
VOLUME /data
|
VOLUME /data
|
||||||
|
|
||||||
|
WORKDIR /data
|
||||||
|
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
description: SeaweedFS
|
description: SeaweedFS
|
||||||
name: seaweedfs
|
name: seaweedfs
|
||||||
appVersion: "2.76"
|
appVersion: "2.78"
|
||||||
version: "2.76"
|
version: "2.78"
|
||||||
@@ -133,11 +133,6 @@ spec:
|
|||||||
-encryptVolumeData \
|
-encryptVolumeData \
|
||||||
{{- end }}
|
{{- end }}
|
||||||
-ip=${POD_IP} \
|
-ip=${POD_IP} \
|
||||||
{{- if .Values.filer.enable_peers }}
|
|
||||||
{{- if gt (.Values.filer.replicas | int) 1 }}
|
|
||||||
-peers=$(echo -n "{{ 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 }}" | sed "s/$HOSTNAME.${SEAWEEDFS_FULLNAME}-filer:{{ $.Values.filer.port }}//" | sed 's/,$//; 's/^,//'; s/,,/,/;' ) \
|
|
||||||
{{- end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if .Values.filer.s3.enabled }}
|
{{- if .Values.filer.s3.enabled }}
|
||||||
-s3 \
|
-s3 \
|
||||||
-s3.port={{ .Values.filer.s3.port }} \
|
-s3.port={{ .Values.filer.s3.port }} \
|
||||||
|
|||||||
@@ -246,8 +246,6 @@ filer:
|
|||||||
maxMB: null
|
maxMB: null
|
||||||
# encrypt data on volume servers
|
# encrypt data on volume servers
|
||||||
encryptVolumeData: false
|
encryptVolumeData: false
|
||||||
# enable peers sync metadata, for leveldb (localdb for filer but with sync across)
|
|
||||||
enable_peers: false
|
|
||||||
|
|
||||||
# Whether proxy or redirect to volume server during file GET request
|
# Whether proxy or redirect to volume server during file GET request
|
||||||
redirectOnRead: false
|
redirectOnRead: false
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
<artifactId>seaweedfs-client</artifactId>
|
<artifactId>seaweedfs-client</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpmime</artifactId>
|
<artifactId>httpmime</artifactId>
|
||||||
<version>4.5.6</version>
|
<version>4.5.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
<artifactId>seaweedfs-client</artifactId>
|
<artifactId>seaweedfs-client</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpmime</artifactId>
|
<artifactId>httpmime</artifactId>
|
||||||
<version>4.5.6</version>
|
<version>4.5.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
<artifactId>seaweedfs-client</artifactId>
|
<artifactId>seaweedfs-client</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpmime</artifactId>
|
<artifactId>httpmime</artifactId>
|
||||||
<version>4.5.6</version>
|
<version>4.5.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ public class RemoteUtil {
|
|||||||
String dir = SeaweedOutputStream.getParentDirectory(fullpath);
|
String dir = SeaweedOutputStream.getParentDirectory(fullpath);
|
||||||
String name = SeaweedOutputStream.getFileName(fullpath);
|
String name = SeaweedOutputStream.getFileName(fullpath);
|
||||||
|
|
||||||
final FilerProto.CacheRemoteObjectToLocalClusterResponse downloadToLocalResponse = filerClient.getBlockingStub()
|
final FilerProto.CacheRemoteObjectToLocalClusterResponse response = filerClient.getBlockingStub()
|
||||||
.downloadToLocal(FilerProto.CacheRemoteObjectToLocalClusterRequest.newBuilder()
|
.cacheRemoteObjectToLocalCluster(FilerProto.CacheRemoteObjectToLocalClusterRequest.newBuilder()
|
||||||
.setDirectory(dir).setName(name).build());
|
.setDirectory(dir).setName(name).build());
|
||||||
|
|
||||||
return downloadToLocalResponse.getEntry();
|
return response.getEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,13 +11,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
<artifactId>seaweedfs-client</artifactId>
|
<artifactId>seaweedfs-client</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.chrislusf</groupId>
|
<groupId>com.github.chrislusf</groupId>
|
||||||
<artifactId>seaweedfs-hadoop2-client</artifactId>
|
<artifactId>seaweedfs-hadoop2-client</artifactId>
|
||||||
<version>1.6.9</version>
|
<version>1.7.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -301,7 +301,7 @@
|
|||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>1.6.9</seaweedfs.client.version>
|
<seaweedfs.client.version>1.7.0</seaweedfs.client.version>
|
||||||
<hadoop.version>2.9.2</hadoop.version>
|
<hadoop.version>2.9.2</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>1.6.9</seaweedfs.client.version>
|
<seaweedfs.client.version>1.7.0</seaweedfs.client.version>
|
||||||
<hadoop.version>2.9.2</hadoop.version>
|
<hadoop.version>2.9.2</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
@@ -309,7 +309,7 @@
|
|||||||
</snapshotRepository>
|
</snapshotRepository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>1.6.9</seaweedfs.client.version>
|
<seaweedfs.client.version>1.7.0</seaweedfs.client.version>
|
||||||
<hadoop.version>3.1.1</hadoop.version>
|
<hadoop.version>3.1.1</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<seaweedfs.client.version>1.6.9</seaweedfs.client.version>
|
<seaweedfs.client.version>1.7.0</seaweedfs.client.version>
|
||||||
<hadoop.version>3.1.1</hadoop.version>
|
<hadoop.version>3.1.1</hadoop.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -2,10 +2,13 @@ BINARY = weed
|
|||||||
|
|
||||||
SOURCE_DIR = .
|
SOURCE_DIR = .
|
||||||
|
|
||||||
all: debug_mount
|
all: install
|
||||||
|
|
||||||
.PHONY : clean debug_mount
|
.PHONY : clean debug_mount
|
||||||
|
|
||||||
|
install:
|
||||||
|
go install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean $(SOURCE_DIR)
|
go clean $(SOURCE_DIR)
|
||||||
rm -f $(BINARY)
|
rm -f $(BINARY)
|
||||||
|
|||||||
@@ -0,0 +1,264 @@
|
|||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
|
"math"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
MasterType = "master"
|
||||||
|
FilerType = "filer"
|
||||||
|
BrokerType = "broker"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ClusterNode struct {
|
||||||
|
Address pb.ServerAddress
|
||||||
|
Version string
|
||||||
|
counter int
|
||||||
|
createdTs time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
type Leaders struct {
|
||||||
|
leaders [3]pb.ServerAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
type Cluster struct {
|
||||||
|
filers map[pb.ServerAddress]*ClusterNode
|
||||||
|
filersLock sync.RWMutex
|
||||||
|
filerLeaders *Leaders
|
||||||
|
brokers map[pb.ServerAddress]*ClusterNode
|
||||||
|
brokersLock sync.RWMutex
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewCluster() *Cluster {
|
||||||
|
return &Cluster{
|
||||||
|
filers: make(map[pb.ServerAddress]*ClusterNode),
|
||||||
|
filerLeaders: &Leaders{},
|
||||||
|
brokers: make(map[pb.ServerAddress]*ClusterNode),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cluster *Cluster) AddClusterNode(nodeType string, address pb.ServerAddress, version string) []*master_pb.KeepConnectedResponse {
|
||||||
|
switch nodeType {
|
||||||
|
case FilerType:
|
||||||
|
cluster.filersLock.Lock()
|
||||||
|
defer cluster.filersLock.Unlock()
|
||||||
|
if existingNode, found := cluster.filers[address]; found {
|
||||||
|
existingNode.counter++
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cluster.filers[address] = &ClusterNode{
|
||||||
|
Address: address,
|
||||||
|
Version: version,
|
||||||
|
counter: 1,
|
||||||
|
createdTs: time.Now(),
|
||||||
|
}
|
||||||
|
return cluster.ensureFilerLeaders(true, nodeType, address)
|
||||||
|
case BrokerType:
|
||||||
|
cluster.brokersLock.Lock()
|
||||||
|
defer cluster.brokersLock.Unlock()
|
||||||
|
if existingNode, found := cluster.brokers[address]; found {
|
||||||
|
existingNode.counter++
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cluster.brokers[address] = &ClusterNode{
|
||||||
|
Address: address,
|
||||||
|
Version: version,
|
||||||
|
counter: 1,
|
||||||
|
createdTs: time.Now(),
|
||||||
|
}
|
||||||
|
return []*master_pb.KeepConnectedResponse{
|
||||||
|
{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsAdd: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
case MasterType:
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cluster *Cluster) RemoveClusterNode(nodeType string, address pb.ServerAddress) []*master_pb.KeepConnectedResponse {
|
||||||
|
switch nodeType {
|
||||||
|
case FilerType:
|
||||||
|
cluster.filersLock.Lock()
|
||||||
|
defer cluster.filersLock.Unlock()
|
||||||
|
if existingNode, found := cluster.filers[address]; !found {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
existingNode.counter--
|
||||||
|
if existingNode.counter <= 0 {
|
||||||
|
delete(cluster.filers, address)
|
||||||
|
return cluster.ensureFilerLeaders(false, nodeType, address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case BrokerType:
|
||||||
|
cluster.brokersLock.Lock()
|
||||||
|
defer cluster.brokersLock.Unlock()
|
||||||
|
if existingNode, found := cluster.brokers[address]; !found {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
existingNode.counter--
|
||||||
|
if existingNode.counter <= 0 {
|
||||||
|
delete(cluster.brokers, address)
|
||||||
|
return []*master_pb.KeepConnectedResponse{
|
||||||
|
{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsAdd: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case MasterType:
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cluster *Cluster) ListClusterNode(nodeType string) (nodes []*ClusterNode) {
|
||||||
|
switch nodeType {
|
||||||
|
case FilerType:
|
||||||
|
cluster.filersLock.RLock()
|
||||||
|
defer cluster.filersLock.RUnlock()
|
||||||
|
for _, node := range cluster.filers {
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
}
|
||||||
|
case BrokerType:
|
||||||
|
cluster.brokersLock.RLock()
|
||||||
|
defer cluster.brokersLock.RUnlock()
|
||||||
|
for _, node := range cluster.brokers {
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
}
|
||||||
|
case MasterType:
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cluster *Cluster) IsOneLeader(address pb.ServerAddress) bool {
|
||||||
|
return cluster.filerLeaders.isOneLeader(address)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cluster *Cluster) ensureFilerLeaders(isAdd bool, nodeType string, address pb.ServerAddress) (result []*master_pb.KeepConnectedResponse) {
|
||||||
|
if isAdd {
|
||||||
|
if cluster.filerLeaders.addLeaderIfVacant(address) {
|
||||||
|
// has added the address as one leader
|
||||||
|
result = append(result, &master_pb.KeepConnectedResponse{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsLeader: true,
|
||||||
|
IsAdd: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
result = append(result, &master_pb.KeepConnectedResponse{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsLeader: false,
|
||||||
|
IsAdd: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if cluster.filerLeaders.removeLeaderIfExists(address) {
|
||||||
|
|
||||||
|
result = append(result, &master_pb.KeepConnectedResponse{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsLeader: true,
|
||||||
|
IsAdd: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
// pick the freshest one, since it is less likely to go away
|
||||||
|
var shortestDuration int64 = math.MaxInt64
|
||||||
|
now := time.Now()
|
||||||
|
var candidateAddress pb.ServerAddress
|
||||||
|
for _, node := range cluster.filers {
|
||||||
|
if cluster.filerLeaders.isOneLeader(node.Address) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
duration := now.Sub(node.createdTs).Nanoseconds()
|
||||||
|
if duration < shortestDuration {
|
||||||
|
shortestDuration = duration
|
||||||
|
candidateAddress = node.Address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if candidateAddress != "" {
|
||||||
|
cluster.filerLeaders.addLeaderIfVacant(candidateAddress)
|
||||||
|
// added a new leader
|
||||||
|
result = append(result, &master_pb.KeepConnectedResponse{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(candidateAddress),
|
||||||
|
IsLeader: true,
|
||||||
|
IsAdd: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = append(result, &master_pb.KeepConnectedResponse{
|
||||||
|
ClusterNodeUpdate: &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: nodeType,
|
||||||
|
Address: string(address),
|
||||||
|
IsLeader: false,
|
||||||
|
IsAdd: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (leaders *Leaders) addLeaderIfVacant(address pb.ServerAddress) (hasChanged bool) {
|
||||||
|
if leaders.isOneLeader(address) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; i < len(leaders.leaders); i++ {
|
||||||
|
if leaders.leaders[i] == "" {
|
||||||
|
leaders.leaders[i] = address
|
||||||
|
hasChanged = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (leaders *Leaders) removeLeaderIfExists(address pb.ServerAddress) (hasChanged bool) {
|
||||||
|
if !leaders.isOneLeader(address) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; i < len(leaders.leaders); i++ {
|
||||||
|
if leaders.leaders[i] == address {
|
||||||
|
leaders.leaders[i] = ""
|
||||||
|
hasChanged = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (leaders *Leaders) isOneLeader(address pb.ServerAddress) bool {
|
||||||
|
for i := 0; i < len(leaders.leaders); i++ {
|
||||||
|
if leaders.leaders[i] == address {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
func (leaders *Leaders) GetLeaders() (addresses []pb.ServerAddress) {
|
||||||
|
for i := 0; i < len(leaders.leaders); i++ {
|
||||||
|
if leaders.leaders[i] != "" {
|
||||||
|
addresses = append(addresses, leaders.leaders[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package cluster
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestClusterAddRemoveNodes(t *testing.T) {
|
||||||
|
c := NewCluster()
|
||||||
|
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:1"), "23.45")
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:2"), "23.45")
|
||||||
|
assert.Equal(t, []pb.ServerAddress{
|
||||||
|
pb.ServerAddress("111:1"),
|
||||||
|
pb.ServerAddress("111:2"),
|
||||||
|
}, c.filerLeaders.GetLeaders())
|
||||||
|
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:3"), "23.45")
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:4"), "23.45")
|
||||||
|
assert.Equal(t, []pb.ServerAddress{
|
||||||
|
pb.ServerAddress("111:1"),
|
||||||
|
pb.ServerAddress("111:2"),
|
||||||
|
pb.ServerAddress("111:3"),
|
||||||
|
}, c.filerLeaders.GetLeaders())
|
||||||
|
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:5"), "23.45")
|
||||||
|
c.AddClusterNode("filer", pb.ServerAddress("111:6"), "23.45")
|
||||||
|
c.RemoveClusterNode("filer", pb.ServerAddress("111:4"))
|
||||||
|
assert.Equal(t, []pb.ServerAddress{
|
||||||
|
pb.ServerAddress("111:1"),
|
||||||
|
pb.ServerAddress("111:2"),
|
||||||
|
pb.ServerAddress("111:3"),
|
||||||
|
}, c.filerLeaders.GetLeaders())
|
||||||
|
|
||||||
|
// remove oldest
|
||||||
|
c.RemoveClusterNode("filer", pb.ServerAddress("111:1"))
|
||||||
|
assert.Equal(t, []pb.ServerAddress{
|
||||||
|
pb.ServerAddress("111:6"),
|
||||||
|
pb.ServerAddress("111:2"),
|
||||||
|
pb.ServerAddress("111:3"),
|
||||||
|
}, c.filerLeaders.GetLeaders())
|
||||||
|
|
||||||
|
// remove oldest
|
||||||
|
c.RemoveClusterNode("filer", pb.ServerAddress("111:1"))
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/reflection"
|
"google.golang.org/grpc/reflection"
|
||||||
@@ -46,7 +45,6 @@ type FilerOptions struct {
|
|||||||
enableNotification *bool
|
enableNotification *bool
|
||||||
disableHttp *bool
|
disableHttp *bool
|
||||||
cipher *bool
|
cipher *bool
|
||||||
peers *string
|
|
||||||
metricsHttpPort *int
|
metricsHttpPort *int
|
||||||
saveToFilerLimit *int
|
saveToFilerLimit *int
|
||||||
defaultLevelDbDirectory *string
|
defaultLevelDbDirectory *string
|
||||||
@@ -72,7 +70,6 @@ func init() {
|
|||||||
f.rack = cmdFiler.Flag.String("rack", "", "prefer to write to volumes in this rack")
|
f.rack = cmdFiler.Flag.String("rack", "", "prefer to write to volumes in this rack")
|
||||||
f.disableHttp = cmdFiler.Flag.Bool("disableHttp", false, "disable http request, only gRpc operations are allowed")
|
f.disableHttp = cmdFiler.Flag.Bool("disableHttp", false, "disable http request, only gRpc operations are allowed")
|
||||||
f.cipher = cmdFiler.Flag.Bool("encryptVolumeData", false, "encrypt data on volume servers")
|
f.cipher = cmdFiler.Flag.Bool("encryptVolumeData", false, "encrypt data on volume servers")
|
||||||
f.peers = cmdFiler.Flag.String("peers", "", "all filers sharing the same filer store in comma separated ip:port list")
|
|
||||||
f.metricsHttpPort = cmdFiler.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
|
f.metricsHttpPort = cmdFiler.Flag.Int("metricsPort", 0, "Prometheus metrics listen port")
|
||||||
f.saveToFilerLimit = cmdFiler.Flag.Int("saveToFilerLimit", 0, "files smaller than this limit will be saved in filer store")
|
f.saveToFilerLimit = cmdFiler.Flag.Int("saveToFilerLimit", 0, "files smaller than this limit will be saved in filer store")
|
||||||
f.defaultLevelDbDirectory = cmdFiler.Flag.String("defaultStoreDir", ".", "if filer.toml is empty, use an embedded filer store in the directory")
|
f.defaultLevelDbDirectory = cmdFiler.Flag.String("defaultStoreDir", ".", "if filer.toml is empty, use an embedded filer store in the directory")
|
||||||
@@ -186,11 +183,6 @@ func (fo *FilerOptions) startFiler() {
|
|||||||
|
|
||||||
defaultLevelDbDirectory := util.ResolvePath(*fo.defaultLevelDbDirectory + "/filerldb2")
|
defaultLevelDbDirectory := util.ResolvePath(*fo.defaultLevelDbDirectory + "/filerldb2")
|
||||||
|
|
||||||
var peers []string
|
|
||||||
if *fo.peers != "" {
|
|
||||||
peers = strings.Split(*fo.peers, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
filerAddress := pb.NewServerAddress(*fo.ip, *fo.port, *fo.portGrpc)
|
filerAddress := pb.NewServerAddress(*fo.ip, *fo.port, *fo.portGrpc)
|
||||||
|
|
||||||
fs, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, &weed_server.FilerOption{
|
fs, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, &weed_server.FilerOption{
|
||||||
@@ -207,7 +199,6 @@ func (fo *FilerOptions) startFiler() {
|
|||||||
Host: filerAddress,
|
Host: filerAddress,
|
||||||
Cipher: *fo.cipher,
|
Cipher: *fo.cipher,
|
||||||
SaveToFilerLimit: int64(*fo.saveToFilerLimit),
|
SaveToFilerLimit: int64(*fo.saveToFilerLimit),
|
||||||
Filers: pb.FromAddressStrings(peers),
|
|
||||||
ConcurrentUploadLimit: int64(*fo.concurrentUploadLimitMB) * 1024 * 1024,
|
ConcurrentUploadLimit: int64(*fo.concurrentUploadLimitMB) * 1024 * 1024,
|
||||||
})
|
})
|
||||||
if nfs_err != nil {
|
if nfs_err != nil {
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ connection_max_lifetime_seconds = 0
|
|||||||
interpolateParams = false
|
interpolateParams = false
|
||||||
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
|
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
|
||||||
enableUpsert = true
|
enableUpsert = true
|
||||||
upsertQuery = """INSERT INTO ` + "`%s`" + ` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)"""
|
upsertQuery = """INSERT INTO `%s` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)"""
|
||||||
|
|
||||||
[mysql2] # or memsql, tidb
|
[mysql2] # or memsql, tidb
|
||||||
enabled = false
|
enabled = false
|
||||||
createTable = """
|
createTable = """
|
||||||
CREATE TABLE IF NOT EXISTS ` + "`%s`" + ` (
|
CREATE TABLE IF NOT EXISTS `%s` (
|
||||||
dirhash BIGINT,
|
dirhash BIGINT,
|
||||||
name VARCHAR(1000) BINARY,
|
name VARCHAR(1000) BINARY,
|
||||||
directory TEXT BINARY,
|
directory TEXT BINARY,
|
||||||
@@ -85,7 +85,7 @@ connection_max_lifetime_seconds = 0
|
|||||||
interpolateParams = false
|
interpolateParams = false
|
||||||
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
|
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
|
||||||
enableUpsert = true
|
enableUpsert = true
|
||||||
upsertQuery = """INSERT INTO ` + "`%s`" + ` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)"""
|
upsertQuery = """INSERT INTO `%s` (dirhash,name,directory,meta) VALUES(?,?,?,?) ON DUPLICATE KEY UPDATE meta = VALUES(meta)"""
|
||||||
|
|
||||||
[postgres] # or cockroachdb, YugabyteDB
|
[postgres] # or cockroachdb, YugabyteDB
|
||||||
# CREATE TABLE IF NOT EXISTS filemeta (
|
# CREATE TABLE IF NOT EXISTS filemeta (
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ func init() {
|
|||||||
filerOptions.maxMB = cmdServer.Flag.Int("filer.maxMB", 4, "split files larger than the limit")
|
filerOptions.maxMB = cmdServer.Flag.Int("filer.maxMB", 4, "split files larger than the limit")
|
||||||
filerOptions.dirListingLimit = cmdServer.Flag.Int("filer.dirListLimit", 1000, "limit sub dir listing size")
|
filerOptions.dirListingLimit = cmdServer.Flag.Int("filer.dirListLimit", 1000, "limit sub dir listing size")
|
||||||
filerOptions.cipher = cmdServer.Flag.Bool("filer.encryptVolumeData", false, "encrypt data on volume servers")
|
filerOptions.cipher = cmdServer.Flag.Bool("filer.encryptVolumeData", false, "encrypt data on volume servers")
|
||||||
filerOptions.peers = cmdServer.Flag.String("filer.peers", "", "all filers sharing the same filer store in comma separated ip:port list")
|
|
||||||
filerOptions.saveToFilerLimit = cmdServer.Flag.Int("filer.saveToFilerLimit", 0, "Small files smaller than this limit can be cached in filer store.")
|
filerOptions.saveToFilerLimit = cmdServer.Flag.Int("filer.saveToFilerLimit", 0, "Small files smaller than this limit can be cached in filer store.")
|
||||||
filerOptions.concurrentUploadLimitMB = cmdServer.Flag.Int("filer.concurrentUploadLimitMB", 64, "limit total concurrent upload size")
|
filerOptions.concurrentUploadLimitMB = cmdServer.Flag.Int("filer.concurrentUploadLimitMB", 64, "limit total concurrent upload size")
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func runShell(command *Command, args []string) bool {
|
|||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
|
|
||||||
if *shellOptions.Masters == "" && *shellInitialFiler == "" {
|
if *shellOptions.Masters == "" {
|
||||||
util.LoadConfiguration("shell", false)
|
util.LoadConfiguration("shell", false)
|
||||||
v := util.GetViper()
|
v := util.GetViper()
|
||||||
cluster := v.GetString("cluster.default")
|
cluster := v.GetString("cluster.default")
|
||||||
@@ -45,15 +45,14 @@ func runShell(command *Command, args []string) bool {
|
|||||||
cluster = *shellCluster
|
cluster = *shellCluster
|
||||||
}
|
}
|
||||||
if cluster == "" {
|
if cluster == "" {
|
||||||
*shellOptions.Masters, *shellInitialFiler = "localhost:9333", "localhost:8888"
|
*shellOptions.Masters = "localhost:9333"
|
||||||
} else {
|
} else {
|
||||||
*shellOptions.Masters = v.GetString("cluster." + cluster + ".master")
|
*shellOptions.Masters = v.GetString("cluster." + cluster + ".master")
|
||||||
*shellInitialFiler = v.GetString("cluster." + cluster + ".filer")
|
*shellInitialFiler = v.GetString("cluster." + cluster + ".filer")
|
||||||
|
fmt.Printf("master: %s filer: %s\n", *shellOptions.Masters, *shellInitialFiler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("master: %s filer: %s\n", *shellOptions.Masters, *shellInitialFiler)
|
|
||||||
|
|
||||||
shellOptions.FilerAddress = pb.ServerAddress(*shellInitialFiler)
|
shellOptions.FilerAddress = pb.ServerAddress(*shellInitialFiler)
|
||||||
shellOptions.Directory = "/"
|
shellOptions.Directory = "/"
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func readResolvedChunks(chunks []*filer_pb.FileChunk) (visibles []VisibleInterva
|
|||||||
for _, point := range points {
|
for _, point := range points {
|
||||||
if point.isStart {
|
if point.isStart {
|
||||||
if len(queue) > 0 {
|
if len(queue) > 0 {
|
||||||
lastIndex := len(queue) -1
|
lastIndex := len(queue) - 1
|
||||||
lastPoint := queue[lastIndex]
|
lastPoint := queue[lastIndex]
|
||||||
if point.x != prevX && lastPoint.ts < point.ts {
|
if point.x != prevX && lastPoint.ts < point.ts {
|
||||||
visibles = addToVisibles(visibles, prevX, lastPoint, point)
|
visibles = addToVisibles(visibles, prevX, lastPoint, point)
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ func TestReadResolvedChunks(t *testing.T) {
|
|||||||
|
|
||||||
func TestRandomizedReadResolvedChunks(t *testing.T) {
|
func TestRandomizedReadResolvedChunks(t *testing.T) {
|
||||||
|
|
||||||
var limit int64 = 1024*1024
|
var limit int64 = 1024 * 1024
|
||||||
array := make([]int64, limit)
|
array := make([]int64, limit)
|
||||||
var chunks []*filer_pb.FileChunk
|
var chunks []*filer_pb.FileChunk
|
||||||
for ts := int64(0); ts < 1024; ts++ {
|
for ts := int64(0); ts < 1024; ts++ {
|
||||||
@@ -75,7 +75,7 @@ func TestRandomizedReadResolvedChunks(t *testing.T) {
|
|||||||
visibles := readResolvedChunks(chunks)
|
visibles := readResolvedChunks(chunks)
|
||||||
|
|
||||||
for _, visible := range visibles {
|
for _, visible := range visibles {
|
||||||
for i := visible.start; i<visible.stop;i++{
|
for i := visible.start; i < visible.stop; i++ {
|
||||||
if array[i] != visible.modifiedTime {
|
if array[i] != visible.modifiedTime {
|
||||||
t.Errorf("position %d expected ts %d actual ts %d", i, array[i], visible.modifiedTime)
|
t.Errorf("position %d expected ts %d actual ts %d", i, array[i], visible.modifiedTime)
|
||||||
}
|
}
|
||||||
@@ -101,12 +101,12 @@ func randomWrite(array []int64, start int64, size int64, ts int64) *filer_pb.Fil
|
|||||||
|
|
||||||
func TestSequentialReadResolvedChunks(t *testing.T) {
|
func TestSequentialReadResolvedChunks(t *testing.T) {
|
||||||
|
|
||||||
var chunkSize int64 = 1024*1024*2
|
var chunkSize int64 = 1024 * 1024 * 2
|
||||||
var chunks []*filer_pb.FileChunk
|
var chunks []*filer_pb.FileChunk
|
||||||
for ts := int64(0); ts < 13; ts++ {
|
for ts := int64(0); ts < 13; ts++ {
|
||||||
chunks = append(chunks, &filer_pb.FileChunk{
|
chunks = append(chunks, &filer_pb.FileChunk{
|
||||||
FileId: "",
|
FileId: "",
|
||||||
Offset: chunkSize*ts,
|
Offset: chunkSize * ts,
|
||||||
Size: uint64(chunkSize),
|
Size: uint64(chunkSize),
|
||||||
Mtime: 1,
|
Mtime: 1,
|
||||||
})
|
})
|
||||||
|
|||||||
+33
-15
@@ -3,7 +3,9 @@ package filer
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -50,7 +52,7 @@ type Filer struct {
|
|||||||
func NewFiler(masters []pb.ServerAddress, grpcDialOption grpc.DialOption,
|
func NewFiler(masters []pb.ServerAddress, grpcDialOption grpc.DialOption,
|
||||||
filerHost pb.ServerAddress, collection string, replication string, dataCenter string, notifyFn func()) *Filer {
|
filerHost pb.ServerAddress, collection string, replication string, dataCenter string, notifyFn func()) *Filer {
|
||||||
f := &Filer{
|
f := &Filer{
|
||||||
MasterClient: wdclient.NewMasterClient(grpcDialOption, "filer", filerHost, dataCenter, masters),
|
MasterClient: wdclient.NewMasterClient(grpcDialOption, cluster.FilerType, filerHost, dataCenter, masters),
|
||||||
fileIdDeletionQueue: util.NewUnboundedQueue(),
|
fileIdDeletionQueue: util.NewUnboundedQueue(),
|
||||||
GrpcDialOption: grpcDialOption,
|
GrpcDialOption: grpcDialOption,
|
||||||
FilerConf: NewFilerConf(),
|
FilerConf: NewFilerConf(),
|
||||||
@@ -66,22 +68,38 @@ func NewFiler(masters []pb.ServerAddress, grpcDialOption grpc.DialOption,
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) AggregateFromPeers(self pb.ServerAddress, filers []pb.ServerAddress) {
|
func (f *Filer) AggregateFromPeers(self pb.ServerAddress) {
|
||||||
|
|
||||||
// set peers
|
f.MetaAggregator = NewMetaAggregator(f, self, f.GrpcDialOption)
|
||||||
found := false
|
f.MasterClient.OnPeerUpdate = f.MetaAggregator.OnPeerUpdate
|
||||||
for _, peer := range filers {
|
|
||||||
if peer == self {
|
for _, peerUpdate := range f.ListExistingPeerUpdates() {
|
||||||
found = true
|
f.MetaAggregator.OnPeerUpdate(peerUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Filer) ListExistingPeerUpdates() (existingNodes []*master_pb.ClusterNodeUpdate){
|
||||||
|
|
||||||
|
if grpcErr := pb.WithMasterClient(f.MasterClient.GetMaster(), f.GrpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
|
ClientType: cluster.FilerType,
|
||||||
|
})
|
||||||
|
|
||||||
|
glog.V(0).Infof("the cluster has %d filers\n", len(resp.ClusterNodes))
|
||||||
|
for _, node := range resp.ClusterNodes {
|
||||||
|
existingNodes = append(existingNodes, &master_pb.ClusterNodeUpdate{
|
||||||
|
NodeType: cluster.FilerType,
|
||||||
|
Address: node.Address,
|
||||||
|
IsLeader: node.IsLeader,
|
||||||
|
IsAdd: true,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
return err
|
||||||
|
}); grpcErr != nil {
|
||||||
|
glog.V(0).Infof("connect to %s: %v", f.MasterClient.GetMaster(), grpcErr)
|
||||||
}
|
}
|
||||||
if !found {
|
return
|
||||||
filers = append(filers, self)
|
|
||||||
}
|
|
||||||
|
|
||||||
f.MetaAggregator = NewMetaAggregator(filers, f.GrpcDialOption)
|
|
||||||
f.MetaAggregator.StartLoopSubscribe(f, self)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) SetStore(store FilerStore) {
|
func (f *Filer) SetStore(store FilerStore) {
|
||||||
@@ -117,7 +135,7 @@ func (fs *Filer) GetMaster() pb.ServerAddress {
|
|||||||
return fs.MasterClient.GetMaster()
|
return fs.MasterClient.GetMaster()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *Filer) KeepConnectedToMaster() {
|
func (fs *Filer) KeepMasterClientConnected() {
|
||||||
fs.MasterClient.KeepConnectedToMaster()
|
fs.MasterClient.KeepConnectedToMaster()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ const (
|
|||||||
MsgFailDelNonEmptyFolder = "fail to delete non-empty folder"
|
MsgFailDelNonEmptyFolder = "fail to delete non-empty folder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type OnChunksFunc func([]*filer_pb.FileChunk) error
|
||||||
|
type OnHardLinkIdsFunc func([]HardLinkId) error
|
||||||
|
|
||||||
func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isFromOtherCluster bool, signatures []int32) (err error) {
|
func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isFromOtherCluster bool, signatures []int32) (err error) {
|
||||||
if p == "/" {
|
if p == "/" {
|
||||||
return nil
|
return nil
|
||||||
@@ -27,20 +30,29 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
|
|
||||||
isDeleteCollection := f.isBucket(entry)
|
isDeleteCollection := f.isBucket(entry)
|
||||||
|
|
||||||
var chunks []*filer_pb.FileChunk
|
|
||||||
var hardLinkIds []HardLinkId
|
|
||||||
chunks = append(chunks, entry.Chunks...)
|
|
||||||
if entry.IsDirectory() {
|
if entry.IsDirectory() {
|
||||||
// delete the folder children, not including the folder itself
|
// delete the folder children, not including the folder itself
|
||||||
var dirChunks []*filer_pb.FileChunk
|
err = f.doBatchDeleteFolderMetaAndData(ctx, entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks && !isDeleteCollection, isDeleteCollection, isFromOtherCluster, signatures, func(chunks []*filer_pb.FileChunk) error {
|
||||||
var dirHardLinkIds []HardLinkId
|
if shouldDeleteChunks && !isDeleteCollection {
|
||||||
dirChunks, dirHardLinkIds, err = f.doBatchDeleteFolderMetaAndData(ctx, entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks && !isDeleteCollection, isDeleteCollection, isFromOtherCluster, signatures)
|
f.DirectDeleteChunks(chunks)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}, func(hardLinkIds []HardLinkId) error {
|
||||||
|
// A case not handled:
|
||||||
|
// what if the chunk is in a different collection?
|
||||||
|
if shouldDeleteChunks {
|
||||||
|
f.maybeDeleteHardLinks(hardLinkIds)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("delete directory %s: %v", p, err)
|
glog.V(0).Infof("delete directory %s: %v", p, err)
|
||||||
return fmt.Errorf("delete directory %s: %v", p, err)
|
return fmt.Errorf("delete directory %s: %v", p, err)
|
||||||
}
|
}
|
||||||
chunks = append(chunks, dirChunks...)
|
}
|
||||||
hardLinkIds = append(hardLinkIds, dirHardLinkIds...)
|
|
||||||
|
if shouldDeleteChunks && !isDeleteCollection {
|
||||||
|
f.DirectDeleteChunks(entry.Chunks)
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the file or folder
|
// delete the file or folder
|
||||||
@@ -49,15 +61,6 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
return fmt.Errorf("delete file %s: %v", p, err)
|
return fmt.Errorf("delete file %s: %v", p, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldDeleteChunks && !isDeleteCollection {
|
|
||||||
f.DirectDeleteChunks(chunks)
|
|
||||||
}
|
|
||||||
// A case not handled:
|
|
||||||
// what if the chunk is in a different collection?
|
|
||||||
if shouldDeleteChunks {
|
|
||||||
f.maybeDeleteHardLinks(hardLinkIds)
|
|
||||||
}
|
|
||||||
|
|
||||||
if isDeleteCollection {
|
if isDeleteCollection {
|
||||||
collectionName := entry.Name()
|
collectionName := entry.Name()
|
||||||
f.doDeleteCollection(collectionName)
|
f.doDeleteCollection(collectionName)
|
||||||
@@ -67,7 +70,7 @@ func (f *Filer) DeleteEntryMetaAndData(ctx context.Context, p util.FullPath, isR
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isDeletingBucket, isFromOtherCluster bool, signatures []int32) (chunks []*filer_pb.FileChunk, hardlinkIds []HardLinkId, err error) {
|
func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry, isRecursive, ignoreRecursiveError, shouldDeleteChunks, isDeletingBucket, isFromOtherCluster bool, signatures []int32, onChunksFn OnChunksFunc, onHardLinkIdsFn OnHardLinkIdsFunc) (err error) {
|
||||||
|
|
||||||
lastFileName := ""
|
lastFileName := ""
|
||||||
includeLastFile := false
|
includeLastFile := false
|
||||||
@@ -76,34 +79,30 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
|||||||
entries, _, err := f.ListDirectoryEntries(ctx, entry.FullPath, lastFileName, includeLastFile, PaginationSize, "", "", "")
|
entries, _, err := f.ListDirectoryEntries(ctx, entry.FullPath, lastFileName, includeLastFile, PaginationSize, "", "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("list folder %s: %v", entry.FullPath, err)
|
glog.Errorf("list folder %s: %v", entry.FullPath, err)
|
||||||
return nil, nil, fmt.Errorf("list folder %s: %v", entry.FullPath, err)
|
return fmt.Errorf("list folder %s: %v", entry.FullPath, err)
|
||||||
}
|
}
|
||||||
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
||||||
// only for first iteration in the loop
|
// only for first iteration in the loop
|
||||||
glog.V(0).Infof("deleting a folder %s has children: %+v ...", entry.FullPath, entries[0].Name())
|
glog.V(0).Infof("deleting a folder %s has children: %+v ...", entry.FullPath, entries[0].Name())
|
||||||
return nil, nil, fmt.Errorf("%s: %s", MsgFailDelNonEmptyFolder, entry.FullPath)
|
return fmt.Errorf("%s: %s", MsgFailDelNonEmptyFolder, entry.FullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, sub := range entries {
|
for _, sub := range entries {
|
||||||
lastFileName = sub.Name()
|
lastFileName = sub.Name()
|
||||||
var dirChunks []*filer_pb.FileChunk
|
|
||||||
var dirHardLinkIds []HardLinkId
|
|
||||||
if sub.IsDirectory() {
|
if sub.IsDirectory() {
|
||||||
subIsDeletingBucket := f.isBucket(sub)
|
subIsDeletingBucket := f.isBucket(sub)
|
||||||
dirChunks, dirHardLinkIds, err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks, subIsDeletingBucket, false, nil)
|
err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks, subIsDeletingBucket, false, nil, onChunksFn, onHardLinkIdsFn)
|
||||||
chunks = append(chunks, dirChunks...)
|
|
||||||
hardlinkIds = append(hardlinkIds, dirHardLinkIds...)
|
|
||||||
} else {
|
} else {
|
||||||
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks, isFromOtherCluster, nil)
|
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks, isFromOtherCluster, nil)
|
||||||
if len(sub.HardLinkId) != 0 {
|
if len(sub.HardLinkId) != 0 {
|
||||||
// hard link chunk data are deleted separately
|
// hard link chunk data are deleted separately
|
||||||
hardlinkIds = append(hardlinkIds, sub.HardLinkId)
|
err = onHardLinkIdsFn([]HardLinkId{sub.HardLinkId})
|
||||||
} else {
|
} else {
|
||||||
chunks = append(chunks, sub.Chunks...)
|
err = onChunksFn(sub.Chunks)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil && !ignoreRecursiveError {
|
if err != nil && !ignoreRecursiveError {
|
||||||
return nil, nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,15 +112,15 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(3).Infof("deleting directory %v delete %d chunks: %v", entry.FullPath, len(chunks), shouldDeleteChunks)
|
glog.V(3).Infof("deleting directory %v delete chunks: %v", entry.FullPath, shouldDeleteChunks)
|
||||||
|
|
||||||
if storeDeletionErr := f.Store.DeleteFolderChildren(ctx, entry.FullPath); storeDeletionErr != nil {
|
if storeDeletionErr := f.Store.DeleteFolderChildren(ctx, entry.FullPath); storeDeletionErr != nil {
|
||||||
return nil, nil, fmt.Errorf("filer store delete: %v", storeDeletionErr)
|
return fmt.Errorf("filer store delete: %v", storeDeletionErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.NotifyUpdateEvent(ctx, entry, nil, shouldDeleteChunks, isFromOtherCluster, signatures)
|
f.NotifyUpdateEvent(ctx, entry, nil, shouldDeleteChunks, isFromOtherCluster, signatures)
|
||||||
|
|
||||||
return chunks, hardlinkIds, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Filer) doDeleteEntryMetaAndData(ctx context.Context, entry *Entry, shouldDeleteChunks bool, isFromOtherCluster bool, signatures []int32) (err error) {
|
func (f *Filer) doDeleteEntryMetaAndData(ctx context.Context, entry *Entry, shouldDeleteChunks bool, isFromOtherCluster bool, signatures []int32) (err error) {
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package filer
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -18,9 +20,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MetaAggregator struct {
|
type MetaAggregator struct {
|
||||||
filers []pb.ServerAddress
|
filer *Filer
|
||||||
grpcDialOption grpc.DialOption
|
self pb.ServerAddress
|
||||||
MetaLogBuffer *log_buffer.LogBuffer
|
isLeader bool
|
||||||
|
grpcDialOption grpc.DialOption
|
||||||
|
MetaLogBuffer *log_buffer.LogBuffer
|
||||||
|
peerStatues map[pb.ServerAddress]struct{}
|
||||||
|
peerStatuesLock sync.Mutex
|
||||||
// notifying clients
|
// notifying clients
|
||||||
ListenersLock sync.Mutex
|
ListenersLock sync.Mutex
|
||||||
ListenersCond *sync.Cond
|
ListenersCond *sync.Cond
|
||||||
@@ -28,10 +34,12 @@ type MetaAggregator struct {
|
|||||||
|
|
||||||
// MetaAggregator only aggregates data "on the fly". The logs are not re-persisted to disk.
|
// MetaAggregator only aggregates data "on the fly". The logs are not re-persisted to disk.
|
||||||
// The old data comes from what each LocalMetadata persisted on disk.
|
// The old data comes from what each LocalMetadata persisted on disk.
|
||||||
func NewMetaAggregator(filers []pb.ServerAddress, grpcDialOption grpc.DialOption) *MetaAggregator {
|
func NewMetaAggregator(filer *Filer, self pb.ServerAddress, grpcDialOption grpc.DialOption) *MetaAggregator {
|
||||||
t := &MetaAggregator{
|
t := &MetaAggregator{
|
||||||
filers: filers,
|
filer: filer,
|
||||||
|
self: self,
|
||||||
grpcDialOption: grpcDialOption,
|
grpcDialOption: grpcDialOption,
|
||||||
|
peerStatues: make(map[pb.ServerAddress]struct{}),
|
||||||
}
|
}
|
||||||
t.ListenersCond = sync.NewCond(&t.ListenersLock)
|
t.ListenersCond = sync.NewCond(&t.ListenersLock)
|
||||||
t.MetaLogBuffer = log_buffer.NewLogBuffer("aggr", LogFlushInterval, nil, func() {
|
t.MetaLogBuffer = log_buffer.NewLogBuffer("aggr", LogFlushInterval, nil, func() {
|
||||||
@@ -40,10 +48,35 @@ func NewMetaAggregator(filers []pb.ServerAddress, grpcDialOption grpc.DialOption
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ma *MetaAggregator) StartLoopSubscribe(f *Filer, self pb.ServerAddress) {
|
func (ma *MetaAggregator) OnPeerUpdate(update *master_pb.ClusterNodeUpdate) {
|
||||||
for _, filer := range ma.filers {
|
if update.NodeType != cluster.FilerType {
|
||||||
go ma.subscribeToOneFiler(f, self, filer)
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
address := pb.ServerAddress(update.Address)
|
||||||
|
if update.IsAdd {
|
||||||
|
// every filer should subscribe to a new filer
|
||||||
|
ma.setActive(address, true)
|
||||||
|
go ma.subscribeToOneFiler(ma.filer, ma.self, address)
|
||||||
|
} else {
|
||||||
|
ma.setActive(address, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ma *MetaAggregator) setActive(address pb.ServerAddress, isActive bool) {
|
||||||
|
ma.peerStatuesLock.Lock()
|
||||||
|
defer ma.peerStatuesLock.Unlock()
|
||||||
|
if isActive {
|
||||||
|
ma.peerStatues[address] = struct{}{}
|
||||||
|
} else {
|
||||||
|
delete(ma.peerStatues, address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (ma *MetaAggregator) isActive(address pb.ServerAddress)(isActive bool) {
|
||||||
|
ma.peerStatuesLock.Lock()
|
||||||
|
defer ma.peerStatuesLock.Unlock()
|
||||||
|
_, isActive = ma.peerStatues[address]
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, peer pb.ServerAddress) {
|
func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, peer pb.ServerAddress) {
|
||||||
@@ -149,6 +182,10 @@ func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, p
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
if !ma.isActive(peer) {
|
||||||
|
glog.V(0).Infof("stop subscribing remote %s meta change", peer)
|
||||||
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("subscribing remote %s meta change: %v", peer, err)
|
glog.V(0).Infof("subscribing remote %s meta change: %v", peer, err)
|
||||||
time.Sleep(1733 * time.Millisecond)
|
time.Sleep(1733 * time.Millisecond)
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ func (store *UniversalRedis2Store) DeleteFolderChildren(ctx context.Context, ful
|
|||||||
}
|
}
|
||||||
|
|
||||||
members, err := store.Client.ZRangeByLex(ctx, genDirectoryListKey(string(fullpath)), &redis.ZRangeBy{
|
members, err := store.Client.ZRangeByLex(ctx, genDirectoryListKey(string(fullpath)), &redis.ZRangeBy{
|
||||||
Min: "-",
|
Min: "-",
|
||||||
Max: "+",
|
Max: "+",
|
||||||
}).Result()
|
}).Result()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("DeleteFolderChildren %s : %v", fullpath, err)
|
return fmt.Errorf("DeleteFolderChildren %s : %v", fullpath, err)
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (dir *Dir) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamRenameEntryResponse) error {
|
func (dir *Dir) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamRenameEntryResponse) error {
|
||||||
// comes from filer StreamRenameEntry, can only be create or delete entry
|
// comes from filer StreamRenameEntry, can only be create or delete entry
|
||||||
|
|
||||||
@@ -119,7 +118,7 @@ func (dir *Dir) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR
|
|||||||
}
|
}
|
||||||
dir.wfs.handlesLock.Unlock()
|
dir.wfs.handlesLock.Unlock()
|
||||||
|
|
||||||
}else if resp.EventNotification.OldEntry != nil {
|
} else if resp.EventNotification.OldEntry != nil {
|
||||||
// without new entry, only old entry name exists. This is the second step to delete old entry
|
// without new entry, only old entry name exists. This is the second step to delete old entry
|
||||||
if err := dir.wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, util.NewFullPath(resp.Directory, resp.EventNotification.OldEntry.Name), nil); err != nil {
|
if err := dir.wfs.metaCache.AtomicUpdateEntryFromFiler(ctx, util.NewFullPath(resp.Directory, resp.EventNotification.OldEntry.Name), nil); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ var s3ApiConfigure IamS3ApiConfig
|
|||||||
func NewIamApiServer(router *mux.Router, option *IamServerOption) (iamApiServer *IamApiServer, err error) {
|
func NewIamApiServer(router *mux.Router, option *IamServerOption) (iamApiServer *IamApiServer, err error) {
|
||||||
s3ApiConfigure = IamS3ApiConfigure{
|
s3ApiConfigure = IamS3ApiConfigure{
|
||||||
option: option,
|
option: option,
|
||||||
masterClient: wdclient.NewMasterClient(option.GrpcDialOption, pb.AdminShellClient, "", "", option.Masters),
|
masterClient: wdclient.NewMasterClient(option.GrpcDialOption, "iam", "", "", option.Masters),
|
||||||
}
|
}
|
||||||
s3Option := s3api.S3ApiServerOption{Filer: option.Filer}
|
s3Option := s3api.S3ApiServerOption{Filer: option.Filer}
|
||||||
iamApiServer = &IamApiServer{
|
iamApiServer = &IamApiServer{
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package broker
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -93,14 +94,16 @@ func (broker *MessageBroker) checkFilers() {
|
|||||||
for !found {
|
for !found {
|
||||||
for _, master := range masters {
|
for _, master := range masters {
|
||||||
err := broker.withMasterClient(master, func(client master_pb.SeaweedClient) error {
|
err := broker.withMasterClient(master, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.ListMasterClients(context.Background(), &master_pb.ListMasterClientsRequest{
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
ClientType: "filer",
|
ClientType: cluster.FilerType,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
filers = append(filers, pb.FromAddressStrings(resp.GrpcAddresses)...)
|
for _, clusterNode := range resp.ClusterNodes {
|
||||||
|
filers = append(filers, pb.ServerAddress(clusterNode.Address))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
+204
-186
@@ -7,209 +7,222 @@ option go_package = "github.com/chrislusf/seaweedfs/weed/pb/master_pb";
|
|||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
service Seaweed {
|
service Seaweed {
|
||||||
rpc SendHeartbeat (stream Heartbeat) returns (stream HeartbeatResponse) {
|
rpc SendHeartbeat (stream Heartbeat) returns (stream HeartbeatResponse) {
|
||||||
}
|
}
|
||||||
rpc KeepConnected (stream KeepConnectedRequest) returns (stream VolumeLocation) {
|
rpc KeepConnected (stream KeepConnectedRequest) returns (stream KeepConnectedResponse) {
|
||||||
}
|
}
|
||||||
rpc LookupVolume (LookupVolumeRequest) returns (LookupVolumeResponse) {
|
rpc LookupVolume (LookupVolumeRequest) returns (LookupVolumeResponse) {
|
||||||
}
|
}
|
||||||
rpc Assign (AssignRequest) returns (AssignResponse) {
|
rpc Assign (AssignRequest) returns (AssignResponse) {
|
||||||
}
|
}
|
||||||
rpc Statistics (StatisticsRequest) returns (StatisticsResponse) {
|
rpc Statistics (StatisticsRequest) returns (StatisticsResponse) {
|
||||||
}
|
}
|
||||||
rpc CollectionList (CollectionListRequest) returns (CollectionListResponse) {
|
rpc CollectionList (CollectionListRequest) returns (CollectionListResponse) {
|
||||||
}
|
}
|
||||||
rpc CollectionDelete (CollectionDeleteRequest) returns (CollectionDeleteResponse) {
|
rpc CollectionDelete (CollectionDeleteRequest) returns (CollectionDeleteResponse) {
|
||||||
}
|
}
|
||||||
rpc VolumeList (VolumeListRequest) returns (VolumeListResponse) {
|
rpc VolumeList (VolumeListRequest) returns (VolumeListResponse) {
|
||||||
}
|
}
|
||||||
rpc LookupEcVolume (LookupEcVolumeRequest) returns (LookupEcVolumeResponse) {
|
rpc LookupEcVolume (LookupEcVolumeRequest) returns (LookupEcVolumeResponse) {
|
||||||
}
|
}
|
||||||
rpc VacuumVolume (VacuumVolumeRequest) returns (VacuumVolumeResponse) {
|
rpc VacuumVolume (VacuumVolumeRequest) returns (VacuumVolumeResponse) {
|
||||||
}
|
}
|
||||||
rpc GetMasterConfiguration (GetMasterConfigurationRequest) returns (GetMasterConfigurationResponse) {
|
rpc GetMasterConfiguration (GetMasterConfigurationRequest) returns (GetMasterConfigurationResponse) {
|
||||||
}
|
}
|
||||||
rpc ListMasterClients (ListMasterClientsRequest) returns (ListMasterClientsResponse) {
|
rpc ListClusterNodes (ListClusterNodesRequest) returns (ListClusterNodesResponse) {
|
||||||
}
|
}
|
||||||
rpc LeaseAdminToken (LeaseAdminTokenRequest) returns (LeaseAdminTokenResponse) {
|
rpc LeaseAdminToken (LeaseAdminTokenRequest) returns (LeaseAdminTokenResponse) {
|
||||||
}
|
}
|
||||||
rpc ReleaseAdminToken (ReleaseAdminTokenRequest) returns (ReleaseAdminTokenResponse) {
|
rpc ReleaseAdminToken (ReleaseAdminTokenRequest) returns (ReleaseAdminTokenResponse) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////
|
//////////////////////////////////////////////////
|
||||||
|
|
||||||
message Heartbeat {
|
message Heartbeat {
|
||||||
string ip = 1;
|
string ip = 1;
|
||||||
uint32 port = 2;
|
uint32 port = 2;
|
||||||
string public_url = 3;
|
string public_url = 3;
|
||||||
uint64 max_file_key = 5;
|
uint64 max_file_key = 5;
|
||||||
string data_center = 6;
|
string data_center = 6;
|
||||||
string rack = 7;
|
string rack = 7;
|
||||||
uint32 admin_port = 8;
|
uint32 admin_port = 8;
|
||||||
repeated VolumeInformationMessage volumes = 9;
|
repeated VolumeInformationMessage volumes = 9;
|
||||||
// delta volumes
|
// delta volumes
|
||||||
repeated VolumeShortInformationMessage new_volumes = 10;
|
repeated VolumeShortInformationMessage new_volumes = 10;
|
||||||
repeated VolumeShortInformationMessage deleted_volumes = 11;
|
repeated VolumeShortInformationMessage deleted_volumes = 11;
|
||||||
bool has_no_volumes = 12;
|
bool has_no_volumes = 12;
|
||||||
|
|
||||||
// erasure coding
|
// erasure coding
|
||||||
repeated VolumeEcShardInformationMessage ec_shards = 16;
|
repeated VolumeEcShardInformationMessage ec_shards = 16;
|
||||||
// delta erasure coding shards
|
// delta erasure coding shards
|
||||||
repeated VolumeEcShardInformationMessage new_ec_shards = 17;
|
repeated VolumeEcShardInformationMessage new_ec_shards = 17;
|
||||||
repeated VolumeEcShardInformationMessage deleted_ec_shards = 18;
|
repeated VolumeEcShardInformationMessage deleted_ec_shards = 18;
|
||||||
bool has_no_ec_shards = 19;
|
bool has_no_ec_shards = 19;
|
||||||
|
|
||||||
map<string, uint32> max_volume_counts = 4;
|
map<string, uint32> max_volume_counts = 4;
|
||||||
uint32 grpc_port = 20;
|
uint32 grpc_port = 20;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message HeartbeatResponse {
|
message HeartbeatResponse {
|
||||||
uint64 volume_size_limit = 1;
|
uint64 volume_size_limit = 1;
|
||||||
string leader = 2;
|
string leader = 2;
|
||||||
string metrics_address = 3;
|
string metrics_address = 3;
|
||||||
uint32 metrics_interval_seconds = 4;
|
uint32 metrics_interval_seconds = 4;
|
||||||
repeated StorageBackend storage_backends = 5;
|
repeated StorageBackend storage_backends = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VolumeInformationMessage {
|
message VolumeInformationMessage {
|
||||||
uint32 id = 1;
|
uint32 id = 1;
|
||||||
uint64 size = 2;
|
uint64 size = 2;
|
||||||
string collection = 3;
|
string collection = 3;
|
||||||
uint64 file_count = 4;
|
uint64 file_count = 4;
|
||||||
uint64 delete_count = 5;
|
uint64 delete_count = 5;
|
||||||
uint64 deleted_byte_count = 6;
|
uint64 deleted_byte_count = 6;
|
||||||
bool read_only = 7;
|
bool read_only = 7;
|
||||||
uint32 replica_placement = 8;
|
uint32 replica_placement = 8;
|
||||||
uint32 version = 9;
|
uint32 version = 9;
|
||||||
uint32 ttl = 10;
|
uint32 ttl = 10;
|
||||||
uint32 compact_revision = 11;
|
uint32 compact_revision = 11;
|
||||||
int64 modified_at_second = 12;
|
int64 modified_at_second = 12;
|
||||||
string remote_storage_name = 13;
|
string remote_storage_name = 13;
|
||||||
string remote_storage_key = 14;
|
string remote_storage_key = 14;
|
||||||
string disk_type = 15;
|
string disk_type = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VolumeShortInformationMessage {
|
message VolumeShortInformationMessage {
|
||||||
uint32 id = 1;
|
uint32 id = 1;
|
||||||
string collection = 3;
|
string collection = 3;
|
||||||
uint32 replica_placement = 8;
|
uint32 replica_placement = 8;
|
||||||
uint32 version = 9;
|
uint32 version = 9;
|
||||||
uint32 ttl = 10;
|
uint32 ttl = 10;
|
||||||
string disk_type = 15;
|
string disk_type = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VolumeEcShardInformationMessage {
|
message VolumeEcShardInformationMessage {
|
||||||
uint32 id = 1;
|
uint32 id = 1;
|
||||||
string collection = 2;
|
string collection = 2;
|
||||||
uint32 ec_index_bits = 3;
|
uint32 ec_index_bits = 3;
|
||||||
string disk_type = 4;
|
string disk_type = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StorageBackend {
|
message StorageBackend {
|
||||||
string type = 1;
|
string type = 1;
|
||||||
string id = 2;
|
string id = 2;
|
||||||
map<string, string> properties = 3;
|
map<string, string> properties = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Empty {
|
message Empty {
|
||||||
}
|
}
|
||||||
|
|
||||||
message SuperBlockExtra {
|
message SuperBlockExtra {
|
||||||
message ErasureCoding {
|
message ErasureCoding {
|
||||||
uint32 data = 1;
|
uint32 data = 1;
|
||||||
uint32 parity = 2;
|
uint32 parity = 2;
|
||||||
repeated uint32 volume_ids = 3;
|
repeated uint32 volume_ids = 3;
|
||||||
}
|
}
|
||||||
ErasureCoding erasure_coding = 1;
|
ErasureCoding erasure_coding = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message KeepConnectedRequest {
|
message KeepConnectedRequest {
|
||||||
string name = 1;
|
string client_type = 1;
|
||||||
string client_address = 3;
|
string client_address = 3;
|
||||||
|
string version = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VolumeLocation {
|
message VolumeLocation {
|
||||||
string url = 1;
|
string url = 1;
|
||||||
string public_url = 2;
|
string public_url = 2;
|
||||||
repeated uint32 new_vids = 3;
|
repeated uint32 new_vids = 3;
|
||||||
repeated uint32 deleted_vids = 4;
|
repeated uint32 deleted_vids = 4;
|
||||||
string leader = 5; // optional when leader is not itself
|
string leader = 5; // optional when leader is not itself
|
||||||
string data_center = 6; // optional when DataCenter is in use
|
string data_center = 6; // optional when DataCenter is in use
|
||||||
uint32 grpc_port = 7;
|
uint32 grpc_port = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ClusterNodeUpdate {
|
||||||
|
string node_type = 1;
|
||||||
|
string address = 2;
|
||||||
|
bool is_leader = 3;
|
||||||
|
bool is_add = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
message KeepConnectedResponse {
|
||||||
|
VolumeLocation volume_location = 1;
|
||||||
|
ClusterNodeUpdate cluster_node_update = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LookupVolumeRequest {
|
message LookupVolumeRequest {
|
||||||
repeated string volume_or_file_ids = 1;
|
repeated string volume_or_file_ids = 1;
|
||||||
string collection = 2; // optional, a bit faster if provided.
|
string collection = 2; // optional, a bit faster if provided.
|
||||||
}
|
}
|
||||||
message LookupVolumeResponse {
|
message LookupVolumeResponse {
|
||||||
message VolumeIdLocation {
|
message VolumeIdLocation {
|
||||||
string volume_or_file_id = 1;
|
string volume_or_file_id = 1;
|
||||||
repeated Location locations = 2;
|
repeated Location locations = 2;
|
||||||
string error = 3;
|
string error = 3;
|
||||||
string auth = 4;
|
string auth = 4;
|
||||||
}
|
}
|
||||||
repeated VolumeIdLocation volume_id_locations = 1;
|
repeated VolumeIdLocation volume_id_locations = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Location {
|
message Location {
|
||||||
string url = 1;
|
string url = 1;
|
||||||
string public_url = 2;
|
string public_url = 2;
|
||||||
uint32 grpc_port = 3;
|
uint32 grpc_port = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
message AssignRequest {
|
message AssignRequest {
|
||||||
uint64 count = 1;
|
uint64 count = 1;
|
||||||
string replication = 2;
|
string replication = 2;
|
||||||
string collection = 3;
|
string collection = 3;
|
||||||
string ttl = 4;
|
string ttl = 4;
|
||||||
string data_center = 5;
|
string data_center = 5;
|
||||||
string rack = 6;
|
string rack = 6;
|
||||||
string data_node = 7;
|
string data_node = 7;
|
||||||
uint32 memory_map_max_size_mb = 8;
|
uint32 memory_map_max_size_mb = 8;
|
||||||
uint32 Writable_volume_count = 9;
|
uint32 Writable_volume_count = 9;
|
||||||
string disk_type = 10;
|
string disk_type = 10;
|
||||||
}
|
}
|
||||||
message AssignResponse {
|
message AssignResponse {
|
||||||
string fid = 1;
|
string fid = 1;
|
||||||
uint64 count = 4;
|
uint64 count = 4;
|
||||||
string error = 5;
|
string error = 5;
|
||||||
string auth = 6;
|
string auth = 6;
|
||||||
repeated Location replicas = 7;
|
repeated Location replicas = 7;
|
||||||
Location location = 8;
|
Location location = 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
message StatisticsRequest {
|
message StatisticsRequest {
|
||||||
string replication = 1;
|
string replication = 1;
|
||||||
string collection = 2;
|
string collection = 2;
|
||||||
string ttl = 3;
|
string ttl = 3;
|
||||||
string disk_type = 4;
|
string disk_type = 4;
|
||||||
}
|
}
|
||||||
message StatisticsResponse {
|
message StatisticsResponse {
|
||||||
uint64 total_size = 4;
|
uint64 total_size = 4;
|
||||||
uint64 used_size = 5;
|
uint64 used_size = 5;
|
||||||
uint64 file_count = 6;
|
uint64 file_count = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// collection related
|
// collection related
|
||||||
//
|
//
|
||||||
message Collection {
|
message Collection {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
}
|
}
|
||||||
message CollectionListRequest {
|
message CollectionListRequest {
|
||||||
bool include_normal_volumes = 1;
|
bool include_normal_volumes = 1;
|
||||||
bool include_ec_volumes = 2;
|
bool include_ec_volumes = 2;
|
||||||
}
|
}
|
||||||
message CollectionListResponse {
|
message CollectionListResponse {
|
||||||
repeated Collection collections = 1;
|
repeated Collection collections = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CollectionDeleteRequest {
|
message CollectionDeleteRequest {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
}
|
}
|
||||||
message CollectionDeleteResponse {
|
message CollectionDeleteResponse {
|
||||||
}
|
}
|
||||||
@@ -218,56 +231,56 @@ message CollectionDeleteResponse {
|
|||||||
// volume related
|
// volume related
|
||||||
//
|
//
|
||||||
message DiskInfo {
|
message DiskInfo {
|
||||||
string type = 1;
|
string type = 1;
|
||||||
int64 volume_count = 2;
|
int64 volume_count = 2;
|
||||||
int64 max_volume_count = 3;
|
int64 max_volume_count = 3;
|
||||||
int64 free_volume_count = 4;
|
int64 free_volume_count = 4;
|
||||||
int64 active_volume_count = 5;
|
int64 active_volume_count = 5;
|
||||||
repeated VolumeInformationMessage volume_infos = 6;
|
repeated VolumeInformationMessage volume_infos = 6;
|
||||||
repeated VolumeEcShardInformationMessage ec_shard_infos = 7;
|
repeated VolumeEcShardInformationMessage ec_shard_infos = 7;
|
||||||
int64 remote_volume_count = 8;
|
int64 remote_volume_count = 8;
|
||||||
}
|
}
|
||||||
message DataNodeInfo {
|
message DataNodeInfo {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
map<string, DiskInfo> diskInfos = 2;
|
map<string, DiskInfo> diskInfos = 2;
|
||||||
uint32 grpc_port = 3;
|
uint32 grpc_port = 3;
|
||||||
}
|
}
|
||||||
message RackInfo {
|
message RackInfo {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
repeated DataNodeInfo data_node_infos = 2;
|
repeated DataNodeInfo data_node_infos = 2;
|
||||||
map<string, DiskInfo> diskInfos = 3;
|
map<string, DiskInfo> diskInfos = 3;
|
||||||
}
|
}
|
||||||
message DataCenterInfo {
|
message DataCenterInfo {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
repeated RackInfo rack_infos = 2;
|
repeated RackInfo rack_infos = 2;
|
||||||
map<string, DiskInfo> diskInfos = 3;
|
map<string, DiskInfo> diskInfos = 3;
|
||||||
}
|
}
|
||||||
message TopologyInfo {
|
message TopologyInfo {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
repeated DataCenterInfo data_center_infos = 2;
|
repeated DataCenterInfo data_center_infos = 2;
|
||||||
map<string, DiskInfo> diskInfos = 3;
|
map<string, DiskInfo> diskInfos = 3;
|
||||||
}
|
}
|
||||||
message VolumeListRequest {
|
message VolumeListRequest {
|
||||||
}
|
}
|
||||||
message VolumeListResponse {
|
message VolumeListResponse {
|
||||||
TopologyInfo topology_info = 1;
|
TopologyInfo topology_info = 1;
|
||||||
uint64 volume_size_limit_mb = 2;
|
uint64 volume_size_limit_mb = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LookupEcVolumeRequest {
|
message LookupEcVolumeRequest {
|
||||||
uint32 volume_id = 1;
|
uint32 volume_id = 1;
|
||||||
}
|
}
|
||||||
message LookupEcVolumeResponse {
|
message LookupEcVolumeResponse {
|
||||||
uint32 volume_id = 1;
|
uint32 volume_id = 1;
|
||||||
message EcShardIdLocation {
|
message EcShardIdLocation {
|
||||||
uint32 shard_id = 1;
|
uint32 shard_id = 1;
|
||||||
repeated Location locations = 2;
|
repeated Location locations = 2;
|
||||||
}
|
}
|
||||||
repeated EcShardIdLocation shard_id_locations = 2;
|
repeated EcShardIdLocation shard_id_locations = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message VacuumVolumeRequest {
|
message VacuumVolumeRequest {
|
||||||
float garbage_threshold = 1;
|
float garbage_threshold = 1;
|
||||||
}
|
}
|
||||||
message VacuumVolumeResponse {
|
message VacuumVolumeResponse {
|
||||||
}
|
}
|
||||||
@@ -275,37 +288,42 @@ message VacuumVolumeResponse {
|
|||||||
message GetMasterConfigurationRequest {
|
message GetMasterConfigurationRequest {
|
||||||
}
|
}
|
||||||
message GetMasterConfigurationResponse {
|
message GetMasterConfigurationResponse {
|
||||||
string metrics_address = 1;
|
string metrics_address = 1;
|
||||||
uint32 metrics_interval_seconds = 2;
|
uint32 metrics_interval_seconds = 2;
|
||||||
repeated StorageBackend storage_backends = 3;
|
repeated StorageBackend storage_backends = 3;
|
||||||
string default_replication = 4;
|
string default_replication = 4;
|
||||||
string leader = 5;
|
string leader = 5;
|
||||||
uint32 volume_size_limit_m_b = 6;
|
uint32 volume_size_limit_m_b = 6;
|
||||||
bool volume_preallocate = 7;
|
bool volume_preallocate = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ListMasterClientsRequest {
|
message ListClusterNodesRequest {
|
||||||
string client_type = 1;
|
string client_type = 1;
|
||||||
}
|
}
|
||||||
message ListMasterClientsResponse {
|
message ListClusterNodesResponse {
|
||||||
repeated string grpc_addresses = 1;
|
message ClusterNode {
|
||||||
|
string address = 1;
|
||||||
|
string version = 2;
|
||||||
|
bool is_leader = 3;
|
||||||
|
}
|
||||||
|
repeated ClusterNode cluster_nodes = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message LeaseAdminTokenRequest {
|
message LeaseAdminTokenRequest {
|
||||||
int64 previous_token = 1;
|
int64 previous_token = 1;
|
||||||
int64 previous_lock_time = 2;
|
int64 previous_lock_time = 2;
|
||||||
string lock_name = 3;
|
string lock_name = 3;
|
||||||
string client_name = 4;
|
string client_name = 4;
|
||||||
}
|
}
|
||||||
message LeaseAdminTokenResponse {
|
message LeaseAdminTokenResponse {
|
||||||
int64 token = 1;
|
int64 token = 1;
|
||||||
int64 lock_ts_ns = 2;
|
int64 lock_ts_ns = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ReleaseAdminTokenRequest {
|
message ReleaseAdminTokenRequest {
|
||||||
int64 previous_token = 1;
|
int64 previous_token = 1;
|
||||||
int64 previous_lock_time = 2;
|
int64 previous_lock_time = 2;
|
||||||
string lock_name = 3;
|
string lock_name = 3;
|
||||||
}
|
}
|
||||||
message ReleaseAdminTokenResponse {
|
message ReleaseAdminTokenResponse {
|
||||||
}
|
}
|
||||||
+901
-632
File diff suppressed because it is too large.
Load diff
@@ -83,6 +83,7 @@ func (s *s3RemoteStorageClient) Traverse(remote *remote_pb.RemoteStorageLocation
|
|||||||
}
|
}
|
||||||
isLastPage := false
|
isLastPage := false
|
||||||
for !isLastPage && err == nil {
|
for !isLastPage && err == nil {
|
||||||
|
var localErr error
|
||||||
listErr := s.conn.ListObjectsV2Pages(listInput, func(page *s3.ListObjectsV2Output, lastPage bool) bool {
|
listErr := s.conn.ListObjectsV2Pages(listInput, func(page *s3.ListObjectsV2Output, lastPage bool) bool {
|
||||||
for _, content := range page.Contents {
|
for _, content := range page.Contents {
|
||||||
key := *content.Key
|
key := *content.Key
|
||||||
@@ -94,6 +95,7 @@ func (s *s3RemoteStorageClient) Traverse(remote *remote_pb.RemoteStorageLocation
|
|||||||
RemoteETag: *content.ETag,
|
RemoteETag: *content.ETag,
|
||||||
StorageName: s.conf.Name,
|
StorageName: s.conf.Name,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
localErr = err
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,9 @@ func (s *s3RemoteStorageClient) Traverse(remote *remote_pb.RemoteStorageLocation
|
|||||||
if listErr != nil {
|
if listErr != nil {
|
||||||
err = fmt.Errorf("list %v: %v", remote, listErr)
|
err = fmt.Errorf("list %v: %v", remote, listErr)
|
||||||
}
|
}
|
||||||
|
if localErr != nil {
|
||||||
|
err = fmt.Errorf("process %v: %v", remote, localErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
@@ -23,6 +24,8 @@ type Iam interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IdentityAccessManagement struct {
|
type IdentityAccessManagement struct {
|
||||||
|
m sync.RWMutex
|
||||||
|
|
||||||
identities []*Identity
|
identities []*Identity
|
||||||
domain string
|
domain string
|
||||||
}
|
}
|
||||||
@@ -131,31 +134,38 @@ func (iam *IdentityAccessManagement) loadS3ApiConfiguration(config *iam_pb.S3Api
|
|||||||
}
|
}
|
||||||
identities = append(identities, t)
|
identities = append(identities, t)
|
||||||
}
|
}
|
||||||
|
iam.m.Lock()
|
||||||
// atomically switch
|
// atomically switch
|
||||||
iam.identities = identities
|
iam.identities = identities
|
||||||
|
iam.m.Unlock()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iam *IdentityAccessManagement) isEnabled() bool {
|
func (iam *IdentityAccessManagement) isEnabled() bool {
|
||||||
|
iam.m.RLock()
|
||||||
|
defer iam.m.RUnlock()
|
||||||
return len(iam.identities) > 0
|
return len(iam.identities) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iam *IdentityAccessManagement) lookupByAccessKey(accessKey string) (identity *Identity, cred *Credential, found bool) {
|
func (iam *IdentityAccessManagement) lookupByAccessKey(accessKey string) (identity *Identity, cred *Credential, found bool) {
|
||||||
|
|
||||||
|
iam.m.RLock()
|
||||||
|
defer iam.m.RUnlock()
|
||||||
for _, ident := range iam.identities {
|
for _, ident := range iam.identities {
|
||||||
for _, cred := range ident.Credentials {
|
for _, cred := range ident.Credentials {
|
||||||
|
// println("checking", ident.Name, cred.AccessKey)
|
||||||
if cred.AccessKey == accessKey {
|
if cred.AccessKey == accessKey {
|
||||||
return ident, cred, true
|
return ident, cred, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
glog.V(1).Infof("could not find accessKey %s", accessKey)
|
||||||
return nil, nil, false
|
return nil, nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iam *IdentityAccessManagement) lookupAnonymous() (identity *Identity, found bool) {
|
func (iam *IdentityAccessManagement) lookupAnonymous() (identity *Identity, found bool) {
|
||||||
|
iam.m.RLock()
|
||||||
|
defer iam.m.RUnlock()
|
||||||
for _, ident := range iam.identities {
|
for _, ident := range iam.identities {
|
||||||
if ident.Name == "anonymous" {
|
if ident.Name == "anonymous" {
|
||||||
return ident, true
|
return ident, true
|
||||||
@@ -177,6 +187,8 @@ func (iam *IdentityAccessManagement) Auth(f http.HandlerFunc, action Action) htt
|
|||||||
r.Header.Set(xhttp.AmzIdentityId, identity.Name)
|
r.Header.Set(xhttp.AmzIdentityId, identity.Name)
|
||||||
if identity.isAdmin() {
|
if identity.isAdmin() {
|
||||||
r.Header.Set(xhttp.AmzIsAdmin, "true")
|
r.Header.Set(xhttp.AmzIsAdmin, "true")
|
||||||
|
} else if _, ok := r.Header[xhttp.AmzIsAdmin]; ok {
|
||||||
|
r.Header.Del(xhttp.AmzIsAdmin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f(w, r)
|
f(w, r)
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if s3a.iam.isEnabled() {
|
||||||
|
if _, errCode = s3a.iam.authRequest(r, s3_constants.ACTION_ADMIN); errCode != s3err.ErrNone {
|
||||||
|
s3err.WriteErrorResponse(w, r, errCode)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn := func(entry *filer_pb.Entry) {
|
fn := func(entry *filer_pb.Entry) {
|
||||||
if identityId := r.Header.Get(xhttp.AmzIdentityId); identityId != "" {
|
if identityId := r.Header.Get(xhttp.AmzIdentityId); identityId != "" {
|
||||||
if entry.Extended == nil {
|
if entry.Extended == nil {
|
||||||
|
|||||||
@@ -220,12 +220,16 @@ func (s3a *S3ApiServer) doListFilerEntries(client filer_pb.SeaweedFilerClient, d
|
|||||||
err = subErr
|
err = subErr
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
counter += subCounter
|
||||||
isTruncated = isTruncated || subIsTruncated
|
isTruncated = isTruncated || subIsTruncated
|
||||||
maxKeys -= subCounter
|
maxKeys -= subCounter
|
||||||
nextMarker = subDir + "/" + subNextMarker
|
nextMarker = subDir + "/" + subNextMarker
|
||||||
// finished processing this sub directory
|
// finished processing this sub directory
|
||||||
marker = subDir
|
marker = subDir
|
||||||
}
|
}
|
||||||
|
if maxKeys <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// now marker is also a direct child of dir
|
// now marker is also a direct child of dir
|
||||||
request := &filer_pb.ListEntriesRequest{
|
request := &filer_pb.ListEntriesRequest{
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) {
|
|||||||
// HeadObject
|
// HeadObject
|
||||||
bucket.Methods("HEAD").Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.HeadObjectHandler, ACTION_READ), "GET"))
|
bucket.Methods("HEAD").Path("/{object:.+}").HandlerFunc(track(s3a.iam.Auth(s3a.HeadObjectHandler, ACTION_READ), "GET"))
|
||||||
// HeadBucket
|
// HeadBucket
|
||||||
bucket.Methods("HEAD").HandlerFunc(track(s3a.iam.Auth(s3a.HeadBucketHandler, ACTION_ADMIN), "GET"))
|
bucket.Methods("HEAD").HandlerFunc(track(s3a.iam.Auth(s3a.HeadBucketHandler, ACTION_READ), "GET"))
|
||||||
|
|
||||||
// CopyObjectPart
|
// CopyObjectPart
|
||||||
bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", `.*?(\/|%2F).*?`).HandlerFunc(track(s3a.iam.Auth(s3a.CopyObjectPartHandler, ACTION_WRITE), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")
|
bucket.Methods("PUT").Path("/{object:.+}").HeadersRegexp("X-Amz-Copy-Source", `.*?(\/|%2F).*?`).HandlerFunc(track(s3a.iam.Auth(s3a.CopyObjectPartHandler, ACTION_WRITE), "PUT")).Queries("partNumber", "{partNumber:[0-9]+}", "uploadId", "{uploadId:.*}")
|
||||||
@@ -137,7 +137,7 @@ func (s3a *S3ApiServer) registerRouter(router *mux.Router) {
|
|||||||
bucket.Methods("GET").HandlerFunc(track(s3a.iam.Auth(s3a.ListObjectsV1Handler, ACTION_LIST), "LIST"))
|
bucket.Methods("GET").HandlerFunc(track(s3a.iam.Auth(s3a.ListObjectsV1Handler, ACTION_LIST), "LIST"))
|
||||||
|
|
||||||
// PutBucket
|
// PutBucket
|
||||||
bucket.Methods("PUT").HandlerFunc(track(s3a.iam.Auth(s3a.PutBucketHandler, ACTION_ADMIN), "PUT"))
|
bucket.Methods("PUT").HandlerFunc(track(s3a.PutBucketHandler, "PUT"))
|
||||||
|
|
||||||
// DeleteBucket
|
// DeleteBucket
|
||||||
bucket.Methods("DELETE").HandlerFunc(track(s3a.iam.Auth(s3a.DeleteBucketHandler, ACTION_WRITE), "DELETE"))
|
bucket.Methods("DELETE").HandlerFunc(track(s3a.iam.Auth(s3a.DeleteBucketHandler, ACTION_WRITE), "DELETE"))
|
||||||
|
|||||||
+1
-2
@@ -2,7 +2,6 @@ package s3api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
|
stats_collect "github.com/chrislusf/seaweedfs/weed/stats"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
@@ -28,7 +27,7 @@ func (r *StatusRecorder) Flush() {
|
|||||||
|
|
||||||
func track(f http.HandlerFunc, action string) http.HandlerFunc {
|
func track(f http.HandlerFunc, action string) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Server", "SeaweedFS S3 "+util.VERSION)
|
w.Header().Set("Server", "SeaweedFS S3")
|
||||||
recorder := NewStatusResponseWriter(w)
|
recorder := NewStatusResponseWriter(w)
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
f(recorder, r)
|
f(recorder, r)
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ func (fs *FilerServer) moveSelfEntry(ctx context.Context, stream filer_pb.Seawee
|
|||||||
if err := stream.Send(&filer_pb.StreamRenameEntryResponse{
|
if err := stream.Send(&filer_pb.StreamRenameEntryResponse{
|
||||||
Directory: string(newParent),
|
Directory: string(newParent),
|
||||||
EventNotification: &filer_pb.EventNotification{
|
EventNotification: &filer_pb.EventNotification{
|
||||||
OldEntry: &filer_pb.Entry{
|
OldEntry: &filer_pb.Entry{
|
||||||
Name: entry.Name(),
|
Name: entry.Name(),
|
||||||
},
|
},
|
||||||
NewEntry: newEntry.ToProtoEntry(),
|
NewEntry: newEntry.ToProtoEntry(),
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ type FilerOption struct {
|
|||||||
recursiveDelete bool
|
recursiveDelete bool
|
||||||
Cipher bool
|
Cipher bool
|
||||||
SaveToFilerLimit int64
|
SaveToFilerLimit int64
|
||||||
Filers []pb.ServerAddress
|
|
||||||
ConcurrentUploadLimit int64
|
ConcurrentUploadLimit int64
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||||||
fs.checkWithMaster()
|
fs.checkWithMaster()
|
||||||
|
|
||||||
go stats.LoopPushingMetric("filer", string(fs.option.Host), fs.metricsAddress, fs.metricsIntervalSec)
|
go stats.LoopPushingMetric("filer", string(fs.option.Host), fs.metricsAddress, fs.metricsIntervalSec)
|
||||||
go fs.filer.KeepConnectedToMaster()
|
go fs.filer.KeepMasterClientConnected()
|
||||||
|
|
||||||
v := util.GetViper()
|
v := util.GetViper()
|
||||||
if !util.LoadConfiguration("filer", false) {
|
if !util.LoadConfiguration("filer", false) {
|
||||||
@@ -143,7 +142,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||||||
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.filer.AggregateFromPeers(option.Host, option.Filers)
|
fs.filer.AggregateFromPeers(option.Host)
|
||||||
|
|
||||||
fs.filer.LoadBuckets()
|
fs.filer.LoadBuckets()
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/chrislusf/raft"
|
"github.com/chrislusf/raft"
|
||||||
@@ -45,11 +44,7 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
if len(message.DeletedVids) > 0 {
|
if len(message.DeletedVids) > 0 {
|
||||||
ms.clientChansLock.RLock()
|
ms.broadcastToClients(&master_pb.KeepConnectedResponse{VolumeLocation: message})
|
||||||
for _, ch := range ms.clientChans {
|
|
||||||
ch <- message
|
|
||||||
}
|
|
||||||
ms.clientChansLock.RUnlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -154,12 +149,7 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||||||
|
|
||||||
}
|
}
|
||||||
if len(message.NewVids) > 0 || len(message.DeletedVids) > 0 {
|
if len(message.NewVids) > 0 || len(message.DeletedVids) > 0 {
|
||||||
ms.clientChansLock.RLock()
|
ms.broadcastToClients(&master_pb.KeepConnectedResponse{VolumeLocation: message})
|
||||||
for host, ch := range ms.clientChans {
|
|
||||||
glog.V(0).Infof("master send to %s: %s", host, message.String())
|
|
||||||
ch <- message
|
|
||||||
}
|
|
||||||
ms.clientChansLock.RUnlock()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// tell the volume servers about the leader
|
// tell the volume servers about the leader
|
||||||
@@ -195,12 +185,20 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
|
|||||||
// buffer by 1 so we don't end up getting stuck writing to stopChan forever
|
// buffer by 1 so we don't end up getting stuck writing to stopChan forever
|
||||||
stopChan := make(chan bool, 1)
|
stopChan := make(chan bool, 1)
|
||||||
|
|
||||||
clientName, messageChan := ms.addClient(req.Name, peerAddress)
|
clientName, messageChan := ms.addClient(req.ClientType, peerAddress)
|
||||||
|
for _, update := range ms.Cluster.AddClusterNode(req.ClientType, peerAddress, req.Version) {
|
||||||
|
ms.broadcastToClients(update)
|
||||||
|
}
|
||||||
|
|
||||||
defer ms.deleteClient(clientName)
|
defer func() {
|
||||||
|
for _, update := range ms.Cluster.RemoveClusterNode(req.ClientType, peerAddress) {
|
||||||
|
ms.broadcastToClients(update)
|
||||||
|
}
|
||||||
|
ms.deleteClient(clientName)
|
||||||
|
}()
|
||||||
|
|
||||||
for _, message := range ms.Topo.ToVolumeLocations() {
|
for _, message := range ms.Topo.ToVolumeLocations() {
|
||||||
if sendErr := stream.Send(message); sendErr != nil {
|
if sendErr := stream.Send(&master_pb.KeepConnectedResponse{VolumeLocation: message}); sendErr != nil {
|
||||||
return sendErr
|
return sendErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,21 +233,31 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ms *MasterServer) broadcastToClients(message *master_pb.KeepConnectedResponse) {
|
||||||
|
ms.clientChansLock.RLock()
|
||||||
|
for _, ch := range ms.clientChans {
|
||||||
|
ch <- message
|
||||||
|
}
|
||||||
|
ms.clientChansLock.RUnlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (ms *MasterServer) informNewLeader(stream master_pb.Seaweed_KeepConnectedServer) error {
|
func (ms *MasterServer) informNewLeader(stream master_pb.Seaweed_KeepConnectedServer) error {
|
||||||
leader, err := ms.Topo.Leader()
|
leader, err := ms.Topo.Leader()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("topo leader: %v", err)
|
glog.Errorf("topo leader: %v", err)
|
||||||
return raft.NotLeaderError
|
return raft.NotLeaderError
|
||||||
}
|
}
|
||||||
if err := stream.Send(&master_pb.VolumeLocation{
|
if err := stream.Send(&master_pb.KeepConnectedResponse{
|
||||||
Leader: string(leader),
|
VolumeLocation: &master_pb.VolumeLocation{
|
||||||
|
Leader: string(leader),
|
||||||
|
},
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MasterServer) addClient(clientType string, clientAddress pb.ServerAddress) (clientName string, messageChan chan *master_pb.VolumeLocation) {
|
func (ms *MasterServer) addClient(clientType string, clientAddress pb.ServerAddress) (clientName string, messageChan chan *master_pb.KeepConnectedResponse) {
|
||||||
clientName = clientType + "@" + string(clientAddress)
|
clientName = clientType + "@" + string(clientAddress)
|
||||||
glog.V(0).Infof("+ client %v", clientName)
|
glog.V(0).Infof("+ client %v", clientName)
|
||||||
|
|
||||||
@@ -258,7 +266,7 @@ func (ms *MasterServer) addClient(clientType string, clientAddress pb.ServerAddr
|
|||||||
// trying to send to it in SendHeartbeat and so we can't lock the
|
// trying to send to it in SendHeartbeat and so we can't lock the
|
||||||
// clientChansLock to remove the channel and we're stuck writing to it
|
// clientChansLock to remove the channel and we're stuck writing to it
|
||||||
// 100 is probably overkill
|
// 100 is probably overkill
|
||||||
messageChan = make(chan *master_pb.VolumeLocation, 100)
|
messageChan = make(chan *master_pb.KeepConnectedResponse, 100)
|
||||||
|
|
||||||
ms.clientChansLock.Lock()
|
ms.clientChansLock.Lock()
|
||||||
ms.clientChans[clientName] = messageChan
|
ms.clientChans[clientName] = messageChan
|
||||||
@@ -295,19 +303,6 @@ func findClientAddress(ctx context.Context, grpcPort uint32) string {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MasterServer) ListMasterClients(ctx context.Context, req *master_pb.ListMasterClientsRequest) (*master_pb.ListMasterClientsResponse, error) {
|
|
||||||
resp := &master_pb.ListMasterClientsResponse{}
|
|
||||||
ms.clientChansLock.RLock()
|
|
||||||
defer ms.clientChansLock.RUnlock()
|
|
||||||
|
|
||||||
for k := range ms.clientChans {
|
|
||||||
if strings.HasPrefix(k, req.ClientType+"@") {
|
|
||||||
resp.GrpcAddresses = append(resp.GrpcAddresses, k[len(req.ClientType)+1:])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ms *MasterServer) GetMasterConfiguration(ctx context.Context, req *master_pb.GetMasterConfigurationRequest) (*master_pb.GetMasterConfigurationResponse, error) {
|
func (ms *MasterServer) GetMasterConfiguration(ctx context.Context, req *master_pb.GetMasterConfigurationRequest) (*master_pb.GetMasterConfigurationResponse, error) {
|
||||||
|
|
||||||
// tell the volume servers about the leader
|
// tell the volume servers about the leader
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package weed_server
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (ms *MasterServer) ListClusterNodes(ctx context.Context, req *master_pb.ListClusterNodesRequest) (*master_pb.ListClusterNodesResponse, error) {
|
||||||
|
resp := &master_pb.ListClusterNodesResponse{}
|
||||||
|
|
||||||
|
clusterNodes := ms.Cluster.ListClusterNode(req.ClientType)
|
||||||
|
|
||||||
|
for _, node := range clusterNodes {
|
||||||
|
resp.ClusterNodes = append(resp.ClusterNodes, &master_pb.ListClusterNodesResponse_ClusterNode{
|
||||||
|
Address: string(node.Address),
|
||||||
|
Version: node.Version,
|
||||||
|
IsLeader: ms.Cluster.IsOneLeader(node.Address),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package weed_server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
@@ -60,13 +61,15 @@ type MasterServer struct {
|
|||||||
|
|
||||||
// notifying clients
|
// notifying clients
|
||||||
clientChansLock sync.RWMutex
|
clientChansLock sync.RWMutex
|
||||||
clientChans map[string]chan *master_pb.VolumeLocation
|
clientChans map[string]chan *master_pb.KeepConnectedResponse
|
||||||
|
|
||||||
grpcDialOption grpc.DialOption
|
grpcDialOption grpc.DialOption
|
||||||
|
|
||||||
MasterClient *wdclient.MasterClient
|
MasterClient *wdclient.MasterClient
|
||||||
|
|
||||||
adminLocks *AdminLocks
|
adminLocks *AdminLocks
|
||||||
|
|
||||||
|
Cluster *cluster.Cluster
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMasterServer(r *mux.Router, option *MasterOption, peers []pb.ServerAddress) *MasterServer {
|
func NewMasterServer(r *mux.Router, option *MasterOption, peers []pb.ServerAddress) *MasterServer {
|
||||||
@@ -99,10 +102,11 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers []pb.ServerAddre
|
|||||||
option: option,
|
option: option,
|
||||||
preallocateSize: preallocateSize,
|
preallocateSize: preallocateSize,
|
||||||
vgCh: make(chan *topology.VolumeGrowRequest, 1<<6),
|
vgCh: make(chan *topology.VolumeGrowRequest, 1<<6),
|
||||||
clientChans: make(map[string]chan *master_pb.VolumeLocation),
|
clientChans: make(map[string]chan *master_pb.KeepConnectedResponse),
|
||||||
grpcDialOption: grpcDialOption,
|
grpcDialOption: grpcDialOption,
|
||||||
MasterClient: wdclient.NewMasterClient(grpcDialOption, "master", option.Master, "", peers),
|
MasterClient: wdclient.NewMasterClient(grpcDialOption, cluster.MasterType, option.Master, "", peers),
|
||||||
adminLocks: NewAdminLocks(),
|
adminLocks: NewAdminLocks(),
|
||||||
|
Cluster: cluster.NewCluster(),
|
||||||
}
|
}
|
||||||
ms.boundedLeaderChan = make(chan int, 16)
|
ms.boundedLeaderChan = make(chan int, 16)
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ func (vs *VolumeServer) VolumeCopy(req *volume_server_pb.VolumeCopyRequest, stre
|
|||||||
|
|
||||||
// println("source:", volFileInfoResp.String())
|
// println("source:", volFileInfoResp.String())
|
||||||
copyResponse := &volume_server_pb.VolumeCopyResponse{}
|
copyResponse := &volume_server_pb.VolumeCopyResponse{}
|
||||||
reportInterval := int64(1024*1024*128)
|
reportInterval := int64(1024 * 1024 * 128)
|
||||||
nextReportTarget := reportInterval
|
nextReportTarget := reportInterval
|
||||||
var modifiedTsNs int64
|
var modifiedTsNs int64
|
||||||
var sendErr error
|
var sendErr error
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (vs *VolumeServer) VacuumVolumeCheck(ctx context.Context, req *volume_serve
|
|||||||
func (vs *VolumeServer) VacuumVolumeCompact(req *volume_server_pb.VacuumVolumeCompactRequest, stream volume_server_pb.VolumeServer_VacuumVolumeCompactServer) error {
|
func (vs *VolumeServer) VacuumVolumeCompact(req *volume_server_pb.VacuumVolumeCompactRequest, stream volume_server_pb.VolumeServer_VacuumVolumeCompactServer) error {
|
||||||
|
|
||||||
resp := &volume_server_pb.VacuumVolumeCompactResponse{}
|
resp := &volume_server_pb.VacuumVolumeCompactResponse{}
|
||||||
reportInterval := int64(1024*1024*128)
|
reportInterval := int64(1024 * 1024 * 128)
|
||||||
nextReportTarget := reportInterval
|
nextReportTarget := reportInterval
|
||||||
|
|
||||||
var sendErr error
|
var sendErr error
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package shell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
|
"io"
|
||||||
|
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Commands = append(Commands, &commandClusterPs{})
|
||||||
|
}
|
||||||
|
|
||||||
|
type commandClusterPs struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *commandClusterPs) Name() string {
|
||||||
|
return "cluster.ps"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *commandClusterPs) Help() string {
|
||||||
|
return `check current cluster process status
|
||||||
|
|
||||||
|
cluster.ps
|
||||||
|
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *commandClusterPs) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
||||||
|
|
||||||
|
clusterPsCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
||||||
|
if err = clusterPsCommand.Parse(args); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
||||||
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
|
ClientType: cluster.FilerType,
|
||||||
|
})
|
||||||
|
|
||||||
|
fmt.Fprintf(writer, "the cluster has %d filers\n", len(resp.ClusterNodes))
|
||||||
|
for _, node := range resp.ClusterNodes {
|
||||||
|
fmt.Fprintf(writer, " * %s (%v)\n", node.Address, node.Version)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"io"
|
"io"
|
||||||
|
"math/rand"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ func (c *commandEcEncode) Name() string {
|
|||||||
func (c *commandEcEncode) Help() string {
|
func (c *commandEcEncode) Help() string {
|
||||||
return `apply erasure coding to a volume
|
return `apply erasure coding to a volume
|
||||||
|
|
||||||
ec.encode [-collection=""] [-fullPercent=95] [-quietFor=1h]
|
ec.encode [-collection=""] [-fullPercent=95 -quietFor=1h]
|
||||||
ec.encode [-collection=""] [-volumeId=<volume_id>]
|
ec.encode [-collection=""] [-volumeId=<volume_id>]
|
||||||
|
|
||||||
This command will:
|
This command will:
|
||||||
@@ -248,7 +249,7 @@ func parallelCopyEcShardsFromSource(grpcDialOption grpc.DialOption, targetServer
|
|||||||
func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) {
|
func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) {
|
||||||
allocated = make([][]uint32, len(servers))
|
allocated = make([][]uint32, len(servers))
|
||||||
allocatedShardIdIndex := uint32(0)
|
allocatedShardIdIndex := uint32(0)
|
||||||
serverIndex := 0
|
serverIndex := rand.Intn(len(servers))
|
||||||
for allocatedShardIdIndex < erasure_coding.TotalShardsCount {
|
for allocatedShardIdIndex < erasure_coding.TotalShardsCount {
|
||||||
if servers[serverIndex].freeEcSlot > 0 {
|
if servers[serverIndex].freeEcSlot > 0 {
|
||||||
allocated[serverIndex] = append(allocated[serverIndex], allocatedShardIdIndex)
|
allocated[serverIndex] = append(allocated[serverIndex], allocatedShardIdIndex)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (c *commandRemoteCache) Help() string {
|
|||||||
return `cache the file content for mounted directories or files
|
return `cache the file content for mounted directories or files
|
||||||
|
|
||||||
# assume a remote storage is configured to name "cloud1"
|
# assume a remote storage is configured to name "cloud1"
|
||||||
remote.configure -name=cloud1 -type=s3 -access_key=xxx -secret_key=yyy
|
remote.configure -name=cloud1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy
|
||||||
# mount and pull one bucket
|
# mount and pull one bucket
|
||||||
remote.mount -dir=/xxx -remote=cloud1/bucket
|
remote.mount -dir=/xxx -remote=cloud1/bucket
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (c *commandRemoteMetaSync) Help() string {
|
|||||||
return `synchronize the local file meta data with the remote file metadata
|
return `synchronize the local file meta data with the remote file metadata
|
||||||
|
|
||||||
# assume a remote storage is configured to name "cloud1"
|
# assume a remote storage is configured to name "cloud1"
|
||||||
remote.configure -name=cloud1 -type=s3 -access_key=xxx -secret_key=yyy
|
remote.configure -name=cloud1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy
|
||||||
# mount and pull one bucket
|
# mount and pull one bucket
|
||||||
remote.mount -dir=/xxx -remote=cloud1/bucket
|
remote.mount -dir=/xxx -remote=cloud1/bucket
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func (c *commandRemoteMount) Help() string {
|
|||||||
return `mount remote storage and pull its metadata
|
return `mount remote storage and pull its metadata
|
||||||
|
|
||||||
# assume a remote storage is configured to name "cloud1"
|
# assume a remote storage is configured to name "cloud1"
|
||||||
remote.configure -name=cloud1 -type=s3 -access_key=xxx -secret_key=yyy
|
remote.configure -name=cloud1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy
|
||||||
|
|
||||||
# mount and pull one bucket
|
# mount and pull one bucket
|
||||||
remote.mount -dir=/xxx -remote=cloud1/bucket
|
remote.mount -dir=/xxx -remote=cloud1/bucket
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (c *commandRemoteMountBuckets) Help() string {
|
|||||||
return `mount all buckets in remote storage and pull its metadata
|
return `mount all buckets in remote storage and pull its metadata
|
||||||
|
|
||||||
# assume a remote storage is configured to name "cloud1"
|
# assume a remote storage is configured to name "cloud1"
|
||||||
remote.configure -name=cloud1 -type=s3 -access_key=xxx -secret_key=yyy
|
remote.configure -name=cloud1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy
|
||||||
|
|
||||||
# mount all buckets
|
# mount all buckets
|
||||||
remote.mount.buckets -remote=cloud1
|
remote.mount.buckets -remote=cloud1
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func (c *commandRemoteUnmount) Help() string {
|
|||||||
return `unmount remote storage
|
return `unmount remote storage
|
||||||
|
|
||||||
# assume a remote storage is configured to name "s3_1"
|
# assume a remote storage is configured to name "s3_1"
|
||||||
remote.configure -name=s3_1 -type=s3 -access_key=xxx -secret_key=yyy
|
remote.configure -name=s3_1 -type=s3 -s3.access_key=xxx -s3.secret_key=yyy
|
||||||
# mount and pull one bucket
|
# mount and pull one bucket
|
||||||
remote.mount -dir=/xxx -remote=s3_1/bucket
|
remote.mount -dir=/xxx -remote=s3_1/bucket
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/operation"
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
@@ -34,11 +35,12 @@ func (c *commandVolumeConfigureReplication) Help() string {
|
|||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
|
func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *CommandEnv, _ io.Writer) (err error) {
|
||||||
|
|
||||||
configureReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
configureReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
|
||||||
volumeIdInt := configureReplicationCommand.Int("volumeId", 0, "the volume id")
|
volumeIdInt := configureReplicationCommand.Int("volumeId", 0, "the volume id")
|
||||||
replicationString := configureReplicationCommand.String("replication", "", "the intended replication value")
|
replicationString := configureReplicationCommand.String("replication", "", "the intended replication value")
|
||||||
|
collectionPattern := configureReplicationCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'")
|
||||||
if err = configureReplicationCommand.Parse(args); err != nil {
|
if err = configureReplicationCommand.Parse(args); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -55,7 +57,6 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("replication format: %v", err)
|
return fmt.Errorf("replication format: %v", err)
|
||||||
}
|
}
|
||||||
replicaPlacementInt32 := uint32(replicaPlacement.Byte())
|
|
||||||
|
|
||||||
// collect topology information
|
// collect topology information
|
||||||
topologyInfo, _, err := collectTopologyInfo(commandEnv)
|
topologyInfo, _, err := collectTopologyInfo(commandEnv)
|
||||||
@@ -64,6 +65,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
|
|||||||
}
|
}
|
||||||
|
|
||||||
vid := needle.VolumeId(*volumeIdInt)
|
vid := needle.VolumeId(*volumeIdInt)
|
||||||
|
volumeFilter := getVolumeFilter(replicaPlacement, uint32(vid), *collectionPattern)
|
||||||
|
|
||||||
// find all data nodes with volumes that needs replication change
|
// find all data nodes with volumes that needs replication change
|
||||||
var allLocations []location
|
var allLocations []location
|
||||||
@@ -71,7 +73,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
|
|||||||
loc := newLocation(dc, string(rack), dn)
|
loc := newLocation(dc, string(rack), dn)
|
||||||
for _, diskInfo := range dn.DiskInfos {
|
for _, diskInfo := range dn.DiskInfos {
|
||||||
for _, v := range diskInfo.VolumeInfos {
|
for _, v := range diskInfo.VolumeInfos {
|
||||||
if v.Id == uint32(vid) && v.ReplicaPlacement != replicaPlacementInt32 {
|
if volumeFilter(v) {
|
||||||
allLocations = append(allLocations, loc)
|
allLocations = append(allLocations, loc)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -106,3 +108,19 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32, collectionPattern string) func(message *master_pb.VolumeInformationMessage) bool {
|
||||||
|
replicaPlacementInt32 := uint32(replicaPlacement.Byte())
|
||||||
|
if volumeId > 0 {
|
||||||
|
return func(v *master_pb.VolumeInformationMessage) bool {
|
||||||
|
return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return func(v *master_pb.VolumeInformationMessage) bool {
|
||||||
|
matched, err := filepath.Match(collectionPattern, v.Collection)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -261,6 +261,29 @@ func TestSatisfyReplicaPlacement00x(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSatisfyReplicaPlacement100(t *testing.T) {
|
||||||
|
|
||||||
|
var tests = []testcase{
|
||||||
|
{
|
||||||
|
name: "test 100",
|
||||||
|
replication: "100",
|
||||||
|
replicas: []*VolumeReplica{
|
||||||
|
{
|
||||||
|
location: &location{"dc1", "r1", &master_pb.DataNodeInfo{Id: "dn1"}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
location: &location{"dc1", "r2", &master_pb.DataNodeInfo{Id: "dn2"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
possibleLocation: location{"dc2", "r3", &master_pb.DataNodeInfo{Id: "dn3"}},
|
||||||
|
expected: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
runTests(tests, t)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func runTests(tests []testcase, t *testing.T) {
|
func runTests(tests []testcase, t *testing.T) {
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
replicaPlacement, _ := super_block.NewReplicaPlacementFromString(tt.replication)
|
replicaPlacement, _ := super_block.NewReplicaPlacementFromString(tt.replication)
|
||||||
|
|||||||
@@ -3,9 +3,13 @@ package shell
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/cluster"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util/grace"
|
"github.com/chrislusf/seaweedfs/weed/util/grace"
|
||||||
"io"
|
"io"
|
||||||
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
@@ -47,6 +51,29 @@ func RunShell(options ShellOptions) {
|
|||||||
go commandEnv.MasterClient.KeepConnectedToMaster()
|
go commandEnv.MasterClient.KeepConnectedToMaster()
|
||||||
commandEnv.MasterClient.WaitUntilConnected()
|
commandEnv.MasterClient.WaitUntilConnected()
|
||||||
|
|
||||||
|
if commandEnv.option.FilerAddress == "" {
|
||||||
|
var filers []pb.ServerAddress
|
||||||
|
commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
||||||
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
|
ClientType: cluster.FilerType,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, clusterNode := range resp.ClusterNodes {
|
||||||
|
filers = append(filers, pb.ServerAddress(clusterNode.Address))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
fmt.Printf("master: %s ", *options.Masters)
|
||||||
|
if len(filers) > 0 {
|
||||||
|
fmt.Printf("filers: %v", filers)
|
||||||
|
commandEnv.option.FilerAddress = filers[rand.Intn(len(filers))]
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
|
|
||||||
if commandEnv.option.FilerAddress != "" {
|
if commandEnv.option.FilerAddress != "" {
|
||||||
commandEnv.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error {
|
commandEnv.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := filerClient.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := filerClient.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ func uploadToS3(sess s3iface.S3API, filename string, destBucket string, destKey
|
|||||||
// Upload the file to S3.
|
// Upload the file to S3.
|
||||||
var result *s3manager.UploadOutput
|
var result *s3manager.UploadOutput
|
||||||
result, err = uploader.Upload(&s3manager.UploadInput{
|
result, err = uploader.Upload(&s3manager.UploadInput{
|
||||||
Bucket: aws.String(destBucket),
|
Bucket: aws.String(destBucket),
|
||||||
Key: aws.String(destKey),
|
Key: aws.String(destKey),
|
||||||
Body: fileReader,
|
Body: fileReader,
|
||||||
StorageClass: aws.String("STANDARD_IA"),
|
StorageClass: aws.String("STANDARD_IA"),
|
||||||
})
|
})
|
||||||
|
|
||||||
//in case it fails to upload
|
//in case it fails to upload
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
VERSION_NUMBER = fmt.Sprintf("%.02f", 2.76)
|
VERSION_NUMBER = fmt.Sprintf("%.02f", 2.78)
|
||||||
VERSION = sizeLimit + " " + VERSION_NUMBER
|
VERSION = sizeLimit + " " + VERSION_NUMBER
|
||||||
COMMIT = ""
|
COMMIT = ""
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ type MasterClient struct {
|
|||||||
grpcDialOption grpc.DialOption
|
grpcDialOption grpc.DialOption
|
||||||
|
|
||||||
vidMap
|
vidMap
|
||||||
|
|
||||||
|
OnPeerUpdate func(update *master_pb.ClusterNodeUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMasterClient(grpcDialOption grpc.DialOption, clientType string, clientHost pb.ServerAddress, clientDataCenter string, masters []pb.ServerAddress) *MasterClient {
|
func NewMasterClient(grpcDialOption grpc.DialOption, clientType string, clientHost pb.ServerAddress, clientDataCenter string, masters []pb.ServerAddress) *MasterClient {
|
||||||
@@ -93,7 +95,7 @@ func (mc *MasterClient) tryAllMasters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedLeader pb.ServerAddress) {
|
func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedLeader pb.ServerAddress) {
|
||||||
glog.V(0).Infof("%s masterClient Connecting to master %v", mc.clientType, master)
|
glog.V(1).Infof("%s masterClient Connecting to master %v", mc.clientType, master)
|
||||||
gprcErr := pb.WithMasterClient(master, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {
|
gprcErr := pb.WithMasterClient(master, mc.grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
@@ -105,7 +107,11 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = stream.Send(&master_pb.KeepConnectedRequest{Name: mc.clientType, ClientAddress: string(mc.clientHost)}); err != nil {
|
if err = stream.Send(&master_pb.KeepConnectedRequest{
|
||||||
|
ClientType: mc.clientType,
|
||||||
|
ClientAddress: string(mc.clientHost),
|
||||||
|
Version: util.Version(),
|
||||||
|
}); err != nil {
|
||||||
glog.V(0).Infof("%s masterClient failed to send to %s: %v", mc.clientType, master, err)
|
glog.V(0).Infof("%s masterClient failed to send to %s: %v", mc.clientType, master, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -114,34 +120,49 @@ func (mc *MasterClient) tryConnectToMaster(master pb.ServerAddress) (nextHintedL
|
|||||||
mc.currentMaster = master
|
mc.currentMaster = master
|
||||||
|
|
||||||
for {
|
for {
|
||||||
volumeLocation, err := stream.Recv()
|
resp, err := stream.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("%s masterClient failed to receive from %s: %v", mc.clientType, master, err)
|
glog.V(0).Infof("%s masterClient failed to receive from %s: %v", mc.clientType, master, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybe the leader is changed
|
if resp.VolumeLocation != nil {
|
||||||
if volumeLocation.Leader != "" {
|
// maybe the leader is changed
|
||||||
glog.V(0).Infof("redirected to leader %v", volumeLocation.Leader)
|
if resp.VolumeLocation.Leader != "" {
|
||||||
nextHintedLeader = pb.ServerAddress(volumeLocation.Leader)
|
glog.V(0).Infof("redirected to leader %v", resp.VolumeLocation.Leader)
|
||||||
return nil
|
nextHintedLeader = pb.ServerAddress(resp.VolumeLocation.Leader)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// process new volume location
|
||||||
|
loc := Location{
|
||||||
|
Url: resp.VolumeLocation.Url,
|
||||||
|
PublicUrl: resp.VolumeLocation.PublicUrl,
|
||||||
|
DataCenter: resp.VolumeLocation.DataCenter,
|
||||||
|
GrpcPort: int(resp.VolumeLocation.GrpcPort),
|
||||||
|
}
|
||||||
|
for _, newVid := range resp.VolumeLocation.NewVids {
|
||||||
|
glog.V(1).Infof("%s: %s masterClient adds volume %d", mc.clientType, loc.Url, newVid)
|
||||||
|
mc.addLocation(newVid, loc)
|
||||||
|
}
|
||||||
|
for _, deletedVid := range resp.VolumeLocation.DeletedVids {
|
||||||
|
glog.V(1).Infof("%s: %s masterClient removes volume %d", mc.clientType, loc.Url, deletedVid)
|
||||||
|
mc.deleteLocation(deletedVid, loc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// process new volume location
|
if resp.ClusterNodeUpdate != nil {
|
||||||
loc := Location{
|
update := resp.ClusterNodeUpdate
|
||||||
Url: volumeLocation.Url,
|
if mc.OnPeerUpdate != nil {
|
||||||
PublicUrl: volumeLocation.PublicUrl,
|
if update.IsAdd {
|
||||||
DataCenter: volumeLocation.DataCenter,
|
glog.V(0).Infof("+ %s %s leader:%v\n", update.NodeType, update.Address, update.IsLeader)
|
||||||
GrpcPort: int(volumeLocation.GrpcPort),
|
} else {
|
||||||
}
|
glog.V(0).Infof("- %s %s leader:%v\n", update.NodeType, update.Address, update.IsLeader)
|
||||||
for _, newVid := range volumeLocation.NewVids {
|
}
|
||||||
glog.V(1).Infof("%s: %s masterClient adds volume %d", mc.clientType, loc.Url, newVid)
|
mc.OnPeerUpdate(update)
|
||||||
mc.addLocation(newVid, loc)
|
}
|
||||||
}
|
|
||||||
for _, deletedVid := range volumeLocation.DeletedVids {
|
|
||||||
glog.V(1).Infof("%s: %s masterClient removes volume %d", mc.clientType, loc.Url, deletedVid)
|
|
||||||
mc.deleteLocation(deletedVid, loc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb"
|
"github.com/chrislusf/seaweedfs/weed/pb"
|
||||||
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -69,13 +70,21 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrls []string, err er
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("volume %d not found", id)
|
return nil, fmt.Errorf("volume %d not found", id)
|
||||||
}
|
}
|
||||||
|
var sameDcServers, otherDcServers []string
|
||||||
for _, loc := range locations {
|
for _, loc := range locations {
|
||||||
if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter {
|
if vc.DataCenter == "" || loc.DataCenter == "" || vc.DataCenter != loc.DataCenter {
|
||||||
serverUrls = append(serverUrls, loc.Url)
|
sameDcServers = append(sameDcServers, loc.Url)
|
||||||
} else {
|
} else {
|
||||||
serverUrls = append([]string{loc.Url}, serverUrls...)
|
otherDcServers = append(otherDcServers, loc.Url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rand.Shuffle(len(sameDcServers), func(i, j int) {
|
||||||
|
sameDcServers[i], sameDcServers[j] = sameDcServers[j], sameDcServers[i]
|
||||||
|
})
|
||||||
|
rand.Shuffle(len(otherDcServers), func(i, j int) {
|
||||||
|
otherDcServers[i], otherDcServers[j] = otherDcServers[j], otherDcServers[i]
|
||||||
|
})
|
||||||
|
serverUrls = append(sameDcServers, otherDcServers...)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user