From 3cd8ee9a6a0e12954942e0a98d6371981b1a4ebd Mon Sep 17 00:00:00 2001 From: Illyoung Choi Date: Thu, 2 Mar 2023 13:19:10 -0700 Subject: [PATCH] Upgrade go-irodsclient, use large socket rw buffer --- cmd/subcmd/cd.go | 4 ++-- cmd/subcmd/ls.go | 4 ++-- cmd/subcmd/mkdir.go | 4 ++-- cmd/subcmd/passwd.go | 4 ++-- cmd/subcmd/ps.go | 4 ++-- cmd/subcmd/svrinfo.go | 17 +++++++---------- commons/irodsclient.go | 3 ++- commons/staging.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 10 files changed, 24 insertions(+), 26 deletions(-) diff --git a/cmd/subcmd/cd.go b/cmd/subcmd/cd.go index b11cda5..b45c5a3 100644 --- a/cmd/subcmd/cd.go +++ b/cmd/subcmd/cd.go @@ -79,11 +79,11 @@ func changeWorkingDir(fs *irodsclient_fs.FileSystem, collectionPath string) erro zone := commons.GetZone() collectionPath = commons.MakeIRODSPath(cwd, home, zone, collectionPath) - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) logger.Debugf("changing working dir: %s", collectionPath) diff --git a/cmd/subcmd/ls.go b/cmd/subcmd/ls.go index f8731e8..4f94c8c 100644 --- a/cmd/subcmd/ls.go +++ b/cmd/subcmd/ls.go @@ -96,11 +96,11 @@ func listOne(fs *irodsclient_fs.FileSystem, sourcePath string, longFormat bool, zone := commons.GetZone() sourcePath = commons.MakeIRODSPath(cwd, home, zone, sourcePath) - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) collection, err := irodsclient_irodsfs.GetCollection(connection, sourcePath) if err != nil { diff --git a/cmd/subcmd/mkdir.go b/cmd/subcmd/mkdir.go index 8f9f94a..4f9e1b0 100644 --- a/cmd/subcmd/mkdir.go +++ b/cmd/subcmd/mkdir.go @@ -84,11 +84,11 @@ func makeOne(fs *irodsclient_fs.FileSystem, targetPath string, parent bool) erro zone := commons.GetZone() targetPath = commons.MakeIRODSPath(cwd, home, zone, targetPath) - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) logger.Debugf("making a collection %s", targetPath) diff --git a/cmd/subcmd/passwd.go b/cmd/subcmd/passwd.go index 5b2f5e7..727ea31 100644 --- a/cmd/subcmd/passwd.go +++ b/cmd/subcmd/passwd.go @@ -65,11 +65,11 @@ func changePassword(fs *irodsclient_fs.FileSystem) error { account := commons.GetAccount() - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) logger.Debugf("changing password for user %s", account.ClientUser) diff --git a/cmd/subcmd/ps.go b/cmd/subcmd/ps.go index 0126640..aa26f56 100644 --- a/cmd/subcmd/ps.go +++ b/cmd/subcmd/ps.go @@ -102,11 +102,11 @@ func listProcesses(fs *irodsclient_fs.FileSystem, address string, zone string, g "function": "listProcesses", }) - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) logger.Debugf("listing processes - addr: %s, zone: %s", address, zone) diff --git a/cmd/subcmd/svrinfo.go b/cmd/subcmd/svrinfo.go index 50bea64..4daeaa0 100644 --- a/cmd/subcmd/svrinfo.go +++ b/cmd/subcmd/svrinfo.go @@ -4,6 +4,7 @@ import ( "os" irodsclient_fs "github.com/cyverse/go-irodsclient/fs" + "github.com/cyverse/go-irodsclient/irods/types" "github.com/cyverse/gocommands/commons" "github.com/jedib0t/go-pretty/v6/table" log "github.com/sirupsen/logrus" @@ -50,7 +51,7 @@ func processSvrinfoCommand(command *cobra.Command, args []string) error { defer filesystem.Release() - err = displayVersion(filesystem) + err = displayVersion(account, filesystem) if err != nil { return xerrors.Errorf("failed to perform svrinfo: %w", err) } @@ -58,22 +59,18 @@ func processSvrinfoCommand(command *cobra.Command, args []string) error { return nil } -func displayVersion(fs *irodsclient_fs.FileSystem) error { +func displayVersion(account *types.IRODSAccount, fs *irodsclient_fs.FileSystem) error { logger := log.WithFields(log.Fields{ "package": "main", "function": "displayVersion", }) - connection, err := fs.GetConnection() - if err != nil { - return xerrors.Errorf("failed to get connection: %w", err) - } - defer fs.ReturnConnection(connection) - logger.Debug("displaying version") - account := connection.GetAccount() - ver := connection.GetVersion() + ver, err := fs.GetServerVersion() + if err != nil { + return xerrors.Errorf("failed to get server version: %w", err) + } t := table.NewWriter() t.SetOutputMirror(os.Stdout) diff --git a/commons/irodsclient.go b/commons/irodsclient.go index 7ca4795..81fe28a 100644 --- a/commons/irodsclient.go +++ b/commons/irodsclient.go @@ -13,12 +13,13 @@ const ( ClientProgramName string = "gocommands" connectionTimeout time.Duration = 10 * time.Minute filesystemTimeout time.Duration = 10 * time.Minute + tcpBufferSize int = 4 * 1024 * 1024 ) // GetIRODSFSClient returns a file system client func GetIRODSFSClient(account *irodsclient_types.IRODSAccount) (*irodsclient_fs.FileSystem, error) { fsConfig := irodsclient_fs.NewFileSystemConfig(ClientProgramName, irodsclient_fs.ConnectionLifespanDefault, - filesystemTimeout, filesystemTimeout, irodsclient_fs.FileSystemConnectionMaxDefault, + filesystemTimeout, filesystemTimeout, irodsclient_fs.FileSystemConnectionMaxDefault, tcpBufferSize, irodsclient_fs.FileSystemTimeoutDefault, irodsclient_fs.FileSystemTimeoutDefault, []irodsclient_fs.MetadataCacheTimeoutSetting{}, true, true) return irodsclient_fs.NewFileSystem(account, fsConfig) diff --git a/commons/staging.go b/commons/staging.go index 9e4286c..a5e68e7 100644 --- a/commons/staging.go +++ b/commons/staging.go @@ -82,11 +82,11 @@ func GetDefaultStagingDir(fs *irodsclient_fs.FileSystem, targetPath string) (str } func GetResourceServers(fs *irodsclient_fs.FileSystem, targetDir string) ([]string, error) { - connection, err := fs.GetConnection() + connection, err := fs.GetMetadataConnection() if err != nil { return nil, xerrors.Errorf("failed to get connection: %w", err) } - defer fs.ReturnConnection(connection) + defer fs.ReturnMetadataConnection(connection) if !fs.ExistsDir(targetDir) { err := fs.MakeDir(targetDir, true) diff --git a/go.mod b/go.mod index 1157b50..d75456c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/cyverse/gocommands go 1.18 require ( - github.com/cyverse/go-irodsclient v0.10.12 + github.com/cyverse/go-irodsclient v0.11.0 github.com/gliderlabs/ssh v0.3.5 github.com/jedib0t/go-pretty/v6 v6.3.1 github.com/kelseyhightower/envconfig v1.4.0 diff --git a/go.sum b/go.sum index 6bb99c9..265bb93 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyverse/go-irodsclient v0.10.12 h1:CTpiEaEUySOJmY01FNfkOVexeZOj8N7krhfkZxYbHyE= -github.com/cyverse/go-irodsclient v0.10.12/go.mod h1:Qs1cjnDN1RaBaUcaZCsRGPFqCffg/cExSBIm466nvTw= +github.com/cyverse/go-irodsclient v0.11.0 h1:pYo6aco+0Vp4qgkm2xbtLJ5CSU29PlWha24mnOvZ6sY= +github.com/cyverse/go-irodsclient v0.11.0/go.mod h1:Qs1cjnDN1RaBaUcaZCsRGPFqCffg/cExSBIm466nvTw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=