Skip to content

Commit

Permalink
Upgrade go-irodsclient, use large socket rw buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
iychoi committed Mar 2, 2023
1 parent 00b0884 commit 3cd8ee9
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions cmd/subcmd/cd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cmd/subcmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cmd/subcmd/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cmd/subcmd/passwd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions cmd/subcmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 7 additions & 10 deletions cmd/subcmd/svrinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,30 +51,26 @@ 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)
}

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)
Expand Down
3 changes: 2 additions & 1 deletion commons/irodsclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions commons/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 3cd8ee9

Please sign in to comment.