mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
use streaming mode for long poll grpc calls
streaming mode would create separate grpc connections for each call. this is to ensure the long poll connections are properly closed.
This commit is contained in:
parent
c935b9669e
commit
9f9ef1340c
|
@ -122,7 +122,7 @@ type needleState struct {
|
||||||
|
|
||||||
func getVolumeFiles(v uint32, addr pb.ServerAddress) (map[types.NeedleId]needleState, int64, error) {
|
func getVolumeFiles(v uint32, addr pb.ServerAddress) (map[types.NeedleId]needleState, int64, error) {
|
||||||
var idxFile *bytes.Reader
|
var idxFile *bytes.Reader
|
||||||
err := operation.WithVolumeServerClient(addr, grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, addr, grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
copyFileClient, err := vs.CopyFile(ctx, &volume_server_pb.CopyFileRequest{
|
copyFileClient, err := vs.CopyFile(ctx, &volume_server_pb.CopyFileRequest{
|
||||||
|
@ -180,7 +180,7 @@ func getVolumeFiles(v uint32, addr pb.ServerAddress) (map[types.NeedleId]needleS
|
||||||
|
|
||||||
func getNeedleFileId(v uint32, nid types.NeedleId, addr pb.ServerAddress) (string, error) {
|
func getNeedleFileId(v uint32, nid types.NeedleId, addr pb.ServerAddress) (string, error) {
|
||||||
var id string
|
var id string
|
||||||
err := operation.WithVolumeServerClient(addr, grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, addr, grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
||||||
resp, err := vs.VolumeNeedleStatus(context.Background(), &volume_server_pb.VolumeNeedleStatusRequest{
|
resp, err := vs.VolumeNeedleStatus(context.Background(), &volume_server_pb.VolumeNeedleStatusRequest{
|
||||||
VolumeId: v,
|
VolumeId: v,
|
||||||
NeedleId: uint64(nid),
|
NeedleId: uint64(nid),
|
||||||
|
|
|
@ -51,7 +51,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func startGenerateMetadata() {
|
func startGenerateMetadata() {
|
||||||
pb.WithFilerClient(pb.ServerAddress(*tailFiler), grpc.WithInsecure(), func(client filer_pb.SeaweedFilerClient) error {
|
pb.WithFilerClient(false, pb.ServerAddress(*tailFiler), grpc.WithInsecure(), func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
for i := 0; i < *n; i++ {
|
for i := 0; i < *n; i++ {
|
||||||
name := fmt.Sprintf("file%d", i)
|
name := fmt.Sprintf("file%d", i)
|
||||||
|
|
|
@ -33,7 +33,7 @@ func main() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(pb.ServerAddress(*volumeServer), grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(true, pb.ServerAddress(*volumeServer), grpcDialOption, func(vs volume_server_pb.VolumeServerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
copyFileClient, err := vs.ReadAllNeedles(ctx, &volume_server_pb.ReadAllNeedlesRequest{
|
copyFileClient, err := vs.ReadAllNeedles(ctx, &volume_server_pb.ReadAllNeedlesRequest{
|
||||||
|
@ -61,4 +61,3 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ func runFilerCat(cmd *Command, args []string) bool {
|
||||||
writer = f
|
writer = f
|
||||||
}
|
}
|
||||||
|
|
||||||
pb.WithFilerClient(filerCat.filerAddress, filerCat.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
pb.WithFilerClient(false, filerCat.filerAddress, filerCat.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
request := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
|
@ -172,7 +172,7 @@ func runCopy(cmd *Command, args []string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFilerConfiguration(grpcDialOption grpc.DialOption, filerGrpcAddress pb.ServerAddress) (masters []string, collection, replication string, dirBuckets string, maxMB uint32, cipher bool, err error) {
|
func readFilerConfiguration(grpcDialOption grpc.DialOption, filerGrpcAddress pb.ServerAddress) (masters []string, collection, replication string, dirBuckets string, maxMB uint32, cipher bool, err error) {
|
||||||
err = pb.WithGrpcFilerClient(filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithGrpcFilerClient(false, filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer %s configuration: %v", filerGrpcAddress, err)
|
return fmt.Errorf("get filer %s configuration: %v", filerGrpcAddress, err)
|
||||||
|
@ -302,7 +302,7 @@ func (worker *FileCopyWorker) checkExistingFileFirst(task FileCopyTask, f *os.Fi
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
request := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: task.destinationUrlPath,
|
Directory: task.destinationUrlPath,
|
||||||
|
@ -344,7 +344,7 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
|
||||||
|
|
||||||
err = util.Retry("upload", func() error {
|
err = util.Retry("upload", func() error {
|
||||||
// assign a volume
|
// assign a volume
|
||||||
assignErr := pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
assignErr := pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
|
@ -404,7 +404,7 @@ func (worker *FileCopyWorker) uploadFileAsOne(task FileCopyTask, f *os.File) err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if err := pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
request := &filer_pb.CreateEntryRequest{
|
request := &filer_pb.CreateEntryRequest{
|
||||||
Directory: task.destinationUrlPath,
|
Directory: task.destinationUrlPath,
|
||||||
Entry: &filer_pb.Entry{
|
Entry: &filer_pb.Entry{
|
||||||
|
@ -461,7 +461,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||||
var assignResult *filer_pb.AssignVolumeResponse
|
var assignResult *filer_pb.AssignVolumeResponse
|
||||||
var assignError error
|
var assignError error
|
||||||
err := util.Retry("assignVolume", func() error {
|
err := util.Retry("assignVolume", func() error {
|
||||||
return pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
Replication: *worker.options.replication,
|
Replication: *worker.options.replication,
|
||||||
|
@ -540,7 +540,7 @@ func (worker *FileCopyWorker) uploadFileInChunks(task FileCopyTask, f *os.File,
|
||||||
return fmt.Errorf("create manifest: %v", manifestErr)
|
return fmt.Errorf("create manifest: %v", manifestErr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if err := pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
request := &filer_pb.CreateEntryRequest{
|
request := &filer_pb.CreateEntryRequest{
|
||||||
Directory: task.destinationUrlPath,
|
Directory: task.destinationUrlPath,
|
||||||
Entry: &filer_pb.Entry{
|
Entry: &filer_pb.Entry{
|
||||||
|
@ -598,7 +598,7 @@ func (worker *FileCopyWorker) saveDataAsChunk(reader io.Reader, name string, off
|
||||||
var fileId, host string
|
var fileId, host string
|
||||||
var auth security.EncodedJwt
|
var auth security.EncodedJwt
|
||||||
|
|
||||||
if flushErr := pb.WithGrpcFilerClient(worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if flushErr := pb.WithGrpcFilerClient(false, worker.filerAddress, worker.options.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
|
|
@ -222,9 +222,9 @@ func (metaBackup *FilerMetaBackupOptions) setOffset(lastWriteTime time.Time) err
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&FilerMetaBackupOptions{})
|
var _ = filer_pb.FilerClient(&FilerMetaBackupOptions{})
|
||||||
|
|
||||||
func (metaBackup *FilerMetaBackupOptions) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (metaBackup *FilerMetaBackupOptions) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithFilerClient(pb.ServerAddress(*metaBackup.filerAddress), metaBackup.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithFilerClient(streamingMode, pb.ServerAddress(*metaBackup.filerAddress), metaBackup.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return fn(client)
|
return fn(client)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ type RemoteGatewayOptions struct {
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&RemoteGatewayOptions{})
|
var _ = filer_pb.FilerClient(&RemoteGatewayOptions{})
|
||||||
|
|
||||||
func (option *RemoteGatewayOptions) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (option *RemoteGatewayOptions) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
return pb.WithFilerClient(pb.ServerAddress(*option.filerAddress), option.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithFilerClient(streamingMode, pb.ServerAddress(*option.filerAddress), option.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return fn(client)
|
return fn(client)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func runFilerRemoteGateway(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
remoteGatewayOptions.bucketsDir = "/buckets"
|
remoteGatewayOptions.bucketsDir = "/buckets"
|
||||||
// check buckets again
|
// check buckets again
|
||||||
remoteGatewayOptions.WithFilerClient(func(filerClient filer_pb.SeaweedFilerClient) error {
|
remoteGatewayOptions.WithFilerClient(false, func(filerClient filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := filerClient.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := filerClient.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -22,8 +22,8 @@ type RemoteSyncOptions struct {
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&RemoteSyncOptions{})
|
var _ = filer_pb.FilerClient(&RemoteSyncOptions{})
|
||||||
|
|
||||||
func (option *RemoteSyncOptions) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (option *RemoteSyncOptions) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
return pb.WithFilerClient(pb.ServerAddress(*option.filerAddress), option.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithFilerClient(streamingMode, pb.ServerAddress(*option.filerAddress), option.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return fn(client)
|
return fn(client)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ func shouldSendToRemote(entry *filer_pb.Entry) bool {
|
||||||
func updateLocalEntry(filerClient filer_pb.FilerClient, dir string, entry *filer_pb.Entry, remoteEntry *filer_pb.RemoteEntry) error {
|
func updateLocalEntry(filerClient filer_pb.FilerClient, dir string, entry *filer_pb.Entry, remoteEntry *filer_pb.RemoteEntry) error {
|
||||||
remoteEntry.LastLocalSyncTsNs = time.Now().UnixNano()
|
remoteEntry.LastLocalSyncTsNs = time.Now().UnixNano()
|
||||||
entry.RemoteEntry = remoteEntry
|
entry.RemoteEntry = remoteEntry
|
||||||
return filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
_, err := client.UpdateEntry(context.Background(), &filer_pb.UpdateEntryRequest{
|
_, err := client.UpdateEntry(context.Background(), &filer_pb.UpdateEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
Entry: entry,
|
Entry: entry,
|
||||||
|
|
|
@ -183,7 +183,7 @@ const (
|
||||||
|
|
||||||
func getOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, signaturePrefix string, signature int32) (lastOffsetTsNs int64, readErr error) {
|
func getOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, signaturePrefix string, signature int32) (lastOffsetTsNs int64, readErr error) {
|
||||||
|
|
||||||
readErr = pb.WithFilerClient(filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
readErr = pb.WithFilerClient(false, filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
syncKey := []byte(signaturePrefix + "____")
|
syncKey := []byte(signaturePrefix + "____")
|
||||||
util.Uint32toBytes(syncKey[len(signaturePrefix):len(signaturePrefix)+4], uint32(signature))
|
util.Uint32toBytes(syncKey[len(signaturePrefix):len(signaturePrefix)+4], uint32(signature))
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ func getOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, signature
|
||||||
}
|
}
|
||||||
|
|
||||||
func setOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, signaturePrefix string, signature int32, offsetTsNs int64) error {
|
func setOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, signaturePrefix string, signature int32, offsetTsNs int64) error {
|
||||||
return pb.WithFilerClient(filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithFilerClient(false, filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
syncKey := []byte(signaturePrefix + "____")
|
syncKey := []byte(signaturePrefix + "____")
|
||||||
util.Uint32toBytes(syncKey[len(signaturePrefix):len(signaturePrefix)+4], uint32(signature))
|
util.Uint32toBytes(syncKey[len(signaturePrefix):len(signaturePrefix)+4], uint32(signature))
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (iamopt *IamOptions) startIamServer() bool {
|
||||||
util.LoadConfiguration("security", false)
|
util.LoadConfiguration("security", false)
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
|
||||||
for {
|
for {
|
||||||
err := pb.WithGrpcFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithGrpcFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
||||||
|
|
|
@ -87,7 +87,7 @@ func startMasterFollower(masterOptions MasterOptions) {
|
||||||
var err error
|
var err error
|
||||||
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.master")
|
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.master")
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
err = pb.WithOneOfGrpcMasterClients(masters, grpcDialOption, func(client master_pb.SeaweedClient) error {
|
err = pb.WithOneOfGrpcMasterClients(false, masters, grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get master grpc address %v configuration: %v", masters, err)
|
return fmt.Errorf("get master grpc address %v configuration: %v", masters, err)
|
||||||
|
|
|
@ -78,7 +78,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
|
||||||
var cipher bool
|
var cipher bool
|
||||||
var err error
|
var err error
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
err = pb.WithOneOfGrpcFilerClients(filerAddresses, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithOneOfGrpcFilerClients(false, filerAddresses, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer grpc address %v configuration: %v", filerAddresses, err)
|
return fmt.Errorf("get filer grpc address %v configuration: %v", filerAddresses, err)
|
||||||
|
|
|
@ -68,7 +68,7 @@ func (msgBrokerOpt *MessageBrokerOptions) startQueueServer() bool {
|
||||||
cipher := false
|
cipher := false
|
||||||
|
|
||||||
for {
|
for {
|
||||||
err := pb.WithGrpcFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithGrpcFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
||||||
|
|
|
@ -153,7 +153,7 @@ func (s3opt *S3Options) startS3Server() bool {
|
||||||
var metricsIntervalSec int
|
var metricsIntervalSec int
|
||||||
|
|
||||||
for {
|
for {
|
||||||
err := pb.WithGrpcFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithGrpcFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
||||||
|
|
|
@ -130,7 +130,7 @@ func runUpload(cmd *Command, args []string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func readMasterConfiguration(grpcDialOption grpc.DialOption, masterAddress pb.ServerAddress) (replication string, err error) {
|
func readMasterConfiguration(grpcDialOption grpc.DialOption, masterAddress pb.ServerAddress) (replication string, err error) {
|
||||||
err = pb.WithMasterClient(masterAddress, grpcDialOption, func(client master_pb.SeaweedClient) error {
|
err = pb.WithMasterClient(false, masterAddress, grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
resp, err := client.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get master %s configuration: %v", masterAddress, err)
|
return fmt.Errorf("get master %s configuration: %v", masterAddress, err)
|
||||||
|
|
|
@ -85,7 +85,7 @@ func (wo *WebDavOption) startWebDav() bool {
|
||||||
var cipher bool
|
var cipher bool
|
||||||
// connect to filer
|
// connect to filer
|
||||||
for {
|
for {
|
||||||
err := pb.WithGrpcFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithGrpcFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
return fmt.Errorf("get filer %s configuration: %v", filerAddress, err)
|
||||||
|
|
|
@ -81,7 +81,7 @@ func (f *Filer) AggregateFromPeers(self pb.ServerAddress) {
|
||||||
|
|
||||||
func (f *Filer) ListExistingPeerUpdates() (existingNodes []*master_pb.ClusterNodeUpdate) {
|
func (f *Filer) ListExistingPeerUpdates() (existingNodes []*master_pb.ClusterNodeUpdate) {
|
||||||
|
|
||||||
if grpcErr := pb.WithMasterClient(f.MasterClient.GetMaster(), f.GrpcDialOption, func(client master_pb.SeaweedClient) error {
|
if grpcErr := pb.WithMasterClient(false, f.MasterClient.GetMaster(), f.GrpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
ClientType: cluster.FilerType,
|
ClientType: cluster.FilerType,
|
||||||
})
|
})
|
||||||
|
|
|
@ -32,7 +32,7 @@ type FilerConf struct {
|
||||||
|
|
||||||
func ReadFilerConf(filerGrpcAddress pb.ServerAddress, grpcDialOption grpc.DialOption, masterClient *wdclient.MasterClient) (*FilerConf, error) {
|
func ReadFilerConf(filerGrpcAddress pb.ServerAddress, grpcDialOption grpc.DialOption, masterClient *wdclient.MasterClient) (*FilerConf, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err := pb.WithGrpcFilerClient(filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if err := pb.WithGrpcFilerClient(false, filerGrpcAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if masterClient != nil {
|
if masterClient != nil {
|
||||||
return ReadEntry(masterClient, client, DirectoryEtcSeaweedFS, FilerConfName, &buf)
|
return ReadEntry(masterClient, client, DirectoryEtcSeaweedFS, FilerConfName, &buf)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -139,7 +139,7 @@ func (f *Filer) doDeleteEntryMetaAndData(ctx context.Context, entry *Entry, shou
|
||||||
|
|
||||||
func (f *Filer) doDeleteCollection(collectionName string) (err error) {
|
func (f *Filer) doDeleteCollection(collectionName string) (err error) {
|
||||||
|
|
||||||
return f.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
return f.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
_, err := client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
_, err := client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
||||||
Name: collectionName,
|
Name: collectionName,
|
||||||
})
|
})
|
||||||
|
|
|
@ -152,7 +152,7 @@ func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, p
|
||||||
|
|
||||||
for {
|
for {
|
||||||
glog.V(4).Infof("subscribing remote %s meta change: %v", peer, time.Unix(0, lastTsNs))
|
glog.V(4).Infof("subscribing remote %s meta change: %v", peer, time.Unix(0, lastTsNs))
|
||||||
err := pb.WithFilerClient(peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err := pb.WithFilerClient(false, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
||||||
|
@ -194,7 +194,7 @@ func (ma *MetaAggregator) subscribeToOneFiler(f *Filer, self pb.ServerAddress, p
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ma *MetaAggregator) readFilerStoreSignature(peer pb.ServerAddress) (sig int32, err error) {
|
func (ma *MetaAggregator) readFilerStoreSignature(peer pb.ServerAddress) (sig int32, err error) {
|
||||||
err = pb.WithFilerClient(peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithFilerClient(false, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,7 +26,7 @@ func MapRemoteStorageLocationPathToFullPath(localMountedDir util.FullPath, remot
|
||||||
}
|
}
|
||||||
|
|
||||||
func CacheRemoteObjectToLocalCluster(filerClient filer_pb.FilerClient, remoteConf *remote_pb.RemoteConf, remoteLocation *remote_pb.RemoteStorageLocation, parent util.FullPath, entry *filer_pb.Entry) error {
|
func CacheRemoteObjectToLocalCluster(filerClient filer_pb.FilerClient, remoteConf *remote_pb.RemoteConf, remoteLocation *remote_pb.RemoteStorageLocation, parent util.FullPath, entry *filer_pb.Entry) error {
|
||||||
return filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
_, err := client.CacheRemoteObjectToLocalCluster(context.Background(), &filer_pb.CacheRemoteObjectToLocalClusterRequest{
|
_, err := client.CacheRemoteObjectToLocalCluster(context.Background(), &filer_pb.CacheRemoteObjectToLocalClusterRequest{
|
||||||
Directory: string(parent),
|
Directory: string(parent),
|
||||||
Name: entry.Name,
|
Name: entry.Name,
|
||||||
|
|
|
@ -44,7 +44,7 @@ func LookupFn(filerClient filer_pb.FilerClient) wdclient.LookupFileIdFunctionTyp
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
util.Retry("lookup volume "+vid, func() error {
|
util.Retry("lookup volume "+vid, func() error {
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
||||||
VolumeIds: []string{vid},
|
VolumeIds: []string{vid},
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
func ReadMountMappings(grpcDialOption grpc.DialOption, filerAddress pb.ServerAddress) (mappings *remote_pb.RemoteStorageMapping, readErr error) {
|
func ReadMountMappings(grpcDialOption grpc.DialOption, filerAddress pb.ServerAddress) (mappings *remote_pb.RemoteStorageMapping, readErr error) {
|
||||||
var oldContent []byte
|
var oldContent []byte
|
||||||
if readErr = pb.WithFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if readErr = pb.WithFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
oldContent, readErr = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
oldContent, readErr = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
||||||
return readErr
|
return readErr
|
||||||
}); readErr != nil {
|
}); readErr != nil {
|
||||||
|
@ -30,7 +30,7 @@ func InsertMountMapping(filerClient filer_pb.FilerClient, dir string, remoteStor
|
||||||
|
|
||||||
// read current mapping
|
// read current mapping
|
||||||
var oldContent, newContent []byte
|
var oldContent, newContent []byte
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
oldContent, err = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
oldContent, err = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
@ -47,7 +47,7 @@ func InsertMountMapping(filerClient filer_pb.FilerClient, dir string, remoteStor
|
||||||
}
|
}
|
||||||
|
|
||||||
// save back
|
// save back
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return SaveInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE, newContent)
|
return SaveInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE, newContent)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -61,7 +61,7 @@ func DeleteMountMapping(filerClient filer_pb.FilerClient, dir string) (err error
|
||||||
|
|
||||||
// read current mapping
|
// read current mapping
|
||||||
var oldContent, newContent []byte
|
var oldContent, newContent []byte
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
oldContent, err = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
oldContent, err = ReadInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
@ -78,7 +78,7 @@ func DeleteMountMapping(filerClient filer_pb.FilerClient, dir string) (err error
|
||||||
}
|
}
|
||||||
|
|
||||||
// save back
|
// save back
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return SaveInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE, newContent)
|
return SaveInsideFiler(client, DirectoryEtcRemote, REMOTE_STORAGE_MOUNT_FILE, newContent)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -133,7 +133,7 @@ func UnmarshalRemoteStorageMappings(oldContent []byte) (mappings *remote_pb.Remo
|
||||||
|
|
||||||
func ReadRemoteStorageConf(grpcDialOption grpc.DialOption, filerAddress pb.ServerAddress, storageName string) (conf *remote_pb.RemoteConf, readErr error) {
|
func ReadRemoteStorageConf(grpcDialOption grpc.DialOption, filerAddress pb.ServerAddress, storageName string) (conf *remote_pb.RemoteConf, readErr error) {
|
||||||
var oldContent []byte
|
var oldContent []byte
|
||||||
if readErr = pb.WithFilerClient(filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if readErr = pb.WithFilerClient(false, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
oldContent, readErr = ReadInsideFiler(client, DirectoryEtcRemote, storageName+REMOTE_STORAGE_CONF_SUFFIX)
|
oldContent, readErr = ReadInsideFiler(client, DirectoryEtcRemote, storageName+REMOTE_STORAGE_CONF_SUFFIX)
|
||||||
return readErr
|
return readErr
|
||||||
}); readErr != nil {
|
}); readErr != nil {
|
||||||
|
|
|
@ -201,7 +201,7 @@ func (dir *Dir) doCreateEntry(name string, mode os.FileMode, uid, gid uint32, ex
|
||||||
}
|
}
|
||||||
glog.V(1).Infof("create %s/%s", dirFullPath, name)
|
glog.V(1).Infof("create %s/%s", dirFullPath, name)
|
||||||
|
|
||||||
err := dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := dir.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
@ -242,7 +242,7 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err
|
||||||
|
|
||||||
dirFullPath := dir.FullPath()
|
dirFullPath := dir.FullPath()
|
||||||
|
|
||||||
err := dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := dir.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir.wfs.mapPbIdFromLocalToFiler(newEntry)
|
dir.wfs.mapPbIdFromLocalToFiler(newEntry)
|
||||||
defer dir.wfs.mapPbIdFromFilerToLocal(newEntry)
|
defer dir.wfs.mapPbIdFromFilerToLocal(newEntry)
|
||||||
|
@ -566,7 +566,7 @@ func (dir *Dir) saveEntry(entry *filer_pb.Entry) error {
|
||||||
|
|
||||||
parentDir, name := util.FullPath(dir.FullPath()).DirAndName()
|
parentDir, name := util.FullPath(dir.FullPath()).DirAndName()
|
||||||
|
|
||||||
return dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return dir.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir.wfs.mapPbIdFromLocalToFiler(entry)
|
dir.wfs.mapPbIdFromLocalToFiler(entry)
|
||||||
defer dir.wfs.mapPbIdFromFilerToLocal(entry)
|
defer dir.wfs.mapPbIdFromFilerToLocal(entry)
|
||||||
|
|
|
@ -68,7 +68,7 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply changes to the filer, and also apply to local metaCache
|
// apply changes to the filer, and also apply to local metaCache
|
||||||
err = dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = dir.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
@ -121,7 +121,7 @@ func (dir *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fs.Node,
|
||||||
Signatures: []int32{dir.wfs.signature},
|
Signatures: []int32{dir.wfs.signature},
|
||||||
}
|
}
|
||||||
|
|
||||||
err := dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := dir.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
dir.wfs.mapPbIdFromLocalToFiler(request.Entry)
|
||||||
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
defer dir.wfs.mapPbIdFromFilerToLocal(request.Entry)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
|
||||||
glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath)
|
glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath)
|
||||||
|
|
||||||
// update remote filer
|
// update remote filer
|
||||||
err := dir.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := dir.wfs.WithFilerClient(true, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ func (file *File) addChunks(chunks []*filer_pb.FileChunk) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *File) saveEntry(entry *filer_pb.Entry) error {
|
func (file *File) saveEntry(entry *filer_pb.Entry) error {
|
||||||
return file.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return file.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
file.wfs.mapPbIdFromLocalToFiler(entry)
|
file.wfs.mapPbIdFromLocalToFiler(entry)
|
||||||
defer file.wfs.mapPbIdFromFilerToLocal(entry)
|
defer file.wfs.mapPbIdFromFilerToLocal(entry)
|
||||||
|
@ -362,7 +362,7 @@ func (file *File) getEntry() *filer_pb.Entry {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *File) downloadRemoteEntry(entry *filer_pb.Entry) (*filer_pb.Entry, error) {
|
func (file *File) downloadRemoteEntry(entry *filer_pb.Entry) (*filer_pb.Entry, error) {
|
||||||
err := file.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := file.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.CacheRemoteObjectToLocalClusterRequest{
|
request := &filer_pb.CacheRemoteObjectToLocalClusterRequest{
|
||||||
Directory: file.dir.FullPath(),
|
Directory: file.dir.FullPath(),
|
||||||
|
|
|
@ -277,7 +277,7 @@ func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err := fh.f.wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := fh.f.wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
entry := fh.f.getEntry()
|
entry := fh.f.getEntry()
|
||||||
if entry == nil {
|
if entry == nil {
|
||||||
|
|
|
@ -197,7 +197,7 @@ func (wfs *WFS) Statfs(ctx context.Context, req *fuse.StatfsRequest, resp *fuse.
|
||||||
|
|
||||||
if wfs.stats.lastChecked < time.Now().Unix()-20 {
|
if wfs.stats.lastChecked < time.Now().Unix()-20 {
|
||||||
|
|
||||||
err := wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.StatisticsRequest{
|
request := &filer_pb.StatisticsRequest{
|
||||||
Collection: wfs.option.Collection,
|
Collection: wfs.option.Collection,
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&WFS{})
|
var _ = filer_pb.FilerClient(&WFS{})
|
||||||
|
|
||||||
func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) (err error) {
|
func (wfs *WFS) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) (err error) {
|
||||||
|
|
||||||
return util.Retry("filer grpc", func() error {
|
return util.Retry("filer grpc", func() error {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ func (wfs *WFS) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) (err
|
||||||
for x := 0; x < n; x++ {
|
for x := 0; x < n; x++ {
|
||||||
|
|
||||||
filerGrpcAddress := wfs.option.FilerAddresses[i].ToGrpcAddress()
|
filerGrpcAddress := wfs.option.FilerAddresses[i].ToGrpcAddress()
|
||||||
err = pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
err = pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, filerGrpcAddress, wfs.option.GrpcDialOption)
|
}, filerGrpcAddress, wfs.option.GrpcDialOption)
|
||||||
|
|
|
@ -19,7 +19,7 @@ func (wfs *WFS) saveDataAsChunk(fullPath util.FullPath) filer.SaveDataAsChunkFun
|
||||||
var fileId, host string
|
var fileId, host string
|
||||||
var auth security.EncodedJwt
|
var auth security.EncodedJwt
|
||||||
|
|
||||||
if err := wfs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return util.Retry("assignVolume", func() error {
|
return util.Retry("assignVolume", func() error {
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
|
|
|
@ -76,7 +76,7 @@ func (iama *IamApiServer) registerRouter(router *mux.Router) {
|
||||||
|
|
||||||
func (iam IamS3ApiConfigure) GetS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfiguration) (err error) {
|
func (iam IamS3ApiConfigure) GetS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfiguration) (err error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err = pb.WithGrpcFilerClient(iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithGrpcFilerClient(false, iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if err = filer.ReadEntry(iam.masterClient, client, filer.IamConfigDirecotry, filer.IamIdentityFile, &buf); err != nil {
|
if err = filer.ReadEntry(iam.masterClient, client, filer.IamConfigDirecotry, filer.IamIdentityFile, &buf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -98,10 +98,7 @@ func (iam IamS3ApiConfigure) PutS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfigurat
|
||||||
if err := filer.ProtoToText(&buf, s3cfg); err != nil {
|
if err := filer.ProtoToText(&buf, s3cfg); err != nil {
|
||||||
return fmt.Errorf("ProtoToText: %s", err)
|
return fmt.Errorf("ProtoToText: %s", err)
|
||||||
}
|
}
|
||||||
return pb.WithGrpcFilerClient(
|
return pb.WithGrpcFilerClient(false, iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
iam.option.Filer,
|
|
||||||
iam.option.GrpcDialOption,
|
|
||||||
func(client filer_pb.SeaweedFilerClient) error {
|
|
||||||
err = util.Retry("saveIamIdentity", func() error {
|
err = util.Retry("saveIamIdentity", func() error {
|
||||||
return filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes())
|
return filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes())
|
||||||
})
|
})
|
||||||
|
@ -109,13 +106,12 @@ func (iam IamS3ApiConfigure) PutS3ApiConfiguration(s3cfg *iam_pb.S3ApiConfigurat
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iam IamS3ApiConfigure) GetPolicies(policies *Policies) (err error) {
|
func (iam IamS3ApiConfigure) GetPolicies(policies *Policies) (err error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err = pb.WithGrpcFilerClient(iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithGrpcFilerClient(false, iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if err = filer.ReadEntry(iam.masterClient, client, filer.IamConfigDirecotry, filer.IamPoliciesFile, &buf); err != nil {
|
if err = filer.ReadEntry(iam.masterClient, client, filer.IamConfigDirecotry, filer.IamPoliciesFile, &buf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -139,14 +135,10 @@ func (iam IamS3ApiConfigure) PutPolicies(policies *Policies) (err error) {
|
||||||
if b, err = json.Marshal(policies); err != nil {
|
if b, err = json.Marshal(policies); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return pb.WithGrpcFilerClient(
|
return pb.WithGrpcFilerClient(false, iam.option.Filer, iam.option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
iam.option.Filer,
|
|
||||||
iam.option.GrpcDialOption,
|
|
||||||
func(client filer_pb.SeaweedFilerClient) error {
|
|
||||||
if err := filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamPoliciesFile, b); err != nil {
|
if err := filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamPoliciesFile, b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ func (broker *MessageBroker) appendToFile(targetFile string, topicConfig *messag
|
||||||
dir, name := util.FullPath(targetFile).DirAndName()
|
dir, name := util.FullPath(targetFile).DirAndName()
|
||||||
|
|
||||||
// append the chunk
|
// append the chunk
|
||||||
if err := broker.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := broker.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.AppendToEntryRequest{
|
request := &filer_pb.AppendToEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
|
@ -51,7 +51,7 @@ func (broker *MessageBroker) assignAndUpload(topicConfig *messaging_pb.TopicConf
|
||||||
var assignResult = &operation.AssignResult{}
|
var assignResult = &operation.AssignResult{}
|
||||||
|
|
||||||
// assign a volume location
|
// assign a volume location
|
||||||
if err := broker.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := broker.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
assignErr := util.Retry("assignVolume", func() error {
|
assignErr := util.Retry("assignVolume", func() error {
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
|
@ -108,10 +108,10 @@ func (broker *MessageBroker) assignAndUpload(topicConfig *messaging_pb.TopicConf
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&MessageBroker{})
|
var _ = filer_pb.FilerClient(&MessageBroker{})
|
||||||
|
|
||||||
func (broker *MessageBroker) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) (err error) {
|
func (broker *MessageBroker) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) (err error) {
|
||||||
|
|
||||||
for _, filer := range broker.option.Filers {
|
for _, filer := range broker.option.Filers {
|
||||||
if err = pb.WithFilerClient(filer, broker.grpcDialOption, fn); err != nil {
|
if err = pb.WithFilerClient(streamingMode, filer, broker.grpcDialOption, fn); err != nil {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (broker *MessageBroker) FindBroker(c context.Context, request *messaging_pb
|
||||||
targetTopicPartition := fmt.Sprintf(TopicPartitionFmt, request.Namespace, request.Topic, request.Parition)
|
targetTopicPartition := fmt.Sprintf(TopicPartitionFmt, request.Namespace, request.Topic, request.Parition)
|
||||||
|
|
||||||
for _, filer := range broker.option.Filers {
|
for _, filer := range broker.option.Filers {
|
||||||
err := broker.withFilerClient(filer, func(client filer_pb.SeaweedFilerClient) error {
|
err := broker.withFilerClient(false, filer, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.LocateBroker(context.Background(), &filer_pb.LocateBrokerRequest{
|
resp, err := client.LocateBroker(context.Background(), &filer_pb.LocateBrokerRequest{
|
||||||
Resource: targetTopicPartition,
|
Resource: targetTopicPartition,
|
||||||
})
|
})
|
||||||
|
@ -68,7 +68,7 @@ func (broker *MessageBroker) checkFilers() {
|
||||||
found := false
|
found := false
|
||||||
for !found {
|
for !found {
|
||||||
for _, filer := range broker.option.Filers {
|
for _, filer := range broker.option.Filers {
|
||||||
err := broker.withFilerClient(filer, func(client filer_pb.SeaweedFilerClient) error {
|
err := broker.withFilerClient(false, filer, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -93,7 +93,7 @@ func (broker *MessageBroker) checkFilers() {
|
||||||
found = false
|
found = false
|
||||||
for !found {
|
for !found {
|
||||||
for _, master := range masters {
|
for _, master := range masters {
|
||||||
err := broker.withMasterClient(master, func(client master_pb.SeaweedClient) error {
|
err := broker.withMasterClient(false, master, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
ClientType: cluster.FilerType,
|
ClientType: cluster.FilerType,
|
||||||
})
|
})
|
||||||
|
|
|
@ -49,7 +49,7 @@ func (broker *MessageBroker) keepConnectedToOneFiler() {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
for _, filer := range broker.option.Filers {
|
for _, filer := range broker.option.Filers {
|
||||||
broker.withFilerClient(filer, func(client filer_pb.SeaweedFilerClient) error {
|
broker.withFilerClient(false, filer, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
stream, err := client.KeepConnected(ctx)
|
stream, err := client.KeepConnected(ctx)
|
||||||
|
@ -101,15 +101,15 @@ func (broker *MessageBroker) keepConnectedToOneFiler() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (broker *MessageBroker) withFilerClient(filer pb.ServerAddress, fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (broker *MessageBroker) withFilerClient(streamingMode bool, filer pb.ServerAddress, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithFilerClient(filer, broker.grpcDialOption, fn)
|
return pb.WithFilerClient(streamingMode, filer, broker.grpcDialOption, fn)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (broker *MessageBroker) withMasterClient(master pb.ServerAddress, fn func(client master_pb.SeaweedClient) error) error {
|
func (broker *MessageBroker) withMasterClient(streamingMode bool, master pb.ServerAddress, fn func(client master_pb.SeaweedClient) error) error {
|
||||||
|
|
||||||
return pb.WithMasterClient(master, broker.grpcDialOption, func(client master_pb.SeaweedClient) error {
|
return pb.WithMasterClient(streamingMode, master, broker.grpcDialOption, func(client master_pb.SeaweedClient) error {
|
||||||
return fn(client)
|
return fn(client)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ func Assign(masterFn GetMasterFn, grpcDialOption grpc.DialOption, primaryRequest
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lastError = WithMasterServerClient(masterFn(), grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
lastError = WithMasterServerClient(false, masterFn(), grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
||||||
|
|
||||||
req := &master_pb.AssignRequest{
|
req := &master_pb.AssignRequest{
|
||||||
Count: request.Count,
|
Count: request.Count,
|
||||||
|
@ -105,7 +105,7 @@ func Assign(masterFn GetMasterFn, grpcDialOption grpc.DialOption, primaryRequest
|
||||||
|
|
||||||
func LookupJwt(master pb.ServerAddress, grpcDialOption grpc.DialOption, fileId string) (token security.EncodedJwt) {
|
func LookupJwt(master pb.ServerAddress, grpcDialOption grpc.DialOption, fileId string) (token security.EncodedJwt) {
|
||||||
|
|
||||||
WithMasterServerClient(master, grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
WithMasterServerClient(false, master, grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
||||||
|
|
||||||
resp, grpcErr := masterClient.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{
|
resp, grpcErr := masterClient.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{
|
||||||
VolumeOrFileIds: []string{fileId},
|
VolumeOrFileIds: []string{fileId},
|
||||||
|
|
|
@ -123,7 +123,7 @@ func DeleteFilesWithLookupVolumeId(grpcDialOption grpc.DialOption, fileIds []str
|
||||||
// DeleteFilesAtOneVolumeServer deletes a list of files that is on one volume server via gRpc
|
// DeleteFilesAtOneVolumeServer deletes a list of files that is on one volume server via gRpc
|
||||||
func DeleteFilesAtOneVolumeServer(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fileIds []string, includeCookie bool) (ret []*volume_server_pb.DeleteResult, err error) {
|
func DeleteFilesAtOneVolumeServer(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fileIds []string, includeCookie bool) (ret []*volume_server_pb.DeleteResult, err error) {
|
||||||
|
|
||||||
err = WithVolumeServerClient(volumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = WithVolumeServerClient(false, volumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
req := &volume_server_pb.BatchDeleteRequest{
|
req := &volume_server_pb.BatchDeleteRequest{
|
||||||
FileIds: fileIds,
|
FileIds: fileIds,
|
||||||
|
|
|
@ -8,18 +8,18 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WithVolumeServerClient(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
|
func WithVolumeServerClient(streamingMode bool, volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(volume_server_pb.VolumeServerClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := volume_server_pb.NewVolumeServerClient(grpcConnection)
|
client := volume_server_pb.NewVolumeServerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, volumeServer.ToGrpcAddress(), grpcDialOption)
|
}, volumeServer.ToGrpcAddress(), grpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMasterServerClient(masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
|
func WithMasterServerClient(streamingMode bool, masterServer pb.ServerAddress, grpcDialOption grpc.DialOption, fn func(masterClient master_pb.SeaweedClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := master_pb.NewSeaweedClient(grpcConnection)
|
client := master_pb.NewSeaweedClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, masterServer.ToGrpcAddress(), grpcDialOption)
|
}, masterServer.ToGrpcAddress(), grpcDialOption)
|
||||||
|
|
|
@ -79,7 +79,7 @@ func LookupVolumeIds(masterFn GetMasterFn, grpcDialOption grpc.DialOption, vids
|
||||||
|
|
||||||
//only query unknown_vids
|
//only query unknown_vids
|
||||||
|
|
||||||
err := WithMasterServerClient(masterFn(), grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
err := WithMasterServerClient(false, masterFn(), grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
||||||
|
|
||||||
req := &master_pb.LookupVolumeRequest{
|
req := &master_pb.LookupVolumeRequest{
|
||||||
VolumeOrFileIds: unknown_vids,
|
VolumeOrFileIds: unknown_vids,
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
func GetVolumeSyncStatus(server pb.ServerAddress, grpcDialOption grpc.DialOption, vid uint32) (resp *volume_server_pb.VolumeSyncStatusResponse, err error) {
|
func GetVolumeSyncStatus(server pb.ServerAddress, grpcDialOption grpc.DialOption, vid uint32) (resp *volume_server_pb.VolumeSyncStatusResponse, err error) {
|
||||||
|
|
||||||
WithVolumeServerClient(server, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
WithVolumeServerClient(false, server, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
resp, err = client.VolumeSyncStatus(context.Background(), &volume_server_pb.VolumeSyncStatusRequest{
|
resp, err = client.VolumeSyncStatus(context.Background(), &volume_server_pb.VolumeSyncStatusRequest{
|
||||||
VolumeId: vid,
|
VolumeId: vid,
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TailVolume(masterFn GetMasterFn, grpcDialOption grpc.DialOption, vid needle
|
||||||
}
|
}
|
||||||
|
|
||||||
func TailVolumeFromSource(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, idleTimeoutSeconds int, fn func(n *needle.Needle) error) error {
|
func TailVolumeFromSource(volumeServer pb.ServerAddress, grpcDialOption grpc.DialOption, vid needle.VolumeId, sinceNs uint64, idleTimeoutSeconds int, fn func(n *needle.Needle) error) error {
|
||||||
return WithVolumeServerClient(volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
return WithVolumeServerClient(true, volumeServer, grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
type FilerClient interface {
|
type FilerClient interface {
|
||||||
WithFilerClient(fn func(SeaweedFilerClient) error) error
|
WithFilerClient(streamingMode bool, fn func(SeaweedFilerClient) error) error
|
||||||
AdjustedUrl(location *Location) string
|
AdjustedUrl(location *Location) string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func GetEntry(filerClient FilerClient, fullFilePath util.FullPath) (entry *Entry
|
||||||
|
|
||||||
dir, name := fullFilePath.DirAndName()
|
dir, name := fullFilePath.DirAndName()
|
||||||
|
|
||||||
err = filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &LookupDirectoryEntryRequest{
|
request := &LookupDirectoryEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
|
@ -83,13 +83,13 @@ func ReadDirAllEntries(filerClient FilerClient, fullDirPath util.FullPath, prefi
|
||||||
}
|
}
|
||||||
|
|
||||||
func List(filerClient FilerClient, parentDirectoryPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {
|
func List(filerClient FilerClient, parentDirectoryPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
return doSeaweedList(client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)
|
return doSeaweedList(client, util.FullPath(parentDirectoryPath), prefix, fn, startFrom, inclusive, limit)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func doList(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {
|
func doList(filerClient FilerClient, fullDirPath util.FullPath, prefix string, fn EachEntryFunciton, startFrom string, inclusive bool, limit uint32) (err error) {
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
return doSeaweedList(client, fullDirPath, prefix, fn, startFrom, inclusive, limit)
|
return doSeaweedList(client, fullDirPath, prefix, fn, startFrom, inclusive, limit)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ func doSeaweedList(client SeaweedFilerClient, fullDirPath util.FullPath, prefix
|
||||||
|
|
||||||
func Exists(filerClient FilerClient, parentDirectoryPath string, entryName string, isDirectory bool) (exists bool, err error) {
|
func Exists(filerClient FilerClient, parentDirectoryPath string, entryName string, isDirectory bool) (exists bool, err error) {
|
||||||
|
|
||||||
err = filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &LookupDirectoryEntryRequest{
|
request := &LookupDirectoryEntryRequest{
|
||||||
Directory: parentDirectoryPath,
|
Directory: parentDirectoryPath,
|
||||||
|
@ -185,7 +185,7 @@ func Exists(filerClient FilerClient, parentDirectoryPath string, entryName strin
|
||||||
|
|
||||||
func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string, entry *Entry) (err error) {
|
func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string, entry *Entry) (err error) {
|
||||||
|
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &UpdateEntryRequest{
|
request := &UpdateEntryRequest{
|
||||||
Directory: parentDirectoryPath,
|
Directory: parentDirectoryPath,
|
||||||
|
@ -204,7 +204,7 @@ func Touch(filerClient FilerClient, parentDirectoryPath string, entryName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func Mkdir(filerClient FilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {
|
func Mkdir(filerClient FilerClient, parentDirectoryPath string, dirName string, fn func(entry *Entry)) error {
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
return DoMkdir(client, parentDirectoryPath, dirName, fn)
|
return DoMkdir(client, parentDirectoryPath, dirName, fn)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ func DoMkdir(client SeaweedFilerClient, parentDirectoryPath string, dirName stri
|
||||||
}
|
}
|
||||||
|
|
||||||
func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk, fn func(entry *Entry)) error {
|
func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string, chunks []*FileChunk, fn func(entry *Entry)) error {
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
|
|
||||||
entry := &Entry{
|
entry := &Entry{
|
||||||
Name: fileName,
|
Name: fileName,
|
||||||
|
@ -276,7 +276,7 @@ func MkFile(filerClient FilerClient, parentDirectoryPath string, fileName string
|
||||||
}
|
}
|
||||||
|
|
||||||
func Remove(filerClient FilerClient, parentDirectoryPath, name string, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster bool, signatures []int32) error {
|
func Remove(filerClient FilerClient, parentDirectoryPath, name string, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster bool, signatures []int32) error {
|
||||||
return filerClient.WithFilerClient(func(client SeaweedFilerClient) error {
|
return filerClient.WithFilerClient(false, func(client SeaweedFilerClient) error {
|
||||||
return DoRemove(client, parentDirectoryPath, name, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster, signatures)
|
return DoRemove(client, parentDirectoryPath, name, isDeleteData, isRecursive, ignoreRecursiveErr, isFromOtherCluster, signatures)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ func FollowMetadata(filerAddress ServerAddress, grpcDialOption grpc.DialOption,
|
||||||
pathPrefix string, additionalPathPrefixes []string, lastTsNs int64, selfSignature int32,
|
pathPrefix string, additionalPathPrefixes []string, lastTsNs int64, selfSignature int32,
|
||||||
processEventFn ProcessMetadataFunc, fatalOnError bool) error {
|
processEventFn ProcessMetadataFunc, fatalOnError bool) error {
|
||||||
|
|
||||||
err := WithFilerClient(filerAddress, grpcDialOption, makeFunc(clientName,
|
err := WithFilerClient(true, filerAddress, grpcDialOption, makeFunc(clientName,
|
||||||
pathPrefix, additionalPathPrefixes, &lastTsNs, selfSignature, processEventFn, fatalOnError))
|
pathPrefix, additionalPathPrefixes, &lastTsNs, selfSignature, processEventFn, fatalOnError))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("subscribing filer meta change: %v", err)
|
return fmt.Errorf("subscribing filer meta change: %v", err)
|
||||||
|
@ -28,7 +28,7 @@ func WithFilerClientFollowMetadata(filerClient filer_pb.FilerClient,
|
||||||
clientName string, pathPrefix string, lastTsNs *int64, selfSignature int32,
|
clientName string, pathPrefix string, lastTsNs *int64, selfSignature int32,
|
||||||
processEventFn ProcessMetadataFunc, fatalOnError bool) error {
|
processEventFn ProcessMetadataFunc, fatalOnError bool) error {
|
||||||
|
|
||||||
err := filerClient.WithFilerClient(makeFunc(clientName,
|
err := filerClient.WithFilerClient(true, makeFunc(clientName,
|
||||||
pathPrefix, nil, lastTsNs, selfSignature, processEventFn, fatalOnError))
|
pathPrefix, nil, lastTsNs, selfSignature, processEventFn, fatalOnError))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("subscribing filer meta change: %v", err)
|
return fmt.Errorf("subscribing filer meta change: %v", err)
|
||||||
|
|
|
@ -97,7 +97,8 @@ func getOrCreateConnection(address string, opts ...grpc.DialOption) (*versionedG
|
||||||
return existingConnection, nil
|
return existingConnection, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
grpcConnection, err := GrpcDial(context.Background(), address, opts...)
|
ctx := context.Background()
|
||||||
|
grpcConnection, err := GrpcDial(ctx, address, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("fail to dial %s: %v", address, err)
|
return nil, fmt.Errorf("fail to dial %s: %v", address, err)
|
||||||
}
|
}
|
||||||
|
@ -112,8 +113,10 @@ func getOrCreateConnection(address string, opts ...grpc.DialOption) (*versionedG
|
||||||
return vgc, nil
|
return vgc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithCachedGrpcClient(fn func(*grpc.ClientConn) error, address string, opts ...grpc.DialOption) error {
|
// WithGrpcClient In streamingMode, always use a fresh connection. Otherwise, try to reuse an existing connection.
|
||||||
|
func WithGrpcClient(streamingMode bool, fn func(*grpc.ClientConn) error, address string, opts ...grpc.DialOption) error {
|
||||||
|
|
||||||
|
if !streamingMode {
|
||||||
vgc, err := getOrCreateConnection(address, opts...)
|
vgc, err := getOrCreateConnection(address, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("getOrCreateConnection %s: %v", address, err)
|
return fmt.Errorf("getOrCreateConnection %s: %v", address, err)
|
||||||
|
@ -132,8 +135,20 @@ func WithCachedGrpcClient(fn func(*grpc.ClientConn) error, address string, opts
|
||||||
grpcClientsLock.Unlock()
|
grpcClientsLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return executionErr
|
return executionErr
|
||||||
|
} else {
|
||||||
|
grpcConnection, err := GrpcDial(context.Background(), address, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("fail to dial %s: %v", address, err)
|
||||||
|
}
|
||||||
|
defer grpcConnection.Close()
|
||||||
|
executionErr := fn(grpcConnection)
|
||||||
|
if executionErr != nil {
|
||||||
|
return executionErr
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseServerAddress(server string, deltaPort int) (newServerAddress string, err error) {
|
func ParseServerAddress(server string, deltaPort int) (newServerAddress string, err error) {
|
||||||
|
@ -184,18 +199,18 @@ func GrpcAddressToServerAddress(grpcAddress string) (serverAddress string) {
|
||||||
return util.JoinHostPort(host, port)
|
return util.JoinHostPort(host, port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithMasterClient(master ServerAddress, grpcDialOption grpc.DialOption, fn func(client master_pb.SeaweedClient) error) error {
|
func WithMasterClient(streamingMode bool, master ServerAddress, grpcDialOption grpc.DialOption, fn func(client master_pb.SeaweedClient) error) error {
|
||||||
return WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := master_pb.NewSeaweedClient(grpcConnection)
|
client := master_pb.NewSeaweedClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, master.ToGrpcAddress(), grpcDialOption)
|
}, master.ToGrpcAddress(), grpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithOneOfGrpcMasterClients(masterGrpcAddresses []ServerAddress, grpcDialOption grpc.DialOption, fn func(client master_pb.SeaweedClient) error) (err error) {
|
func WithOneOfGrpcMasterClients(streamingMode bool, masterGrpcAddresses []ServerAddress, grpcDialOption grpc.DialOption, fn func(client master_pb.SeaweedClient) error) (err error) {
|
||||||
|
|
||||||
for _, masterGrpcAddress := range masterGrpcAddresses {
|
for _, masterGrpcAddress := range masterGrpcAddresses {
|
||||||
err = WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
err = WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := master_pb.NewSeaweedClient(grpcConnection)
|
client := master_pb.NewSeaweedClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, masterGrpcAddress.ToGrpcAddress(), grpcDialOption)
|
}, masterGrpcAddress.ToGrpcAddress(), grpcDialOption)
|
||||||
|
@ -207,34 +222,34 @@ func WithOneOfGrpcMasterClients(masterGrpcAddresses []ServerAddress, grpcDialOpt
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithBrokerGrpcClient(brokerGrpcAddress string, grpcDialOption grpc.DialOption, fn func(client messaging_pb.SeaweedMessagingClient) error) error {
|
func WithBrokerGrpcClient(streamingMode bool, brokerGrpcAddress string, grpcDialOption grpc.DialOption, fn func(client messaging_pb.SeaweedMessagingClient) error) error {
|
||||||
|
|
||||||
return WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := messaging_pb.NewSeaweedMessagingClient(grpcConnection)
|
client := messaging_pb.NewSeaweedMessagingClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, brokerGrpcAddress, grpcDialOption)
|
}, brokerGrpcAddress, grpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithFilerClient(filer ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) error {
|
func WithFilerClient(streamingMode bool, filer ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return WithGrpcFilerClient(filer, grpcDialOption, fn)
|
return WithGrpcFilerClient(streamingMode, filer, grpcDialOption, fn)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithGrpcFilerClient(filerGrpcAddress ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) error {
|
func WithGrpcFilerClient(streamingMode bool, filerGrpcAddress ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, filerGrpcAddress.ToGrpcAddress(), grpcDialOption)
|
}, filerGrpcAddress.ToGrpcAddress(), grpcDialOption)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithOneOfGrpcFilerClients(filerAddresses []ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) (err error) {
|
func WithOneOfGrpcFilerClients(streamingMode bool, filerAddresses []ServerAddress, grpcDialOption grpc.DialOption, fn func(client filer_pb.SeaweedFilerClient) error) (err error) {
|
||||||
|
|
||||||
for _, filerAddress := range filerAddresses {
|
for _, filerAddress := range filerAddresses {
|
||||||
err = WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
err = WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, filerAddress.ToGrpcAddress(), grpcDialOption)
|
}, filerAddress.ToGrpcAddress(), grpcDialOption)
|
||||||
|
|
|
@ -17,7 +17,7 @@ func GetSyncOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, dir s
|
||||||
|
|
||||||
dirHash := uint32(util.HashStringToLong(dir))
|
dirHash := uint32(util.HashStringToLong(dir))
|
||||||
|
|
||||||
readErr = pb.WithFilerClient(filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
readErr = pb.WithFilerClient(false, filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
syncKey := []byte(SyncKeyPrefix + "____")
|
syncKey := []byte(SyncKeyPrefix + "____")
|
||||||
util.Uint32toBytes(syncKey[len(SyncKeyPrefix):len(SyncKeyPrefix)+4], dirHash)
|
util.Uint32toBytes(syncKey[len(SyncKeyPrefix):len(SyncKeyPrefix)+4], dirHash)
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func SetSyncOffset(grpcDialOption grpc.DialOption, filer pb.ServerAddress, dir s
|
||||||
|
|
||||||
dirHash := uint32(util.HashStringToLong(dir))
|
dirHash := uint32(util.HashStringToLong(dir))
|
||||||
|
|
||||||
return pb.WithFilerClient(filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
return pb.WithFilerClient(false, filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
syncKey := []byte(SyncKeyPrefix + "____")
|
syncKey := []byte(SyncKeyPrefix + "____")
|
||||||
util.Uint32toBytes(syncKey[len(SyncKeyPrefix):len(SyncKeyPrefix)+4], dirHash)
|
util.Uint32toBytes(syncKey[len(SyncKeyPrefix):len(SyncKeyPrefix)+4], dirHash)
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (r *Replicator) Replicate(ctx context.Context, key string, message *filer_p
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadFilerSignature(grpcDialOption grpc.DialOption, filer pb.ServerAddress) (filerSignature int32, readErr error) {
|
func ReadFilerSignature(grpcDialOption grpc.DialOption, filer pb.ServerAddress) (filerSignature int32, readErr error) {
|
||||||
if readErr = pb.WithFilerClient(filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
if readErr = pb.WithFilerClient(false, filer, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{}); err != nil {
|
if resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{}); err != nil {
|
||||||
return fmt.Errorf("GetFilerConfiguration %s: %v", filer, err)
|
return fmt.Errorf("GetFilerConfiguration %s: %v", filer, err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -70,7 +70,7 @@ func (fs *FilerSink) fetchAndWrite(sourceChunk *filer_pb.FileChunk, path string)
|
||||||
var host string
|
var host string
|
||||||
var auth security.EncodedJwt
|
var auth security.EncodedJwt
|
||||||
|
|
||||||
if err := fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return util.Retry("assignVolume", func() error {
|
return util.Retry("assignVolume", func() error {
|
||||||
request := &filer_pb.AssignVolumeRequest{
|
request := &filer_pb.AssignVolumeRequest{
|
||||||
Count: 1,
|
Count: 1,
|
||||||
|
@ -131,9 +131,9 @@ func (fs *FilerSink) fetchAndWrite(sourceChunk *filer_pb.FileChunk, path string)
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&FilerSink{})
|
var _ = filer_pb.FilerClient(&FilerSink{})
|
||||||
|
|
||||||
func (fs *FilerSink) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (fs *FilerSink) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, fs.grpcAddress, fs.grpcDialOption)
|
}, fs.grpcAddress, fs.grpcDialOption)
|
||||||
|
|
|
@ -100,7 +100,7 @@ func (fs *FilerSink) DeleteEntry(key string, isDirectory, deleteIncludeChunks bo
|
||||||
|
|
||||||
func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry, signatures []int32) error {
|
func (fs *FilerSink) CreateEntry(key string, entry *filer_pb.Entry, signatures []int32) error {
|
||||||
|
|
||||||
return fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
dir, name := util.FullPath(key).DirAndName()
|
dir, name := util.FullPath(key).DirAndName()
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent
|
||||||
|
|
||||||
// read existing entry
|
// read existing entry
|
||||||
var existingEntry *filer_pb.Entry
|
var existingEntry *filer_pb.Entry
|
||||||
err = fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
request := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
|
@ -211,7 +211,7 @@ func (fs *FilerSink) UpdateEntry(key string, oldEntry *filer_pb.Entry, newParent
|
||||||
}
|
}
|
||||||
|
|
||||||
// save updated meta data
|
// save updated meta data
|
||||||
return true, fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return true, fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.UpdateEntryRequest{
|
request := &filer_pb.UpdateEntryRequest{
|
||||||
Directory: newParentPath,
|
Directory: newParentPath,
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (fs *FilerSource) LookupFileId(part string) (fileUrls []string, err error)
|
||||||
|
|
||||||
vid := volumeId(part)
|
vid := volumeId(part)
|
||||||
|
|
||||||
err = fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
resp, err := client.LookupVolume(context.Background(), &filer_pb.LookupVolumeRequest{
|
||||||
VolumeIds: []string{vid},
|
VolumeIds: []string{vid},
|
||||||
|
@ -118,9 +118,9 @@ func (fs *FilerSource) ReadPart(fileId string) (filename string, header http.Hea
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&FilerSource{})
|
var _ = filer_pb.FilerClient(&FilerSource{})
|
||||||
|
|
||||||
func (fs *FilerSource) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (fs *FilerSource) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, fs.grpcAddress, fs.grpcDialOption)
|
}, fs.grpcAddress, fs.grpcDialOption)
|
||||||
|
|
|
@ -84,7 +84,7 @@ func NewIdentityAccessManagement(option *S3ApiServerOption) *IdentityAccessManag
|
||||||
|
|
||||||
func (iam *IdentityAccessManagement) loadS3ApiConfigurationFromFiler(option *S3ApiServerOption) (err error) {
|
func (iam *IdentityAccessManagement) loadS3ApiConfigurationFromFiler(option *S3ApiServerOption) (err error) {
|
||||||
var content []byte
|
var content []byte
|
||||||
err = pb.WithFilerClient(option.Filer, option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithFilerClient(false, option.Filer, option.GrpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
content, err = filer.ReadInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile)
|
content, err = filer.ReadInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile)
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (s3a *S3ApiServer) list(parentDirectoryPath, prefix, startFrom string, incl
|
||||||
|
|
||||||
func (s3a *S3ApiServer) rm(parentDirectoryPath, entryName string, isDeleteData, isRecursive bool) error {
|
func (s3a *S3ApiServer) rm(parentDirectoryPath, entryName string, isDeleteData, isRecursive bool) error {
|
||||||
|
|
||||||
return s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
err := doDeleteEntry(client, parentDirectoryPath, entryName, isDeleteData, isRecursive)
|
err := doDeleteEntry(client, parentDirectoryPath, entryName, isDeleteData, isRecursive)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -13,7 +13,7 @@ const (
|
||||||
|
|
||||||
func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {
|
func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (tags map[string]string, err error) {
|
||||||
|
|
||||||
err = s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parentDirectoryPath,
|
Directory: parentDirectoryPath,
|
||||||
|
@ -35,7 +35,7 @@ func (s3a *S3ApiServer) getTags(parentDirectoryPath string, entryName string) (t
|
||||||
|
|
||||||
func (s3a *S3ApiServer) setTags(parentDirectoryPath string, entryName string, tags map[string]string) (err error) {
|
func (s3a *S3ApiServer) setTags(parentDirectoryPath string, entryName string, tags map[string]string) (err error) {
|
||||||
|
|
||||||
return s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parentDirectoryPath,
|
Directory: parentDirectoryPath,
|
||||||
|
@ -71,7 +71,7 @@ func (s3a *S3ApiServer) setTags(parentDirectoryPath string, entryName string, ta
|
||||||
|
|
||||||
func (s3a *S3ApiServer) rmTags(parentDirectoryPath string, entryName string) (err error) {
|
func (s3a *S3ApiServer) rmTags(parentDirectoryPath string, entryName string) (err error) {
|
||||||
|
|
||||||
return s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
resp, err := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parentDirectoryPath,
|
Directory: parentDirectoryPath,
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (s3a *S3ApiServer) PutBucketHandler(w http.ResponseWriter, r *http.Request)
|
||||||
|
|
||||||
// avoid duplicated buckets
|
// avoid duplicated buckets
|
||||||
errCode := s3err.ErrNone
|
errCode := s3err.ErrNone
|
||||||
if err := s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if resp, err := client.CollectionList(context.Background(), &filer_pb.CollectionListRequest{
|
if resp, err := client.CollectionList(context.Background(), &filer_pb.CollectionListRequest{
|
||||||
IncludeEcVolumes: true,
|
IncludeEcVolumes: true,
|
||||||
IncludeNormalVolumes: true,
|
IncludeNormalVolumes: true,
|
||||||
|
@ -146,7 +146,7 @@ func (s3a *S3ApiServer) DeleteBucketHandler(w http.ResponseWriter, r *http.Reque
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err := s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
// delete collection
|
// delete collection
|
||||||
deleteCollectionRequest := &filer_pb.DeleteCollectionRequest{
|
deleteCollectionRequest := &filer_pb.DeleteCollectionRequest{
|
||||||
|
|
|
@ -13,9 +13,9 @@ import (
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&S3ApiServer{})
|
var _ = filer_pb.FilerClient(&S3ApiServer{})
|
||||||
|
|
||||||
func (s3a *S3ApiServer) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (s3a *S3ApiServer) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, s3a.option.Filer.ToGrpcAddress(), s3a.option.GrpcDialOption)
|
}, s3a.option.Filer.ToGrpcAddress(), s3a.option.GrpcDialOption)
|
||||||
|
|
|
@ -233,7 +233,7 @@ func (s3a *S3ApiServer) DeleteMultipleObjectsHandler(w http.ResponseWriter, r *h
|
||||||
if s3err.Logger != nil {
|
if s3err.Logger != nil {
|
||||||
auditLog = s3err.GetAccessLog(r, http.StatusNoContent, s3err.ErrNone)
|
auditLog = s3err.GetAccessLog(r, http.StatusNoContent, s3err.ErrNone)
|
||||||
}
|
}
|
||||||
s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
// delete file entries
|
// delete file entries
|
||||||
for _, object := range deleteObjects.Objects {
|
for _, object := range deleteObjects.Objects {
|
||||||
|
|
|
@ -146,7 +146,7 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
|
||||||
var nextMarker string
|
var nextMarker string
|
||||||
|
|
||||||
// check filer
|
// check filer
|
||||||
err = s3a.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
_, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) {
|
_, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) {
|
||||||
if entry.IsDirectory {
|
if entry.IsDirectory {
|
||||||
|
|
|
@ -327,7 +327,7 @@ func (fs *FilerServer) CollectionList(ctx context.Context, req *filer_pb.Collect
|
||||||
glog.V(4).Infof("CollectionList %v", req)
|
glog.V(4).Infof("CollectionList %v", req)
|
||||||
resp = &filer_pb.CollectionListResponse{}
|
resp = &filer_pb.CollectionListResponse{}
|
||||||
|
|
||||||
err = fs.filer.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = fs.filer.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
masterResp, err := client.CollectionList(context.Background(), &master_pb.CollectionListRequest{
|
masterResp, err := client.CollectionList(context.Background(), &master_pb.CollectionListRequest{
|
||||||
IncludeNormalVolumes: req.IncludeNormalVolumes,
|
IncludeNormalVolumes: req.IncludeNormalVolumes,
|
||||||
IncludeEcVolumes: req.IncludeEcVolumes,
|
IncludeEcVolumes: req.IncludeEcVolumes,
|
||||||
|
@ -348,7 +348,7 @@ func (fs *FilerServer) DeleteCollection(ctx context.Context, req *filer_pb.Delet
|
||||||
|
|
||||||
glog.V(4).Infof("DeleteCollection %v", req)
|
glog.V(4).Infof("DeleteCollection %v", req)
|
||||||
|
|
||||||
err = fs.filer.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = fs.filer.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
_, err := client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
_, err := client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
||||||
Name: req.GetCollection(),
|
Name: req.GetCollection(),
|
||||||
})
|
})
|
||||||
|
@ -362,7 +362,7 @@ func (fs *FilerServer) Statistics(ctx context.Context, req *filer_pb.StatisticsR
|
||||||
|
|
||||||
var output *master_pb.StatisticsResponse
|
var output *master_pb.StatisticsResponse
|
||||||
|
|
||||||
err = fs.filer.MasterClient.WithClient(func(masterClient master_pb.SeaweedClient) error {
|
err = fs.filer.MasterClient.WithClient(false, func(masterClient master_pb.SeaweedClient) error {
|
||||||
grpcResponse, grpcErr := masterClient.Statistics(context.Background(), &master_pb.StatisticsRequest{
|
grpcResponse, grpcErr := masterClient.Statistics(context.Background(), &master_pb.StatisticsRequest{
|
||||||
Replication: req.Replication,
|
Replication: req.Replication,
|
||||||
Collection: req.Collection,
|
Collection: req.Collection,
|
||||||
|
|
|
@ -123,7 +123,7 @@ func (fs *FilerServer) CacheRemoteObjectToLocalCluster(ctx context.Context, req
|
||||||
|
|
||||||
// tell filer to tell volume server to download into needles
|
// tell filer to tell volume server to download into needles
|
||||||
assignedServerAddress := pb.NewServerAddressWithGrpcPort(assignResult.Url, assignResult.GrpcPort)
|
assignedServerAddress := pb.NewServerAddressWithGrpcPort(assignResult.Url, assignResult.GrpcPort)
|
||||||
err = operation.WithVolumeServerClient(assignedServerAddress, fs.grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, assignedServerAddress, fs.grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, fetchAndWriteErr := volumeServerClient.FetchAndWriteNeedle(context.Background(), &volume_server_pb.FetchAndWriteNeedleRequest{
|
_, fetchAndWriteErr := volumeServerClient.FetchAndWriteNeedle(context.Background(), &volume_server_pb.FetchAndWriteNeedleRequest{
|
||||||
VolumeId: uint32(fileId.VolumeId),
|
VolumeId: uint32(fileId.VolumeId),
|
||||||
NeedleId: uint64(fileId.Key),
|
NeedleId: uint64(fileId.Key),
|
||||||
|
|
|
@ -165,7 +165,7 @@ func (fs *FilerServer) checkWithMaster() {
|
||||||
isConnected := false
|
isConnected := false
|
||||||
for !isConnected {
|
for !isConnected {
|
||||||
for _, master := range fs.option.Masters {
|
for _, master := range fs.option.Masters {
|
||||||
readErr := operation.WithMasterServerClient(master, fs.grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
readErr := operation.WithMasterServerClient(false, master, fs.grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
||||||
resp, err := masterClient.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
resp, err := masterClient.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get master %s configuration: %v", master, err)
|
return fmt.Errorf("get master %s configuration: %v", master, err)
|
||||||
|
|
|
@ -58,7 +58,7 @@ func (ms *MasterServer) doDeleteNormalCollection(collectionName string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, server := range collection.ListVolumeServers() {
|
for _, server := range collection.ListVolumeServers() {
|
||||||
err := operation.WithVolumeServerClient(server.ServerAddress(), ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, server.ServerAddress(), ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
||||||
Collection: collectionName,
|
Collection: collectionName,
|
||||||
})
|
})
|
||||||
|
@ -78,7 +78,7 @@ func (ms *MasterServer) doDeleteEcCollection(collectionName string) error {
|
||||||
listOfEcServers := ms.Topo.ListEcServersByCollection(collectionName)
|
listOfEcServers := ms.Topo.ListEcServersByCollection(collectionName)
|
||||||
|
|
||||||
for _, server := range listOfEcServers {
|
for _, server := range listOfEcServers {
|
||||||
err := operation.WithVolumeServerClient(server, ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, server, ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
||||||
Collection: collectionName,
|
Collection: collectionName,
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (ms *MasterServer) collectionDeleteHandler(w http.ResponseWriter, r *http.R
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, server := range collection.ListVolumeServers() {
|
for _, server := range collection.ListVolumeServers() {
|
||||||
err := operation.WithVolumeServerClient(server.ServerAddress(), ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, server.ServerAddress(), ms.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
_, deleteErr := client.DeleteCollection(context.Background(), &volume_server_pb.DeleteCollectionRequest{
|
||||||
Collection: collection.Name,
|
Collection: collection.Name,
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,7 +26,7 @@ func (vs *VolumeServer) GetMaster() pb.ServerAddress {
|
||||||
func (vs *VolumeServer) checkWithMaster() (err error) {
|
func (vs *VolumeServer) checkWithMaster() (err error) {
|
||||||
for {
|
for {
|
||||||
for _, master := range vs.SeedMasterNodes {
|
for _, master := range vs.SeedMasterNodes {
|
||||||
err = operation.WithMasterServerClient(master, vs.grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
err = operation.WithMasterServerClient(false, master, vs.grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
|
||||||
resp, err := masterClient.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
resp, err := masterClient.GetMasterConfiguration(context.Background(), &master_pb.GetMasterConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("get master %s configuration: %v", master, err)
|
return fmt.Errorf("get master %s configuration: %v", master, err)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (vs *VolumeServer) VolumeCopy(req *volume_server_pb.VolumeCopyRequest, stre
|
||||||
// confirm size and timestamp
|
// confirm size and timestamp
|
||||||
var volFileInfoResp *volume_server_pb.ReadVolumeFileStatusResponse
|
var volFileInfoResp *volume_server_pb.ReadVolumeFileStatusResponse
|
||||||
var dataBaseFileName, indexBaseFileName, idxFileName, datFileName string
|
var dataBaseFileName, indexBaseFileName, idxFileName, datFileName string
|
||||||
err := operation.WithVolumeServerClient(pb.ServerAddress(req.SourceDataNode), vs.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(true, pb.ServerAddress(req.SourceDataNode), vs.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
var err error
|
var err error
|
||||||
volFileInfoResp, err = client.ReadVolumeFileStatus(context.Background(),
|
volFileInfoResp, err = client.ReadVolumeFileStatus(context.Background(),
|
||||||
&volume_server_pb.ReadVolumeFileStatusRequest{
|
&volume_server_pb.ReadVolumeFileStatusRequest{
|
||||||
|
|
|
@ -126,7 +126,7 @@ func (vs *VolumeServer) VolumeEcShardsCopy(ctx context.Context, req *volume_serv
|
||||||
dataBaseFileName := storage.VolumeFileName(location.Directory, req.Collection, int(req.VolumeId))
|
dataBaseFileName := storage.VolumeFileName(location.Directory, req.Collection, int(req.VolumeId))
|
||||||
indexBaseFileName := storage.VolumeFileName(location.IdxDirectory, req.Collection, int(req.VolumeId))
|
indexBaseFileName := storage.VolumeFileName(location.IdxDirectory, req.Collection, int(req.VolumeId))
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(pb.ServerAddress(req.SourceDataNode), vs.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(true, pb.ServerAddress(req.SourceDataNode), vs.grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
// copy ec data slices
|
// copy ec data slices
|
||||||
for _, shardId := range req.ShardIds {
|
for _, shardId := range req.ShardIds {
|
||||||
|
|
|
@ -120,9 +120,9 @@ func NewWebDavFileSystem(option *WebDavOption) (webdav.FileSystem, error) {
|
||||||
|
|
||||||
var _ = filer_pb.FilerClient(&WebDavFileSystem{})
|
var _ = filer_pb.FilerClient(&WebDavFileSystem{})
|
||||||
|
|
||||||
func (fs *WebDavFileSystem) WithFilerClient(fn func(filer_pb.SeaweedFilerClient) error) error {
|
func (fs *WebDavFileSystem) WithFilerClient(streamingMode bool, fn func(filer_pb.SeaweedFilerClient) error) error {
|
||||||
|
|
||||||
return pb.WithCachedGrpcClient(func(grpcConnection *grpc.ClientConn) error {
|
return pb.WithGrpcClient(streamingMode, func(grpcConnection *grpc.ClientConn) error {
|
||||||
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
client := filer_pb.NewSeaweedFilerClient(grpcConnection)
|
||||||
return fn(client)
|
return fn(client)
|
||||||
}, fs.option.Filer.ToGrpcAddress(), fs.option.GrpcDialOption)
|
}, fs.option.Filer.ToGrpcAddress(), fs.option.GrpcDialOption)
|
||||||
|
@ -162,7 +162,7 @@ func (fs *WebDavFileSystem) Mkdir(ctx context.Context, fullDirPath string, perm
|
||||||
return os.ErrExist
|
return os.ErrExist
|
||||||
}
|
}
|
||||||
|
|
||||||
return fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
dir, name := util.FullPath(fullDirPath).DirAndName()
|
dir, name := util.FullPath(fullDirPath).DirAndName()
|
||||||
request := &filer_pb.CreateEntryRequest{
|
request := &filer_pb.CreateEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
|
@ -212,7 +212,7 @@ func (fs *WebDavFileSystem) OpenFile(ctx context.Context, fullFilePath string, f
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, name := util.FullPath(fullFilePath).DirAndName()
|
dir, name := util.FullPath(fullFilePath).DirAndName()
|
||||||
err = fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{
|
if err := filer_pb.CreateEntry(client, &filer_pb.CreateEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
Entry: &filer_pb.Entry{
|
Entry: &filer_pb.Entry{
|
||||||
|
@ -315,7 +315,7 @@ func (fs *WebDavFileSystem) Rename(ctx context.Context, oldName, newName string)
|
||||||
oldDir, oldBaseName := util.FullPath(oldName).DirAndName()
|
oldDir, oldBaseName := util.FullPath(oldName).DirAndName()
|
||||||
newDir, newBaseName := util.FullPath(newName).DirAndName()
|
newDir, newBaseName := util.FullPath(newName).DirAndName()
|
||||||
|
|
||||||
return fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.AtomicRenameEntryRequest{
|
request := &filer_pb.AtomicRenameEntryRequest{
|
||||||
OldDirectory: oldDir,
|
OldDirectory: oldDir,
|
||||||
|
@ -375,7 +375,7 @@ func (f *WebDavFile) saveDataAsChunk(reader io.Reader, name string, offset int64
|
||||||
var fileId, host string
|
var fileId, host string
|
||||||
var auth security.EncodedJwt
|
var auth security.EncodedJwt
|
||||||
|
|
||||||
if flushErr := f.fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if flushErr := f.fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ func (f *WebDavFile) Write(buf []byte) (int, error) {
|
||||||
f.entry.Chunks = manifestedChunks
|
f.entry.Chunks = manifestedChunks
|
||||||
}
|
}
|
||||||
|
|
||||||
flushErr := f.fs.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
flushErr := f.fs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
f.entry.Attributes.Mtime = time.Now().Unix()
|
f.entry.Attributes.Mtime = time.Now().Unix()
|
||||||
f.entry.Attributes.Collection = f.collection
|
f.entry.Attributes.Collection = f.collection
|
||||||
f.entry.Attributes.Replication = f.replication
|
f.entry.Attributes.Replication = f.replication
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (c *commandClusterPs) Do(args []string, commandEnv *CommandEnv, writer io.W
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{
|
||||||
ClientType: cluster.FilerType,
|
ClientType: cluster.FilerType,
|
||||||
})
|
})
|
||||||
|
|
|
@ -53,7 +53,7 @@ func (c *commandCollectionDelete) Do(args []string, commandEnv *CommandEnv, writ
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
_, err = client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
_, err = client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
||||||
Name: *collectionName,
|
Name: *collectionName,
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,7 +62,7 @@ func (c *commandCollectionList) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
|
|
||||||
func ListCollectionNames(commandEnv *CommandEnv, includeNormalVolumes, includeEcVolumes bool) (collections []string, err error) {
|
func ListCollectionNames(commandEnv *CommandEnv, includeNormalVolumes, includeEcVolumes bool) (collections []string, err error) {
|
||||||
var resp *master_pb.CollectionListResponse
|
var resp *master_pb.CollectionListResponse
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err = client.CollectionList(context.Background(), &master_pb.CollectionListRequest{
|
resp, err = client.CollectionList(context.Background(), &master_pb.CollectionListRequest{
|
||||||
IncludeNormalVolumes: includeNormalVolumes,
|
IncludeNormalVolumes: includeNormalVolumes,
|
||||||
IncludeEcVolumes: includeEcVolumes,
|
IncludeEcVolumes: includeEcVolumes,
|
||||||
|
|
|
@ -61,7 +61,7 @@ func oneServerCopyAndMountEcShardsFromSource(grpcDialOption grpc.DialOption,
|
||||||
fmt.Printf("allocate %d.%v %s => %s\n", volumeId, shardIdsToCopy, existingLocation, targetServer.info.Id)
|
fmt.Printf("allocate %d.%v %s => %s\n", volumeId, shardIdsToCopy, existingLocation, targetServer.info.Id)
|
||||||
|
|
||||||
targetAddress := pb.NewServerAddressFromDataNode(targetServer.info)
|
targetAddress := pb.NewServerAddressFromDataNode(targetServer.info)
|
||||||
err = operation.WithVolumeServerClient(targetAddress, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, targetAddress, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
if targetAddress != existingLocation {
|
if targetAddress != existingLocation {
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ func sourceServerDeleteEcShards(grpcDialOption grpc.DialOption, collection strin
|
||||||
|
|
||||||
fmt.Printf("delete %d.%v from %s\n", volumeId, toBeDeletedShardIds, sourceLocation)
|
fmt.Printf("delete %d.%v from %s\n", volumeId, toBeDeletedShardIds, sourceLocation)
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := volumeServerClient.VolumeEcShardsDelete(context.Background(), &volume_server_pb.VolumeEcShardsDeleteRequest{
|
_, deleteErr := volumeServerClient.VolumeEcShardsDelete(context.Background(), &volume_server_pb.VolumeEcShardsDeleteRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
@ -256,7 +256,7 @@ func unmountEcShards(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, s
|
||||||
|
|
||||||
fmt.Printf("unmount %d.%v from %s\n", volumeId, toBeUnmountedhardIds, sourceLocation)
|
fmt.Printf("unmount %d.%v from %s\n", volumeId, toBeUnmountedhardIds, sourceLocation)
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := volumeServerClient.VolumeEcShardsUnmount(context.Background(), &volume_server_pb.VolumeEcShardsUnmountRequest{
|
_, deleteErr := volumeServerClient.VolumeEcShardsUnmount(context.Background(), &volume_server_pb.VolumeEcShardsUnmountRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
ShardIds: toBeUnmountedhardIds,
|
ShardIds: toBeUnmountedhardIds,
|
||||||
|
@ -269,7 +269,7 @@ func mountEcShards(grpcDialOption grpc.DialOption, collection string, volumeId n
|
||||||
|
|
||||||
fmt.Printf("mount %d.%v on %s\n", volumeId, toBeMountedhardIds, sourceLocation)
|
fmt.Printf("mount %d.%v on %s\n", volumeId, toBeMountedhardIds, sourceLocation)
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, mountErr := volumeServerClient.VolumeEcShardsMount(context.Background(), &volume_server_pb.VolumeEcShardsMountRequest{
|
_, mountErr := volumeServerClient.VolumeEcShardsMount(context.Background(), &volume_server_pb.VolumeEcShardsMountRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
|
|
@ -116,7 +116,7 @@ func doEcDecode(commandEnv *CommandEnv, topoInfo *master_pb.TopologyInfo, collec
|
||||||
func mountVolumeAndDeleteEcShards(grpcDialOption grpc.DialOption, collection string, targetNodeLocation pb.ServerAddress, nodeToEcIndexBits map[pb.ServerAddress]erasure_coding.ShardBits, vid needle.VolumeId) error {
|
func mountVolumeAndDeleteEcShards(grpcDialOption grpc.DialOption, collection string, targetNodeLocation pb.ServerAddress, nodeToEcIndexBits map[pb.ServerAddress]erasure_coding.ShardBits, vid needle.VolumeId) error {
|
||||||
|
|
||||||
// mount volume
|
// mount volume
|
||||||
if err := operation.WithVolumeServerClient(targetNodeLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
if err := operation.WithVolumeServerClient(false, targetNodeLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, mountErr := volumeServerClient.VolumeMount(context.Background(), &volume_server_pb.VolumeMountRequest{
|
_, mountErr := volumeServerClient.VolumeMount(context.Background(), &volume_server_pb.VolumeMountRequest{
|
||||||
VolumeId: uint32(vid),
|
VolumeId: uint32(vid),
|
||||||
})
|
})
|
||||||
|
@ -149,7 +149,7 @@ func generateNormalVolume(grpcDialOption grpc.DialOption, vid needle.VolumeId, c
|
||||||
|
|
||||||
fmt.Printf("generateNormalVolume from ec volume %d on %s\n", vid, sourceVolumeServer)
|
fmt.Printf("generateNormalVolume from ec volume %d on %s\n", vid, sourceVolumeServer)
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, genErr := volumeServerClient.VolumeEcShardsToVolume(context.Background(), &volume_server_pb.VolumeEcShardsToVolumeRequest{
|
_, genErr := volumeServerClient.VolumeEcShardsToVolume(context.Background(), &volume_server_pb.VolumeEcShardsToVolumeRequest{
|
||||||
VolumeId: uint32(vid),
|
VolumeId: uint32(vid),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
@ -187,7 +187,7 @@ func collectEcShards(commandEnv *CommandEnv, nodeToEcIndexBits map[pb.ServerAddr
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = operation.WithVolumeServerClient(targetNodeLocation, commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, targetNodeLocation, commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
fmt.Printf("copy %d.%v %s => %s\n", vid, needToCopyEcIndexBits.ShardIds(), loc, targetNodeLocation)
|
fmt.Printf("copy %d.%v %s => %s\n", vid, needToCopyEcIndexBits.ShardIds(), loc, targetNodeLocation)
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ func collectEcShards(commandEnv *CommandEnv, nodeToEcIndexBits map[pb.ServerAddr
|
||||||
|
|
||||||
func lookupVolumeIds(commandEnv *CommandEnv, volumeIds []string) (volumeIdLocations []*master_pb.LookupVolumeResponse_VolumeIdLocation, err error) {
|
func lookupVolumeIds(commandEnv *CommandEnv, volumeIds []string) (volumeIdLocations []*master_pb.LookupVolumeResponse_VolumeIdLocation, err error) {
|
||||||
var resp *master_pb.LookupVolumeResponse
|
var resp *master_pb.LookupVolumeResponse
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err = client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{VolumeOrFileIds: volumeIds})
|
resp, err = client.LookupVolume(context.Background(), &master_pb.LookupVolumeRequest{VolumeOrFileIds: volumeIds})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
@ -236,7 +236,7 @@ func lookupVolumeIds(commandEnv *CommandEnv, volumeIds []string) (volumeIdLocati
|
||||||
func collectTopologyInfo(commandEnv *CommandEnv) (topoInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, err error) {
|
func collectTopologyInfo(commandEnv *CommandEnv) (topoInfo *master_pb.TopologyInfo, volumeSizeLimitMb uint64, err error) {
|
||||||
|
|
||||||
var resp *master_pb.VolumeListResponse
|
var resp *master_pb.VolumeListResponse
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
resp, err = client.VolumeList(context.Background(), &master_pb.VolumeListRequest{})
|
resp, err = client.VolumeList(context.Background(), &master_pb.VolumeListRequest{})
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
|
@ -126,7 +126,7 @@ func generateEcShards(grpcDialOption grpc.DialOption, volumeId needle.VolumeId,
|
||||||
|
|
||||||
fmt.Printf("generateEcShards %s %d on %s ...\n", collection, volumeId, sourceVolumeServer)
|
fmt.Printf("generateEcShards %s %d on %s ...\n", collection, volumeId, sourceVolumeServer)
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, genErr := volumeServerClient.VolumeEcShardsGenerate(context.Background(), &volume_server_pb.VolumeEcShardsGenerateRequest{
|
_, genErr := volumeServerClient.VolumeEcShardsGenerate(context.Background(), &volume_server_pb.VolumeEcShardsGenerateRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
|
|
@ -172,7 +172,7 @@ func rebuildOneEcVolume(commandEnv *CommandEnv, rebuilder *EcNode, collection st
|
||||||
|
|
||||||
func generateMissingShards(grpcDialOption grpc.DialOption, collection string, volumeId needle.VolumeId, sourceLocation pb.ServerAddress) (rebuiltShardIds []uint32, err error) {
|
func generateMissingShards(grpcDialOption grpc.DialOption, collection string, volumeId needle.VolumeId, sourceLocation pb.ServerAddress) (rebuiltShardIds []uint32, err error) {
|
||||||
|
|
||||||
err = operation.WithVolumeServerClient(sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, sourceLocation, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
resp, rebultErr := volumeServerClient.VolumeEcShardsRebuild(context.Background(), &volume_server_pb.VolumeEcShardsRebuildRequest{
|
resp, rebultErr := volumeServerClient.VolumeEcShardsRebuild(context.Background(), &volume_server_pb.VolumeEcShardsRebuildRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
@ -213,7 +213,7 @@ func prepareDataToRecover(commandEnv *CommandEnv, rebuilder *EcNode, collection
|
||||||
|
|
||||||
var copyErr error
|
var copyErr error
|
||||||
if applyBalancing {
|
if applyBalancing {
|
||||||
copyErr = operation.WithVolumeServerClient(pb.NewServerAddressFromDataNode(rebuilder.info), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
copyErr = operation.WithVolumeServerClient(false, pb.NewServerAddressFromDataNode(rebuilder.info), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, copyErr := volumeServerClient.VolumeEcShardsCopy(context.Background(), &volume_server_pb.VolumeEcShardsCopyRequest{
|
_, copyErr := volumeServerClient.VolumeEcShardsCopy(context.Background(), &volume_server_pb.VolumeEcShardsCopyRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.Write
|
||||||
|
|
||||||
dir, name := util.FullPath(path).DirAndName()
|
dir, name := util.FullPath(path).DirAndName()
|
||||||
|
|
||||||
return commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
request := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
|
@ -117,7 +117,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
|
||||||
|
|
||||||
if *apply {
|
if *apply {
|
||||||
|
|
||||||
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf2.Bytes())
|
return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf2.Bytes())
|
||||||
}); err != nil && err != filer_pb.ErrNotFound {
|
}); err != nil && err != filer_pb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W
|
||||||
|
|
||||||
dir, name := util.FullPath(path).DirAndName()
|
dir, name := util.FullPath(path).DirAndName()
|
||||||
|
|
||||||
return commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
request := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (c *commandFsMetaLoad) Do(args []string, commandEnv *CommandEnv, writer io.
|
||||||
|
|
||||||
var dirCount, fileCount uint64
|
var dirCount, fileCount uint64
|
||||||
|
|
||||||
err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
sizeBuf := make([]byte, 4)
|
sizeBuf := make([]byte, 4)
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (c *commandFsMkdir) Do(args []string, commandEnv *CommandEnv, writer io.Wri
|
||||||
|
|
||||||
dir, name := util.FullPath(path).DirAndName()
|
dir, name := util.FullPath(path).DirAndName()
|
||||||
|
|
||||||
err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
_, createErr := client.CreateEntry(context.Background(), &filer_pb.CreateEntryRequest{
|
_, createErr := client.CreateEntry(context.Background(), &filer_pb.CreateEntryRequest{
|
||||||
Directory: dir,
|
Directory: dir,
|
||||||
|
|
|
@ -54,7 +54,7 @@ func (c *commandFsMv) Do(args []string, commandEnv *CommandEnv, writer io.Writer
|
||||||
|
|
||||||
destinationDir, destinationName := util.FullPath(destinationPath).DirAndName()
|
destinationDir, destinationName := util.FullPath(destinationPath).DirAndName()
|
||||||
|
|
||||||
return commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
// collect destination entry info
|
// collect destination entry info
|
||||||
destinationRequest := &filer_pb.LookupDirectoryEntryRequest{
|
destinationRequest := &filer_pb.LookupDirectoryEntryRequest{
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (c *commandFsRm) Do(args []string, commandEnv *CommandEnv, writer io.Writer
|
||||||
return fmt.Errorf("need to have arguments")
|
return fmt.Errorf("need to have arguments")
|
||||||
}
|
}
|
||||||
|
|
||||||
commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
for _, entry := range entiries {
|
for _, entry := range entiries {
|
||||||
targetPath, err := commandEnv.parseUrl(entry)
|
targetPath, err := commandEnv.parseUrl(entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -184,7 +184,7 @@ func (c *commandRemoteConfigure) listExistingRemoteStorages(commandEnv *CommandE
|
||||||
|
|
||||||
func (c *commandRemoteConfigure) deleteRemoteStorage(commandEnv *CommandEnv, writer io.Writer, storageName string) error {
|
func (c *commandRemoteConfigure) deleteRemoteStorage(commandEnv *CommandEnv, writer io.Writer, storageName string) error {
|
||||||
|
|
||||||
return commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
return commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
request := &filer_pb.DeleteEntryRequest{
|
request := &filer_pb.DeleteEntryRequest{
|
||||||
Directory: filer.DirectoryEtcRemote,
|
Directory: filer.DirectoryEtcRemote,
|
||||||
|
@ -214,7 +214,7 @@ func (c *commandRemoteConfigure) saveRemoteStorage(commandEnv *CommandEnv, write
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return filer.SaveInsideFiler(client, filer.DirectoryEtcRemote, conf.Name+filer.REMOTE_STORAGE_CONF_SUFFIX, data)
|
return filer.SaveInsideFiler(client, filer.DirectoryEtcRemote, conf.Name+filer.REMOTE_STORAGE_CONF_SUFFIX, data)
|
||||||
}); err != nil && err != filer_pb.ErrNotFound {
|
}); err != nil && err != filer_pb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -117,7 +117,7 @@ func pullMetadata(commandEnv *CommandEnv, writer io.Writer, localMountedDir util
|
||||||
|
|
||||||
remote := filer.MapFullPathToRemoteStorageLocation(localMountedDir, remoteMountedLocation, dirToCache)
|
remote := filer.MapFullPathToRemoteStorageLocation(localMountedDir, remoteMountedLocation, dirToCache)
|
||||||
|
|
||||||
err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
err = remoteStorage.Traverse(remote, func(remoteDir, name string, isDirectory bool, remoteEntry *filer_pb.RemoteEntry) error {
|
err = remoteStorage.Traverse(remote, func(remoteDir, name string, isDirectory bool, remoteEntry *filer_pb.RemoteEntry) error {
|
||||||
localDir := filer.MapRemoteStorageLocationPathToFullPath(localMountedDir, remoteMountedLocation, remoteDir)
|
localDir := filer.MapRemoteStorageLocationPathToFullPath(localMountedDir, remoteMountedLocation, remoteDir)
|
||||||
|
|
|
@ -117,7 +117,7 @@ func jsonPrintln(writer io.Writer, message proto.Message) error {
|
||||||
func syncMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty bool, remoteConf *remote_pb.RemoteConf, remote *remote_pb.RemoteStorageLocation) error {
|
func syncMetadata(commandEnv *CommandEnv, writer io.Writer, dir string, nonEmpty bool, remoteConf *remote_pb.RemoteConf, remote *remote_pb.RemoteStorageLocation) error {
|
||||||
|
|
||||||
// find existing directory, and ensure the directory is empty
|
// find existing directory, and ensure the directory is empty
|
||||||
err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
parent, name := util.FullPath(dir).DirAndName()
|
parent, name := util.FullPath(dir).DirAndName()
|
||||||
_, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
_, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parent,
|
Directory: parent,
|
||||||
|
|
|
@ -105,7 +105,7 @@ func (c *commandRemoteUncache) uncacheContentData(commandEnv *CommandEnv, writer
|
||||||
|
|
||||||
fmt.Fprintf(writer, "Uncache %+v ... ", dir.Child(entry.Name))
|
fmt.Fprintf(writer, "Uncache %+v ... ", dir.Child(entry.Name))
|
||||||
|
|
||||||
err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
_, updateErr := client.UpdateEntry(context.Background(), &filer_pb.UpdateEntryRequest{
|
_, updateErr := client.UpdateEntry(context.Background(), &filer_pb.UpdateEntryRequest{
|
||||||
Directory: string(dir),
|
Directory: string(dir),
|
||||||
Entry: entry,
|
Entry: entry,
|
||||||
|
|
|
@ -83,7 +83,7 @@ func (c *commandRemoteUnmount) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir string) error {
|
func (c *commandRemoteUnmount) purgeMountedData(commandEnv *CommandEnv, dir string) error {
|
||||||
|
|
||||||
// find existing directory, and ensure the directory is empty
|
// find existing directory, and ensure the directory is empty
|
||||||
err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
parent, name := util.FullPath(dir).DirAndName()
|
parent, name := util.FullPath(dir).DirAndName()
|
||||||
lookupResp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
lookupResp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
||||||
Directory: parent,
|
Directory: parent,
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (c *commandS3BucketCreate) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
return fmt.Errorf("empty bucket name")
|
return fmt.Errorf("empty bucket name")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -52,7 +52,7 @@ func (c *commandS3BucketDelete) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete the collection directly first
|
// delete the collection directly first
|
||||||
err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error {
|
err = commandEnv.MasterClient.WithClient(false, func(client master_pb.SeaweedClient) error {
|
||||||
_, err = client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
_, err = client.CollectionDelete(context.Background(), &master_pb.CollectionDeleteRequest{
|
||||||
Name: *bucketName,
|
Name: *bucketName,
|
||||||
})
|
})
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (c *commandS3BucketList) Do(args []string, commandEnv *CommandEnv, writer i
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFilerBucketsPath(filerClient filer_pb.FilerClient) (filerBucketsPath string, err error) {
|
func readFilerBucketsPath(filerClient filer_pb.FilerClient) (filerBucketsPath string, err error) {
|
||||||
err = filerClient.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
err = filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
|
||||||
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
resp, err := client.GetFilerConfiguration(context.Background(), &filer_pb.GetFilerConfigurationRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -48,7 +48,7 @@ func (c *commandS3Configure) Do(args []string, commandEnv *CommandEnv, writer io
|
||||||
}
|
}
|
||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return filer.ReadEntry(commandEnv.MasterClient, client, filer.IamConfigDirecotry, filer.IamIdentityFile, &buf)
|
return filer.ReadEntry(commandEnv.MasterClient, client, filer.IamConfigDirecotry, filer.IamIdentityFile, &buf)
|
||||||
}); err != nil && err != filer_pb.ErrNotFound {
|
}); err != nil && err != filer_pb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
|
@ -171,7 +171,7 @@ func (c *commandS3Configure) Do(args []string, commandEnv *CommandEnv, writer io
|
||||||
|
|
||||||
if *apply {
|
if *apply {
|
||||||
|
|
||||||
if err := commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err := commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
return filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes())
|
return filer.SaveInsideFiler(client, filer.IamConfigDirecotry, filer.IamIdentityFile, buf.Bytes())
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -182,7 +182,7 @@ func (c *commandVolumeCheckDisk) doVolumeCheckDisk(minuend, subtrahend *needle_m
|
||||||
|
|
||||||
func (c *commandVolumeCheckDisk) readSourceNeedleBlob(sourceVolumeServer pb.ServerAddress, volumeId uint32, needleValue needle_map.NeedleValue) (needleBlob []byte, err error) {
|
func (c *commandVolumeCheckDisk) readSourceNeedleBlob(sourceVolumeServer pb.ServerAddress, volumeId uint32, needleValue needle_map.NeedleValue) (needleBlob []byte, err error) {
|
||||||
|
|
||||||
err = operation.WithVolumeServerClient(sourceVolumeServer, c.env.option.GrpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, sourceVolumeServer, c.env.option.GrpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
resp, err := client.ReadNeedleBlob(context.Background(), &volume_server_pb.ReadNeedleBlobRequest{
|
resp, err := client.ReadNeedleBlob(context.Background(), &volume_server_pb.ReadNeedleBlobRequest{
|
||||||
VolumeId: volumeId,
|
VolumeId: volumeId,
|
||||||
NeedleId: uint64(needleValue.Key),
|
NeedleId: uint64(needleValue.Key),
|
||||||
|
@ -200,7 +200,7 @@ func (c *commandVolumeCheckDisk) readSourceNeedleBlob(sourceVolumeServer pb.Serv
|
||||||
|
|
||||||
func (c *commandVolumeCheckDisk) writeNeedleBlobToTarget(targetVolumeServer pb.ServerAddress, volumeId uint32, needleValue needle_map.NeedleValue, needleBlob []byte) error {
|
func (c *commandVolumeCheckDisk) writeNeedleBlobToTarget(targetVolumeServer pb.ServerAddress, volumeId uint32, needleValue needle_map.NeedleValue, needleBlob []byte) error {
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(targetVolumeServer, c.env.option.GrpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, targetVolumeServer, c.env.option.GrpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
|
||||||
_, err := client.WriteNeedleBlob(context.Background(), &volume_server_pb.WriteNeedleBlobRequest{
|
_, err := client.WriteNeedleBlob(context.Background(), &volume_server_pb.WriteNeedleBlobRequest{
|
||||||
VolumeId: volumeId,
|
VolumeId: volumeId,
|
||||||
NeedleId: uint64(needleValue.Key),
|
NeedleId: uint64(needleValue.Key),
|
||||||
|
@ -229,7 +229,7 @@ func (c *commandVolumeCheckDisk) readIndexDatabase(db *needle_map.MemDb, collect
|
||||||
|
|
||||||
func (c *commandVolumeCheckDisk) copyVolumeIndexFile(collection string, volumeId uint32, volumeServer pb.ServerAddress, buf *bytes.Buffer, verbose bool, writer io.Writer) error {
|
func (c *commandVolumeCheckDisk) copyVolumeIndexFile(collection string, volumeId uint32, volumeServer pb.ServerAddress, buf *bytes.Buffer, verbose bool, writer io.Writer) error {
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(volumeServer, c.env.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(true, volumeServer, c.env.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
ext := ".idx"
|
ext := ".idx"
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dst := range allLocations {
|
for _, dst := range allLocations {
|
||||||
err := operation.WithVolumeServerClient(pb.NewServerAddressFromDataNode(dst.dataNode), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, pb.NewServerAddressFromDataNode(dst.dataNode), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
resp, configureErr := volumeServerClient.VolumeConfigure(context.Background(), &volume_server_pb.VolumeConfigureRequest{
|
resp, configureErr := volumeServerClient.VolumeConfigure(context.Background(), &volume_server_pb.VolumeConfigureRequest{
|
||||||
VolumeId: uint32(vid),
|
VolumeId: uint32(vid),
|
||||||
Replication: replicaPlacement.String(),
|
Replication: replicaPlacement.String(),
|
||||||
|
|
|
@ -265,7 +265,7 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(pb.NewServerAddressFromDataNode(dst.dataNode), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(false, pb.NewServerAddressFromDataNode(dst.dataNode), commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
stream, replicateErr := volumeServerClient.VolumeCopy(context.Background(), &volume_server_pb.VolumeCopyRequest{
|
stream, replicateErr := volumeServerClient.VolumeCopy(context.Background(), &volume_server_pb.VolumeCopyRequest{
|
||||||
VolumeId: replica.info.Id,
|
VolumeId: replica.info.Id,
|
||||||
SourceDataNode: string(pb.NewServerAddressFromDataNode(replica.location.dataNode)),
|
SourceDataNode: string(pb.NewServerAddressFromDataNode(replica.location.dataNode)),
|
||||||
|
|
|
@ -248,7 +248,7 @@ func (c *commandVolumeFsck) collectOneVolumeFileIds(tempFolder string, volumeId
|
||||||
fmt.Fprintf(writer, "collecting volume %d file ids from %s ...\n", volumeId, vinfo.server)
|
fmt.Fprintf(writer, "collecting volume %d file ids from %s ...\n", volumeId, vinfo.server)
|
||||||
}
|
}
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(vinfo.server, c.env.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, vinfo.server, c.env.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
|
|
||||||
ext := ".idx"
|
ext := ".idx"
|
||||||
if vinfo.isEcVolume {
|
if vinfo.isEcVolume {
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (c *commandVolumeMount) Do(args []string, commandEnv *CommandEnv, writer io
|
||||||
}
|
}
|
||||||
|
|
||||||
func mountVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
func mountVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
||||||
return operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, mountErr := volumeServerClient.VolumeMount(context.Background(), &volume_server_pb.VolumeMountRequest{
|
_, mountErr := volumeServerClient.VolumeMount(context.Background(), &volume_server_pb.VolumeMountRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
})
|
})
|
||||||
|
|
|
@ -112,7 +112,7 @@ func copyVolume(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
clientErr := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
clientErr := operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, writableErr := volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{
|
_, writableErr := volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
})
|
})
|
||||||
|
@ -123,7 +123,7 @@ func copyVolume(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needl
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
resp, statusErr := volumeServerClient.VolumeStatus(context.Background(), &volume_server_pb.VolumeStatusRequest{
|
resp, statusErr := volumeServerClient.VolumeStatus(context.Background(), &volume_server_pb.VolumeStatusRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
})
|
})
|
||||||
|
@ -140,7 +140,7 @@ func copyVolume(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needl
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err = operation.WithVolumeServerClient(true, targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
stream, replicateErr := volumeServerClient.VolumeCopy(context.Background(), &volume_server_pb.VolumeCopyRequest{
|
stream, replicateErr := volumeServerClient.VolumeCopy(context.Background(), &volume_server_pb.VolumeCopyRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
SourceDataNode: string(sourceVolumeServer),
|
SourceDataNode: string(sourceVolumeServer),
|
||||||
|
@ -173,7 +173,7 @@ func copyVolume(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needl
|
||||||
|
|
||||||
func tailVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer pb.ServerAddress, lastAppendAtNs uint64, idleTimeout time.Duration) (err error) {
|
func tailVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer, targetVolumeServer pb.ServerAddress, lastAppendAtNs uint64, idleTimeout time.Duration) (err error) {
|
||||||
|
|
||||||
return operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(true, targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, replicateErr := volumeServerClient.VolumeTailReceiver(context.Background(), &volume_server_pb.VolumeTailReceiverRequest{
|
_, replicateErr := volumeServerClient.VolumeTailReceiver(context.Background(), &volume_server_pb.VolumeTailReceiverRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
SinceNs: lastAppendAtNs,
|
SinceNs: lastAppendAtNs,
|
||||||
|
@ -186,7 +186,7 @@ func tailVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, source
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
func deleteVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
||||||
return operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, deleteErr := volumeServerClient.VolumeDelete(context.Background(), &volume_server_pb.VolumeDeleteRequest{
|
_, deleteErr := volumeServerClient.VolumeDelete(context.Background(), &volume_server_pb.VolumeDeleteRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
})
|
})
|
||||||
|
@ -195,7 +195,7 @@ func deleteVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sour
|
||||||
}
|
}
|
||||||
|
|
||||||
func markVolumeWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress, writable bool) (err error) {
|
func markVolumeWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress, writable bool) (err error) {
|
||||||
return operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
if writable {
|
if writable {
|
||||||
_, err = volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{
|
_, err = volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (c *commandVolumeServerLeave) Do(args []string, commandEnv *CommandEnv, wri
|
||||||
}
|
}
|
||||||
|
|
||||||
func volumeServerLeave(grpcDialOption grpc.DialOption, volumeServer pb.ServerAddress, writer io.Writer) (err error) {
|
func volumeServerLeave(grpcDialOption grpc.DialOption, volumeServer pb.ServerAddress, writer io.Writer) (err error) {
|
||||||
return operation.WithVolumeServerClient(volumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, volumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, leaveErr := volumeServerClient.VolumeServerLeave(context.Background(), &volume_server_pb.VolumeServerLeaveRequest{})
|
_, leaveErr := volumeServerClient.VolumeServerLeave(context.Background(), &volume_server_pb.VolumeServerLeaveRequest{})
|
||||||
if leaveErr != nil {
|
if leaveErr != nil {
|
||||||
fmt.Fprintf(writer, "ask volume server %s to leave: %v\n", volumeServer, leaveErr)
|
fmt.Fprintf(writer, "ask volume server %s to leave: %v\n", volumeServer, leaveErr)
|
||||||
|
|
|
@ -124,7 +124,7 @@ func doVolumeTierDownload(commandEnv *CommandEnv, writer io.Writer, collection s
|
||||||
|
|
||||||
func downloadDatFromRemoteTier(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needle.VolumeId, collection string, targetVolumeServer pb.ServerAddress) error {
|
func downloadDatFromRemoteTier(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needle.VolumeId, collection string, targetVolumeServer pb.ServerAddress) error {
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(true, targetVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
stream, downloadErr := volumeServerClient.VolumeTierMoveDatFromRemote(context.Background(), &volume_server_pb.VolumeTierMoveDatFromRemoteRequest{
|
stream, downloadErr := volumeServerClient.VolumeTierMoveDatFromRemote(context.Background(), &volume_server_pb.VolumeTierMoveDatFromRemoteRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
|
|
@ -118,7 +118,7 @@ func doVolumeTierUpload(commandEnv *CommandEnv, writer io.Writer, collection str
|
||||||
|
|
||||||
func uploadDatToRemoteTier(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needle.VolumeId, collection string, sourceVolumeServer pb.ServerAddress, dest string, keepLocalDatFile bool) error {
|
func uploadDatToRemoteTier(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needle.VolumeId, collection string, sourceVolumeServer pb.ServerAddress, dest string, keepLocalDatFile bool) error {
|
||||||
|
|
||||||
err := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
err := operation.WithVolumeServerClient(true, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
stream, copyErr := volumeServerClient.VolumeTierMoveDatToRemote(context.Background(), &volume_server_pb.VolumeTierMoveDatToRemoteRequest{
|
stream, copyErr := volumeServerClient.VolumeTierMoveDatToRemote(context.Background(), &volume_server_pb.VolumeTierMoveDatToRemoteRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
Collection: collection,
|
Collection: collection,
|
||||||
|
|
|
@ -55,7 +55,7 @@ func (c *commandVolumeUnmount) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmountVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
func unmountVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress) (err error) {
|
||||||
return operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
|
||||||
_, unmountErr := volumeServerClient.VolumeUnmount(context.Background(), &volume_server_pb.VolumeUnmountRequest{
|
_, unmountErr := volumeServerClient.VolumeUnmount(context.Background(), &volume_server_pb.VolumeUnmountRequest{
|
||||||
VolumeId: uint32(volumeId),
|
VolumeId: uint32(volumeId),
|
||||||
})
|
})
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue