Refs #11258 Add possibility to force to rerun an already completed aggregation
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-aggregator-se-plugin@164535 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a511653fe4
commit
e8b6dfcc50
|
@ -1,9 +1,9 @@
|
|||
package org.gcube.accounting.aggregator.aggregation;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.accounting.aggregator.utility.Constant;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
|
@ -24,6 +24,18 @@ public class AggregationInfo {
|
|||
@SuppressWarnings("unused")
|
||||
private AggregationInfo(){}
|
||||
|
||||
public AggregationInfo(AggregationInfo aggregationInfo) {
|
||||
super();
|
||||
this.recordType = aggregationInfo.getRecordType();
|
||||
this.aggregationType = aggregationInfo.getAggregationType();
|
||||
Calendar start = Calendar.getInstance();
|
||||
start.setTime(aggregationInfo.getAggregationStartDate());
|
||||
this.aggregationStartDate = start.getTime();
|
||||
Calendar end = Calendar.getInstance();
|
||||
end.setTime(aggregationInfo.getAggregationEndDate());
|
||||
this.aggregationEndDate = end.getTime();
|
||||
}
|
||||
|
||||
public AggregationInfo(String recordType, AggregationType aggregationType, Date aggregationStartDate,
|
||||
Date aggregationEndDate) {
|
||||
super();
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Elaborator {
|
|||
public final static String ORIGINAL_SUFFIX = ".original.json";
|
||||
public final static String AGGREGATED_SUFFIX = ".aggregated.json";
|
||||
|
||||
protected final AggregationStatus aggregationStatus;
|
||||
protected AggregationStatus aggregationStatus;
|
||||
protected final Date persistStartTime;
|
||||
protected final Date persistEndTime;
|
||||
|
||||
|
@ -89,9 +89,9 @@ public class Elaborator {
|
|||
public void elaborate(boolean forceEarlyAggregation, boolean forceRerun, boolean forceRestart) throws Exception {
|
||||
Calendar startTime = Utility.getUTCCalendarInstance();
|
||||
|
||||
AggregationInfo aggregationInfo = aggregationStatus.getAggregationInfo();
|
||||
Date aggregationStartDate = aggregationInfo.getAggregationStartDate();
|
||||
AggregationType aggregationType = aggregationInfo.getAggregationType();
|
||||
final AggregationInfo aggregationInfo = aggregationStatus.getAggregationInfo();
|
||||
final Date aggregationStartDate = aggregationInfo.getAggregationStartDate();
|
||||
final AggregationType aggregationType = aggregationInfo.getAggregationType();
|
||||
|
||||
if(!isAggregationAllowed()){
|
||||
if(!forceEarlyAggregation) {
|
||||
|
@ -125,6 +125,12 @@ public class Elaborator {
|
|||
AggregationStatus.class.getSimpleName(),
|
||||
aggregationStatus.getAggregationState(),
|
||||
DSMapper.getObjectMapper().writeValueAsString(aggregationStatus));
|
||||
|
||||
|
||||
|
||||
aggregationStatus = new AggregationStatus(aggregationStatus);
|
||||
|
||||
|
||||
aggregationStatus.setAggregationState(AggregationState.RESTARTED, startTime, false);
|
||||
aggregationStatus.setAggregationState(AggregationState.STARTED, startTime, true);
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ public class AggregationStatus {
|
|||
@JsonProperty(required=false)
|
||||
protected String context;
|
||||
|
||||
@JsonProperty(required=false)
|
||||
protected AggregationStatus previous;
|
||||
|
||||
// Last observed status
|
||||
@JsonFormat(shape= JsonFormat.Shape.STRING)
|
||||
@JsonProperty
|
||||
|
@ -81,6 +84,15 @@ public class AggregationStatus {
|
|||
this.aggregationStateEvents = new ArrayList<>();
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.malformedRecordNumber = 0;
|
||||
this.previous = null;
|
||||
}
|
||||
|
||||
public AggregationStatus(AggregationStatus aggregationStatus) throws Exception {
|
||||
this.aggregationInfo = new AggregationInfo(aggregationStatus.getAggregationInfo());
|
||||
this.aggregationStateEvents = new ArrayList<>();
|
||||
this.uuid = aggregationStatus.getUUID();
|
||||
this.malformedRecordNumber = 0;
|
||||
this.previous = aggregationStatus;
|
||||
}
|
||||
|
||||
public AggregationInfo getAggregationInfo() {
|
||||
|
|
|
@ -58,6 +58,7 @@ public class AccountingAggregatorPluginTest extends ScopedTest {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void cycle() throws Exception {
|
||||
for(int i=0; i<20; i++) {
|
||||
|
@ -65,6 +66,7 @@ public class AccountingAggregatorPluginTest extends ScopedTest {
|
|||
logger.debug("---------------------------------------------\n\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// @Test
|
||||
public void testRecovery() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue