Skip to content

Commit

Permalink
cluster mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Ushkov committed May 3, 2023
1 parent f3589dd commit d94adc8
Show file tree
Hide file tree
Showing 21 changed files with 8,664 additions and 74 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ build:

install:
go install -ldflags "-X main.Version=`git rev-parse HEAD`"


.PHONY: protoc
protoc:
protoc --go_out=. --experimental_allow_proto3_optional --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/pb/*.proto
83 changes: 83 additions & 0 deletions api/cluster_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package goofys

import (
"context"
"fmt"

"github.com/jacobsa/fuse"
"github.com/jacobsa/fuse/fuseutil"
"github.com/sirupsen/logrus"
. "github.com/yandex-cloud/geesefs/api/common"
"github.com/yandex-cloud/geesefs/internal"
"github.com/yandex-cloud/geesefs/internal/pb"
)

func MountCluster(
ctx context.Context,
bucketName string,
flags *FlagStorage,
) (*Goofys, *fuse.MountedFileSystem, *internal.ConnPool, error) {

if flags.DebugS3 {
SetCloudLogLevel(logrus.DebugLevel)
}

mountConfig := &fuse.MountConfig{
FSName: bucketName,
Subtype: "geesefs",
Options: flags.MountOptions,
ErrorLogger: GetStdLogger(NewLogger("fuse"), logrus.ErrorLevel),
DisableWritebackCaching: true,
UseVectoredRead: true,
}

if flags.DebugFuse {
fuseLog := GetLogger("fuse")
fuseLog.Level = logrus.DebugLevel
mountConfig.DebugLogger = GetStdLogger(fuseLog, logrus.DebugLevel)
}

if flags.DebugFuse || flags.DebugMain {
log.Level = logrus.DebugLevel
}

if flags.DebugGrpc {
grpcLog := GetLogger("grpc")
grpcLog.Level = logrus.DebugLevel
}

srv := internal.NewGrpcServer(flags)
conns := internal.NewConnPool(flags)
rec := &internal.Recovery{
Flags: flags,
}
goofys := internal.NewClusterGoofys(context.Background(), bucketName, flags, conns)
fs := &internal.Fs{
Flags: flags,
Conns: conns,
Goofys: goofys,
}
go fs.StatPrinter()

pb.RegisterRecoveryServer(srv, rec)
pb.RegisterFsGrpcServer(srv, &internal.FsGrpc{Fs: fs})

go func() {
err := srv.Start()
if err != nil {
panic(err)
}
}()

mfs, err := fuse.Mount(
flags.MountPoint,
fuseutil.NewFileSystemServer(&internal.FsFuse{Fs: fs}),
mountConfig,
)
if err != nil {
err = fmt.Errorf("Mount: %v", err)
return nil, nil, nil, err
}

return goofys, mfs, conns, nil
}
12 changes: 12 additions & 0 deletions api/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ type PartSizeConfig struct {
PartCount uint64
}

type NodeConfig struct {
Id uint64
Address string
}

type FlagStorage struct {
// File system
MountOptions map[string]string
Expand Down Expand Up @@ -100,8 +105,15 @@ type FlagStorage struct {
PProf string
Foreground bool
LogFile string
DebugGrpc bool

StatsInterval time.Duration

// Cluster Mode
ClusterMode bool
ClusterGrpcReflection bool
ClusterMe *NodeConfig
ClusterPeers []*NodeConfig
}

func (flags *FlagStorage) GetMimeType(fileName string) (retMime *string) {
Expand Down
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,32 @@ require (
github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect
github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect
github.com/aws/aws-sdk-go v1.38.7
github.com/golang/protobuf v1.5.2
github.com/google/btree v1.0.0
github.com/google/uuid v1.1.2
github.com/gopherjs/gopherjs v0.0.0-20210202160940-bed99a852dfe // indirect
github.com/jacobsa/fuse v0.0.0-20230225155227-86031ac261e8
github.com/jacobsa/fuse v0.0.0-20210818065549-10d864429bf7
github.com/jtolds/gls v4.2.0+incompatible // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/kr/pretty v0.1.1-0.20190720101428-71e7e4993750 // indirect
github.com/mattn/go-ieproxy v0.0.0-20190805055040-f9202b1cfdeb // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/xattr v0.4.9 // indirect
github.com/pkg/xattr v0.4.9
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
github.com/sevlyar/go-daemon v0.1.5
github.com/shirou/gopsutil v0.0.0-20190731134726-d80c43f9c984
github.com/sirupsen/logrus v1.8.1
github.com/smartystreets/assertions v0.0.0-20160201214316-443d812296a8 // indirect
github.com/smartystreets/goconvey v1.6.1-0.20160119221636-995f5b2e021c // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/urfave/cli v1.21.1-0.20190807111034-521735b7608a
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
google.golang.org/api v0.49.0
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
gopkg.in/ini.v1 v1.46.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/aws/aws-sdk-go => ./s3ext
Expand Down
Loading

0 comments on commit d94adc8

Please sign in to comment.