Changeset 410

Show
Ignore:
Timestamp:
11/08/08 17:29:30 (2 months ago)
Author:
arneke
Message:

Fixes seeding progress reports.

Location:
trunk/geowebcache/src/main/java/org/geowebcache/rest
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/GWCTask.java

    r369 r410  
    1919import org.geowebcache.GeoWebCacheException; 
    2020 
     21/** 
     22 *  
     23 */ 
    2124public abstract class GWCTask { 
    2225     
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/RESTDispatcher.java

    r409 r410  
    5252    private static final int THREAD_NUMBER = 4; 
    5353     
    54     private static final int THREAD_MAX_NUMBER = 32; 
     54    static final int THREAD_MAX_NUMBER = 32; 
    5555     
    5656    private final XMLConfiguration xmlConfig; 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedResource.java

    r389 r410  
    4949 
    5050public class SeedResource extends GWCResource { 
    51     private static int[][] statusArray = new int[RESTDispatcher.getInstance().getExecutor().getCorePoolSize()][3];  
     51    private static int[][] statusArray = new int[RESTDispatcher.THREAD_MAX_NUMBER][3];  
    5252    public JSONObject myrequest;  
    5353    private static Log log = LogFactory.getLog(org.geowebcache.rest.SeedResource.class); 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedTask.java

    r393 r410  
    5959            tl.isInitialized(); 
    6060             
    61             log.info("Begin seeding layer : " + tl.getName()); 
     61            log.info("Thread "+threadOffset+" begins seeding layer : " + tl.getName()); 
    6262            int zoomStart = req.getZoomStart().intValue(); 
    6363            int zoomStop = req.getZoomStop().intValue(); 
     
    8383             
    8484            int arrayIndex = getCurrentThreadArrayIndex(); 
    85             int TOTAL_TILES = tileCount(coveredGridLevels, zoomStart, zoomStop);  
     85            int TOTAL_TILES = tileCount(coveredGridLevels, zoomStart, zoomStop); 
     86            int tilesPerThread = TOTAL_TILES / threadCount; 
     87            int[][] list = SeedResource.getStatusList(); 
     88             
    8689            int count = 0; 
    8790            boolean tryCache = !reseed; 
     
    9194                for (int gridy = gridBounds[1]; gridy <= gridBounds[3];) { 
    9295 
    93                     for (int gridx = gridBounds[0]; gridx <= gridBounds[2];) { 
     96                    for (int gridx = gridBounds[0] + threadOffset; gridx <= gridBounds[2];) { 
    9497                         
    9598                        int[] gridLoc = { gridx, gridy, level }; 
     
    106109 
    107110                        // Next column 
    108                         gridx += metaTilingFactors[0] * (1 + threadOffset); 
     111                        gridx += metaTilingFactors[0]; 
    109112                         
    110113                        count += tilesPerMetaTile; 
    111                          
    112                         int[][] list = SeedResource.getStatusList(); 
    113114                         
    114115                        // Threads don't really collide 
    115116                        //synchronized(list) { 
    116117                            // This is not quite right... 
    117                             list[arrayIndex]= getStatusInfo(arrayIndex, tl, count, (TOTAL_TILES / threadCount), START_TIME); 
     118                            list[arrayIndex]= getStatusInfo(arrayIndex, tl, count, tilesPerThread, START_TIME); 
    118119                        //} 
    119120                    } 
     
    124125                } 
    125126 
    126                 log.info("Completed seeding level " + level + " for layer " 
    127                         + tl.getName()); 
    128             } 
    129             log.info("Completed seeding layer " + tl.getName()); 
    130             int[][] list = SeedResource.getStatusList(); 
    131             synchronized(list) {                 
     127                double percCompl = (100.0 * count)/ (double) (tilesPerThread * tilesPerMetaTile); 
     128                int intPercCompl = (int) Math.floor(percCompl); 
     129                int decPercCompl = (int) Math.round((percCompl - intPercCompl) * 100); 
     130                 
     131                log.info("Thread "+threadOffset+" completed seeding level " + level + " for layer " 
     132                        + tl.getName() +" (ca. "+intPercCompl+"."+decPercCompl+"%)"); 
     133            } 
     134            log.info("Thread "+threadOffset+" completed seeding layer " + tl.getName()); 
     135             
     136            //int[][] list = SeedResource.getStatusList(); 
     137            //synchronized(list) {                 
    132138                    list[arrayIndex] = new int[3]; 
    133             } 
     139            //} 
    134140        //} catch (Exception e) { 
    135141        //    log.error(e.getMessage()); 
     
    167173        int indexOfnumber = tn.indexOf('d')+2; 
    168174        String tmp = tn.substring(indexOfnumber); 
    169         int arrayIndex = Integer.parseInt(tmp);         
    170         arrayIndex--; 
    171          
    172         return arrayIndex; 
     175        return Integer.parseInt(tmp) - 1; 
    173176    } 
    174177     
     
    188191        //working on tile 
    189192        temp[0] = tilesCount; 
     193         
    190194        //out of 
    191195        temp[1] = tilesTotal; 
    192196         
    193197        //estimated time of completion in seconds, use a moving average over the last  
    194         long timeSpent = (System.currentTimeMillis() - start_time) / 1000; 
    195          
    196         long timeTotal = Math.round(timeSpent * ((double) tilesTotal / (double) tilesCount)); 
    197          
    198         int timeRemaining = (int) (timeTotal - timeSpent); 
    199          
    200         temp[2] = timeRemaining; 
     198        long timeSpent = (System.currentTimeMillis() - start_time); 
     199         
     200        long timeTotal = Math.round((double) timeSpent * ((double) tilesTotal / (double) tilesCount)); 
     201         
     202        temp[2] = (int) (timeTotal - timeSpent) / 1000; 
    201203         
    202204        return temp;