From e2e73258ca780951f89b41267c20da3f9aa10908 Mon Sep 17 00:00:00 2001 From: reger Date: Sat, 8 Aug 2015 18:35:49 +0200 Subject: [PATCH] remove obsolete interface SearchAccumulator and unused SRURSSConnector Thread inheritance --- .../yacy/cora/federate/SearchAccumulator.java | 40 ------------- .../federate/opensearch/SRURSSConnector.java | 59 +------------------ 2 files changed, 1 insertion(+), 98 deletions(-) delete mode 100644 source/net/yacy/cora/federate/SearchAccumulator.java diff --git a/source/net/yacy/cora/federate/SearchAccumulator.java b/source/net/yacy/cora/federate/SearchAccumulator.java deleted file mode 100644 index adab95c74..000000000 --- a/source/net/yacy/cora/federate/SearchAccumulator.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Accumulator - * Copyright 2010 by Michael Peter Christen - * First released 07.01.2011 at http://yacy.net - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program in the file lgpl21.txt - * If not, see . - */ - -package net.yacy.cora.federate; - -/** - * place-holder class to provide a object declaration for threads in Search object - */ -public interface SearchAccumulator extends Runnable { - - /** - * join this accumulator: wait until it terminates - * @throws InterruptedException - */ - public void join() throws InterruptedException; - - /** - * test if the accumulator is still running - * @return - */ - public boolean isAlive(); - -} diff --git a/source/net/yacy/cora/federate/opensearch/SRURSSConnector.java b/source/net/yacy/cora/federate/opensearch/SRURSSConnector.java index 3a0d83d18..b5b78a44e 100644 --- a/source/net/yacy/cora/federate/opensearch/SRURSSConnector.java +++ b/source/net/yacy/cora/federate/opensearch/SRURSSConnector.java @@ -22,79 +22,24 @@ package net.yacy.cora.federate.opensearch; import java.io.IOException; import java.net.MalformedURLException; -import java.util.ArrayList; import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; import net.yacy.cora.document.encoding.UTF8; import net.yacy.cora.document.feed.RSSFeed; import net.yacy.cora.document.feed.RSSMessage; import net.yacy.cora.document.feed.RSSReader; import net.yacy.cora.document.id.MultiProtocolURL; -import net.yacy.cora.federate.SearchAccumulator; import net.yacy.cora.federate.yacy.CacheStrategy; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.http.HTTPClient; import org.apache.http.entity.mime.content.ContentBody; -public class SRURSSConnector extends Thread implements SearchAccumulator { +public class SRURSSConnector { private final static int recordsPerSession = 250; - final String urlBase; - final String query; - final long timeoutInit; - final int maximumRecordsInit; - final CacheStrategy verify; - final boolean global; - final Map> result; - final ClientIdentification.Agent agent; - - private final BlockingQueue results; - - public SRURSSConnector( - final Map> result, - final String query, - final long timeoutInit, - final String urlBase, - final int maximumRecordsInit, - final CacheStrategy verify, - final boolean global, - final ClientIdentification.Agent agent) { - this.results = new LinkedBlockingQueue(); - this.result = result; - this.query = query; - this.timeoutInit = timeoutInit; - this.urlBase = urlBase; - this.maximumRecordsInit = maximumRecordsInit; - this.verify = verify; - this.global = global; - this.agent = agent; - } - - @Override - public void run() { - searchSRURSS(this.results, this.urlBase, this.query, this.timeoutInit, this.maximumRecordsInit, this.verify, this.global, this.agent); - int p = 1; - RSSMessage message; - try { - while ((message = this.results.poll(this.timeoutInit, TimeUnit.MILLISECONDS)) != RSSMessage.POISON) { - if (message == null) break; - List m = this.result.get(message.getLink()); - if (m == null) m = new ArrayList(); - m.add(new Integer(p++)); - this.result.put(message, m); - } - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - public static Thread searchSRURSS( final BlockingQueue queue, final String urlBase, @@ -118,7 +63,6 @@ public class SRURSSConnector extends Thread implements SearchAccumulator { try { feed = loadSRURSS(urlBase, query, startRecord, recordsPerSession, verify, global, agent); } catch (final IOException e1) { - //e1.printStackTrace(); break mainloop; } if (feed == null || feed.isEmpty()) break mainloop; @@ -129,7 +73,6 @@ public class SRURSSConnector extends Thread implements SearchAccumulator { try { queue.put(message); } catch (final InterruptedException e) { - e.printStackTrace(); break innerloop; } }