Browse Source

needle priting format

pull/693/head
Chris Lu 7 years ago
parent
commit
852af28f91
  1. 4
      weed/server/volume_server_handlers_write.go
  2. 10
      weed/storage/file_id.go
  3. 2
      weed/storage/needle.go

4
weed/server/volume_server_handlers_write.go

@ -9,8 +9,8 @@ import (
"github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/topology" "github.com/chrislusf/seaweedfs/weed/topology"
"time"
"strconv" "strconv"
"time"
) )
func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) { func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
@ -55,7 +55,7 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
volumeId, _ := storage.NewVolumeId(vid) volumeId, _ := storage.NewVolumeId(vid)
n.ParsePath(fid) n.ParsePath(fid)
glog.V(2).Infoln("deleting", n)
glog.V(2).Infof("volume %d deleting %s", vid, n)
cookie := n.Cookie cookie := n.Cookie

10
weed/storage/file_id.go

@ -20,11 +20,15 @@ func NewFileId(VolumeId VolumeId, key uint64, cookie uint32) *FileId {
} }
func (n *FileId) String() string { func (n *FileId) String() string {
return n.VolumeId.String() + "," + formatNeedleIdCookie(n.Key, n.Cookie)
}
func formatNeedleIdCookie(key NeedleId, cookie Cookie) string {
bytes := make([]byte, NeedleIdSize+CookieSize) bytes := make([]byte, NeedleIdSize+CookieSize)
NeedleIdToBytes(bytes[0:NeedleIdSize], n.Key)
CookieToBytes(bytes[NeedleIdSize:NeedleIdSize+CookieSize], n.Cookie)
NeedleIdToBytes(bytes[0:NeedleIdSize], key)
CookieToBytes(bytes[NeedleIdSize:NeedleIdSize+CookieSize], cookie)
nonzero_index := 0 nonzero_index := 0
for ; bytes[nonzero_index] == 0; nonzero_index++ { for ; bytes[nonzero_index] == 0; nonzero_index++ {
} }
return n.VolumeId.String() + "," + hex.EncodeToString(bytes[nonzero_index:])
return hex.EncodeToString(bytes[nonzero_index:])
} }

2
weed/storage/needle.go

@ -44,7 +44,7 @@ type Needle struct {
} }
func (n *Needle) String() (str string) { func (n *Needle) String() (str string) {
str = fmt.Sprintf("Cookie:%d, Id:%d, Size:%d, DataSize:%d, Name: %s, Mime: %s", n.Cookie, n.Id, n.Size, n.DataSize, n.Name, n.Mime)
str = fmt.Sprintf("%s Size:%d, DataSize:%d, Name:%s, Mime:%s", formatNeedleIdCookie(n.Id, n.Cookie), n.Size, n.DataSize, n.Name, n.Mime)
return return
} }

Loading…
Cancel
Save