mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-06 01:50:25 +08:00
节点可以单独设置缓存目录
This commit is contained in:
@@ -873,6 +873,8 @@ func (this *NodeDAO) ComposeNodeConfig(tx *dbs.Tx, nodeId int64, cacheMap *utils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.CacheDiskDir = node.CacheDiskDir
|
||||||
|
|
||||||
// TOA
|
// TOA
|
||||||
toaConfig, err := SharedNodeClusterDAO.FindClusterTOAConfig(tx, primaryClusterId, cacheMap)
|
toaConfig, err := SharedNodeClusterDAO.FindClusterTOAConfig(tx, primaryClusterId, cacheMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1222,7 +1224,7 @@ func (this *NodeDAO) UpdateNodeSystem(tx *dbs.Tx, nodeId int64, maxCPU int32) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateNodeCache 设置缓存相关
|
// 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 {
|
if nodeId <= 0 {
|
||||||
return errors.New("invalid nodeId")
|
return errors.New("invalid nodeId")
|
||||||
}
|
}
|
||||||
@@ -1234,6 +1236,7 @@ func (this *NodeDAO) UpdateNodeCache(tx *dbs.Tx, nodeId int64, maxCacheDiskCapac
|
|||||||
if len(maxCacheMemoryCapacityJSON) > 0 {
|
if len(maxCacheMemoryCapacityJSON) > 0 {
|
||||||
op.MaxCacheMemoryCapacity = maxCacheMemoryCapacityJSON
|
op.MaxCacheMemoryCapacity = maxCacheMemoryCapacityJSON
|
||||||
}
|
}
|
||||||
|
op.CacheDiskDir = cacheDiskDir
|
||||||
err := this.Save(tx, op)
|
err := this.Save(tx, op)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ type Node struct {
|
|||||||
DnsRoutes string `field:"dnsRoutes"` // DNS线路设置
|
DnsRoutes string `field:"dnsRoutes"` // DNS线路设置
|
||||||
MaxCacheDiskCapacity string `field:"maxCacheDiskCapacity"` // 硬盘缓存容量
|
MaxCacheDiskCapacity string `field:"maxCacheDiskCapacity"` // 硬盘缓存容量
|
||||||
MaxCacheMemoryCapacity string `field:"maxCacheMemoryCapacity"` // 内存缓存容量
|
MaxCacheMemoryCapacity string `field:"maxCacheMemoryCapacity"` // 内存缓存容量
|
||||||
|
CacheDiskDir string `field:"cacheDiskDir"` // 缓存目录
|
||||||
}
|
}
|
||||||
|
|
||||||
type NodeOperator struct {
|
type NodeOperator struct {
|
||||||
@@ -63,6 +64,7 @@ type NodeOperator struct {
|
|||||||
DnsRoutes interface{} // DNS线路设置
|
DnsRoutes interface{} // DNS线路设置
|
||||||
MaxCacheDiskCapacity interface{} // 硬盘缓存容量
|
MaxCacheDiskCapacity interface{} // 硬盘缓存容量
|
||||||
MaxCacheMemoryCapacity interface{} // 内存缓存容量
|
MaxCacheMemoryCapacity interface{} // 内存缓存容量
|
||||||
|
CacheDiskDir interface{} // 缓存目录
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNodeOperator() *NodeOperator {
|
func NewNodeOperator() *NodeOperator {
|
||||||
|
|||||||
@@ -578,6 +578,7 @@ func (this *NodeService) FindEnabledNode(ctx context.Context, req *pb.FindEnable
|
|||||||
NodeRegion: pbRegion,
|
NodeRegion: pbRegion,
|
||||||
MaxCacheDiskCapacity: pbMaxCacheDiskCapacity,
|
MaxCacheDiskCapacity: pbMaxCacheDiskCapacity,
|
||||||
MaxCacheMemoryCapacity: pbMaxCacheMemoryCapacity,
|
MaxCacheMemoryCapacity: pbMaxCacheMemoryCapacity,
|
||||||
|
CacheDiskDir: node.CacheDiskDir,
|
||||||
}}, nil
|
}}, 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user