Konstantin Lebedev
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
10 additions and
2 deletions
-
weed/server/master_grpc_server_assign.go
-
weed/server/master_server_handlers.go
-
weed/topology/volume_layout.go
-
weed/topology/volume_location_list.go
|
@ -97,6 +97,9 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest |
|
|
continue |
|
|
continue |
|
|
} |
|
|
} |
|
|
dn := dnList.Head() |
|
|
dn := dnList.Head() |
|
|
|
|
|
if dn == nil { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
var replicas []*master_pb.Location |
|
|
var replicas []*master_pb.Location |
|
|
for _, r := range dnList.Rest() { |
|
|
for _, r := range dnList.Rest() { |
|
|
replicas = append(replicas, &master_pb.Location{ |
|
|
replicas = append(replicas, &master_pb.Location{ |
|
|
|
@ -149,7 +149,9 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request) |
|
|
} else { |
|
|
} else { |
|
|
ms.maybeAddJwtAuthorization(w, fid, true) |
|
|
ms.maybeAddJwtAuthorization(w, fid, true) |
|
|
dn := dnList.Head() |
|
|
dn := dnList.Head() |
|
|
|
|
|
|
|
|
|
|
|
if dn == nil { |
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count}) |
|
|
writeJsonQuiet(w, r, http.StatusOK, operation.AssignResult{Fid: fid, Url: dn.Url(), PublicUrl: dn.PublicUrl, Count: count}) |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
|
@ -301,7 +301,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi |
|
|
if float64(info.Size) > float64(vl.volumeSizeLimit)*option.Threshold() { |
|
|
if float64(info.Size) > float64(vl.volumeSizeLimit)*option.Threshold() { |
|
|
shouldGrow = true |
|
|
shouldGrow = true |
|
|
} |
|
|
} |
|
|
return vid, count, locationList, shouldGrow, nil |
|
|
|
|
|
|
|
|
return vid, count, locationList.Copy(), shouldGrow, nil |
|
|
} |
|
|
} |
|
|
return 0, 0, nil, shouldGrow, errors.New("Strangely vid " + vid.String() + " is on no machine!") |
|
|
return 0, 0, nil, shouldGrow, errors.New("Strangely vid " + vid.String() + " is on no machine!") |
|
|
} |
|
|
} |
|
|
|
@ -28,6 +28,9 @@ func (dnll *VolumeLocationList) Copy() *VolumeLocationList { |
|
|
|
|
|
|
|
|
func (dnll *VolumeLocationList) Head() *DataNode { |
|
|
func (dnll *VolumeLocationList) Head() *DataNode { |
|
|
//mark first node as master volume
|
|
|
//mark first node as master volume
|
|
|
|
|
|
if dnll.Length() == 0 { |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
return dnll.list[0] |
|
|
return dnll.list[0] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|