Add delete support on StructuredGridCoverage2DReader - STEMLab/geotools GitHub Wiki
-
Contact: Daniele Romagnoli
This proposal aims on adding the capability to do a cleanup delete of a coverageStore/GridCoverageReader.
Some readers/stores like the imageMosaic one, deal with a set of ancillary files and create a set of new files as well when configured.
Right now there is no way to fully purge a store/reader. The user have to manually delete all the granules, the auxiliary files as well as to remove the records from the database/feature store if any (as in the imageMosaic case).
A delete method will allow to do all these cleanup through a simple method invokation. The Reader, which is the only one which has full knowledge of the data structure, will do that cleanup operation by also potentially delegating some jobs to the underlying readers
As an instance, an ImageMosaic made of NetCDFs, will delegate some cleanup to the underlying NetCDF readers (which implements the StructuredGridCoverage2DReader too) to delete hidden files and purge quick access DBs.
The updated StructuredGridCoverage2Dreader will define a new delete method to cleanup everything associated to the reader. Moreover, the removeCoverage method will be updated by adding a delete parameter to specify whether the coverage Removal should also take care of deleting the referred files. Finally, a new FileSetManager interface will be defined in order to take note of sidecar/auxiliary files, remove or purge them. Specific FileSystem related implementation will also phisically remove or purge files from disk.
Voting has started:
- Andrea Aime
- Ben Caradoc-Davies
- Christian Mueller
- Ian Turton: +1
- Justin Deoliveira
- Jody Garnett
- Simone Giannecchini
This section is used to make sure your proposal is complete (did you remember documentation?) and has enough paid or volunteer time lined up to be a success
- API changed based on BEFORE / AFTER ✅
- Remove deprecated code from GeoTools project ✅
- Implement it on imageMosaic and test it against H2 ✅
- Update the user guide
BEFORE:
public interface StructuredGridCoverage2DReader extends GridCoverage2DReader {
...
boolean removeCoverage(String coverageName) throws IOException, UnsupportedOperationException;
...
}
AFTER:
public interface StructuredGridCoverage2DReader extends GridCoverage2DReader {
...
/**
* @deprecated use {@link #removeCoverage(String, boolean)}
*/
boolean removeCoverage(String coverageName) throws IOException, UnsupportedOperationException;
/**
* removes a granule store for the specified coverageName. Also tries to delete the related files if requested
*/
boolean removeCoverage(String coverageName, boolean delete) throws IOException, UnsupportedOperationException;
/**
* delete all stuff (database content, indexer files, property files, associated auxiliary files and so on).
* The deleteData parameter specifies whether data should be deleted too or not.
*/
void delete(boolean deleteData) throws IOException;
...
}
AFTER:
public interface FileSetManager {
/**
* Add a file to the file set manager
*/
void addFile(final String filePath);
/**
* Return the list of all the files currently added to the manager
*/
List<String> list();
/**
* Remove a file from the manager (An implementation may also physically remove the file)
*/
void removeFile(final String filePath);
/**
* Remove all the files from the manager (An implementation may also physically remove all the files)
*/
void purge();
}
final File file = new File("/data/mosaic");
StructuredGridCoverage2DReader reader = new ImageMosaicReader(file);
// delete all files associated to that mosaic (granules, auxiliary files, DB entries, ...)
reader.delete(true);
list the pages effected by this proposal
- Module Matrix page