diff --git a/weed/command/filer.go b/weed/command/filer.go index cddad4c0d..279fc3fbb 100644 --- a/weed/command/filer.go +++ b/weed/command/filer.go @@ -31,6 +31,7 @@ type FilerOptions struct { maxMB *int secretKey *string dirListingLimit *int + dataCenter *string } func init() { @@ -47,6 +48,7 @@ func init() { f.maxMB = cmdFiler.Flag.Int("maxMB", 32, "split files larger than the limit") f.secretKey = cmdFiler.Flag.String("secure.secret", "", "secret to encrypt Json Web Token(JWT)") f.dirListingLimit = cmdFiler.Flag.Int("dirListLimit", 1000, "limit sub dir listing size") + f.dataCenter = cmdFiler.Flag.String("dataCenter", "", "write to volumes in this data center") } var cmdFiler = &Command{ @@ -99,6 +101,7 @@ func (fo *FilerOptions) start() { MaxMB: *f.maxMB, SecretKey: *f.secretKey, DirListingLimit: *f.dirListingLimit, + DataCenter: *f.dataCenter, }) if nfs_err != nil { glog.Fatalf("Filer startup error: %v", nfs_err) diff --git a/weed/command/server.go b/weed/command/server.go index 3796a5785..983b3075f 100644 --- a/weed/command/server.go +++ b/weed/command/server.go @@ -110,6 +110,8 @@ func runServer(cmd *Command, args []string) bool { master := *serverIp + ":" + strconv.Itoa(*masterPort) filerOptions.ip = serverIp + filerOptions.dataCenter = serverDataCenter + if *filerOptions.defaultReplicaPlacement == "" { *filerOptions.defaultReplicaPlacement = *masterDefaultReplicaPlacement } diff --git a/weed/server/filer_grpc_server.go b/weed/server/filer_grpc_server.go index f553956cd..183904284 100644 --- a/weed/server/filer_grpc_server.go +++ b/weed/server/filer_grpc_server.go @@ -178,6 +178,7 @@ func (fs *FilerServer) AssignVolume(ctx context.Context, req *filer_pb.AssignVol Replication: req.Replication, Collection: req.Collection, Ttl: ttlStr, + DataCenter: fs.option.DataCenter, }) if err != nil { return nil, fmt.Errorf("assign volume: %v", err) diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index 0e5135763..601790f8a 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -22,6 +22,7 @@ type FilerOption struct { MaxMB int SecretKey string DirListingLimit int + DataCenter string } type FilerServer struct {