@Override public void addListener(BlobStoreListener listener) { listeners.addListener(listener); }
@Override public boolean removeListener(BlobStoreListener listener) { return listeners.removeListener(listener); }
@Override public boolean rename(String oldLayerName, String newLayerName) throws StorageException { log.debug("No need to rename layers, S3BlobStore uses layer id as key root"); if (s3Ops.prefixExists(oldLayerName)) { listeners.sendLayerRenamed(oldLayerName, newLayerName); } return true; }
if (listeners.isEmpty()) { existed = false; oldObj = null; if (!listeners.isEmpty()) { if (existed) { long oldSize = oldObj.getContentLength(); listeners.sendTileUpdated(obj, oldSize); } else { listeners.sendTileStored(obj);
/** 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); } }
@Override public boolean delete(TileObject obj) throws StorageException { final String key = keyBuilder.forTile(obj); // don't bother for the extra call if there are no listeners if (listeners.isEmpty()) { return s3Ops.deleteObject(key); } ObjectMetadata oldObj = s3Ops.getObjectMetadata(key); if (oldObj == null) { return false; } s3Ops.deleteObject(key); obj.setBlobSize((int) oldObj.getContentLength()); listeners.sendTileDeleted(obj); return true; }
@Override public boolean delete(String layerName) throws StorageException { boolean deleted = deleteFiles(fileManager.getFiles(layerName)); listeners.sendLayerDeleted(layerName); return deleted; }
/** Delete a particular tile */ public boolean delete(TileObject stObj) throws StorageException { File fh = getFileHandleTile(stObj, false); boolean ret = false; // we call fh.length() here to check wthether the file exists and its length in a single // operation cause lots of calls to exists() may raise the file system cache usage to the // ceiling. File.length() returns 0 if the file does not exist anyway final long length = fh.length(); final boolean exists = length > 0; if (exists) { if (!fh.delete()) { throw new StorageException("Unable to delete " + fh.getAbsolutePath()); } stObj.setBlobSize((int) padSize(length)); listeners.sendTileDeleted(stObj); ret = true; } else { log.trace("delete unexistant file " + fh.toString()); } // Look at the parent directory to prune it if empty File parentDir = fh.getParentFile(); // Try deleting the directory (will not do it if the directory contains files) parentDir.delete(); return ret; }
@Override public boolean deleteByParametersId(String layerName, String parametersId) throws StorageException { checkNotNull(layerName, "layerName"); checkNotNull(parametersId, "parametersId"); boolean prefixExists = keyBuilder .forParameters(layerName, parametersId) .stream() .map( prefix -> { try { return s3Ops.scheduleAsyncDelete(prefix); } catch (RuntimeException | GeoWebCacheException e) { throw Throwables.propagate(e); } }) .reduce(Boolean::logicalOr) // Don't use Stream.anyMatch as it would short // circuit .orElse(false); if (prefixExists) { listeners.sendParametersDeleted(layerName, parametersId); } return prefixExists; }
@Override public boolean deleteByGridsetId(final String layerName, final String gridSetId) throws StorageException { checkNotNull(layerName, "layerName"); checkNotNull(gridSetId, "gridSetId"); final String gridsetPrefix = keyBuilder.forGridset(layerName, gridSetId); boolean prefixExists; try { prefixExists = s3Ops.scheduleAsyncDelete(gridsetPrefix); } catch (GeoWebCacheException e) { throw Throwables.propagate(e); } if (prefixExists) { listeners.sendGridSubsetDeleted(layerName, gridSetId); } return prefixExists; }
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 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); } }
if (listeners.isEmpty()) {
if (listeners.isEmpty()) { existed = false; oldObj = null; if (!listeners.isEmpty()) { if (existed) { long oldSize = oldObj.getContentLength(); listeners.sendTileUpdated(obj, oldSize); } else { listeners.sendTileStored(obj);
@Override public boolean delete(TileObject obj) throws StorageException { final String key = keyBuilder.forTile(obj); // don't bother for the extra call if there are no listeners if (listeners.isEmpty()) { return s3Ops.deleteObject(key); } ObjectMetadata oldObj = s3Ops.getObjectMetadata(key); if (oldObj == null) { return false; } s3Ops.deleteObject(key); obj.setBlobSize((int) oldObj.getContentLength()); listeners.sendTileDeleted(obj); return true; }
@Override public boolean delete(String layerName) throws StorageException { boolean deleted = deleteFiles(fileManager.getFiles(layerName)); listeners.sendLayerDeleted(layerName); return deleted; }
long x = Long.parseLong(coords[0]); long y = Long.parseLong(coords[1]); listeners.sendTileDeleted( layerName, gridSetId,
@Override public boolean deleteByParametersId(String layerName, String parametersId) throws StorageException { boolean deleted = deleteFiles(fileManager.getParametersFiles(layerName, parametersId)); listeners.sendParametersDeleted(layerName, parametersId); return deleted; }
@Override public boolean deleteByGridsetId(final String layerName, final String gridSetId) throws StorageException { checkNotNull(layerName, "layerName"); checkNotNull(gridSetId, "gridSetId"); final String gridsetPrefix = keyBuilder.forGridset(layerName, gridSetId); boolean prefixExists; try { prefixExists = s3Ops.scheduleAsyncDelete(gridsetPrefix); } catch (GeoWebCacheException e) { throw Throwables.propagate(e); } if (prefixExists) { listeners.sendGridSubsetDeleted(layerName, gridSetId); } return prefixExists; }
if (listeners.isEmpty()) {