Now, the saveSnapshotAfterMirror boolean property is used in the end of ResultSetJdbcGpsDevice.performMirroring method.
The problem, I think, is that if the property is true, the saving of the snapshot is always performed, even if there was no created/updated/deleted rows in the DB.
This is not a problem if using RAMJdbcSnapshotPersister, but if using FSJdbcSnapshotPersister this could be a quite heavy operation to perform every time the performMirroring is called, especially if the index content is big.
So, I think the solution should be something like this:
...
if (!createdRows.isEmpty() || !updatedRows.isEmpty()) {
getSnapshotEventListener().onCreateAndUpdate(
new CreateAndUpdateSnapshotEvent(connection, dialect, mapping, createdRows, updatedRows,
compassGps));
}
if (!deletedRows.isEmpty()) {
getSnapshotEventListener().onDelete(
new DeleteSnapshotEvent(connection, dialect, mapping, deletedRows, compassGps));
}
snapshot.putAliasSnapshot(newAliasSnapshot);
// >>>>>>>>>>>>>>>>>
if (isSaveSnapshotAfterMirror() && (!createdRows.isEmpty() || !updatedRows.isEmpty() || !deletedRows.isEmpty()) {
getSnapshotPersister().save(snapshot);
}
// <<<<<<<<<<<<<<<<
}
} catch (SQLException e) {
throw new JdbcGpsDeviceException(buildMessage("Failed while mirroring data changes"), e);
} finally {
JdbcUtils.closeResultSet(rs);
JdbcUtils.closeStatement(ps);
JdbcUtils.closeConnection(connection);
}
}