After doing some transformations I get a PCollection<FinalResult>
that looks like this:
PCollection<FinalResult> finalResult = merged
.apply("Process merged", ParDo.of(new MergedToFinalResultFunction()));
The FinalResult object is:
public class FinalResult implements Serializable {
private String application;
private Integer totalUnavailabilityMins;
private Integer totalMaintenanceMins;
// getter setter
}
For example if I log each FinalResult inside the PCollection<FinalResult>
it looks like the following:
APP1, Total Unavailability Mins: 0, Total Maintenance Mins: 30
APP2, Total Unavailability Mins: 140, Total Maintenance Mins: 0
APP3, Total Unavailability Mins: 50, Total Maintenance Mins: 70
Now for the final step I want to add to the pipeline is to give me the global unavailability mins and maintenance mins across the apps, have not been able to figure out how to this (with the example above total unavailability mins 190 and total maintenance mins 100), I was thinking that maybe to achieve this I need to create a new Object called CombinedTotals that can look like this:
public class CombinedTotals implements Serializable {
private final int totalUnavailabilityMins;
private final int totalMaintenanceMins;
// getter setter
}
and apply some step to the finalResult
pipeline above, to return one single Object inside the PCollection<CombinedTotals>
but im not being able to do this, can someone help with this or maybe if there is a better approach point it out, thanks!