mirror of
https://github.com/minio/minio.git
synced 2025-11-21 10:16:03 -05:00
object layer initialization using distributed locking (#2397)
* vendorized latest minio/dsync * wip - object layer initialization using distributed locking
This commit is contained in:
committed by
Harshavardhana
parent
3939c75345
commit
b7c169d71d
@@ -21,11 +21,13 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/dsync"
|
||||
)
|
||||
|
||||
var srvConfig serverCmdConfig
|
||||
@@ -220,6 +222,29 @@ func getPort(address string) int {
|
||||
return portInt
|
||||
}
|
||||
|
||||
// Initialize distributed locking only in case of distributed setup.
|
||||
func initDsyncNodes(disks []string, port int) error {
|
||||
var isDist bool = false
|
||||
var dsyncNodes []string
|
||||
var rpcPaths []string
|
||||
serverPort := strconv.Itoa(port)
|
||||
|
||||
for _, disk := range disks {
|
||||
if idx := strings.LastIndex(disk, ":"); idx != -1 {
|
||||
dsyncNodes = append(dsyncNodes, disk[:idx]+":"+serverPort)
|
||||
rpcPaths = append(rpcPaths, path.Join(lockRPCPath, disk[idx+1:]))
|
||||
}
|
||||
if !isLocalStorage(disk) {
|
||||
// One or more disks supplied as arguments are remote.
|
||||
isDist = true
|
||||
}
|
||||
}
|
||||
if isDist {
|
||||
return dsync.SetNodesWithPath(dsyncNodes, rpcPaths)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// serverMain handler called for 'minio server' command.
|
||||
func serverMain(c *cli.Context) {
|
||||
// Check 'server' cli arguments.
|
||||
@@ -245,6 +270,14 @@ func serverMain(c *cli.Context) {
|
||||
// Disks to be used in server init.
|
||||
disks := c.Args()
|
||||
|
||||
// Set nodes for dsync
|
||||
err = initDsyncNodes(disks, port)
|
||||
fatalIf(err, "Unable to initialize distributed locking")
|
||||
|
||||
// Initialize name space lock.
|
||||
// FIXME: add logic to switch between distributed and single-node namespace locking.
|
||||
initNSLock()
|
||||
|
||||
// Configure server.
|
||||
srvConfig = serverCmdConfig{
|
||||
serverAddr: serverAddress,
|
||||
|
||||
Reference in New Issue
Block a user