GeoWebCache

Changeset 948

Show
Ignore:
Timestamp:
02/20/10 17:19:34 (7 months ago)
Author:
arneke
Message:

Seeding changes in GeoRSS , terminate old jobs before starting new ones

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/documentation/en/user/source/configuration/xml/exhaustive.rst

    r944 r948  
    196196             <format>image/png</format> 
    197197             <!-- OPTIONAL If the operation is not truncate, specify how many threads 
    198                   should run in parallel? Note that each format is done sequencially. --> 
     198                  should run in parallel? Note that multiple formats are done in parallel, 
     199                  so if you say 2 threads and the layer has 3 formats (and the geoRSsFeed  
     200                  does not specify a format), then the total number of threads will be  
     201                  3x2 = 6 --> 
    199202             <seedingThreads>2</seedingThreads> 
    200203             <!-- OPTIONAL GWC will render the geometries onto a bitmask and use that 
  • trunk/geowebcache/src/main/java/org/geowebcache/georss/GeoRSSPollTask.java

    r940 r948  
    3939import org.geowebcache.mime.MimeType; 
    4040import org.geowebcache.rest.GWCTask; 
     41import org.geowebcache.rest.GWCTask.STATE; 
    4142import org.geowebcache.rest.seed.RasterMask; 
    4243import org.geowebcache.rest.seed.SeedRestlet; 
     
    7475 
    7576    private final SeedRestlet seedRestlet; 
     77     
     78    private LinkedList<GWCTask> seedTasks; 
    7679 
    7780    /** 
     
    246249         
    247250        Iterator<MimeType> mimeIter = mimeList.iterator(); 
    248  
    249         // We do the truncate synchronously to get rid of stale data as quick as we can 
     251         
     252        // Ask any existing seed jobs started by this feed to terminate 
     253        stopSeeding(true); 
     254 
     255        // We do the truncate synchronously to get rid of stale data as quickly as we can 
    250256        while(mimeIter.hasNext()) { 
    251257            DiscontinuousTileRange dtr = new DiscontinuousTileRange(layer.getName(), gridSetId,  
     
    272278             
    273279            final int seedingThreads = pollDef.getSeedingThreads(); 
    274             GWCTask[] seedTasks; 
    275             seedTasks = seedRestlet.createTasks(dtr, layer, GWCTask.TYPE.SEED, seedingThreads, false); 
    276             seedRestlet.dispatchTasks(seedTasks); 
     280            GWCTask[] tasks = seedRestlet.createTasks(dtr, layer, GWCTask.TYPE.SEED, seedingThreads, false); 
     281            seedRestlet.dispatchTasks(tasks); 
     282             
     283            // Save the handles so we can stop them 
     284            for (GWCTask task : tasks) { 
     285                seedTasks.add(task); 
     286            } 
     287 
     288        } 
     289    } 
     290     
     291    protected void stopSeeding(boolean checkLiveCount) { 
     292        if(this.seedTasks != null) { 
     293            int liveCount = 0; 
     294            for (GWCTask task : seedTasks) { 
     295                if(task.getState() != STATE.DEAD || task.getState() != STATE.DONE) { 
     296                    task.terminateNicely(); 
     297                    liveCount++; 
     298                } 
     299            } 
     300             
     301            try { 
     302                logger.debug("Found " + liveCount + " running seed threads. Waiting 3s for them to terminate."); 
     303                Thread.sleep(3000); 
     304            } catch (InterruptedException e) { 
     305                e.printStackTrace(); 
     306            } 
     307             
     308            if(! checkLiveCount) { 
     309                return; 
     310            } 
     311             
     312            liveCount = 0; 
     313            Iterator<GWCTask> iter = seedTasks.iterator(); 
     314            while(iter.hasNext()) { 
     315                GWCTask task = iter.next(); 
     316                if(task.getState() != STATE.DEAD || task.getState() != STATE.DONE) { 
     317                    liveCount++;   
     318                } else { 
     319                    iter.remove(); 
     320                } 
     321            } 
     322            logger.debug(liveCount + " seed jobs are still waiting to terminate, proceeding anyway."); 
     323             
     324        } else { 
     325            logger.debug("Found no running seed jobs"); 
    277326        } 
    278327    } 
  • trunk/geowebcache/src/main/java/org/geowebcache/rest/GWCTask.java

    r908 r948  
    113113        return type; 
    114114    } 
     115     
     116    public STATE getState() { 
     117        return state; 
     118    } 
    115119} 
  • trunk/geowebcache/src/main/resources/org/geowebcache/config/geowebcache.xsd

    r942 r948  
    955955    <xs:element name="seedingThreads" type="xs:integer" minOccurs="0"> 
    956956      <xs:annotation><xs:documentation xml:lang="en"> 
    957         This controls the number of threads to use while seeding, provided the 
    958         operation is reseed. Note that the truncate is synchronous and single threaded. 
     957        This controls the number of threads to use per format while seeding,  
     958        provided the operation is seed or reseed. (Truncate is synchronous  
     959        and single threaded.) So if you write 2 threads here, and the layer  
     960        supports 3 formats, and no format is specified above, then the total 
     961        number of threads will be 3x2 = 6 
    959962      </xs:documentation></xs:annotation> 
    960963    </xs:element>