本文整理了Java中org.geowebcache.diskquota.storage.Quota
类的一些代码示例,展示了Quota
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quota
类的具体详情如下:
包路径:org.geowebcache.diskquota.storage.Quota
类名称:Quota
[英]A Mutable representation of the disk usage of a given cache tile set, given by a value and a StorageUnit.
Instances of this class are not thread safe.
[中]给定缓存磁贴集的磁盘使用情况的可变表示形式,由值和存储单元给出。
此类的实例不是线程安全的。
代码示例来源:origin: GeoWebCache/geowebcache
/** @param newQuota the new global quota, or {@code null} to unset */
public void setGlobalQuota(final Quota newQuota) {
if (newQuota == null) {
this.globalQuota = null;
} else {
this.globalQuota = new Quota(newQuota);
}
}
代码示例来源: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: org.geoserver/gs-gwc
@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;
}
}
};
代码示例来源:origin: GeoWebCache/geowebcache
/** Shorthand for {@link #subtract(BigInteger) subtract(quota.getBytes())} */
public void subtract(final Quota quota) {
subtract(quota.getBytes());
}
代码示例来源:origin: GeoWebCache/geowebcache
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;
}
},
代码示例来源: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
public Quota(Quota quota) {
id = quota.id;
tileSetId = quota.tileSetId;
bytes = quota.getBytes();
}
代码示例来源: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
public Quota call() throws Exception {
Quota aggregated = null;
EntityCursor<TileSet> layerTileSetsIds;
layerTileSetsIds =
tileSetsByLayer.entities(
null, layerName, true, layerName, true, CursorConfig.DEFAULT);
TileSet tileSet;
try {
Quota tileSetUsedQuota;
while (null != (tileSet = layerTileSetsIds.next())) {
if (aggregated == null) {
aggregated = new Quota();
}
tileSetUsedQuota = new UsedQuotaByTileSetId(tileSet.getId()).call();
aggregated.add(tileSetUsedQuota);
}
} finally {
layerTileSetsIds.close();
}
if (aggregated == null) {
aggregated = new Quota();
}
return aggregated;
}
}
代码示例来源:origin: GeoWebCache/geowebcache
excess = used.difference(limit);
if (excess.getBytes().compareTo(BigInteger.ZERO) <= 0) {
log.info(
"Reached back Quota: "
+ limit.toNiceString()
+ " ("
+ used.toNiceString()
+ ") for layers "
+ layerNames);
limit = quotaResolver.getLimit();
Quota usedQuota = quotaResolver.getUsed();
if (excess.getBytes().compareTo(BigInteger.ZERO) > 0) {
log.warn(
"No more pages to expire, check if youd disk quota"
+ " database is out of date with your blob store. Quota: "
+ limit.toNiceString()
+ " used: "
+ usedQuota.toNiceString());
代码示例来源:origin: GeoWebCache/geowebcache
/**
* @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;
}
代码示例来源:origin: GeoWebCache/geowebcache
if (usedQuota.getBytes().compareTo(BigInteger.ZERO) > 0) {
log.debug(
"Using saved quota information for layer "
+ layerName
+ ": "
+ usedQuota.toNiceString());
} else {
log.debug(
代码示例来源:origin: GeoWebCache/geowebcache
assertEquals(JDBCQuotaStore.GLOBAL_QUOTA_NAME, global.getTileSetId());
assertEquals(0, global.getBytes().longValue());
代码示例来源:origin: GeoWebCache/geowebcache
public void setBytes(long bytes) {
setBytes(BigInteger.valueOf(bytes));
}
代码示例来源:origin: GeoWebCache/geowebcache
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[");
sb.append(tileSet);
sb.append(numAggregations).append(" aggregated updates, ");
sb.append(tilePages.size()).append(" different pages, ");
sb.append("accum quota diff: ").append(accumQuotaDiff.toNiceString());
sb.append(", created ")
.append((System.currentTimeMillis() - creationTime))
.append("ms ago")
.append("]");
return sb.toString();
}
}
代码示例来源:origin: GeoWebCache/geowebcache
/** Shorthand for {@link #subtract(BigInteger) subtract(units.toBytes(amount))} */
public void subtract(final double amount, final StorageUnit units) {
subtract(units.toBytes(amount));
}
代码示例来源: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()));
}
代码示例来源: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
@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
private TileSet getOrCreateTileSet(final Transaction transaction, final TileSet tset) {
String id = tset.getId();
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;
}
内容来源于网络,如有侵权,请联系作者删除!