From 5d86b50782159d49bcbbbccb3ebc0e8c91199184 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Wed, 26 Sep 2012 02:29:16 -0700 Subject: [PATCH] fixes --- weed-fs/src/cmd/weed/master.go | 2 +- weed-fs/src/cmd/weed/volume.go | 6 +++++- weed-fs/src/pkg/operation/upload_content.go | 2 ++ weed-fs/src/pkg/storage/needle.go | 1 - 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.go index f65681e48..d866e1580 100644 --- a/weed-fs/src/cmd/weed/master.go +++ b/weed-fs/src/cmd/weed/master.go @@ -83,7 +83,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) { } fid, count, dn, err := topo.PickForWrite(rt, c) if err == nil { - writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "count": count}) + writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl":dn.PublicUrl, "count": count}) } else { writeJson(w, r, map[string]string{"error": err.Error()}) } diff --git a/weed-fs/src/cmd/weed/volume.go b/weed-fs/src/cmd/weed/volume.go index 6a5bd4fc4..9f73df942 100644 --- a/weed-fs/src/cmd/weed/volume.go +++ b/weed-fs/src/cmd/weed/volume.go @@ -30,7 +30,7 @@ var cmdVolume = &Command{ var ( vport = cmdVolume.Flag.Int("port", 8080, "http listen port") volumeFolder = cmdVolume.Flag.String("dir", "/tmp", "directory to store data files") - ip = cmdVolume.Flag.String("ip", "", "ip or server name") + ip = cmdVolume.Flag.String("ip", "localhost", "ip or server name") publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible :") masterNode = cmdVolume.Flag.String("mserver", "localhost:9333", "master server location") vpulse = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats") @@ -228,6 +228,10 @@ func runVolume(cmd *Command, args []string) bool { } perm := fileInfo.Mode().Perm() log.Println("Volume Folder permission:", perm) + + if *publicUrl == "" { + *publicUrl = *ip + ":" + strconv.Itoa(*vport) + } store = storage.NewStore(*vport, *ip, *publicUrl, *volumeFolder, *maxVolumeCount) defer store.Close() diff --git a/weed-fs/src/pkg/operation/upload_content.go b/weed-fs/src/pkg/operation/upload_content.go index 069a9ff4e..e7822d387 100644 --- a/weed-fs/src/pkg/operation/upload_content.go +++ b/weed-fs/src/pkg/operation/upload_content.go @@ -15,6 +15,7 @@ type UploadResult struct { } func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult, error) { + println("uploading to", uploadUrl) body_buf := bytes.NewBufferString("") body_writer := multipart.NewWriter(body_buf) file_writer, err := body_writer.CreateFormFile("file", filename) @@ -31,6 +32,7 @@ func Upload(uploadUrl string, filename string, reader io.Reader) (*UploadResult, return nil, err } var ret UploadResult + println("upload response to", uploadUrl, resp_body) err = json.Unmarshal(resp_body, &ret) if err != nil { panic(err.Error()) diff --git a/weed-fs/src/pkg/storage/needle.go b/weed-fs/src/pkg/storage/needle.go index 49cceb1d6..8f3a26ee6 100644 --- a/weed-fs/src/pkg/storage/needle.go +++ b/weed-fs/src/pkg/storage/needle.go @@ -89,7 +89,6 @@ func (n *Needle) Append(w io.Writer) uint32 { w.Write(n.Data) rest := 8 - ((n.Size + 16 + 4) % 8) util.Uint32toBytes(header[0:4], n.Checksum.Value()) - println("writing checksum", n.Checksum.Value(), "=>", util.BytesToUint32(header[0:4]), "for", n.Id) w.Write(header[0 : rest+4]) return n.Size }