Skip to content

DO NOT MERGE YET! added BlockWriterDialTimeout to namenode #71

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion rpc/block_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ func (bw *BlockWriter) Close() error {
func (bw *BlockWriter) connectNext() error {
address := getDatanodeAddress(bw.currentPipeline()[0])

conn, err := net.DialTimeout("tcp", address, connectTimeout)
var conn net.Conn
var err error
if bw.namenode.BlockWriterDialTimeout != nil {
conn, err = bw.namenode.BlockWriterDialTimeout("tcp", address, connectTimeout)
} else {
conn, err = net.DialTimeout("tcp", address, connectTimeout)
}
if err != nil {
return err
}
Expand Down
14 changes: 8 additions & 6 deletions rpc/namenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net"
"sync"
"time"

hadoop "github.com/colinmarc/hdfs/protocol/hadoop_common"
"github.com/golang/protobuf/proto"
Expand All @@ -23,12 +24,13 @@ const (

// NamenodeConnection represents an open connection to a namenode.
type NamenodeConnection struct {
clientId []byte
clientName string
currentRequestID int
user string
conn net.Conn
reqLock sync.Mutex
clientId []byte
clientName string
currentRequestID int
user string
conn net.Conn
reqLock sync.Mutex
BlockWriterDialTimeout func(network, address string, timeout time.Duration) (net.Conn, error)
}

// NamenodeError represents an interepreted error from the Namenode, including
Expand Down