github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/xact/bckjog.go (about)

     1  // Package xact provides core functionality for the AIStore eXtended Actions (xactions).
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package xact
     6  
     7  import (
     8  	"github.com/NVIDIA/aistore/cmn"
     9  	"github.com/NVIDIA/aistore/core/meta"
    10  	"github.com/NVIDIA/aistore/fs/mpather"
    11  )
    12  
    13  type BckJog struct {
    14  	Config  *cmn.Config
    15  	joggers *mpather.Jgroup
    16  	Base
    17  }
    18  
    19  func (r *BckJog) Init(id, kind string, bck *meta.Bck, opts *mpather.JgroupOpts, config *cmn.Config) {
    20  	r.InitBase(id, kind, bck)
    21  	r.joggers = mpather.NewJoggerGroup(opts, config, "")
    22  	r.Config = config
    23  }
    24  
    25  func (r *BckJog) Run() { r.joggers.Run() }
    26  
    27  func (r *BckJog) Wait() error {
    28  	select {
    29  	case errCause := <-r.ChanAbort():
    30  		r.joggers.Stop()
    31  		if cmn.IsErrAborted(errCause) {
    32  			return errCause
    33  		}
    34  		return cmn.NewErrAborted(r.Name(), "x-bck-jog", errCause)
    35  	case <-r.joggers.ListenFinished():
    36  		return r.joggers.Stop()
    37  	}
    38  }