Browse Source

breaks dependency loop

tikv
Chris Lu 5 years ago
parent
commit
afb20de14c
  1. 3
      weed/filer2/abstract_sql/abstract_sql_store.go
  2. 9
      weed/filer2/cassandra/cassandra_store.go
  3. 6
      weed/filer2/etcd/etcd_store.go
  4. 3
      weed/filer2/filer.go
  5. 2
      weed/filer2/filer_client_util.go
  6. 3
      weed/filer2/filerstore.go
  7. 3
      weed/filer2/leveldb/leveldb_store.go
  8. 3
      weed/filer2/leveldb2/leveldb2_store.go
  9. 3
      weed/filer2/redis/universal_redis_store.go
  10. 3
      weed/filer2/tikv/tikv_store.go
  11. 2
      weed/filesys/xattr.go
  12. 21
      weed/pb/filer_pb/filer_pb_helper.go
  13. 3
      weed/s3api/filer_util.go
  14. 5
      weed/s3api/s3api_bucket_handlers.go
  15. 2
      weed/server/filer_grpc_server.go
  16. 3
      weed/server/filer_server_handlers_read.go
  17. 2
      weed/server/filer_server_handlers_write.go
  18. 1
      weed/shell/command_fs_meta_cat.go
  19. 1
      weed/shell/commands.go

3
weed/filer2/abstract_sql/abstract_sql_store.go

