Browse Source

add descriptive error if no free volumes

volume_buffered_writes
Chris Lu 4 years ago
parent
commit
73958e357d
  1. 2
      weed/server/master_grpc_server_volume.go
  2. 2
      weed/server/master_server_handlers.go
  3. 6
      weed/storage/super_block/replica_placement.go
  4. 22
      weed/topology/volume_growth.go

2
weed/server/master_grpc_server_volume.go

@ -77,7 +77,7 @@ func (ms *MasterServer) Assign(ctx context.Context, req *master_pb.AssignRequest
if !ms.Topo.HasWritableVolume(option) { if !ms.Topo.HasWritableVolume(option) {
if ms.Topo.AvailableSpaceFor(option) <= 0 { if ms.Topo.AvailableSpaceFor(option) <= 0 {
return nil, fmt.Errorf("No free volumes left!")
return nil, fmt.Errorf("no free volumes left for "+option.String())
} }
ms.vgLock.Lock() ms.vgLock.Lock()
if !ms.Topo.HasWritableVolume(option) { if !ms.Topo.HasWritableVolume(option) {

2
weed/server/master_server_handlers.go

@ -113,7 +113,7 @@ func (ms *MasterServer) dirAssignHandler(w http.ResponseWriter, r *http.Request)
if !ms.Topo.HasWritableVolume(option) { if !ms.Topo.HasWritableVolume(option) {
if ms.Topo.AvailableSpaceFor(option) <= 0 { if ms.Topo.AvailableSpaceFor(option) <= 0 {
writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left!"})
writeJsonQuiet(w, r, http.StatusNotFound, operation.AssignResult{Error: "No free volumes left for " + option.String()})
return return
} }
ms.vgLock.Lock() ms.vgLock.Lock()

6
weed/storage/super_block/replica_placement.go

@ -6,9 +6,9 @@ import (
) )
type ReplicaPlacement struct { type ReplicaPlacement struct {
SameRackCount int
DiffRackCount int
DiffDataCenterCount int
SameRackCount int `json:"node,omitempty"`
DiffRackCount int `json:"rack,omitempty"`
DiffDataCenterCount int `json:"dc,omitempty"`
} }
func NewReplicaPlacementFromString(t string) (*ReplicaPlacement, error) { func NewReplicaPlacementFromString(t string) (*ReplicaPlacement, error) {

22
weed/topology/volume_growth.go

@ -1,6 +1,7 @@
package topology package topology
import ( import (
"encoding/json"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/storage/types" "github.com/chrislusf/seaweedfs/weed/storage/types"
"math/rand" "math/rand"
@ -25,15 +26,15 @@ This package is created to resolve these replica placement issues:
*/ */
type VolumeGrowOption struct { type VolumeGrowOption struct {
Collection string
ReplicaPlacement *super_block.ReplicaPlacement
Ttl *needle.TTL
DiskType types.DiskType
Prealloacte int64
DataCenter string
Rack string
DataNode string
MemoryMapMaxSizeMb uint32
Collection string `json:"collection,omitempty"`
ReplicaPlacement *super_block.ReplicaPlacement `json:"replication,omitempty"`
Ttl *needle.TTL `json:"ttl,omitempty"`
DiskType types.DiskType `json:"disk,omitempty"`
Prealloacte int64 `json:"prealloacte,omitempty"`
DataCenter string `json:"dataCenter,omitempty"`
Rack string `json:"rack,omitempty"`
DataNode string `json:"dataNode,omitempty"`
MemoryMapMaxSizeMb uint32 `json:"memoryMapMaxSizeMb,omitempty"`
} }
type VolumeGrowth struct { type VolumeGrowth struct {
@ -41,7 +42,8 @@ type VolumeGrowth struct {
} }
func (o *VolumeGrowOption) String() string { func (o *VolumeGrowOption) String() string {
return fmt.Sprintf("Collection:%s, ReplicaPlacement:%v, Ttl:%v, DataCenter:%s, Rack:%s, DataNode:%s", o.Collection, o.ReplicaPlacement, o.Ttl, o.DataCenter, o.Rack, o.DataNode)
blob, _ := json.Marshal(o)
return string(blob)
} }
func NewDefaultVolumeGrowth() *VolumeGrowth { func NewDefaultVolumeGrowth() *VolumeGrowth {

Loading…
Cancel
Save