1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-05 12:45:38 +01:00

Using peerid instead of nodeid

This commit is contained in:
rishubhjain
2018-06-23 12:38:09 -04:00
committed by Aravinda VK
parent cfbb8641a6
commit 96a5d9d7b8
20 changed files with 50 additions and 50 deletions

View File

@@ -22,7 +22,7 @@ volume.auth.password
```
brick.id
brick.hostname
brick.nodeid
brick.peerid
brick.path
brick.volumename
brick.volumeid

View File

@@ -117,7 +117,7 @@ func handleMessage(inMessage string, addr *net.UDPAddr) {
message := make(map[string]interface{})
message["ts"] = time.Now().Unix()
message["nodeid"] = gdctx.MyUUID.String()
message["peerid"] = gdctx.MyUUID.String()
message["message"] = msgDict
marshalledMsg, err := json.Marshal(message)

View File

@@ -20,15 +20,15 @@ const (
)
// IsNodeAlive returns true and pid if the node specified is alive as seen by the store
func (s *GDStore) IsNodeAlive(nodeID interface{}) (int, bool) {
func (s *GDStore) IsNodeAlive(peerID interface{}) (int, bool) {
var keySuffix string
switch nodeID.(type) {
switch peerID.(type) {
case uuid.UUID:
keySuffix = nodeID.(uuid.UUID).String()
keySuffix = peerID.(uuid.UUID).String()
case string:
keySuffix = nodeID.(string)
keySuffix = peerID.(string)
if uuid.Parse(keySuffix) == nil {
return 0, false
}

View File

@@ -18,11 +18,11 @@ type TxnCtx interface {
// Set attaches the given key with value to the context. It updates value if key exists already.
Set(key string, value interface{}) error
// SetNodeResult is similar to Set but prefixes the key with node UUID specified.
SetNodeResult(nodeID uuid.UUID, key string, value interface{}) error
SetNodeResult(peerID uuid.UUID, key string, value interface{}) error
// Get gets the value for the given key. Returns an error if the key is not present
Get(key string, value interface{}) error
// GetNodeResult is similar to Get but prefixes the key with node UUID specified.
GetNodeResult(nodeID uuid.UUID, key string, value interface{}) error
GetNodeResult(peerID uuid.UUID, key string, value interface{}) error
// Delete deletes the key and value
Delete(key string) error
// Logger returns the Logrus logger associated with the context
@@ -121,8 +121,8 @@ func (c *Tctx) commit() error {
// SetNodeResult is similar to Set but prefixes the key with the node UUID
// specified. This function can be used by nodes to store results of
// transaction steps.
func (c *Tctx) SetNodeResult(nodeID uuid.UUID, key string, value interface{}) error {
storeKey := nodeID.String() + "/" + key
func (c *Tctx) SetNodeResult(peerID uuid.UUID, key string, value interface{}) error {
storeKey := peerID.String() + "/" + key
return c.Set(storeKey, value)
}
@@ -160,8 +160,8 @@ func (c *Tctx) Get(key string, value interface{}) error {
// GetNodeResult is similar to Get but prefixes the key with node UUID
// specified. This function can be used by the transaction initiator node to
// fetch results of transaction step run on remote nodes.
func (c *Tctx) GetNodeResult(nodeID uuid.UUID, key string, value interface{}) error {
storeKey := nodeID.String() + "/" + key
func (c *Tctx) GetNodeResult(peerID uuid.UUID, key string, value interface{}) error {
storeKey := peerID.String() + "/" + key
return c.Get(storeKey, value)
}

View File

@@ -25,8 +25,8 @@ func (m *MockTctx) Set(key string, value interface{}) error {
}
// SetNodeResult is similar to Set but prefixes the key with the node UUID specified.
func (m *MockTctx) SetNodeResult(nodeID uuid.UUID, key string, value interface{}) error {
storeKey := nodeID.String() + "/" + key
func (m *MockTctx) SetNodeResult(peerID uuid.UUID, key string, value interface{}) error {
storeKey := peerID.String() + "/" + key
return m.Set(storeKey, value)
}
@@ -40,8 +40,8 @@ func (m *MockTctx) Get(key string, value interface{}) error {
}
// GetNodeResult is similar to Get but prefixes the key with node UUID specified.
func (m *MockTctx) GetNodeResult(nodeID uuid.UUID, key string, value interface{}) error {
storeKey := nodeID.String() + "/" + key
func (m *MockTctx) GetNodeResult(peerID uuid.UUID, key string, value interface{}) error {
storeKey := peerID.String() + "/" + key
return m.Get(storeKey, value)
}

View File

@@ -123,11 +123,11 @@ func getClientVolFilePath(volname string) string {
return path.Join(dir, file)
}
func getBrickVolFilePath(volname string, brickNodeID string, brickPath string) string {
func getBrickVolFilePath(volname string, brickPeerID string, brickPath string) string {
dir := utils.GetVolumeDir(volname)
brickPathWithoutSlashes := strings.Trim(strings.Replace(brickPath, "/", "-", -1), "-")
file := fmt.Sprintf("%s.%s.%s.vol", volname, brickNodeID, brickPathWithoutSlashes)
file := fmt.Sprintf("%s.%s.%s.vol", volname, brickPeerID, brickPathWithoutSlashes)
return path.Join(dir, file)
}

View File

@@ -29,7 +29,7 @@ func typeInSubvolType(ele volume.SubvolType, list []volume.SubvolType) bool {
return false
}
func clusterGraph(volfile *Volfile, dht *Entry, vol *volume.Volinfo, nodeid uuid.UUID, filters *clusterGraphFilters) {
func clusterGraph(volfile *Volfile, dht *Entry, vol *volume.Volinfo, peerid uuid.UUID, filters *clusterGraphFilters) {
numSubvols := len(vol.Subvols)
decommissionedBricks := []string{}
clientIdx := 0
@@ -79,7 +79,7 @@ func clusterGraph(volfile *Volfile, dht *Entry, vol *volume.Volinfo, nodeid uuid
clientIdx++
// If local bricks only
if filters != nil && filters.onlyLocalBricks && !uuid.Equal(b.PeerID, nodeid) {
if filters != nil && filters.onlyLocalBricks && !uuid.Equal(b.PeerID, peerid) {
continue
}

View File

@@ -30,14 +30,14 @@ type extrainfo struct {
func generateClusterLevelVolfiles(clusterinfo []*volume.Volinfo, xopts *map[string]extrainfo) error {
for _, cvf := range clusterVolfiles {
if cvf.nodeLevel {
for _, nodeid := range nodesFromClusterInfo(clusterinfo) {
for _, peerid := range nodesFromClusterInfo(clusterinfo) {
volfile := New(cvf.name)
cvf.fn.(clusterVolfileFunc)(volfile, clusterinfo, nodeid)
cvf.fn.(clusterVolfileFunc)(volfile, clusterinfo, peerid)
volfiledata, err := volfile.Generate("", xopts)
if err != nil {
return err
}
err = save(nodeid.String()+"-"+volfile.FileName, volfiledata)
err = save(peerid.String()+"-"+volfile.FileName, volfiledata)
if err != nil {
return err
}
@@ -63,14 +63,14 @@ func generateVolumeLevelVolfiles(clusterinfo []*volume.Volinfo, xopts *map[strin
for _, volinfo := range clusterinfo {
for _, vvf := range volumeVolfiles {
if vvf.nodeLevel {
for _, nodeid := range volinfo.Nodes() {
for _, peerid := range volinfo.Nodes() {
volfile := New(vvf.name)
vvf.fn.(volumeVolfileFunc)(volfile, volinfo, nodeid)
vvf.fn.(volumeVolfileFunc)(volfile, volinfo, peerid)
volfiledata, err := volfile.Generate("", xopts)
if err != nil {
return err
}
err = save(nodeid.String()+"-"+volfile.FileName, volfiledata)
err = save(peerid.String()+"-"+volfile.FileName, volfiledata)
if err != nil {
return err
}
@@ -98,14 +98,14 @@ func generateBrickLevelVolfiles(clusterinfo []*volume.Volinfo, xopts *map[string
for _, brick := range volinfo.GetBricks() {
for _, bvf := range brickVolfiles {
if bvf.nodeLevel {
for _, nodeid := range nodes {
for _, peerid := range nodes {
volfile := New(bvf.name)
bvf.fn.(brickVolfileFunc)(volfile, &brick, volinfo, nodeid)
bvf.fn.(brickVolfileFunc)(volfile, &brick, volinfo, peerid)
volfiledata, err := volfile.Generate("", xopts)
if err != nil {
return err
}
err = save(nodeid.String()+"-"+volfile.FileName, volfiledata)
err = save(peerid.String()+"-"+volfile.FileName, volfiledata)
if err != nil {
return err
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/pborman/uuid"
)
func generateBitdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid uuid.UUID) {
func generateBitdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "gluster/bitd"
bitd := volfile.RootEntry.Add("debug/io-stats", nil, nil).SetName("bitd")
@@ -20,7 +20,7 @@ func generateBitdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid
if exists && val == "on" {
name := fmt.Sprintf("%s-bit-rot-%d", vol.Name, volIdx)
bitdvol := bitd.Add("features/bit-rot", vol, nil).SetName(name).SetIgnoreOptions([]string{"scrubber"})
clusterGraph(volfile, bitdvol, vol, nodeid, &clusterGraphFilters{onlyLocalBricks: true})
clusterGraph(volfile, bitdvol, vol, peerid, &clusterGraphFilters{onlyLocalBricks: true})
}
}
}

View File

@@ -9,7 +9,7 @@ import (
"github.com/pborman/uuid"
)
func generateBrickVolfile(volfile *Volfile, b *brick.Brickinfo, vol *volume.Volinfo, nodeid uuid.UUID) {
func generateBrickVolfile(volfile *Volfile, b *brick.Brickinfo, vol *volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = fmt.Sprintf("%s.%s.%s",
vol.Name,
b.PeerID,

View File

@@ -6,7 +6,7 @@ import (
"github.com/pborman/uuid"
)
func generateTCPFuseVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.UUID) {
func generateTCPFuseVolfile(volfile *Volfile, vol *volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = vol.VolfileID
dht := volfile.RootEntry.Add("debug/io-stats", vol, nil).SetName(vol.Name).
@@ -20,7 +20,7 @@ func generateTCPFuseVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.U
Add("performance/write-behind", vol, nil).
Add("cluster/distribute", vol, nil)
clusterGraph(volfile, dht, vol, nodeid, nil)
clusterGraph(volfile, dht, vol, peerid, nil)
}
func init() {

View File

@@ -6,7 +6,7 @@ import (
"github.com/pborman/uuid"
)
func generateTCPGfProxyFuseVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.UUID) {
func generateTCPGfProxyFuseVolfile(volfile *Volfile, vol *volume.Volinfo, peerid uuid.UUID) {
/*
Name should be different for snapshot
@@ -18,7 +18,7 @@ func generateTCPGfProxyFuseVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid
Add("protocol/client", vol, nil).SetExtraData(map[string]string{"brick.path": "gfproxyd-" + vol.Name, "brick.hostname": ""})
}
func generateGfproxydVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.UUID) {
func generateGfproxydVolfile(volfile *Volfile, vol *volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "gfproxyd/" + vol.Name
@@ -33,7 +33,7 @@ func generateGfproxydVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.
Add("performance/read-ahead", vol, nil).
Add("cluster/distribute", vol, nil)
clusterGraph(volfile, dht, vol, nodeid, nil)
clusterGraph(volfile, dht, vol, peerid, nil)
}
func init() {

View File

@@ -6,7 +6,7 @@ import (
"github.com/pborman/uuid"
)
func generateQuotadVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid uuid.UUID) {
func generateQuotadVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "gluster/quotad"
quotaOpts := make(map[string]string)
@@ -22,7 +22,7 @@ func generateQuotadVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, node
val, exists := v.Options["features.quota"]
if exists && val == "on" {
dht := quota.Add("cluster/distribute", v, nil).SetName(v.Name)
clusterGraph(volfile, dht, v, nodeid, nil)
clusterGraph(volfile, dht, v, peerid, nil)
}
}
}

View File

@@ -6,14 +6,14 @@ import (
"github.com/pborman/uuid"
)
func generateRebalanceVolfile(volfile *Volfile, vol *volume.Volinfo, nodeid uuid.UUID) {
func generateRebalanceVolfile(volfile *Volfile, vol *volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "rebalance/" + vol.Name
dht := volfile.RootEntry.Add("debug/io-stats", vol, nil).SetName(vol.Name).
Add("cluster/distribute", vol, nil)
clusterGraph(volfile, dht, vol, nodeid, nil)
clusterGraph(volfile, dht, vol, peerid, nil)
}
func init() {

View File

@@ -8,7 +8,7 @@ import (
"github.com/pborman/uuid"
)
func generateScrubVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid uuid.UUID) {
func generateScrubVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "gluster/scrub"
scrub := volfile.RootEntry.Add("debug/io-stats", nil, nil).SetName("scrub")
@@ -19,7 +19,7 @@ func generateScrubVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodei
if exists && val == "on" {
name := fmt.Sprintf("%s-bit-rot-%d", vol.Name, volIdx)
scrubvol := scrub.Add("features/bit-rot", vol, nil).SetName(name)
clusterGraph(volfile, scrubvol, vol, nodeid, &clusterGraphFilters{onlyLocalBricks: true})
clusterGraph(volfile, scrubvol, vol, peerid, &clusterGraphFilters{onlyLocalBricks: true})
}
}
}

View File

@@ -6,7 +6,7 @@ import (
"github.com/pborman/uuid"
)
func generateShdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid uuid.UUID) {
func generateShdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, peerid uuid.UUID) {
volfile.FileName = "gluster/glustershd"
shd := volfile.RootEntry.Add("debug/io-stats", nil, nil).SetName("glustershd")
@@ -16,7 +16,7 @@ func generateShdVolfile(volfile *Volfile, clusterinfo []*volume.Volinfo, nodeid
volume.SubvolReplicate,
volume.SubvolDisperse,
}}
clusterGraph(volfile, shd, vol, nodeid, &filters)
clusterGraph(volfile, shd, vol, peerid, &filters)
}
}

View File

@@ -35,7 +35,7 @@ const (
// GeorepRemoteHost represents Remote host UUID and Hostname
type GeorepRemoteHost struct {
PeerID uuid.UUID `json:"nodeid"`
PeerID uuid.UUID `json:"peerid"`
Hostname string `json:"host"`
}
@@ -64,7 +64,7 @@ type GeorepWorker struct {
// GeorepSSHPublicKey represents one nodes SSH Public key
type GeorepSSHPublicKey struct {
PeerID uuid.UUID `json:"nodeid"`
PeerID uuid.UUID `json:"peerid"`
GsyncdKey string `json:"gsyncd"`
TarKey string `json:"tar"`
}

View File

@@ -40,7 +40,7 @@ const (
// RebalNodeStatus represents the rebalance status on the Node
type RebalNodeStatus struct {
NodeID uuid.UUID `json:"nodeid"`
PeerID uuid.UUID `json:"peerid"`
Status string `json:"status"`
RebalancedFiles string `json:"rebalanced-files"`
RebalancedSize string `json:"size"`

View File

@@ -52,7 +52,7 @@ func HandleEventNotify(status map[string]string) error {
return err
}
rebalNodeStatus.NodeID = gdctx.MyUUID
rebalNodeStatus.PeerID = gdctx.MyUUID
rebalNodeStatus.Status = status["status"]
rebalNodeStatus.RebalancedFiles = status["files"]
rebalNodeStatus.RebalancedSize = status["size"]

View File

@@ -197,7 +197,7 @@ func txnRebalanceStatus(c transaction.TxnCtx) error {
return err
}
rebalNodeStatus.NodeID = gdctx.MyUUID
rebalNodeStatus.PeerID = gdctx.MyUUID
rebalNodeStatus.Status = rspDict["status"]
rebalNodeStatus.RebalancedFiles = rspDict["files"]
rebalNodeStatus.RebalancedSize = rspDict["size"]