@ -7,6 +7,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
)
@ -104,7 +105,7 @@ func (store *AbstractSqlStore) FindEntry(ctx context.Context, fullpath filer2.Fu
row := store.getTxOrDB(ctx).QueryRowContext(ctx, store.SqlFind, util.HashStringToLong(dir), name, dir)
var data []byte
if err := row.Scan(&data); err != nil {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
entry := &filer2.Entry{

9
weed/filer2/cassandra/cassandra_store.go

@ -3,10 +3,13 @@ package cassandra
import (
"context"
"fmt"
"github.com/gocql/gocql"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/gocql/gocql"
)
func init() {
@ -80,12 +83,12 @@ func (store *CassandraStore) FindEntry(ctx context.Context, fullpath filer2.Full
"SELECT meta FROM filemeta WHERE directory=? AND name=?",
dir, name).Consistency(gocql.One).Scan(&data); err != nil {
if err != gocql.ErrNotFound {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
}
if len(data) == 0 {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
entry = &filer2.Entry{

6
weed/filer2/etcd/etcd_store.go

@ -6,10 +6,12 @@ import (
"strings"
"time"
"go.etcd.io/etcd/clientv3"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
weed_util "github.com/chrislusf/seaweedfs/weed/util"
"go.etcd.io/etcd/clientv3"
)
const (
@ -99,7 +101,7 @@ func (store *EtcdStore) FindEntry(ctx context.Context, fullpath filer2.FullPath)
}
if len(resp.Kvs) == 0 {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
entry = &filer2.Entry{

3
weed/filer2/filer.go

@ -13,6 +13,7 @@ import (
"github.com/karlseguin/ccache"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/chrislusf/seaweedfs/weed/wdclient"
)
@ -126,7 +127,7 @@ func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool) erro
glog.V(2).Infof("create directory: %s %v", dirPath, dirEntry.Mode)
mkdirErr := f.store.InsertEntry(ctx, dirEntry)
if mkdirErr != nil {
if _, err := f.FindEntry(ctx, FullPath(dirPath)); err == ErrNotFound {
if _, err := f.FindEntry(ctx, FullPath(dirPath)); err == filer_pb.ErrNotFound {
glog.V(3).Infof("mkdir %s: %v", dirPath, mkdirErr)
return fmt.Errorf("mkdir %s: %v", dirPath, mkdirErr)
}

2
weed/filer2/filer_client_util.go

@ -104,7 +104,7 @@ func GetEntry(filerClient FilerClient, fullFilePath FullPath) (entry *filer_pb.E
// glog.V(3).Infof("read %s request: %v", fullFilePath, request)
resp, err := filer_pb.LookupEntry(client, request)
if err != nil {
if err == ErrNotFound {
if err == filer_pb.ErrNotFound {
return nil
}
glog.V(3).Infof("read %s %v: %v", fullFilePath, resp, err)

3
weed/filer2/filerstore.go

@ -2,7 +2,6 @@ package filer2
import (
"context"
"errors"
"time"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
@ -28,8 +27,6 @@ type FilerStore interface {
RollbackTransaction(ctx context.Context) error
}
var ErrNotFound = errors.New("filer: no entry is found in filer store")
type FilerStoreWrapper struct {
actualStore FilerStore
}

3
weed/filer2/leveldb/leveldb_store.go

@ -11,6 +11,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
weed_util "github.com/chrislusf/seaweedfs/weed/util"
)
@ -94,7 +95,7 @@ func (store *LevelDBStore) FindEntry(ctx context.Context, fullpath filer2.FullPa
data, err := store.db.Get(key, nil)
if err == leveldb.ErrNotFound {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
if err != nil {
return nil, fmt.Errorf("get %s : %v", entry.FullPath, err)

3
weed/filer2/leveldb2/leveldb2_store.go

@ -14,6 +14,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
weed_util "github.com/chrislusf/seaweedfs/weed/util"
)
@ -104,7 +105,7 @@ func (store *LevelDB2Store) FindEntry(ctx context.Context, fullpath filer2.FullP
data, err := store.dbs[partitionId].Get(key, nil)
if err == leveldb.ErrNotFound {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
if err != nil {
return nil, fmt.Errorf("get %s : %v", entry.FullPath, err)

3
weed/filer2/redis/universal_redis_store.go

@ -11,6 +11,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
const (
@ -64,7 +65,7 @@ func (store *UniversalRedisStore) FindEntry(ctx context.Context, fullpath filer2
data, err := store.Client.Get(string(fullpath)).Result()
if err == redis.Nil {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
if err != nil {

3
weed/filer2/tikv/tikv_store.go

@ -12,6 +12,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
weed_util "github.com/chrislusf/seaweedfs/weed/util"
"github.com/pingcap/tidb/kv"
@ -110,7 +111,7 @@ func (store *TikvStore) FindEntry(ctx context.Context, fullpath filer2.FullPath)
data, err := store.getTx(ctx).Get(ctx, key)
if err == kv.ErrNotExist {
return nil, filer2.ErrNotFound
return nil, filer_pb.ErrNotFound
}
if err != nil {
return nil, fmt.Errorf("get %s : %v", entry.FullPath, err)

2
weed/filesys/xattr.go

@ -123,7 +123,7 @@ func (wfs *WFS) maybeLoadEntry(dir, name string) (entry *filer_pb.Entry, err err
resp, err := filer_pb.LookupEntry(client, request)
if err != nil {
if err == filer2.ErrNotFound {
if err == filer_pb.ErrNotFound {
glog.V(3).Infof("file attr read not found file %v: %v", request, err)
return fuse.ENOENT
}

21
weed/pb/filer_pb/filer_pb_helper.go

@ -2,10 +2,10 @@ package filer_pb
import (
"context"
"errors"
"fmt"
"strings"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/storage/needle"
)
@ -88,23 +88,18 @@ func CreateEntry(client SeaweedFilerClient, request *CreateEntryRequest) error {
}
func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) {
resp, err := filer_pb.LookupEntry(client, request)
resp, err := client.LookupDirectoryEntry(context.Background(), request)
if err != nil {
if err == filer2.ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) {
return nil, filer2.ErrNotFound
if err == ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) {
return nil, ErrNotFound
}
glog.V(3).Infof("read %s/%v: %v", request.Directory, request.Entry.Name, err)
glog.V(3).Infof("read %s/%v: %v", request.Directory, request.Name, err)
return nil, fmt.Errorf("LookupEntry1: %v", err)
}
if resp.Error != "" && strings.Contains(resp.Error, ErrNotFound.Error()) {
return nil, filer2.ErrNotFound
}
if resp.Error != "" {
glog.V(3).Infof("lookup %s/%v: %v", request.Directory, request.Entry.Name, err)
return nil, fmt.Errorf("LookupEntry2: %v", err)
}
if resp.Entry == nil {
return nil, filer2.ErrNotFound
return nil, ErrNotFound
}
return resp, nil
}
var ErrNotFound = errors.New("filer: no entry is found in filer store")

3
weed/s3api/filer_util.go

@ -8,7 +8,6 @@ import (
"strings"
"time"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
@ -205,7 +204,7 @@ func (s3a *S3ApiServer) exists(parentDirectoryPath string, entryName string, isD
glog.V(4).Infof("exists entry %v/%v: %v", parentDirectoryPath, entryName, request)
resp, err := filer_pb.LookupEntry(client, request)
if err != nil {
if err == filer2.ErrNotFound {
if err == filer_pb.ErrNotFound {
exists = false
return nil
}

5
weed/s3api/s3api_bucket_handlers.go

@ -13,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/gorilla/mux"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
)
@ -119,8 +118,8 @@ func (s3a *S3ApiServer) HeadBucketHandler(w http.ResponseWriter, r *http.Request
glog.V(1).Infof("lookup bucket: %v", request)
if _, err := filer_pb.LookupEntry(client, request); err != nil {
if err == filer2.ErrNotFound {
return filer2.ErrNotFound
if err == filer_pb.ErrNotFound {
return filer_pb.ErrNotFound
}
return fmt.Errorf("lookup bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)
}

2
weed/server/filer_grpc_server.go

@ -19,7 +19,7 @@ import (
func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {
entry, err := fs.filer.FindEntry(ctx, filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Name))))
if err == filer2.ErrNotFound {
if err == filer_pb.ErrNotFound {
return &filer_pb.LookupDirectoryEntryResponse{}, nil
}
if err != nil {

3
weed/server/filer_server_handlers_read.go

@ -15,6 +15,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/util"
)
@ -33,7 +34,7 @@ func (fs *FilerServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
fs.listDirectoryHandler(w, r)
return
}
if err == filer2.ErrNotFound {
if err == filer_pb.ErrNotFound {
glog.V(1).Infof("Not found %s: %v", path, err)
stats.FilerRequestCounter.WithLabelValues("read.notfound").Inc()
w.WriteHeader(http.StatusNotFound)

2
weed/server/filer_server_handlers_write.go

@ -307,7 +307,7 @@ func (fs *FilerServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
if err != nil {
glog.V(1).Infoln("deleting", r.URL.Path, ":", err.Error())
httpStatus := http.StatusInternalServerError
if err == filer2.ErrNotFound {
if err == filer_pb.ErrNotFound {
httpStatus = http.StatusNotFound
}
writeJsonError(w, r, httpStatus, err)

1
weed/shell/command_fs_meta_cat.go

@ -1,7 +1,6 @@
package shell
import (
"context"
"fmt"
"io"

1
weed/shell/commands.go

@ -1,7 +1,6 @@
package shell
import (
"context"
"fmt"
"io"
"net/url"

Loading…
Cancel
Save