@Override public int weigh(String key, TileObject value) { currentSize.addAndGet(value.getBlobSize()); return value.getBlobSize(); } };
@Override public void onRemoval( RemovalNotification<String, TileObject> notification) { // TODO This operation is not atomic TileObject obj = notification.getValue(); // Update the current size currentSize.addAndGet(-obj.getBlobSize()); final String tileKey = generateTileKey(obj); final String layerName = obj.getLayerName(); multimap.removeTile(layerName, tileKey); if (LOGGER.isDebugEnabled()) { LOGGER.debug( "Removed tile " + tileKey + " for layer " + layerName + " due to reason:" + notification.getCause().toString()); LOGGER.debug( "Removed tile was evicted? " + notification.wasEvicted()); } } });
public void sendTileDeleted(final TileObject stObj) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileDeleted( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize); }
public void sendTileStored(final TileObject stObj) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileStored( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize); }
/** Store a tile. */ public void put(TileObject stObj) throws StorageException { final File fh = getFileHandleTile(stObj, true); final long oldSize = fh.length(); final boolean existed = oldSize > 0; writeFile(fh, stObj, existed); // mark the last modification as the tile creation time if set, otherwise // we'll leave it to the writing time if (stObj.getCreated() > 0) { try { fh.setLastModified(stObj.getCreated()); } catch (Exception e) { log.debug("Failed to set the last modified time to match the tile request time", e); } } /* * This is important because listeners may be tracking tile existence */ stObj.setBlobSize((int) padSize(stObj.getBlobSize())); if (existed) { listeners.sendTileUpdated(stObj, padSize(oldSize)); } else { listeners.sendTileStored(stObj); } }
public void sendTileUpdated(final TileObject stObj, final long oldSize) { final long[] xyz = stObj.getXYZ(); final String layerName = stObj.getLayerName(); final String gridSetId = stObj.getGridSetId(); final String blobFormat = stObj.getBlobFormat(); final String paramsId = stObj.getParametersId(); final int blobSize = stObj.getBlobSize(); sendTileUpdated( layerName, gridSetId, blobFormat, paramsId, xyz[0], xyz[1], (int) xyz[2], blobSize, oldSize); } }
params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size2 = toCache2.getBlobSize();
null, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); final long size1 = toCache1.getBlobSize();
null, new ByteArrayResource("1,2,4,5,6 test".getBytes(StandardCharsets.UTF_8))); final long size = toCache.getBlobSize(); TileObject fromCache = TileObject.createQueryTileObject(
null, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize();
BlobStoreListener listener = EasyMock.createMock(BlobStoreListener.class); store.addListener(listener); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize();
null, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize(); TileObject fromCache1 = TileObject.createQueryTileObject(
BlobStoreListener listener = EasyMock.createMock(BlobStoreListener.class); store.addListener(listener); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize();
null, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size2 = toCache2.getBlobSize(); TileObject fromCache = TileObject.createQueryTileObject(
params2, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize();
null, new ByteArrayResource("7,8,9,10 test".getBytes(StandardCharsets.UTF_8))); final long size1 = toCache1.getBlobSize(); final long size2 = toCache2.getBlobSize(); TileObject remove = TileObject.createQueryTileObject(