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

Method RemoteObjPage

objwalk/objwalk.go:74–141  ·  view source on GitHub ↗

RemoteObjPage reads a page of objects in a cloud bucket. NOTE: if a request wants cached object list, the function returns only local data without talking to backend provider. After reading cloud object list, the function fills it with information that is available only locally(copies, targetURL etc

()

Source from the content-addressed store, hash-verified

72// After reading cloud object list, the function fills it with information
73// that is available only locally(copies, targetURL etc).
74func (w *Walk) RemoteObjPage() (*cmn.BucketList, error) {
75 if w.msg.IsFlagSet(apc.LsPresent) {
76 return w.DefaultLocalObjPage()
77 }
78 msg := &apc.ListObjsMsg{}
79 *msg = *w.msg
80 objList, _, err := w.t.Backend(w.bck).ListObjects(w.bck, msg)
81 if err != nil {
82 return nil, err
83 }
84 var (
85 localURL = w.t.Snode().URL(cmn.NetPublic)
86 localID = w.t.SID()
87 smap = w.t.Sowner().Get()
88 postCallback, _ = w.ctx.Value(walkinfo.CtxPostCallbackKey).(walkinfo.PostCallbackFunc)
89 needURL = w.msg.WantProp(apc.GetTargetURL)
90 needAtime = w.msg.WantProp(apc.GetPropsAtime)
91 needCksum = w.msg.WantProp(apc.GetPropsChecksum)
92 needVersion = w.msg.WantProp(apc.GetPropsVersion)
93 needCopies = w.msg.WantProp(apc.GetPropsCopies)
94 )
95 for _, e := range objList.Entries {
96 si, _ := cluster.HrwTarget(w.bck.MakeUname(e.Name), smap)
97 if si.ID() != localID {
98 continue
99 }
100
101 if needURL {
102 e.TargetURL = localURL
103 }
104 lom := cluster.AllocLOM(e.Name)
105 if err := lom.InitBck(w.bck.Bucket()); err != nil {
106 cluster.FreeLOM(lom)
107 if cmn.IsErrBucketNought(err) {
108 return nil, err
109 }
110 continue
111 }
112 if err := lom.Load(true /* cache it*/, false /*locked*/); err != nil {
113 cluster.FreeLOM(lom)
114 continue
115 }
116 e.SetExists()
117 if needAtime {
118 if lom.AtimeUnix() < 0 {
119 // Prefetched object - return zero time
120 e.Atime = cos.FormatUnixNano(0, w.msg.TimeFormat)
121 } else {
122 e.Atime = cos.FormatUnixNano(lom.AtimeUnix(), w.msg.TimeFormat)
123 }
124 }
125 if needCksum && lom.Checksum() != nil {
126 e.Checksum = lom.Checksum().Value()
127 }
128 if needVersion && lom.Version() != "" {
129 e.Version = lom.Version()
130 }
131 if needCopies {

Callers 2

_runMethod · 0.95
nextPageRemoteMethod · 0.95

Calls 15

DefaultLocalObjPageMethod · 0.95
HrwTargetFunction · 0.92
AllocLOMFunction · 0.92
FreeLOMFunction · 0.92
IsErrBucketNoughtFunction · 0.92
FormatUnixNanoFunction · 0.92
IsFlagSetMethod · 0.80
WantPropMethod · 0.80
InitBckMethod · 0.80
SetExistsMethod · 0.80
NumCopiesMethod · 0.80
ListObjectsMethod · 0.65

Tested by

no test coverage detected