Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.Quota


            }
        }

        private void addToUsedQuota(final Transaction tx, final TileSet tileSet,
                final Quota quotaDiff) {
            Quota usedQuota = usedQuotaByTileSetId.get(tx, tileSet.getId(), LockMode.DEFAULT);
            Quota globalQuota = usedQuotaByTileSetId.get(tx, GLOBAL_QUOTA_NAME, LockMode.DEFAULT);

            usedQuota.add(quotaDiff);
            globalQuota.add(quotaDiff);

            usedQuotaById.putNoReturn(tx, usedQuota);
            usedQuotaById.putNoReturn(tx, globalQuota);
        }
View Full Code Here


        cacheInfoBuilder = new LayerCacheInfoBuilder(cacheRoot, cleanUpExecutorService,
                quotaUsageMonitor);

        for (String layerName : tileLayerDispatcher.getLayerNames()) {

            Quota usedQuota = quotaStore.getUsedQuotaByLayerName(layerName);
            if (usedQuota.getBytes().compareTo(BigInteger.ZERO) > 0) {
                log.debug("Using saved quota information for layer " + layerName + ": "
                        + usedQuota.toNiceString());
            } else {
                log.debug(layerName + " has no saved used quota information,"
                        + "traversing layer cache to compute its disk usage.");
                TileLayer tileLayer;
                try {
View Full Code Here

    private void attachConfiguredLayers() throws ConfigurationException {

        final List<LayerQuota> layerQuotas = quotaConfig.getLayerQuotas();

        final ExpirationPolicy globalExpirationPolicy = quotaConfig.getGlobalExpirationPolicyName();
        final Quota globalQuota = quotaConfig.getGlobalQuota();

        int explicitConfigs = 0;

        if (layerQuotas != null) {
            for (LayerQuota layerQuota : layerQuotas) {
                final String layerName = layerQuota.getLayer();
                final ExpirationPolicy policyName = layerQuota.getExpirationPolicyName();
                if (policyName != null) {
                    final Quota quota = layerQuota.getQuota();
                    explicitConfigs++;
                    log.trace("Attaching layer " + layerName + " to quota " + quota
                            + " with expiration policy " + policyName);
                }
            }
View Full Code Here

                continue;
            }

            final LayerQuota definedQuotaForLayer = quotaConfig.layerQuota(layerName);
            final ExpirationPolicy policy = definedQuotaForLayer.getExpirationPolicyName();
            final Quota quota = definedQuotaForLayer.getQuota();
            final Quota usedQuota = monitor.getUsedQuotaByLayerName(layerName);

            Quota excedent = usedQuota.difference(quota);
            if (excedent.getBytes().compareTo(BigInteger.ZERO) > 0) {
                if (log.isInfoEnabled()) {
                    log.info("Layer '" + layerName + "' exceeds its quota of "
                            + quota.toNiceString() + " by " + excedent.toNiceString()
                            + ". Currently used: " + usedQuota.toNiceString()
                            + ". Clean up task will be performed using expiration policy " + policy);
                }

                Set<String> layerNames = Collections.singleton(layerName);
                QuotaResolver quotaResolver;
                quotaResolver = monitor.newLayerQuotaResolver(layerName);

                LayerQuotaEnforcementTask task;
                task = new LayerQuotaEnforcementTask(layerNames, quotaResolver, monitor);
                Future<Object> future = this.cleanUpExecutorService.submit(task);
                perLayerRunningCleanUps.put(layerName, future);
            }
        }

        if (globallyManagedLayerNames.size() > 0) {
            ExpirationPolicy globalExpirationPolicy = quotaConfig.getGlobalExpirationPolicyName();
            if (globalExpirationPolicy == null) {
                return;
            }
            final Quota globalQuota = quotaConfig.getGlobalQuota();
            if (globalQuota == null) {
                log.info("There's not a global disk quota configured. The following layers "
                        + "will not be checked for excess of disk usage: "
                        + globallyManagedLayerNames);
                return;
            }

            if (globalCleanUpTask != null && !globalCleanUpTask.isDone()) {
                log.debug("Global cache quota enforcement task still running, avoiding issueing a new one...");
                return;
            }

            Quota globalUsedQuota = monitor.getGloballyUsedQuota();
            Quota excedent = globalUsedQuota.difference(globalQuota);

            if (excedent.getBytes().compareTo(BigInteger.ZERO) > 0) {

                log.debug("Submitting global cache quota enforcement task");
                LayerQuotaEnforcementTask task;
                QuotaResolver quotaResolver = monitor.newGlobalQuotaResolver();
                task = new LayerQuotaEnforcementTask(globallyManagedLayerNames, quotaResolver,
View Full Code Here

        return false;
    }

    private void commit(final TimedQuotaUpdate aggregatedUpadte) throws InterruptedException {
        final TileSet tileSet = aggregatedUpadte.getTileSet();
        final Quota quotaDiff = aggregatedUpadte.getAccummulatedQuotaDifference();

        Collection<PageStatsPayload> tileCountDiffs;
        tileCountDiffs = new ArrayList<PageStatsPayload>(
                aggregatedUpadte.getAccummulatedTilePageCounts());

        if (quotaDiff.getBytes().compareTo(BigInteger.ZERO) == 0 && tileCountDiffs.size() == 0) {
            return;
        }

        quotaStore.addToQuotaAndTileCounts(tileSet, quotaDiff, tileCountDiffs);
    }
View Full Code Here

            this.tpc = tpc;
            this.creationTime = System.currentTimeMillis();
            tilePages = new HashMap<String, PageStatsPayload>();
            pageIndexTarget = new int[3];
            pageIdTarget = new StringBuilder(128);
            accumQuotaDiff = new Quota();
        }
View Full Code Here

        public Quota mapRow(ResultSet rs, int rowNum) throws SQLException {
            BigDecimal bytes = rs.getBigDecimal(1);
            if (bytes == null) {
                bytes = BigDecimal.ZERO;
            }
            return new Quota(bytes.toBigInteger());
        }
View Full Code Here

                for (String layerName : layerNames) {
                    createLayerInternal(layerName);
                }

                // create the global quota if necessary
                Quota global = getUsedQuotaByTileSetIdInternal(GLOBAL_QUOTA_NAME);
                if (global == null) {
                    createLayerInternal(GLOBAL_QUOTA_NAME);
                }
            }
        });
View Full Code Here

        String sql = dialect.getUsedQuotaByTileSetId(schema, "key");
        return jt.queryForOptionalObject(sql, new ParameterizedRowMapper<Quota>() {

            public Quota mapRow(ResultSet rs, int rowNum) throws SQLException {
                BigDecimal bytes = rs.getBigDecimal(1);
                Quota quota = new Quota(bytes.toBigInteger());
                quota.setTileSetId(tileSetId);
                return quota;
            }
        }, Collections.singletonMap("key", tileSetId));
    }
View Full Code Here

        tt.execute(new TransactionCallbackWithoutResult() {

            @Override
            protected void doInTransactionWithoutResult(TransactionStatus status) {
                // first gather the disk quota used by the gridset, and update the global quota
                Quota quota = getUsedQuotaByGridsetid(gridSetId);
                quota.setBytes(quota.getBytes().negate());
                String updateQuota = dialect.getUpdateQuotaStatement(schema, "tileSetId", "bytes");
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("tileSetId", GLOBAL_QUOTA_NAME);
                params.put("bytes", new BigDecimal(quota.getBytes()));
                jt.update(updateQuota, params);
               
                // then delete all the gridsets with the specified id
                String statement = dialect.getLayerGridDeletionStatement(schema, "layerName",
                        "gridSetId");
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.