github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/xact/xs/etl.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-2023, 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/cos"
    13  	"github.com/NVIDIA/aistore/cmn/debug"
    14  	"github.com/NVIDIA/aistore/core"
    15  	"github.com/NVIDIA/aistore/core/meta"
    16  	"github.com/NVIDIA/aistore/xact"
    17  	"github.com/NVIDIA/aistore/xact/xreg"
    18  )
    19  
    20  type (
    21  	etlFactory struct {
    22  		xreg.RenewBase
    23  		xctn *xactETL
    24  	}
    25  	xactETL struct {
    26  		xact.Base
    27  	}
    28  )
    29  
    30  // interface guard
    31  var (
    32  	_ core.Xact      = (*xactETL)(nil)
    33  	_ xreg.Renewable = (*etlFactory)(nil)
    34  )
    35  
    36  func (*etlFactory) New(args xreg.Args, _ *meta.Bck) xreg.Renewable {
    37  	return &etlFactory{RenewBase: xreg.RenewBase{Args: args}}
    38  }
    39  
    40  func (p *etlFactory) Start() error {
    41  	debug.Assert(cos.IsValidUUID(p.Args.UUID), p.Args.UUID)
    42  	p.xctn = newETL(p.Args.UUID, p.Kind())
    43  	return nil
    44  }
    45  
    46  func (*etlFactory) Kind() string     { return apc.ActETLInline }
    47  func (p *etlFactory) Get() core.Xact { return p.xctn }
    48  
    49  func (*etlFactory) WhenPrevIsRunning(xreg.Renewable) (xreg.WPR, error) {
    50  	return xreg.WprKeepAndStartNew, nil
    51  }
    52  
    53  // (tests only)
    54  
    55  func newETL(id, kind string) (xctn *xactETL) {
    56  	xctn = &xactETL{}
    57  	xctn.InitBase(id, kind, nil)
    58  	return
    59  }
    60  
    61  func (*xactETL) Run(*sync.WaitGroup) { debug.Assert(false) }
    62  
    63  func (r *xactETL) Snap() (snap *core.Snap) {
    64  	snap = &core.Snap{}
    65  	r.ToSnap(snap)
    66  
    67  	snap.IdleX = r.IsIdle()
    68  	return
    69  }