SOLR-4032: Files larger than an internal buffer size fail to replicate.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1414428 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-11-27 22:05:18 +00:00
parent 01cfcca8a6
commit 862335a772
3 changed files with 19 additions and 12 deletions

View File

@ -69,6 +69,9 @@ New Features
* SOLR-3911: Make Directory and DirectoryFactory first class so that the majority * SOLR-3911: Make Directory and DirectoryFactory first class so that the majority
of Solr's features work with any custom implementations. (Mark Miller) of Solr's features work with any custom implementations. (Mark Miller)
Additional Work:
- SOLR-4032: Files larger than an internal buffer size fail to replicate.
(Mark Miller, Markus Jelsma)
* SOLR-1972: Add extra statistics to RequestHandlers - 5 & 15-minute reqs/sec * SOLR-1972: Add extra statistics to RequestHandlers - 5 & 15-minute reqs/sec
rolling averages; median, 75th, 95th, 99th, 99.9th percentile request times rolling averages; median, 75th, 95th, 99th, 99.9th percentile request times

View File

@ -1062,7 +1062,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
while (true) { while (true) {
offset = offset == -1 ? 0 : offset; offset = offset == -1 ? 0 : offset;
int read = (int) Math.min(buf.length, filelen - offset); int read = (int) Math.min(buf.length, filelen - offset);
in.readBytes(buf, offset == -1 ? 0 : (int) offset, read); in.readBytes(buf, 0, read);
fos.writeInt((int) read); fos.writeInt((int) read);
if (useChecksum) { if (useChecksum) {
@ -1082,6 +1082,8 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw
fos.close(); fos.close();
break; break;
} }
offset += read;
in.seek(offset);
} }
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Exception while writing response for params: " + params, e); LOG.warn("Exception while writing response for params: " + params, e);

View File

@ -656,6 +656,8 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
} }
private void doTestReplicateAfterCoreReload() throws Exception { private void doTestReplicateAfterCoreReload() throws Exception {
int docs = TEST_NIGHTLY ? 200000 : 0;
//stop slave //stop slave
slaveJetty.stop(); slaveJetty.stop();
@ -670,14 +672,14 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
masterClient = createNewSolrServer(masterJetty.getLocalPort()); masterClient = createNewSolrServer(masterJetty.getLocalPort());
masterClient.deleteByQuery("*:*"); masterClient.deleteByQuery("*:*");
for (int i = 0; i < 10; i++) for (int i = 0; i < docs; i++)
index(masterClient, "id", i, "name", "name = " + i); index(masterClient, "id", i, "name", "name = " + i);
masterClient.commit(); masterClient.commit();
NamedList masterQueryRsp = rQuery(10, "*:*", masterClient); NamedList masterQueryRsp = rQuery(docs, "*:*", masterClient);
SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response"); SolrDocumentList masterQueryResult = (SolrDocumentList) masterQueryRsp.get("response");
assertEquals(10, masterQueryResult.getNumFound()); assertEquals(docs, masterQueryResult.getNumFound());
slave.setTestPort(masterJetty.getLocalPort()); slave.setTestPort(masterJetty.getLocalPort());
slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml"); slave.copyConfigFile(slave.getSolrConfigFile(), "solrconfig.xml");
@ -687,9 +689,9 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
slaveClient = createNewSolrServer(slaveJetty.getLocalPort()); slaveClient = createNewSolrServer(slaveJetty.getLocalPort());
//get docs from slave and check if number is equal to master //get docs from slave and check if number is equal to master
NamedList slaveQueryRsp = rQuery(10, "*:*", slaveClient); NamedList slaveQueryRsp = rQuery(docs, "*:*", slaveClient);
SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response"); SolrDocumentList slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(10, slaveQueryResult.getNumFound()); assertEquals(docs, slaveQueryResult.getNumFound());
//compare results //compare results
String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult, slaveQueryResult, 0, null); String cmp = BaseDistributedSearchTestCase.compare(masterQueryResult, slaveQueryResult, 0, null);
@ -703,19 +705,19 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
assertEquals(version, getIndexVersion(masterClient).get("indexversion")); assertEquals(version, getIndexVersion(masterClient).get("indexversion"));
assertEquals(commits.get("commits"), getCommits(masterClient).get("commits")); assertEquals(commits.get("commits"), getCommits(masterClient).get("commits"));
index(masterClient, "id", 110, "name", "name = 1"); index(masterClient, "id", docs + 10, "name", "name = 1");
index(masterClient, "id", 120, "name", "name = 2"); index(masterClient, "id", docs + 20, "name", "name = 2");
masterClient.commit(); masterClient.commit();
NamedList resp = rQuery(12, "*:*", masterClient); NamedList resp = rQuery(docs + 2, "*:*", masterClient);
masterQueryResult = (SolrDocumentList) resp.get("response"); masterQueryResult = (SolrDocumentList) resp.get("response");
assertEquals(12, masterQueryResult.getNumFound()); assertEquals(docs + 2, masterQueryResult.getNumFound());
//get docs from slave and check if number is equal to master //get docs from slave and check if number is equal to master
slaveQueryRsp = rQuery(12, "*:*", slaveClient); slaveQueryRsp = rQuery(docs + 2, "*:*", slaveClient);
slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response"); slaveQueryResult = (SolrDocumentList) slaveQueryRsp.get("response");
assertEquals(12, slaveQueryResult.getNumFound()); assertEquals(docs + 2, slaveQueryResult.getNumFound());
// NOTE: revert config on master. // NOTE: revert config on master.
master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml"); master.copyConfigFile(CONF_DIR + "solrconfig-master.xml", "solrconfig.xml");