MCPcopy
hub / github.com/NVIDIA/aistore / EncodeObject

Method EncodeObject

ec/manager.go:277–308  ·  view source on GitHub ↗

EncodeObject generates slices using Reed-Solom algorithm: - lom - object to encode - intra - if true, it is internal request and has low priority - cb - optional callback that is called after the object is encoded

(lom *cluster.LOM, cb ...cluster.OnFinishObj)

Source from the content-addressed store, hash-verified

275// - intra - if true, it is internal request and has low priority
276// - cb - optional callback that is called after the object is encoded
277func (mgr *Manager) EncodeObject(lom *cluster.LOM, cb ...cluster.OnFinishObj) error {
278 if !lom.Bprops().EC.Enabled {
279 return ErrorECDisabled
280 }
281 if cs := fs.GetCapStatus(); cs.Err != nil {
282 return cs.Err
283 }
284 isECCopy := IsECCopy(lom.SizeBytes(), &lom.Bprops().EC)
285 targetCnt := mgr.targetCnt.Load()
286
287 // tradeoff: encoding small object might require just 1 additional target available
288 // we will start xaction to satisfy this request
289 if required := lom.Bprops().EC.RequiredEncodeTargets(); !isECCopy && int(targetCnt) < required {
290 glog.Warningf("not enough targets to encode the object; actual: %v, required: %v", targetCnt, required)
291 return cmn.ErrNotEnoughTargets
292 }
293 spec, _ := fs.CSM.FileSpec(lom.FQN)
294 if spec != nil && !spec.PermToProcess() {
295 return errSkipped
296 }
297
298 req := allocateReq(ActSplit, lom.LIF())
299 req.IsCopy = IsECCopy(lom.SizeBytes(), &lom.Bprops().EC)
300 if len(cb) != 0 {
301 req.rebuild = true
302 req.Callback = cb[0]
303 }
304
305 mgr.RestoreBckPutXact(lom.Bck()).encode(req, lom)
306
307 return nil
308}
309
310func (mgr *Manager) CleanupObject(lom *cluster.LOM) {
311 if !lom.Bprops().EC.Enabled {

Callers 3

bckEncodeMethod · 0.80
finalizeMethod · 0.80
finalizeMethod · 0.80

Calls 14

RestoreBckPutXactMethod · 0.95
GetCapStatusFunction · 0.92
WarningfFunction · 0.92
IsECCopyFunction · 0.85
allocateReqFunction · 0.85
BpropsMethod · 0.80
RequiredEncodeTargetsMethod · 0.80
FileSpecMethod · 0.80
LIFMethod · 0.80
SizeBytesMethod · 0.65
PermToProcessMethod · 0.65
BckMethod · 0.65

Tested by

no test coverage detected