Skip to content

Commit

Permalink
XPLANBOX-2608 - added method to clear cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoltz committed Feb 28, 2024
1 parent c470030 commit 839100b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ void shutdown() {
}
}

public void removeAndClose(File file) throws IOException {
pool.removeAndClose(file.getCanonicalFile().toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
----------------------------------------------------------------------------*/
package org.deegree.commons.gdal.pool;

import static org.apache.commons.io.IOUtils.closeQuietly;
import static org.slf4j.LoggerFactory.getLogger;

import java.io.Closeable;
Expand Down Expand Up @@ -153,4 +154,12 @@ private synchronized BlockingQueue<T> getQueue(final String key) {
return queue;
}

public void removeAndClose(final String key) {
LOG.debug("Destroying resource, key: " + key);
BlockingQueue<T> queue = getQueue(key);
T resource = queue.poll();
closeQuietly(resource);
keyTracker.remove(key);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package org.deegree.tile.persistence.gdal;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.deegree.commons.gdal.GdalDataset;
Expand All @@ -47,7 +48,7 @@
* @author <a href="mailto:schneider@occamlabs.de">Markus Schneider</a>
* @since 3.4
*/
class GdalTileDataLevel implements TileDataLevel {
public class GdalTileDataLevel implements TileDataLevel {

private final TileMatrix metadata;

Expand Down Expand Up @@ -120,4 +121,8 @@ public List<String> getStyles() {
return null;
}

public void clearPool() throws IOException {
gdalSettings.getDatasetPool().removeAndClose(file);
}

}

0 comments on commit 839100b

Please sign in to comment.