try to shut down in a bit more ordered way

inspired by https://github.com/yacy/yacy_search_server/issues/518
pull/533/head
Michael Christen 2 years ago
parent 1b825df086
commit 99174282d8

@ -124,6 +124,12 @@ public final class CrawlStacker implements WorkflowTask<Request>{
public synchronized void close() {
CrawlStacker.log.info("Shutdown. waiting for remaining " + this.size() + " crawl stacker job entries. please wait.");
this.requestQueue.shutdown();
// busy waiting for the queue to empty
for (int i = 0; i < 10; i++) {
if (this.size() <= 0) break;
try {Thread.sleep(1000);} catch (InterruptedException e) {}
}
CrawlStacker.log.info("Shutdown. Closing stackCrawl queue.");

@ -366,7 +366,7 @@ public final class Fulltext {
public void putDocument(final SolrInputDocument doc) throws IOException {
final SolrConnector connector = this.getDefaultConnector();
if (connector == null) return;
if (connector == null || connector.isClosed()) return;
final String id = (String) doc.getFieldValue(CollectionSchema.id.getSolrFieldName());
final String url = (String) doc.getFieldValue(CollectionSchema.sku.getSolrFieldName());
assert url != null && url.length() < 30000;

@ -406,8 +406,8 @@ public final class yacy {
ConcurrentLog.severe("STARTUP", "Unexpected Error: " + e.getClass().getName(),e);
//System.exit(1);
}
if(lock != null) lock.release();
if(channel != null) channel.close();
if (lock != null && lock.isValid()) lock.release();
if (channel != null && channel.isOpen()) channel.close();
} catch (final Exception ee) {
ConcurrentLog.severe("STARTUP", "FATAL ERROR: " + ee.getMessage(),ee);
} finally {

Loading…
Cancel
Save