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

Method listObjects

ais/proxy.go:1280–1356  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, bck *cluster.Bck, amsg *apc.ActionMsg,
	lsmsg *apc.ListObjsMsg, begin int64)

Source from the content-addressed store, hash-verified

1278}
1279
1280func (p *proxy) listObjects(w http.ResponseWriter, r *http.Request, bck *cluster.Bck, amsg *apc.ActionMsg,
1281 lsmsg *apc.ListObjsMsg, begin int64) {
1282 var (
1283 err error
1284 bckList *cmn.BucketList
1285 smap = p.owner.smap.get()
1286 )
1287 if smap.CountActiveTargets() < 1 {
1288 p.writeErrMsg(w, r, "no registered targets yet")
1289 return
1290 }
1291
1292 // If props were not explicitly specified always return default ones.
1293 if lsmsg.Props == "" {
1294 lsmsg.AddProps(apc.GetPropsDefault...)
1295 }
1296
1297 // Vanilla HTTP buckets do not support remote listing.
1298 // LsArchDir needs files locally to read archive content.
1299 if bck.IsHTTP() || lsmsg.IsFlagSet(apc.LsArchDir) {
1300 lsmsg.SetFlag(apc.LsPresent)
1301 }
1302
1303 locationIsAIS := bck.IsAIS() || lsmsg.IsFlagSet(apc.LsPresent)
1304 if lsmsg.UUID == "" {
1305 var nl nl.NotifListener
1306 lsmsg.UUID = cos.GenUUID()
1307 if locationIsAIS || lsmsg.NeedLocalMD() {
1308 nl = xact.NewXactNL(lsmsg.UUID, apc.ActList, &smap.Smap, nil, bck.Bucket())
1309 } else {
1310 // random target to execute `list-objects` on a Cloud bucket
1311 si, _ := smap.GetRandTarget()
1312 nl = xact.NewXactNL(lsmsg.UUID, apc.ActList,
1313 &smap.Smap, cluster.NodeMap{si.ID(): si}, bck.Bucket())
1314 }
1315 nl.SetHrwOwner(&smap.Smap)
1316 p.ic.registerEqual(regIC{nl: nl, smap: smap, msg: amsg})
1317 }
1318
1319 if p.ic.reverseToOwner(w, r, lsmsg.UUID, amsg) {
1320 return
1321 }
1322
1323 if locationIsAIS {
1324 bckList, err = p.listObjectsAIS(bck, lsmsg)
1325 } else {
1326 bckList, err = p.listObjectsRemote(bck, lsmsg)
1327 // TODO: `status == http.StatusGone` At this point we know that this
1328 // remote bucket exists and is offline. We should somehow try to list
1329 // cached objects. This isn't easy as we basically need to start a new
1330 // xaction and return new `UUID`.
1331 }
1332 if err != nil {
1333 p.writeErr(w, r, err)
1334 return
1335 }
1336 debug.Assert(bckList != nil)
1337

Callers 1

httpbckgetMethod · 0.95

Calls 15

SetHrwOwnerMethod · 0.95
listObjectsAISMethod · 0.95
listObjectsRemoteMethod · 0.95
GenUUIDFunction · 0.92
NewXactNLFunction · 0.92
AssertFunction · 0.92
SinceNanoFunction · 0.92
CountActiveTargetsMethod · 0.80
writeErrMsgMethod · 0.80
AddPropsMethod · 0.80
IsFlagSetMethod · 0.80
SetFlagMethod · 0.80

Tested by

no test coverage detected