Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- fixed another concurrency problem in collection sorting - fixed a typing problem that was introduced in svn 4579 and caused the crawl monitor to fail
orbiter433ff855f780
diff --git a/htroot/IndexCreateLoaderQueue_p.java b/htroot/IndexCreateLoaderQueue_p.javaindex ce52169f0..ba641353a 100644--- a/htroot/IndexCreateLoaderQueue_p.java+++ b/htroot/IndexCreateLoaderQueue_p.java@@ -64,7 +64,7 @@ public class IndexCreateLoaderQueue_p {} else {prop.put("loader-set", "1");boolean dark = true;- plasmaCrawlEntry[] w = switchboard.crawlQueues.activeWorker();+ plasmaCrawlEntry[] w = switchboard.crawlQueues.activeWorkerEntries();yacySeed initiator;int count = 0;for (int i = 0; i < w.length; i++) {diff --git a/htroot/xml/queues_p.java b/htroot/xml/queues_p.javaindex 14bff25a2..912f83c2b 100644--- a/htroot/xml/queues_p.java+++ b/htroot/xml/queues_p.java@@ -144,7 +144,7 @@ public class queues_p {if (sb.crawlQueues.size() == 0) {prop.put("list-loader", "0");} else {- plasmaCrawlEntry[] w = sb.crawlQueues.activeWorker();+ plasmaCrawlEntry[] w = sb.crawlQueues.activeWorkerEntries();int count = 0;for (int i = 0; i < w.length; i++) {if (w[i] == null) continue;diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex 6229604f0..cdd7fd754 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -31,8 +31,13 @@ import java.util.Iterator;import java.util.List;import java.util.Random;import java.util.Set;+import java.util.concurrent.Callable;+import java.util.concurrent.CompletionService;+import java.util.concurrent.ExecutionException;+import java.util.concurrent.ExecutorCompletionService;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;+import java.util.concurrent.Future;import de.anomic.server.serverFileUtils;import de.anomic.server.serverMemory;@@ -47,12 +52,15 @@ public class kelondroRowCollection {static final Integer dummy = new Integer(0);public static ExecutorService sortingthreadexecutor = null;+ public static CompletionService<Object> sortingthreadcompletion = null;static {if (serverProcessor.useCPU > 1) {sortingthreadexecutor = Executors.newCachedThreadPool();+ sortingthreadcompletion = new ExecutorCompletionService<Object>(sortingthreadexecutor);} else {sortingthreadexecutor = null;+ sortingthreadcompletion = null;}}@@ -478,10 +486,15 @@ public class kelondroRowCollection {int p = partition(0, this.chunkcount, this.sortBound, swapspace);if ((sortingthreadexecutor != null) && (!sortingthreadexecutor.isShutdown()) && (p > 50)) {// sort this using multi-threading- Thread qsortthread = new qsortthread(this, 0, p, 0);- sortingthreadexecutor.execute(qsortthread);+ Future<Object> part = sortingthreadcompletion.submit(new qsortthread(this, 0, p, 0));qsort(p, this.chunkcount, 0, swapspace);- if (qsortthread.isAlive()) try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); }+ try {+ part.get();+ } catch (InterruptedException e) {+ e.printStackTrace();+ } catch (ExecutionException e) {+ e.printStackTrace();+ }} else {qsort(0, p, 0, swapspace);qsort(p, this.chunkcount, 0, swapspace);@@ -490,7 +503,7 @@ public class kelondroRowCollection {//assert this.isSorted();}- public static class qsortthread extends Thread {+ public static class qsortthread implements Callable<Object> {kelondroRowCollection rc;int L, R, S;@@ -501,10 +514,10 @@ public class kelondroRowCollection {this.S = S;}- public void run() {+ public Object call() throws Exception {rc.qsort(L, R, S, new byte[rc.rowdef.objectsize]);- synchronized (rc) {rc.notify();}- }+ return null;+ }}final void qsort(int L, int R, int S, byte[] swapspace) {diff --git a/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java b/source/de/anomic/plasma/crawler/plasmaCrawlQueues.javaindex 18121209d..d91f0b4d9 100644--- a/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java+++ b/source/de/anomic/plasma/crawler/plasmaCrawlQueues.java@@ -129,9 +129,12 @@ public class plasmaCrawlQueues {delegatedURL.close();}- public plasmaCrawlEntry[] activeWorker() {+ public plasmaCrawlEntry[] activeWorkerEntries() {synchronized (workers) {- return workers.values().toArray(new plasmaCrawlEntry[0]);+ plasmaCrawlEntry[] e = new plasmaCrawlEntry[workers.size()];+ int i = 0;+ for (crawlWorker w: workers.values()) e[i++] = w.entry;+ return e;}}