chore: execute goimports to format the code (#7983)
* chore: execute goimports to format the code Signed-off-by: promalert <promalert@outlook.com> * goimports -w . --------- Signed-off-by: promalert <promalert@outlook.com> Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -10,6 +9,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
type BackendStorageFile interface {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
. "github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
. "github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -157,7 +157,7 @@ func syscallMode(i os.FileMode) (o uint32) {
|
||||
return
|
||||
}
|
||||
|
||||
//If the bool is set to true then the file is opened with the parameters FILE_ATTRIBUTE_TEMPORARY and
|
||||
// If the bool is set to true then the file is opened with the parameters FILE_ATTRIBUTE_TEMPORARY and
|
||||
// FILE_FLAG_DELETE_ON_CLOSE
|
||||
func OpenFile(name string, flag int, perm os.FileMode, setToTempAndDelete bool) (file *os.File, err error) {
|
||||
r, e := Open(fixLongPath(name), flag|windows.O_CLOEXEC, syscallMode(perm), setToTempAndDelete)
|
||||
|
||||
@@ -7,23 +7,21 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/rclone/rclone/fs/config/configfile"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"io"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
_ "github.com/rclone/rclone/backend/all"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/accounting"
|
||||
"github.com/rclone/rclone/fs/config/configfile"
|
||||
"github.com/rclone/rclone/fs/object"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -2,7 +2,6 @@ package s3_backend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util/version"
|
||||
"sync"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
@@ -11,6 +10,7 @@ import (
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/s3"
|
||||
"github.com/aws/aws-sdk-go/service/s3/s3iface"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util/version"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -2,11 +2,12 @@ package s3_backend
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/s3/s3iface"
|
||||
"github.com/aws/aws-sdk-go/service/s3/s3manager"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ type ShardLocation struct {
|
||||
|
||||
// TopologyNode represents a node in the topology that can hold EC shards
|
||||
type TopologyNode struct {
|
||||
NodeID string
|
||||
DataCenter string
|
||||
Rack string
|
||||
FreeSlots int // Available slots for new shards
|
||||
ShardIDs []int // Shard IDs currently on this node for a specific volume
|
||||
TotalShards int // Total shards on this node (for all volumes)
|
||||
NodeID string
|
||||
DataCenter string
|
||||
Rack string
|
||||
FreeSlots int // Available slots for new shards
|
||||
ShardIDs []int // Shard IDs currently on this node for a specific volume
|
||||
TotalShards int // Total shards on this node (for all volumes)
|
||||
}
|
||||
|
||||
// TopologyAnalysis holds the current shard distribution analysis for a volume
|
||||
@@ -36,9 +36,9 @@ type TopologyAnalysis struct {
|
||||
NodeToShards map[string][]int // NodeID -> list of shard IDs
|
||||
|
||||
// Topology structure
|
||||
DCToRacks map[string][]string // DC -> list of rack IDs
|
||||
RackToNodes map[string][]*TopologyNode // Rack -> list of nodes
|
||||
AllNodes map[string]*TopologyNode // NodeID -> node info
|
||||
DCToRacks map[string][]string // DC -> list of rack IDs
|
||||
RackToNodes map[string][]*TopologyNode // Rack -> list of nodes
|
||||
AllNodes map[string]*TopologyNode // NodeID -> node info
|
||||
|
||||
// Statistics
|
||||
TotalShards int
|
||||
@@ -144,11 +144,11 @@ func (a *TopologyAnalysis) DetailedString() string {
|
||||
|
||||
// TopologyExcess represents a topology level (DC/rack/node) with excess shards
|
||||
type TopologyExcess struct {
|
||||
ID string // DC/rack/node ID
|
||||
Level string // "dc", "rack", or "node"
|
||||
Excess int // Number of excess shards (above target)
|
||||
Shards []int // Shard IDs at this level
|
||||
Nodes []*TopologyNode // Nodes at this level (for finding sources)
|
||||
ID string // DC/rack/node ID
|
||||
Level string // "dc", "rack", or "node"
|
||||
Excess int // Number of excess shards (above target)
|
||||
Shards []int // Shard IDs at this level
|
||||
Nodes []*TopologyNode // Nodes at this level (for finding sources)
|
||||
}
|
||||
|
||||
// CalculateDCExcess returns DCs with more shards than the target
|
||||
@@ -238,4 +238,3 @@ func CalculateUnderservedRacks(analysis *TopologyAnalysis, dc string, targetPerR
|
||||
|
||||
return underserved
|
||||
}
|
||||
|
||||
|
||||
@@ -158,4 +158,3 @@ func ceilDivide(a, b int) int {
|
||||
}
|
||||
return (a + b - 1) / b
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ type RebalancePlan struct {
|
||||
Analysis *TopologyAnalysis
|
||||
|
||||
// Statistics
|
||||
TotalMoves int
|
||||
MovesAcrossDC int
|
||||
TotalMoves int
|
||||
MovesAcrossDC int
|
||||
MovesAcrossRack int
|
||||
MovesWithinRack int
|
||||
}
|
||||
@@ -54,8 +54,8 @@ func (p *RebalancePlan) DetailedString() string {
|
||||
|
||||
// Rebalancer plans shard moves to achieve proportional distribution
|
||||
type Rebalancer struct {
|
||||
ecConfig ECConfig
|
||||
repConfig ReplicationConfig
|
||||
ecConfig ECConfig
|
||||
repConfig ReplicationConfig
|
||||
}
|
||||
|
||||
// NewRebalancer creates a new rebalancer with the given configuration
|
||||
@@ -375,4 +375,3 @@ func (r *Rebalancer) applyMovesToAnalysis(analysis *TopologyAnalysis, moves []Sh
|
||||
// Counts are already updated by the individual planners.
|
||||
// This function is kept for API compatibility and potential future use.
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@ package erasure_coding
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"math/rand"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/klauspost/reedsolomon"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle_map"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package placement
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Helper function to create disk candidates for testing
|
||||
@@ -402,19 +402,19 @@ func TestCalculateIdealDistribution(t *testing.T) {
|
||||
expectedMin int
|
||||
expectedMax int
|
||||
}{
|
||||
{14, 7, 2, 2}, // Even distribution
|
||||
{14, 4, 3, 4}, // Uneven: 14/4 = 3 remainder 2
|
||||
{6, 3, 2, 2}, // Even distribution
|
||||
{7, 3, 2, 3}, // Uneven: 7/3 = 2 remainder 1
|
||||
{10, 0, 0, 10}, // Edge case: no servers
|
||||
{0, 5, 0, 0}, // Edge case: no shards
|
||||
{14, 7, 2, 2}, // Even distribution
|
||||
{14, 4, 3, 4}, // Uneven: 14/4 = 3 remainder 2
|
||||
{6, 3, 2, 2}, // Even distribution
|
||||
{7, 3, 2, 3}, // Uneven: 7/3 = 2 remainder 1
|
||||
{10, 0, 0, 10}, // Edge case: no servers
|
||||
{0, 5, 0, 0}, // Edge case: no shards
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
min, max := CalculateIdealDistribution(tt.totalShards, tt.numServers)
|
||||
if min != tt.expectedMin || max != tt.expectedMax {
|
||||
t.Errorf("CalculateIdealDistribution(%d, %d) = (%d, %d), want (%d, %d)",
|
||||
tt.totalShards, tt.numServers, min, max, tt.expectedMin, tt.expectedMax)
|
||||
tt.totalShards, tt.numServers, min, max, tt.expectedMin, tt.expectedMax)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package needle
|
||||
|
||||
import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"testing"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
)
|
||||
|
||||
func TestParseFileIdFromString(t *testing.T) {
|
||||
|
||||
@@ -2,8 +2,9 @@ package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
"strconv"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
type NeedleId uint64
|
||||
|
||||
@@ -2,7 +2,6 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -10,6 +9,7 @@ import (
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/idx"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
||||
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
|
||||
. "github.com/seaweedfs/seaweedfs/weed/storage/types"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
)
|
||||
|
||||
@@ -2,7 +2,6 @@ package volume_info
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
jsonpb "google.golang.org/protobuf/encoding/protojson"
|
||||
"os"
|
||||
|
||||
"github.com/seaweedfs/seaweedfs/weed/glog"
|
||||
@@ -10,6 +9,7 @@ import (
|
||||
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/rclone_backend"
|
||||
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend"
|
||||
"github.com/seaweedfs/seaweedfs/weed/util"
|
||||
jsonpb "google.golang.org/protobuf/encoding/protojson"
|
||||
)
|
||||
|
||||
// MaybeLoadVolumeInfo load the file data as *volume_server_pb.VolumeInfo, the returned volumeInfo will not be nil
|
||||
|
||||
Reference in New Issue
Block a user