Class TMSCachedTileLoader
java.lang.Object
org.openstreetmap.josm.data.imagery.TMSCachedTileLoader
- All Implemented Interfaces:
org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader,org.openstreetmap.gui.jmapviewer.interfaces.TileLoader
- Direct Known Subclasses:
WMSCachedTileLoader
public class TMSCachedTileLoader
extends Object
implements org.openstreetmap.gui.jmapviewer.interfaces.TileLoader, org.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader
Wrapper class that bridges between JCS cache and Tile Loaders
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.commons.jcs3.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> private static final ThreadPoolExecutorseparate from JCS thread pool for TMS loader, so we can have different thread pools for default JCS and for TMS imageryprivate ThreadPoolExecutorstatic final IntegerPropertyLimit definition for per host concurrent connectionsprotected final org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListenerprotected final TileJobOptionsstatic final IntegerPropertyoverrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for TMS -
Constructor Summary
ConstructorsConstructorDescriptionTMSCachedTileLoader(org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener, org.apache.commons.jcs3.access.behavior.ICacheAccess<String, BufferedImageCacheEntry> cache, TileJobOptions options) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidcancels all outstanding tasks in the queue.voidclearCache(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source) org.openstreetmap.gui.jmapviewer.interfaces.TileJobcreateTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile tile) Returns download executor that is used by this factory.static ThreadPoolExecutorReturns a newThreadPoolExecutor.static ThreadPoolExecutorgetNewThreadPoolExecutor(String nameFormat, int workers) Returns a newThreadPoolExecutor.static ThreadPoolExecutorgetNewThreadPoolExecutor(String nameFormat, int workers, int hostLimit) Returns a newThreadPoolExecutor.getStats()Returns cache statistics as string.booleanvoidsetDownloadExecutor(ThreadPoolExecutor downloadExecutor) Sets the download executor that will be used to download tiles instead of default one.voidshutdown()Shutdown the job dispatcher provided that it's not the default one
-
Field Details
-
cache
protected final org.apache.commons.jcs3.access.behavior.ICacheAccess<String,BufferedImageCacheEntry> cache -
listener
-
THREAD_LIMIT
overrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for TMS -
HOST_LIMIT
Limit definition for per host concurrent connections -
DEFAULT_DOWNLOAD_JOB_DISPATCHER
separate from JCS thread pool for TMS loader, so we can have different thread pools for default JCS and for TMS imagery -
downloadExecutor
-
options
-
-
Constructor Details
-
TMSCachedTileLoader
public TMSCachedTileLoader(org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener, org.apache.commons.jcs3.access.behavior.ICacheAccess<String, BufferedImageCacheEntry> cache, TileJobOptions options) Constructor- Parameters:
listener- called when tile loading has finishedcache- of the cacheoptions- tile job options
-
-
Method Details
-
getNewThreadPoolExecutor
Returns a newThreadPoolExecutor.- Parameters:
nameFormat- seeUtils.newThreadFactory(String, int)workers- number of worker thread to keep- Returns:
- new ThreadPoolExecutor that will use a @see HostLimitQueue based queue
-
getNewThreadPoolExecutor
public static ThreadPoolExecutor getNewThreadPoolExecutor(String nameFormat, int workers, int hostLimit) Returns a newThreadPoolExecutor.- Parameters:
nameFormat- seeUtils.newThreadFactory(String, int)workers- number of worker thread to keephostLimit- number of concurrent downloads per host allowed- Returns:
- new ThreadPoolExecutor that will use a @see HostLimitQueue based queue
-
getNewThreadPoolExecutor
Returns a newThreadPoolExecutor.- Parameters:
name- name of threads- Returns:
- new ThreadPoolExecutor that will use a
HostLimitQueuebased queue, with default number of threads
-
createTileLoaderJob
public org.openstreetmap.gui.jmapviewer.interfaces.TileJob createTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile tile) - Specified by:
createTileLoaderJobin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
clearCache
- Specified by:
clearCachein interfaceorg.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader
-
getStats
Returns cache statistics as string.- Returns:
- cache statistics as string
-
cancelOutstandingTasks
cancels all outstanding tasks in the queue. This rollbacks the state of the tiles in the queue to loading = false / loaded = false- Specified by:
cancelOutstandingTasksin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
hasOutstandingTasks
- Specified by:
hasOutstandingTasksin interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
setDownloadExecutor
Sets the download executor that will be used to download tiles instead of default one. You can usegetNewThreadPoolExecutor(java.lang.String, int)to create a new download executor with separate queue from default.- Parameters:
downloadExecutor- download executor that will be used to download tiles
-
getDownloadExecutor
Returns download executor that is used by this factory.- Returns:
- download executor that is used by this factory
-
shutdown
Shutdown the job dispatcher provided that it's not the default one
-