Browse Source

增加参数控制调度时是否同时保存到分片存储

master
Sydonian 3 months ago
parent
commit
4992417b04
3 changed files with 14 additions and 10 deletions
  1. +1
    -1
      client/internal/services/user_space.go
  2. +5
    -4
      client/sdk/api/v1/user_space.go
  3. +8
    -5
      jcsctl/cmd/userspace/getp.go

+ 1
- 1
client/internal/services/user_space.go View File

@@ -268,7 +268,7 @@ func (svc *UserSpaceService) DownloadPackage(req cliapi.UserSpaceDownloadPackage
ft.AddTo(ioswitch2.NewToBaseStore(newDstSpace, dstPath).WithRange(math2.NewRange(0, details[dIndex].Object.Size))) ft.AddTo(ioswitch2.NewToBaseStore(newDstSpace, dstPath).WithRange(math2.NewRange(0, details[dIndex].Object.Size)))


// 顺便保存到同存储服务的分片存储中 // 顺便保存到同存储服务的分片存储中
if destSpace.UserSpace.ShardStore != nil {
if req.SaveToShards && destSpace.UserSpace.ShardStore != nil {
ft.AddTo(ioswitch2.NewToShardStore(newDstSpace, ioswitch2.RawStream(), "").WithRange(math2.NewRange(0, details[dIndex].Object.Size))) ft.AddTo(ioswitch2.NewToShardStore(newDstSpace, ioswitch2.RawStream(), "").WithRange(math2.NewRange(0, details[dIndex].Object.Size)))
pinned = append(pinned, jcstypes.PinnedObject{ pinned = append(pinned, jcstypes.PinnedObject{
ObjectID: details[dIndex].Object.ObjectID, ObjectID: details[dIndex].Object.ObjectID,


+ 5
- 4
client/sdk/api/v1/user_space.go View File

@@ -18,10 +18,11 @@ func (c *Client) UserSpace() *UserSpaceService {
const UserSpaceDownloadPackagePath = "/userSpace/downloadPackage" const UserSpaceDownloadPackagePath = "/userSpace/downloadPackage"


type UserSpaceDownloadPackage struct { type UserSpaceDownloadPackage struct {
PackageID jcstypes.PackageID `json:"packageID" binding:"required"`
UserSpaceID jcstypes.UserSpaceID `json:"userSpaceID" binding:"required"`
RootPath string `json:"rootPath"`
Concurrency int `json:"concurrency"`
PackageID jcstypes.PackageID `json:"packageID" binding:"required"`
UserSpaceID jcstypes.UserSpaceID `json:"userSpaceID" binding:"required"`
RootPath string `json:"rootPath"`
Concurrency int `json:"concurrency"`
SaveToShards bool `json:"saveToShards"`
} }


func (r *UserSpaceDownloadPackage) MakeParam() *sdks.RequestParam { func (r *UserSpaceDownloadPackage) MakeParam() *sdks.RequestParam {


+ 8
- 5
jcsctl/cmd/userspace/getp.go View File

@@ -22,11 +22,13 @@ func init() {
}, },
} }
c.Flags().IntVarP(&opt.Concurrency, "concurrency", "c", 5, "concurrency of download files") c.Flags().IntVarP(&opt.Concurrency, "concurrency", "c", 5, "concurrency of download files")
c.Flags().BoolVar(&opt.SaveToShards, "to-shards", false, "save downloaded files to shards")
UserSpaceCmd.AddCommand(c) UserSpaceCmd.AddCommand(c)
} }


type getpOpt struct { type getpOpt struct {
Concurrency int
Concurrency int
SaveToShards bool
} }


func getp(c *cobra.Command, ctx *cmd.CommandContext, opt getpOpt, args []string) error { func getp(c *cobra.Command, ctx *cmd.CommandContext, opt getpOpt, args []string) error {
@@ -62,10 +64,11 @@ func getp(c *cobra.Command, ctx *cmd.CommandContext, opt getpOpt, args []string)
startTime := time.Now() startTime := time.Now()


_, err = ctx.Client.UserSpace().DownloadPackage(cliapi.UserSpaceDownloadPackage{ _, err = ctx.Client.UserSpace().DownloadPackage(cliapi.UserSpaceDownloadPackage{
PackageID: getPkg.Package.PackageID,
UserSpaceID: getSpace.UserSpace.UserSpaceID,
RootPath: rootPath,
Concurrency: opt.Concurrency,
PackageID: getPkg.Package.PackageID,
UserSpaceID: getSpace.UserSpace.UserSpaceID,
RootPath: rootPath,
Concurrency: opt.Concurrency,
SaveToShards: opt.SaveToShards,
}) })
if err != nil { if err != nil {
return fmt.Errorf("download package %v to user space %v: %w", args[0], spaceName, err) return fmt.Errorf("download package %v to user space %v: %w", args[0], spaceName, err)


Loading…
Cancel
Save