Show
Ignore:
Timestamp:
09/02/08 22:50:21 (4 months ago)
Author:
arneke
Message:

(Re)added functionality to force reseeding of existing tiles. Renamed getResponse to getTile.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/layer/wms/WMSLayer.java

    r348 r370  
    6767    private String errormime; 
    6868 
    69     //private int width; 
    70  
    71     //private int height; 
    72  
    7369    private String version; 
    7470 
     
    8581    private String vendorParameters; 
    8682 
    87     //private boolean debugheaders; 
    88  
    89     //protected transient GridCalculator[] gridCalc; 
    90  
    91     //private transient int zoomStart; 
    92  
    93     //private transient int zoomStop; 
    94  
    95     //private transient String request; 
    96  
    97     //protected transient String[] wmsURL; 
    98  
    9983    private transient int curWmsURL; 
    10084 
    101     //private transient String wmsLayers; 
    102  
    103     //private transient String wmsStyles; 
    104  
    105     //private transient WMSParameters wmsparams; 
    106  
    10785    private transient boolean saveExpirationHeaders; 
    10886 
     
    134112 
    135113    private static transient Log log; 
    136  
    137     //public WMSLayer(String layerName, CacheFactory cacheFactory) 
    138     //        throws GeoWebCacheException { 
    139     //    name = layerName; 
    140     //    initCacheFactory = cacheFactory; 
    141     //    log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 
    142     //} 
    143114     
    144115    public WMSLayer(String layerName, CacheFactory cacheFactory, 
     
    167138        //log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 
    168139    } 
    169      
    170 //    private void lazyLayerInitialization() { 
    171 //        width = 256; 
    172 //        height = 256; 
    173 //        version = "1.1.0"; 
    174 //        transparent = true; 
    175 //        zoomStart = 0; 
    176 //        zoomStop = 20; 
    177 //        request = "GetMap"; 
    178 //        errormime = ErrorMime.vnd_ogc_se_inimage.getMimeType(); 
    179 //        curWmsURL = 0; 
    180 //        wmsLayers = "topp:states"; 
    181 //        saveExpirationHeaders = false; 
    182 //        expireClients = GWCVars.CACHE_USE_WMS_BACKEND_VALUE; 
    183 //        expireCache = GWCVars.CACHE_NEVER_EXPIRE; 
    184 //        layerLock = new ReentrantLock(); 
    185 //        layerLocked = false; 
    186 //        layerLockedCond = layerLock.newCondition(); 
    187 //        procQueue = new HashMap<GridLocObj, Boolean>(); 
    188 //        cacheLockWait = -1; 
    189 //        //initCacheFactory = cf;             
    190 //    } 
    191140 
    192141    public Boolean isInitialized() { 
     
    204153 
    205154    protected Boolean initialize() { 
    206          
    207         //lazyLayerInitialization(); 
    208155        log = LogFactory.getLog(org.geowebcache.layer.wms.WMSLayer.class); 
    209156        curWmsURL = 0; 
     
    214161        //width = 256; 
    215162        //height = 256; 
    216          
    217163        //request = "GetMap"; 
     164         
    218165        errormime = ErrorMime.vnd_ogc_se_inimage.getMimeType(); 
    219166        version = "1.1.0"; 
     
    226173        procQueue = new HashMap<GridLocObj, Boolean>(); 
    227174         
    228          
    229175        try { 
    230176            initParameters(); 
     
    258204     * @return 
    259205     */ 
    260     public Tile getResponse(Tile tile) throws GeoWebCacheException, IOException { 
     206    public Tile getTile(Tile tile) throws GeoWebCacheException, IOException { 
    261207        MimeType mime = tile.getMimeType(); 
    262208 
     
    278224        // Okay, so we need to go to the backend 
    279225        if (mime.supportsTiling()) { 
    280             return getMetatilingReponse(tile); 
     226            return getMetatilingReponse(tile, true); 
    281227        } else { 
    282             return getNonMetatilingReponse(tile); 
    283         } 
    284     } 
     228            return getNonMetatilingReponse(tile, true); 
     229        } 
     230    } 
     231     
     232     
     233    /** 
     234     * Used for seeding 
     235     */ 
     236    public void seedTile(Tile tile, boolean tryCache) throws GeoWebCacheException, IOException {      
     237        if (tile.getMimeType().supportsTiling()) { 
     238            getMetatilingReponse(tile, tryCache); 
     239        } else { 
     240            getNonMetatilingReponse(tile, tryCache); 
     241        } 
     242    } 
     243     
    285244 
    286245    /** 
    287246     * Metatiling request forwarding 
    288247     *  
    289      * @param tileRequest 
    290      * @param gridLoc 
    291      * @param mime 
    292      * @param idx 
    293      * @param response 
    294      * @return 
     248     * @param tile the Tile with all the information 
     249     * @param tryCache whether to try the cache, or seed 
    295250     * @throws GeoWebCacheException 
    296251     */ 
    297     private Tile getMetatilingReponse(Tile tile) throws GeoWebCacheException { 
    298  
     252    private Tile getMetatilingReponse(Tile tile, boolean tryCache)  
     253    throws GeoWebCacheException { 
    299254        //int idx = this.getSRSIndex(tile.getSRS()); 
    300255        int[] gridLoc = tile.getTileIndex(); 
     
    318273        try { 
    319274            /** ****************** Check cache again ************** */ 
    320             if (tryCacheFetch(tile)) { 
     275            if (tryCache && tryCacheFetch(tile)) { 
    321276                // Someone got it already, return lock and we're done 
    322277                removeFromQueue(metaGlo, condIdx); 
     
    370325     * Non-metatiling forward to backend 
    371326     *  
    372      * @param tileRequest 
    373      * @param gridLoc 
    374      * @param mime 
    375      * @param idx 
    376      * @param response 
    377      * @return 
    378      */ 
    379     private Tile getNonMetatilingReponse(Tile tile) throws GeoWebCacheException { 
     327     * @param tile the Tile with all the information 
     328     * @param tryCache whether to try the cache, or seed 
     329     * @throws GeoWebCacheException 
     330     */ 
     331    private Tile getNonMetatilingReponse(Tile tile, boolean tryCache)  
     332    throws GeoWebCacheException { 
    380333        // String debugHeadersStr = null; 
    381334        int[] gridLoc = tile.getTileIndex(); 
     
    387340        try { 
    388341            /** ****************** Check cache again ************** */ 
    389             if (tryCacheFetch(tile)) { 
     342            if (tryCache && tryCacheFetch(tile)) { 
    390343                // Someone got it already, return lock and we're done 
    391344                removeFromQueue(glo, condIdx);