diff --git a/CHANGES.txt b/CHANGES.txt index 1b3b0cc1ffe..3d4a6d49efe 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -258,6 +258,9 @@ Bug Fixes 30. SOLR-1016: HTTP 503 error changes 500 in SolrCore (koji) +31. SOLR-1015: Incomplete information in replication admin page and http command response when server + is both master and slave i.e. when server is a repeater (Akshay Ukey via shalin) + Other Changes ---------------------- diff --git a/src/java/org/apache/solr/handler/ReplicationHandler.java b/src/java/org/apache/solr/handler/ReplicationHandler.java index 66ce2ecb703..4a1bed3ef47 100644 --- a/src/java/org/apache/solr/handler/ReplicationHandler.java +++ b/src/java/org/apache/solr/handler/ReplicationHandler.java @@ -82,6 +82,8 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw private boolean replicateOnCommit = false; + private boolean replicateOnStart = false; + private int numTimesReplicated = 0; private final Map confFileInfoCache = new HashMap(); @@ -139,7 +141,8 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } else if (command.equals(CMD_SHOW_COMMITS)) { rsp.add(CMD_SHOW_COMMITS, getCommits()); } else if (command.equals(CMD_DETAILS)) { - getReplicationDetails(rsp); + rsp.add(CMD_DETAILS, getReplicationDetails()); + RequestHandlerUtils.addExperimentalFormatWarning(rsp); } } @@ -443,11 +446,12 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw if (core != null) { list.add("indexSize", readableSize(getIndexSize())); long[] versionGen = getIndexVersion(); - list.add(CMD_INDEX_VERSION, versionGen[0]); + list.add("indexVersion", versionGen[0]); list.add(GENERATION, versionGen[1]); list.add("indexPath", core.getIndexDir()); list.add("isMaster", String.valueOf(isMaster)); + list.add("isSlave", String.valueOf(isSlave)); SnapPuller snapPuller = tempSnapPuller; if (snapPuller != null) { @@ -461,10 +465,16 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw if (isMaster) { if (includeConfFiles != null) list.add("confFilesToReplicate", includeConfFiles); + String replicateAfterString=""; if (replicateOnCommit) - list.add(REPLICATE_AFTER, "commit"); + replicateAfterString += "commit, "; if (replicateOnOptimize) - list.add(REPLICATE_AFTER, "optimize"); + replicateAfterString += "optimize, "; + if(replicateOnStart) + replicateAfterString += "startup, "; + if(replicateAfterString.lastIndexOf(',') > -1) + replicateAfterString = replicateAfterString.substring(0, replicateAfterString.lastIndexOf(',')); + list.add(REPLICATE_AFTER, replicateAfterString); } } return list; @@ -473,23 +483,44 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw /** * Used for showing statistics and progress information. */ - void getReplicationDetails(SolrQueryResponse resp) { + NamedList getReplicationDetails() { String timeLastReplicated = "", confFilesReplicated = "", confFilesReplicatedTime = "", timesIndexReplicated = "", timesConfigReplicated = ""; NamedList details = new SimpleOrderedMap(); + NamedList master = new SimpleOrderedMap(); + NamedList slave = new SimpleOrderedMap(); FileInputStream inFile = null; details.add("indexSize", readableSize(getIndexSize())); details.add("indexPath", core.getIndexDir()); details.add(CMD_SHOW_COMMITS, getCommits()); details.add("isMaster", String.valueOf(isMaster)); + details.add("isSlave", String.valueOf(isSlave)); long[] versionAndGeneration = getIndexVersion(); - details.add(CMD_INDEX_VERSION, versionAndGeneration[0]); + details.add("indexVersion", versionAndGeneration[0]); details.add(GENERATION, versionAndGeneration[1]); + IndexCommit commit = indexCommitPoint; // make a copy so it won't change - if (isMaster && commit != null) { - details.add("replicatable" + CMD_INDEX_VERSION, commit.getVersion()); - details.add("replicatable" + GENERATION, commit.getGeneration()); + + if (isMaster) { + if (includeConfFiles != null) + master.add(CONF_FILES, includeConfFiles); + String replicateAfterString=""; + if (replicateOnCommit) + replicateAfterString += "commit, "; + if (replicateOnOptimize) + replicateAfterString += "optimize, "; + if(replicateOnStart) + replicateAfterString += "startup, "; + if(replicateAfterString.lastIndexOf(',') > -1) + replicateAfterString = replicateAfterString.substring(0, replicateAfterString.lastIndexOf(',')); + master.add(REPLICATE_AFTER, replicateAfterString); } + + if (isMaster && commit != null) { + master.add("replicatableIndexVersion", commit.getVersion()); + master.add("replicatableGeneration", commit.getGeneration()); + } + SnapPuller snapPuller = tempSnapPuller; if (snapPuller != null) { try { @@ -515,36 +546,36 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw } try { NamedList nl = snapPuller.getCommandResponse(CMD_DETAILS); - details.add("masterDetails", nl.get(CMD_DETAILS)); + slave.add("masterDetails", nl.get(CMD_DETAILS)); } catch (IOException e) { LOG.warn("Exception while invoking a 'details' method on master ", e); } - details.add(MASTER_URL, snapPuller.getMasterUrl()); + slave.add(MASTER_URL, snapPuller.getMasterUrl()); if (snapPuller.getPollInterval() != null) { - details.add(SnapPuller.POLL_INTERVAL, snapPuller.getPollInterval()); + slave.add(SnapPuller.POLL_INTERVAL, snapPuller.getPollInterval()); } if (snapPuller.getNextScheduledExecTime() != null && !isPollingDisabled()) { Date d = new Date(snapPuller.getNextScheduledExecTime()); - details.add("nextExecutionAt", d.toString()); + slave.add("nextExecutionAt", d.toString()); } else if (isPollingDisabled()) { - details.add("nextExecutionAt", "Polling disabled"); + slave.add("nextExecutionAt", "Polling disabled"); } else - details.add("nextExecutionAt", ""); + slave.add("nextExecutionAt", ""); if (timeLastReplicated != null && timeLastReplicated.length() > 0) { Date d = new Date(Long.valueOf(timeLastReplicated)); - details.add("indexReplicatedAt", d.toString()); + slave.add("indexReplicatedAt", d.toString()); } else { - details.add("indexReplicatedAt", ""); + slave.add("indexReplicatedAt", ""); } - details.add("timesIndexReplicated", timesIndexReplicated); - details.add("confFilesReplicated", confFilesReplicated); - details.add("timesConfigReplicated", timesConfigReplicated); + slave.add("timesIndexReplicated", timesIndexReplicated); + slave.add("confFilesReplicated", confFilesReplicated); + slave.add("timesConfigReplicated", timesConfigReplicated); if (confFilesReplicatedTime != null && confFilesReplicatedTime.length() > 0) { Date d = new Date(Long.valueOf(confFilesReplicatedTime)); - details.add("confFilesReplicatedAt", d.toString()); + slave.add("confFilesReplicatedAt", d.toString()); } else { - details.add("confFilesReplicatedAt", confFilesReplicatedTime); + slave.add("confFilesReplicatedAt", confFilesReplicatedTime); } try { @@ -563,9 +594,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw bytesToDownload += (Long) file.get(SIZE); } - details.add("filesToDownload", filesToDownload.toString()); - details.add("numFilesToDownload", String.valueOf(filesToDownload.size())); - details.add("bytesToDownload", readableSize(bytesToDownload)); + slave.add("filesToDownload", filesToDownload.toString()); + slave.add("numFilesToDownload", String.valueOf(filesToDownload.size())); + slave.add("bytesToDownload", readableSize(bytesToDownload)); long bytesDownloaded = 0; List filesDownloaded = new ArrayList(); @@ -580,8 +611,8 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw bytesDownloaded += (Long) file.get(SIZE); } - details.add("filesDownloaded", filesDownloaded.toString()); - details.add("numFilesDownloaded", String.valueOf(filesDownloaded.size())); + slave.add("filesDownloaded", filesDownloaded.toString()); + slave.add("numFilesDownloaded", String.valueOf(filesDownloaded.size())); Map currentFile = snapPuller.getCurrentFile(); String currFile = null; @@ -605,9 +636,9 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw timeElapsed = (System.currentTimeMillis() - snapPuller.getReplicationStartTime()) / 1000; } if (replicationStartTime != null) { - details.add("replicationStartTime", replicationStartTime.toString()); + slave.add("replicationStartTime", replicationStartTime.toString()); } - details.add("timeElapsed", String.valueOf(timeElapsed) + "s"); + slave.add("timeElapsed", String.valueOf(timeElapsed) + "s"); if (bytesDownloaded > 0) estimatedTimeRemaining = ((bytesToDownload - bytesDownloaded) * timeElapsed) / bytesDownloaded; @@ -618,31 +649,25 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw if (timeElapsed > 0) downloadSpeed = (bytesDownloaded / timeElapsed); if (currFile != null) - details.add("currentFile", currFile); - details.add("currentFileSize", readableSize(currFileSize)); - details.add("currentFileSizeDownloaded", readableSize(currFileSizeDownloaded)); - details.add("currentFileSizePercent", String.valueOf(percentDownloaded)); - details.add("bytesDownloaded", readableSize(bytesDownloaded)); - details.add("totalPercent", String.valueOf(totalPercent)); - details.add("timeRemaining", String.valueOf(estimatedTimeRemaining) + "s"); - details.add("downloadSpeed", readableSize(downloadSpeed)); - details.add("isPollingDisabled", String.valueOf(isPollingDisabled())); - details.add("isReplicating", String.valueOf(isReplicating())); + slave.add("currentFile", currFile); + slave.add("currentFileSize", readableSize(currFileSize)); + slave.add("currentFileSizeDownloaded", readableSize(currFileSizeDownloaded)); + slave.add("currentFileSizePercent", String.valueOf(percentDownloaded)); + slave.add("bytesDownloaded", readableSize(bytesDownloaded)); + slave.add("totalPercent", String.valueOf(totalPercent)); + slave.add("timeRemaining", String.valueOf(estimatedTimeRemaining) + "s"); + slave.add("downloadSpeed", readableSize(downloadSpeed)); + slave.add("isPollingDisabled", String.valueOf(isPollingDisabled())); + slave.add("isReplicating", String.valueOf(isReplicating())); } catch (Exception e) { LOG.error("Exception while writing details: ", e); } } - - if (isMaster) { - if (includeConfFiles != null) - details.add(CONF_FILES, includeConfFiles); - if (replicateOnCommit) - details.add(REPLICATE_AFTER, "commit"); - if (replicateOnOptimize) - details.add(REPLICATE_AFTER, "optimize"); - } - - resp.add(CMD_DETAILS, details); + if(isMaster) + details.add("master", master); + if(isSlave) + details.add("slave", slave); + return details; } @SuppressWarnings("unchecked") @@ -683,6 +708,7 @@ public class ReplicationHandler extends RequestHandlerBase implements SolrCoreAw core.getUpdateHandler().registerCommitCallback(getEventListener(snapshotOnCommit, replicateOnCommit)); } if (replicateAfter.contains("startup")) { + replicateOnStart = true; RefCounted s = core.getNewestSearcher(false); try { if (core.getUpdateHandler() instanceof DirectUpdateHandler2) { diff --git a/src/webapp/web/admin/replication/header.jsp b/src/webapp/web/admin/replication/header.jsp index 9da02e1defe..58689c1a5ad 100644 --- a/src/webapp/web/admin/replication/header.jsp +++ b/src/webapp/web/admin/replication/header.jsp @@ -55,12 +55,11 @@ public NamedList executeCommand(String command, SolrCore core, SolrRequestHandle %> <% - final SolrRequestHandler rh = core.getRequestHandler("/replication"); NamedList namedlist = executeCommand("details",core,rh); NamedList detailsMap = (NamedList)namedlist.get("details"); - -if("false".equals((String)detailsMap.get("isMaster"))){ +if(detailsMap != null) +if("true".equals((String)detailsMap.get("isSlave"))){ %> <%}%> @@ -70,11 +69,16 @@ if("false".equals((String)detailsMap.get("isMaster"))){ Solr

Solr replication (<%= collectionName %>) + <% -if("true".equals((String)detailsMap.get("isMaster"))) - out.println(" Master"); - else - out.println(" Slave"); +if(detailsMap != null){ + if( "true".equals(detailsMap.get("isMaster")) && "true".equals(detailsMap.get("isSlave"))) + out.println(" Master & Slave"); + else if("true".equals(detailsMap.get("isMaster"))) + out.println(" Master"); + else if("true".equals(detailsMap.get("isSlave"))) + out.println(" Slave"); +} %>

<%= hostname %>:<%= port %>
diff --git a/src/webapp/web/admin/replication/index.jsp b/src/webapp/web/admin/replication/index.jsp index a4c967bc690..629d246654a 100644 --- a/src/webapp/web/admin/replication/index.jsp +++ b/src/webapp/web/admin/replication/index.jsp @@ -19,8 +19,7 @@ <%-- do a verbatim include so we can use the local vars --%> -<%@include file="header.jsp" - %> +<%@include file="header.jsp"%>
@@ -31,30 +30,36 @@ %> <% - if ("false".equals(detailsMap.get("isMaster"))) - if (detailsMap != null) {%> +NamedList slave = null, master = null; +if (detailsMap != null) + if ("true".equals(detailsMap.get("isSlave"))) + if(detailsMap.get("slave") != null){ + slave = (NamedList)detailsMap.get("slave");%> <% - NamedList nl = (NamedList) detailsMap.get("masterDetails"); + NamedList nl = (NamedList) slave.get("masterDetails"); if (nl != null) { - long masterVersion = (Long) nl.get("indexversion"); + long masterVersion = (Long) nl.get("indexVersion"); long masterGeneration = (Long) nl.get("generation"); long replicatableMasterVer = 0, replicatableMasterGen = 0; - if (nl.get("replicatableindexversion") != null) - replicatableMasterVer = (Long) nl.get("replicatableindexversion"); - if (nl.get("replicatablegeneration") != null) - replicatableMasterGen = (Long) nl.get("replicatablegeneration"); + nl = (NamedList) nl.get("master"); + if(nl != null){ + if (nl.get("replicatableindexversion") != null) + replicatableMasterVer = (Long) nl.get("replicatableindexversion"); + if (nl.get("replicatablegeneration") != null) + replicatableMasterGen = (Long) nl.get("replicatablegeneration"); + } %> @@ -75,7 +80,7 @@ @@ -88,7 +93,7 @@ @@ -113,34 +118,36 @@ <% - if ("true".equals(detailsMap.get("isMaster"))) - if (detailsMap != null) { + if (detailsMap != null) + if ("true".equals(detailsMap.get("isMaster"))) + if(detailsMap.get("master") != null){ + master = (NamedList) detailsMap.get("master"); %> <%}%> <% - if ("false".equals(detailsMap.get("isMaster"))) - if (detailsMap != null) {%> + if ("true".equals(detailsMap.get("isSlave"))) + if (slave != null) {%> @@ -150,7 +157,7 @@ @@ -160,7 +167,7 @@ @@ -170,7 +177,7 @@ @@ -180,7 +187,7 @@ @@ -190,27 +197,31 @@ <% - if ("true".equals(detailsMap.get("isReplicating"))) { + if ("true".equals(slave.get("isReplicating"))) { %> @@ -218,7 +229,7 @@ @@ -226,7 +237,7 @@ @@ -234,7 +245,7 @@ @@ -242,7 +253,7 @@ <%}%> @@ -257,7 +268,8 @@ executeCommand("disablepoll", core, rh); else if (pollVal.equals("enable")) executeCommand("enablepoll", core, rh); - if ("false".equals(detailsMap.get("isPollingDisabled"))) { + if(slave != null) + if ("false".equals(slave.get("isPollingDisabled"))) { %> @@ -267,7 +279,8 @@ <%}%> <% - if ("true".equals(detailsMap.get("isPollingDisabled"))) { + if(slave != null) + if ("true".equals(slave.get("isPollingDisabled"))) { %> @@ -289,7 +302,8 @@ <% - if ("true".equals(detailsMap.get("isReplicating"))) { + if(slave != null) + if ("true".equals(slave.get("isReplicating"))) { %>
Master <% - out.println((String) detailsMap.get("masterUrl")); + out.println((String) slave.get("masterUrl")); %>
<% - out.println((String) detailsMap.get("pollInterval")); + out.println((String) slave.get("pollInterval")); %>
<% if (detailsMap != null) - out.println("Index Version: " + detailsMap.get("indexversion") + ", Generation: " + detailsMap.get("generation")); + out.println("Index Version: " + detailsMap.get("indexVersion") + ", Generation: " + detailsMap.get("generation")); %>
- <%out.println("Config Files To Replicate: " + detailsMap.get("confFiles"));%> + <%out.println("Config Files To Replicate: " + master.get("confFiles"));%>
- <%out.println("Trigger Replication On: " + detailsMap.get("replicateAfter")); %> + <%out.println("Trigger Replication On: " + master.get("replicateAfter")); %>
<% - out.println("Times Replicated Since Startup: " + detailsMap.get("timesIndexReplicated")); + out.println("Times Replicated Since Startup: " + slave.get("timesIndexReplicated")); %>
<% - out.println("Previous Replication Done At: " + detailsMap.get("indexReplicatedAt")); + out.println("Previous Replication Done At: " + slave.get("indexReplicatedAt")); %>
<% - out.println("Config Files Replicated At: " + detailsMap.get("confFilesReplicatedAt")); + out.println("Config Files Replicated At: " + slave.get("confFilesReplicatedAt")); %>
<% - out.println("Config Files Replicated: " + detailsMap.get("confFilesReplicated")); + out.println("Config Files Replicated: " + slave.get("confFilesReplicated")); %>
<% - out.println("Times Config Files Replicated Since Startup: " + detailsMap.get("timesConfigReplicated")); + out.println("Times Config Files Replicated Since Startup: " + slave.get("timesConfigReplicated")); %>
<% - if (detailsMap.get("nextExecutionAt") != null) - if (detailsMap.get("nextExecutionAt") != "") - out.println("Next Replication Cycle At: " + detailsMap.get("nextExecutionAt")); - else if ("true".equals(detailsMap.get("isPollingDisabled"))) + if (slave.get("nextExecutionAt") != null) + if (slave.get("nextExecutionAt") != "") + out.println("Next Replication Cycle At: " + slave.get("nextExecutionAt")); + else if ("true".equals(slave.get("isPollingDisabled"))) out.println("Next Replication Cycle At: Polling disabled."); else { - NamedList nl1 = (NamedList) detailsMap.get("masterDetails"); - out.println("Next Replication Cycle At: After " + nl1.get("replicateAfter") + " on master."); + NamedList nl1 = (NamedList) slave.get("masterDetails"); + if(nl1 != null){ + NamedList nl2 = (NamedList) nl1.get("master"); + if(nl2 != null) + out.println("Next Replication Cycle At: After " + nl2.get("replicateAfter") + " on master."); + } } %>
Current Replication Status - <%out.println("Start Time: " + detailsMap.get("replicationStartTime"));%> + <%out.println("Start Time: " + slave.get("replicationStartTime"));%>
<% - out.println("Files Downloaded: " + detailsMap.get("numFilesDownloaded") + " / " + detailsMap.get("numFilesToDownload"));%> + out.println("Files Downloaded: " + slave.get("numFilesDownloaded") + " / " + slave.get("numFilesToDownload"));%>
<% - out.println("Downloaded: " + detailsMap.get("bytesDownloaded") + " / " + detailsMap.get("bytesToDownload") + " [" + detailsMap.get("totalPercent") + "%]");%> + out.println("Downloaded: " + slave.get("bytesDownloaded") + " / " + slave.get("bytesToDownload") + " [" + slave.get("totalPercent") + "%]");%>
<% - out.println("Downloading File: " + detailsMap.get("currentFile") + ", Downloaded: " + detailsMap.get("currentFileSizeDownloaded") + " / " + detailsMap.get("currentFileSize") + " [" + detailsMap.get("currentFileSizePercent") + "%]");%> + out.println("Downloading File: " + slave.get("currentFile") + ", Downloaded: " + slave.get("currentFileSizeDownloaded") + " / " + slave.get("currentFileSize") + " [" + slave.get("currentFileSizePercent") + "%]");%>
<% - out.println("Time Elapsed: " + detailsMap.get("timeElapsed") + ", Estimated Time Remaining: " + detailsMap.get("timeRemaining") + ", Speed: " + detailsMap.get("downloadSpeed") + "/s");%> + out.println("Time Elapsed: " + slave.get("timeElapsed") + ", Estimated Time Remaining: " + slave.get("timeRemaining") + ", Speed: " + slave.get("downloadSpeed") + "/s");%>