Skip to content

Commit

Permalink
Reduce logging and add timing
Browse files Browse the repository at this point in the history
  • Loading branch information
wwtamu committed Jan 1, 2025
1 parent ec87843 commit 281dc18
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@ public void destroy() {

@Override
public void load(Collection<SolrInputDocument> documents) {
log.info("Loading {} {} documents", documents.size(), this.data.getName());
this.index.update(documents);
log.info("{} {} documents loaded", documents.size(), this.data.getName());
}

@Override
public void load(SolrInputDocument document) {
log.debug("Loading {} document", this.data.getName());
this.index.update(document);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static edu.tamu.scholars.discovery.etl.EtlCacheUtility.VALUES_CACHE;
import static java.lang.String.format;

import java.time.Duration;
import java.time.Instant;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -50,11 +51,12 @@ public EtlService(

@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
Instant startTime = Instant.now().plusMillis(10000);
threadPoolTaskScheduler.schedule(this::process, startTime);
threadPoolTaskScheduler.schedule(this::process, Instant.now());
}

private <I, O> void process() {
final Instant start = Instant.now();

List<CompletableFuture<EtlContext<I, O>>> futures = dataRepo.findAll()
.stream()
.<EtlContext<I, O>>map(this::init)
Expand All @@ -68,7 +70,8 @@ private <I, O> void process() {
.map(CompletableFuture::join)
.toList())
.thenAccept(contexts -> {
log.info("All ETL processes completed");
log.info("All ETL processes finished. {} seconds",
Duration.between(start, Instant.now()).toMillis() / 1000.0);
contexts.stream().forEach(this::destroy);
PROPERTY_CACHE.clear();
VALUES_CACHE.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ public JsonNode schema(JsonNode schema) {
@Override
public void update(Collection<SolrInputDocument> documents) {
try {
log.info("Updating {} documents to Solr", documents.size());
this.solrClient.add(documents);
this.solrClient.commit();
log.info("Successfully updated {} documents to Solr", documents.size());
} catch (RemoteSolrException | SolrServerException | IOException e) {
log.warn("Error updating Solr documents", e);
log.info("Attempting batch documents individually");
Expand All @@ -109,10 +107,8 @@ public void update(SolrInputDocument document) {
}

try {
// log.info("Updating document to Solr");
this.solrClient.add(document);
this.solrClient.commit();
// log.info("Successfully updated document to Solr");
} catch (RemoteSolrException | SolrServerException | IOException e) {

System.out.println("\n\n" + document + "\n\n");
Expand Down

0 comments on commit 281dc18

Please sign in to comment.