Package org.geowebcache.diskquota.storage

Examples of org.geowebcache.diskquota.storage.Quota


        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

                        + "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

        CheckBox wmsIntegration = checkbox("enableWMSIntegration", wmsIntegrationEnabledModel,
                "GWCSettingsPage.enableWMSIntegration.title");
        form.add(wmsIntegration);

        final DiskQuotaConfig diskQuotaConfig = diskQuotaModel.getObject();
        Quota globalQuota = diskQuotaConfig.getGlobalQuota();
        if (globalQuota == null) {
            LOGGER.info("There's no GWC global disk quota configured, setting a default of 100MiB");
            globalQuota = new Quota(100, StorageUnit.MiB);
            diskQuotaConfig.setGlobalQuota(globalQuota);
        }

        // use this two payload models to let the user configure the global
        // quota as a decimal value
        // plus a storage unit. Then at form sumbission we'll transform them
        // back to a BigInteger
        // representing the quota byte count
        BigInteger bytes = globalQuota.getBytes();
        StorageUnit bestRepresentedUnit = StorageUnit.bestFit(bytes);
        BigDecimal transformedQuota = StorageUnit.B.convertTo(new BigDecimal(bytes),
                bestRepresentedUnit);
        final IModel<Double> configQuotaValueModel = new Model<Double>(
                transformedQuota.doubleValue());
View Full Code Here

            @Override
            protected Quota load() {
                GWC gwc = getGWC();
                if(null == gwc.getDisQuotaConfig()){
                    return new Quota();
                }
                return gwc.getGlobalQuota();
            }
        };
        final IModel<Quota> globalUsedQuotaModel = new LoadableDetachableModel<Quota>() {
            private static final long serialVersionUID = 1L;

            @Override
            protected Quota load() {
                GWC gwc = getGWC();
                if(null == gwc.getDisQuotaConfig()){
                    return new Quota();
                }
                return getGWC().getGlobalUsedQuota();
            }
        };
View Full Code Here

    }

    private void addGlobalQuotaStatusBar(final IModel<Quota> globalQuotaModel,
            final IModel<Quota> globalUsedQuotaModel, IModel<String> progressMessageModel) {

        Quota limit = globalQuotaModel.getObject();
        Quota used = globalUsedQuotaModel.getObject();

        BigInteger limitValue = limit.getBytes();
        BigInteger usedValue = used.getBytes();

        StorageUnit bestUnitForLimit = StorageUnit.bestFit(limitValue);
        StorageUnit bestUnitForUsed = StorageUnit.bestFit(usedValue);

        StorageUnit biggerUnit = bestUnitForLimit.compareTo(bestUnitForUsed) > 0 ? bestUnitForLimit
View Full Code Here

        checkNotNull(gridSetName, "GridSet name is null");
        if (!isDiskQuotaAvailable()) {
            return null;
        }

        final Quota quota = new Quota();

        TileSetVisitor visitor = new TileSetVisitor() {
            @Override
            public void visit(final TileSet tileSet, final QuotaStore store) {
                if (!gridSetName.equals(tileSet.getGridsetId())) {
                    return;
                }

                final String tileSetId = tileSet.getId();
                try {
                    Quota used = store.getUsedQuotaByTileSetId(tileSetId);
                    quota.add(used);
                } catch (InterruptedException e) {
                    log.fine(e.getMessage());
                    return;
                }
View Full Code Here

        if (layerQuotas == null) {
            return null;
        }
        for (LayerQuota lq : layerQuotas) {
            if (layerName.equals(lq.getLayer())) {
                return new Quota(lq.getQuota());
            }
        }
        return null;
    }
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.