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 java.lang.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
Fields Modifier and Type Field Description protected org.apache.commons.jcs3.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry>
cache
private static java.util.concurrent.ThreadPoolExecutor
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 imageryprivate java.util.concurrent.ThreadPoolExecutor
downloadExecutor
static IntegerProperty
HOST_LIMIT
Limit definition for per host concurrent connectionsprotected org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener
listener
protected TileJobOptions
options
static IntegerProperty
THREAD_LIMIT
overrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for TMS
-
Constructor Summary
Constructors Constructor Description TMSCachedTileLoader(org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener, org.apache.commons.jcs3.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry> cache, TileJobOptions options)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelOutstandingTasks()
cancels all outstanding tasks in the queue.void
clearCache(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source)
org.openstreetmap.gui.jmapviewer.interfaces.TileJob
createTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile tile)
java.util.concurrent.ThreadPoolExecutor
getDownloadExecutor()
Returns download executor that is used by this factory.static java.util.concurrent.ThreadPoolExecutor
getNewThreadPoolExecutor(java.lang.String name)
Returns a newThreadPoolExecutor
.static java.util.concurrent.ThreadPoolExecutor
getNewThreadPoolExecutor(java.lang.String nameFormat, int workers)
Returns a newThreadPoolExecutor
.static java.util.concurrent.ThreadPoolExecutor
getNewThreadPoolExecutor(java.lang.String nameFormat, int workers, int hostLimit)
Returns a newThreadPoolExecutor
.java.lang.String
getStats()
Returns cache statistics as string.boolean
hasOutstandingTasks()
void
setDownloadExecutor(java.util.concurrent.ThreadPoolExecutor downloadExecutor)
Sets the download executor that will be used to download tiles instead of default one.void
shutdown()
Shutdown the job dispatcher provided that it's not the default one
-
-
-
Field Detail
-
cache
protected final org.apache.commons.jcs3.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry> cache
-
listener
protected final org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener
-
THREAD_LIMIT
public static final IntegerProperty THREAD_LIMIT
overrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for TMS
-
HOST_LIMIT
public static final IntegerProperty HOST_LIMIT
Limit definition for per host concurrent connections
-
DEFAULT_DOWNLOAD_JOB_DISPATCHER
private static final java.util.concurrent.ThreadPoolExecutor 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
private java.util.concurrent.ThreadPoolExecutor downloadExecutor
-
options
protected final TileJobOptions options
-
-
Constructor Detail
-
TMSCachedTileLoader
public TMSCachedTileLoader(org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener listener, org.apache.commons.jcs3.access.behavior.ICacheAccess<java.lang.String,BufferedImageCacheEntry> cache, TileJobOptions options)
Constructor- Parameters:
listener
- called when tile loading has finishedcache
- of the cacheoptions
- tile job options
-
-
Method Detail
-
getNewThreadPoolExecutor
public static java.util.concurrent.ThreadPoolExecutor getNewThreadPoolExecutor(java.lang.String nameFormat, int workers)
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 java.util.concurrent.ThreadPoolExecutor getNewThreadPoolExecutor(java.lang.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
public static java.util.concurrent.ThreadPoolExecutor getNewThreadPoolExecutor(java.lang.String name)
Returns a newThreadPoolExecutor
.- Parameters:
name
- name of threads- Returns:
- new ThreadPoolExecutor that will use a
HostLimitQueue
based queue, with default number of threads
-
createTileLoaderJob
public org.openstreetmap.gui.jmapviewer.interfaces.TileJob createTileLoaderJob(org.openstreetmap.gui.jmapviewer.Tile tile)
- Specified by:
createTileLoaderJob
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
clearCache
public void clearCache(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source)
- Specified by:
clearCache
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.CachedTileLoader
-
getStats
public java.lang.String getStats()
Returns cache statistics as string.- Returns:
- cache statistics as string
-
cancelOutstandingTasks
public void 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:
cancelOutstandingTasks
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
hasOutstandingTasks
public boolean hasOutstandingTasks()
- Specified by:
hasOutstandingTasks
in interfaceorg.openstreetmap.gui.jmapviewer.interfaces.TileLoader
-
setDownloadExecutor
public void setDownloadExecutor(java.util.concurrent.ThreadPoolExecutor downloadExecutor)
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
public java.util.concurrent.ThreadPoolExecutor getDownloadExecutor()
Returns download executor that is used by this factory.- Returns:
- download executor that is used by this factory
-
shutdown
public void shutdown()
Shutdown the job dispatcher provided that it's not the default one
-
-