Github user dsmiley commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/422#discussion_r204411897
--- Diff:
solr/core/src/java/org/apache/solr/update/processor/TimeRoutedAliasUpdateProcessor.java
---
@@ -230,6 +219,59 @@ public void processAdd(AddUpdateCommand cmd) throws
IOException {
}
}
+ /**
+ * Create an executor that can only handle one task at a time. This is
used to ensure that
+ */
+ private ThreadPoolExecutor singleThreadSingleTaskExecutor() {
+ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1,
1, TimeUnit.HOURS, new ArrayBlockingQueue<>(1));
+ // add a hook to keep from leaking threads in tests.
+ this.req.getCore().addCloseHook(new CloseHook() {
+ @Override
+ public void preClose(SolrCore core) {
+ try {
+ threadPoolExecutor.shutdown();
+ threadPoolExecutor.awaitTermination(250, TimeUnit.MILLISECONDS);
+ threadPoolExecutor.shutdownNow();
+ } catch (InterruptedException e) {
+ log.error("Interrupted while closing executor for TRA update
processor");
+ }
+ }
+
+ @Override
+ public void postClose(SolrCore core) { }
+ });
+ return threadPoolExecutor;
+ }
+
+ /**
+ * Determine if the a new collection will be required based on the
document timestamp. Passing null for
+ * preemptiveCreateInterval tells you if the document is beyond all
existing collections, and passing a
+ * valid date math for preemptiveCreateWindow tells you if the document
is close enough to the end of the
+ * TRA to trigger preemptive creation.
+ *
+ * @param routeTimestamp The timestamp from the document
+ * @param preemptiveCreateWindow The date math indicating the {@link
TimeRoutedAlias#preemptiveCreateWindow}
+ * @return true if a new collection would be required.
+ */
+ private boolean requiresCreateCollection(Instant routeTimestamp, String
preemptiveCreateWindow) {
+ // Create a new collection?
+ final Instant mostRecentCollTimestamp =
parsedCollectionsDesc.get(0).getKey();
+ final Instant nextCollTimestamp =
timeRoutedAlias.computeNextCollTimestamp(mostRecentCollTimestamp);
+ Instant nextCollCreateTime = nextCollTimestamp;
+ if (StringUtils.isNotBlank(preemptiveCreateWindow)) {
+ DateMathParser dateMathParser = new DateMathParser();
+ dateMathParser.setNow(Date.from(nextCollTimestamp));
+ try {
+ nextCollCreateTime = dateMathParser.parseMath("-" +
preemptiveCreateWindow).toInstant();
--- End diff --
there's that subtle '-' again
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]