Skip to content

Commit

Permalink
Removed routers UUID (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
poolnam authored Dec 24, 2020
1 parent 0ba46f4 commit 3f0c458
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 23 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ clusters:
routers:
- name: 'my_cluster_router_1'
addr: 'localhost:3301'
uuid: 'my_cluster_router_1'
```
You might override default connection settings for each cluster.
Expand All @@ -56,7 +55,6 @@ clusters:
routers:
- name: 'my_cluster_router_1'
addr: 'localhost:3301'
uuid: 'my_cluster_router_1'
```
For a sample vshard configuration,
Expand Down
3 changes: 1 addition & 2 deletions example/qumomf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,4 @@ clusters:

routers:
- name: 'router_1'
uuid: 'router_1_uuid'
addr: '127.0.0.1:9301'
addr: '127.0.0.1:9301'
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ type ClusterConfig struct {
type RouterConfig struct {
Name string `yaml:"name"`
Addr string `yaml:"addr"`
UUID string `yaml:"uuid"`
}

func Setup(path string) (*Config, error) {
Expand Down
3 changes: 0 additions & 3 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ func TestSetup_ValidPath(t *testing.T) {
{
Name: "sandbox1-router1",
Addr: "127.0.0.1:9301",
UUID: "a94e7310-13f0-4690-b136-169599e87ba0",
},
{
Name: "sandbox1-router2",
Addr: "127.0.0.1:9302",
UUID: "a3ef657e-eb9a-4730-b420-7ea78d52797d",
},
},
},
Expand All @@ -104,7 +102,6 @@ func TestSetup_ValidPath(t *testing.T) {
{
Name: "sandbox2-router1",
Addr: "127.0.0.1:7301",
UUID: "38dbe90b-9bca-4766-a98c-f02e56ddf986",
},
},
},
Expand Down
9 changes: 3 additions & 6 deletions internal/vshard/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ func NewCluster(name string, cfg config.ClusterConfig) *Cluster {
routers := make([]Router, 0, len(cfg.Routers))
for _, r := range cfg.Routers {
uri := r.Addr
uuid := RouterUUID(r.UUID)
routers = append(routers, NewRouter(uri, uuid))
routers = append(routers, NewRouter(uri))
}
c.snapshot.Routers = routers

Expand Down Expand Up @@ -281,7 +280,7 @@ func (c *Cluster) Discover() {
c.logger.Error().Msg("There is no router in the cluster to discover its topology")
return
}
c.logger.Debug().Str("uuid", string(router.UUID)).Str("uri", router.URI).Msgf("Picked up the router in the cluster to discover its topology")
c.logger.Debug().Str("uri", router.URI).Msgf("Picked up the router in the cluster to discover its topology")

// Read the topology configuration from the selected router.
conn := c.Connector(router.URI)
Expand All @@ -291,7 +290,6 @@ func (c *Cluster) Discover() {
c.logger.
Err(resp.Error).
Str("URI", router.URI).
Str("UUID", string(router.UUID)).
Msgf("Failed to discover the topology of the cluster. Error code: %d", resp.ErrorCode)
return
}
Expand All @@ -301,7 +299,6 @@ func (c *Cluster) Discover() {
metrics.RecordDiscoveryError(router.URI)
c.logger.Err(err).
Str("URI", router.URI).
Str("UUID", string(router.UUID)).
Msg("Failed to discover the topology of the cluster using router")
return
}
Expand Down Expand Up @@ -359,7 +356,7 @@ func (c *Cluster) Discover() {
}
for i := range ns.Routers {
r := &ns.Routers[i]
if r.UUID == router.UUID {
if r.URI == router.URI {
r.Info = updatedRI
break
}
Expand Down
1 change: 0 additions & 1 deletion internal/vshard/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestCluster_Discover(t *testing.T) {
routers := c.Routers()
require.Len(t, routers, 1)
r := routers[0]
assert.Equal(t, RouterUUID("router_uuid_1"), r.UUID)
assert.Equal(t, "127.0.0.1:9301", r.URI)

sets := c.ReplicaSets()
Expand Down
1 change: 0 additions & 1 deletion internal/vshard/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func MockCluster() *Cluster {
{
Name: "router_1",
Addr: "127.0.0.1:9301",
UUID: "router_uuid_1",
},
},
})
Expand Down
2 changes: 0 additions & 2 deletions internal/vshard/orchestrator/failover.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,10 @@ func (f *failover) promoteFollowerToMaster(ctx context.Context, analysis *Replic
if resp.Error == nil {
logger.Info().
Str("URI", r.URI).
Str("UUID", string(r.UUID)).
Msg("Configuration was updated on router")
} else {
logger.Err(resp.Error).
Str("URI", r.URI).
Str("UUID", string(r.UUID)).
Msg("Failed to update configuration on router")
}
}
Expand Down
7 changes: 2 additions & 5 deletions internal/vshard/router.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package vshard

type RouterUUID string
type InstanceStatus string

const (
Expand All @@ -11,14 +10,12 @@ const (

type Router struct {
URI string `json:"uri"`
UUID RouterUUID `json:"uuid"`
Info RouterInfo `json:"info"`
}

func NewRouter(uri string, uuid RouterUUID) Router {
func NewRouter(uri string) Router {
return Router{
URI: uri,
UUID: uuid,
URI: uri,
Info: RouterInfo{
Status: -1,
},
Expand Down

0 comments on commit 3f0c458

Please sign in to comment.