Merge branch 'master' of https://github.com/chrislusf/seaweedfs into gocdk

This commit is contained in:
Jonathan Amsterdam 2019-03-20 16:02:38 -04:00
commit e966033098
27 changed files with 331 additions and 167 deletions

View file

@ -36,6 +36,7 @@ type BenchmarkOptions struct {
read *bool
sequentialRead *bool
collection *string
replication *string
cpuprofile *string
maxCpu *int
grpcDialOption grpc.DialOption
@ -61,6 +62,7 @@ func init() {
b.read = cmdBenchmark.Flag.Bool("read", true, "enable read")
b.sequentialRead = cmdBenchmark.Flag.Bool("readSequentially", false, "randomly read by ids from \"-list\" specified file")
b.collection = cmdBenchmark.Flag.String("collection", "benchmark", "write data to this collection")
b.replication = cmdBenchmark.Flag.String("replication", "000", "replication type")
b.cpuprofile = cmdBenchmark.Flag.String("cpuprofile", "", "cpu profile output file")
b.maxCpu = cmdBenchmark.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
sharedBytes = make([]byte, 1024)
@ -230,6 +232,7 @@ func writeFiles(idChan chan int, fileIdLineChan chan string, s *stat) {
ar := &operation.VolumeAssignRequest{
Count: 1,
Collection: *b.collection,
Replication: *b.replication,
}
if assignResult, err := operation.Assign(masterClient.GetMaster(), b.grpcDialOption, ar); err == nil {
fp.Server, fp.Fid, fp.Collection = assignResult.Url, assignResult.Fid, *b.collection

View file

@ -8,7 +8,6 @@ import (
type MountOptions struct {
filer *string
filerGrpcPort *int
filerMountRootPath *string
dir *string
dirListingLimit *int
@ -29,7 +28,6 @@ var (
func init() {
cmdMount.Run = runMount // break init cycle
mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "weed filer location")
mountOptions.filerGrpcPort = cmdMount.Flag.Int("filer.grpc.port", 0, "filer grpc server listen port, default to http port + 10000")
mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
mountOptions.dirListingLimit = cmdMount.Flag.Int("dirListLimit", 100000, "limit directory listing size")
@ -61,7 +59,7 @@ var cmdMount = &Command{
`,
}
func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress string, err error) {
func parseFilerGrpcAddress(filer string) (filerGrpcAddress string, err error) {
hostnameAndPort := strings.Split(filer, ":")
if len(hostnameAndPort) != 2 {
return "", fmt.Errorf("The filer should have hostname:port format: %v", hostnameAndPort)
@ -73,9 +71,6 @@ func parseFilerGrpcAddress(filer string, optionalGrpcPort int) (filerGrpcAddress
}
filerGrpcPort := int(filerPort) + 10000
if optionalGrpcPort != 0 {
filerGrpcPort = optionalGrpcPort
}
return fmt.Sprintf("%s:%d", hostnameAndPort[0], filerGrpcPort), nil
}

View file

@ -87,7 +87,7 @@ func runMount(cmd *Command, args []string) bool {
c.Close()
})
filerGrpcAddress, err := parseFilerGrpcAddress(*mountOptions.filer, *mountOptions.filerGrpcPort)
filerGrpcAddress, err := parseFilerGrpcAddress(*mountOptions.filer)
if err != nil {
glog.Fatal(err)
return false

View file

@ -51,7 +51,7 @@ func runS3(cmd *Command, args []string) bool {
weed_server.LoadConfiguration("security", false)
filerGrpcAddress, err := parseFilerGrpcAddress(*s3options.filer, *s3options.filerGrpcPort)
filerGrpcAddress, err := parseFilerGrpcAddress(*s3options.filer)
if err != nil {
glog.Fatal(err)
return false

View file

@ -42,7 +42,7 @@ func withMasterServerClient(masterServer string, grpcDialOption grpc.DialOption,
ctx := context.Background()
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(masterServer, 0)
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(masterServer)
if parseErr != nil {
return fmt.Errorf("failed to parse master grpc %v", masterServer)
}

View file

@ -56,6 +56,7 @@ message VolumeInformationMessage {
uint32 replica_placement = 8;
uint32 version = 9;
uint32 ttl = 10;
uint32 compact_revision = 11;
}
message Empty {

View file

@ -190,6 +190,7 @@ type VolumeInformationMessage struct {
ReplicaPlacement uint32 `protobuf:"varint,8,opt,name=replica_placement,json=replicaPlacement" json:"replica_placement,omitempty"`
Version uint32 `protobuf:"varint,9,opt,name=version" json:"version,omitempty"`
Ttl uint32 `protobuf:"varint,10,opt,name=ttl" json:"ttl,omitempty"`
CompactRevision uint32 `protobuf:"varint,11,opt,name=compact_revision,json=compactRevision" json:"compact_revision,omitempty"`
}
func (m *VolumeInformationMessage) Reset() { *m = VolumeInformationMessage{} }
@ -267,6 +268,13 @@ func (m *VolumeInformationMessage) GetTtl() uint32 {
return 0
}
func (m *VolumeInformationMessage) GetCompactRevision() uint32 {
if m != nil {
return m.CompactRevision
}
return 0
}
type Empty struct {
}
@ -1428,93 +1436,94 @@ var _Seaweed_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("master.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 1394 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xd4, 0x58, 0x4b, 0x6f, 0xdb, 0xc6,
0x13, 0x37, 0xa9, 0x87, 0xc5, 0xd1, 0xc3, 0xd2, 0xda, 0x49, 0x18, 0xe5, 0x9f, 0x44, 0x61, 0x2e,
0xfa, 0xbf, 0x8c, 0xd4, 0x3d, 0xf4, 0xd0, 0x16, 0x41, 0xe2, 0x38, 0x68, 0x10, 0xb7, 0x49, 0xe8,
0x24, 0x05, 0x0a, 0x14, 0xea, 0x9a, 0x1c, 0xbb, 0x84, 0x29, 0x92, 0x25, 0x57, 0x8e, 0x95, 0x4b,
0x2f, 0x3d, 0x16, 0xed, 0xa1, 0xdf, 0xa7, 0x97, 0xf6, 0xd6, 0x8f, 0xd2, 0x5b, 0xef, 0x05, 0x8a,
0x7d, 0x90, 0x5a, 0x52, 0xb2, 0x13, 0x14, 0xe8, 0x21, 0xb7, 0xdd, 0x99, 0xd9, 0xdd, 0xe1, 0xef,
0x37, 0x2f, 0x09, 0x3a, 0x53, 0x9a, 0x31, 0x4c, 0xb7, 0x93, 0x34, 0x66, 0x31, 0xb1, 0xe4, 0x6e,
0x92,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c, 0xfc, 0xc5, 0x4f, 0xcb, 0x2d, 0xed,
0x8e, 0x42, 0x3a, 0xfc, 0xd7, 0x2a, 0x69, 0x51, 0xe3, 0xd6, 0xc6, 0xc6, 0x1d, 0x83, 0x3c, 0x85,
0xee, 0x63, 0xc4, 0x64, 0x37, 0x8e, 0x22, 0xf4, 0x18, 0xfa, 0xe4, 0x86, 0x5e, 0x69, 0x97, 0xc7,
0xdc, 0xe1, 0xd5, 0xa5, 0xd2, 0x91, 0x4f, 0x45, 0xea, 0xc6, 0x67, 0xd0, 0xd1, 0xa7, 0xbb, 0xd2,
0x85, 0x2b, 0x66, 0xd1, 0xe1, 0xcd, 0x37, 0x8c, 0x85, 0xce, 0x1a, 0xb9, 0x0b, 0x4d, 0x39, 0x6e,
0x10, 0x5b, 0x33, 0x2e, 0xcd, 0x53, 0x25, 0xbf, 0xca, 0xb3, 0x89, 0xb3, 0x46, 0x1e, 0x03, 0x2c,
0x1a, 0x36, 0xd1, 0x71, 0x59, 0x9a, 0x18, 0x86, 0xd7, 0xcf, 0xd1, 0x16, 0x97, 0x7d, 0x0e, 0xbd,
0x72, 0xeb, 0x22, 0xa3, 0x95, 0xdd, 0x49, 0x8b, 0x88, 0xe1, 0xad, 0x0b, 0x2c, 0x8a, 0x8b, 0xbf,
0x84, 0x7e, 0xb5, 0x23, 0x11, 0x67, 0xe5, 0xc1, 0x52, 0x77, 0x1b, 0xde, 0xbe, 0xd0, 0x46, 0x07,
0x61, 0x11, 0x95, 0x25, 0x10, 0x96, 0x22, 0xb8, 0x04, 0xc2, 0x72, 0x28, 0x3b, 0x6b, 0x87, 0x4d,
0xf1, 0x67, 0xc7, 0xfb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x50, 0x28, 0x66, 0xfc, 0x10,
0x00, 0x00,
// 1416 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xd4, 0x58, 0xc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0xfa, 0x6b, 0xc6, 0x42, 0x6b,
0x8d, 0xdc, 0x81, 0x66, 0x36, 0x6e, 0x10, 0x53, 0x51, 0x2e, 0xcd, 0x53, 0x25, 0xbb, 0xca, 0xb3,
0x89, 0xb5, 0x46, 0x1e, 0x01, 0x2c, 0x1a, 0x36, 0x51, 0x79, 0x59, 0x9a, 0x18, 0x86, 0x57, 0xcf,
0x90, 0x16, 0x87, 0x7d, 0x05, 0xbd, 0x72, 0xeb, 0x22, 0xa3, 0x95, 0xdd, 0x49, 0x89, 0x88, 0xe1,
0x8d, 0x73, 0x34, 0x8a, 0x83, 0xbf, 0x81, 0x7e, 0xb5, 0x23, 0x11, 0x6b, 0xe5, 0xc6, 0x52, 0x77,
0x1b, 0xde, 0x3c, 0x57, 0x47, 0x25, 0x61, 0x11, 0x95, 0x25, 0x12, 0x96, 0x22, 0xb8, 0x44, 0xc2,
0x72, 0x28, 0x5b, 0x6b, 0x87, 0x4d, 0xf1, 0xbf, 0xc8, 0x47, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff,
0x88, 0xac, 0x76, 0x9c, 0x27, 0x11, 0x00, 0x00,
}

View file

@ -238,7 +238,12 @@ func (fs *FilerServer) AssignVolume(ctx context.Context, req *filer_pb.AssignVol
func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.DeleteCollectionRequest) (resp *filer_pb.DeleteCollectionResponse, err error) {
err = fs.filer.MasterClient.CollectionDelete(ctx, req.GetCollection())
err = fs.filer.MasterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
_, err := client.CollectionDelete(ctx, &master_pb.CollectionDeleteRequest{
Name: req.GetCollection(),
})
return err
})
return &filer_pb.DeleteCollectionResponse{}, err
}

View file

@ -52,6 +52,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
if r.Method == "HEAD" {
w.Header().Set("Content-Length", strconv.FormatInt(int64(filer2.TotalSize(entry.Chunks)), 10))
w.Header().Set("Last-Modified", entry.Attr.Mtime.Format(http.TimeFormat))
setEtag(w, filer2.ETag(entry.Chunks))
return
}

View file

@ -19,7 +19,8 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
)
func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *http.Request, replication string, collection string, dataCenter string) bool {
func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *http.Request,
replication string, collection string, dataCenter string) bool {
if r.Method != "POST" {
glog.V(4).Infoln("AutoChunking not supported for method", r.Method)
return false
@ -64,7 +65,8 @@ func (fs *FilerServer) autoChunk(ctx context.Context, w http.ResponseWriter, r *
return true
}
func (fs *FilerServer) doAutoChunk(ctx context.Context, w http.ResponseWriter, r *http.Request, contentLength int64, chunkSize int32, replication string, collection string, dataCenter string) (filerResult *FilerPostResult, replyerr error) {
func (fs *FilerServer) doAutoChunk(ctx context.Context, w http.ResponseWriter, r *http.Request,
contentLength int64, chunkSize int32, replication string, collection string, dataCenter string) (filerResult *FilerPostResult, replyerr error) {
multipartReader, multipartReaderErr := r.MultipartReader()
if multipartReaderErr != nil {
@ -177,8 +179,8 @@ func (fs *FilerServer) doAutoChunk(ctx context.Context, w http.ResponseWriter, r
return
}
func (fs *FilerServer) doUpload(urlLocation string, w http.ResponseWriter, r *http.Request, chunkBuf []byte, fileName string, contentType string, fileId string, auth security.EncodedJwt) (err error) {
err = nil
func (fs *FilerServer) doUpload(urlLocation string, w http.ResponseWriter, r *http.Request,
chunkBuf []byte, fileName string, contentType string, fileId string, auth security.EncodedJwt) (err error) {
ioReader := ioutil.NopCloser(bytes.NewBuffer(chunkBuf))
uploadResult, uploadError := operation.Upload(urlLocation, fileName, ioReader, false, contentType, nil, auth)

View file

@ -61,7 +61,7 @@ func NewRaftServer(grpcDialOption grpc.DialOption, peers []string, serverAddr st
s.raftServer.Start()
for _, peer := range s.peers {
s.raftServer.AddPeer(peer, util.ServerToGrpcAddress(peer, 19333))
s.raftServer.AddPeer(peer, util.ServerToGrpcAddress(peer))
}
s.GrpcServer = raft.NewGrpcServer(s.raftServer)
@ -72,7 +72,7 @@ func NewRaftServer(grpcDialOption grpc.DialOption, peers []string, serverAddr st
_, err := s.raftServer.Do(&raft.DefaultJoinCommand{
Name: s.raftServer.Name(),
ConnectionString: util.ServerToGrpcAddress(s.serverAddr, 19333),
ConnectionString: util.ServerToGrpcAddress(s.serverAddr),
})
if err != nil {

View file

@ -31,7 +31,7 @@ func (vs *VolumeServer) heartbeat() {
if newLeader != "" {
master = newLeader
}
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master, 0)
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master)
if parseErr != nil {
glog.V(0).Infof("failed to parse master grpc %v", masterGrpcAddress)
continue

View file

@ -41,8 +41,7 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
}
ret := operation.UploadResult{}
_, errorStatus := topology.ReplicatedWrite(vs.GetMaster(),
vs.store, volumeId, needle, r)
_, errorStatus := topology.ReplicatedWrite(vs.GetMaster(), vs.store, volumeId, needle, r)
httpStatus := http.StatusCreated
if errorStatus != "" {
httpStatus = http.StatusInternalServerError

View file

@ -3,6 +3,7 @@ package shell
import (
"context"
"fmt"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"io"
)
@ -21,9 +22,14 @@ func (c *commandCollectionList) Help() string {
return "# list all collections"
}
func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer io.Writer) error {
func (c *commandCollectionList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
resp, err := commandEnv.masterClient.CollectionList(context.Background())
var resp *master_pb.CollectionListResponse
ctx := context.Background()
err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
resp, err = client.CollectionList(ctx, &master_pb.CollectionListRequest{})
return err
})
if err != nil {
return err

137
weed/shell/command_fs_du.go Normal file
View file

@ -0,0 +1,137 @@
package shell
import (
"context"
"fmt"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"google.golang.org/grpc"
"io"
"net/url"
"strconv"
"strings"
)
func init() {
commands = append(commands, &commandFsDu{})
}
type commandFsDu struct {
}
func (c *commandFsDu) Name() string {
return "fs.du"
}
func (c *commandFsDu) Help() string {
return "http://<filer_server>:<port>/dir[/file] # show disk usage"
}
func (c *commandFsDu) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
filerServer, filerPort, path, err := parseFilerUrl(args[0])
if err != nil {
return err
}
dir, name := filer2.FullPath(path).DirAndName()
if strings.HasSuffix(path, "/") {
if path == "/"{
dir, name = "/", ""
}else{
dir, name = path[0 : len(path)-1], ""
}
}
ctx := context.Background()
return commandEnv.withFilerClient(ctx, filerServer, filerPort, func(client filer_pb.SeaweedFilerClient) error {
_, _, err = paginateDirectory(ctx, writer, client, dir, name, 1000)
return err
})
}
func paginateDirectory(ctx context.Context, writer io.Writer, client filer_pb.SeaweedFilerClient, dir, name string, paginateSize int) (blockCount uint64, byteCount uint64, err error) {
paginatedCount := -1
startFromFileName := ""
for paginatedCount == -1 || paginatedCount == paginateSize {
resp, listErr := client.ListEntries(ctx, &filer_pb.ListEntriesRequest{
Directory: dir,
Prefix: name,
StartFromFileName: startFromFileName,
InclusiveStartFrom: false,
Limit: uint32(paginateSize),
})
if listErr != nil {
err = listErr
return
}
paginatedCount = len(resp.Entries)
for _, entry := range resp.Entries {
if entry.IsDirectory {
subDir := fmt.Sprintf("%s/%s", dir, entry.Name)
if dir == "/" {
subDir = "/" + entry.Name
}
numBlock, numByte, err := paginateDirectory(ctx, writer, client, subDir, "", paginateSize)
if err == nil {
blockCount += numBlock
byteCount += numByte
}
} else {
blockCount += uint64(len(entry.Chunks))
byteCount += filer2.TotalSize(entry.Chunks)
}
startFromFileName = entry.Name
if name != "" && !entry.IsDirectory {
fmt.Fprintf(writer, "block:%4d\tbyte:%10d\t%s/%s\n", blockCount, byteCount, dir, name)
}
}
}
if name == "" {
fmt.Fprintf(writer, "block:%4d\tbyte:%10d\t%s\n", blockCount, byteCount, dir)
}
return
}
func parseFilerUrl(entryPath string) (filerServer string, filerPort int64, path string, err error) {
if strings.HasPrefix(entryPath, "http") {
var u *url.URL
u, err = url.Parse(entryPath)
if err != nil {
return
}
filerServer = u.Hostname()
portString := u.Port()
if portString != "" {
filerPort, err = strconv.ParseInt(portString, 10, 32)
}
path = u.Path
} else {
err = fmt.Errorf("path should have full url http://<filer_server>:<port>/path/to/dirOrFile : %s", entryPath)
}
return
}
func (env *commandEnv) withFilerClient(ctx context.Context, filerServer string, filerPort int64, fn func(filer_pb.SeaweedFilerClient) error) error {
filerGrpcAddress := fmt.Sprintf("%s:%d", filerServer, filerPort+10000)
return util.WithCachedGrpcClient(ctx, func(grpcConnection *grpc.ClientConn) error {
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
return fn(client)
}, filerGrpcAddress, env.option.GrpcDialOption)
}

View file

@ -22,16 +22,19 @@ func (c *commandVolumeList) Help() string {
return "# list all volumes"
}
func (c *commandVolumeList) Do(args []string, commandEnv *commandEnv, writer io.Writer) error {
resp, err := commandEnv.masterClient.VolumeList(context.Background())
func (c *commandVolumeList) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) {
var resp *master_pb.VolumeListResponse
ctx := context.Background()
err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error {
resp, err = client.VolumeList(ctx, &master_pb.VolumeListRequest{})
return err
})
if err != nil {
return err
}
writeTopologyInfo(writer, resp.TopologyInfo)
return nil
}

View file

@ -14,6 +14,7 @@ type ShellOptions struct {
type commandEnv struct {
env map[string]string
masterClient *wdclient.MasterClient
option ShellOptions
}
type command interface {

View file

@ -36,6 +36,7 @@ func RunShell(options ShellOptions) {
env: make(map[string]string),
masterClient: wdclient.NewMasterClient(context.Background(),
options.GrpcDialOption, "shell", strings.Split(*options.Masters, ",")),
option: options,
}
go commandEnv.masterClient.KeepConnectedToMaster()

View file

@ -182,10 +182,10 @@ func (n *Needle) ReadData(r *os.File, offset int64, size uint32, version Version
case Version1:
n.Data = bytes[NeedleEntrySize : NeedleEntrySize+size]
case Version2, Version3:
n.readNeedleDataVersion2(bytes[NeedleEntrySize : NeedleEntrySize+int(n.Size)])
err = n.readNeedleDataVersion2(bytes[NeedleEntrySize : NeedleEntrySize+int(n.Size)])
}
if size == 0 {
return nil
if size == 0 || err != nil {
return err
}
checksum := util.BytesToUint32(bytes[NeedleEntrySize+size : NeedleEntrySize+size+NeedleChecksumSize])
newChecksum := NewCRC(n.Data)
@ -206,15 +206,13 @@ func (n *Needle) ParseNeedleHeader(bytes []byte) {
n.Size = util.BytesToUint32(bytes[CookieSize+NeedleIdSize : NeedleEntrySize])
}
func (n *Needle) readNeedleDataVersion2(bytes []byte) {
func (n *Needle) readNeedleDataVersion2(bytes []byte) (err error) {
index, lenBytes := 0, len(bytes)
if index < lenBytes {
n.DataSize = util.BytesToUint32(bytes[index : index+4])
index = index + 4
if int(n.DataSize)+index > lenBytes {
// this if clause is due to bug #87 and #93, fixed in v0.69
// remove this clause later
return
return fmt.Errorf("index out of range %d", 1)
}
n.Data = bytes[index : index+int(n.DataSize)]
index = index + int(n.DataSize)
@ -224,30 +222,49 @@ func (n *Needle) readNeedleDataVersion2(bytes []byte) {
if index < lenBytes && n.HasName() {
n.NameSize = uint8(bytes[index])
index = index + 1
if int(n.NameSize)+index > lenBytes {
return fmt.Errorf("index out of range %d", 2)
}
n.Name = bytes[index : index+int(n.NameSize)]
index = index + int(n.NameSize)
}
if index < lenBytes && n.HasMime() {
n.MimeSize = uint8(bytes[index])
index = index + 1
if int(n.MimeSize)+index > lenBytes {
return fmt.Errorf("index out of range %d", 3)
}
n.Mime = bytes[index : index+int(n.MimeSize)]
index = index + int(n.MimeSize)
}
if index < lenBytes && n.HasLastModifiedDate() {
if LastModifiedBytesLength+index > lenBytes {
return fmt.Errorf("index out of range %d", 4)
}
n.LastModified = util.BytesToUint64(bytes[index : index+LastModifiedBytesLength])
index = index + LastModifiedBytesLength
}
if index < lenBytes && n.HasTtl() {
if TtlBytesLength+index > lenBytes {
return fmt.Errorf("index out of range %d", 5)
}
n.Ttl = LoadTTLFromBytes(bytes[index : index+TtlBytesLength])
index = index + TtlBytesLength
}
if index < lenBytes && n.HasPairs() {
if 2+index > lenBytes {
return fmt.Errorf("index out of range %d", 6)
}
n.PairsSize = util.BytesToUint16(bytes[index : index+2])
index += 2
if int(n.PairsSize)+index > lenBytes {
return fmt.Errorf("index out of range %d", 7)
}
end := index + int(n.PairsSize)
n.Pairs = bytes[index:end]
index = end
}
return nil
}
func ReadNeedleHeader(r *os.File, version Version, offset int64) (n *Needle, bodyLength int64, err error) {
@ -300,11 +317,11 @@ func (n *Needle) ReadNeedleBody(r *os.File, version Version, offset int64, bodyL
if _, err = r.ReadAt(bytes, offset); err != nil {
return
}
n.readNeedleDataVersion2(bytes[0:n.Size])
err = n.readNeedleDataVersion2(bytes[0:n.Size])
n.Checksum = NewCRC(n.Data)
if version == Version3 {
tsOffset := n.Size+NeedleChecksumSize
tsOffset := n.Size + NeedleChecksumSize
n.AppendAtNs = util.BytesToUint64(bytes[tsOffset : tsOffset+TimestampSize])
}
default:

View file

@ -121,7 +121,9 @@ func (s *Store) Status() []*VolumeInfo {
DeleteCount: v.nm.DeletedCount(),
DeletedByteCount: v.nm.DeletedSize(),
ReadOnly: v.readOnly,
Ttl: v.Ttl}
Ttl: v.Ttl,
CompactRevision: uint32(v.CompactRevision),
}
stats = append(stats, s)
}
location.RUnlock()

View file

@ -148,5 +148,6 @@ func (v *Volume) ToVolumeInformationMessage() *master_pb.VolumeInformationMessag
ReplicaPlacement: uint32(v.ReplicaPlacement.Byte()),
Version: uint32(v.Version()),
Ttl: v.Ttl.ToUint32(),
CompactRevision: uint32(v.SuperBlock.CompactRevision),
}
}

View file

@ -18,6 +18,7 @@ type VolumeInfo struct {
DeleteCount int
DeletedByteCount uint64
ReadOnly bool
CompactRevision uint32
}
func NewVolumeInfo(m *master_pb.VolumeInformationMessage) (vi VolumeInfo, err error) {
@ -30,6 +31,7 @@ func NewVolumeInfo(m *master_pb.VolumeInformationMessage) (vi VolumeInfo, err er
DeletedByteCount: m.DeletedByteCount,
ReadOnly: m.ReadOnly,
Version: Version(m.Version),
CompactRevision: m.CompactRevision,
}
rp, e := NewReplicaPlacementFromByte(byte(m.ReplicaPlacement))
if e != nil {
@ -57,6 +59,7 @@ func (vi VolumeInfo) ToVolumeInformationMessage() *master_pb.VolumeInformationMe
ReplicaPlacement: uint32(vi.ReplicaPlacement.Byte()),
Version: uint32(vi.Version),
Ttl: vi.Ttl.ToUint32(),
CompactRevision: vi.CompactRevision,
}
}

View file

@ -335,7 +335,10 @@ func (v *Volume) copyDataBasedOnIndexFile(dstName, idxName string) (err error) {
}
n := new(Needle)
n.ReadData(v.dataFile, int64(offset)*NeedlePaddingSize, size, v.Version())
err := n.ReadData(v.dataFile, int64(offset)*NeedlePaddingSize, size, v.Version())
if err != nil {
return nil
}
if n.HasTtl() && now >= n.LastModified+uint64(v.Ttl.Minutes()*60) {
return nil

View file

@ -81,7 +81,7 @@ func WithCachedGrpcClient(ctx context.Context, fn func(*grpc.ClientConn) error,
return err
}
func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAddress string, err error) {
func ParseServerToGrpcAddress(server string) (serverGrpcAddress string, err error) {
hostnameAndPort := strings.Split(server, ":")
if len(hostnameAndPort) != 2 {
return "", fmt.Errorf("server should have hostname:port format: %v", hostnameAndPort)
@ -93,22 +93,19 @@ func ParseServerToGrpcAddress(server string, optionalGrpcPort int) (serverGrpcAd
}
grpcPort := int(port) + 10000
if optionalGrpcPort != 0 {
grpcPort = optionalGrpcPort
}
return fmt.Sprintf("%s:%d", hostnameAndPort[0], grpcPort), nil
}
func ServerToGrpcAddress(server string, defaultGrpcPort int) (serverGrpcAddress string) {
func ServerToGrpcAddress(server string) (serverGrpcAddress string) {
hostnameAndPort := strings.Split(server, ":")
if len(hostnameAndPort) != 2 {
return fmt.Sprintf("%s:%d", server, defaultGrpcPort)
return fmt.Sprintf("unexpected server address: %s", server)
}
port, parseErr := strconv.ParseUint(hostnameAndPort[1], 10, 64)
if parseErr != nil {
return fmt.Sprintf("%s:%d", hostnameAndPort[0], defaultGrpcPort)
return fmt.Sprintf("failed to parse port for %s:%s", hostnameAndPort[0], hostnameAndPort[1])
}
grpcPort := int(port) + 10000

View file

@ -101,7 +101,7 @@ func (mc *MasterClient) tryAllMasters() {
func withMasterClient(ctx context.Context, master string, grpcDialOption grpc.DialOption, fn func(ctx context.Context, client master_pb.SeaweedClient) error) error {
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master, 0)
masterGrpcAddress, parseErr := util.ParseServerToGrpcAddress(master)
if parseErr != nil {
return fmt.Errorf("failed to parse master grpc %v", master)
}
@ -116,3 +116,9 @@ func withMasterClient(ctx context.Context, master string, grpcDialOption grpc.Di
return fn(ctx, client)
}
func (mc *MasterClient) WithClient(ctx context.Context, fn func(client master_pb.SeaweedClient) error) error {
return withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
return fn(client)
})
}

View file

@ -1,31 +0,0 @@
package wdclient
import (
"context"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb"
)
func (mc *MasterClient) CollectionDelete(ctx context.Context, collection string) error {
return withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
_, err := client.CollectionDelete(ctx, &master_pb.CollectionDeleteRequest{
Name: collection,
})
return err
})
}
func (mc *MasterClient) CollectionList(ctx context.Context) (resp *master_pb.CollectionListResponse, err error) {
err = withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
resp, err = client.CollectionList(ctx, &master_pb.CollectionListRequest{})
return err
})
return
}
func (mc *MasterClient) VolumeList(ctx context.Context) (resp *master_pb.VolumeListResponse, err error) {
err = withMasterClient(ctx, mc.currentMaster, mc.grpcDialOption, func(ctx context.Context, client master_pb.SeaweedClient) error {
resp, err = client.VolumeList(ctx, &master_pb.VolumeListRequest{})
return err
})
return
}

View file

@ -7,6 +7,7 @@ import (
"strconv"
"strings"
"sync"
"time"
"github.com/chrislusf/seaweedfs/weed/glog"
)
@ -19,11 +20,13 @@ type Location struct {
type vidMap struct {
sync.RWMutex
vid2Locations map[uint32][]Location
r *rand.Rand
}
func newVidMap() vidMap {
return vidMap{
vid2Locations: make(map[uint32][]Location),
r: rand.New(rand.NewSource(time.Now().UnixNano())),
}
}
@ -39,7 +42,7 @@ func (vc *vidMap) LookupVolumeServerUrl(vid string) (serverUrl string, err error
return "", fmt.Errorf("volume %d not found", id)
}
return locations[rand.Intn(len(locations))].Url, nil
return locations[vc.r.Intn(len(locations))].Url, nil
}
func (vc *vidMap) LookupFileId(fileId string) (fullUrl string, err error) {