Skip to content

Commit

Permalink
feat: update api version to v2.0.7 (#2560)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi authored Jul 25, 2023
1 parent c7d02aa commit b4a390d
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 193 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module d7y.io/dragonfly/v2
go 1.20

require (
d7y.io/api/v2 v2.0.3
d7y.io/api/v2 v2.0.7
github.com/MysteriousPotato/go-lockable v1.0.0
github.com/RichardKnop/machinery v1.10.6
github.com/Showmax/go-fqdn v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
d7y.io/api/v2 v2.0.3 h1:xvLyYJJvZr/U5oX0MFsAaZEDb8/EX+ScSfXD30HhNaQ=
d7y.io/api/v2 v2.0.3/go.mod h1:lwCvFjtRVsyTKsiXfh2W0Jdv+5tQGR/vFj+TknwnusY=
d7y.io/api/v2 v2.0.7 h1:jfvjTaZ4Q1Z/Ak25u3EU2UuXSDlmVI8OWiwqFW8961A=
d7y.io/api/v2 v2.0.7/go.mod h1:lwCvFjtRVsyTKsiXfh2W0Jdv+5tQGR/vFj+TknwnusY=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20201218220906-28db891af037/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U=
Expand Down
56 changes: 28 additions & 28 deletions manager/rpcserver/manager_server_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ func (s *managerServerV1) UpdateSeedPeer(ctx context.Context, req *managerv1.Upd
}

if err := s.db.WithContext(ctx).Model(&seedPeer).Updates(models.SeedPeer{
Type: req.Type,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
DownloadPort: req.DownloadPort,
ObjectStoragePort: req.ObjectStoragePort,
SeedPeerClusterID: uint(req.SeedPeerClusterId),
Type: req.GetType(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
DownloadPort: req.GetDownloadPort(),
ObjectStoragePort: req.GetObjectStoragePort(),
SeedPeerClusterID: uint(req.GetSeedPeerClusterId()),
}).Error; err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -235,15 +235,15 @@ func (s *managerServerV1) UpdateSeedPeer(ctx context.Context, req *managerv1.Upd
// Create SeedPeer and associate cluster.
func (s *managerServerV1) createSeedPeer(ctx context.Context, req *managerv1.UpdateSeedPeerRequest) (*managerv1.SeedPeer, error) {
seedPeer := models.SeedPeer{
Hostname: req.Hostname,
Type: req.Type,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
DownloadPort: req.DownloadPort,
ObjectStoragePort: req.ObjectStoragePort,
SeedPeerClusterID: uint(req.SeedPeerClusterId),
Hostname: req.GetHostname(),
Type: req.GetType(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
DownloadPort: req.GetDownloadPort(),
ObjectStoragePort: req.GetObjectStoragePort(),
SeedPeerClusterID: uint(req.GetSeedPeerClusterId()),
}

if err := s.db.WithContext(ctx).Create(&seedPeer).Error; err != nil {
Expand Down Expand Up @@ -396,11 +396,11 @@ func (s *managerServerV1) UpdateScheduler(ctx context.Context, req *managerv1.Up
}

if err := s.db.WithContext(ctx).Model(&scheduler).Updates(models.Scheduler{
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
SchedulerClusterID: uint(req.SchedulerClusterId),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
}).Error; err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand Down Expand Up @@ -434,13 +434,13 @@ func (s *managerServerV1) UpdateScheduler(ctx context.Context, req *managerv1.Up
// Create scheduler and associate cluster.
func (s *managerServerV1) createScheduler(ctx context.Context, req *managerv1.UpdateSchedulerRequest) (*managerv1.Scheduler, error) {
scheduler := models.Scheduler{
Hostname: req.Hostname,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
Hostname: req.GetHostname(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
Features: types.DefaultSchedulerFeatures,
SchedulerClusterID: uint(req.SchedulerClusterId),
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
}

if err := s.db.WithContext(ctx).Create(&scheduler).Error; err != nil {
Expand Down
96 changes: 48 additions & 48 deletions manager/rpcserver/manager_server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func (s *managerServerV2) GetSeedPeer(ctx context.Context, req *managerv2.GetSee
pbSchedulers = append(pbSchedulers, &managerv2.Scheduler{
Id: uint64(scheduler.ID),
Hostname: scheduler.Hostname,
Idc: scheduler.IDC,
Location: scheduler.Location,
Idc: &scheduler.IDC,
Location: &scheduler.Location,
Ip: scheduler.IP,
Port: scheduler.Port,
State: scheduler.State,
Expand All @@ -152,8 +152,8 @@ func (s *managerServerV2) GetSeedPeer(ctx context.Context, req *managerv2.GetSee
Id: uint64(seedPeer.ID),
Type: seedPeer.Type,
Hostname: seedPeer.Hostname,
Idc: seedPeer.IDC,
Location: seedPeer.Location,
Idc: &seedPeer.IDC,
Location: &seedPeer.Location,
Ip: seedPeer.IP,
Port: seedPeer.Port,
DownloadPort: seedPeer.DownloadPort,
Expand Down Expand Up @@ -198,14 +198,14 @@ func (s *managerServerV2) UpdateSeedPeer(ctx context.Context, req *managerv2.Upd
}

if err := s.db.WithContext(ctx).Model(&seedPeer).Updates(models.SeedPeer{
Type: req.Type,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
DownloadPort: req.DownloadPort,
ObjectStoragePort: req.ObjectStoragePort,
SeedPeerClusterID: uint(req.SeedPeerClusterId),
Type: req.GetType(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
DownloadPort: req.GetDownloadPort(),
ObjectStoragePort: req.GetObjectStoragePort(),
SeedPeerClusterID: uint(req.GetSeedPeerClusterId()),
}).Error; err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand All @@ -221,8 +221,8 @@ func (s *managerServerV2) UpdateSeedPeer(ctx context.Context, req *managerv2.Upd
Id: uint64(seedPeer.ID),
Hostname: seedPeer.Hostname,
Type: seedPeer.Type,
Idc: seedPeer.IDC,
Location: seedPeer.Location,
Idc: &seedPeer.IDC,
Location: &seedPeer.Location,
Ip: seedPeer.IP,
Port: seedPeer.Port,
DownloadPort: seedPeer.DownloadPort,
Expand All @@ -235,15 +235,15 @@ func (s *managerServerV2) UpdateSeedPeer(ctx context.Context, req *managerv2.Upd
// Create SeedPeer and associate cluster.
func (s *managerServerV2) createSeedPeer(ctx context.Context, req *managerv2.UpdateSeedPeerRequest) (*managerv2.SeedPeer, error) {
seedPeer := models.SeedPeer{
Hostname: req.Hostname,
Type: req.Type,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
DownloadPort: req.DownloadPort,
ObjectStoragePort: req.ObjectStoragePort,
SeedPeerClusterID: uint(req.SeedPeerClusterId),
Hostname: req.GetHostname(),
Type: req.GetType(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
DownloadPort: req.GetDownloadPort(),
ObjectStoragePort: req.GetObjectStoragePort(),
SeedPeerClusterID: uint(req.GetSeedPeerClusterId()),
}

if err := s.db.WithContext(ctx).Create(&seedPeer).Error; err != nil {
Expand All @@ -254,8 +254,8 @@ func (s *managerServerV2) createSeedPeer(ctx context.Context, req *managerv2.Upd
Id: uint64(seedPeer.ID),
Hostname: seedPeer.Hostname,
Type: seedPeer.Type,
Idc: seedPeer.IDC,
Location: seedPeer.Location,
Idc: &seedPeer.IDC,
Location: &seedPeer.Location,
Ip: seedPeer.IP,
Port: seedPeer.Port,
DownloadPort: seedPeer.DownloadPort,
Expand Down Expand Up @@ -321,8 +321,8 @@ func (s *managerServerV2) GetScheduler(ctx context.Context, req *managerv2.GetSc
Id: uint64(seedPeer.ID),
Hostname: seedPeer.Hostname,
Type: seedPeer.Type,
Idc: seedPeer.IDC,
Location: seedPeer.Location,
Idc: &seedPeer.IDC,
Location: &seedPeer.Location,
Ip: seedPeer.IP,
Port: seedPeer.Port,
DownloadPort: seedPeer.DownloadPort,
Expand All @@ -349,8 +349,8 @@ func (s *managerServerV2) GetScheduler(ctx context.Context, req *managerv2.GetSc
pbScheduler = managerv2.Scheduler{
Id: uint64(scheduler.ID),
Hostname: scheduler.Hostname,
Idc: scheduler.IDC,
Location: scheduler.Location,
Idc: &scheduler.IDC,
Location: &scheduler.Location,
Ip: scheduler.IP,
Port: scheduler.Port,
State: scheduler.State,
Expand Down Expand Up @@ -396,11 +396,11 @@ func (s *managerServerV2) UpdateScheduler(ctx context.Context, req *managerv2.Up
}

if err := s.db.WithContext(ctx).Model(&scheduler).Updates(models.Scheduler{
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
SchedulerClusterID: uint(req.SchedulerClusterId),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
}).Error; err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
Expand All @@ -421,8 +421,8 @@ func (s *managerServerV2) UpdateScheduler(ctx context.Context, req *managerv2.Up
return &managerv2.Scheduler{
Id: uint64(scheduler.ID),
Hostname: scheduler.Hostname,
Idc: scheduler.IDC,
Location: scheduler.Location,
Idc: &scheduler.IDC,
Location: &scheduler.Location,
Ip: scheduler.IP,
Port: scheduler.Port,
Features: features,
Expand All @@ -434,13 +434,13 @@ func (s *managerServerV2) UpdateScheduler(ctx context.Context, req *managerv2.Up
// Create scheduler and associate cluster.
func (s *managerServerV2) createScheduler(ctx context.Context, req *managerv2.UpdateSchedulerRequest) (*managerv2.Scheduler, error) {
scheduler := models.Scheduler{
Hostname: req.Hostname,
IDC: req.Idc,
Location: req.Location,
IP: req.Ip,
Port: req.Port,
Hostname: req.GetHostname(),
IDC: req.GetIdc(),
Location: req.GetLocation(),
IP: req.GetIp(),
Port: req.GetPort(),
Features: types.DefaultSchedulerFeatures,
SchedulerClusterID: uint(req.SchedulerClusterId),
SchedulerClusterID: uint(req.GetSchedulerClusterId()),
}

if err := s.db.WithContext(ctx).Create(&scheduler).Error; err != nil {
Expand All @@ -456,8 +456,8 @@ func (s *managerServerV2) createScheduler(ctx context.Context, req *managerv2.Up
return &managerv2.Scheduler{
Id: uint64(scheduler.ID),
Hostname: scheduler.Hostname,
Idc: scheduler.IDC,
Location: scheduler.Location,
Idc: &scheduler.IDC,
Location: &scheduler.Location,
Ip: scheduler.IP,
Port: scheduler.Port,
State: scheduler.State,
Expand Down Expand Up @@ -552,8 +552,8 @@ func (s *managerServerV2) ListSchedulers(ctx context.Context, req *managerv2.Lis
Id: uint64(seedPeer.ID),
Hostname: seedPeer.Hostname,
Type: seedPeer.Type,
Idc: seedPeer.IDC,
Location: seedPeer.Location,
Idc: &seedPeer.IDC,
Location: &seedPeer.Location,
Ip: seedPeer.IP,
Port: seedPeer.Port,
DownloadPort: seedPeer.DownloadPort,
Expand All @@ -573,8 +573,8 @@ func (s *managerServerV2) ListSchedulers(ctx context.Context, req *managerv2.Lis
pbListSchedulersResponse.Schedulers = append(pbListSchedulersResponse.Schedulers, &managerv2.Scheduler{
Id: uint64(scheduler.ID),
Hostname: scheduler.Hostname,
Idc: scheduler.IDC,
Location: scheduler.Location,
Idc: &scheduler.IDC,
Location: &scheduler.Location,
Ip: scheduler.IP,
Port: scheduler.Port,
State: scheduler.State,
Expand Down
4 changes: 2 additions & 2 deletions scheduler/announcer/announcer.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ func New(cfg *config.Config, managerClient managerclient.V2, storage storage.Sto
Hostname: a.config.Server.Host,
Ip: a.config.Server.AdvertiseIP.String(),
Port: int32(a.config.Server.AdvertisePort),
Idc: a.config.Host.IDC,
Location: a.config.Host.Location,
Idc: &a.config.Host.IDC,
Location: &a.config.Host.Location,
SchedulerClusterId: uint64(a.config.Manager.SchedulerClusterID),
}); err != nil {
return nil, err
Expand Down
Loading

0 comments on commit b4a390d

Please sign in to comment.