use of io.siddhi.core.util.persistence.util.IncrementalSnapshotInfo in project siddhi by wso2.
the class IncrementalFileSystemPersistenceStore method cleanOldRevisions.
private void cleanOldRevisions(IncrementalSnapshotInfo incrementalSnapshotInfo) {
if (incrementalSnapshotInfo.getType() != IncrementalSnapshotInfo.SnapshotType.INCREMENT) {
File dir = new File(folder + File.separator + incrementalSnapshotInfo.getSiddhiAppId());
File[] files = dir.listFiles();
if (files != null) {
long baseTimeStamp = (incrementalSnapshotInfo.getTime());
for (File file : files) {
String fileName = file.getName();
IncrementalSnapshotInfo snapshotInfo = PersistenceHelper.convertRevision(fileName);
if (snapshotInfo.getTime() < baseTimeStamp && incrementalSnapshotInfo.getId().equals(snapshotInfo.getId())) {
if (incrementalSnapshotInfo.getType() == IncrementalSnapshotInfo.SnapshotType.BASE && snapshotInfo.getType() != IncrementalSnapshotInfo.SnapshotType.PERIODIC) {
if (file.exists()) {
Boolean isDeleted = file.delete();
if (!isDeleted) {
log.error("Error deleting old revision " + fileName);
}
}
} else if (incrementalSnapshotInfo.getType() == IncrementalSnapshotInfo.SnapshotType.PERIODIC && snapshotInfo.getType() == IncrementalSnapshotInfo.SnapshotType.PERIODIC) {
if (file.exists()) {
Boolean isDeleted = file.delete();
if (!isDeleted) {
log.error("Error deleting old revision " + fileName);
}
}
}
}
}
}
}
}
Aggregations