Changeset 14268 in josm


Ignore:
Timestamp:
2018-09-22T00:00:37+02:00 (6 years ago)
Author:
wiktorn
Message:

Retry tile download on transient errors.

Till now there was no strategy to retry tile download. Tiles for which download
finished with error where by design not downloaded again. Because we were
issuing surplus download requests it was not easy to notice, that some tiles
where downloaded at different zoom level. When surplus downloads where removed -
problem became aparent.

Redefine semantics in AbstractTileSourceLayer, that all Tiles that are not
loaded are tried again. Move all logic deciding whether tile has loaded or not
to TMSCachedTileLoaderJob.

Implment in TMSCachedTileLoaderJob following rules:

  • when HTTP status code is between 400 and 500 - treat errors as permament
  • when HTTP status code equals or is greater than 500 - then treat error as

temporary

  • when there was exception in JCSCachedTileLoaderJob, then HTTP status code is

set to 599. Treat this as permament error. This is suboptimal, as we could treat
Socket read timeout and similar as temporary, and UnkownHostException as
permament

The other aproach is to implement retry count in Tile and retry for finite
number of times, preferably with some delay between tries.

Closes: #16747
See: #16743

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java

    r14214 r14268  
    181181                    int httpStatusCode = attributes.getResponseCode();
    182182                    if (httpStatusCode >= 400 && !isNoTileAtZoom()) {
    183                         if (attributes.getErrorMessage() == null) {
    184                             tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
    185                         } else {
    186                             tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
    187                         }
    188183                        status = false;
     184                        handleError(attributes);
    189185                    }
    190186                }
     
    192188                break;
    193189            case FAILURE:
    194                 tile.setError("Problem loading tile");
     190                handleError(attributes);
    195191                tryLoadTileImage(object);
    196192                break;
     
    215211                }
    216212            }
     213        }
     214    }
     215
     216    private void handleError(CacheEntryAttributes attributes) {
     217        if (attributes != null) {
     218            int httpStatusCode = attributes.getResponseCode();
     219            if (attributes.getErrorMessage() == null) {
     220                tile.setError(tr("HTTP error {0} when loading tiles", httpStatusCode));
     221            } else {
     222                tile.setError(tr("Error downloading tiles: {0}", attributes.getErrorMessage()));
     223            }
     224            if (httpStatusCode >= 500 && httpStatusCode != 599) {
     225                // httpStatusCode = 599 is set by JCSCachedTileLoaderJob on IOException
     226                tile.setLoaded(false); // treat 500 errors as temporary and try to load it again
     227            }
     228        } else {
     229            tile.setError(tr("Problem loading tile"));
     230            // treat unknown errors as permanent and do not try to load tile again
    217231        }
    218232    }
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r14260 r14268  
    303303            tile.setImage(null);
    304304        }
    305         tile.setLoaded(success);
    306305        invalidateLater();
    307306        Logging.debug("tileLoadingFinished() tile: {0} success: {1}", tile, success);
     
    461460                    }
    462461                }
     462                content.add(Arrays.asList(tr("Status:"), tr(tile.getStatus())));
     463                content.add(Arrays.asList(tr("Loaded:"), tr(Boolean.toString(tile.isLoaded()))));
     464                content.add(Arrays.asList(tr("Loading:"), tr(Boolean.toString(tile.isLoading()))));
     465                content.add(Arrays.asList(tr("Error:"), tr(Boolean.toString(tile.hasError()))));
    463466                for (List<String> entry: content) {
    464467                    panel.add(new JLabel(entry.get(0) + ':'), GBC.std());
     
    889892        if (tile == null)
    890893            return false;
    891         if (!force && (tile.isLoaded() || tile.hasError()))
     894        if (!force && tile.isLoaded())
    892895            return false;
    893896        if (tile.isLoading())
Note: See TracChangeset for help on using the changeset viewer.