diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-11-16 16:30:19 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-16 16:30:19 +0800 |
| commit | 218561c206943d179740a80d8bb21e1f42b35daa (patch) | |
| tree | efabb31545c495648d99d4b2eb7ea7536d17d8e3 /weed/operation/assign_file_id.go | |
| parent | e0d5207ed9ff6350e83497586ac9859d841a711a (diff) | |
| parent | c0d279c54e56882bc0ecdf496ecfcbcfa1c6d6e3 (diff) | |
| download | seaweedfs-218561c206943d179740a80d8bb21e1f42b35daa.tar.xz seaweedfs-218561c206943d179740a80d8bb21e1f42b35daa.zip | |
Merge pull request #37 from chrislusf/master
sync
Diffstat (limited to 'weed/operation/assign_file_id.go')
| -rw-r--r-- | weed/operation/assign_file_id.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go index 893bf516c..16ad04476 100644 --- a/weed/operation/assign_file_id.go +++ b/weed/operation/assign_file_id.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" + "github.com/chrislusf/seaweedfs/weed/storage/needle" "google.golang.org/grpc" "github.com/chrislusf/seaweedfs/weed/pb/master_pb" @@ -101,3 +102,38 @@ func LookupJwt(master string, fileId string) security.EncodedJwt { return security.EncodedJwt(tokenStr) } + +type StorageOption struct { + Replication string + Collection string + DataCenter string + Rack string + TtlSeconds int32 + Fsync bool +} + +func (so *StorageOption) TtlString() string { + return needle.SecondsToTTL(so.TtlSeconds) +} + +func (so *StorageOption) ToAssignRequests(count int) (ar *VolumeAssignRequest, altRequest *VolumeAssignRequest) { + ar = &VolumeAssignRequest{ + Count: uint64(count), + Replication: so.Replication, + Collection: so.Collection, + Ttl: so.TtlString(), + DataCenter: so.DataCenter, + Rack: so.Rack, + } + if so.DataCenter != "" || so.Rack != "" { + altRequest = &VolumeAssignRequest{ + Count: uint64(count), + Replication: so.Replication, + Collection: so.Collection, + Ttl: so.TtlString(), + DataCenter: "", + Rack: "", + } + } + return +} |
