github.com/swiftstack/proxyfs@v0.0.0-20201223034610-5434d919416e/halter/config.go (about)

     1  package halter
     2  
     3  import (
     4  	"github.com/swiftstack/ProxyFS/conf"
     5  	"github.com/swiftstack/ProxyFS/trackedlock"
     6  	"github.com/swiftstack/ProxyFS/transitions"
     7  )
     8  
     9  type globalsStruct struct {
    10  	trackedlock.Mutex
    11  	armedTriggers         map[uint32]uint32 // key: haltLabel; value: haltAfterCount (remaining)
    12  	triggerNamesToNumbers map[string]uint32
    13  	triggerNumbersToNames map[uint32]string
    14  	testModeHaltCB        func(err error)
    15  }
    16  
    17  var globals globalsStruct
    18  
    19  func init() {
    20  	transitions.Register("halter", &globals)
    21  }
    22  
    23  func (dummy *globalsStruct) Up(confMap conf.ConfMap) (err error) {
    24  	globals.armedTriggers = make(map[uint32]uint32)
    25  	globals.triggerNamesToNumbers = make(map[string]uint32)
    26  	globals.triggerNumbersToNames = make(map[uint32]string)
    27  	for i, s := range HaltLabelStrings {
    28  		globals.triggerNamesToNumbers[s] = uint32(i)
    29  		globals.triggerNumbersToNames[uint32(i)] = s
    30  	}
    31  	globals.testModeHaltCB = nil
    32  	err = nil
    33  	return
    34  }
    35  
    36  func (dummy *globalsStruct) VolumeGroupCreated(confMap conf.ConfMap, volumeGroupName string, activePeer string, virtualIPAddr string) (err error) {
    37  	return nil
    38  }
    39  func (dummy *globalsStruct) VolumeGroupMoved(confMap conf.ConfMap, volumeGroupName string, activePeer string, virtualIPAddr string) (err error) {
    40  	return nil
    41  }
    42  func (dummy *globalsStruct) VolumeGroupDestroyed(confMap conf.ConfMap, volumeGroupName string) (err error) {
    43  	return nil
    44  }
    45  func (dummy *globalsStruct) VolumeCreated(confMap conf.ConfMap, volumeName string, volumeGroupName string) (err error) {
    46  	return nil
    47  }
    48  func (dummy *globalsStruct) VolumeMoved(confMap conf.ConfMap, volumeName string, volumeGroupName string) (err error) {
    49  	return nil
    50  }
    51  func (dummy *globalsStruct) VolumeDestroyed(confMap conf.ConfMap, volumeName string) (err error) {
    52  	return nil
    53  }
    54  func (dummy *globalsStruct) ServeVolume(confMap conf.ConfMap, volumeName string) (err error) {
    55  	return nil
    56  }
    57  func (dummy *globalsStruct) UnserveVolume(confMap conf.ConfMap, volumeName string) (err error) {
    58  	return nil
    59  }
    60  func (dummy *globalsStruct) VolumeToBeUnserved(confMap conf.ConfMap, volumeName string) (err error) {
    61  	return nil
    62  }
    63  func (dummy *globalsStruct) SignaledStart(confMap conf.ConfMap) (err error) {
    64  	return nil
    65  }
    66  func (dummy *globalsStruct) SignaledFinish(confMap conf.ConfMap) (err error) {
    67  	return nil
    68  }
    69  
    70  func (dummy *globalsStruct) Down(confMap conf.ConfMap) (err error) {
    71  	err = nil
    72  	return
    73  }
    74  
    75  func configureTestModeHaltCB(testHalt func(err error)) {
    76  	globals.Lock()
    77  	globals.testModeHaltCB = testHalt
    78  	globals.Unlock()
    79  }