aboutsummaryrefslogtreecommitdiff
path: root/weed/command
diff options
context:
space:
mode:
Diffstat (limited to 'weed/command')
-rw-r--r--weed/command/benchmark.go5
-rw-r--r--weed/command/download.go9
-rw-r--r--weed/command/filer_copy.go21
-rw-r--r--weed/command/scaffold/security.toml8
-rw-r--r--weed/command/update.go5
5 files changed, 35 insertions, 13 deletions
diff --git a/weed/command/benchmark.go b/weed/command/benchmark.go
index 0cd9d31c5..bc7ee1292 100644
--- a/weed/command/benchmark.go
+++ b/weed/command/benchmark.go
@@ -22,6 +22,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/seaweedfs/seaweedfs/weed/wdclient"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
type BenchmarkOptions struct {
@@ -214,7 +215,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
if isSecure {
jwtAuthorization = operation.LookupJwt(b.masterClient.GetMaster(context.Background()), b.grpcDialOption, df.fp.Fid)
}
- if e := util.Delete(fmt.Sprintf("http://%s/%s", df.fp.Server, df.fp.Fid), string(jwtAuthorization)); e == nil {
+ if e := util_http.Delete(fmt.Sprintf("http://%s/%s", df.fp.Server, df.fp.Fid), string(jwtAuthorization)); e == nil {
s.completed++
} else {
s.failed++
@@ -295,7 +296,7 @@ func readFiles(fileIdLineChan chan string, s *stat) {
}
var bytes []byte
for _, url := range urls {
- bytes, _, err = util.Get(url)
+ bytes, _, err = util_http.Get(url)
if err == nil {
break
}
diff --git a/weed/command/download.go b/weed/command/download.go
index 1032dcb62..1b7098824 100644
--- a/weed/command/download.go
+++ b/weed/command/download.go
@@ -15,6 +15,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
var (
@@ -63,11 +64,11 @@ func downloadToFile(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOpti
if lookupError != nil {
return lookupError
}
- filename, _, rc, err := util.DownloadFile(fileUrl, jwt)
+ filename, _, rc, err := util_http.DownloadFile(fileUrl, jwt)
if err != nil {
return err
}
- defer util.CloseResponse(rc)
+ defer util_http.CloseResponse(rc)
if filename == "" {
filename = fileId
}
@@ -116,10 +117,10 @@ func fetchContent(masterFn operation.GetMasterFn, grpcDialOption grpc.DialOption
return "", nil, lookupError
}
var rc *http.Response
- if filename, _, rc, e = util.DownloadFile(fileUrl, jwt); e != nil {
+ if filename, _, rc, e = util_http.DownloadFile(fileUrl, jwt); e != nil {
return "", nil, e
}
- defer util.CloseResponse(rc)
+ defer util_http.CloseResponse(rc)
content, e = io.ReadAll(rc.Body)
return
}
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go
index 59cd5491d..8f6cb233e 100644
--- a/weed/command/filer_copy.go
+++ b/weed/command/filer_copy.go
@@ -344,7 +344,12 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
return err
}
- finalFileId, uploadResult, flushErr, _ := operation.UploadWithRetry(
+ uploader, uploaderErr := operation.NewUploader()
+ if uploaderErr != nil {
+ return uploaderErr
+ }
+
+ finalFileId, uploadResult, flushErr, _ := uploader.UploadWithRetry(
worker,
&filer_pb.AssignVolumeRequest{
Count: 1,
@@ -423,7 +428,13 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
<-concurrentChunks
}()
- fileId, uploadResult, err, _ := operation.UploadWithRetry(
+ uploader, err := operation.NewUploader()
+ if err != nil {
+ uploadError = fmt.Errorf("upload data %v: %v\n", fileName, err)
+ return
+ }
+
+ fileId, uploadResult, err, _ := uploader.UploadWithRetry(
worker,
&filer_pb.AssignVolumeRequest{
Count: 1,
@@ -535,8 +546,12 @@ func detectMimeType(f *os.File) string {
}
func (worker *FileCopyWorker) saveDataAsChunk(reader io.Reader, name string, offset int64, tsNs int64) (chunk *filer_pb.FileChunk, err error) {
+ uploader, uploaderErr := operation.NewUploader()
+ if uploaderErr != nil {
+ return nil, fmt.Errorf("upload data: %v", uploaderErr)
+ }
- finalFileId, uploadResult, flushErr, _ := operation.UploadWithRetry(
+ finalFileId, uploadResult, flushErr, _ := uploader.UploadWithRetry(
worker,
&filer_pb.AssignVolumeRequest{
Count: 1,
diff --git a/weed/command/scaffold/security.toml b/weed/command/scaffold/security.toml
index 687854264..113e5b016 100644
--- a/weed/command/scaffold/security.toml
+++ b/weed/command/scaffold/security.toml
@@ -94,10 +94,14 @@ allowed_commonNames = "" # comma-separated SSL certificate common names
[grpc.client]
cert = ""
key = ""
-# Note: work in progress!
-# this does not work with other clients, e.g., "weed filer|mount" etc, yet.
+
+# https client for master|volume|filer|etc connection
+# It is necessary that the parameters [https.volume]|[https.master]|[https.filer] are set
[https.client]
enabled = true
+cert = ""
+key = ""
+ca = ""
# volume server https options
[https.volume]
diff --git a/weed/command/update.go b/weed/command/update.go
index 314a903f2..4f2b66b2e 100644
--- a/weed/command/update.go
+++ b/weed/command/update.go
@@ -21,6 +21,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/util"
"golang.org/x/net/context/ctxhttp"
+ util_http "github.com/seaweedfs/seaweedfs/weed/util/http"
)
//copied from https://github.com/restic/restic/tree/master/internal/selfupdate
@@ -198,7 +199,7 @@ func GitHubLatestRelease(ctx context.Context, ver string, owner, repo string) (R
if err != nil {
return Release{}, err
}
- defer util.CloseResponse(res)
+ defer util_http.CloseResponse(res)
if res.StatusCode != http.StatusOK {
content := res.Header.Get("Content-Type")
@@ -258,7 +259,7 @@ func getGithubData(ctx context.Context, url string) ([]byte, error) {
if err != nil {
return nil, err
}
- defer util.CloseResponse(res)
+ defer util_http.CloseResponse(res)
if res.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status %v (%v) returned", res.StatusCode, res.Status)