From 12ff7f7a0283e40f346575a076b408f2fd9cb4d8 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 16 Mar 2022 15:23:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E7=82=B9=E5=8F=AF=E4=BB=A5=E5=8D=95?= =?UTF-8?q?=E7=8B=AC=E8=AE=BE=E7=BD=AE=E7=BC=93=E5=AD=98=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/db/models/node_dao.go | 5 ++++- internal/db/models/node_model.go | 2 ++ internal/rpc/services/service_node.go | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/db/models/node_dao.go b/internal/db/models/node_dao.go index dad9221f..721b561d 100644 --- a/internal/db/models/node_dao.go +++ b/internal/db/models/node_dao.go @@ -873,6 +873,8 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils } } + config.CacheDiskDir = node.CacheDiskDir + // TOA toaConfig, err := SharedNodeClusterDAO.FindClusterTOAConfig(tx, primaryClusterId, cacheMap) if err != nil { @@ -1222,7 +1224,7 @@ func (this *NodeDAO) UpdateNodeSystem(tx *dbs.Tx, nodeId int64, maxCPU int32) er } // UpdateNodeCache 设置缓存相关 -func (this *NodeDAO) UpdateNodeCache(tx *dbs.Tx, nodeId int64, maxCacheDiskCapacityJSON []byte, maxCacheMemoryCapacityJSON []byte) error { +func (this *NodeDAO) UpdateNodeCache(tx *dbs.Tx, nodeId int64, maxCacheDiskCapacityJSON []byte, maxCacheMemoryCapacityJSON []byte, cacheDiskDir string) error { if nodeId <= 0 { return errors.New("invalid nodeId") } @@ -1234,6 +1236,7 @@ func (this *NodeDAO) UpdateNodeCache(tx *dbs.Tx, nodeId int64, maxCacheDiskCapac if len(maxCacheMemoryCapacityJSON) > 0 { op.MaxCacheMemoryCapacity = maxCacheMemoryCapacityJSON } + op.CacheDiskDir = cacheDiskDir err := this.Save(tx, op) if err != nil { return err diff --git a/internal/db/models/node_model.go b/internal/db/models/node_model.go index d46aa755..54f203a8 100644 --- a/internal/db/models/node_model.go +++ b/internal/db/models/node_model.go @@ -31,6 +31,7 @@ type Node struct { DnsRoutes string `field:"dnsRoutes"` // DNS线路设置 MaxCacheDiskCapacity string `field:"maxCacheDiskCapacity"` // 硬盘缓存容量 MaxCacheMemoryCapacity string `field:"maxCacheMemoryCapacity"` // 内存缓存容量 + CacheDiskDir string `field:"cacheDiskDir"` // 缓存目录 } type NodeOperator struct { @@ -63,6 +64,7 @@ type NodeOperator struct { DnsRoutes interface{} // DNS线路设置 MaxCacheDiskCapacity interface{} // 硬盘缓存容量 MaxCacheMemoryCapacity interface{} // 内存缓存容量 + CacheDiskDir interface{} // 缓存目录 } func NewNodeOperator() *NodeOperator { diff --git a/internal/rpc/services/service_node.go b/internal/rpc/services/service_node.go index 8a788c4e..d16ffa3c 100644 --- a/internal/rpc/services/service_node.go +++ b/internal/rpc/services/service_node.go @@ -578,6 +578,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable NodeRegion: pbRegion, MaxCacheDiskCapacity: pbMaxCacheDiskCapacity, MaxCacheMemoryCapacity: pbMaxCacheMemoryCapacity, + CacheDiskDir: node.CacheDiskDir, }}, nil } @@ -1570,7 +1571,7 @@ func (this *NodeService) UpdateNodeCache(ctx context.Context, req *pb.UpdateNode } } - err = models.SharedNodeDAO.UpdateNodeCache(tx, req.NodeId, maxCacheDiskCapacityJSON, maxCacheMemoryCapacityJSON) + err = models.SharedNodeDAO.UpdateNodeCache(tx, req.NodeId, maxCacheDiskCapacityJSON, maxCacheMemoryCapacityJSON, req.CacheDiskDir) if err != nil { return nil, err }