added counter on wf progress information

This commit is contained in:
Enrico Ottonello 2020-10-20 19:34:40 +02:00
parent 8073ac7131
commit 5d29077a43
1 changed files with 36 additions and 2 deletions

View File

@ -86,27 +86,45 @@ public class IndexOnESJobNode extends AsyncJobNode {
String[] splits = getDatasourceInterface().split("::"); String[] splits = getDatasourceInterface().split("::");
String datasource = splits[2]; String datasource = splits[2];
String collectionId = splits[3]; String collectionId = splits[3];
log.info("selecting collection identifiers for "+datasource+" "+collectionId+" ...");
List<String> collectionIdentifiers = selectIdentifiers(datasource, collectionId, collectionResourceType); List<String> collectionIdentifiers = selectIdentifiers(datasource, collectionId, collectionResourceType);
if (!collectionIdentifiers.isEmpty()) { if (!collectionIdentifiers.isEmpty()) {
log.info("retrieved "+collectionIdentifiers.size()+" collections");
setTotalResourceToIndex(collectionIdentifiers.size());
int counter = 0;
List <Integer> counters = Arrays.asList(counter);
log.info("start indexing loop for collections ... ");
collectionIdentifiers.forEach(identifier -> { collectionIdentifiers.forEach(identifier -> {
try { try {
indexing(datasource, collectionId, collectionResourceType, cleanIdentifier(identifier)); indexing(datasource, collectionId, collectionResourceType, cleanIdentifier(identifier));
int value = counters.get(0);
counters.set(0, value+1);
setCurrentResourceToIndex(counters.get(0));
} catch (Throwable t) { } catch (Throwable t) {
log.error(identifier+" "+t); log.error(identifier+" "+t);
} }
}); });
log.info("index loop for collections completed");
} }
log.info("selecting record identifiers for "+datasource+" "+collectionId+" ...");
List<String> recordIdentifiers = selectIdentifiers(datasource, collectionId, recordResourceType); List<String> recordIdentifiers = selectIdentifiers(datasource, collectionId, recordResourceType);
if (!recordIdentifiers.isEmpty()) { if (!recordIdentifiers.isEmpty()) {
log.info("retrieved "+recordIdentifiers.size()+" records");
setTotalResourceToIndex(recordIdentifiers.size());
int counter = 0;
List <Integer> counters = Arrays.asList(counter);
log.info("start indexing loop for records ... ");
recordIdentifiers.forEach(identifier -> { recordIdentifiers.forEach(identifier -> {
try { try {
indexing(datasource, collectionId, recordResourceType, cleanIdentifier(identifier)); indexing(datasource, collectionId, recordResourceType, cleanIdentifier(identifier));
int value = counters.get(0);
counters.set(0, value+1);
setCurrentResourceToIndex(counters.get(0));
} catch (Throwable t) { } catch (Throwable t) {
log.error(identifier+" "+t); log.error(identifier+" "+t);
} }
}); });
log.info("index loop for records completed");
} }
} }
catch (Throwable t) { catch (Throwable t) {
@ -217,4 +235,20 @@ public class IndexOnESJobNode extends AsyncJobNode {
} }
}); });
} }
public int getCurrentResourceToIndex() {
return currentResourceToIndex;
}
public void setCurrentResourceToIndex(int currentResourceToIndex) {
this.currentResourceToIndex = currentResourceToIndex;
}
public int getTotalResourceToIndex() {
return totalResourceToIndex;
}
public void setTotalResourceToIndex(int totalResourceToIndex) {
this.totalResourceToIndex = totalResourceToIndex;
}
} }