Added 3 attempts in upsert aggregation_status
This commit is contained in:
parent
e2bcfc016a
commit
74349c3253
|
@ -14,6 +14,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.accounting.aggregator.aggregation.AggregationInfo;
|
import org.gcube.accounting.aggregator.aggregation.AggregationInfo;
|
||||||
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
import org.gcube.accounting.aggregator.aggregation.AggregationType;
|
||||||
|
@ -205,7 +206,7 @@ public class PostgreSQLConnector extends PersistencePostgreSQL implements Aggreg
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void upsertAggregationStatus(AggregationStatus aggregationStatus) throws Exception {
|
public void upsertAggregationStatus(AggregationStatus aggregationStatus) throws Exception {
|
||||||
for(int i=1; i<=3; i++){
|
for(int i=0; i<3; i++){
|
||||||
try {
|
try {
|
||||||
Connection connection = getConnection();
|
Connection connection = getConnection();
|
||||||
Statement statement = connection.createStatement();
|
Statement statement = connection.createStatement();
|
||||||
|
@ -217,6 +218,15 @@ public class PostgreSQLConnector extends PersistencePostgreSQL implements Aggreg
|
||||||
connection.commit();
|
connection.commit();
|
||||||
break;
|
break;
|
||||||
}catch (Throwable e) {
|
}catch (Throwable e) {
|
||||||
|
if(i<3) {
|
||||||
|
long delay = TimeUnit.MILLISECONDS.toMillis(100);
|
||||||
|
logger.error("Unable to upsert aggregation status at attemp {}. Retrying in {} millis.", i, delay, e);
|
||||||
|
Thread.sleep(delay);
|
||||||
|
}else {
|
||||||
|
logger.error("Unable to upsert aggregation status.", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue