diff --git a/CHANGES.txt b/CHANGES.txt index fe658651cfb..29f2d0899d0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -219,6 +219,8 @@ New Features 52. SOLR-769: Added support for clustering in contrib/clustering. See http://wiki.apache.org/solr/ClusteringComponent for more info. (gsingers, Stanislaw Osinski) +53. SOLR-1175: disable/enable replication on master side. added two commands 'enableReplication' and 'disableReplication' + Optimizations ---------------------- 1. SOLR-374: Use IndexReader.reopen to save resources by re-using parts of the diff --git a/src/java/org/apache/solr/handler/ReplicationHandler.java b/src/java/org/apache/solr/handler/ReplicationHandler.java index 82de402c491..578ab6e64fa 100644 --- a/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -44,6 +44,7 @@ import java.nio.channels.FileChannel; import java.text.NumberFormat; import java.util.*; import java.util.concurrent.locks.ReentrantLock; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.zip.Adler32; import java.util.zip.Checksum; import java.util.zip.DeflaterOutputStream; @@ -93,7 +94,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw private volatile IndexCommit indexCommitPoint; - volatile NamedList snapShootDetails; + volatile NamedList snapShootDetails; + + private AtomicBoolean replicationEnabled = new AtomicBoolean(true); public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { rsp.setHttpCaching(false); @@ -105,9 +108,13 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } // This command does not give the current index version of the master // It gives the current 'replicateable' index version - if (command.equals(CMD_INDEX_VERSION)) { + if(CMD_ENABLE_REPL.equalsIgnoreCase(command)){ + replicationEnabled.set(true); + } else if(CMD_DISABLE_REPL.equalsIgnoreCase(command)){ + replicationEnabled.set(false); + } else if (command.equals(CMD_INDEX_VERSION)) { IndexCommit commitPoint = indexCommitPoint; // make a copy so it won't change - if (commitPoint != null) { + if (commitPoint != null && replicationEnabled.get()) { rsp.add(CMD_INDEX_VERSION, commitPoint.getVersion()); rsp.add(GENERATION, commitPoint.getGeneration()); } else { @@ -950,6 +957,10 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw public static final String CMD_DISABLE_POLL = "disablepoll"; + public static final String CMD_DISABLE_REPL = "disablereplication"; + + public static final String CMD_ENABLE_REPL = "enablereplication"; + public static final String CMD_ENABLE_POLL = "enablepoll"; public static final String CMD_INDEX_VERSION = "indexversion";