Skip to content

Commit

Permalink
[membership] Replace Ringop with PeerProvider interface (uber#4653)
Browse files Browse the repository at this point in the history
  • Loading branch information
mantas-sidlauskas authored Nov 24, 2021
1 parent 429db90 commit 770e9ec
Show file tree
Hide file tree
Showing 19 changed files with 913 additions and 542 deletions.
6 changes: 3 additions & 3 deletions client/history/peerResolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func TestPeerResolver(t *testing.T) {
numShards := 123
controller := gomock.NewController(t)
serviceResolver := membership.NewMockResolver(controller)
serviceResolver.EXPECT().Lookup(service.History, string(rune(common.DomainIDToHistoryShard("domainID", numShards)))).Return(membership.NewHostInfo("domainHost:thriftPort", nil), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(common.WorkflowIDToHistoryShard("workflowID", numShards)))).Return(membership.NewHostInfo("workflowHost:thriftPort", nil), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(99))).Return(membership.NewHostInfo("shardHost:thriftPort", nil), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(common.DomainIDToHistoryShard("domainID", numShards)))).Return(membership.NewHostInfo("domainHost:thriftPort"), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(common.WorkflowIDToHistoryShard("workflowID", numShards)))).Return(membership.NewHostInfo("workflowHost:thriftPort"), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(99))).Return(membership.NewHostInfo("shardHost:thriftPort"), nil)
serviceResolver.EXPECT().Lookup(service.History, string(rune(11))).Return(nil, assert.AnError)

r := NewPeerResolver(numShards, serviceResolver, fakeAddressMapper)
Expand Down
6 changes: 3 additions & 3 deletions client/matching/peerResolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ import (
func TestPeerResolver(t *testing.T) {
controller := gomock.NewController(t)
serviceResolver := membership.NewMockResolver(controller)
serviceResolver.EXPECT().Lookup(service.Matching, "taskListA").Return(membership.NewHostInfo("taskListA:thriftPort", nil), nil)
serviceResolver.EXPECT().Lookup(service.Matching, "taskListA").Return(membership.NewHostInfo("taskListA:thriftPort"), nil)
serviceResolver.EXPECT().Lookup(service.Matching, "invalid").Return(nil, assert.AnError)
serviceResolver.EXPECT().Members(service.Matching).Return([]*membership.HostInfo{
membership.NewHostInfo("taskListA:thriftPort", nil),
membership.NewHostInfo("taskListB:thriftPort", nil),
membership.NewHostInfo("taskListA:thriftPort"),
membership.NewHostInfo("taskListB:thriftPort"),
}, nil)

r := NewPeerResolver(serviceResolver, fakeAddressMapper)
Expand Down
15 changes: 13 additions & 2 deletions cmd/server/cadence/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/uber/cadence/common/membership"
"github.com/uber/cadence/common/messaging/kafka"
"github.com/uber/cadence/common/metrics"
"github.com/uber/cadence/common/peerprovider/ringpopprovider"
"github.com/uber/cadence/common/resource"
"github.com/uber/cadence/common/rpc"
"github.com/uber/cadence/common/service"
Expand Down Expand Up @@ -156,10 +157,20 @@ func (s *server) startService() common.Daemon {
)
rpcFactory := rpc.NewFactory(params.Logger, rpcParams)
params.RPCFactory = rpcFactory
params.MembershipResolver, err = membership.NewResolver(

peerProvider, err := ringpopprovider.New(
params.Name,
&s.cfg.Ringpop,
rpcFactory.GetChannel(),
params.Name,
params.Logger,
)

if err != nil {
log.Fatalf("ringpop provider failed: %v", err)
}

params.MembershipResolver, err = membership.NewResolver(
peerProvider,
params.Logger,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ import (

"github.com/uber/cadence/common/dynamicconfig"
c "github.com/uber/cadence/common/dynamicconfig/configstore/config"
"github.com/uber/cadence/common/membership"
"github.com/uber/cadence/common/peerprovider/ringpopprovider"
"github.com/uber/cadence/common/service"
)

type (
// Config contains the configuration for a set of cadence services
Config struct {
// Ringpop is the ringpop related configuration
Ringpop membership.RingpopConfig `yaml:"ringpop"`
Ringpop ringpopprovider.Config `yaml:"ringpop"`
// Persistence contains the configuration for cadence datastores
Persistence Persistence `yaml:"persistence"`
// Log is the logging config
Expand Down
Loading

0 comments on commit 770e9ec

Please sign in to comment.