Skip to content

Commit

Permalink
Update Atomix client to v1beta1 API (#1069)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuujo authored Feb 3, 2020
1 parent 566694c commit 217c31e
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion benchmark/gnmi/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type BenchmarkSuite struct {
// SetupSuite :: benchmark
func (s *BenchmarkSuite) SetupSuite(c *benchmark.Context) {
setup.Atomix()
setup.Partitions().Raft()
setup.Database().Raft()
setup.Topo().SetReplicas(2)
setup.Config().SetReplicas(2)
setup.SetupOrDie()
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ module github.com/onosproject/onos-config
go 1.12

require (
github.com/atomix/api v0.0.0-20200202100958-13b24edbe32d
github.com/atomix/atomix-k8s-controller v0.0.0-20191203231043-ae7d3a341174 // indirect
github.com/atomix/go-client v0.0.0-20200124061314-d0420ff9ffa8
github.com/atomix/go-framework v0.0.0-20200124061342-61b0ae5140c9
github.com/atomix/go-local v0.0.0-20200124003802-357f6682b2f4
github.com/atomix/go-client v0.0.0-20200202124444-2b0271852fac
github.com/atomix/go-framework v0.0.0-20200202102454-440bc2678f1c
github.com/atomix/go-local v0.0.0-20200202105028-743d224c66eb
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/docker/docker v1.13.1
github.com/gogo/protobuf v1.3.1
github.com/golang/mock v1.3.1
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
github.com/mitchellh/go-homedir v1.1.0
github.com/onosproject/onos-test v0.0.0-20200124030233-2ce11592f40b
github.com/onosproject/onos-test v0.0.0-20200202125349-5b744e8890fb
github.com/onosproject/onos-topo v0.0.0-20191113170912-88eeee89f4eb
github.com/openconfig/gnmi v0.0.0-20190823184014-89b2bf29312c
github.com/openconfig/goyang v0.0.0-20190924211109-064f9690516f
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/atomix/api v0.0.0-20200123231207-4e5fb1cbaf40 h1:wLOZYpUQvIVrQOEhN5ND4CXq60yHHMPu7+s1wGG7yU8=
github.com/atomix/api v0.0.0-20200123231207-4e5fb1cbaf40/go.mod h1:Ec7OEwfv1qGASdRZdXxi6TUvwmayT4IkkewDcm7pItI=
github.com/atomix/api v0.0.0-20200202100958-13b24edbe32d h1:rM+AnOZfgosBZzvkbZUbttAWKkj3m6y2f4Jj4jo7YA4=
github.com/atomix/api v0.0.0-20200202100958-13b24edbe32d/go.mod h1:Ec7OEwfv1qGASdRZdXxi6TUvwmayT4IkkewDcm7pItI=
github.com/atomix/atomix-api v0.0.0-20190826211343-dd8f4db3bf77/go.mod h1:joWKUd0zIeYbAQ0vmYHGsnV03ZgRalhceHgnJ3EN0mI=
github.com/atomix/atomix-api v0.0.0-20191002225141-1ee9c98c7dfd/go.mod h1:joWKUd0zIeYbAQ0vmYHGsnV03ZgRalhceHgnJ3EN0mI=
github.com/atomix/atomix-api v0.0.0-20191005223910-aa620357faa0/go.mod h1:joWKUd0zIeYbAQ0vmYHGsnV03ZgRalhceHgnJ3EN0mI=
Expand Down Expand Up @@ -86,14 +88,22 @@ github.com/atomix/atomix-k8s-controller v0.0.0-20191203231043-ae7d3a341174/go.mo
github.com/atomix/go-client v0.0.0-20200124004211-e5e19cd4730d/go.mod h1:KBBiViOYhnvSh/U0fIYiuJ8j+k63eyRWZl42kwdseFI=
github.com/atomix/go-client v0.0.0-20200124061314-d0420ff9ffa8 h1:qryNBxX/wtj+mP9TDuDSZGttIe1eEjCh+oY/XhjgwHo=
github.com/atomix/go-client v0.0.0-20200124061314-d0420ff9ffa8/go.mod h1:KBBiViOYhnvSh/U0fIYiuJ8j+k63eyRWZl42kwdseFI=
github.com/atomix/go-client v0.0.0-20200202124444-2b0271852fac h1:ePNAXVryk9ML5dah7XjCNGeEca+sBDqZeOqhj14Gpxo=
github.com/atomix/go-client v0.0.0-20200202124444-2b0271852fac/go.mod h1:VWAEeWdocSRL1cqMs3zZ32kuIzMAbheoV02wsEVYwhw=
github.com/atomix/go-framework v0.0.0-20200123235029-e29fc7d6e104/go.mod h1:Dn7tjt5LIRA/qr5afQZDh9hdtvK82uQpMrADYIlVtfQ=
github.com/atomix/go-framework v0.0.0-20200124003840-f24758b13aa2/go.mod h1:vo5K/v+rc5mohoZIw9vbyj+Y/EGGaEdF6XVkEvM9CSM=
github.com/atomix/go-framework v0.0.0-20200124061342-61b0ae5140c9 h1:GyxC/X6SMje0Xg+bQaMHhC76S0mqMfFGN7w+HsElnok=
github.com/atomix/go-framework v0.0.0-20200124061342-61b0ae5140c9/go.mod h1:G/yTdMGpfwbA2YXym/VEi7op3qZKd1jtGJX0sjcZmpQ=
github.com/atomix/go-framework v0.0.0-20200202102454-440bc2678f1c h1:oBev1tWxnLlwKhAwGnDdKoe6cVqbTBrPCC4VW0aB2Sk=
github.com/atomix/go-framework v0.0.0-20200202102454-440bc2678f1c/go.mod h1:EJ/rV5Eea5cPJ7z8LR5Ql/6c6mZEceeH84d7yX5o8No=
github.com/atomix/go-local v0.0.0-20200124003802-357f6682b2f4 h1:acDXXOuqzbqfOYDTMvz4dhckHfmH0DMfXSQE+gLFGOA=
github.com/atomix/go-local v0.0.0-20200124003802-357f6682b2f4/go.mod h1:MabPkX/j2bN399GVAYGigyvDaAslu7omZoujEfzdKDg=
github.com/atomix/go-local v0.0.0-20200202105028-743d224c66eb h1:MCstZMd7aizXswJ69hf3fzYU3StG4Ge/vHEfp3mS518=
github.com/atomix/go-local v0.0.0-20200202105028-743d224c66eb/go.mod h1:r+i7K/PMo9+0J0vQM7f7gjSsr8uZj6iiqkc8xLOIR/U=
github.com/atomix/kubernetes-controller v0.0.0-20200124024416-04b783c4ede4 h1:1MPcQB8Q1YpR3mKA5ybpVUpr16zgGZCLU8X2CbYrpfo=
github.com/atomix/kubernetes-controller v0.0.0-20200124024416-04b783c4ede4/go.mod h1:6Jz1WZ379QpUynR5+7WoSC1/pCIn+yDxopSOV2Lmjas=
github.com/atomix/kubernetes-controller v0.0.0-20200202101151-b31765af9a0f h1:nqP97ZUi2T4cAyouMhMifklYMW5EjRDgYQLeOQN0nW8=
github.com/atomix/kubernetes-controller v0.0.0-20200202101151-b31765af9a0f/go.mod h1:ud/7iiSYTsZ6mrzCMTpfMnUT6wCx9e/9tHavM7ZMYWA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
Expand Down Expand Up @@ -266,6 +276,8 @@ github.com/onosproject/onos-test v0.0.0-20200124000609-2c23d699896e h1:kv4nCTX9h
github.com/onosproject/onos-test v0.0.0-20200124000609-2c23d699896e/go.mod h1:yL/WBZiJEjdBPtVRP7OkP6qdg9+kW1N+92c6xz12cSs=
github.com/onosproject/onos-test v0.0.0-20200124030233-2ce11592f40b h1:rtjgklvuQoh+6CzcWKBqiqxuDxVbBjxVuvMZLvcN5L8=
github.com/onosproject/onos-test v0.0.0-20200124030233-2ce11592f40b/go.mod h1:1LWbQObEmAY+C0jIQ2CPaD2vIoaMn5BfZ+39n5q9AAM=
github.com/onosproject/onos-test v0.0.0-20200202125349-5b744e8890fb h1:qMGOPTKGrxN1692scl/VsZVbF1UWEHzVYmDAx2fF7O8=
github.com/onosproject/onos-test v0.0.0-20200202125349-5b744e8890fb/go.mod h1:Nby//C8vU8SKh5Oh+WrTStE54VefuUSzMQQY0FrqMxo=
github.com/onosproject/onos-topo v0.0.0-20191107000708-af85b82cfca3 h1:J0qw6ZRZiLvWm94Yu1HI7K/hNG/52aRdnBErYmLJL3M=
github.com/onosproject/onos-topo v0.0.0-20191107000708-af85b82cfca3/go.mod h1:oPGdJnMHy5UGx4slrbf84DEFqcKXuGMv36N+EBc3QwM=
github.com/onosproject/onos-topo v0.0.0-20191113170912-88eeee89f4eb h1:jcQhZMMGue2jeAs0A2HVTGpybxywHjyRoyd+b0R96B8=
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/change/device/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
group, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func newLocalStore(address net.Address) (Store, error) {
Namespace: "local",
Name: getDeviceChangesName(deviceID),
}
return indexedmap.New(context.Background(), counterName, []net.Address{address})
return indexedmap.New(context.Background(), counterName, []primitive.Partition{{ID: 1, Address: address}})
}

return &atomixStore{
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/change/network/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
group, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}
Expand All @@ -71,7 +71,7 @@ func newLocalStore(address net.Address) (Store, error) {
Namespace: "local",
Name: changesName,
}
changes, err := indexedmap.New(context.Background(), configsName, []net.Address{address})
changes, err := indexedmap.New(context.Background(), configsName, []primitive.Partition{{ID: 1, Address: address}})
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/leadership/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
group, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func newLocalStore(nodeID cluster.NodeID, address net.Address) (Store, error) {
Name: primitiveName,
}

election, err := election.New(context.Background(), name, []net.Address{address}, session.WithID(string(nodeID)))
election, err := election.New(context.Background(), name, []primitive.Partition{{ID: 1, Address: address}}, session.WithID(string(nodeID)))
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/mastership/election.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import (
)

// newAtomixElection returns a new persistent device mastership election
func newAtomixElection(deviceID topodevice.ID, group *client.PartitionGroup) (deviceMastershipElection, error) {
func newAtomixElection(deviceID topodevice.ID, database *client.Database) (deviceMastershipElection, error) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
election, err := group.GetElection(ctx, fmt.Sprintf("mastership-%s", deviceID), session.WithID(string(cluster.GetNodeID())), session.WithTimeout(15*time.Second))
election, err := database.GetElection(ctx, fmt.Sprintf("mastership-%s", deviceID), session.WithID(string(cluster.GetNodeID())), session.WithTimeout(15*time.Second))
cancel()
if err != nil {
return nil, err
Expand All @@ -47,7 +47,7 @@ func newLocalElection(deviceID topodevice.ID, nodeID cluster.NodeID, address net
Namespace: "local",
Name: fmt.Sprintf("mastership-%s", deviceID),
}
election, err := election.New(context.Background(), name, []net.Address{address}, session.WithID(string(nodeID)), session.WithTimeout(15*time.Second))
election, err := election.New(context.Background(), name, []primitive.Partition{{ID: 1, Address: address}}, session.WithID(string(nodeID)), session.WithTimeout(15*time.Second))
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/mastership/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
database, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}

return &atomixStore{
nodeID: cluster.GetNodeID(),
newElection: func(id topodevice.ID) (deviceMastershipElection, error) {
return newAtomixElection(id, group)
return newAtomixElection(id, database)
},
elections: make(map[topodevice.ID]deviceMastershipElection),
}, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/snapshot/device/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
group, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -73,7 +73,7 @@ func newLocalStore(address net.Address) (Store, error) {
Namespace: "local",
Name: deviceSnapshotsName,
}
deviceSnapshots, err := _map.New(context.Background(), deviceSnapshotsName, []net.Address{address})
deviceSnapshots, err := _map.New(context.Background(), deviceSnapshotsName, []primitive.Partition{{ID: 1, Address: address}})
if err != nil {
return nil, err
}
Expand All @@ -82,7 +82,7 @@ func newLocalStore(address net.Address) (Store, error) {
Namespace: "local",
Name: snapshotsName,
}
snapshots, err := _map.New(context.Background(), snapshotsName, []net.Address{address})
snapshots, err := _map.New(context.Background(), snapshotsName, []primitive.Partition{{ID: 1, Address: address}})
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/store/snapshot/network/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewAtomixStore() (Store, error) {
return nil, err
}

group, err := client.GetGroup(context.Background(), utils.GetAtomixRaftGroup())
group, err := client.GetDatabase(context.Background(), utils.GetAtomixRaftGroup())
if err != nil {
return nil, err
}
Expand All @@ -71,7 +71,7 @@ func newLocalStore(address net.Address) (Store, error) {
Namespace: "local",
Name: snapshotsName,
}
snapshots, err := indexedmap.New(context.Background(), snapshotsName, []net.Address{address})
snapshots, err := indexedmap.New(context.Background(), snapshotsName, []primitive.Partition{{ID: 1, Address: address}})
if err != nil {
return nil, err
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/store/utils/atomix.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package utils

import (
"fmt"
"github.com/atomix/api/proto/atomix/controller"
"github.com/atomix/go-client/pkg/client"
netutil "github.com/atomix/go-client/pkg/client/util/net"
"github.com/atomix/go-framework/pkg/atomix"
Expand Down Expand Up @@ -43,7 +44,11 @@ func StartLocalNode() (*atomix.Node, netutil.Address) {
if err != nil {
continue
}
node := local.NewNode(lis, registry.Registry)
node := local.NewNode(lis, registry.Registry, []*controller.PartitionId{
{
Partition: 1,
},
})
_ = node.Start()
return node, address
}
Expand Down
6 changes: 3 additions & 3 deletions test/cli/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type SmokeTestSuite struct {
// SetupTestSuite sets up the onos-config test suite
func (s *SmokeTestSuite) SetupTestSuite() {
setup.Atomix()
setup.Partitions().Raft()
setup.Database().Raft()
setup.Topo().SetReplicas(2)
setup.Config().SetReplicas(2)
setup.SetupOrDie()
Expand All @@ -45,7 +45,7 @@ type TestSuite struct {
// SetupTestSuite sets up the onos-config CLI test suite
func (s *TestSuite) SetupTestSuite() {
setup.Atomix()
setup.Partitions().Raft()
setup.Database().Raft()
setup.CLI().SetEnabled()
setup.Topo().SetReplicas(2)
setup.Config().SetReplicas(2)
Expand All @@ -60,7 +60,7 @@ type HATestSuite struct {
// SetupTestSuite sets up the onos-config CLI test suite
func (s *HATestSuite) SetupTestSuite() {
setup.Atomix()
setup.Partitions().Raft()
setup.Database().Raft()
setup.Topo().SetReplicas(2)
setup.Config().SetReplicas(2)
setup.SetupOrDie()
Expand Down
2 changes: 1 addition & 1 deletion test/gnmi/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type TestSuite struct {
// SetupTestSuite sets up the onos-config gNMI test suite
func (s *TestSuite) SetupTestSuite() {
setup.Atomix()
setup.Partitions().Raft()
setup.Database().Raft()
setup.Topo().SetReplicas(2)
setup.Config().SetReplicas(2)
setup.SetupOrDie()
Expand Down
4 changes: 2 additions & 2 deletions test/ha/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ type TestSuite struct {

// SetupTestSuite sets up the onos-config CLI test suite
func (s *TestSuite) SetupTestSuite() {
setup.Partitions().Raft().
setup.Database().Raft().
SetPartitions(3).
SetReplicasPerPartition(3)
SetReplicas(3)
setup.Topo().
SetReplicas(2)
setup.Config().
Expand Down

0 comments on commit 217c31e

Please sign in to comment.