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

Method listObjectsRemote

ais/proxy.go:2084–2158  ·  view source on GitHub ↗

listObjectsRemote returns the list of objects from requested remote bucket (cloud or remote AIS). If request requires local data then it is broadcast to all targets which perform traverse on the disks, otherwise random target is chosen to perform cloud listing.

(bck *cluster.Bck, lsmsg *apc.ListObjsMsg)

Source from the content-addressed store, hash-verified

2082// to all targets which perform traverse on the disks, otherwise random target
2083// is chosen to perform cloud listing.
2084func (p *proxy) listObjectsRemote(bck *cluster.Bck, lsmsg *apc.ListObjsMsg) (allEntries *cmn.BucketList, err error) {
2085 if lsmsg.StartAfter != "" {
2086 return nil, fmt.Errorf("list-objects %q option for remote buckets is not yet supported", lsmsg.StartAfter)
2087 }
2088 var (
2089 smap = p.owner.smap.get()
2090 config = cmn.GCO.Get()
2091 reqTimeout = config.Client.ListObjTimeout.D()
2092 aisMsg = p.newAmsgActVal(apc.ActList, &lsmsg)
2093 args = allocBcArgs()
2094 results sliceResults
2095 )
2096 args.req = cmn.HreqArgs{
2097 Method: http.MethodGet,
2098 Path: apc.URLPathBuckets.Join(bck.Name),
2099 Query: bck.AddToQuery(nil),
2100 Body: cos.MustMarshal(aisMsg),
2101 }
2102 if lsmsg.NeedLocalMD() {
2103 args.timeout = reqTimeout
2104 args.smap = smap
2105 args.cresv = cresBL{} // -> cmn.BucketList
2106 results = p.bcastGroup(args)
2107 } else {
2108 nl, exists := p.notifs.entry(lsmsg.UUID)
2109 debug.Assert(exists) // NOTE: we register listobj xaction before starting to list
2110 for _, si := range nl.Notifiers() {
2111 cargs := allocCargs()
2112 {
2113 cargs.si = si
2114 cargs.req = args.req
2115 cargs.timeout = reqTimeout
2116 cargs.cresv = cresBL{} // -> cmn.BucketList
2117 }
2118 res := p.call(cargs)
2119 freeCargs(cargs)
2120 results = make(sliceResults, 1)
2121 results[0] = res
2122 break
2123 }
2124 }
2125 freeBcArgs(args)
2126 // Combine the results.
2127 bckLists := make([]*cmn.BucketList, 0, len(results))
2128 for _, res := range results {
2129 if res.status == http.StatusNotFound {
2130 continue
2131 }
2132 if res.err != nil {
2133 err = res.toErr()
2134 freeBcastRes(results)
2135 return nil, err
2136 }
2137 bckLists = append(bckLists, res.v.(*cmn.BucketList))
2138 }
2139 freeBcastRes(results)
2140
2141 // Maximum objects in the final result page. Take all objects in

Callers 2

listObjectsMethod · 0.95
bckListS3Method · 0.95

Calls 15

MustMarshalFunction · 0.92
AssertFunction · 0.92
MergeObjListsFunction · 0.92
FastVFunction · 0.92
InfofFunction · 0.92
HrwTargetFunction · 0.92
allocBcArgsFunction · 0.85
allocCargsFunction · 0.85
freeCargsFunction · 0.85
freeBcArgsFunction · 0.85
freeBcastResFunction · 0.85
DMethod · 0.80

Tested by

no test coverage detected