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.

provider.go 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright (c) [2023] [pcm]
  3. [pcm-coordinator] is licensed under Mulan PSL v2.
  4. You can use this software according to the terms and conditions of the Mulan PSL v2.
  5. You may obtain a copy of Mulan PSL v2 at:
  6. http://license.coscl.org.cn/MulanPSL2
  7. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  8. EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  9. MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  10. See the Mulan PSL v2 for more details.
  11. */
  12. package providerPricing
  13. import (
  14. "math"
  15. )
  16. type Provider struct {
  17. Pid int64
  18. CpuSum float64
  19. MemSum float64
  20. DiskSum float64
  21. CpuCost float64
  22. MemCost float64
  23. DiskCost float64
  24. CpuAvail float64
  25. MemAvail float64
  26. DiskAvail float64
  27. CurReplicas int
  28. MaxReplicas int
  29. MaxTaskCanRun int //记录该厂商针对当前可以接收的最大任务数
  30. TrustDegree float64 //信任度取值为0到1,默认初始为1
  31. LearnIndex float64 //云厂商生产成本的学习指数
  32. PartWill float64 //合作意愿
  33. ProfitSum float64
  34. ProfitPerTask map[int]float64
  35. }
  36. func NewProvider(Pid int64, CpuSum float64, MemSum float64, DiskSum float64, CpuCost float64, MemCost float64, DiskCost float64) *Provider {
  37. return &Provider{
  38. Pid: Pid,
  39. CpuSum: CpuSum,
  40. MemSum: MemSum,
  41. DiskSum: DiskSum,
  42. CpuCost: CpuCost,
  43. MemCost: MemCost,
  44. DiskCost: DiskCost,
  45. CpuAvail: CpuSum,
  46. MemAvail: MemSum,
  47. DiskAvail: DiskSum,
  48. LearnIndex: 0.9,
  49. PartWill: 1,
  50. }
  51. }
  52. func (p *Provider) GenMaxResourceNum(t *Task) {
  53. p.MaxReplicas = int(math.Floor(p.CpuAvail / t.Cpu))
  54. if p.MaxReplicas > int(math.Floor(p.MemAvail/t.Mem)) {
  55. p.MaxReplicas = int(math.Floor(p.MemAvail / t.Mem))
  56. }
  57. if p.MaxReplicas > int(math.Floor(p.DiskAvail/t.Disk)) {
  58. p.MaxReplicas = int(math.Floor(p.DiskAvail / t.Disk))
  59. }
  60. if p.MaxReplicas > 0 {
  61. p.MaxTaskCanRun = t.Replicas
  62. }
  63. }
  64. func (p Provider) name() {
  65. }

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.