Skip to content

Commit

Permalink
The upload-hours parameter supports - as a separator
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijian-pro committed Jan 2, 2025
1 parent c03663e commit c3ce551
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func dataCacheFlags() []cli.Flag {
},
&cli.StringFlag{
Name: "upload-hours",
Usage: "(start,end) hour of a day between which the delayed blocks can be uploaded",
Usage: "(start-end) hour of a day between which the delayed blocks can be uploaded",
},
&cli.StringFlag{
Name: "cache-dir",
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/_common_options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ For metadata cache description and usage, refer to [Kernel metadata cache](../gu
|`--prefetch=1`|prefetch N blocks in parallel (default: 1), see [Client read data cache](../guide/cache.md#client-read-cache)|
|`--writeback`|upload objects in background (default: false), see [Client write data cache](../guide/cache.md#client-write-cache)|
|`--upload-delay=0`|When `--writeback` is enabled, you can use this option to add a delay to object storage upload, default to 0, meaning that upload will begin immediately after write. Different units are supported, including `s` (second), `m` (minute), `h` (hour). If files are deleted during this delay, upload will be skipped entirely, when using JuiceFS for temporary storage, use this option to reduce resource usage. Refer to [Client write data cache](../guide/cache.md#client-write-cache).|
|`--upload-hours` <VersionAdd>1.2</VersionAdd>|When `--writeback` is enabled, data blocks are only uploaded during the specified time of day. The format of the parameter is `<start hour>,<end hour>` (including "start hour", but not including "end hour", "start hour" must be less than or greater than "end hour"), where `<hour>` can range from 0 to 23. For example, `0,6` means that data blocks are only uploaded between 0:00 and 5:59 every day, and `23,3` means that data blocks are only uploaded between 23:00 every day and 2:59 the next day.|
|`--upload-hours` <VersionAdd>1.2</VersionAdd>|When `--writeback` is enabled, data blocks are only uploaded during the specified time of day. The format of the parameter is `<start hour>-<end hour>` (including "start hour", but not including "end hour", "start hour" must be less than or greater than "end hour"), where `<hour>` can range from 0 to 23. For example, `0-6` means that data blocks are only uploaded between 0:00 and 5:59 every day, and `23-3` means that data blocks are only uploaded between 23:00 every day and 2:59 the next day.|
|`--cache-dir=value`|directory paths of local cache, use `:` (Linux, macOS) or `;` (Windows) to separate multiple paths (default: `$HOME/.juicefs/cache` or `/var/jfsCache`), see [Client read data cache](../guide/cache.md#client-read-cache)|
|`--cache-mode value` <VersionAdd>1.1</VersionAdd> |file permissions for cached blocks (default: "0600")|
|`--cache-size=102400`|size of cached object for read in MiB (default: 102400), see [Client read data cache](../guide/cache.md#client-read-cache)|
Expand Down
2 changes: 1 addition & 1 deletion docs/zh_cn/reference/_common_options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
|`--prefetch=1`|并发预读 N 个块 (默认:1)。阅读[「客户端读缓存」](../guide/cache.md#client-read-cache)了解更多。|
|`--writeback`|后台异步上传对象,默认为 false。阅读[「客户端写缓存」](../guide/cache.md#client-write-cache)了解更多。|
|`--upload-delay=0`|启用 `--writeback` 后,可以使用该选项控制数据延迟上传到对象存储,默认为 0 秒,相当于写入后立刻上传。该选项也支持 `s`(秒)、`m`(分)、`h`(时)这些单位。如果在等待的时间内数据被应用删除,则无需再上传到对象存储。如果数据只是临时落盘,可以考虑用该选项节约资源。阅读[「客户端写缓存」](../guide/cache.md#client-write-cache)了解更多。|
|`--upload-hours` <VersionAdd>1.2</VersionAdd>|启用 `--writeback` 后,只在一天中指定的时间段上传数据块。参数的格式为 `<起始小时>,<结束小时>`(含「起始小时」,但是不含「结束小时」,「起始小时」必须小于或者大于「结束小时」),其中 `<小时>` 的取值范围为 0 到 23。例如 `0,6` 表示只在每天 0:00 至 5:59 之间上传数据块、`23,3` 表示只在每天 23:00 至第二天 2:59 之间上传数据块。|
|`--upload-hours` <VersionAdd>1.2</VersionAdd>|启用 `--writeback` 后,只在一天中指定的时间段上传数据块。参数的格式为 `<起始小时>-<结束小时>`(含「起始小时」,但是不含「结束小时」,「起始小时」必须小于或者大于「结束小时」),其中 `<小时>` 的取值范围为 0 到 23。例如 `0-6` 表示只在每天 0:00 至 5:59 之间上传数据块、`23-3` 表示只在每天 23:00 至第二天 2:59 之间上传数据块。|
|`--cache-dir=value`|本地缓存目录路径;使用 `:`(Linux、macOS)或 `;`(Windows)隔离多个路径 (默认:`$HOME/.juicefs/cache``/var/jfsCache`)。阅读[「客户端读缓存」](../guide/cache.md#client-read-cache)了解更多。|
|`--cache-mode value` <VersionAdd>1.1</VersionAdd>|缓存块的文件权限 (默认:"0600")|
|`--cache-size=102400`|缓存对象的总大小;单位为 MiB (默认:102400)。阅读[「客户端读缓存」](../guide/cache.md#client-read-cache)了解更多。|
Expand Down
9 changes: 6 additions & 3 deletions pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,14 @@ func (c *Config) parseHours() (start, end int, err error) {
if c.UploadHours == "" {
return
}
ps := strings.Split(c.UploadHours, ",")
ps := strings.Split(c.UploadHours, "-")
if len(ps) != 2 {
err = errors.New("unexpected number of fields")
return
if ps = strings.Split(c.UploadHours, ","); len(ps) != 2 {
err = errors.New("unexpected number of fields")
return
}
}

if start, err = strconv.Atoi(ps[0]); err != nil {
return
}
Expand Down

0 comments on commit c3ce551

Please sign in to comment.