github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/xact/xs/election.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  	eleFactory struct {
    22  		xreg.RenewBase
    23  		xctn *Election
    24  	}
    25  	Election struct {
    26  		xact.Base
    27  	}
    28  )
    29  
    30  // interface guard
    31  var (
    32  	_ core.Xact      = (*Election)(nil)
    33  	_ xreg.Renewable = (*eleFactory)(nil)
    34  )
    35  
    36  func (*eleFactory) New(xreg.Args, *meta.Bck) xreg.Renewable { return &eleFactory{} }
    37  
    38  func (p *eleFactory) Start() error {
    39  	p.xctn = &Election{}
    40  	p.xctn.InitBase(cos.GenUUID(), apc.ActElection, nil)
    41  	return nil
    42  }
    43  
    44  func (*eleFactory) Kind() string     { return apc.ActElection }
    45  func (p *eleFactory) Get() core.Xact { return p.xctn }
    46  
    47  func (*eleFactory) WhenPrevIsRunning(xreg.Renewable) (xreg.WPR, error) {
    48  	return xreg.WprUse, nil
    49  }
    50  
    51  func (*Election) Run(*sync.WaitGroup) { debug.Assert(false) }
    52  
    53  func (r *Election) Snap() (snap *core.Snap) {
    54  	snap = &core.Snap{}
    55  	r.ToSnap(snap)
    56  	return
    57  }