lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject svn commit: r808305 - in /lucene/solr/trunk/src/java/org/apache/solr/handler: ReplicationHandler.java SnapPuller.java
Date Thu, 27 Aug 2009 07:19:11 GMT
Author: noble
Date: Thu Aug 27 07:19:11 2009
New Revision: 808305

URL: http://svn.apache.org/viewvc?rev=808305&view=rev
Log:
SOLR-1355 add an enable value in master/slave configuration

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/handler/ReplicationHandler.java
    lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.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=808305&r1=808304&r2=808305&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 Thu Aug 27
07:19:11 2009
@@ -171,7 +171,7 @@
     } else if (command.equals(CMD_SHOW_COMMITS)) {
       rsp.add(CMD_SHOW_COMMITS, getCommits());
     } else if (command.equals(CMD_DETAILS)) {
-      rsp.add(CMD_DETAILS, getReplicationDetails());
+      rsp.add(CMD_DETAILS, getReplicationDetails(solrParams.getBool("slave",true)));
       RequestHandlerUtils.addExperimentalFormatWarning(rsp);
     } else if (CMD_ENABLE_REPL.equalsIgnoreCase(command)) {
       replicationEnabled.set(true);
@@ -523,8 +523,9 @@
 
   /**
    * Used for showing statistics and progress information.
+   * @param showSlaveDetails
    */
-  NamedList<Object> getReplicationDetails() {
+  private NamedList<Object> getReplicationDetails(boolean showSlaveDetails) {
     String timeLastReplicated = "", confFilesReplicated = "", confFilesReplicatedTime = "",
timesIndexReplicated = "", timesConfigReplicated = "";
     NamedList<Object> details = new SimpleOrderedMap<Object>();
     NamedList<Object> master = new SimpleOrderedMap<Object>();
@@ -563,7 +564,7 @@
     }
 
     SnapPuller snapPuller = tempSnapPuller;
-    if (snapPuller != null) {
+    if (showSlaveDetails && snapPuller != null) {
       try {
         Properties props = new Properties();
         File f = new File(core.getDataDir(), SnapPuller.REPLICATION_PROPERTIES);
@@ -586,10 +587,14 @@
         IOUtils.closeQuietly(inFile);
       }
       try {
-        NamedList nl = snapPuller.getCommandResponse(CMD_DETAILS);
+        NamedList<String> command = new NamedList<String>();
+        command.add(COMMAND,CMD_DETAILS);
+        command.add("slave","false");
+        NamedList nl = snapPuller.getCommandResponse(command);
         slave.add("masterDetails", nl.get(CMD_DETAILS));
-      } catch (IOException e) {
+      } catch (Exception e) {
         LOG.warn("Exception while invoking a 'details' method on master ", e);
+        slave.add(ERR_STATUS,"invalid_master");
       }
       slave.add(MASTER_URL, snapPuller.getMasterUrl());
       if (snapPuller.getPollInterval() != null) {
@@ -706,7 +711,7 @@
     }
     if(isMaster)
       details.add("master", master);
-    if(isSlave)
+    if(isSlave && showSlaveDetails)
       details.add("slave", slave);
     NamedList snapshotStats = snapShootDetails;
     if (snapshotStats != null)
@@ -730,12 +735,14 @@
     registerFileStreamResponseWriter();
     registerCloseHook();
     NamedList slave = (NamedList) initArgs.get("slave");
-    if (slave != null) {
+    boolean enableSlave = slave != null && (null == slave.get("enable") || "true".equals(slave.get("enable")));
+    if (enableSlave) {
       tempSnapPuller = snapPuller = new SnapPuller(slave, this, core);
       isSlave = true;
     }
     NamedList master = (NamedList) initArgs.get("master");
-    if (master != null) {
+    boolean enableMaster = master != null && (null == master.get("enable") || "true".equals(master.get("enable")));
+    if (enableMaster) {
       includeConfFiles = (String) master.get(CONF_FILES);
       if (includeConfFiles != null && includeConfFiles.trim().length() > 0) {
         List<String> files = Arrays.asList(includeConfFiles.split(","));

Modified: lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java?rev=808305&r1=808304&r2=808305&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/handler/SnapPuller.java Thu Aug 27 07:19:11
2009
@@ -180,9 +180,11 @@
     return getNamedListResponse(post);
   }
 
-  NamedList getCommandResponse(String cmd) throws IOException {
+  NamedList getCommandResponse(NamedList<String> commands) throws IOException {
     PostMethod post = new PostMethod(masterUrl);
-    post.addParameter(COMMAND, cmd);
+    for (Map.Entry<String, String> c : commands) {
+      post.addParameter(c.getKey(),c.getValue());
+    } 
     post.addParameter("wt", "javabin");
     return getNamedListResponse(post);
   }



Mime
View raw message