forked from TrueCloudLab/frostfs-node
[#351] cli: Support copies number parameter in `object put`
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>feature/325-policer_off
parent
079b28fa0f
commit
8da6530f41
|
@ -7,6 +7,7 @@ Changelog for FrostFS Node
|
||||||
- Support impersonate bearer token (#229)
|
- Support impersonate bearer token (#229)
|
||||||
- Change log level on SIGHUP for ir (#125)
|
- Change log level on SIGHUP for ir (#125)
|
||||||
- Reload pprof and metrics on SIGHUP for ir (#125)
|
- Reload pprof and metrics on SIGHUP for ir (#125)
|
||||||
|
- Support copies number parameter in `frostfs-cli object put` (#351)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- `frostfs-cli util locode generate` is now much faster (#309)
|
- `frostfs-cli util locode generate` is now much faster (#309)
|
||||||
|
|
|
@ -329,6 +329,8 @@ func CreateSession(prm CreateSessionPrm) (res CreateSessionRes, err error) {
|
||||||
type PutObjectPrm struct {
|
type PutObjectPrm struct {
|
||||||
commonObjectPrm
|
commonObjectPrm
|
||||||
|
|
||||||
|
copyNum []uint32
|
||||||
|
|
||||||
hdr *object.Object
|
hdr *object.Object
|
||||||
|
|
||||||
rdr io.Reader
|
rdr io.Reader
|
||||||
|
@ -352,6 +354,12 @@ func (x *PutObjectPrm) SetHeaderCallback(f func(*object.Object)) {
|
||||||
x.headerCallback = f
|
x.headerCallback = f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCopiesNumberByVectors sets ordered list of minimal required object copies numbers
|
||||||
|
// per placement vector.
|
||||||
|
func (x *PutObjectPrm) SetCopiesNumberByVectors(copiesNumbers []uint32) {
|
||||||
|
x.copyNum = copiesNumbers
|
||||||
|
}
|
||||||
|
|
||||||
// PutObjectRes groups the resulting values of PutObject operation.
|
// PutObjectRes groups the resulting values of PutObject operation.
|
||||||
type PutObjectRes struct {
|
type PutObjectRes struct {
|
||||||
id oid.ID
|
id oid.ID
|
||||||
|
@ -381,6 +389,7 @@ func PutObject(prm PutObjectPrm) (*PutObjectRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
putPrm.WithXHeaders(prm.xHeaders...)
|
putPrm.WithXHeaders(prm.xHeaders...)
|
||||||
|
putPrm.SetCopiesNumberByVectors(prm.copyNum)
|
||||||
|
|
||||||
wrt, err := prm.cli.ObjectPutInit(context.Background(), putPrm)
|
wrt, err := prm.cli.ObjectPutInit(context.Background(), putPrm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import (
|
||||||
const (
|
const (
|
||||||
noProgressFlag = "no-progress"
|
noProgressFlag = "no-progress"
|
||||||
notificationFlag = "notify"
|
notificationFlag = "notify"
|
||||||
|
copiesNumberFlag = "copies-number"
|
||||||
)
|
)
|
||||||
|
|
||||||
var putExpiredOn uint64
|
var putExpiredOn uint64
|
||||||
|
@ -56,6 +57,8 @@ func initObjectPutCmd() {
|
||||||
|
|
||||||
flags.String(notificationFlag, "", "Object notification in the form of *epoch*:*topic*; '-' topic means using default")
|
flags.String(notificationFlag, "", "Object notification in the form of *epoch*:*topic*; '-' topic means using default")
|
||||||
flags.Bool(binaryFlag, false, "Deserialize object structure from given file.")
|
flags.Bool(binaryFlag, false, "Deserialize object structure from given file.")
|
||||||
|
|
||||||
|
flags.String(copiesNumberFlag, "", "Number of copies of the object to store within the RPC call")
|
||||||
}
|
}
|
||||||
|
|
||||||
func putObject(cmd *cobra.Command, _ []string) {
|
func putObject(cmd *cobra.Command, _ []string) {
|
||||||
|
@ -116,6 +119,18 @@ func putObject(cmd *cobra.Command, _ []string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
copyNum, err := cmd.Flags().GetString(copiesNumberFlag)
|
||||||
|
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
|
||||||
|
if len(copyNum) > 0 {
|
||||||
|
var cn []uint32
|
||||||
|
for _, num := range strings.Split(copyNum, ",") {
|
||||||
|
val, err := strconv.ParseUint(num, 10, 32)
|
||||||
|
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
|
||||||
|
cn = append(cn, uint32(val))
|
||||||
|
}
|
||||||
|
prm.SetCopiesNumberByVectors(cn)
|
||||||
|
}
|
||||||
|
|
||||||
res, err := internalclient.PutObject(prm)
|
res, err := internalclient.PutObject(prm)
|
||||||
if p != nil {
|
if p != nil {
|
||||||
p.Finish()
|
p.Finish()
|
||||||
|
|
Loading…
Reference in New Issue