Changeset 410
- Timestamp:
- 11/08/08 17:29:30 (2 months ago)
- Location:
- trunk/geowebcache/src/main/java/org/geowebcache/rest
- Files:
-
- 4 modified
-
GWCTask.java (modified) (1 diff)
-
RESTDispatcher.java (modified) (1 diff)
-
SeedResource.java (modified) (1 diff)
-
SeedTask.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/geowebcache/src/main/java/org/geowebcache/rest/GWCTask.java
r369 r410 19 19 import org.geowebcache.GeoWebCacheException; 20 20 21 /** 22 * 23 */ 21 24 public abstract class GWCTask { 22 25 -
trunk/geowebcache/src/main/java/org/geowebcache/rest/RESTDispatcher.java
r409 r410 52 52 private static final int THREAD_NUMBER = 4; 53 53 54 privatestatic final int THREAD_MAX_NUMBER = 32;54 static final int THREAD_MAX_NUMBER = 32; 55 55 56 56 private final XMLConfiguration xmlConfig; -
trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedResource.java
r389 r410 49 49 50 50 public 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]; 52 52 public JSONObject myrequest; 53 53 private static Log log = LogFactory.getLog(org.geowebcache.rest.SeedResource.class); -
trunk/geowebcache/src/main/java/org/geowebcache/rest/SeedTask.java
r393 r410 59 59 tl.isInitialized(); 60 60 61 log.info(" Beginseeding layer : " + tl.getName());61 log.info("Thread "+threadOffset+" begins seeding layer : " + tl.getName()); 62 62 int zoomStart = req.getZoomStart().intValue(); 63 63 int zoomStop = req.getZoomStop().intValue(); … … 83 83 84 84 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 86 89 int count = 0; 87 90 boolean tryCache = !reseed; … … 91 94 for (int gridy = gridBounds[1]; gridy <= gridBounds[3];) { 92 95 93 for (int gridx = gridBounds[0] ; gridx <= gridBounds[2];) {96 for (int gridx = gridBounds[0] + threadOffset; gridx <= gridBounds[2];) { 94 97 95 98 int[] gridLoc = { gridx, gridy, level }; … … 106 109 107 110 // Next column 108 gridx += metaTilingFactors[0] * (1 + threadOffset);111 gridx += metaTilingFactors[0]; 109 112 110 113 count += tilesPerMetaTile; 111 112 int[][] list = SeedResource.getStatusList();113 114 114 115 // Threads don't really collide 115 116 //synchronized(list) { 116 117 // 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); 118 119 //} 119 120 } … … 124 125 } 125 126 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) { 132 138 list[arrayIndex] = new int[3]; 133 }139 //} 134 140 //} catch (Exception e) { 135 141 // log.error(e.getMessage()); … … 167 173 int indexOfnumber = tn.indexOf('d')+2; 168 174 String tmp = tn.substring(indexOfnumber); 169 int arrayIndex = Integer.parseInt(tmp); 170 arrayIndex--; 171 172 return arrayIndex; 175 return Integer.parseInt(tmp) - 1; 173 176 } 174 177 … … 188 191 //working on tile 189 192 temp[0] = tilesCount; 193 190 194 //out of 191 195 temp[1] = tilesTotal; 192 196 193 197 //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; 201 203 202 204 return temp;
