Examples of PageStats


Examples of org.geowebcache.diskquota.storage.PageStats

    private PageStats getPageStats(String pageStatsKey) {
        String getPageStats = dialect.getPageStats(schema, "key");
        return jt.queryForOptionalObject(getPageStats, new ParameterizedRowMapper<PageStats>() {

            public PageStats mapRow(ResultSet rs, int rowNum) throws SQLException {
                PageStats ps = new PageStats(0);
                // FREQUENCY_OF_USE, LAST_ACCESS_TIME, FILL_FACTOR, NUM_HITS FROM
                ps.setFrequencyOfUsePerMinute(rs.getFloat(1));
                ps.setLastAccessMinutes(rs.getInt(2));
                ps.setFillFactor(rs.getFloat(3));
                ps.setNumHits(rs.getBigDecimal(4).toBigInteger());

                return ps;
            }
        }, Collections.singletonMap("key", pageStatsKey));
    }
View Full Code Here

Examples of org.geowebcache.diskquota.storage.PageStats

                                } else {
                                    getOrCreateTileSet(tset);
                                }

                                // update the stats
                                PageStats stats = upsertTilePageHitAccessTime(payload);
                                result.add(stats);
                            }
                        }

                        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

Examples of org.geowebcache.diskquota.storage.PageStats

            public Object doInTransaction(TransactionStatus status) {
                if (log.isDebugEnabled()) {
                    log.info("Truncating page " + page);
                }

                PageStats stats = getPageStats(page.getKey());
                if (stats != null) {
                    stats.setFillFactor(0);

                    // update the record in the db
                    int modified = setPageFillFactor(page, stats);
                    // if no record updated the page has been deleted by another instance
                    if (modified == 0) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.