forked from NVIDIA/aistore
/
target.go
139 lines (119 loc) · 3.94 KB
/
target.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Package cluster provides local access to cluster-level metadata
/*
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
*/
package cluster
import (
"context"
"io"
"net/http"
"net/url"
"time"
"github.com/artashesbalabekyan/aistore/cluster/meta"
"github.com/artashesbalabekyan/aistore/cmn"
"github.com/artashesbalabekyan/aistore/cmn/cos"
"github.com/artashesbalabekyan/aistore/fs"
"github.com/artashesbalabekyan/aistore/memsys"
"github.com/artashesbalabekyan/aistore/transport"
)
//
// ais target: types and interfaces
//
type (
NodeMemCap interface {
Node
// Memory allocators
PageMM() *memsys.MMSA
ByteMM() *memsys.MMSA
// Space
OOS(*fs.CapStatus) fs.CapStatus
// Running now
GetAllRunning(xactKind string, separateIdle bool) (running, idle []string)
}
// a node that can also write objects
TargetPut interface {
NodeMemCap
// local PUT
PutObject(lom *LOM, params *PutObjectParams) (err error)
}
// local target node
TargetLoc interface {
TargetPut
// backend
Backend(*meta.Bck) BackendProvider
// FS health and Health
FSHC(err error, path string)
Health(si *meta.Snode, timeout time.Duration, query url.Values) (body []byte, errCode int, err error)
}
// all of the above; for implementations, see `ais/tgtimpl.go` and `ais/htrun.go`
Target interface {
TargetLoc
// (for intra-cluster data-net comm - no streams)
DataClient() *http.Client
CompareObjects(ctx context.Context, lom *LOM) (equal bool, errCode int, err error)
// core object (+ PutObject above)
FinalizeObj(lom *LOM, workFQN string, xctn Xact) (errCode int, err error)
EvictObject(lom *LOM) (errCode int, err error)
DeleteObject(lom *LOM, evict bool) (errCode int, err error)
CopyObject(lom *LOM, params *CopyObjectParams, dryRun bool) (int64, error)
GetCold(ctx context.Context, lom *LOM, owt cmn.OWT) (errCode int, err error)
Promote(params PromoteParams) (errCode int, err error)
HeadObjT2T(lom *LOM, si *meta.Snode) bool
}
TargetExt interface {
Target
// misc
BMDVersionFixup(r *http.Request, bck ...cmn.Bck)
}
)
// data path: control structures and types
type (
OnFinishObj = func(lom *LOM, err error)
DataMover interface {
RegRecv() error
GetXact() Xact
Open()
Close(err error)
UnregRecv()
Send(obj *transport.Obj, roc cos.ReadOpenCloser, tsi *meta.Snode) error
ACK(hdr transport.ObjHdr, cb transport.ObjSentCB, tsi *meta.Snode) error
OWT() cmn.OWT
}
PutObjectParams struct {
Reader io.ReadCloser
Cksum *cos.Cksum // checksum to check
Atime time.Time
Xact Xact
WorkTag string // (=> work fqn)
OWT cmn.OWT
SkipEncode bool // don't run erasure-code when finalizing
}
CopyObjectParams struct {
DM DataMover
DP DP // Data Provider (optional; see Transform/Copy Bucket (TCB))
Xact Xact
BckTo *meta.Bck
ObjNameTo string
Buf []byte
}
// common part that's used in `api.PromoteArgs` and `PromoteParams`(server side), both
PromoteArgs struct {
DaemonID string `json:"tid,omitempty"` // target ID
SrcFQN string `json:"src,omitempty"` // source file or directory (must be absolute pathname)
ObjName string `json:"obj,omitempty"` // destination object name
Recursive bool `json:"rcr,omitempty"` // recursively promote nested dirs
// once successfully promoted:
OverwriteDst bool `json:"ovw,omitempty"` // overwrite destination
DeleteSrc bool `json:"dls,omitempty"` // remove source when (and after) successfully promoting
// explicit request _not_ to treat the source as a potential file share
// and _not_ to try to auto-detect if it is;
// (auto-detection takes time, etc.)
SrcIsNotFshare bool `json:"notshr,omitempty"` // the source is not a file share equally accessible by all targets
}
PromoteParams struct {
Bck *meta.Bck // destination bucket
Cksum *cos.Cksum // checksum to validate
Xact Xact // responsible xaction
PromoteArgs // all of the above
}
)