Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1838 (pull request DSpace#2507)
Browse files Browse the repository at this point in the history
Optimize dspace cron scripts

Approved-by: Vincenzo Mecca
  • Loading branch information
atarix83 authored and vins01-4science committed Jul 18, 2024
2 parents 2a71a84 + e59577c commit eb4fdd5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -679,11 +679,11 @@ public void optimize() {
return;
}
long start = System.currentTimeMillis();
System.out.println("SOLR Search Optimize -- Process Started:" + start);
System.out.println("SOLR Dedup Optimize -- Process Started:" + start);
getSolr().optimize();
long finish = System.currentTimeMillis();
System.out.println("SOLR Search Optimize -- Process Finished:" + finish);
System.out.println("SOLR Search Optimize -- Total time taken:" + (finish - start) + " (ms).");
System.out.println("SOLR Dedup Optimize -- Process Finished:" + finish);
System.out.println("SOLR Dedup Optimize -- Total time taken:" + (finish - start) + " (ms).");
} catch (SolrServerException sse) {
System.err.println(sse.getMessage());
} catch (IOException ioe) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void internalRun() throws Exception {
timeUntilReindex = getTimeUntilReindex();
maxTime = getMaxTime();

Context context = new Context();
Context context = new Context(Context.Mode.READ_ONLY);

try {
context.turnOffAuthorisationSystem();
Expand Down Expand Up @@ -128,6 +128,7 @@ private void performStatusUpdate(Context context) throws SearchServiceException,
if (indexableObject.isPresent()) {
logDebugAndOut("Item exists in DB, updating solr document");
updateItem(context, indexableObject.get());
context.uncacheEntity(indexableObject.get().getIndexedObject());
} else {
logDebugAndOut("Item doesn't exist in DB, removing solr document");
removeItem(context, uniqueId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ public void verifySolrRecordsOfDeletedObjectsPaginationTest() throws Exception {
assertSearchQuery(IndexableItem.TYPE, 6, 6, 0, -1);
// delete col3 and all items that it contained
collectionService.delete(context, col3);
context.commit();
context.restoreAuthSystemState();

// check Collection type with start=0 and limit=default, we expect: indexableObjects=2, totalFound=2
Expand Down Expand Up @@ -562,6 +563,7 @@ public void disabledSolrToRemoveStaleObjectsTest() throws Exception {
assertSearchQuery(IndexableItem.TYPE, 6, 6, 0, -1);
// delete col3 and all items that it contained
collectionService.delete(context, col3);
context.commit();
context.restoreAuthSystemState();

// check Collection type with start=0 and limit=default,
Expand Down Expand Up @@ -653,6 +655,7 @@ public void disabledRerunOfSolrQueryDueToStaleObjectsTest() throws Exception {
assertSearchQuery(IndexableItem.TYPE, 6, 6, 0, -1);
// delete col3 and all items that it contained
collectionService.delete(context, col3);
context.commit();
context.restoreAuthSystemState();

// check Collection type with start=0 and limit=default,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void pollItemToUpdateAndProcess() {
}
log.debug("item enhancer poller committing");
context.commit();
context.clear();
}
context.restoreAuthSystemState();
context.complete();
Expand Down

0 comments on commit eb4fdd5

Please sign in to comment.