Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.Quota


        payload.setTileSet(testTileSet);
        int numHits = 100;
        payload.setNumHits(numHits);
        payload.setNumTiles(5);

        store.addToQuotaAndTileCounts(testTileSet, new Quota(1, StorageUnit.MiB),
                Collections.singleton(payload));
        List<PageStats> stats = store.addHitsAndSetAccesTime(Collections.singleton(payload)).get();
        assertTrue(stats.get(0).getFillFactor() > 0f);
        PageStats pageStats = store.setTruncated(page);
        assertEquals(0f, pageStats.getFillFactor());
View Full Code Here


     * Asserts the quota used by this tile set is null
     *
     * @param tileSet
     */
    private void assertQuotaZero(TileSet tileSet) {
        Quota quota = store.getUsedQuotaByTileSetId(tileSet.getId());
        assertNotNull(quota);
        assertEquals(0, quota.getBytes().longValue());
    }
View Full Code Here

     *
     * @param tileSet
     * @throws InterruptedException
     */
    private void assertQuotaZero(String layerName) throws InterruptedException {
        Quota quota = store.getUsedQuotaByLayerName(layerName);
        assertNotNull(quota);
        assertEquals(0, quota.getBytes().longValue());
    }
View Full Code Here

                        + "Either both or neither should be present");
            }
            return;
        }

        Quota quota = lq.getQuota();
        try {
            validateQuota(quota);
        } catch (ConfigurationException e) {
            log.error("LayerQuota configuration error for layer " + layer + ". Error message is: "
                    + e.getMessage() + ". Quota removed from runtime configuration.");
View Full Code Here

         * @see com.thoughtworks.xstream.converters.Converter#unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader,
         *      com.thoughtworks.xstream.converters.UnmarshallingContext)
         */
        public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {

            Quota quota = new Quota();

            reader.moveDown();
            String nodeName = reader.getNodeName();
            Assert.isTrue("value".equals(nodeName));

            String nodevalue = reader.getValue();
            double value = Double.parseDouble(nodevalue);
            reader.moveUp();

            reader.moveDown();
            nodeName = reader.getNodeName();
            Assert.isTrue("units".equals(nodeName));

            nodevalue = reader.getValue();
            StorageUnit unit = StorageUnit.valueOf(nodevalue);
            reader.moveUp();

            quota.setValue(value, unit);
            return quota;
        }
View Full Code Here

         *      com.thoughtworks.xstream.io.HierarchicalStreamWriter,
         *      com.thoughtworks.xstream.converters.MarshallingContext)
         */
        public void marshal(Object source, HierarchicalStreamWriter writer,
                MarshallingContext context) {
            Quota quota = (Quota) source;
            BigInteger bytes = quota.getBytes();
            StorageUnit unit = StorageUnit.bestFit(bytes);
            BigDecimal value = unit.fromBytes(bytes);

            writer.startNode("value");
            writer.setValue(value.toString());
View Full Code Here

     * @see {@link org.geowebcache.diskquota.ExpirationPolicy#expireByLayerNames}
     */
    public void expireByLayerNames(final Set<String> layerNames, final QuotaResolver quotaResolver, final QuotaStore pageStore)
            throws InterruptedException {

        Quota limit;
        Quota used;
        Quota excess;

        while (true) {
            if (shutDown || Thread.currentThread().isInterrupted()) {
                throw new InterruptedException();
            }
            // get it everytime in case the admin changed it while we're processsing
            limit = quotaResolver.getLimit();
            used = quotaResolver.getUsed();
            excess = used.difference(limit);
            if (excess.getBytes().compareTo(BigInteger.ZERO) <= 0) {
                log.info("Reached back Quota: " + limit.toNiceString() + " (" + used.toNiceString() + ") for layers "
                        + layerNames);
                return;
            }
            // same thing, check it every time
            ExpirationPolicy expirationPolicy = quotaResolver.getExpirationPolicy();
            if (null == expirationPolicy) {
                log.warn("Aborting disk quota enforcement task, no expiration policy defined for layers "
                        + layerNames);
                return;
            }

            TilePage tilePage = null;
            if (ExpirationPolicy.LFU.equals(expirationPolicy)) {
                tilePage = pageStore.getLeastFrequentlyUsedPage(layerNames);
            } else if (ExpirationPolicy.LRU.equals(expirationPolicy)) {
                tilePage = pageStore.getLeastRecentlyUsedPage(layerNames);
            } else {
                throw new IllegalStateException("Unrecognized expiration policy: "
                        + expirationPolicy);
            }

            if (tilePage == null) {
                limit = quotaResolver.getLimit();
                Quota usedQuota = quotaResolver.getUsed();
                if (excess.getBytes().compareTo(BigInteger.ZERO) > 0) {
                    log.warn("No more pages to expire, check if youd disk quota"
                            + " database is out of date with your blob store. Quota: "
                            + limit.toNiceString() + " used: " + usedQuota.toNiceString());
                }
                return;
            }
            if (log.isDebugEnabled()) {
                log.debug("Expiring tile page " + tilePage + " based on the global "
View Full Code Here

            this.layerQuota = layerQuota;
            this.store = store;
        }

        public Quota getLimit() {
            Quota limit = layerQuota.getQuota();
            if (limit == null) {
                // has the admin disabled specific quota for this layer?
                limit = new Quota(BigInteger.valueOf(Long.MAX_VALUE));
            }
            return limit;
        }
View Full Code Here

            return limit;
        }

        public Quota getUsed() throws InterruptedException {
            String layer = layerQuota.getLayer();
            Quota usedQuotaByLayerName = store.getUsedQuotaByLayerName(layer);
            return usedQuotaByLayerName;
        }
View Full Code Here

        }
        if (globalExpirationPolicyName == null) {
            globalExpirationPolicyName = DEFAULT_GLOBAL_POLICY_NAME;
        }
        if (globalQuota == null) {
            globalQuota = new Quota(500, StorageUnit.MiB);
        }
    }
View Full Code Here

TOP

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

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.