refactoring

pull/1/head
Michael Peter Christen 12 years ago
parent f9fc5cfaba
commit d54b80327a

@ -32,7 +32,7 @@ import net.yacy.cora.document.UTF8;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.services.federated.solr.ShardSelection;
import net.yacy.cora.services.federated.solr.ShardSolrConnector;
import net.yacy.cora.services.federated.solr.SingleSolrConnector;
import net.yacy.cora.services.federated.solr.RemoteSolrConnector;
import net.yacy.cora.services.federated.solr.SolrConnector;
import net.yacy.cora.storage.ConfigurationSet;
import net.yacy.kelondro.logging.Log;
@ -175,8 +175,8 @@ public class IndexFederated_p {
} else {
prop.put("table", 1);
final SolrConnector solr = sb.index.fulltext().getRemoteSolr();
final long[] size = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getSizeList() : new long[]{((SingleSolrConnector) solr).getSize()};
final String[] urls = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getAdminInterfaceList() : new String[]{((SingleSolrConnector) solr).getAdminInterface()};
final long[] size = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getSizeList() : new long[]{((RemoteSolrConnector) solr).getSize()};
final String[] urls = (solr instanceof ShardSolrConnector) ? ((ShardSolrConnector) solr).getAdminInterfaceList() : new String[]{((RemoteSolrConnector) solr).getAdminInterface()};
boolean dark = false;
for (int i = 0; i < size.length; i++) {
prop.put("table_list_" + i + "_dark", dark ? 1 : 0); dark = !dark;

@ -40,7 +40,7 @@ public class MultipleSolrConnector implements SolrConnector {
private int commitWithinMs;
public MultipleSolrConnector(final String url, int connections) throws IOException {
this.solr = new SingleSolrConnector(url);
this.solr = new RemoteSolrConnector(url);
this.queue = new ArrayBlockingQueue<SolrInputDocument>(1000);
this.worker = new AddWorker[connections];
this.commitWithinMs = 180000;
@ -53,7 +53,7 @@ public class MultipleSolrConnector implements SolrConnector {
private class AddWorker extends Thread {
private final SolrConnector solr;
public AddWorker(final String url) throws IOException {
this.solr = new SingleSolrConnector(url);
this.solr = new RemoteSolrConnector(url);
this.solr.setCommitWithinMs(MultipleSolrConnector.this.commitWithinMs);
}
@Override

@ -44,7 +44,7 @@ import org.apache.http.protocol.HttpContext;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
public class SingleSolrConnector extends AbstractSolrConnector implements SolrConnector {
public class RemoteSolrConnector extends AbstractSolrConnector implements SolrConnector {
private final String solrurl, host, solrpath, solraccount, solrpw;
private final int port;
@ -55,7 +55,7 @@ public class SingleSolrConnector extends AbstractSolrConnector implements SolrCo
* @param scheme
* @throws IOException
*/
public SingleSolrConnector(final String url) throws IOException {
public RemoteSolrConnector(final String url) throws IOException {
super();
this.solrurl = url;
@ -115,9 +115,9 @@ public class SingleSolrConnector extends AbstractSolrConnector implements SolrCo
}
public static void main(final String args[]) {
SingleSolrConnector solr;
RemoteSolrConnector solr;
try {
solr = new SingleSolrConnector("http://127.0.0.1:8983/solr");
solr = new RemoteSolrConnector("http://127.0.0.1:8983/solr");
solr.clear();
final File exampleDir = new File("test/parsertest/");
long t, t0, a = 0;

@ -50,7 +50,7 @@ public class ShardSolrConnector implements SolrConnector {
this.connectors = new ArrayList<SolrConnector>();
SolrConnector s;
for (final String u: this.urls) {
s = multipleConnections ? new MultipleSolrConnector(u.trim(), 2) : new SingleSolrConnector(u.trim());
s = multipleConnections ? new MultipleSolrConnector(u.trim(), 2) : new RemoteSolrConnector(u.trim());
this.connectors.add(new RetrySolrConnector(s, timeout));
}
this.sharding = new ShardSelection(method, this.urls.length);

Loading…
Cancel
Save