@Override
protected void execute(Context context) throws SQLException {
- boolean firstAttempt = context.prepareSelect("select count(1) from live_measures_p")
- .get(t -> t.getLong(1)) == 0;
+ boolean firstAttempt = isFirstAttempt(context);
if (!firstAttempt) {
LOG.info("Retry detected (non empty table live_measures_p). Handle it");
}
}
}
+ private static boolean isFirstAttempt(Context context) throws SQLException {
+ try (Select select = context.prepareSelect("select count(1) from live_measures_p")) {
+ return select.get(t -> t.getLong(1)) == 0;
+ }
+ }
+
private static void processProjectBatch(Context context, List<Row> rows, boolean firstAttempt, long now) throws SQLException {
MassUpdate massUpdate = context.prepareMassUpdate();
massUpdate.rowPluralName("live measures");