Browse Source

CheckStorage任务增加StorageID

gitlink
Sydonian 2 years ago
parent
commit
0e0f0b8b33
4 changed files with 26 additions and 7 deletions
  1. +1
    -1
      internal/event/agent_check_storage.go
  2. +9
    -2
      internal/event/update_cache.go
  3. +15
    -3
      internal/event/update_storage.go
  4. +1
    -1
      internal/tickevent/check_cache.go

+ 1
- 1
internal/event/agent_check_storage.go View File

@@ -104,7 +104,7 @@ func (t *AgentCheckStorage) Execute(execCtx ExecuteContext) {
defer agentClient.Close() defer agentClient.Close()


evtmsg, err := agtmsg.NewPostEventBody( evtmsg, err := agtmsg.NewPostEventBody(
agtevt.NewCheckStorage(stg.Directory, isComplete, objects),
agtevt.NewCheckStorage(stg.StorageID, stg.Directory, isComplete, objects),
execCtx.Option.IsEmergency, // 继承本任务的执行选项 execCtx.Option.IsEmergency, // 继承本任务的执行选项
execCtx.Option.DontMerge) execCtx.Option.DontMerge)
if err != nil { if err != nil {


+ 9
- 2
internal/event/update_cache.go View File

@@ -38,15 +38,18 @@ func (t *UpdateCache) Execute(execCtx ExecuteContext) {


for _, entry := range t.Entries { for _, entry := range t.Entries {
switch entry.Operation { switch entry.Operation {
case evtcst.UPDATE_CACHE_UNTEMP:
case evtcst.UPDATE_CACHE_DELETE_TEMP:
err := mysql.Cache.DeleteTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID) err := mysql.Cache.DeleteTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID)

if err != nil { if err != nil {
logger.WithField("FileHash", entry.FileHash). logger.WithField("FileHash", entry.FileHash).
WithField("NodeID", t.NodeID). WithField("NodeID", t.NodeID).
Warnf("delete temp cache failed, err: %s", err.Error()) Warnf("delete temp cache failed, err: %s", err.Error())
} }


logger.WithField("FileHash", entry.FileHash).
WithField("NodeID", t.NodeID).
Debugf("delete temp cache")

case evtcst.UPDATE_CACHE_CREATE_TEMP: case evtcst.UPDATE_CACHE_CREATE_TEMP:
err := mysql.Cache.CreateTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID) err := mysql.Cache.CreateTemp(execCtx.Args.DB.SQLCtx(), entry.FileHash, t.NodeID)
if err != nil { if err != nil {
@@ -54,6 +57,10 @@ func (t *UpdateCache) Execute(execCtx ExecuteContext) {
WithField("NodeID", t.NodeID). WithField("NodeID", t.NodeID).
Warnf("create temp cache failed, err: %s", err.Error()) Warnf("create temp cache failed, err: %s", err.Error())
} }

logger.WithField("FileHash", entry.FileHash).
WithField("NodeID", t.NodeID).
Debugf("create temp cache")
} }
} }
} }


+ 15
- 3
internal/event/update_storage.go View File

@@ -12,9 +12,9 @@ type UpdateStorage struct {
scevt.UpdateStorage scevt.UpdateStorage
} }


func NewUpdateStorage(dirState string, entries []UpdateStorageEntry) *UpdateStorage {
func NewUpdateStorage(storageID int, dirState string, entries []UpdateStorageEntry) *UpdateStorage {
return &UpdateStorage{ return &UpdateStorage{
UpdateStorage: scevt.NewUpdateStorage(dirState, entries),
UpdateStorage: scevt.NewUpdateStorage(storageID, dirState, entries),
} }
} }


@@ -54,6 +54,11 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) {
} }
chkObjIDs = append(chkObjIDs, entry.ObjectID) chkObjIDs = append(chkObjIDs, entry.ObjectID)


logger.WithField("StorageID", t.StorageID).
WithField("ObjectID", entry.ObjectID).
WithField("UserID", entry.UserID).
Debugf("delete storage object")

case tskcst.UPDATE_STORAGE_SET_NORMAL: case tskcst.UPDATE_STORAGE_SET_NORMAL:
err := mysql.StorageObject.SetStateNormal(execCtx.Args.DB.SQLCtx(), t.StorageID, entry.ObjectID, entry.UserID) err := mysql.StorageObject.SetStateNormal(execCtx.Args.DB.SQLCtx(), t.StorageID, entry.ObjectID, entry.UserID)
if err != nil { if err != nil {
@@ -61,6 +66,11 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) {
WithField("ObjectID", entry.ObjectID). WithField("ObjectID", entry.ObjectID).
Warnf("change storage object state failed, err: %s", err.Error()) Warnf("change storage object state failed, err: %s", err.Error())
} }

logger.WithField("StorageID", t.StorageID).
WithField("ObjectID", entry.ObjectID).
WithField("UserID", entry.UserID).
Debugf("set storage object normal")
} }
} }


@@ -70,5 +80,7 @@ func (t *UpdateStorage) Execute(execCtx ExecuteContext) {
} }


func init() { func init() {
RegisterMessageConvertor(func(msg scevt.UpdateStorage) Event { return NewUpdateStorage(msg.DirectoryState, msg.Entries) })
RegisterMessageConvertor(func(msg scevt.UpdateStorage) Event {
return NewUpdateStorage(msg.StorageID, msg.DirectoryState, msg.Entries)
})
} }

+ 1
- 1
internal/tickevent/check_cache.go View File

@@ -9,7 +9,7 @@ import (
type CheckCache struct { type CheckCache struct {
} }


func NewCheckUnavailableCache() *CheckCache {
func NewCheckCache() *CheckCache {
return &CheckCache{} return &CheckCache{}
} }




Loading…
Cancel
Save