aboutsummaryrefslogtreecommitdiff
path: root/unmaintained
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2024-08-10 10:01:57 -0700
committerchrislu <chris.lu@gmail.com>2024-08-10 10:01:57 -0700
commit7438648d1cfacd5ca570dd029d1bdb5fd271bd70 (patch)
treecf12b49473be0373cb03d83470ddc75708454171 /unmaintained
parent49893267e978cc3fda00dc991e00099742fb5a9d (diff)
parent63c707f9c1b4dc469ec39c446563c324ce4ccb6f (diff)
downloadseaweedfs-7438648d1cfacd5ca570dd029d1bdb5fd271bd70.tar.xz
seaweedfs-7438648d1cfacd5ca570dd029d1bdb5fd271bd70.zip
Merge branch 'master' into mq
Diffstat (limited to 'unmaintained')
-rw-r--r--unmaintained/change_superblock/change_superblock.go3
-rw-r--r--unmaintained/diff_volume_servers/diff_volume_servers.go6
-rw-r--r--unmaintained/fix_dat/fix_dat.go3
-rw-r--r--unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go11
-rw-r--r--unmaintained/remove_duplicate_fids/remove_duplicate_fids.go2
-rw-r--r--unmaintained/repeated_vacuum/repeated_vacuum.go16
-rw-r--r--unmaintained/s3/presigned_put/presigned_put.go6
-rw-r--r--unmaintained/see_dat/see_dat.go2
-rw-r--r--unmaintained/see_idx/see_idx.go3
-rw-r--r--unmaintained/see_log_entry/see_log_entry.go2
-rw-r--r--unmaintained/see_meta/see_meta.go2
-rw-r--r--unmaintained/stream_read_volume/stream_read_volume.go4
-rw-r--r--unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go18
-rw-r--r--unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go17
-rw-r--r--unmaintained/volume_tailer/volume_tailer.go4
15 files changed, 71 insertions, 28 deletions
diff --git a/unmaintained/change_superblock/change_superblock.go b/unmaintained/change_superblock/change_superblock.go
index 27876272c..52368f8cd 100644
--- a/unmaintained/change_superblock/change_superblock.go
+++ b/unmaintained/change_superblock/change_superblock.go
@@ -11,6 +11,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -40,6 +41,8 @@ that has those volumes.
*/
func main() {
flag.Parse()
+ util_http.NewGlobalHttpClient()
+
fileName := strconv.Itoa(*fixVolumeId)
if *fixVolumeCollection != "" {
fileName = *fixVolumeCollection + "_" + fileName
diff --git a/unmaintained/diff_volume_servers/diff_volume_servers.go b/unmaintained/diff_volume_servers/diff_volume_servers.go
index 698d7dd3b..e289fefe8 100644
--- a/unmaintained/diff_volume_servers/diff_volume_servers.go
+++ b/unmaintained/diff_volume_servers/diff_volume_servers.go
@@ -20,6 +20,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/util"
"google.golang.org/grpc"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -40,8 +41,9 @@ var (
*/
func main() {
flag.Parse()
-
- util.LoadConfiguration("security", false)
+ util_http.InitGlobalHttpClient()
+
+ util.LoadSecurityConfiguration()
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
vid := uint32(*volumeId)
diff --git a/unmaintained/fix_dat/fix_dat.go b/unmaintained/fix_dat/fix_dat.go
index 760fc79ca..164b5b238 100644
--- a/unmaintained/fix_dat/fix_dat.go
+++ b/unmaintained/fix_dat/fix_dat.go
@@ -14,6 +14,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -36,6 +37,8 @@ The .idx has all correct offsets.
*/
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
+
fileName := strconv.Itoa(*fixVolumeId)
if *fixVolumeCollection != "" {
fileName = *fixVolumeCollection + "_" + fileName
diff --git a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go
index eb08e5353..2b63d5d59 100644
--- a/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go
+++ b/unmaintained/load_test/load_test_meta_tail/load_test_meta_tail.go
@@ -10,7 +10,9 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"strconv"
+ "strings"
"time"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -22,8 +24,8 @@ var (
)
func main() {
-
flag.Parse()
+ util_http.InitGlobalHttpClient()
if *isWrite {
startGenerateMetadata()
@@ -79,12 +81,17 @@ func startGenerateMetadata() {
func startSubscribeMetadata(eachEntryFunc func(event *filer_pb.SubscribeMetadataResponse) error) {
+ prefix := *dir
+ if !strings.HasSuffix(prefix, "/") {
+ prefix = prefix + "/"
+ }
+
metadataFollowOption := &pb.MetadataFollowOption{
ClientName: "tail",
ClientId: 0,
ClientEpoch: 0,
SelfSignature: 0,
- PathPrefix: *dir,
+ PathPrefix: prefix,
AdditionalPathPrefixes: nil,
DirectoriesToWatch: nil,
StartTsNs: 0,
diff --git a/unmaintained/remove_duplicate_fids/remove_duplicate_fids.go b/unmaintained/remove_duplicate_fids/remove_duplicate_fids.go
index 354707c81..cfac97432 100644
--- a/unmaintained/remove_duplicate_fids/remove_duplicate_fids.go
+++ b/unmaintained/remove_duplicate_fids/remove_duplicate_fids.go
@@ -11,6 +11,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -71,6 +72,7 @@ func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *needle.Needle, offset in
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
vid := needle.VolumeId(*volumeId)
diff --git a/unmaintained/repeated_vacuum/repeated_vacuum.go b/unmaintained/repeated_vacuum/repeated_vacuum.go
index 893f4a68a..1f89bd902 100644
--- a/unmaintained/repeated_vacuum/repeated_vacuum.go
+++ b/unmaintained/repeated_vacuum/repeated_vacuum.go
@@ -14,6 +14,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/operation"
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -25,8 +26,9 @@ var (
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
- util.LoadConfiguration("security", false)
+ util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
genFile(grpcDialOption, 0)
@@ -34,7 +36,7 @@ func main() {
go func() {
for {
println("vacuum threshold", *garbageThreshold)
- _, _, err := util.Get(fmt.Sprintf("http://%s/vol/vacuum?garbageThreshold=%f", pb.ServerAddress(*master).ToHttpAddress(), *garbageThreshold))
+ _, _, err := util_http.Get(fmt.Sprintf("http://%s/vol/vacuum?garbageThreshold=%f", pb.ServerAddress(*master).ToHttpAddress(), *garbageThreshold))
if err != nil {
log.Fatalf("vacuum: %v", err)
}
@@ -47,7 +49,7 @@ func main() {
assignResult, targetUrl := genFile(grpcDialOption, i)
- util.Delete(targetUrl, string(assignResult.Auth))
+ util_http.Delete(targetUrl, string(assignResult.Auth))
}
@@ -76,7 +78,13 @@ func genFile(grpcDialOption grpc.DialOption, i int) (*operation.AssignResult, st
PairMap: nil,
Jwt: assignResult.Auth,
}
- _, err = operation.UploadData(data, uploadOption)
+
+ uploader, err := operation.NewUploader()
+ if err != nil {
+ log.Fatalf("upload: %v", err)
+ }
+
+ _, err = uploader.UploadData(data, uploadOption)
if err != nil {
log.Fatalf("upload: %v", err)
}
diff --git a/unmaintained/s3/presigned_put/presigned_put.go b/unmaintained/s3/presigned_put/presigned_put.go
index ba135ff25..1e591dff2 100644
--- a/unmaintained/s3/presigned_put/presigned_put.go
+++ b/unmaintained/s3/presigned_put/presigned_put.go
@@ -7,10 +7,10 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
- "github.com/seaweedfs/seaweedfs/weed/util"
"net/http"
"strings"
"time"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
// Downloads an item from an S3 Bucket in the region configured in the shared config
@@ -21,6 +21,8 @@ import (
// For this exampl to work, the domainName is needd
// weed s3 -domainName=localhost
func main() {
+ util_http.InitGlobalHttpClient()
+
h := md5.New()
content := strings.NewReader(stringContent)
content.WriteTo(h)
@@ -64,7 +66,7 @@ func main() {
fmt.Printf("error put request: %v\n", err)
return
}
- defer util.CloseResponse(resp)
+ defer util_http.CloseResponse(resp)
fmt.Printf("response: %+v\n", resp)
}
diff --git a/unmaintained/see_dat/see_dat.go b/unmaintained/see_dat/see_dat.go
index 1b2f0bb6a..a60e45760 100644
--- a/unmaintained/see_dat/see_dat.go
+++ b/unmaintained/see_dat/see_dat.go
@@ -10,6 +10,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/super_block"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -40,6 +41,7 @@ func (scanner *VolumeFileScanner4SeeDat) VisitNeedle(n *needle.Needle, offset in
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
vid := needle.VolumeId(*volumeId)
diff --git a/unmaintained/see_idx/see_idx.go b/unmaintained/see_idx/see_idx.go
index 856d96d54..87f00ebb0 100644
--- a/unmaintained/see_idx/see_idx.go
+++ b/unmaintained/see_idx/see_idx.go
@@ -12,6 +12,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/storage/idx"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -27,6 +28,8 @@ This is to see content in .idx files.
*/
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
+
fileName := strconv.Itoa(*fixVolumeId)
if *fixVolumeCollection != "" {
fileName = *fixVolumeCollection + "_" + fileName
diff --git a/unmaintained/see_log_entry/see_log_entry.go b/unmaintained/see_log_entry/see_log_entry.go
index d5deff283..42a63476b 100644
--- a/unmaintained/see_log_entry/see_log_entry.go
+++ b/unmaintained/see_log_entry/see_log_entry.go
@@ -12,6 +12,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/filer"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -20,6 +21,7 @@ var (
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
dst, err := os.OpenFile(*logdataFile, os.O_RDONLY, 0644)
if err != nil {
diff --git a/unmaintained/see_meta/see_meta.go b/unmaintained/see_meta/see_meta.go
index 6fc88358c..da78f0918 100644
--- a/unmaintained/see_meta/see_meta.go
+++ b/unmaintained/see_meta/see_meta.go
@@ -11,6 +11,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -19,6 +20,7 @@ var (
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
dst, err := os.OpenFile(*metaFile, os.O_RDONLY, 0644)
if err != nil {
diff --git a/unmaintained/stream_read_volume/stream_read_volume.go b/unmaintained/stream_read_volume/stream_read_volume.go
index cdbfa2c44..cfdb36815 100644
--- a/unmaintained/stream_read_volume/stream_read_volume.go
+++ b/unmaintained/stream_read_volume/stream_read_volume.go
@@ -13,6 +13,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"google.golang.org/grpc"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -23,8 +24,9 @@ var (
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
- util.LoadConfiguration("security", false)
+ util.LoadSecurityConfiguration()
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
vid := uint32(*volumeId)
diff --git a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go
index 1767b04b2..6dc703dbc 100644
--- a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go
+++ b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go
@@ -13,6 +13,7 @@ import (
"strings"
"sync"
"time"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -30,8 +31,8 @@ type stat struct {
}
func main() {
-
flag.Parse()
+ util_http.InitGlobalHttpClient()
data := make([]byte, *size)
println("data len", len(data))
@@ -43,16 +44,12 @@ func main() {
go func(x int) {
defer wg.Done()
- client := &http.Client{Transport: &http.Transport{
- MaxIdleConns: 1024,
- MaxIdleConnsPerHost: 1024,
- }}
r := rand.New(rand.NewSource(time.Now().UnixNano() + int64(x)))
for t := 0; t < *times; t++ {
for f := 0; f < *fileCount; f++ {
fn := r.Intn(*fileCount)
- if size, err := uploadFileToFiler(client, data, fmt.Sprintf("file%04d", fn), *destination); err == nil {
+ if size, err := uploadFileToFiler(data, fmt.Sprintf("file%04d", fn), *destination); err == nil {
statsChan <- stat{
size: size,
}
@@ -93,7 +90,7 @@ func main() {
}
-func uploadFileToFiler(client *http.Client, data []byte, filename, destination string) (size int64, err error) {
+func uploadFileToFiler(data []byte, filename, destination string) (size int64, err error) {
if !strings.HasSuffix(destination, "/") {
destination = destination + "/"
@@ -115,11 +112,14 @@ func uploadFileToFiler(client *http.Client, data []byte, filename, destination s
uri := destination + filename
- request, err := http.NewRequest("POST", uri, body)
+ request, err := http.NewRequest(http.MethodPost, uri, body)
+ if err != nil {
+ return 0, fmt.Errorf("http POST %s: %v", uri, err)
+ }
request.Header.Set("Content-Type", writer.FormDataContentType())
// request.Close = true // can not use this, which do not reuse http connection, impacting filer->volume also.
- resp, err := client.Do(request)
+ resp, err := util_http.GetGlobalHttpClient().Do(request)
if err != nil {
return 0, fmt.Errorf("http POST %s: %v", uri, err)
} else {
diff --git a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go
index afcd51917..1cdcad0b3 100644
--- a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go
+++ b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go
@@ -14,6 +14,7 @@ import (
"strings"
"sync"
"time"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -30,8 +31,8 @@ type stat struct {
}
func main() {
-
flag.Parse()
+ util_http.InitGlobalHttpClient()
var fileNames []string
@@ -51,8 +52,6 @@ func main() {
for x := 0; x < *concurrency; x++ {
wg.Add(1)
- client := &http.Client{}
-
go func() {
defer wg.Done()
rand.Shuffle(len(fileNames), func(i, j int) {
@@ -60,7 +59,7 @@ func main() {
})
for t := 0; t < *times; t++ {
for _, filename := range fileNames {
- if size, err := uploadFileToFiler(client, filename, *destination); err == nil {
+ if size, err := uploadFileToFiler(filename, *destination); err == nil {
statsChan <- stat{
size: size,
}
@@ -99,7 +98,7 @@ func main() {
}
-func uploadFileToFiler(client *http.Client, filename, destination string) (size int64, err error) {
+func uploadFileToFiler(filename, destination string) (size int64, err error) {
file, err := os.Open(filename)
if err != nil {
panic(err)
@@ -130,10 +129,14 @@ func uploadFileToFiler(client *http.Client, filename, destination string) (size
uri := destination + file.Name()
- request, err := http.NewRequest("POST", uri, body)
+ request, err := http.NewRequest(http.MethodPost, uri, body)
+ if err != nil {
+ return 0, fmt.Errorf("http POST %s: %v", uri, err)
+ }
+
request.Header.Set("Content-Type", writer.FormDataContentType())
- resp, err := client.Do(request)
+ resp, err := util_http.GetGlobalHttpClient().Do(request)
if err != nil {
return 0, fmt.Errorf("http POST %s: %v", uri, err)
} else {
diff --git a/unmaintained/volume_tailer/volume_tailer.go b/unmaintained/volume_tailer/volume_tailer.go
index 50ef1c74f..a75a095d4 100644
--- a/unmaintained/volume_tailer/volume_tailer.go
+++ b/unmaintained/volume_tailer/volume_tailer.go
@@ -12,6 +12,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
util2 "github.com/seaweedfs/seaweedfs/weed/util"
"golang.org/x/tools/godoc/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -24,8 +25,9 @@ var (
func main() {
flag.Parse()
+ util_http.InitGlobalHttpClient()
- util2.LoadConfiguration("security", false)
+ util2.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util2.GetViper(), "grpc.client")
vid := needle.VolumeId(*volumeId)