Apache Solr open-source search software
SOLR-1018 -- Slave is unable to replicate when server acts as repeater (as both master and slave)
Shalin Shekhar Mangar5cfb336f5ca9
diff --git a/CHANGES.txt b/CHANGES.txtindex 3d4a6d49efe..d0cc42b8e0f 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -261,6 +261,9 @@ Bug Fixes31. SOLR-1015: Incomplete information in replication admin page and http command response when serveris both master and slave i.e. when server is a repeater (Akshay Ukey via shalin)+32. SOLR-1018: Slave is unable to replicate when server acts as repeater (as both master and slave)+ (Akshay Ukey, Noble Paul via shalin)+Other Changes----------------------diff --git a/src/java/org/apache/solr/handler/ReplicationHandler.java b/src/java/org/apache/solr/handler/ReplicationHandler.javaindex 4a1bed3ef47..a2669deafdc 100644--- a/src/java/org/apache/solr/handler/ReplicationHandler.java+++ b/src/java/org/apache/solr/handler/ReplicationHandler.java@@ -83,7 +83,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAwprivate boolean replicateOnCommit = false;private boolean replicateOnStart = false;-+private int numTimesReplicated = 0;private final Map<String, FileInfo> confFileInfoCache = new HashMap<String, FileInfo>();@@ -520,7 +520,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAwmaster.add("replicatableIndexVersion", commit.getVersion());master.add("replicatableGeneration", commit.getGeneration());}-+SnapPuller snapPuller = tempSnapPuller;if (snapPuller != null) {try {@@ -670,6 +670,16 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAwreturn details;}+ void refreshCommitpoint(){+ IndexCommit commitPoint = core.getDeletionPolicy().getLatestCommit();+ if(replicateOnCommit && !commitPoint.isOptimized()){+ indexCommitPoint = commitPoint;+ }+ if(replicateOnOptimize && commitPoint.isOptimized()){+ indexCommitPoint = commitPoint;+ }+ }+@SuppressWarnings("unchecked")public void inform(SolrCore core) {this.core = core;@@ -717,7 +727,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAwLOG.warn("The update handler being used is not an instance or sub-class of DirectUpdateHandler2. " +"Replicate on Startup cannot work.");}- indexCommitPoint = s.get().getReader().getIndexCommit();+ if(s.get().getReader().getIndexCommit() != null)+ if(s.get().getReader().getIndexCommit().getGeneration() != 1L)+ indexCommitPoint = s.get().getReader().getIndexCommit();} catch (IOException e) {LOG.warn("Unable to get IndexCommit on startup", e);} finally {diff --git a/src/java/org/apache/solr/handler/SnapPuller.java b/src/java/org/apache/solr/handler/SnapPuller.javaindex 3a5a3f4a6cb..f86df506f49 100644--- a/src/java/org/apache/solr/handler/SnapPuller.java+++ b/src/java/org/apache/solr/handler/SnapPuller.java@@ -354,6 +354,7 @@ public class SnapPuller {LOG.info("Force open index writer to make sure older index files get deleted");DirectUpdateHandler2 handler = (DirectUpdateHandler2) solrCore.getUpdateHandler();handler.forceOpenWriter();+ replicationHandler.refreshCommitpoint();} else {LOG.warn("The update handler is not an instance or sub-class of DirectUpdateHandler2. " +"ReplicationHandler may not be able to cleanup un-used index files.");