Changeset 8673 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-08-20T23:01:54+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java
r8624 r8673 2 2 package org.openstreetmap.josm.data.cache; 3 3 4 import java.io.IOException; 5 import java.net.URL; 4 6 import java.util.Iterator; 5 7 import java.util.Map; … … 57 59 } 58 60 } else { 59 Main.info("TMS - Skipping job {0} because host limit reached", job.getUrl()); 61 URL url = null; 62 try { 63 url = job.getUrl(); 64 } catch (IOException e) { 65 } 66 Main.info("TMS - Skipping job {0} because host limit reached", url); 60 67 } 61 68 } … … 91 98 92 99 private Semaphore getSemaphore(JCSCachedTileLoaderJob<?, ?> job) { 93 String host = job.getUrl().getHost(); 100 String host; 101 try { 102 host = job.getUrl().getHost(); 103 } catch (IOException e) { 104 // do not pass me illegal URL's 105 throw new IllegalArgumentException(e); 106 } 94 107 Semaphore limit = hostSemaphores.get(host); 95 108 if (limit == null) { -
trunk/src/org/openstreetmap/josm/data/cache/ICachedLoaderJob.java
r8624 r8673 2 2 package org.openstreetmap.josm.data.cache; 3 3 4 import java.io.IOException; 4 5 import java.net.URL; 5 6 … … 21 22 * method to get download URL for Job 22 23 * @return URL that should be fetched 24 * @throws IOException when could not determine the URL of the tile 23 25 * 24 26 */ 25 URL getUrl() ;27 URL getUrl() throws IOException; 26 28 27 29 /** … … 42 44 * @param listener cache loader listener 43 45 * @param force true if the load should skip all the caches (local & remote) 46 * @throws IOException on failure from getUrl() call 44 47 */ 45 void submit(ICachedLoaderListener listener, boolean force) ;48 void submit(ICachedLoaderListener listener, boolean force) throws IOException; 46 49 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8649 r8673 149 149 150 150 @Override 151 public void submit(ICachedLoaderListener listener, boolean force) {151 public void submit(ICachedLoaderListener listener, boolean force) throws IOException { 152 152 this.force = force; 153 153 boolean first = false; … … 160 160 if (deduplicationKey == null) { 161 161 log.log(Level.WARNING, "No url returned for: {0}, skipping", getCacheKey()); 162 return;162 throw new IllegalArgumentException("No url returned"); 163 163 } 164 164 synchronized (inProgress) { … … 173 173 174 174 if (first || force) { 175 ensureCacheElement();176 175 // submit all jobs to separate thread, so calling thread is not blocked with IO when loading from disk 177 176 downloadJobExecutor.execute(this); … … 214 213 */ 215 214 protected String getServerKey() { 216 return getUrl ().getHost();215 return getUrlNoException().getHost(); 217 216 } 218 217 … … 221 220 final Thread currentThread = Thread.currentThread(); 222 221 final String oldName = currentThread.getName(); 223 currentThread.setName("JCS Downloading: " + getUrl()); 222 currentThread.setName("JCS Downloading: " + getUrlNoException()); 223 ensureCacheElement(); 224 224 try { 225 225 // try to fetch from cache … … 239 239 // try to get stale entry in cache 240 240 finishLoading(LoadResult.SUCCESS); 241 log.log(Level.FINE, "JCS - found stale object in cache: {0}", getUrl ());241 log.log(Level.FINE, "JCS - found stale object in cache: {0}", getUrlNoException()); 242 242 } else { 243 243 // failed completely … … 254 254 Set<ICachedLoaderListener> listeners = null; 255 255 synchronized (inProgress) { 256 listeners = inProgress.remove(getUrl ().toString());256 listeners = inProgress.remove(getUrlNoException().toString()); 257 257 } 258 258 if (listeners == null) { 259 log.log(Level.WARNING, "Listener not found for URL: {0}. Listener not notified!", getUrl ());259 log.log(Level.WARNING, "Listener not found for URL: {0}. Listener not notified!", getUrlNoException()); 260 260 return; 261 261 } … … 275 275 if (now > expires) { 276 276 log.log(Level.FINE, "JCS - Object {0} has expired -> valid to {1}, now is: {2}", 277 new Object[]{getUrl (), Long.toString(expires), Long.toString(now)});277 new Object[]{getUrlNoException(), Long.toString(expires), Long.toString(now)}); 278 278 return false; 279 279 } … … 281 281 now - attributes.getLastModification() > DEFAULT_EXPIRE_TIME) { 282 282 // check by file modification date 283 log.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrl ());283 log.log(Level.FINE, "JCS - Object has expired, maximum file age reached {0}", getUrlNoException()); 284 284 return false; 285 285 } else if (now - attributes.getCreateTime() > DEFAULT_EXPIRE_TIME) { 286 log.log(Level.FINE, "JCS - Object has expired, maximum time since object creation reached {0}", getUrl ());286 log.log(Level.FINE, "JCS - Object has expired, maximum time since object creation reached {0}", getUrlNoException()); 287 287 return false; 288 288 } … … 380 380 } 381 381 } catch (FileNotFoundException e) { 382 log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrl ());382 log.log(Level.FINE, "JCS - Caching empty object as server returned 404 for: {0}", getUrlNoException()); 383 383 attributes.setResponseCode(404); 384 384 attributes.setErrorMessage(e.toString()); … … 390 390 return doCache; 391 391 } catch (IOException e) { 392 log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrl ());392 log.log(Level.FINE, "JCS - IOExecption during communication with server for: {0}", getUrlNoException()); 393 393 attributes.setErrorMessage(e.toString()); 394 394 attributes.setResponseCode(499); // set dummy error code … … 401 401 } catch (Exception e) { 402 402 attributes.setErrorMessage(e.toString()); 403 log.log(Level.WARNING, "JCS - Exception during download {0}", getUrl ());403 log.log(Level.WARNING, "JCS - Exception during download {0}", getUrlNoException()); 404 404 Main.warn(e); 405 405 } 406 log.log(Level.WARNING, "JCS - Silent failure during download: {0}", getUrl ());406 log.log(Level.WARNING, "JCS - Silent failure during download: {0}", getUrlNoException()); 407 407 return false; 408 408 … … 517 517 finishLoading(LoadResult.CANCELED); 518 518 } 519 520 private URL getUrlNoException() { 521 try { 522 return getUrl(); 523 } catch (IOException e) { 524 return null; 525 } 526 } 519 527 } -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r8643 r8673 106 106 */ 107 107 @Override 108 public URL getUrl() {108 public URL getUrl() throws IOException { 109 109 if (url == null) { 110 try { 111 synchronized (this) { 112 if (url == null) 113 url = new URL(tile.getUrl()); 114 } 115 } catch (IOException e) { 116 LOG.log(Level.WARNING, "JCS TMS Cache - error creating URL for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()}); 117 LOG.log(Level.INFO, "Exception: ", e); 110 synchronized (this) { 111 if (url == null) 112 url = new URL(tile.getUrl()); 118 113 } 119 114 } … … 152 147 public void submit(boolean force) { 153 148 tile.initLoading(); 154 super.submit(this, force); 149 try { 150 super.submit(this, force); 151 } catch (Exception e) { 152 // if we fail to submit the job, mark tile as loaded and set error message 153 tile.finishLoading(); 154 tile.setError(e.getMessage()); 155 } 155 156 } 156 157 -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r8659 r8673 1305 1305 result.hasLoadingTiles = allTiles.size() < ts.size(); 1306 1306 for (Tile t : allTiles) { 1307 if ("no-tile".equals(t.getValue("tile-info"))) { 1308 result.hasOverzoomedTiles = true; 1309 } 1310 1307 1311 if (t.isLoaded()) { 1308 1312 if (!t.hasError()) { 1309 1313 result.hasVisibleTiles = true; 1310 1314 } 1311 if ("no-tile".equals(t.getValue("tile-info"))) { 1312 result.hasOverzoomedTiles = true; 1313 } 1314 } else { 1315 } else if (t.isLoading()) { 1315 1316 result.hasLoadingTiles = true; 1316 1317 } … … 1410 1411 // If all tiles at displayZoomLevel is loaded, load all tiles at next zoom level 1411 1412 // to make sure there're really no more zoom levels 1413 // loading is done in the next if section 1412 1414 if (zoom == displayZoomLevel && !tsi.hasLoadingTiles && zoom < dts.maxZoom) { 1413 1415 zoom++; … … 1416 1418 // When we have overzoomed tiles and all tiles at current zoomlevel is loaded, 1417 1419 // load tiles at previovus zoomlevels until we have all tiles on screen is loaded. 1420 // loading is done in the next if section 1418 1421 while (zoom > dts.minZoom && tsi.hasOverzoomedTiles && !tsi.hasLoadingTiles) { 1419 1422 zoom--;
Note:
See TracChangeset
for help on using the changeset viewer.