github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/core/target.go (about) 1 // Package core provides core metadata and in-cluster API 2 /* 3 * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package core 6 7 import ( 8 "context" 9 "io" 10 "net/http" 11 "net/url" 12 "os" 13 "time" 14 15 "github.com/NVIDIA/aistore/api/apc" 16 "github.com/NVIDIA/aistore/cmn" 17 "github.com/NVIDIA/aistore/cmn/cos" 18 "github.com/NVIDIA/aistore/core/meta" 19 "github.com/NVIDIA/aistore/fs" 20 "github.com/NVIDIA/aistore/memsys" 21 "github.com/NVIDIA/aistore/transport" 22 ) 23 24 // 25 // ais target: types and interfaces 26 // 27 28 // intra-cluster data path: control structures and types 29 type ( 30 OnFinishObj = func(lom *LOM, err error) 31 32 DM interface { 33 Send(obj *transport.Obj, roc cos.ReadOpenCloser, tsi *meta.Snode) error 34 } 35 36 PutParams struct { 37 Reader io.ReadCloser 38 Cksum *cos.Cksum // checksum to check 39 Atime time.Time 40 Xact Xact 41 WorkTag string // (=> work fqn) 42 Size int64 43 OWT cmn.OWT 44 SkipEC bool // don't erasure-code when finalizing 45 ColdGET bool // this PUT is in fact a cold-GET 46 } 47 PromoteParams struct { 48 Bck *meta.Bck // destination bucket 49 Cksum *cos.Cksum // checksum to validate 50 Config *cmn.Config // during xaction 51 Xact Xact // responsible xaction 52 apc.PromoteArgs // all of the above 53 } 54 CopyParams struct { 55 DP DP // transform via: ext/etl/dp.go or core/ldp.go 56 Xact Xact 57 Config *cmn.Config 58 BckTo *meta.Bck 59 ObjnameTo string 60 Buf []byte 61 OWT cmn.OWT 62 Finalize bool // copies and EC (as in poi.finalize()) 63 DryRun bool 64 LatestVer bool // can be used without changing bucket's 'versioning.validate_warm_get'; see also: QparamLatestVer 65 Sync bool // ditto - bucket's 'versioning.synchronize' 66 } 67 68 // blob 69 WriteSGL func(*memsys.SGL) error 70 71 BlobParams struct { 72 RspW http.ResponseWriter // (GET) 73 WriteSGL WriteSGL // custom write 74 Lom *LOM 75 Lmfh *os.File 76 Msg *apc.BlobMsg 77 Wfqn string 78 } 79 ) 80 81 type ( 82 NodeMemCap interface { 83 Node 84 85 // Memory allocators 86 PageMM() *memsys.MMSA 87 ByteMM() *memsys.MMSA 88 89 // Space 90 OOS(*fs.CapStatus) fs.CapStatus 91 92 // xactions (jobs) now 93 GetAllRunning(inout *AllRunningInOut, periodic bool) 94 } 95 96 // a node that can also write objects 97 TargetPut interface { 98 NodeMemCap 99 100 // PUT params.Reader => lom 101 PutObject(lom *LOM, params *PutParams) (err error) 102 103 // utilize blob downloader to cold-GET => (lom | custom write callback) 104 GetColdBlob(params *BlobParams, oa *cmn.ObjAttrs) (xctn Xact, err error) 105 } 106 107 // local target node 108 TargetLoc interface { 109 TargetPut 110 111 // backend 112 Backend(*meta.Bck) Backend 113 114 // FS health and Health 115 FSHC(err error, path string) 116 Health(si *meta.Snode, timeout time.Duration, query url.Values) (body []byte, ecode int, err error) 117 } 118 119 // all of the above; for implementations, see `ais/tgtimpl.go` and `ais/htrun.go` 120 Target interface { 121 TargetLoc 122 123 // target <=> target & target => backend (no streams) 124 DataClient() *http.Client 125 126 // core object (+ PutObject above) 127 FinalizeObj(lom *LOM, workFQN string, xctn Xact, owt cmn.OWT) (ecode int, err error) 128 EvictObject(lom *LOM) (ecode int, err error) 129 DeleteObject(lom *LOM, evict bool) (ecode int, err error) 130 131 GetCold(ctx context.Context, lom *LOM, owt cmn.OWT) (ecode int, err error) 132 133 CopyObject(lom *LOM, dm DM, coi *CopyParams) (int64, error) 134 Promote(params *PromoteParams) (ecode int, err error) 135 HeadObjT2T(lom *LOM, si *meta.Snode) bool 136 137 BMDVersionFixup(r *http.Request, bck ...cmn.Bck) 138 } 139 )