aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-10-15 00:40:46 -0700
committerChris Lu <chris.lu@gmail.com>2018-10-15 00:40:46 -0700
commitb423bb9e2def089f57406ce8476c08f3de8436e9 (patch)
treecfca3252fd667a57f39af5f16190db7576c1ad95 /weed/server
parent333709657cb9360d112ce681e2275abd22961087 (diff)
downloadseaweedfs-b423bb9e2def089f57406ce8476c08f3de8436e9.tar.xz
seaweedfs-b423bb9e2def089f57406ce8476c08f3de8436e9.zip
migrate assign volume to grpc API on volume server
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/master_server_handlers_admin.go3
-rw-r--r--weed/server/volume_grpc_admin.go28
-rw-r--r--weed/server/volume_server.go1
-rw-r--r--weed/server/volume_server_handlers_admin.go31
4 files changed, 29 insertions, 34 deletions
diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.go
index 99da2c603..490693d97 100644
--- a/weed/server/master_server_handlers_admin.go
+++ b/weed/server/master_server_handlers_admin.go
@@ -23,8 +23,7 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R
return
}
for _, server := range collection.ListVolumeServers() {
- serverAddress := fmt.Sprintf("%s:%d", server.Ip, server.Port)
- err := operation.WithVolumeServerClient(serverAddress, func(client volume_server_pb.VolumeServerClient) error {
+ err := operation.WithVolumeServerClient(server.Url(), func(client volume_server_pb.VolumeServerClient) error {
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
Collection: collection.Name,
})
diff --git a/weed/server/volume_grpc_admin.go b/weed/server/volume_grpc_admin.go
index 52a5e1928..af08a38f9 100644
--- a/weed/server/volume_grpc_admin.go
+++ b/weed/server/volume_grpc_admin.go
@@ -5,6 +5,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
+ "github.com/chrislusf/seaweedfs/weed/storage"
)
func (vs *VolumeServer) DeleteCollection(ctx context.Context, req *volume_server_pb.DeleteCollectionRequest) (*volume_server_pb.DeleteCollectionResponse, error) {
@@ -14,7 +15,32 @@ func (vs *VolumeServer) DeleteCollection(ctx context.Context, req *volume_server
err := vs.store.DeleteCollection(req.Collection)
if err != nil {
- glog.V(3).Infof("delete collection %s: %v", req.Collection, err)
+ glog.Errorf("delete collection %s: %v", req.Collection, err)
+ } else {
+ glog.V(2).Infof("delete collection %v", req)
+ }
+
+ return resp, err
+
+}
+
+func (vs *VolumeServer) AssignVolume(ctx context.Context, req *volume_server_pb.AssignVolumeRequest) (*volume_server_pb.AssignVolumeResponse, error) {
+
+ resp := &volume_server_pb.AssignVolumeResponse{}
+
+ err := vs.store.AddVolume(
+ storage.VolumeId(req.VolumdId),
+ req.Collection,
+ vs.needleMapKind,
+ req.Replication,
+ req.Ttl,
+ req.Preallocate,
+ )
+
+ if err != nil {
+ glog.Errorf("assign volume %v: %v", req, err)
+ } else {
+ glog.V(2).Infof("assign volume %v", req)
}
return resp, err
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go
index 64eeb0d79..59874d51c 100644
--- a/weed/server/volume_server.go
+++ b/weed/server/volume_server.go
@@ -47,7 +47,6 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
handleStaticResources(adminMux)
adminMux.HandleFunc("/ui/index.html", vs.uiStatusHandler)
adminMux.HandleFunc("/status", vs.guard.WhiteList(vs.statusHandler))
- adminMux.HandleFunc("/admin/assign_volume", vs.guard.WhiteList(vs.assignVolumeHandler))
adminMux.HandleFunc("/admin/sync/status", vs.guard.WhiteList(vs.getVolumeSyncStatusHandler))
adminMux.HandleFunc("/admin/sync/index", vs.guard.WhiteList(vs.getVolumeIndexContentHandler))
adminMux.HandleFunc("/admin/sync/data", vs.guard.WhiteList(vs.getVolumeDataContentHandler))
diff --git a/weed/server/volume_server_handlers_admin.go b/weed/server/volume_server_handlers_admin.go
index 4e985f787..091e121cb 100644
--- a/weed/server/volume_server_handlers_admin.go
+++ b/weed/server/volume_server_handlers_admin.go
@@ -4,10 +4,7 @@ import (
"fmt"
"net/http"
"path/filepath"
- "strconv"
-
- "github.com/chrislusf/seaweedfs/weed/glog"
- "github.com/chrislusf/seaweedfs/weed/stats"
+ "github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/util"
)
@@ -19,32 +16,6 @@ func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
writeJsonQuiet(w, r, http.StatusOK, m)
}
-func (vs *VolumeServer) assignVolumeHandler(w http.ResponseWriter, r *http.Request) {
- var err error
- preallocate := int64(0)
- if r.FormValue("preallocate") != "" {
- preallocate, err = strconv.ParseInt(r.FormValue("preallocate"), 10, 64)
- if err != nil {
- glog.V(0).Infof("ignoring invalid int64 value for preallocate = %v", r.FormValue("preallocate"))
- }
- }
- err = vs.store.AddVolume(
- r.FormValue("volume"),
- r.FormValue("collection"),
- vs.needleMapKind,
- r.FormValue("replication"),
- r.FormValue("ttl"),
- preallocate,
- )
- if err == nil {
- writeJsonQuiet(w, r, http.StatusAccepted, map[string]string{"error": ""})
- } else {
- writeJsonError(w, r, http.StatusNotAcceptable, err)
- }
- glog.V(2).Infof("assign volume = %s, collection = %s , replication = %s, error = %v",
- r.FormValue("volume"), r.FormValue("collection"), r.FormValue("replication"), err)
-}
-
func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request) {
m := make(map[string]interface{})
m["Version"] = util.VERSION