diff --git a/src/main/java/org/ecocean/Base.java b/src/main/java/org/ecocean/Base.java index ff94170d5d..8313503d1c 100644 --- a/src/main/java/org/ecocean/Base.java +++ b/src/main/java/org/ecocean/Base.java @@ -106,9 +106,12 @@ public JSONObject opensearchMapping() { public void opensearchIndex() throws IOException { + long startT = System.currentTimeMillis(); OpenSearch opensearch = new OpenSearch(); opensearch.index(this.opensearchIndexName(), this); + long endT = System.currentTimeMillis(); + System.out.println("opensearchIndex(): " + (endT - startT) + "ms indexing " + this); } // this will index "related" objects as needed diff --git a/src/main/java/org/ecocean/Encounter.java b/src/main/java/org/ecocean/Encounter.java index 584e9d70cf..16a2aa8b45 100644 --- a/src/main/java/org/ecocean/Encounter.java +++ b/src/main/java/org/ecocean/Encounter.java @@ -4705,35 +4705,4 @@ public void sendCreationEmails(Shepherd myShepherd, String langCode) { } } - public void opensearchIndexDeep() - throws IOException { - final String encId = this.getId(); - final Encounter origEnc = this; - ExecutorService executor = Executors.newFixedThreadPool(4); - Runnable rn = new Runnable() { - public void run() { - Shepherd bgShepherd = new Shepherd("context0"); - bgShepherd.setAction("Encounter.opensearchIndexDeep_" + encId); - bgShepherd.beginDBTransaction(); - try { - Encounter enc = bgShepherd.getEncounter(encId); - if (enc == null) { - // we use origEnc if we can (especially necessary on initial creation of Encounter) - if (origEnc != null) origEnc.opensearchIndex(); - bgShepherd.rollbackAndClose(); - executor.shutdown(); - return; - } - enc.opensearchIndex(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - bgShepherd.rollbackAndClose(); - } - executor.shutdown(); - } - }; - - executor.execute(rn); - } } diff --git a/src/main/java/org/ecocean/Occurrence.java b/src/main/java/org/ecocean/Occurrence.java index 1f4cce4a65..f267d6cb54 100644 --- a/src/main/java/org/ecocean/Occurrence.java +++ b/src/main/java/org/ecocean/Occurrence.java @@ -1370,7 +1370,7 @@ public void run() { try { Occurrence occur = bgShepherd.getOccurrence(occurId); if ((occur == null) || (occur.getEncounters() == null)) { - bgShepherd.rollbackAndClose(); + // rollbackAndClose handled by finally executor.shutdown(); return; }