object layer initialization using distributed locking (#2397)

* vendorized latest minio/dsync

* wip - object layer initialization using distributed locking
This commit is contained in:
Krishnan Parthasarathi
2016-08-09 23:57:16 -07:00
committed by Harshavardhana
parent 3939c75345
commit b7c169d71d
7 changed files with 64 additions and 24 deletions

View File

@@ -21,7 +21,6 @@ import (
"math"
"math/rand"
"net/rpc"
"strings"
"sync"
"time"
)
@@ -52,7 +51,7 @@ func connectLazy(dm *DMutex) {
for i := range dm.clnts {
if dm.clnts[i] == nil {
// pass in unique path (as required by server.HandleHTTP()
dm.clnts[i], _ = rpc.DialHTTPPath("tcp", nodes[i], rpcPath+"-"+strings.Split(nodes[i], ":")[1])
dm.clnts[i], _ = rpc.DialHTTPPath("tcp", nodes[i], rpcPaths[i])
}
}
}

View File

@@ -28,7 +28,7 @@ const DefaultPath = "/rpc/dsync"
var n int
var nodes []string
var rpcPath string
var rpcPaths []string
func closeClients(clients []*rpc.Client) {
for _, clnt := range clients {
@@ -36,8 +36,8 @@ func closeClients(clients []*rpc.Client) {
}
}
// Same as SetNodes, but takes a path argument different from the package-level default.
func SetNodesWithPath(nodeList []string, path string) (err error) {
// Same as SetNodes, but takes a slice of rpc paths as argument different from the package-level default.
func SetNodesWithPath(nodeList []string, paths []string) (err error) {
// Validate if number of nodes is within allowable range.
if n != 0 {
@@ -50,7 +50,8 @@ func SetNodesWithPath(nodeList []string, path string) (err error) {
nodes = make([]string, len(nodeList))
copy(nodes, nodeList[:])
rpcPath = path
rpcPaths = make([]string, len(paths))
copy(rpcPaths, paths[:])
n = len(nodes)
return nil
}