org.geowebcache.diskquota.storage.Quota.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.geowebcache.diskquota.storage.Quota.<init>方法的一些代码示例,展示了Quota.<init>的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Quota.<init>方法的具体详情如下:
包路径:org.geowebcache.diskquota.storage.Quota
类名称:Quota
方法名:<init>

Quota.<init>介绍

暂无

代码示例

代码示例来源: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

/**
 * Return a empty quota object in case a null value is passed, otherwise return the passed value
 *
 * @param optionalQuota
 * @return
 */
private Quota nonNullQuota(Quota optionalQuota) {
  if (optionalQuota == null) {
    return new Quota();
  } else {
    return optionalQuota;
  }
}

代码示例来源:origin: GeoWebCache/geowebcache

@Override
public Quota clone() {
  return new Quota(this);
}

代码示例来源:origin: GeoWebCache/geowebcache

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());
  }
}

代码示例来源:origin: GeoWebCache/geowebcache

public TimedQuotaUpdate(TileSet tileSet, TilePageCalculator tpc) {
  this.tileSet = tileSet;
  this.tpc = tpc;
  this.creationTime = System.currentTimeMillis();
  tilePages = new HashMap<String, PageStatsPayload>();
  pageIndexTarget = new int[3];
  pageIdTarget = new StringBuilder(128);
  accumQuotaDiff = new Quota();
}

代码示例来源:origin: GeoWebCache/geowebcache

@Override
public DiskQuotaConfig clone() {
  DiskQuotaConfig clone;
  try {
    clone = (DiskQuotaConfig) super.clone();
  } catch (CloneNotSupportedException e) {
    throw new RuntimeException(e);
  }
  clone.lastCleanUpTime = lastCleanUpTime;
  clone.globalQuota = globalQuota == null ? null : new Quota(globalQuota);
  clone.layerQuotas = layerQuotas == null ? null : new ArrayList<LayerQuota>(layerQuotas);
  return clone;
}

代码示例来源: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

public Quota call() throws Exception {
    Quota quota = usedQuotaByTileSetId.get(null, tileSetId, LockMode.READ_COMMITTED);
    if (quota == null) {
      quota = new Quota();
    }
    return quota;
  }
}

代码示例来源: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

public Quota getLimit() {
  Quota limit = layerQuota.getQuota();
  if (limit == null) {
    // has the admin disabled specific quota for this layer?
    limit = new Quota(BigInteger.valueOf(Long.MAX_VALUE));
  }
  return limit;
}

代码示例来源:origin: GeoWebCache/geowebcache

protected Quota getUsedQuotaByTileSetIdInternal(final String tileSetId) {
  String sql = dialect.getUsedQuotaByTileSetId(schema, "key");
  return jt.queryForOptionalObject(
      sql,
      new RowMapper<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));
}

代码示例来源: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;
}

代码示例来源:origin: GeoWebCache/geowebcache

public void testRemove() {
  LayerQuota lq = new LayerQuota("layer", ExpirationPolicy.LFU, new Quota());
  config.addLayerQuota(lq);
  config.remove(lq);
  assertNull(config.layerQuota("layer"));
}

代码示例来源: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

@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

@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

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));
}

代码示例来源:origin: GeoWebCache/geowebcache

@Test
public void testSetTruncated() throws Exception {
  String tileSetId = testTileSet.getId();
  TilePage page = new TilePage(tileSetId, 0, 0, 2);
  PageStatsPayload payload = new PageStatsPayload(page);
  int numHits = 100;
  payload.setNumHits(numHits);
  payload.setNumTiles(5);
  store.addToQuotaAndTileCounts(
      testTileSet, new Quota(1, StorageUnit.MiB), Collections.singleton(payload));
  List<PageStats> stats = store.addHitsAndSetAccesTime(Collections.singleton(payload)).get();
  assertThat(stats, contains(hasProperty("fillFactor", greaterThan(0f))));
  PageStats pageStats = store.setTruncated(page);
  assertThat(pageStats, hasProperty("fillFactor", closeTo(0f, 0f)));
}

代码示例来源:origin: GeoWebCache/geowebcache

public void testSetLayerQuotas() {
  // config.setLayerQuotas(null);
  assertNull(config.getLayerQuotas());
  try {
    config.addLayerQuota(new LayerQuota("layer", ExpirationPolicy.LRU));
    fail("Expected IAE");
  } catch (IllegalArgumentException e) {
    assertTrue(true);
  }
  LayerQuota lq = new LayerQuota("layer", ExpirationPolicy.LFU, new Quota());
  config.addLayerQuota(lq);
  assertNotNull(config.layerQuota("layer"));
}

代码示例来源: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());
}

相关文章