Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.TilePage


    protected List<PageStatsPayload> sortPayloads(Collection<PageStatsPayload> tileCountDiffs) {
        List<PageStatsPayload> result = new ArrayList<PageStatsPayload>(tileCountDiffs);
        Collections.sort(result, new Comparator<PageStatsPayload>() {

            public int compare(PageStatsPayload pl1, PageStatsPayload pl2) {
                TilePage p1 = pl1.getPage();
                TilePage p2 = pl2.getPage();
                return p1.getKey().compareTo(p2.getKey());
            }});
        return result;
    }
View Full Code Here


                        return result;
                    }

                    private PageStats upsertTilePageHitAccessTime(PageStatsPayload payload) {
                        TilePage page = payload.getPage();

                        if (log.isDebugEnabled()) {
                            log.info("Updating page " + page + " with payload " + payload);
                        }

                        int modified = 0;
                        int count = 0;
                        PageStats stats = null;
                        while (modified == 0 && count < maxLoops) {
                            try {
                                count++;
                                stats = getPageStats(page.getKey());
                                if (stats != null) {
                                    // gather the old values, we'll use them for the optimistic locking
                                    final BigInteger oldHits = stats.getNumHits();
                                    final float oldFrequency = stats.getFrequencyOfUsePerMinute();
                                    final int oldAccessTime = stats.getLastAccessTimeMinutes();
                                    // update the page so that it computes the new stats
                                    updatePageStats(payload, page, stats);
   
                                    // update the record in the db
                                    String update = dialect.updatePageStats(schema, "key", "newHits",
                                            "oldHits", "newFrequency", "oldFrequency", "newAccessTime",
                                            "oldAccessTime");
                                    Map<String, Object> params = new HashMap<String, Object>();
                                    params.put("key", page.getKey());
                                    params.put("newHits", new BigDecimal(stats.getNumHits()));
                                    params.put("oldHits", new BigDecimal(oldHits));
                                    params.put("newFrequency", stats.getFrequencyOfUsePerMinute());
                                    params.put("oldFrequency", oldFrequency);
                                    params.put("newAccessTime", stats.getLastAccessTimeMinutes());
                                    params.put("oldAccessTime", oldAccessTime);
                                    modified = jt.update(update, params);
                                } else {
                                    // create the new stats and insert it
                                    stats = new PageStats(0);
                                    updatePageStats(payload, page, stats);
                                    modified = createNewPageStats(stats, page);
                                }
                            } catch(DeadlockLoserDataAccessException e) {
                                if(log.isDebugEnabled()) {
                                    log.debug("Deadlock while updating page stats, will retry", e);
                                }
                            }
                        }

                        if (modified == 0) {
                            throw new ConcurrencyFailureException(
                                    "Failed to create or update page stats for page "
                                            + payload.getPage() + " after " + count + " attempts");
                        }

                        return stats;
                    }

                    private void updatePageStats(PageStatsPayload payload, TilePage page,
                            PageStats stats) {
                        final int addedHits = payload.getNumHits();
                        final int lastAccessTimeMinutes = (int) (payload.getLastAccessTime() / 1000 / 60);
                        final int creationTimeMinutes = page.getCreationTimeMinutes();
                        stats.addHitsAndAccessTime(addedHits, lastAccessTimeMinutes,
                                creationTimeMinutes);
                    }

                });
View Full Code Here

            int pageX = rs.getInt(2);
            int pageY = rs.getInt(3);
            int pageZ = rs.getInt(4);
            int creationTimeMinutes = rs.getInt(5);

            return new TilePage(tileSetId, pageX, pageY, pageZ, creationTimeMinutes);
        }
View Full Code Here

                // and loop over them.
                // Loop conditions: we find the page stats, but they are deleted before we can
                // update
                // them, we don't find the page stats, but they are inserted before we can do so, in
                // both cases we re-start from zero
                TilePage page = payload.getPage();
                final byte level = page.getZoomLevel();
                final BigInteger tilesPerPage = calculator.getTilesPerPage(tileSet, level);

                int modified = 0;
                int count = 0;
                while (modified == 0 && count < maxLoops) {
                    try {
                        count++;
                        PageStats stats = getPageStats(page.getKey());
                        if (stats != null) {
                            float oldFillFactor = stats.getFillFactor();
                            stats.addTiles(payload.getNumTiles(), tilesPerPage);
                            // if no change, bail out early
                            if (oldFillFactor == stats.getFillFactor()) {
View Full Code Here

TOP

Related Classes of org.geowebcache.diskquota.storage.TilePage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.