aboutsummaryrefslogtreecommitdiff
path: root/weed/operation/assign_file_id.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-11-15 16:58:48 -0800
committerChris Lu <chris.lu@gmail.com>2020-11-15 16:58:48 -0800
commit95c0de285d907cbd826ba6ce97f7c4994c16ffd5 (patch)
tree2ef04241b575b8169bf6b1baa2dd15cda4046be7 /weed/operation/assign_file_id.go
parent500bcab9535835404d29b8f68a03bf2ecf5b2991 (diff)
downloadseaweedfs-95c0de285d907cbd826ba6ce97f7c4994c16ffd5.tar.xz
seaweedfs-95c0de285d907cbd826ba6ce97f7c4994c16ffd5.zip
refactoring
Diffstat (limited to 'weed/operation/assign_file_id.go')
-rw-r--r--weed/operation/assign_file_id.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/weed/operation/assign_file_id.go b/weed/operation/assign_file_id.go
index 893bf516c..c58d3a84d 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,39 @@ 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
+}
+