Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.Quota


    public void testTableSetup() throws Exception {
        // on initialization we should have the tilesets setup properly

        // check the global quota
        Quota global = store.getGloballyUsedQuota();
        assertNotNull(global);
        assertEquals(JDBCQuotaStore.GLOBAL_QUOTA_NAME, global.getTileSetId());
        assertEquals(0, global.getBytes().longValue());

        Set<TileSet> tileSets = store.getTileSets();
        // two formats for topp:states2, four formats and two tilesets for topp:states
        assertNotNull(tileSets);
        assertEquals(10, tileSets.size());
View Full Code Here


    public void testRenameLayer2() throws InterruptedException {
        final String oldLayerName = tilePageCalculator.getLayerNames().iterator().next();
        final String newLayerName = "renamed_layer";

        // make sure the layer is there and has stuff
        Quota usedQuota = store.getUsedQuotaByLayerName(oldLayerName);
        assertNotNull(usedQuota);

        TileSet tileSet = tilePageCalculator.getTileSetsFor(oldLayerName).iterator().next();
        TilePage page = new TilePage(tileSet.getId(), 0, 0, (byte) 0);
        store.addHitsAndSetAccesTime(Collections.singleton(new PageStatsPayload(page)));
        store.addToQuotaAndTileCounts(tileSet, new Quota(BigInteger.valueOf(1024)),
                Collections.EMPTY_LIST);

        Quota expectedQuota = store.getUsedQuotaByLayerName(oldLayerName);
        assertEquals(1024L, expectedQuota.getBytes().longValue());

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

        store.renameLayer(oldLayerName, newLayerName);

        // cascade deleted old layer?
        assertNull(store.getLeastRecentlyUsedPage(Collections.singleton(oldLayerName)));
        usedQuota = store.getUsedQuotaByLayerName(oldLayerName);
        assertNotNull(usedQuota);
        assertEquals(0L, usedQuota.getBytes().longValue());

        // created new layer?
        Quota newLayerUsedQuota = store.getUsedQuotaByLayerName(newLayerName);
        assertEquals(expectedQuota.getBytes(), newLayerUsedQuota.getBytes());
    }
View Full Code Here

        String layerName = "topp:states";
        TileSet tset1 = new TileSet(layerName, "EPSG:4326", "image/jpeg", null);
        addToQuotaStore(tset1);
        TileSet tset2 = new TileSet(layerName, "EPSG:900913", "image/jpeg", null);
        addToQuotaStore(tset2);
        Quota tset1Quota = store.getUsedQuotaByTileSetId(tset1.getId());
        Quota tset2Quota = store.getUsedQuotaByTileSetId(tset2.getId());
        Quota globalQuota = store.getGloballyUsedQuota();
        Quota sum = new Quota();
        sum.add(tset1Quota);
        sum.add(tset2Quota);
        assertEquals(globalQuota.getBytes(), sum.getBytes());
       
        assertEquals(8, countTileSetsByLayerName("topp:states"));
        store.deleteGridSubset("topp:states", "EPSG:900913");
        assertEquals(4, countTileSetsByLayerName("topp:states"));
View Full Code Here

        assertNull(tset2Quota);
        assertEquals(tset1Quota.getBytes(), globalQuota.getBytes());
    }

    private void addToQuotaStore(TileSet tset) throws InterruptedException {
        Quota quotaDiff = new Quota(5, StorageUnit.MiB);
        PageStatsPayload stats = new PageStatsPayload(new TilePage(tset.getId(), 0, 0, 3));
        stats.setNumTiles(10);
        store.addToQuotaAndTileCounts(tset, quotaDiff, Collections.singletonList(stats));
    }
View Full Code Here

        TileSet tset = new TileSet(layerName, "EPSG:2163", "image/jpeg", null);

        addToQuotaStore(tset);

        // make sure the layer is there and has stuff
        Quota oldUsedQuota = store.getUsedQuotaByLayerName(layerName);
        assertNotNull(oldUsedQuota);
        Quota globalQuotaBefore = store.getGloballyUsedQuota();
        assertTrue(oldUsedQuota.getBytes().longValue() > 0);
        assertTrue(globalQuotaBefore.getBytes().longValue() > 0);

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

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

        store.deleteLayer(layerName);

        // cascade deleted?
        assertNull(store.getLeastRecentlyUsedPage(Collections.singleton(layerName)));
        Quota usedQuota = store.getUsedQuotaByLayerName(layerName);
        assertNotNull(usedQuota);
        assertEquals(0L, usedQuota.getBytes().longValue());
       
        // make sure the global quota got updated
        Quota globalQuotaAfter = store.getGloballyUsedQuota();
        assertEquals(0, globalQuotaAfter.getBytes().longValue());
    }
View Full Code Here

    public void testGetUsedQuotaByLayerName() throws Exception {
        String layerName = "topp:states2";
        List<TileSet> tileSets;
        tileSets = new ArrayList<TileSet>(tilePageCalculator.getTileSetsFor(layerName));

        Quota expected = new Quota();
        for (TileSet tset : tileSets) {
            Quota quotaDiff = new Quota(10, StorageUnit.MiB);
            expected.add(quotaDiff);
            store.addToQuotaAndTileCounts(tset, quotaDiff, Collections.EMPTY_SET);
        }

        Quota usedQuotaByLayerName = store.getUsedQuotaByLayerName(layerName);
        assertEquals(expected.getBytes(), usedQuotaByLayerName.getBytes());
    }
View Full Code Here

        tileSets = new ArrayList<TileSet>(tilePageCalculator.getTileSetsFor(layerName));

        Map<String, Quota> expectedById = new HashMap<String, Quota>();

        for (TileSet tset : tileSets) {
            Quota quotaDiff = new Quota(10D * Math.random(), StorageUnit.MiB);
            store.addToQuotaAndTileCounts(tset, quotaDiff, Collections.EMPTY_SET);
            store.addToQuotaAndTileCounts(tset, quotaDiff, Collections.EMPTY_SET);
            Quota tsetQuota = new Quota(quotaDiff);
            tsetQuota.add(quotaDiff);
            expectedById.put(tset.getId(), tsetQuota);
        }

        for (Map.Entry<String, Quota> expected : expectedById.entrySet()) {
            BigInteger expectedValaue = expected.getValue().getBytes();
View Full Code Here

    public void testUpdateUsedQuotaWithParameters() throws Exception {
        // prepare a tileset with params
        String paramId = DigestUtils.shaHex("&styles=polygon");
        TileSet tset = new TileSet("topp:states2", "EPSG:2163", "image/jpeg", paramId);

        Quota quotaDiff = new Quota(10D * Math.random(), StorageUnit.MiB);
        PageStatsPayload stats = new PageStatsPayload(new TilePage(tset.getId(), 0, 0, 3));
        stats.setNumTiles(10);
        store.addToQuotaAndTileCounts(tset, quotaDiff, Collections.singletonList(stats));

        assertEquals(quotaDiff.getBytes(), store.getUsedQuotaByTileSetId(tset.getId()).getBytes());
    }
View Full Code Here

        payload.setTileSet(tileSet);
        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();

        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

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.