Browse Source

go fmt

pull/778/head
Chris Lu 6 years ago
parent
commit
86dd933596
  1. 2
      weed/command/filer_export.go
  2. 10
      weed/filer2/filechunks.go
  3. 19
      weed/filer2/filechunks_test.go
  4. 2
      weed/filer2/filer_deletion.go
  5. 1
      weed/filesys/filehandle.go
  6. 3
      weed/operation/assign_file_id.go
  7. 4
      weed/operation/grpc_client.go
  8. 2
      weed/server/filer_grpc_server.go
  9. 2
      weed/server/master_grpc_server_volume.go
  10. 2
      weed/server/volume_server_handlers_read.go
  11. 4
      weed/storage/crc.go
  12. 2
      weed/storage/volume_read_write.go

2
weed/command/filer_export.go

@ -171,7 +171,7 @@ func printout(level int, entry *filer2.Entry) error {
} }
} }
print(entry.FullPath.Name()) print(entry.FullPath.Name())
if *verboseFilerExport{
if *verboseFilerExport {
for _, chunk := range entry.Chunks { for _, chunk := range entry.Chunks {
print("[") print("[")
print(chunk.FileId) print(chunk.FileId)

10
weed/filer2/filechunks.go

@ -96,10 +96,10 @@ func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views
func logPrintf(name string, visibles []*visibleInterval) { func logPrintf(name string, visibles []*visibleInterval) {
/* /*
log.Printf("%s len %d", name, len(visibles))
for _, v := range visibles {
log.Printf("%s: => %+v", name, v)
}
log.Printf("%s len %d", name, len(visibles))
for _, v := range visibles {
log.Printf("%s: => %+v", name, v)
}
*/ */
} }
@ -109,7 +109,7 @@ var bufPool = sync.Pool{
}, },
} }
func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb.FileChunk, ) ([]*visibleInterval) {
func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb.FileChunk) []*visibleInterval {
newV := newVisibleInterval( newV := newVisibleInterval(
chunk.Offset, chunk.Offset,

19
weed/filer2/filechunks_test.go

@ -4,8 +4,8 @@ import (
"log" "log"
"testing" "testing"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
) )
func TestCompactFileChunks(t *testing.T) { func TestCompactFileChunks(t *testing.T) {
@ -27,7 +27,6 @@ func TestCompactFileChunks(t *testing.T) {
} }
func TestCompactFileChunks2(t *testing.T) { func TestCompactFileChunks2(t *testing.T) {
chunks := []*filer_pb.FileChunk{ chunks := []*filer_pb.FileChunk{
@ -43,10 +42,10 @@ func TestCompactFileChunks2(t *testing.T) {
for n := 0; n < k; n++ { for n := 0; n < k; n++ {
chunks = append(chunks, &filer_pb.FileChunk{ chunks = append(chunks, &filer_pb.FileChunk{
Offset: int64(n * 100), Size: 100, FileId: fmt.Sprintf("fileId%d",n), Mtime: int64(n),
Offset: int64(n * 100), Size: 100, FileId: fmt.Sprintf("fileId%d", n), Mtime: int64(n),
}) })
chunks = append(chunks, &filer_pb.FileChunk{ chunks = append(chunks, &filer_pb.FileChunk{
Offset: int64(n * 50), Size: 100, FileId: fmt.Sprintf("fileId%d",n+k), Mtime: int64(n + k),
Offset: int64(n * 50), Size: 100, FileId: fmt.Sprintf("fileId%d", n+k), Mtime: int64(n + k),
}) })
} }
@ -170,10 +169,10 @@ func TestIntervalMerging(t *testing.T) {
{ {
Chunks: []*filer_pb.FileChunk{ Chunks: []*filer_pb.FileChunk{
{Offset: 0, Size: 77824, FileId: "4,0b3df938e301", Mtime: 123}, {Offset: 0, Size: 77824, FileId: "4,0b3df938e301", Mtime: 123},
{Offset: 471040, Size: 472225-471040, FileId: "6,0b3e0650019c", Mtime: 130},
{Offset: 77824, Size: 208896-77824, FileId: "4,0b3f0c7202f0", Mtime: 140},
{Offset: 208896, Size: 339968-208896, FileId: "2,0b4031a72689", Mtime: 150},
{Offset: 339968, Size: 471040-339968, FileId: "3,0b416a557362", Mtime: 160},
{Offset: 471040, Size: 472225 - 471040, FileId: "6,0b3e0650019c", Mtime: 130},
{Offset: 77824, Size: 208896 - 77824, FileId: "4,0b3f0c7202f0", Mtime: 140},
{Offset: 208896, Size: 339968 - 208896, FileId: "2,0b4031a72689", Mtime: 150},
{Offset: 339968, Size: 471040 - 339968, FileId: "3,0b416a557362", Mtime: 160},
}, },
Expected: []*visibleInterval{ Expected: []*visibleInterval{
{start: 0, stop: 77824, fileId: "4,0b3df938e301"}, {start: 0, stop: 77824, fileId: "4,0b3df938e301"},
@ -372,10 +371,10 @@ func BenchmarkCompactFileChunks(b *testing.B) {
for n := 0; n < k; n++ { for n := 0; n < k; n++ {
chunks = append(chunks, &filer_pb.FileChunk{ chunks = append(chunks, &filer_pb.FileChunk{
Offset: int64(n * 100), Size: 100, FileId: fmt.Sprintf("fileId%d",n), Mtime: int64(n),
Offset: int64(n * 100), Size: 100, FileId: fmt.Sprintf("fileId%d", n), Mtime: int64(n),
}) })
chunks = append(chunks, &filer_pb.FileChunk{ chunks = append(chunks, &filer_pb.FileChunk{
Offset: int64(n * 50), Size: 100, FileId: fmt.Sprintf("fileId%d",n+k), Mtime: int64(n + k),
Offset: int64(n * 50), Size: 100, FileId: fmt.Sprintf("fileId%d", n+k), Mtime: int64(n + k),
}) })
} }

2
weed/filer2/filer_deletion.go

@ -3,9 +3,9 @@ package filer2
import ( import (
"time" "time"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/glog"
) )
func (f *Filer) loopProcessingDeletion() { func (f *Filer) loopProcessingDeletion() {

1
weed/filesys/filehandle.go

@ -46,6 +46,7 @@ func (fh *FileHandle) InitializeToFile(file *File, uid, gid uint32) *FileHandle
} }
return newHandle return newHandle
} }
var _ = fs.Handle(&FileHandle{}) var _ = fs.Handle(&FileHandle{})
// var _ = fs.HandleReadAller(&FileHandle{}) // var _ = fs.HandleReadAller(&FileHandle{})

3
weed/operation/assign_file_id.go

@ -1,9 +1,10 @@
package operation package operation
import ( import (
"context"
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"context"
) )
type VolumeAssignRequest struct { type VolumeAssignRequest struct {

4
weed/operation/grpc_client.go

@ -4,14 +4,14 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
"sync"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"sync"
"google.golang.org/grpc" "google.golang.org/grpc"
)
)
var ( var (
grpcClients = make(map[string]*grpc.ClientConn) grpcClients = make(map[string]*grpc.ClientConn)

2
weed/server/filer_grpc_server.go

@ -13,8 +13,8 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/util"
) )
func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) { func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {

2
weed/server/master_grpc_server_volume.go

@ -5,8 +5,8 @@ import (
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/pb/master_pb" "github.com/chrislusf/seaweedfs/weed/pb/master_pb"
"github.com/chrislusf/seaweedfs/weed/topology"
"github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/topology"
) )
func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupVolumeRequest) (*master_pb.LookupVolumeResponse, error) { func (ms *MasterServer) LookupVolume(ctx context.Context, req *master_pb.LookupVolumeRequest) (*master_pb.LookupVolumeResponse, error) {

2
weed/server/volume_server_handlers_read.go

@ -94,7 +94,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
} }
if r.Header.Get("ETag-MD5") == "True" { if r.Header.Get("ETag-MD5") == "True" {
setEtag(w, n.MD5()) setEtag(w, n.MD5())
}else{
} else {
setEtag(w, n.Etag()) setEtag(w, n.Etag())
} }

4
weed/storage/crc.go

@ -1,11 +1,11 @@
package storage package storage
import ( import (
"fmt"
"crypto/md5" "crypto/md5"
"fmt"
"github.com/klauspost/crc32"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"github.com/klauspost/crc32"
) )
var table = crc32.MakeTable(crc32.Castagnoli) var table = crc32.MakeTable(crc32.Castagnoli)

2
weed/storage/volume_read_write.go

@ -42,7 +42,7 @@ func (v *Volume) Destroy() (err error) {
} }
v.Close() v.Close()
os.Remove(v.FileName() + ".dat") os.Remove(v.FileName() + ".dat")
if v.nm!=nil{
if v.nm != nil {
err = v.nm.Destroy() err = v.nm.Destroy()
} }
os.Remove(v.FileName() + ".cpd") os.Remove(v.FileName() + ".cpd")

Loading…
Cancel
Save