本文整理了Java中org.geowebcache.diskquota.storage.Quota.getBytes
方法的一些代码示例,展示了Quota.getBytes
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quota.getBytes
方法的具体详情如下:
包路径:org.geowebcache.diskquota.storage.Quota
类名称:Quota
方法名:getBytes
暂无
代码示例来源:origin: GeoWebCache/geowebcache
public Quota(Quota quota) {
id = quota.id;
tileSetId = quota.tileSetId;
bytes = quota.getBytes();
}
代码示例来源:origin: GeoWebCache/geowebcache
/** Shorthand for {@link #add(BigInteger) add(quota.getBytes())} */
public void add(final Quota quota) {
this.bytes = this.bytes.add(quota.getBytes());
}
代码示例来源:origin: GeoWebCache/geowebcache
/** @see java.lang.Comparable#compareTo(java.lang.Object) */
public int compareTo(Quota o) {
if (o == null) {
throw new NullPointerException("Can't compare against null");
}
return bytes.compareTo(o.getBytes());
}
代码示例来源:origin: GeoWebCache/geowebcache
/**
* Returns the difference between this quota and the argument one, in this quota's units
*
* @param quota
* @return
*/
public Quota difference(Quota quota) {
BigInteger difference = this.bytes.subtract(quota.getBytes());
return new Quota(difference);
}
代码示例来源:origin: GeoWebCache/geowebcache
/**
* @param quota quota to be compared against this one
* @return {@code this} or {@code quota}, the one that represents a lower amount
*/
public Quota min(Quota quota) {
BigInteger min = this.bytes.min(quota.getBytes());
return this.bytes.equals(min) ? this : quota;
}
代码示例来源:origin: GeoWebCache/geowebcache
private void validateQuota(Quota quota) throws ConfigurationException {
if (quota == null) {
throw new IllegalArgumentException("No quota defined");
}
BigInteger limit = quota.getBytes();
if (limit.compareTo(BigInteger.ZERO) < 0) {
throw new ConfigurationException("Limit shall be >= 0: " + limit + ". " + quota);
}
log.debug("Quota validated: " + quota);
}
代码示例来源:origin: GeoWebCache/geowebcache
/** Shorthand for {@link #subtract(BigInteger) subtract(quota.getBytes())} */
public void subtract(final Quota quota) {
subtract(quota.getBytes());
}
代码示例来源:origin: GeoWebCache/geowebcache
private void updateQuotas(final TileSet tileSet, final Quota quotaDiff) {
if (log.isDebugEnabled()) {
log.info(
"Applying quota diff "
+ quotaDiff.getBytes()
+ " on tileset "
+ tileSet);
}
String updateQuota =
dialect.getUpdateQuotaStatement(schema, "tileSetId", "bytes");
Map<String, Object> params = new HashMap<String, Object>();
params.put("tileSetId", tileSet.getId());
params.put("bytes", new BigDecimal(quotaDiff.getBytes()));
jt.update(updateQuota, params);
params.put("tileSetId", GLOBAL_QUOTA_NAME);
jt.update(updateQuota, params);
}
代码示例来源:origin: GeoWebCache/geowebcache
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);
}
代码示例来源:origin: GeoWebCache/geowebcache
@Override
protected void doInTransactionWithoutResult(TransactionStatus arg0) {
// update the global quota
Quota quota = getUsedQuotaByLayerName(layerName);
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);
// delete the layer
log.info("Deleting disk quota information for layer '" + layerName + "'");
String statement = dialect.getLayerDeletionStatement(schema, "layerName");
jt.update(statement, Collections.singletonMap("layerName", layerName));
}
});
代码示例来源:origin: GeoWebCache/geowebcache
@Override
protected void doInTransactionWithoutResult(TransactionStatus status) {
// get the disk quota used by the layer gridset
Quota quota = getUsedQuotaByLayerGridset(layerName, gridSetId);
// we will subtracting the current disk quota value
quota.setBytes(quota.getBytes().negate());
// update the global disk quota by subtracting the value above
String updateQuota =
dialect.getUpdateQuotaStatement(schema, "tileSetId", "bytes");
Map<String, Object> params = new HashMap<>();
params.put("tileSetId", GLOBAL_QUOTA_NAME);
params.put("bytes", new BigDecimal(quota.getBytes()));
jt.update(updateQuota, params);
// delete layer gridset
String statement =
dialect.getLayerGridDeletionStatement(
schema, "layerName", "gridSetId");
params = new HashMap<String, Object>();
params.put("layerName", layerName);
params.put("gridSetId", gridSetId);
jt.update(statement, params);
}
});
代码示例来源:origin: GeoWebCache/geowebcache
/**
* Asserts the quota used by this tile set is null
*
* @param layerName
* @throws InterruptedException
*/
private void assertQuotaZero(String layerName) throws InterruptedException {
Quota quota = store.getUsedQuotaByLayerName(layerName);
assertNotNull(quota);
assertEquals(0, quota.getBytes().longValue());
}
}
代码示例来源:origin: GeoWebCache/geowebcache
/**
* 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());
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
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());
}
代码示例来源:origin: GeoWebCache/geowebcache
/**
* @see com.thoughtworks.xstream.converters.Converter#marshal(java.lang.Object,
* 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());
writer.endNode();
writer.startNode("units");
writer.setValue(unit.toString());
writer.endNode();
}
}
代码示例来源:origin: GeoWebCache/geowebcache
@SuppressWarnings("unchecked")
@Test
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());
}
代码示例来源:origin: GeoWebCache/geowebcache
@SuppressWarnings("unchecked")
@Test
public void testGetUsedQuotaByTileSetId() throws Exception {
String layerName = "topp:states2";
List<TileSet> tileSets;
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 expectedValue = expected.getValue().getBytes();
String tsetId = expected.getKey();
assertThat(store.getUsedQuotaByTileSetId(tsetId), bytes(expectedValue));
}
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
public void testUpdateUsedQuotaWithParameters() throws Exception {
// prepare a tileset with params
String paramId = DigestUtils.sha1Hex("&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());
}
代码示例来源:origin: GeoWebCache/geowebcache
@Test
public void testGetGloballyUsedQuota() throws InterruptedException {
store.getGloballyUsedQuota().getBytes();
assertThat(store, hasProperty("globallyUsedQuota", quotaEmpty()));
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);
assertThat(store, hasProperty("globallyUsedQuota", bytes(1000)));
quotaDiff = new Quota(BigInteger.valueOf(-500));
store.addToQuotaAndTileCounts(tileSet, quotaDiff, tileCountDiffs);
assertThat(store, hasProperty("globallyUsedQuota", bytes(500)));
}
代码示例来源:origin: GeoWebCache/geowebcache
@SuppressWarnings("unchecked")
@Test
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);
}
assertThat(store.getUsedQuotaByLayerName(layerName), bytes(expected.getBytes()));
}
内容来源于网络,如有侵权,请联系作者删除!