github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/api/apc/actmsg.go (about) 1 // Package apc: API constant and control messages 2 /* 3 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package apc 6 7 import ( 8 "strings" 9 10 "github.com/NVIDIA/aistore/cmn/cos" 11 jsoniter "github.com/json-iterator/go" 12 ) 13 14 // ActMsg.Action 15 // includes Xaction.Kind == ActMsg.Action (when the action is asynchronous) 16 const ( 17 ActCreateBck = "create-bck" // NOTE: compare w/ ActAddRemoteBck below 18 ActDestroyBck = "destroy-bck" // destroy bucket data and metadata 19 ActSetBprops = "set-bprops" 20 ActResetBprops = "reset-bprops" 21 22 ActSummaryBck = "summary-bck" 23 24 ActECEncode = "ec-encode" // erasure code a bucket 25 ActECGet = "ec-get" // read erasure coded objects 26 ActECPut = "ec-put" // erasure code objects 27 ActECRespond = "ec-resp" // respond to other targets' EC requests 28 29 ActCopyBck = "copy-bck" 30 ActETLBck = "etl-bck" 31 32 ActETLInline = "etl-inline" 33 34 ActDsort = "dsort" 35 ActDownload = "download" 36 37 ActBlobDl = "blob-download" 38 39 ActMakeNCopies = "make-n-copies" 40 ActPutCopies = "put-copies" 41 42 ActRebalance = "rebalance" 43 ActMoveBck = "move-bck" 44 45 ActResilver = "resilver" 46 47 ActElection = "election" 48 49 ActLRU = "lru" 50 ActStoreCleanup = "cleanup-store" 51 52 ActEvictRemoteBck = "evict-remote-bck" // evict remote bucket's data 53 ActInvalListCache = "inval-listobj-cache" 54 ActList = "list" 55 ActLoadLomCache = "load-lom-cache" 56 ActNewPrimary = "new-primary" 57 ActPromote = "promote" 58 ActRenameObject = "rename-obj" 59 60 // cp (reverse) 61 ActResetStats = "reset-stats" 62 ActResetConfig = "reset-config" 63 ActSetConfig = "set-config" 64 65 ActRotateLogs = "rotate-logs" 66 67 ActShutdownCluster = "shutdown" // see also: ActShutdownNode 68 69 // multi-object (via `ListRange`) 70 ActCopyObjects = "copy-listrange" 71 ActDeleteObjects = "delete-listrange" 72 ActETLObjects = "etl-listrange" 73 ActEvictObjects = "evict-listrange" 74 ActPrefetchObjects = "prefetch-listrange" 75 ActArchive = "archive" // see ArchiveMsg 76 77 ActAttachRemAis = "attach" 78 ActDetachRemAis = "detach" 79 80 // Node maintenance & cluster membership (see also ActRmNodeUnsafe below) 81 ActStartMaintenance = "start-maintenance" // put into maintenance state 82 ActStopMaintenance = "stop-maintenance" // cancel maintenance state 83 ActShutdownNode = "shutdown-node" // shutdown node 84 ActDecommissionNode = "decommission-node" // start rebalance and, when done, remove node from Smap 85 86 ActDecommissionCluster = "decommission" // decommission all nodes in the cluster (cleanup system data) 87 88 ActAdminJoinTarget = "admin-join-target" 89 ActSelfJoinTarget = "self-join-target" 90 ActAdminJoinProxy = "admin-join-proxy" 91 ActSelfJoinProxy = "self-join-proxy" 92 ActKeepaliveUpdate = "keepalive-update" 93 94 // IC 95 ActSendOwnershipTbl = "ic-send-own-tbl" 96 ActListenToNotif = "watch-xaction" 97 ActMergeOwnershipTbl = "ic-merge-own-tbl" 98 ActRegGlobalXaction = "reg-global-xaction" 99 ) 100 101 // internal use 102 const ( 103 ActAddRemoteBck = "add-remote-bck" // add to BMD existing remote bucket, usually on the fly 104 ActRmNodeUnsafe = "rm-unsafe" // primary => the node to be removed 105 ActStartGFN = "start-gfn" // get-from-neighbor 106 ActStopGFN = "stop-gfn" // off 107 ActCleanupMarkers = "cleanup-markers" 108 ) 109 110 const ( 111 // Actions on mountpaths (/v1/daemon/mountpaths) 112 ActMountpathAttach = "attach-mp" 113 ActMountpathEnable = "enable-mp" 114 ActMountpathDetach = "detach-mp" 115 ActMountpathDisable = "disable-mp" 116 117 // Actions on xactions 118 ActXactStop = Stop 119 ActXactStart = Start 120 121 // auxiliary 122 ActTransient = "transient" // transient - in-memory only 123 ) 124 125 // xaction begin-commit phases and related control 126 const ( 127 ActBegin = "begin" 128 ActCommit = "commit" 129 ActAbort = "abort" 130 131 ActQuery = "query" 132 ) 133 134 const ( 135 NodeMaintenance = "maintenance" 136 NodeDecommission = "decommission" 137 ) 138 139 // ActMsg is a JSON-formatted control structures used in a majority of API calls 140 type ( 141 ActMsg struct { 142 Value any `json:"value"` // action-specific and optional 143 Action string `json:"action"` // ActShutdown, ActRebalance, and many more (see apc/const.go) 144 Name string `json:"name"` // action-specific name (e.g., bucket name) 145 } 146 ActValRmNode struct { 147 DaemonID string `json:"sid"` 148 SkipRebalance bool `json:"skip_rebalance"` 149 RmUserData bool `json:"rm_user_data"` // decommission-only 150 KeepInitialConfig bool `json:"keep_initial_config"` // ditto (to be able to restart a node from scratch) 151 NoShutdown bool `json:"no_shutdown"` 152 } 153 ) 154 155 type ( 156 JoinNodeResult struct { 157 DaemonID string `json:"daemon_id"` 158 RebalanceID string `json:"rebalance_id"` 159 } 160 ) 161 162 // MountpathList contains two lists: 163 // - Available - list of local mountpaths available to the storage target 164 // - WaitingDD - waiting for resilvering completion to be detached or disabled (moved to `Disabled`) 165 // - Disabled - list of disabled mountpaths, the mountpaths that generated 166 // IO errors followed by (FSHC) health check, etc. 167 type ( 168 MountpathList struct { 169 Available []string `json:"available"` 170 WaitingDD []string `json:"waiting_dd"` 171 Disabled []string `json:"disabled"` 172 } 173 ) 174 175 // sysinfo 176 type ( 177 CapacityInfo struct { 178 Used uint64 `json:"fs_used,string"` 179 Total uint64 `json:"fs_capacity,string"` 180 PctUsed float64 `json:"pct_fs_used"` 181 } 182 TSysInfo struct { 183 MemCPUInfo 184 CapacityInfo 185 } 186 ClusterSysInfo struct { 187 Proxy map[string]*MemCPUInfo `json:"proxy"` 188 Target map[string]*TSysInfo `json:"target"` 189 } 190 ClusterSysInfoRaw struct { 191 Proxy cos.JSONRawMsgs `json:"proxy"` 192 Target cos.JSONRawMsgs `json:"target"` 193 } 194 ) 195 196 //////////// 197 // ActMsg // 198 //////////// 199 200 func (msg *ActMsg) String() string { return msg._string(false) } 201 func (msg *ActMsg) StringEx() string { return msg._string(true) } 202 203 func (msg *ActMsg) _string(wval bool) string { 204 s := "actm[" + msg.Action 205 if msg.Name != "" { 206 s += ", name=" + msg.Name 207 } 208 if !wval || msg.Value == nil { 209 return s + "]" 210 } 211 vs, err := jsoniter.Marshal(msg.Value) 212 if err != nil { 213 s += "-<json err: " + err.Error() + ">" 214 return s + "]" 215 } 216 s += ", val=" + strings.ReplaceAll(string(vs), ",", ", ") + "]" 217 return s 218 }