Improve performance of "DashboardController.getCollectionMonitorSummary()"-endpoint.
Now, a single "getRepositoryAggregations"-call is made, which results in just one "DSM-aggregationhistory"-api-call. Previously, multiple api-calls where made, each requesting the whole "aggregationhistory"-data and then trimming it down to only a few results.
This commit is contained in:
parent
c1abaad3e1
commit
06cea537bf
|
@ -55,31 +55,21 @@ public class DashboardController {
|
|||
@PreAuthorize("hasAuthority('REGISTERED_USER')")
|
||||
public CollectionMonitorSummary getCollectionMonitorSummary(
|
||||
@PathVariable("repoId") String repoId,
|
||||
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
||||
@RequestParam(name = "size", required = false, defaultValue = "20") int summarySize) throws JSONException {
|
||||
|
||||
// Get the "aggregationInfo" for the first <number of> requested aggregations.
|
||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, 0, size);
|
||||
List<AggregationInfo> aggregationInfoList = aggregationService.getRepositoryAggregations(repoId);
|
||||
|
||||
CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary();
|
||||
collectionMonitorSummary.setAggregationInfo(aggregationInfoList);
|
||||
// Set the "aggregationInfo" for the first <number of> requested aggregations, in order to create a "summary".
|
||||
collectionMonitorSummary.setAggregationInfo(aggregationInfoList.subList(0, Math.min(summarySize, aggregationInfoList.size())));
|
||||
|
||||
// Search for the last indexed version, from the beginning of the list.
|
||||
|
||||
// TODO - WARNING! This is very slow, since each time it requests the next 50, it re-requests the whole list from the "/ds/aggregationhistory/" DSM-endpoint.
|
||||
// inside "AggregationServiceImpl.getRepositoryAggregations()". Then it splits the list in a chunk of 50 and then iterate though it here..
|
||||
// Since we already request the whole list each time anyway, just take that use it here!!
|
||||
|
||||
size = 0;
|
||||
do {
|
||||
aggregationInfoList = aggregationService.getRepositoryAggregations(repoId, size, size + 50);
|
||||
for (AggregationInfo aggregationInfo : aggregationInfoList) {
|
||||
if (aggregationInfo.isIndexedVersion()) {
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationInfo);
|
||||
break;
|
||||
}
|
||||
// Search for the last indexed version and set the "collectionMonitorSummary".
|
||||
for ( AggregationInfo aggregationInfo : aggregationInfoList ) {
|
||||
if ( aggregationInfo.isIndexedVersion() ) {
|
||||
collectionMonitorSummary.setLastIndexedVersion(aggregationInfo);
|
||||
break;
|
||||
}
|
||||
size += 50;
|
||||
} while (aggregationInfoList.size() != 0 && collectionMonitorSummary.getLastIndexedVersion() == null);
|
||||
}
|
||||
|
||||
return collectionMonitorSummary;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue