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

Method downloadLocal

downloader/task.go:159–194  ·  view source on GitHub ↗
(lom *cluster.LOM)

Source from the content-addressed store, hash-verified

157}
158
159func (t *singleObjectTask) downloadLocal(lom *cluster.LOM) (err error) {
160 var (
161 timeout = t.initialTimeout()
162 fatal bool
163 )
164 for i := 0; i < retryCnt; i++ {
165 fatal, err = t.tryDownloadLocal(lom, timeout)
166 if err == nil || fatal {
167 return err
168 }
169 if errors.Is(err, context.Canceled) || errors.Is(err, errThrottlerStopped) {
170 // Download was canceled or stopped, so just return.
171 return err
172 }
173 if errors.Is(err, context.DeadlineExceeded) {
174 glog.Warningf("%s [retries: %d/%d]: timeout (%v) - increasing and retrying...",
175 t, i, retryCnt, timeout)
176 timeout = time.Duration(float64(timeout) * reqTimeoutFactor)
177 } else if httpErr := cmn.Err2HTTPErr(err); httpErr != nil {
178 glog.Warningf("%s [retries: %d/%d]: failed to perform request: %v (code: %d)", t, i, retryCnt, err,
179 httpErr.Status)
180 if _, exists := terminalStatuses[httpErr.Status]; exists {
181 // Nothing we can do...
182 return err
183 }
184 // Otherwise retry...
185 } else if cos.IsRetriableConnErr(err) {
186 glog.Warningf("%s [retries: %d/%d]: connection failed with (%v), retrying...", t, i, retryCnt, err)
187 } else {
188 glog.Warningf("%s [retries: %d/%d]: unexpected error (%v), retrying...", t, i, retryCnt, err)
189 }
190
191 t.reset()
192 }
193 return err
194}
195
196func (t *singleObjectTask) wrapReader(ctx context.Context, r io.ReadCloser) io.ReadCloser {
197 // Create a custom reader to monitor progress every time we read from response body stream.

Callers 1

downloadMethod · 0.95

Calls 7

initialTimeoutMethod · 0.95
tryDownloadLocalMethod · 0.95
resetMethod · 0.95
WarningfFunction · 0.92
Err2HTTPErrFunction · 0.92
IsRetriableConnErrFunction · 0.92
IsMethod · 0.80

Tested by

no test coverage detected