You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by no...@apache.org on 2009/07/15 10:40:19 UTC
svn commit: r794187 -
/lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java
Author: noble
Date: Wed Jul 15 08:40:19 2009
New Revision: 794187
URL: http://svn.apache.org/viewvc?rev=794187&view=rev
Log:
status message for each command
Modified:
lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java
Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java?rev=794187&r1=794186&r2=794187&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java Wed Jul 15 08:40:19 2009
@@ -103,15 +103,18 @@
final SolrParams solrParams = req.getParams();
String command = solrParams.get(COMMAND);
if (command == null) {
- rsp.add("status", "OK");
+ rsp.add(STATUS, OK_STATUS);
+ rsp.add("message", "No command");
return;
}
// This command does not give the current index version of the master
// It gives the current 'replicateable' index version
if(CMD_ENABLE_REPL.equalsIgnoreCase(command)){
replicationEnabled.set(true);
+ rsp.add(STATUS, OK_STATUS);
} else if(CMD_DISABLE_REPL.equalsIgnoreCase(command)){
replicationEnabled.set(false);
+ rsp.add(STATUS, OK_STATUS);
} else if (command.equals(CMD_INDEX_VERSION)) {
IndexCommit commitPoint = indexCommitPoint; // make a copy so it won't change
if (commitPoint != null && replicationEnabled.get()) {
@@ -128,23 +131,46 @@
} else if (command.equals(CMD_GET_FILE_LIST)) {
getFileList(solrParams, rsp);
} else if (command.equalsIgnoreCase(CMD_BACKUP)) {
- doSnapShoot(solrParams, rsp);
+ doSnapShoot(new ModifiableSolrParams(solrParams), rsp);
+ rsp.add(STATUS, OK_STATUS);
} else if (command.equalsIgnoreCase(CMD_FETCH_INDEX)) {
+ String masterUrl = solrParams.get(MASTER_URL);
+ if (!isSlave && masterUrl == null) {
+ rsp.add(STATUS,ERR_STATUS);
+ rsp.add("message","No slave configured or no 'masterUrl' Specified");
+ return;
+ }
+ final SolrParams paramsCopy = new ModifiableSolrParams(solrParams);
new Thread() {
public void run() {
- doSnapPull(solrParams);
+ doSnapPull(paramsCopy);
}
}.start();
- rsp.add("status", "OK");
+ rsp.add(STATUS, OK_STATUS);
} else if (command.equalsIgnoreCase(CMD_DISABLE_POLL)) {
- if (snapPuller != null)
+ if (snapPuller != null){
snapPuller.disablePoll();
+ rsp.add(STATUS, OK_STATUS);
+ } else {
+ rsp.add(STATUS, ERR_STATUS);
+ rsp.add("message","No slave configured");
+ }
} else if (command.equalsIgnoreCase(CMD_ENABLE_POLL)) {
- if (snapPuller != null)
+ if (snapPuller != null){
snapPuller.enablePoll();
+ rsp.add(STATUS, OK_STATUS);
+ }else {
+ rsp.add(STATUS,ERR_STATUS);
+ rsp.add("message","No slave configured");
+ }
} else if (command.equalsIgnoreCase(CMD_ABORT_FETCH)) {
- if (snapPuller != null)
+ if (snapPuller != null){
snapPuller.abortPull();
+ rsp.add(STATUS, OK_STATUS);
+ } else {
+ rsp.add(STATUS,ERR_STATUS);
+ rsp.add("message","No slave configured");
+ }
} else if (command.equals(CMD_FILE_CHECKSUM)) {
// this command is not used by anyone
getFileChecksum(solrParams, rsp);
@@ -220,8 +246,6 @@
void doSnapPull(SolrParams solrParams) {
String masterUrl = solrParams == null ? null : solrParams.get(MASTER_URL);
- if (!isSlave && masterUrl == null)
- return;
if (!snapPullLock.tryLock())
return;
try {
@@ -939,6 +963,8 @@
public static final String MASTER_URL = "masterUrl";
+ public static final String STATUS = "status";
+
public static final String COMMAND = "command";
public static final String CMD_DETAILS = "details";
@@ -1005,4 +1031,9 @@
public static final String INTERNAL = "internal";
+ public static final String ERR_STATUS = "ERROR";
+
+ public static final String OK_STATUS = "OK";
+
+
}