Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.Quota


     */
    public void setGlobalQuota(final Quota newQuota) {
        if (newQuota == null) {
            this.globalQuota = null;
        } else {
            this.globalQuota = new Quota(newQuota);
        }
    }
View Full Code Here


            clone = (DiskQuotaConfig) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
        clone.lastCleanUpTime = lastCleanUpTime;
        clone.globalQuota = globalQuota == null ? null : new Quota(globalQuota);
        clone.layerQuotas = layerQuotas == null ? null : new ArrayList<LayerQuota>(layerQuotas);
        return clone;
    }
View Full Code Here

            config.addLayerQuota(new LayerQuota("layer", ExpirationPolicy.LRU));
            fail("Expected IAE");
        } catch (IllegalArgumentException e) {
            assertTrue(true);
        }
        LayerQuota lq = new LayerQuota("layer", ExpirationPolicy.LFU, new Quota());
        config.addLayerQuota(lq);
        assertNotNull(config.layerQuota("layer"));
    }
View Full Code Here

        config.addLayerQuota(lq);
        assertNotNull(config.layerQuota("layer"));
    }

    public void testRemove() {
        LayerQuota lq = new LayerQuota("layer", ExpirationPolicy.LFU, new Quota());
        config.addLayerQuota(lq);
        config.remove(lq);
        assertNull(config.layerQuota("layer"));
    }
View Full Code Here

    }

    public void testSaveConfig() throws ConfigurationException, IOException {
        DiskQuotaConfig config = new DiskQuotaConfig();
        List<LayerQuota> quotas = new ArrayList<LayerQuota>();
        LayerQuota lq = new LayerQuota("topp:states", LRU, new Quota(10, StorageUnit.MiB));
        quotas.add(lq);
        config.addLayerQuota(lq);

        File configFile = new File(cacheDir, "geowebcache-diskquota.xml");
        if (configFile.exists()) {
View Full Code Here

        TileSet stored;
        if (null == (stored = tileSetById.get(transaction, id, LockMode.DEFAULT))) {
            log.debug("Creating TileSet for quota tracking: " + tset);
            tileSetById.putNoReturn(transaction, tset);
            stored = tset;
            Quota tileSetUsedQuota = new Quota();
            tileSetUsedQuota.setTileSetId(tset.getId());
            usedQuotaById.putNoReturn(transaction, tileSetUsedQuota);
        }
        return stored;
    }
View Full Code Here

    /**
     * @see org.geowebcache.diskquota.QuotaStore#getUsedQuotaByTileSetId(java.lang.String)
     */
    public Quota getUsedQuotaByTileSetId(final String tileSetId) throws InterruptedException {
        Quota usedQuota = issueSync(new UsedQuotaByTileSetId(tileSetId));
        return usedQuota;
    }
View Full Code Here

        int numHits = 100;
        payload.setLastAccessTime(sysUtils.currentTimeMillis() - 1 * 60 * 1000);
        payload.setNumHits(numHits);
        payload.setNumTiles(1);

        store.addToQuotaAndTileCounts(tileSet, new Quota(1, StorageUnit.MiB),
                Collections.singleton(payload));

        Future<List<PageStats>> result = store.addHitsAndSetAccesTime(Collections
                .singleton(payload));
        List<PageStats> allStats = result.get();
View Full Code Here

        float expected = 55.0f;// the 100 previous + the 10 added now / the 2 minutes that elapsed
        assertEquals(expected, frequencyOfUsePerMinute, 1e-6f);
    }

    public void testGetGloballyUsedQuota() throws InterruptedException {
        Quota usedQuota = store.getGloballyUsedQuota();
        assertNotNull(usedQuota);
        assertEquals(0, usedQuota.getBytes().intValue());

        String layerName = tilePageCalculator.getLayerNames().iterator().next();
        TileSet tileSet = tilePageCalculator.getTileSetsFor(layerName).iterator().next();

        final String tileSetId = tileSet.getId();

        Quota quotaDiff = new Quota(BigInteger.valueOf(1000));
        Collection<PageStatsPayload> tileCountDiffs = Collections.emptySet();
        store.addToQuotaAndTileCounts(tileSet, quotaDiff, tileCountDiffs);

        usedQuota = store.getGloballyUsedQuota();
        assertNotNull(usedQuota);
        assertEquals(1000, usedQuota.getBytes().intValue());

        quotaDiff = new Quota(BigInteger.valueOf(-500));
        store.addToQuotaAndTileCounts(tileSet, quotaDiff, tileCountDiffs);

        usedQuota = store.getGloballyUsedQuota();
        assertNotNull(usedQuota);
        assertEquals(500, usedQuota.getBytes().intValue());
View Full Code Here

    }

    public void testDeleteLayer() throws InterruptedException {
        String layerName = tilePageCalculator.getLayerNames().iterator().next();
        // make sure the layer is there and has stuff
        Quota usedQuota = store.getUsedQuotaByLayerName(layerName);
        assertNotNull(usedQuota);

        TileSet tileSet = tilePageCalculator.getTileSetsFor(layerName).iterator().next();
        TilePage page = new TilePage(tileSet.getId(), 0, 0, (byte) 0);
        store.addHitsAndSetAccesTime(Collections.singleton(new PageStatsPayload(page)));
        // page.setNumHits(10);
        // page.setLastAccessTime(System.currentTimeMillis());
        // store.addHitsAndSetAccesTime(page);

        assertNotNull(store.getTileSetById(tileSet.getId()));

        store.deleteLayer(layerName);

        // cascade deleted?
        assertNull(store.getLeastRecentlyUsedPage(Collections.singleton(layerName)));
        usedQuota = store.getUsedQuotaByLayerName(layerName);
        assertNotNull(usedQuota);
        assertEquals(0L, usedQuota.getBytes().longValue());
    }
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.