github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/xact/xs/lom_warmup.go (about) 1 // Package xs is a collection of eXtended actions (xactions), including multi-object 2 // operations, list-objects, (cluster) rebalance and (target) resilver, ETL, and more. 3 /* 4 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 5 */ 6 package xs 7 8 import ( 9 "sync" 10 11 "github.com/NVIDIA/aistore/api/apc" 12 "github.com/NVIDIA/aistore/cmn" 13 "github.com/NVIDIA/aistore/cmn/nlog" 14 "github.com/NVIDIA/aistore/core" 15 "github.com/NVIDIA/aistore/core/meta" 16 "github.com/NVIDIA/aistore/fs" 17 "github.com/NVIDIA/aistore/fs/mpather" 18 "github.com/NVIDIA/aistore/xact" 19 "github.com/NVIDIA/aistore/xact/xreg" 20 ) 21 22 type ( 23 llcFactory struct { 24 xreg.RenewBase 25 xctn *xactLLC 26 } 27 xactLLC struct { 28 xact.BckJog 29 } 30 ) 31 32 // interface guard 33 var ( 34 _ core.Xact = (*xactLLC)(nil) 35 _ xreg.Renewable = (*llcFactory)(nil) 36 ) 37 38 //////////////// 39 // llcFactory // 40 //////////////// 41 42 func (*llcFactory) New(args xreg.Args, bck *meta.Bck) xreg.Renewable { 43 p := &llcFactory{RenewBase: xreg.RenewBase{Args: args, Bck: bck}} 44 p.Bck = bck 45 return p 46 } 47 48 func (p *llcFactory) Start() error { 49 xctn := newXactLLC(p.UUID(), p.Bck) 50 p.xctn = xctn 51 go xctn.Run(nil) 52 return nil 53 } 54 55 func (*llcFactory) Kind() string { return apc.ActLoadLomCache } 56 func (p *llcFactory) Get() core.Xact { return p.xctn } 57 58 func (*llcFactory) WhenPrevIsRunning(xreg.Renewable) (xreg.WPR, error) { return xreg.WprUse, nil } 59 60 ///////////// 61 // xactLLC // 62 ///////////// 63 64 func newXactLLC(uuid string, bck *meta.Bck) (r *xactLLC) { 65 r = &xactLLC{} 66 mpopts := &mpather.JgroupOpts{ 67 CTs: []string{fs.ObjectType}, 68 VisitObj: func(*core.LOM, []byte) error { return nil }, 69 DoLoad: mpather.Load, 70 } 71 mpopts.Bck.Copy(bck.Bucket()) 72 r.BckJog.Init(uuid, apc.ActLoadLomCache, bck, mpopts, cmn.GCO.Get()) 73 return 74 } 75 76 func (r *xactLLC) Run(*sync.WaitGroup) { 77 r.BckJog.Run() 78 nlog.Infoln(r.Name()) 79 err := r.BckJog.Wait() 80 if err != nil { 81 r.AddErr(err) 82 } 83 r.Finish() 84 } 85 86 func (r *xactLLC) Snap() (snap *core.Snap) { 87 snap = &core.Snap{} 88 r.ToSnap(snap) 89 90 snap.IdleX = r.IsIdle() 91 return 92 }