From 5d29077a431e18abb9e5aa520a554fe154045cdd Mon Sep 17 00:00:00 2001 From: Enrico Ottonello Date: Tue, 20 Oct 2020 19:34:40 +0200 Subject: [PATCH] added counter on wf progress information --- .../workflows/nodes/IndexOnESJobNode.java | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java b/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java index 05a6564..e005b74 100644 --- a/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java +++ b/dnet-ariadneplus/src/main/java/eu/dnetlib/ariadneplus/workflows/nodes/IndexOnESJobNode.java @@ -86,27 +86,45 @@ public class IndexOnESJobNode extends AsyncJobNode { String[] splits = getDatasourceInterface().split("::"); String datasource = splits[2]; String collectionId = splits[3]; - + log.info("selecting collection identifiers for "+datasource+" "+collectionId+" ..."); List collectionIdentifiers = selectIdentifiers(datasource, collectionId, collectionResourceType); if (!collectionIdentifiers.isEmpty()) { + log.info("retrieved "+collectionIdentifiers.size()+" collections"); + setTotalResourceToIndex(collectionIdentifiers.size()); + int counter = 0; + List counters = Arrays.asList(counter); + log.info("start indexing loop for collections ... "); collectionIdentifiers.forEach(identifier -> { try { indexing(datasource, collectionId, collectionResourceType, cleanIdentifier(identifier)); + int value = counters.get(0); + counters.set(0, value+1); + setCurrentResourceToIndex(counters.get(0)); } catch (Throwable t) { log.error(identifier+" "+t); } }); + log.info("index loop for collections completed"); } - + log.info("selecting record identifiers for "+datasource+" "+collectionId+" ..."); List recordIdentifiers = selectIdentifiers(datasource, collectionId, recordResourceType); if (!recordIdentifiers.isEmpty()) { + log.info("retrieved "+recordIdentifiers.size()+" records"); + setTotalResourceToIndex(recordIdentifiers.size()); + int counter = 0; + List counters = Arrays.asList(counter); + log.info("start indexing loop for records ... "); recordIdentifiers.forEach(identifier -> { try { indexing(datasource, collectionId, recordResourceType, cleanIdentifier(identifier)); + int value = counters.get(0); + counters.set(0, value+1); + setCurrentResourceToIndex(counters.get(0)); } catch (Throwable t) { log.error(identifier+" "+t); } }); + log.info("index loop for records completed"); } } 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; + } }