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.

models.go 4.8 kB

10 months ago
10 months ago
10 months ago
10 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. package models
  2. import (
  3. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  4. "gorm.io/gorm"
  5. "time"
  6. )
  7. var DB *gorm.DB
  8. // InitDB 初始化数据库连接
  9. func InitDB(db *gorm.DB) {
  10. DB = db
  11. }
  12. type RequestID int64
  13. type BlockID int64
  14. type RelationshipID int64
  15. type Status int
  16. const (
  17. StatusNow = 0 //表示当前实时状态
  18. StatusYesterdayAfter = 1 // 表示前一天调整后的状态
  19. StatusYesterdayBefore = 2 // 表示前一天调整前的状态
  20. StatusTodayBeforeYesterday = 3 // 表示前两天调整后的状态
  21. )
  22. // 节点间关系图
  23. type HubRelationship struct {
  24. Nodes []Node `json:"nodes"` // 节点列表
  25. Edges []Edge `json:"edges"` // 名称
  26. }
  27. type Node struct {
  28. ID string `json:"id"` // 节点/中心ID
  29. NodeType string `json:"nodeType"` //节点类型 storage/hub
  30. Name string `json:"name"` // 节点/中心名称
  31. Address cdssdk.HubAddressInfo `json:"address"` // 地址
  32. DataCount int64 `json:"dataCount"` // 总数据量(文件分块数)
  33. NewDataCount int64 `json:"newdataCount"` // 新增数据量(文件分块数)
  34. Timestamp time.Time `json:"timestamp"` // 时间戳
  35. }
  36. type Edge struct {
  37. SourceType string `json:"sourceType"` // 源节点类型
  38. SourceID string `json:"source"` // 源节点ID
  39. TargetType string `json:"targetType"` // 目标节点类型
  40. TargetID string `json:"target"` // 目标节点ID
  41. DataTransferCount int64 `json:"dataTransferCount"` // 数据传输量
  42. RequestCount int64 `json:"requestCount"` // 请求数
  43. FailedRequestCount int64 `json:"failedRequestCount"` // 失败请求数
  44. AvgTransferCount int64 `json:"avgTransferCount"` // 平均数据传输量
  45. MaxTransferCount int64 `json:"maxTransferCount"` // 最大数据传输量
  46. MinTransferCount int64 `json:"minTransferCount"` // 最小数据传输量
  47. StartTimestamp time.Time `json:"startTimestamp"` // 起始时间戳
  48. EndTimestamp time.Time `json:"endTimestamp"` // 结束时间戳
  49. }
  50. // 对象分布
  51. type ObjectDistribution struct {
  52. Nodes []DistNode `json:"nodes"`
  53. Combos []Combo `json:"combos"`
  54. Edges []DistEdge `json:"edges"`
  55. }
  56. type DistNode struct {
  57. ID string `json:"id"`
  58. ComboID string `json:"comboId"`
  59. Label string `json:"label"`
  60. NodeType string `json:"nodeType"`
  61. }
  62. type Combo struct {
  63. ID string `json:"id"`
  64. Label string `json:"label"`
  65. ParentId string `json:"parentId"`
  66. ComboType string `json:"comboType"`
  67. }
  68. type DistEdge struct {
  69. Source string `json:"source"`
  70. Target string `json:"target"`
  71. }
  72. // 对象块分布结构
  73. //type ObjectDistribution struct {
  74. // ObjectID cdssdk.ObjectID `json:"objectID"` // 对象 ID
  75. // PackageID cdssdk.PackageID `json:"packageID"` // 包 ID
  76. // Path string `json:"path"` // 路径
  77. // Size int64 `json:"size"` // 大小
  78. // FileHash string `json:"fileHash"` // 文件哈希
  79. // States []State `json:"states"` // 各阶段状态信息(只需要传1、2、3阶段)
  80. // Relationships []Relationship `json:"relationships"` // 节点间传输量
  81. // Timestamp time.Time `json:"timestamp"` // 请求中的时间戳
  82. //}
  83. //
  84. //type State struct {
  85. // Timestamp time.Time `json:"timestamp"` // 时间戳
  86. // Status string `json:"status"` // 状态
  87. // FaultTolerance string `json:"faultTolerance"` // 容灾度(仅布局调整后)
  88. // Redundancy string `json:"redundancy"` // 冗余度(仅布局调整后)
  89. // AvgAccessCost float64 `json:"avgAccessCost"` // 平均访问开销(仅布局调整前)
  90. // BlockDistributions []BlockDist `json:"blockDistributions"` // 块分布情况
  91. //}
  92. //
  93. //type BlockDist struct {
  94. // StorageID cdssdk.StorageID `json:"storageID"` // 中心ID
  95. // Blocks []Block `json:"blocks"` // 该中心的所有块
  96. //}
  97. //
  98. //type Block struct {
  99. // Type string `json:"type"` // 块类型
  100. // Index string `json:"index"` // 块编号
  101. // ID string `json:"id"` // 块ID
  102. //}
  103. //
  104. //type Relationship struct {
  105. // Status Status `json:"status"` // 连线左侧的状态
  106. // SourceStorageID string `json:"sourceStorageID"` // 源存储节点 ID
  107. // TargetStorageID string `json:"targetStorageID"` // 目标存储节点 ID
  108. // DataTransferCount string `json:"dataTransferCount"` // 数据传输量
  109. // Timestamp time.Time `json:"timestamp"` // 变化结束时间戳
  110. //}

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。