Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support lease related APIs. #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions lease.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package hdfs

import (
"os"

hdfs "github.com/colinmarc/hdfs/v2/internal/protocol/hadoop_hdfs"
"github.com/golang/protobuf/proto"
)

func (c *Client) RecoverLease(name string) (bool, error) {
recoverLeaseReq := &hdfs.RecoverLeaseRequestProto{
Src: proto.String(name),
ClientName: proto.String(c.namenode.ClientName),
}
recoverLeaseResp := &hdfs.RecoverLeaseResponseProto{}

err := c.namenode.Execute("recoverLease", recoverLeaseReq, recoverLeaseResp)
if err != nil {
return false, &os.PathError{"recoverLease", name, interpretException(err)}
}

return recoverLeaseResp.GetResult(), nil
}

func (c *Client) RenewLease(name string) (bool, error) {
renewLeaseReq := &hdfs.RenewLeaseRequestProto{
ClientName: proto.String(c.namenode.ClientName),
}
renewLeaseResp := &hdfs.RecoverLeaseResponseProto{}

err := c.namenode.Execute("renewLease", renewLeaseReq, renewLeaseResp)
if err != nil {
return false, &os.PathError{"renewLease", name, interpretException(err)}
}

return renewLeaseResp.GetResult(), nil
}