SOLR-3131: "details" command fails when a replication is forced with a "fetchIndex" command on a non-slave server

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1245231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-02-16 22:46:15 +00:00
parent 851f4f647b
commit efa20a5149
2 changed files with 29 additions and 4 deletions

View File

@ -296,7 +296,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
} catch (Exception e) {
SolrException.log(LOG, "SnapPull failed ", e);
} finally {
tempSnapPuller = snapPuller;
if (snapPuller != null) {
tempSnapPuller = snapPuller;
}
snapPullLock.unlock();
}
return false;
@ -444,6 +446,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
}
boolean isPollingDisabled() {
if (snapPuller == null) return true;
return snapPuller.isPollingDisabled();
}

View File

@ -27,7 +27,7 @@ import java.io.Writer;
import java.net.URL;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.io.IOUtils;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
@ -35,7 +35,6 @@ import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.SimpleFSDirectory;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.TestDistributedSearch;
import org.apache.solr.client.solrj.SolrServer;
@ -522,7 +521,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
} catch (IOException e) {
//e.printStackTrace();
}
//get docs from slave and check if number is equal to master
NamedList slaveQueryRsp = rQuery(nDocs, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
@ -531,6 +530,29 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
String cmp = TestDistributedSearch.compare(masterQueryResult, slaveQueryResult, 0, null);
assertEquals(null, cmp);
System.out.println("replicate slave to master");
// snappull from the slave to the master
for (int i = 0; i < 3; i++)
index(slaveClient, "id", i, "name", "name = " + i);
slaveClient.commit();
masterUrl = "http://localhost:" + masterJetty.getLocalPort() + "/solr/replication?command=fetchindex&masterUrl=";
masterUrl += "http://localhost:" + slaveJetty.getLocalPort() + "/solr/replication";
url = new URL(masterUrl);
stream = url.openStream();
try {
stream.close();
} catch (IOException e) {
//e.printStackTrace();
}
// get the details
// just ensures we don't get an exception
NamedList<Object> details = getDetails(masterClient);
//System.out.println("details:" + details);
// NOTE: at this point, the slave is not polling any more
// restore it.
slave.copyConfigFile(CONF_DIR + "solrconfig-slave.xml", "solrconfig.xml");