mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
weed mount can request to prioritize to write to a data center
This commit is contained in:
parent
a51aa4c586
commit
842dab07b4
|
@ -8,6 +8,7 @@ type MountOptions struct {
|
|||
replication *string
|
||||
ttlSec *int
|
||||
chunkSizeLimitMB *int
|
||||
dataCenter *string
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -23,6 +24,7 @@ func init() {
|
|||
mountOptions.replication = cmdMount.Flag.String("replication", "000", "replication to create to files")
|
||||
mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
|
||||
mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 16, "local write buffer size, also chunk large files")
|
||||
mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
|
||||
}
|
||||
|
||||
var cmdMount = &Command{
|
||||
|
|
|
@ -122,6 +122,7 @@ func (pages *ContinuousDirtyPages) saveToStorage(ctx context.Context, buf []byte
|
|||
Replication: pages.f.wfs.replication,
|
||||
Collection: pages.f.wfs.collection,
|
||||
TtlSec: pages.f.wfs.ttlSec,
|
||||
DataCenter: pages.f.wfs.dataCenter,
|
||||
}
|
||||
|
||||
resp, err := client.AssignVolume(ctx, request)
|
||||
|
|
|
@ -18,6 +18,7 @@ type WFS struct {
|
|||
replication string
|
||||
ttlSec int32
|
||||
chunkSizeLimit int64
|
||||
dataCenter string
|
||||
|
||||
// contains all open handles
|
||||
handles []*FileHandle
|
||||
|
@ -25,7 +26,7 @@ type WFS struct {
|
|||
pathToHandleLock sync.Mutex
|
||||
}
|
||||
|
||||
func NewSeaweedFileSystem(filerGrpcAddress string, collection string, replication string, ttlSec int32, chunkSizeLimitMB int) *WFS {
|
||||
func NewSeaweedFileSystem(filerGrpcAddress string, collection string, replication string, ttlSec int32, chunkSizeLimitMB int, dataCenter string) *WFS {
|
||||
return &WFS{
|
||||
filerGrpcAddress: filerGrpcAddress,
|
||||
listDirectoryEntriesCache: ccache.New(ccache.Configure().MaxSize(6000).ItemsToPrune(100)),
|
||||
|
@ -33,6 +34,7 @@ func NewSeaweedFileSystem(filerGrpcAddress string, collection string, replicatio
|
|||
replication: replication,
|
||||
ttlSec: ttlSec,
|
||||
chunkSizeLimit: int64(chunkSizeLimitMB) * 1024 * 1024,
|
||||
dataCenter: dataCenter,
|
||||
pathToHandleIndex: make(map[string]int),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,6 +127,7 @@ message AssignVolumeRequest {
|
|||
string collection = 2;
|
||||
string replication = 3;
|
||||
int32 ttl_sec = 4;
|
||||
string data_center = 5;
|
||||
}
|
||||
|
||||
message AssignVolumeResponse {
|
||||
|
|
|
@ -500,6 +500,7 @@ type AssignVolumeRequest struct {
|
|||
Collection string `protobuf:"bytes,2,opt,name=collection" json:"collection,omitempty"`
|
||||
Replication string `protobuf:"bytes,3,opt,name=replication" json:"replication,omitempty"`
|
||||
TtlSec int32 `protobuf:"varint,4,opt,name=ttl_sec,json=ttlSec" json:"ttl_sec,omitempty"`
|
||||
DataCenter string `protobuf:"bytes,5,opt,name=data_center,json=dataCenter" json:"data_center,omitempty"`
|
||||
}
|
||||
|
||||
func (m *AssignVolumeRequest) Reset() { *m = AssignVolumeRequest{} }
|
||||
|
@ -535,6 +536,13 @@ func (m *AssignVolumeRequest) GetTtlSec() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (m *AssignVolumeRequest) GetDataCenter() string {
|
||||
if m != nil {
|
||||
return m.DataCenter
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AssignVolumeResponse struct {
|
||||
FileId string `protobuf:"bytes,1,opt,name=file_id,json=fileId" json:"file_id,omitempty"`
|
||||
Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"`
|
||||
|
@ -979,66 +987,67 @@ var _SeaweedFiler_serviceDesc = grpc.ServiceDesc{
|
|||
func init() { proto.RegisterFile("filer.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 971 bytes of a gzipped FileDescriptorProto
|
||||
// 990 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x56, 0xdd, 0x6e, 0xdc, 0x44,
|
||||
0x14, 0x8e, 0xd7, 0xeb, 0xcd, 0xfa, 0xec, 0xa6, 0xc0, 0x6c, 0x5a, 0xcc, 0x36, 0xa9, 0x16, 0xd3,
|
||||
0xa2, 0x54, 0x48, 0x51, 0x14, 0xb8, 0xa8, 0x40, 0x48, 0x54, 0x4d, 0xa9, 0x2a, 0xa5, 0xaa, 0xe4,
|
||||
0x10, 0x24, 0xae, 0x56, 0x8e, 0x7d, 0x76, 0x19, 0xc5, 0x6b, 0x1b, 0xcf, 0x38, 0x28, 0xdc, 0x22,
|
||||
0x71, 0xc3, 0x05, 0x4f, 0xc1, 0x1b, 0xf0, 0x06, 0xbc, 0x18, 0x9a, 0x1f, 0x7b, 0xc7, 0x6b, 0x6f,
|
||||
0x7f, 0x2e, 0xb8, 0x9b, 0x39, 0x3f, 0xdf, 0xf9, 0x8e, 0x7d, 0xce, 0x67, 0xc3, 0x68, 0x41, 0x13,
|
||||
0x2c, 0x8e, 0xf3, 0x22, 0xe3, 0x19, 0x19, 0xca, 0xcb, 0x3c, 0xbf, 0xf2, 0x5f, 0xc3, 0xfd, 0xf3,
|
||||
0x2c, 0xbb, 0x2e, 0xf3, 0x33, 0x5a, 0x60, 0xc4, 0xb3, 0xe2, 0xf6, 0x79, 0xca, 0x8b, 0xdb, 0x00,
|
||||
0x7f, 0x29, 0x91, 0x71, 0x72, 0x00, 0x6e, 0x5c, 0x39, 0x3c, 0x6b, 0x66, 0x1d, 0xb9, 0xc1, 0xda,
|
||||
0x40, 0x08, 0xf4, 0xd3, 0x70, 0x85, 0x5e, 0x4f, 0x3a, 0xe4, 0xd9, 0x7f, 0x0e, 0x07, 0xdd, 0x80,
|
||||
0x2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 0xf8,
|
||||
0x7f, 0xf6, 0xe0, 0x4e, 0x93, 0x06, 0xb9, 0x0f, 0xae, 0xac, 0x26, 0x11, 0x2c, 0x89, 0x20, 0xa7,
|
||||
0xe9, 0xa2, 0x81, 0xd2, 0x33, 0x50, 0xea, 0x94, 0x55, 0x16, 0xab, 0xa2, 0x7b, 0x2a, 0xe5, 0x55,
|
||||
0x16, 0x23, 0xf9, 0x10, 0xec, 0x92, 0xc6, 0xb2, 0xec, 0x5e, 0x20, 0x8e, 0xc2, 0xb2, 0xa4, 0xb1,
|
||||
0xe7, 0x28, 0xcb, 0x92, 0xca, 0x46, 0xa2, 0x42, 0xe2, 0x0e, 0x54, 0x23, 0xea, 0x26, 0x1a, 0x59,
|
||||
0x09, 0xeb, 0xae, 0x7a, 0x49, 0xe2, 0x4c, 0x66, 0x30, 0x2a, 0x30, 0x4f, 0x68, 0x14, 0x72, 0x9a,
|
||||
0xa5, 0xde, 0x50, 0xba, 0x4c, 0x13, 0x79, 0x00, 0x10, 0x65, 0x49, 0x82, 0x91, 0x0c, 0x70, 0x65,
|
||||
0x80, 0x61, 0x11, 0xcf, 0x93, 0xf3, 0x64, 0xce, 0x30, 0xf2, 0x60, 0x66, 0x1d, 0x39, 0xc1, 0x80,
|
||||
0xf3, 0xe4, 0x02, 0x23, 0x7f, 0x09, 0x9f, 0xbc, 0x40, 0x39, 0x5e, 0xb7, 0xc6, 0x7b, 0xd1, 0xa3,
|
||||
0xd9, 0x35, 0x30, 0x87, 0x00, 0x79, 0x58, 0x60, 0xca, 0xc5, 0xd0, 0xe8, 0x2d, 0x71, 0x95, 0xe5,
|
||||
0x8c, 0x16, 0xe6, 0x8b, 0xb3, 0xcd, 0x17, 0xe7, 0xff, 0x6e, 0xc1, 0xb4, 0xab, 0x92, 0x1e, 0xe8,
|
||||
0xe6, 0xdc, 0x58, 0xef, 0x3e, 0x37, 0xc6, 0x78, 0xf6, 0xde, 0x3a, 0x9e, 0xfe, 0x09, 0xdc, 0x7d,
|
||||
0x81, 0x5c, 0xda, 0xb3, 0x94, 0x63, 0xca, 0xab, 0x56, 0xb7, 0x0d, 0x9c, 0x7f, 0x0a, 0xf7, 0x36,
|
||||
0x33, 0x34, 0x65, 0x0f, 0x76, 0x23, 0x65, 0x92, 0x29, 0xe3, 0xa0, 0xba, 0xfa, 0x3f, 0x01, 0x79,
|
||||
0x56, 0x60, 0xc8, 0xf1, 0x3d, 0x74, 0xa7, 0xd6, 0x90, 0xde, 0x1b, 0x35, 0xe4, 0x2e, 0x4c, 0x1a,
|
||||
0xd0, 0x8a, 0x8b, 0xa8, 0x78, 0x99, 0xc7, 0xff, 0x57, 0xc5, 0x06, 0xb4, 0xae, 0xf8, 0x97, 0x05,
|
||||
0xe4, 0x0c, 0x13, 0x7c, 0xaf, 0x92, 0x1d, 0xe2, 0xda, 0x52, 0x20, 0xbb, 0xad, 0x40, 0x0f, 0xe1,
|
||||
0x8e, 0x08, 0x91, 0xd5, 0xe6, 0x71, 0xc8, 0x43, 0xb9, 0x5a, 0xc3, 0x60, 0x4c, 0x99, 0xa2, 0x70,
|
||||
0x16, 0xf2, 0x50, 0x10, 0x6d, 0x10, 0xd2, 0x44, 0xff, 0xb0, 0x60, 0xf2, 0x94, 0x31, 0xba, 0x4c,
|
||||
0x7f, 0xcc, 0x92, 0x72, 0x85, 0x15, 0xd3, 0x7d, 0x70, 0xa2, 0xac, 0xd4, 0x2f, 0xcf, 0x09, 0xd4,
|
||||
0x65, 0x63, 0x91, 0x7a, 0xad, 0x45, 0xda, 0x58, 0x45, 0xbb, 0xbd, 0x8a, 0xc6, 0xaa, 0xf5, 0x1b,
|
||||
0xab, 0x76, 0x03, 0xfb, 0x4d, 0x1e, 0x7a, 0x8e, 0xb6, 0x6a, 0x9d, 0x90, 0x91, 0x22, 0xd1, 0x24,
|
||||
0xc4, 0x51, 0x2e, 0x5f, 0x79, 0x95, 0xd0, 0x68, 0x2e, 0x1c, 0xb6, 0x5e, 0x3e, 0x69, 0xb9, 0x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xd6, 0xff, 0xc7,
|
||||
0xf4, 0x70, 0x8b, 0xb7, 0x46, 0x0b, 0x81, 0xb4, 0x85, 0x9b, 0x7c, 0xb6, 0x4e, 0xdb, 0xfa, 0x01,
|
||||
0x99, 0x3e, 0x7c, 0x73, 0x90, 0x49, 0xd8, 0x50, 0x35, 0x93, 0x70, 0x5b, 0x47, 0x4d, 0xc2, 0x5d,
|
||||
0x52, 0x28, 0xd1, 0x0c, 0xc5, 0x32, 0xd1, 0xda, 0x1a, 0x69, 0xa2, 0x75, 0xc9, 0x9c, 0x44, 0x33,
|
||||
0x64, 0xc5, 0x44, 0x6b, 0xcb, 0x9f, 0x89, 0xd6, 0xa5, 0x45, 0x3b, 0xe4, 0x35, 0x8c, 0x4d, 0x11,
|
||||
0x20, 0x46, 0x42, 0x87, 0x48, 0x4d, 0x1f, 0x6c, 0x73, 0x9b, 0x80, 0xe6, 0xcc, 0x9b, 0x80, 0x1d,
|
||||
0x5b, 0x6f, 0x02, 0x76, 0xad, 0x8a, 0xbf, 0x73, 0x35, 0x90, 0xbf, 0xd3, 0x5f, 0xfe, 0x17, 0x00,
|
||||
0x00, 0xff, 0xff, 0x00, 0xdc, 0x65, 0x5f, 0x5d, 0x0b, 0x00, 0x00,
|
||||
0x14, 0x8e, 0xd7, 0xbb, 0x9b, 0xf5, 0xd9, 0x4d, 0x81, 0xd9, 0xb4, 0x98, 0x6d, 0x52, 0x96, 0xa1,
|
||||
0x45, 0xa9, 0x90, 0xa2, 0x28, 0x70, 0x51, 0x81, 0x90, 0xa8, 0x92, 0x52, 0x55, 0x4a, 0x55, 0xc9,
|
||||
0x21, 0x48, 0x5c, 0xad, 0x1c, 0xfb, 0x64, 0x19, 0xc5, 0x6b, 0x2f, 0x9e, 0x71, 0x50, 0xb8, 0xe5,
|
||||
0x92, 0x0b, 0x9e, 0x02, 0xf1, 0x02, 0xbc, 0x01, 0x2f, 0x86, 0xe6, 0xc7, 0xde, 0xf1, 0xda, 0xdb,
|
||||
0x9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, 0xd2,
|
||||
0x17, 0x98, 0x10, 0xf2, 0x04, 0x20, 0x14, 0x22, 0x67, 0x97, 0x85, 0x40, 0xee, 0x77, 0xd5, 0xf3,
|
||||
0xf0, 0xad, 0x84, 0x82, 0xe3, 0xd3, 0xca, 0x1f, 0x58, 0xb1, 0xf4, 0x0a, 0xbc, 0x0a, 0x8e, 0x7c,
|
||||
0x0c, 0xdb, 0x32, 0x67, 0xc6, 0x62, 0xc3, 0xb6, 0x2f, 0xaf, 0x2f, 0x62, 0x72, 0x0f, 0xfa, 0xd9,
|
||||
0xd5, 0x15, 0x47, 0xa1, 0x98, 0xba, 0x81, 0xb9, 0xc9, 0xde, 0x38, 0xfb, 0x1d, 0x7d, 0x77, 0xea,
|
||||
0x1c, 0x74, 0x03, 0x75, 0x26, 0xbb, 0xd0, 0x5b, 0x08, 0xb6, 0x40, 0x45, 0xc3, 0x0d, 0xf4, 0x85,
|
||||
0xfe, 0xd9, 0x81, 0x3b, 0x75, 0x1a, 0xe4, 0x3e, 0x78, 0xaa, 0x9a, 0x42, 0x70, 0x14, 0x82, 0x9a,
|
||||
0xa6, 0xf3, 0x1a, 0x4a, 0xc7, 0x42, 0xa9, 0x52, 0x16, 0x59, 0xac, 0x8b, 0xee, 0xe8, 0x94, 0x97,
|
||||
0x59, 0x8c, 0xe4, 0x43, 0x70, 0x0b, 0x16, 0xab, 0xb2, 0x3b, 0x81, 0x3c, 0x4a, 0xcb, 0x9c, 0xc5,
|
||||
0x7e, 0x4f, 0x5b, 0xe6, 0x4c, 0x35, 0x12, 0xe5, 0x0a, 0xb7, 0xaf, 0x1b, 0xd1, 0x37, 0xd9, 0xc8,
|
||||
0x42, 0x5a, 0xb7, 0xf5, 0x4b, 0x92, 0x67, 0x32, 0x85, 0x61, 0x8e, 0xcb, 0x84, 0x45, 0xa1, 0x60,
|
||||
0x59, 0xea, 0x0f, 0x94, 0xcb, 0x36, 0x91, 0x07, 0x00, 0x51, 0x96, 0x24, 0x18, 0xa9, 0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0xc4, 0xb8, 0xa6, 0x70,
|
||||
0x1a, 0x8a, 0x50, 0x12, 0xad, 0x11, 0x32, 0x44, 0xff, 0x71, 0x60, 0xfc, 0x94, 0x73, 0x36, 0x4f,
|
||||
0x7f, 0xca, 0x92, 0x62, 0x81, 0x25, 0xd3, 0x5d, 0xe8, 0x45, 0x59, 0x61, 0x5e, 0x5e, 0x2f, 0xd0,
|
||||
0x97, 0xb5, 0x45, 0xea, 0x34, 0x16, 0x69, 0x6d, 0x15, 0xdd, 0xe6, 0x2a, 0x5a, 0xab, 0xd6, 0xb5,
|
||||
0x57, 0x8d, 0x7c, 0x0a, 0x43, 0xc9, 0x7d, 0x16, 0x61, 0x2a, 0x30, 0x57, 0x5a, 0xe0, 0x05, 0x20,
|
||||
0x4d, 0x27, 0xca, 0x42, 0x6f, 0x60, 0xb7, 0x4e, 0xd4, 0x0c, 0xda, 0x46, 0x31, 0x94, 0x3a, 0x93,
|
||||
0x27, 0x86, 0xa5, 0x3c, 0xaa, 0xed, 0x2c, 0x2e, 0x13, 0x16, 0xcd, 0xa4, 0xc3, 0x35, 0xdb, 0xa9,
|
||||
0x2c, 0x17, 0x79, 0xb2, 0xea, 0xb9, 0x6b, 0xf5, 0x4c, 0xbf, 0x86, 0xb1, 0xfe, 0xbc, 0xd5, 0x1f,
|
||||
0xd0, 0x3e, 0xc0, 0x8d, 0x32, 0xcc, 0x58, 0xac, 0x3f, 0x33, 0x5e, 0xe0, 0x69, 0xcb, 0x8b, 0x98,
|
||||
0xd3, 0xef, 0xc0, 0x3b, 0xcb, 0x74, 0xcf, 0x9c, 0x1c, 0x81, 0x97, 0x94, 0x17, 0xf3, 0x45, 0x22,
|
||||
0xab, 0x79, 0x2a, 0xe3, 0x82, 0x55, 0x10, 0xfd, 0x16, 0x06, 0xa5, 0xb9, 0xec, 0xc3, 0xd9, 0xd4,
|
||||
0x47, 0x67, 0xad, 0x0f, 0xfa, 0x9f, 0x03, 0xbb, 0x75, 0xca, 0xe6, 0x51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e, 0x6c, 0x72, 0xdb, 0x80, 0xf6, 0xcc,
|
||||
0xdb, 0x80, 0x2d, 0x5b, 0x6f, 0x03, 0xb6, 0xad, 0x0a, 0xdd, 0xba, 0xec, 0xab, 0xff, 0xed, 0xaf,
|
||||
0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x65, 0x12, 0xc7, 0x9d, 0x7e, 0x0b, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -175,14 +175,19 @@ func (fs *FilerServer) AssignVolume(ctx context.Context, req *filer_pb.AssignVol
|
|||
|
||||
var altRequest *operation.VolumeAssignRequest
|
||||
|
||||
dataCenter := req.DataCenter
|
||||
if dataCenter!=""{
|
||||
dataCenter = fs.option.DataCenter
|
||||
}
|
||||
|
||||
assignRequest := &operation.VolumeAssignRequest{
|
||||
Count: uint64(req.Count),
|
||||
Replication: req.Replication,
|
||||
Collection: req.Collection,
|
||||
Ttl: ttlStr,
|
||||
DataCenter: fs.option.DataCenter,
|
||||
DataCenter: dataCenter,
|
||||
}
|
||||
if fs.option.DataCenter != "" {
|
||||
if dataCenter != "" {
|
||||
altRequest = &operation.VolumeAssignRequest{
|
||||
Count: uint64(req.Count),
|
||||
Replication: req.Replication,
|
||||
|
|
|
@ -41,16 +41,16 @@ func (fs *FilerServer) queryFileInfoByPath(w http.ResponseWriter, r *http.Reques
|
|||
return
|
||||
}
|
||||
|
||||
func (fs *FilerServer) assignNewFileInfo(w http.ResponseWriter, r *http.Request, replication, collection string) (fileId, urlLocation string, err error) {
|
||||
func (fs *FilerServer) assignNewFileInfo(w http.ResponseWriter, r *http.Request, replication, collection string, dataCenter string) (fileId, urlLocation string, err error) {
|
||||
ar := &operation.VolumeAssignRequest{
|
||||
Count: 1,
|
||||
Replication: replication,
|
||||
Collection: collection,
|
||||
Ttl: r.URL.Query().Get("ttl"),
|
||||
DataCenter: fs.option.DataCenter,
|
||||
DataCenter: dataCenter,
|
||||
}
|
||||
var altRequest *operation.VolumeAssignRequest
|
||||
if fs.option.DataCenter != "" {
|
||||
if dataCenter != "" {
|
||||
altRequest = &operation.VolumeAssignRequest{
|
||||
Count: 1,
|
||||
Replication: replication,
|
||||
|
@ -82,8 +82,12 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if collection == "" {
|
||||
collection = fs.option.Collection
|
||||
}
|
||||
dataCenter := query.Get("dataCenter")
|
||||
if dataCenter == "" {
|
||||
dataCenter = fs.option.DataCenter
|
||||
}
|
||||
|
||||
if autoChunked := fs.autoChunk(w, r, replication, collection); autoChunked {
|
||||
if autoChunked := fs.autoChunk(w, r, replication, collection, dataCenter); autoChunked {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -91,12 +95,12 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
|
|||
var err error
|
||||
|
||||
if strings.HasPrefix(r.Header.Get("Content-Type"), "multipart/form-data; boundary=") {
|
||||
fileId, urlLocation, err = fs.multipartUploadAnalyzer(w, r, replication, collection)
|
||||
fileId, urlLocation, err = fs.multipartUploadAnalyzer(w, r, replication, collection, dataCenter)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
fileId, urlLocation, err = fs.monolithicUploadAnalyzer(w, r, replication, collection)
|
||||
fileId, urlLocation, err = fs.monolithicUploadAnalyzer(w, r, replication, collection, dataCenter)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
func (fs *FilerServer) autoChunk(w http.ResponseWriter, r *http.Request, replication string, collection string) bool {
|
||||
func (fs *FilerServer) autoChunk(w http.ResponseWriter, r *http.Request, replication string, collection string, dataCenter string) bool {
|
||||
if r.Method != "POST" {
|
||||
glog.V(4).Infoln("AutoChunking not supported for method", r.Method)
|
||||
return false
|
||||
|
@ -52,7 +52,7 @@ func (fs *FilerServer) autoChunk(w http.ResponseWriter, r *http.Request, replica
|
|||
return false
|
||||
}
|
||||
|
||||
reply, err := fs.doAutoChunk(w, r, contentLength, chunkSize, replication, collection)
|
||||
reply, err := fs.doAutoChunk(w, r, contentLength, chunkSize, replication, collection, dataCenter)
|
||||
if err != nil {
|
||||
writeJsonError(w, r, http.StatusInternalServerError, err)
|
||||
} else if reply != nil {
|
||||
|
@ -61,7 +61,7 @@ func (fs *FilerServer) autoChunk(w http.ResponseWriter, r *http.Request, replica
|
|||
return true
|
||||
}
|
||||
|
||||
func (fs *FilerServer) doAutoChunk(w http.ResponseWriter, r *http.Request, contentLength int64, chunkSize int32, replication string, collection string) (filerResult *FilerPostResult, replyerr error) {
|
||||
func (fs *FilerServer) doAutoChunk(w http.ResponseWriter, r *http.Request, contentLength int64, chunkSize int32, replication string, collection string, dataCenter string) (filerResult *FilerPostResult, replyerr error) {
|
||||
|
||||
multipartReader, multipartReaderErr := r.MultipartReader()
|
||||
if multipartReaderErr != nil {
|
||||
|
@ -104,7 +104,7 @@ func (fs *FilerServer) doAutoChunk(w http.ResponseWriter, r *http.Request, conte
|
|||
|
||||
if chunkBufOffset >= chunkSize || readFully || (chunkBufOffset > 0 && bytesRead == 0) {
|
||||
writtenChunks = writtenChunks + 1
|
||||
fileId, urlLocation, assignErr := fs.assignNewFileInfo(w, r, replication, collection)
|
||||
fileId, urlLocation, assignErr := fs.assignNewFileInfo(w, r, replication, collection, dataCenter)
|
||||
if assignErr != nil {
|
||||
return nil, assignErr
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ func checkContentMD5(w http.ResponseWriter, r *http.Request) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (fs *FilerServer) monolithicUploadAnalyzer(w http.ResponseWriter, r *http.Request, replication, collection string) (fileId, urlLocation string, err error) {
|
||||
func (fs *FilerServer) monolithicUploadAnalyzer(w http.ResponseWriter, r *http.Request, replication, collection string, dataCenter string) (fileId, urlLocation string, err error) {
|
||||
/*
|
||||
Amazon S3 ref link:[http://docs.aws.amazon.com/AmazonS3/latest/API/Welcome.html]
|
||||
There is a long way to provide a completely compatibility against all Amazon S3 API, I just made
|
||||
|
@ -104,7 +104,7 @@ func (fs *FilerServer) monolithicUploadAnalyzer(w http.ResponseWriter, r *http.R
|
|||
path := r.URL.Path
|
||||
|
||||
if fileId, urlLocation, err = fs.queryFileInfoByPath(w, r, path); err == nil && fileId == "" {
|
||||
fileId, urlLocation, err = fs.assignNewFileInfo(w, r, replication, collection)
|
||||
fileId, urlLocation, err = fs.assignNewFileInfo(w, r, replication, collection, dataCenter)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/chrislusf/seaweedfs/weed/storage"
|
||||
)
|
||||
|
||||
func (fs *FilerServer) multipartUploadAnalyzer(w http.ResponseWriter, r *http.Request, replication, collection string) (fileId, urlLocation string, err error) {
|
||||
func (fs *FilerServer) multipartUploadAnalyzer(w http.ResponseWriter, r *http.Request, replication, collection string, dataCenter string) (fileId, urlLocation string, err error) {
|
||||
//Default handle way for http multipart
|
||||
if r.Method == "PUT" {
|
||||
buf, _ := ioutil.ReadAll(r.Body)
|
||||
|
@ -33,7 +33,7 @@ func (fs *FilerServer) multipartUploadAnalyzer(w http.ResponseWriter, r *http.Re
|
|||
}
|
||||
fileId, urlLocation, err = fs.queryFileInfoByPath(w, r, path)
|
||||
} else {
|
||||
fileId, urlLocation, err = fs.assignNewFileInfo(w, r, replication, collection)
|
||||
fileId, urlLocation, err = fs.assignNewFileInfo(w, r, replication, collection, dataCenter)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue