if (layers.contains(obj.getLayerName())) {
if (layers.contains(obj.getLayerName())) { multimap.putTile(obj.getLayerName(), id); } finally {
if (layers.contains(obj.getLayerName())) {
/** * * Static method for generating the {@link TileObject} cache key to use for caching. * * @param obj * @return {@link TileObject} key */ public static String generateTileKey(TileObject obj) { Map<String, String> parameters = obj.getParameters(); StringBuilder builder = new StringBuilder(obj.getLayerName()) .append(SEPARATOR) .append(obj.getGridSetId()) .append(SEPARATOR) .append(Arrays.toString(obj.getXYZ())) .append(SEPARATOR) .append(obj.getBlobFormat()); // If parameters are present they must be handled if (parameters != null && !parameters.isEmpty()) { for (String key : parameters.keySet()) { builder.append(SEPARATOR).append(key).append(SEPARATOR).append(parameters.get(key)); } } return builder.toString(); }
@Override public boolean delete(TileObject obj) throws StorageException { return readFunctionUnsafe(() -> store(obj.getLayerName()).delete(obj)); }
@Override public void put(TileObject obj) throws StorageException { readActionUnsafe(() -> store(obj.getLayerName()).put(obj)); }
@Override public boolean get(TileObject obj) throws StorageException { return readFunctionUnsafe(() -> store(obj.getLayerName()).get(obj)); }
@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()); } } });
protected void persistParameterMap(TileObject stObj) { if (Objects.nonNull(stObj.getParametersId())) { putLayerMetadata( stObj.getLayerName(), "parameters." + stObj.getParametersId(), ParametersUtils.getKvp(stObj.getParameters())); } }
protected void persistParameterMap(TileObject stObj) { if (Objects.nonNull(stObj.getParametersId())) { putLayerMetadata( stObj.getLayerName(), "parameters." + stObj.getParametersId(), ParametersUtils.getKvp(stObj.getParameters())); } } }
protected void persistParameterMap(TileObject stObj) { if (Objects.nonNull(stObj.getParametersId())) { putLayerMetadata( stObj.getLayerName(), "parameters." + stObj.getParametersId(), ParametersUtils.getKvp(stObj.getParameters())); } } }
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); }
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 String forTile(TileObject obj) { checkNotNull(obj.getLayerName()); checkNotNull(obj.getGridSetId()); checkNotNull(obj.getBlobFormat()); checkNotNull(obj.getXYZ()); String layer = layerId(obj.getLayerName()); String gridset = obj.getGridSetId(); String shortFormat;
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); } }
eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()), eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()),
/** Builds the complete file path associated to the provided tile. */ File getFile(TileObject tile) { if (tile.getParametersId() == null && tile.getParameters() != null) { tile.setParametersId(ParametersUtils.getId(tile.getParameters())); } return getFile( tile.getParametersId(), tile.getXYZ(), tile.getLayerName(), tile.getGridSetId(), tile.getBlobFormat(), tile.getParameters()); }
/** Builds the complete file path associated to the provided tile. */ File getFile(TileObject tile) { if (tile.getParametersId() == null && tile.getParameters() != null) { tile.setParametersId(ParametersUtils.getId(tile.getParameters())); } return getFile( tile.getParametersId(), tile.getXYZ(), tile.getLayerName(), tile.getGridSetId(), tile.getBlobFormat(), tile.getParameters()); }
eq(tile.getLayerName()), eq(tile.getGridSetId()), eq(tile.getBlobFormat()),
@Test public void testDeleteLayer() throws Exception { byte[] bytes = new byte[1024]; Arrays.fill(bytes, (byte) 0xaf); TileObject tile = queryTile(20, 30, 12); tile.setBlob(new ByteArrayResource(bytes)); blobStore.put(tile); tile.getXYZ()[0] = 21; blobStore.put(tile); tile.getXYZ()[0] = 22; blobStore.put(tile); BlobStoreListener listener = mock(BlobStoreListener.class); blobStore.addListener(listener); String layerName = tile.getLayerName(); blobStore.delete(layerName); blobStore.destroy(); Thread.sleep(10000); // blobStore.delete(layerName); // verify(listener, Mockito.atLeastOnce()).layerDeleted(eq(layerName)); }