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 720 B

123456789101112131415161718192021222324252627282930313233
  1. package strategy
  2. import (
  3. "errors"
  4. )
  5. type ReplicationStrategy struct {
  6. replicas int32
  7. clusterIds []string
  8. }
  9. func NewReplicationStrategy(clusterIds []string, replicas int32) *ReplicationStrategy {
  10. return &ReplicationStrategy{clusterIds: clusterIds,
  11. replicas: replicas,
  12. }
  13. }
  14. func (r *ReplicationStrategy) Schedule() ([]*AssignedCluster, error) {
  15. if r.replicas < 1 {
  16. return nil, errors.New("replicas must be greater than 0")
  17. }
  18. if len(r.clusterIds) == 0 {
  19. return nil, errors.New("clusterIds must be set")
  20. }
  21. var results []*AssignedCluster
  22. for _, c := range r.clusterIds {
  23. cluster := &AssignedCluster{ClusterId: c, Replicas: r.replicas}
  24. results = append(results, cluster)
  25. }
  26. return results, nil
  27. }

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.