SOLR-1175 disable/enable replication from master

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@776978 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-05-21 06:58:01 +00:00
parent 4c6d63f975
commit b17d5bc816
2 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -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";