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)
| 275 | // - intra - if true, it is internal request and has low priority |
| 276 | // - cb - optional callback that is called after the object is encoded |
| 277 | func (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 | |
| 310 | func (mgr *Manager) CleanupObject(lom *cluster.LOM) { |
| 311 | if !lom.Bprops().EC.Enabled { |
no test coverage detected