- Timestamp:
- 2015-05-24T23:41:24+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8424 r8425 96 96 private static ConcurrentMap<String, Boolean> useHead = new ConcurrentHashMap<>(); 97 97 98 pr ivatelong now; // when the job started98 protected long now; // when the job started 99 99 100 100 private ICacheAccess<K, V> cache; … … 398 398 protected abstract V createCacheEntry(byte[] content); 399 399 400 pr ivateCacheEntryAttributes parseHeaders(URLConnection urlConn) {400 protected CacheEntryAttributes parseHeaders(URLConnection urlConn) { 401 401 CacheEntryAttributes ret = new CacheEntryAttributes(); 402 402 -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r8424 r8425 7 7 import java.io.IOException; 8 8 import java.net.URL; 9 import java.net.URLConnection; 9 10 import java.util.HashSet; 10 11 import java.util.List; … … 38 39 */ 39 40 public class TMSCachedTileLoaderJob extends JCSCachedTileLoaderJob<String, BufferedImageCacheEntry> implements TileJob, ICachedLoaderListener { 40 private static final Logger log = FeatureAdapter.getLogger(TMSCachedTileLoaderJob.class.getCanonicalName()); 41 private static final Logger LOG = FeatureAdapter.getLogger(TMSCachedTileLoaderJob.class.getCanonicalName()); 42 private static final long MAXIMUM_EXPIRES = 30 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/; 43 private static final long MINIMUM_EXPIRES = 1 /*hour*/ * 60 /*minutes*/ * 60 /*seconds*/ *1000L /*milliseconds*/; 41 44 private Tile tile; 42 45 private volatile URL url; 46 43 47 44 48 // we need another deduplication of Tile Loader listeners, as for each submit, new TMSCachedTileLoaderJob was created … … 105 109 } 106 110 } catch (IOException e) { 107 log.log(Level.WARNING, "JCS TMS Cache - error creating URL for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});108 log.log(Level.INFO, "Exception: ", e);111 LOG.log(Level.WARNING, "JCS TMS Cache - error creating URL for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()}); 112 LOG.log(Level.INFO, "Exception: ", e); 109 113 } 110 114 } … … 119 123 return content != null || cacheData.getImage() != null || isNoTileAtZoom(); 120 124 } catch (IOException e) { 121 log.log(Level.WARNING, "JCS TMS - error loading from cache for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});125 LOG.log(Level.WARNING, "JCS TMS - error loading from cache for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()}); 122 126 } 123 127 } … … 127 131 private boolean isNoTileAtZoom() { 128 132 if (attributes == null) { 129 log.warning("Cache attributes are null");133 LOG.warning("Cache attributes are null"); 130 134 } 131 135 return attributes != null && attributes.isNoTileAtZoom(); … … 146 150 private boolean handleNoTileAtZoom() { 147 151 if (isNoTileAtZoom()) { 148 log.log(Level.FINE, "JCS TMS - Tile valid, but no file, as no tiles at this level {0}", tile);152 LOG.log(Level.FINE, "JCS TMS - Tile valid, but no file, as no tiles at this level {0}", tile); 149 153 tile.setError("No tile at this zoom level"); 150 154 tile.putValue("tile-info", "no-tile"); … … 207 211 } 208 212 } catch (IOException e) { 209 log.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});213 LOG.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()}); 210 214 tile.setError(e.getMessage()); 211 215 tile.setLoaded(false); … … 246 250 return tile; 247 251 } catch (IOException e) { 248 log.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()});252 LOG.log(Level.WARNING, "JCS TMS - error loading object for tile {0}: {1}", new Object[] {tile.getKey(), e.getMessage()}); 249 253 return null; 250 254 } … … 288 292 submit(false); 289 293 } 294 295 @Override 296 protected CacheEntryAttributes parseHeaders(URLConnection urlConn) { 297 CacheEntryAttributes ret = super.parseHeaders(urlConn); 298 // keep the expiration time between MINIMUM_EXPIRES and MAXIMUM_EXPIRES, so we will cache the tiles 299 // at least for some short period of time, but not too long 300 if (ret.getExpirationTime() < MINIMUM_EXPIRES) { 301 ret.setExpirationTime(now + MINIMUM_EXPIRES); 302 } 303 if (ret.getExpirationTime() > MAXIMUM_EXPIRES) { 304 ret.setExpirationTime(now + MAXIMUM_EXPIRES); 305 } 306 return ret; 307 } 290 308 }
Note:
See TracChangeset
for help on using the changeset viewer.