You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

replication.go 957 B

1234567891011121314151617181920212223242526272829303132333435
  1. package strategy
  2. import (
  3. "errors"
  4. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/entity"
  5. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/scheduler/strategy/param"
  6. )
  7. type ReplicationStrategy struct {
  8. replicas int32
  9. participants []*entity.Participant
  10. }
  11. func NewReplicationStrategy(params *param.ReplicationParams) *ReplicationStrategy {
  12. return &ReplicationStrategy{replicas: params.GetReplicas(),
  13. participants: params.GetParticipants(),
  14. }
  15. }
  16. func (ps *ReplicationStrategy) Schedule() ([]*AssignedCluster, error) {
  17. if ps.replicas < 1 {
  18. return nil, errors.New("replicas must be greater than 0")
  19. }
  20. if ps.participants == nil {
  21. return nil, errors.New("participantId must be set")
  22. }
  23. var results []*AssignedCluster
  24. for _, p := range ps.participants {
  25. cluster := &AssignedCluster{ParticipantId: p.Participant_id, Name: p.Name, Replicas: ps.replicas}
  26. results = append(results, cluster)
  27. }
  28. return results, nil
  29. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.